@modelform/react-native 0.16.0 → 0.18.0

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.
@@ -664,7 +664,80 @@ function formatDate(ms, format3 = "YYYY-MM-DD HH:mm:ss") {
664
664
  };
665
665
  return format3.replace(/YYYY|YY|MM|DD|HH|mm|ss|SSS/g, (t) => tokens[t]);
666
666
  }
667
+ var operandName = (o) => o == null ? void 0 : typeof o === "object" ? _optionalChain([(_nullishCoalesce(_optionalChain([o, 'access', _70 => _70.matcher, 'optionalAccess', _71 => _71.options]), () => ( o.fixed))), 'optionalAccess', _72 => _72.toString, 'call', _73 => _73()]) : String(o);
668
+ var OPERATORS = {
669
+ "+": (a, b) => a + b,
670
+ "-": (a, b) => a - b,
671
+ "*": (a, b) => a * b,
672
+ "/": (a, b) => a / b,
673
+ "%": (a, b) => a % b,
674
+ "^": (a, b) => a ** b
675
+ };
676
+ var ROW_REDUCERS = {
677
+ sum: { label: "Total", fn: (vs) => vs.length ? vs.reduce((a, b) => a + b, 0) : null },
678
+ mean: { label: "Mean", fn: (vs) => vs.length ? vs.reduce((a, b) => a + b, 0) / vs.length : null },
679
+ min: { label: "Min", fn: (vs) => vs.length ? Math.min(...vs) : null },
680
+ max: { label: "Max", fn: (vs) => vs.length ? Math.max(...vs) : null },
681
+ first: { label: "First", fn: (vs) => _nullishCoalesce(vs[0], () => ( null)) },
682
+ last: { label: "Last", fn: (vs) => _nullishCoalesce(vs.at(-1), () => ( null)) },
683
+ count: { label: "Count", fn: (vs) => vs.length },
684
+ range: { label: "Range", fn: (vs) => vs.length ? Math.max(...vs) - Math.min(...vs) : null }
685
+ };
686
+ var asNumber = (v) => {
687
+ if (v == null || v === "" || typeof v === "boolean") return v === true ? 1 : v === false ? 0 : null;
688
+ const n = Number(v);
689
+ return Number.isFinite(n) ? n : null;
690
+ };
691
+ function calculate(frame, multiple, options) {
692
+ const rows = _nullishCoalesce(_optionalChain([frame, 'access', _74 => _74.fields, 'access', _75 => _75[0], 'optionalAccess', _76 => _76.values, 'access', _77 => _77.length]), () => ( 0));
693
+ const find = (name) => frame.fields.find((f) => f.name === name || fieldDisplayName(f, frame, multiple) === name);
694
+ const mode = _nullishCoalesce(options.mode, () => ( "reduceRow"));
695
+ if (mode === "binary") {
696
+ const { left, right, operator = "*" } = _nullishCoalesce(options.binary, () => ( {}));
697
+ const op = OPERATORS[operator];
698
+ const [l, r] = [operandName(left), operandName(right)];
699
+ if (!op || l == null || r == null) return;
700
+ const side = (name) => {
701
+ const f = find(name);
702
+ if (f) return (i) => asNumber(f.values[i]);
703
+ const n = asNumber(name);
704
+ return n == null ? void 0 : () => n;
705
+ };
706
+ const [a, b] = [side(l), side(r)];
707
+ if (!a || !b) return;
708
+ const values = Array.from({ length: rows }, (_, i) => {
709
+ const [x, y] = [a(i), b(i)];
710
+ if (x == null || y == null) return null;
711
+ const v = op(x, y);
712
+ return Number.isFinite(v) ? v : null;
713
+ });
714
+ return { name: options.alias || `${l} ${operator} ${r}`, type: "number", values };
715
+ }
716
+ if (mode === "reduceRow") {
717
+ const { reducer = "sum", include } = _nullishCoalesce(options.reduce, () => ( {}));
718
+ const red = ROW_REDUCERS[reducer];
719
+ if (!red) return;
720
+ const fields = _optionalChain([include, 'optionalAccess', _78 => _78.length]) ? include.map(find).filter((f) => !!f) : frame.fields.filter((f) => f.type === "number");
721
+ if (!fields.length) return;
722
+ const values = Array.from({ length: rows }, (_, i) => red.fn(fields.map((f) => asNumber(f.values[i])).filter((v) => v != null)));
723
+ return { name: options.alias || red.label, type: "number", values };
724
+ }
725
+ }
667
726
  var TRANSFORMERS = {
727
+ // A field computed per row: from two fields, or a field and a number (binary), or across fields
728
+ // (reduceRow). Several frames are joined on time first, as Grafana does, so the entries of one
729
+ // Save (which share a time) meet in one row: yield ÷ dose per shot. A row missing a value, or a
730
+ // division by zero, gives null.
731
+ calculateField: (frames, options) => {
732
+ const joined = frames.length > 1 ? TRANSFORMERS.joinByField(frames, {}) : frames;
733
+ const multiple = joined.length > 1;
734
+ return joined.map((frame) => {
735
+ const field2 = calculate(frame, multiple, options);
736
+ if (!field2) return frame;
737
+ const time = frame.fields.find((f) => f.type === "time");
738
+ return { ...frame, fields: options.replaceFields ? [...time ? [time] : [], field2] : [...frame.fields, field2] };
739
+ });
740
+ },
668
741
  convertFieldType: (frames, { conversions = [] }) => frames.map((frame) => ({
669
742
  ...frame,
670
743
  fields: frame.fields.map((f) => {
@@ -672,7 +745,7 @@ var TRANSFORMERS = {
672
745
  const c = conversions.find(
673
746
  (c2) => c2.targetField === f.name || c2.targetField === name
674
747
  );
675
- return _optionalChain([c, 'optionalAccess', _70 => _70.destinationType]) ? convert(f, c.destinationType, c) : f;
748
+ return _optionalChain([c, 'optionalAccess', _79 => _79.destinationType]) ? convert(f, c.destinationType, c) : f;
676
749
  })
677
750
  })),
678
751
  // Long rows (row, column, value) to a table with one row per row value and one column per column value, each
@@ -734,7 +807,7 @@ var TRANSFORMERS = {
734
807
  filterFieldsByName: (frames, { include, exclude }) => {
735
808
  const inc = nameMatcher(include);
736
809
  const exc = nameMatcher(exclude);
737
- return mapFields(frames, (fields) => fields.filter((f) => (!inc || inc(f.name)) && !_optionalChain([exc, 'optionalCall', _71 => _71(f.name)])));
810
+ return mapFields(frames, (fields) => fields.filter((f) => (!inc || inc(f.name)) && !_optionalChain([exc, 'optionalCall', _80 => _80(f.name)])));
738
811
  },
739
812
  organize: (frames, { excludeByName = {}, indexByName = {}, renameByName = {} }) => mapFields(
740
813
  frames,
@@ -753,7 +826,7 @@ function applyTransformations(frames, transformations) {
753
826
  // src/core/datasource.ts
754
827
  var MIXED = "-- Mixed --";
755
828
  var DASHBOARD_DS = "-- Dashboard --";
756
- var isDashboardRef = (ref) => _optionalChain([ref, 'optionalAccess', _72 => _72.uid]) === DASHBOARD_DS;
829
+ var isDashboardRef = (ref) => _optionalChain([ref, 'optionalAccess', _81 => _81.uid]) === DASHBOARD_DS;
757
830
  function dashboardSourceIds(dashboard) {
758
831
  const ids = /* @__PURE__ */ new Set();
759
832
  for (const p of allPanels(dashboard.panels))
@@ -766,7 +839,7 @@ function* allPanels(panels) {
766
839
  yield* allPanels(_nullishCoalesce(p.panels, () => ( [])));
767
840
  }
768
841
  }
769
- var panelHasQueries = (panel) => !!_optionalChain([panel, 'access', _73 => _73.targets, 'optionalAccess', _74 => _74.some, 'call', _75 => _75((t) => !t.hide)]) && panel.type !== "text" && panel.type !== "row";
842
+ var panelHasQueries = (panel) => !!_optionalChain([panel, 'access', _82 => _82.targets, 'optionalAccess', _83 => _83.some, 'call', _84 => _84((t) => !t.hide)]) && panel.type !== "text" && panel.type !== "row";
770
843
  async function queryPanel(panel, ctx, signal) {
771
844
  return applyTransformations(await sharedQuery(panel, ctx, signal), panel.transformations);
772
845
  }
@@ -788,20 +861,20 @@ async function rawQuery(panel, ctx, signal, seen) {
788
861
  const maxDataPoints = _nullishCoalesce(panel.maxDataPoints, () => ( Math.max(100, Math.round(ctx.widthPx))));
789
862
  const minInterval = typeof panel.interval === "string" && panel.interval ? safeDuration(panel.interval) : void 0;
790
863
  const intervalMs = calculateInterval(ctx.range, maxDataPoints, minInterval);
791
- const interp = { values: ctx.variables, info: ctx.variableInfo, scoped: panel.scopedVars, range: ctx.range, intervalMs, timezone: _nullishCoalesce(ctx.timezone, () => ( _optionalChain([ctx, 'access', _76 => _76.dashboard, 'optionalAccess', _77 => _77.timezone]))) };
864
+ const interp = { values: ctx.variables, info: ctx.variableInfo, scoped: panel.scopedVars, range: ctx.range, intervalMs, timezone: _nullishCoalesce(ctx.timezone, () => ( _optionalChain([ctx, 'access', _85 => _85.dashboard, 'optionalAccess', _86 => _86.timezone]))) };
792
865
  const panelRef = normalizeRef(panel.datasource);
793
866
  const groups = /* @__PURE__ */ new Map();
794
867
  const reused = [];
795
868
  for (const target of _nullishCoalesce(panel.targets, () => ( []))) {
796
869
  if (target.hide) continue;
797
- const fallback = _optionalChain([panelRef, 'optionalAccess', _78 => _78.uid]) === MIXED ? void 0 : panelRef;
870
+ const fallback = _optionalChain([panelRef, 'optionalAccess', _87 => _87.uid]) === MIXED ? void 0 : panelRef;
798
871
  const ref = interpolateDeep(_nullishCoalesce(normalizeRef(target.datasource), () => ( fallback)), interp);
799
872
  if (isDashboardRef(ref)) {
800
873
  reused.push(reusePanel(panel, target, ctx, signal, seen));
801
874
  continue;
802
875
  }
803
876
  const ds = ctx.resolve(ref);
804
- const resolved = { ...interpolateDeep(target, { ...interp, datasourceType: _optionalChain([ref, 'optionalAccess', _79 => _79.type]) }), datasource: ref };
877
+ const resolved = { ...interpolateDeep(target, { ...interp, datasourceType: _optionalChain([ref, 'optionalAccess', _88 => _88.type]) }), datasource: ref };
805
878
  groups.set(ds, [..._nullishCoalesce(groups.get(ds), () => ( [])), resolved]);
806
879
  }
807
880
  const results = await Promise.all([
@@ -834,10 +907,10 @@ function safeDuration(s) {
834
907
 
835
908
  // src/core/resolveVariables.ts
836
909
  function refreshedVariables(dashboard, on) {
837
- return (_nullishCoalesce(_optionalChain([dashboard, 'access', _80 => _80.templating, 'optionalAccess', _81 => _81.list]), () => ( []))).filter((v) => v.type === "query" && (on === "load" ? (_nullishCoalesce(v.refresh, () => ( 0))) >= 1 : v.refresh === 2)).map((v) => v.name);
910
+ return (_nullishCoalesce(_optionalChain([dashboard, 'access', _89 => _89.templating, 'optionalAccess', _90 => _90.list]), () => ( []))).filter((v) => v.type === "query" && (on === "load" ? (_nullishCoalesce(v.refresh, () => ( 0))) >= 1 : v.refresh === 2)).map((v) => v.name);
838
911
  }
839
912
  function variableDependents(dashboard, names) {
840
- const list = _nullishCoalesce(_optionalChain([dashboard, 'access', _82 => _82.templating, 'optionalAccess', _83 => _83.list]), () => ( []));
913
+ const list = _nullishCoalesce(_optionalChain([dashboard, 'access', _91 => _91.templating, 'optionalAccess', _92 => _92.list]), () => ( []));
841
914
  const all = list.map((v) => v.name);
842
915
  const refs = new Map(list.map((v) => [v.name, variableReferences(v, all)]));
843
916
  const out = /* @__PURE__ */ new Set();
@@ -854,7 +927,7 @@ function variableDependents(dashboard, names) {
854
927
  return out;
855
928
  }
856
929
  function variableOrder(dashboard) {
857
- const list = _nullishCoalesce(_optionalChain([dashboard, 'access', _84 => _84.templating, 'optionalAccess', _85 => _85.list]), () => ( []));
930
+ const list = _nullishCoalesce(_optionalChain([dashboard, 'access', _93 => _93.templating, 'optionalAccess', _94 => _94.list]), () => ( []));
858
931
  const all = list.map((v) => v.name);
859
932
  const deps = new Map(list.map((v) => [v.name, variableReferences(v, all)]));
860
933
  const order = [];
@@ -884,13 +957,13 @@ async function resolveVariables(dashboard, opts) {
884
957
  const ref = interpolateDeep(normalizeRef(v.datasource), { values, info });
885
958
  const ds = opts.resolve(ref);
886
959
  if (!ds.variableOptions) continue;
887
- const query = interpolateDeep(v.query, { values, info, range: opts.range, datasourceType: _optionalChain([ref, 'optionalAccess', _86 => _86.type]), timezone: dashboard.timezone });
960
+ const query = interpolateDeep(v.query, { values, info, range: opts.range, datasourceType: _optionalChain([ref, 'optionalAccess', _95 => _95.type]), timezone: dashboard.timezone });
888
961
  let raw;
889
962
  try {
890
963
  raw = await ds.variableOptions({ query, datasource: ref, range: opts.range }, opts.signal);
891
964
  } catch (e) {
892
- if (_optionalChain([opts, 'access', _87 => _87.signal, 'optionalAccess', _88 => _88.aborted])) throw e;
893
- errors[v.name] = String(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _89 => _89.message]), () => ( e)));
965
+ if (_optionalChain([opts, 'access', _96 => _96.signal, 'optionalAccess', _97 => _97.aborted])) throw e;
966
+ errors[v.name] = String(_nullishCoalesce(_optionalChain([e, 'optionalAccess', _98 => _98.message]), () => ( e)));
894
967
  continue;
895
968
  }
896
969
  if (!raw) continue;
@@ -989,13 +1062,13 @@ var INPUT_OPTION_KEYS = {
989
1062
  };
990
1063
  var INPUT_TYPES = Object.keys(INPUT_OPTION_KEYS);
991
1064
  var isInputType = (type) => type in INPUT_OPTION_KEYS;
992
- var isInputPanel = (p) => p.type.startsWith("input-") && !!_optionalChain([p, 'access', _90 => _90.options, 'optionalAccess', _91 => _91.metric]);
1065
+ var isInputPanel = (p) => p.type.startsWith("input-") && !!_optionalChain([p, 'access', _99 => _99.options, 'optionalAccess', _100 => _100.metric]);
993
1066
  var INPUT_GROUP = "input-group";
994
1067
  var isFormPanelType = (type) => isInputType(type) || type === INPUT_GROUP;
995
- var isInputGroup = (p) => p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _92 => _92.options, 'optionalAccess', _93 => _93.fields]));
1068
+ var isInputGroup = (p) => p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _101 => _101.options, 'optionalAccess', _102 => _102.fields]));
996
1069
  var GROUP_FIELD_TYPES = INPUT_TYPES.filter((t) => t !== "input-counter");
997
1070
  function groupFields(group) {
998
- return group.options.fields.filter((f) => f && isInputType(f.type) && f.type !== "input-counter" && typeof _optionalChain([f, 'access', _94 => _94.options, 'optionalAccess', _95 => _95.metric]) === "string" && f.options.metric).map(({ span, ...f }) => ({ ...f, gridPos: { x: 0, y: 0, w: _nullishCoalesce(span, () => ( 24)), h: 3 } }));
1071
+ return group.options.fields.filter((f) => f && isInputType(f.type) && f.type !== "input-counter" && typeof _optionalChain([f, 'access', _103 => _103.options, 'optionalAccess', _104 => _104.metric]) === "string" && f.options.metric).map(({ span, ...f }) => ({ ...f, gridPos: { x: 0, y: 0, w: _nullishCoalesce(span, () => ( 24)), h: 3 } }));
999
1072
  }
1000
1073
  var panelsOf = (dashboard) => dashboard.panels.flatMap((p) => p.type === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]);
1001
1074
  function inputPanels(dashboard) {
@@ -1087,7 +1160,7 @@ function sameSave(entry, candidates) {
1087
1160
  function inputProblem(panel, value) {
1088
1161
  const o = panel.options;
1089
1162
  const empty = value == null || value === "" || Array.isArray(value) && !value.length;
1090
- if (empty) return o.required && _optionalChain([INPUT_OPTION_KEYS, 'access', _96 => _96[panel.type], 'optionalAccess', _97 => _97.includes, 'call', _98 => _98("required")]) ? "Required" : void 0;
1163
+ if (empty) return o.required && _optionalChain([INPUT_OPTION_KEYS, 'access', _105 => _105[panel.type], 'optionalAccess', _106 => _106.includes, 'call', _107 => _107("required")]) ? "Required" : void 0;
1091
1164
  if ((panel.type === "input-number" || panel.type === "input-slider") && typeof value === "number") {
1092
1165
  const unit = o.unit ? ` ${o.unit}` : "";
1093
1166
  if (typeof o.min === "number" && value < o.min) return `At least ${o.min}${unit}`;
@@ -1105,8 +1178,8 @@ function textSuggestions(entries, query, limit = 8) {
1105
1178
  const seen = /* @__PURE__ */ new Set();
1106
1179
  const out = [];
1107
1180
  for (const e of [...entries].sort((a, b) => b.ts - a.ts)) {
1108
- const text = _optionalChain([e, 'access', _99 => _99.text, 'optionalAccess', _100 => _100.trim, 'call', _101 => _101()]);
1109
- const key = _optionalChain([text, 'optionalAccess', _102 => _102.toLowerCase, 'call', _103 => _103()]);
1181
+ const text = _optionalChain([e, 'access', _108 => _108.text, 'optionalAccess', _109 => _109.trim, 'call', _110 => _110()]);
1182
+ const key = _optionalChain([text, 'optionalAccess', _111 => _111.toLowerCase, 'call', _112 => _112()]);
1110
1183
  if (!text || !key || seen.has(key)) continue;
1111
1184
  seen.add(key);
1112
1185
  if (key === q) continue;
@@ -1118,7 +1191,7 @@ function textSuggestions(entries, query, limit = 8) {
1118
1191
  }
1119
1192
  function entriesSavedWith(entries, metric, withMetric, withText) {
1120
1193
  const want = withText.trim().toLowerCase();
1121
- const matches = entries.filter((e) => e.metric === withMetric && _optionalChain([e, 'access', _104 => _104.text, 'optionalAccess', _105 => _105.trim, 'call', _106 => _106(), 'access', _107 => _107.toLowerCase, 'call', _108 => _108()]) === want);
1194
+ const matches = entries.filter((e) => e.metric === withMetric && _optionalChain([e, 'access', _113 => _113.text, 'optionalAccess', _114 => _114.trim, 'call', _115 => _115(), 'access', _116 => _116.toLowerCase, 'call', _117 => _117()]) === want);
1122
1195
  const saves = new Set(matches.map((e) => e.save).filter(Boolean));
1123
1196
  const times = new Set(matches.filter((e) => !e.save).map((e) => e.ts));
1124
1197
  return entries.filter((e) => e.metric === metric && (e.save ? saves.has(e.save) : times.has(e.ts)));
@@ -1227,11 +1300,11 @@ function fromNow(t) {
1227
1300
  return diff >= 0 ? `${text} ago` : `in ${text}`;
1228
1301
  }
1229
1302
  function thresholdStep(value, config = {}) {
1230
- const steps = _optionalChain([config, 'access', _109 => _109.thresholds, 'optionalAccess', _110 => _110.steps]);
1231
- if (!_optionalChain([steps, 'optionalAccess', _111 => _111.length])) return void 0;
1303
+ const steps = _optionalChain([config, 'access', _118 => _118.thresholds, 'optionalAccess', _119 => _119.steps]);
1304
+ if (!_optionalChain([steps, 'optionalAccess', _120 => _120.length])) return void 0;
1232
1305
  if (value == null) return steps[0];
1233
1306
  let v = value;
1234
- if (_optionalChain([config, 'access', _112 => _112.thresholds, 'optionalAccess', _113 => _113.mode]) === "percentage") {
1307
+ if (_optionalChain([config, 'access', _121 => _121.thresholds, 'optionalAccess', _122 => _122.mode]) === "percentage") {
1235
1308
  const min = _nullishCoalesce(config.min, () => ( 0));
1236
1309
  const max = _nullishCoalesce(config.max, () => ( 100));
1237
1310
  v = (value - min) / (max - min || 1) * 100;
@@ -1291,12 +1364,12 @@ var SERIES_PALETTE = {
1291
1364
  function seriesColor(index, scheme, config) {
1292
1365
  const palette = SERIES_PALETTE[scheme];
1293
1366
  const color = palette[index % palette.length];
1294
- if (_optionalChain([config, 'optionalAccess', _114 => _114.color, 'optionalAccess', _115 => _115.mode]) === "fixed") return resolveColor(config.color.fixedColor, color);
1367
+ if (_optionalChain([config, 'optionalAccess', _123 => _123.color, 'optionalAccess', _124 => _124.mode]) === "fixed") return resolveColor(config.color.fixedColor, color);
1295
1368
  return color;
1296
1369
  }
1297
1370
  function mappedResult(value, config = {}) {
1298
1371
  for (const m of _nullishCoalesce(config.mappings, () => ( []))) {
1299
- if (!_optionalChain([m, 'optionalAccess', _116 => _116.options]) || typeof m.options !== "object") continue;
1372
+ if (!_optionalChain([m, 'optionalAccess', _125 => _125.options]) || typeof m.options !== "object") continue;
1300
1373
  if (m.type === "value") {
1301
1374
  const hit = m.options[String(value)];
1302
1375
  if (hit) return hit;
@@ -1309,7 +1382,7 @@ function mappedResult(value, config = {}) {
1309
1382
  if (value == null) continue;
1310
1383
  const re = regexOf(pattern);
1311
1384
  const match = re && String(value).match(re);
1312
- if (match) return { ...result, text: _optionalChain([result, 'access', _117 => _117.text, 'optionalAccess', _118 => _118.replace, 'call', _119 => _119(/\$(\d+)/g, (_, n) => _nullishCoalesce(match[Number(n)], () => ( "")))]) };
1385
+ if (match) return { ...result, text: _optionalChain([result, 'access', _126 => _126.text, 'optionalAccess', _127 => _127.replace, 'call', _128 => _128(/\$(\d+)/g, (_, n) => _nullishCoalesce(match[Number(n)], () => ( "")))]) };
1313
1386
  } else if (m.type === "special") {
1314
1387
  const { match, result } = m.options;
1315
1388
  const isNull = value == null;
@@ -1329,7 +1402,7 @@ function regexOf(pattern) {
1329
1402
  }
1330
1403
  }
1331
1404
  function formatDisplay(value, config = {}) {
1332
- return _nullishCoalesce(_optionalChain([mappedResult, 'call', _120 => _120(value, config), 'optionalAccess', _121 => _121.text]), () => ( formatValue(value, config)));
1405
+ return _nullishCoalesce(_optionalChain([mappedResult, 'call', _129 => _129(value, config), 'optionalAccess', _130 => _130.text]), () => ( formatValue(value, config)));
1333
1406
  }
1334
1407
  var CONTINUOUS = {
1335
1408
  "continuous-GrYlRd": ["#73BF69", "#FADE2A", "#F2495C"],
@@ -1349,14 +1422,14 @@ function mix(a, b, t) {
1349
1422
  return `#${out.map((v) => v.toString(16).padStart(2, "0")).join("")}`;
1350
1423
  }
1351
1424
  function valueColor(value, config, fallback, extent) {
1352
- const mapped = _optionalChain([mappedResult, 'call', _122 => _122(value, config), 'optionalAccess', _123 => _123.color]);
1425
+ const mapped = _optionalChain([mappedResult, 'call', _131 => _131(value, config), 'optionalAccess', _132 => _132.color]);
1353
1426
  if (mapped) return resolveColor(mapped, fallback);
1354
- const mode = _optionalChain([config, 'access', _124 => _124.color, 'optionalAccess', _125 => _125.mode]);
1355
- if (mode === "fixed") return resolveColor(_optionalChain([config, 'access', _126 => _126.color, 'optionalAccess', _127 => _127.fixedColor]), fallback);
1427
+ const mode = _optionalChain([config, 'access', _133 => _133.color, 'optionalAccess', _134 => _134.mode]);
1428
+ if (mode === "fixed") return resolveColor(_optionalChain([config, 'access', _135 => _135.color, 'optionalAccess', _136 => _136.fixedColor]), fallback);
1356
1429
  const stops = mode ? CONTINUOUS[mode] : void 0;
1357
1430
  if (stops) {
1358
- const min = _nullishCoalesce(_nullishCoalesce(config.min, () => ( _optionalChain([extent, 'optionalAccess', _128 => _128[0]]))), () => ( 0));
1359
- const max = _nullishCoalesce(_nullishCoalesce(config.max, () => ( _optionalChain([extent, 'optionalAccess', _129 => _129[1]]))), () => ( 1));
1431
+ const min = _nullishCoalesce(_nullishCoalesce(config.min, () => ( _optionalChain([extent, 'optionalAccess', _137 => _137[0]]))), () => ( 0));
1432
+ const max = _nullishCoalesce(_nullishCoalesce(config.max, () => ( _optionalChain([extent, 'optionalAccess', _138 => _138[1]]))), () => ( 1));
1360
1433
  const t = value == null ? 0 : Math.min(1, Math.max(0, (value - min) / (max - min || 1)));
1361
1434
  const at = t * (stops.length - 1);
1362
1435
  const i = Math.min(Math.floor(at), stops.length - 2);
@@ -1371,8 +1444,8 @@ function valueColor(value, config, fallback, extent) {
1371
1444
 
1372
1445
  // src/core/fieldconfig.ts
1373
1446
  function resolveFieldConfig(panel, field2, frame, displayName) {
1374
- let config = mergeConfig(_nullishCoalesce(_optionalChain([panel, 'access', _130 => _130.fieldConfig, 'optionalAccess', _131 => _131.defaults]), () => ( {})), _nullishCoalesce(field2.config, () => ( {})));
1375
- for (const o of _nullishCoalesce(_optionalChain([panel, 'access', _132 => _132.fieldConfig, 'optionalAccess', _133 => _133.overrides]), () => ( []))) {
1447
+ let config = mergeConfig(_nullishCoalesce(_optionalChain([panel, 'access', _139 => _139.fieldConfig, 'optionalAccess', _140 => _140.defaults]), () => ( {})), _nullishCoalesce(field2.config, () => ( {})));
1448
+ for (const o of _nullishCoalesce(_optionalChain([panel, 'access', _141 => _141.fieldConfig, 'optionalAccess', _142 => _142.overrides]), () => ( []))) {
1376
1449
  if (!fieldMatches(o.matcher, field2, frame, displayName)) continue;
1377
1450
  for (const p of o.properties) if (p.value !== void 0) config = setPath(config, p.id, p.value);
1378
1451
  }
@@ -1457,7 +1530,7 @@ var GrafanaClient = class {
1457
1530
  }
1458
1531
  search(query = "", options = {}) {
1459
1532
  const params = new URLSearchParams({ type: _nullishCoalesce(options.type, () => ( "dash-db")), query, limit: String(_nullishCoalesce(options.limit, () => ( 100))) });
1460
- _optionalChain([options, 'access', _134 => _134.tag, 'optionalAccess', _135 => _135.forEach, 'call', _136 => _136((t) => params.append("tag", t))]);
1533
+ _optionalChain([options, 'access', _143 => _143.tag, 'optionalAccess', _144 => _144.forEach, 'call', _145 => _145((t) => params.append("tag", t))]);
1461
1534
  return this.request(`/api/search?${params}`);
1462
1535
  }
1463
1536
  async dashboard(uid) {
@@ -1466,7 +1539,7 @@ var GrafanaClient = class {
1466
1539
  }
1467
1540
  /** Resolve name / "${DS_X}" placeholder / missing refs to a concrete {type, uid}. */
1468
1541
  async resolveRef(ref) {
1469
- if (_optionalChain([ref, 'optionalAccess', _137 => _137.uid]) && !isPlaceholder(ref.uid) && ref.uid !== "default") {
1542
+ if (_optionalChain([ref, 'optionalAccess', _146 => _146.uid]) && !isPlaceholder(ref.uid) && ref.uid !== "default") {
1470
1543
  if (ref.type) return ref;
1471
1544
  }
1472
1545
  this.settings ??= this.request("/api/frontend/settings");
@@ -1478,11 +1551,11 @@ var GrafanaClient = class {
1478
1551
  throw e;
1479
1552
  }
1480
1553
  const all = Object.values(settings.datasources);
1481
- const sameType = (type) => type === _optionalChain([ref, 'optionalAccess', _138 => _138.type]) || TYPE_ALIASES[type] === _optionalChain([ref, 'optionalAccess', _139 => _139.type]) || TYPE_ALIASES[_nullishCoalesce(_optionalChain([ref, 'optionalAccess', _140 => _140.type]), () => ( ""))] === type;
1482
- const found = _optionalChain([ref, 'optionalAccess', _141 => _141.uid]) && !isPlaceholder(ref.uid) && all.find((d) => d.uid === ref.uid || d.name === ref.uid) || _optionalChain([ref, 'optionalAccess', _142 => _142.type]) && all.find((d) => sameType(d.type) && d.isDefault) || _optionalChain([ref, 'optionalAccess', _143 => _143.type]) && all.find((d) => sameType(d.type)) || // A ref that names a type this Grafana doesn't have must not run against some other datasource.
1483
- (_optionalChain([ref, 'optionalAccess', _144 => _144.type]) ? void 0 : settings.datasources[settings.defaultDatasource]);
1554
+ const sameType = (type) => type === _optionalChain([ref, 'optionalAccess', _147 => _147.type]) || TYPE_ALIASES[type] === _optionalChain([ref, 'optionalAccess', _148 => _148.type]) || TYPE_ALIASES[_nullishCoalesce(_optionalChain([ref, 'optionalAccess', _149 => _149.type]), () => ( ""))] === type;
1555
+ const found = _optionalChain([ref, 'optionalAccess', _150 => _150.uid]) && !isPlaceholder(ref.uid) && all.find((d) => d.uid === ref.uid || d.name === ref.uid) || _optionalChain([ref, 'optionalAccess', _151 => _151.type]) && all.find((d) => sameType(d.type) && d.isDefault) || _optionalChain([ref, 'optionalAccess', _152 => _152.type]) && all.find((d) => sameType(d.type)) || // A ref that names a type this Grafana doesn't have must not run against some other datasource.
1556
+ (_optionalChain([ref, 'optionalAccess', _153 => _153.type]) ? void 0 : settings.datasources[settings.defaultDatasource]);
1484
1557
  if (!found) {
1485
- throw new GrafanaError(_optionalChain([ref, 'optionalAccess', _145 => _145.type]) ? `No ${ref.type} datasource in this Grafana` : `No datasource matches ${JSON.stringify(ref)}`);
1558
+ throw new GrafanaError(_optionalChain([ref, 'optionalAccess', _154 => _154.type]) ? `No ${ref.type} datasource in this Grafana` : `No datasource matches ${JSON.stringify(ref)}`);
1486
1559
  }
1487
1560
  return { uid: found.uid, type: found.type };
1488
1561
  }
@@ -1544,11 +1617,11 @@ var GrafanaDataSource = class {
1544
1617
  };
1545
1618
  var FIELD_TYPES = ["time", "number", "string", "boolean"];
1546
1619
  function fromWire(frame) {
1547
- const fields = _nullishCoalesce(_optionalChain([frame, 'access', _146 => _146.schema, 'optionalAccess', _147 => _147.fields]), () => ( []));
1548
- const values = _nullishCoalesce(_optionalChain([frame, 'access', _148 => _148.data, 'optionalAccess', _149 => _149.values]), () => ( []));
1620
+ const fields = _nullishCoalesce(_optionalChain([frame, 'access', _155 => _155.schema, 'optionalAccess', _156 => _156.fields]), () => ( []));
1621
+ const values = _nullishCoalesce(_optionalChain([frame, 'access', _157 => _157.data, 'optionalAccess', _158 => _158.values]), () => ( []));
1549
1622
  return {
1550
- name: _optionalChain([frame, 'access', _150 => _150.schema, 'optionalAccess', _151 => _151.name]),
1551
- refId: _optionalChain([frame, 'access', _152 => _152.schema, 'optionalAccess', _153 => _153.refId]),
1623
+ name: _optionalChain([frame, 'access', _159 => _159.schema, 'optionalAccess', _160 => _160.name]),
1624
+ refId: _optionalChain([frame, 'access', _161 => _161.schema, 'optionalAccess', _162 => _162.refId]),
1552
1625
  fields: fields.map((f, i) => ({
1553
1626
  name: f.name,
1554
1627
  type: FIELD_TYPES.includes(f.type) ? f.type : "other",
@@ -1771,7 +1844,7 @@ function spokenValue(panel, said, current = null, choices2) {
1771
1844
  const min = _nullishCoalesce(o.min, () => ( 0));
1772
1845
  const max = _nullishCoalesce(o.max, () => ( 10));
1773
1846
  const step = _nullishCoalesce(o.step, () => ( 1));
1774
- if (_optionalChain([o, 'access', _154 => _154.labels, 'optionalAccess', _155 => _155.length])) {
1847
+ if (_optionalChain([o, 'access', _163 => _163.labels, 'optionalAccess', _164 => _164.length])) {
1775
1848
  const [hit] = matchChoices(text, o.labels.map((label, i) => ({ label, value: i })));
1776
1849
  if (typeof hit === "number") {
1777
1850
  const raw = o.labels.length === 1 ? min : min + hit / (o.labels.length - 1) * (max - min);
@@ -1822,13 +1895,13 @@ function fillForm(dashboard, choices2 = {}) {
1822
1895
  let field2;
1823
1896
  switch (p.type) {
1824
1897
  case "input-number":
1825
- field2 = { ...base, type: "number", unit: o.unit, min: o.min, max: o.max };
1898
+ field2 = { ...base, type: "number", unit: o.unit, min: o.min, max: o.max, step: _nullishCoalesce(o.step, () => ( 1)) };
1826
1899
  break;
1827
1900
  case "input-rating":
1828
- field2 = { ...base, type: "number", min: Math.round(_nullishCoalesce(o.min, () => ( 1))), max: Math.round(_nullishCoalesce(o.max, () => ( 5))) };
1901
+ field2 = { ...base, type: "number", min: Math.round(_nullishCoalesce(o.min, () => ( 1))), max: Math.round(_nullishCoalesce(o.max, () => ( 5))), step: 1 };
1829
1902
  break;
1830
1903
  case "input-slider":
1831
- field2 = { ...base, type: "number", unit: o.unit, min: _nullishCoalesce(o.min, () => ( 0)), max: _nullishCoalesce(o.max, () => ( 10)), choices: _optionalChain([o, 'access', _156 => _156.labels, 'optionalAccess', _157 => _157.length]) ? o.labels : void 0 };
1904
+ field2 = { ...base, type: "number", unit: o.unit, min: _nullishCoalesce(o.min, () => ( 0)), max: _nullishCoalesce(o.max, () => ( 10)), step: _nullishCoalesce(o.step, () => ( 1)), choices: _optionalChain([o, 'access', _165 => _165.labels, 'optionalAccess', _166 => _166.length]) ? o.labels : void 0 };
1832
1905
  break;
1833
1906
  case "input-duration":
1834
1907
  field2 = { ...base, type: "duration" };
@@ -1856,8 +1929,11 @@ function fillForm(dashboard, choices2 = {}) {
1856
1929
  function describe(f) {
1857
1930
  const range = f.min != null && f.max != null ? `, from ${f.min} to ${f.max}` : f.min != null ? `, ${f.min} or more` : f.max != null ? `, at most ${f.max}` : "";
1858
1931
  switch (f.type) {
1859
- case "number":
1860
- return `a number${f.unit ? ` in ${f.unit}` : ""}${range}${f.choices ? ` (${f.choices.join(" \u2026 ")} along the scale)` : ""}`;
1932
+ case "number": {
1933
+ const whole = f.step === void 0 || Number.isInteger(f.step);
1934
+ const precision = whole ? "" : ` (to ${f.step})`;
1935
+ return `a ${whole ? "whole number" : "number"}${f.unit ? ` in ${f.unit}` : ""}${precision}${range}${f.choices ? ` (${f.choices.join(" \u2026 ")} along the scale)` : ""}`;
1936
+ }
1861
1937
  case "duration":
1862
1938
  return "a duration in seconds";
1863
1939
  case "choice":
@@ -1877,7 +1953,7 @@ function fillSchema(form) {
1877
1953
  switch (f.type) {
1878
1954
  case "number":
1879
1955
  case "duration":
1880
- properties[f.key] = { type: "number", description, ...f.min != null && { minimum: f.min }, ...f.max != null && { maximum: f.max } };
1956
+ properties[f.key] = { type: f.type === "number" && (f.step === void 0 || Number.isInteger(f.step)) ? "integer" : "number", description, ...f.min != null && { minimum: f.min }, ...f.max != null && { maximum: f.max } };
1881
1957
  break;
1882
1958
  case "choice":
1883
1959
  properties[f.key] = { type: "string", enum: f.choices, description };
@@ -2203,7 +2279,7 @@ function scaleValue(f, tokens, from, to) {
2203
2279
  if (!(w in SCALE_WORDS)) continue;
2204
2280
  if (is(tokens[j - 1], "not") || is(tokens[j - 2], "not")) return null;
2205
2281
  let x = SCALE_WORDS[w];
2206
- if (INTENSIFIERS.has(_nullishCoalesce(_optionalChain([tokens, 'access', _158 => _158[j - 1], 'optionalAccess', _159 => _159.text]), () => ( ""))) && x !== 0.5) x = x < 0.5 ? Math.max(0, x - 0.25) : Math.min(1, x + 0.25);
2282
+ if (INTENSIFIERS.has(_nullishCoalesce(_optionalChain([tokens, 'access', _167 => _167[j - 1], 'optionalAccess', _168 => _168.text]), () => ( ""))) && x !== 0.5) x = x < 0.5 ? Math.max(0, x - 0.25) : Math.min(1, x + 0.25);
2207
2283
  return { value: Math.round(f.min + x * (f.max - f.min)), at: j };
2208
2284
  }
2209
2285
  return null;
@@ -2220,7 +2296,7 @@ var CORRECTIONS = [["no", "wait"], ["wait"], ["sorry"], ["actually"], ["i", "mea
2220
2296
  function lastCorrection(tokens, from, to) {
2221
2297
  let last = null;
2222
2298
  for (let j = from; j < to; j++)
2223
- for (const c of CORRECTIONS) if (c.every((w, n) => _optionalChain([tokens, 'access', _160 => _160[j + n], 'optionalAccess', _161 => _161.text]) === w) && j + c.length <= to) last = j + c.length;
2299
+ for (const c of CORRECTIONS) if (c.every((w, n) => _optionalChain([tokens, 'access', _169 => _169[j + n], 'optionalAccess', _170 => _170.text]) === w) && j + c.length <= to) last = j + c.length;
2224
2300
  return last;
2225
2301
  }
2226
2302
  var LEAD = /^[\s,:;.-]*(?:(?:is|was|were|of|at|about|around|to|=)\b[\s,:;.-]*)*/i;
@@ -2292,7 +2368,7 @@ function ruleFill(form, said) {
2292
2368
  for (const f of form.fields) {
2293
2369
  const mine = named.map((h, i) => ({ h, i })).filter(({ h }) => h.key === f.key);
2294
2370
  for (const { h, i } of mine.reverse()) {
2295
- const stop = _nullishCoalesce(_optionalChain([named, 'access', _162 => _162[i + 1], 'optionalAccess', _163 => _163.start]), () => ( tokens.length));
2371
+ const stop = _nullishCoalesce(_optionalChain([named, 'access', _171 => _171[i + 1], 'optionalAccess', _172 => _172.start]), () => ( tokens.length));
2296
2372
  const nextIsToggle = !!named[i + 1] && fieldOf(named[i + 1].key).type === "boolean";
2297
2373
  const found = valueAfter(said, f, h, tokens, stop, free, nextIsToggle);
2298
2374
  if (!found) continue;
@@ -2413,7 +2489,7 @@ function buildFrames(target, entries, request, label, siblings = []) {
2413
2489
  const fill = _nullishCoalesce(target.fillZero, () => ( (aggregate === "sum" || aggregate === "count")));
2414
2490
  ({ times, values } = bucketize(rows, aggregate, bucket, request.range, fill));
2415
2491
  }
2416
- const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall', _164 => _164(labelKey, group)]), () => ( group));
2492
+ const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall', _173 => _173(labelKey, group)]), () => ( group));
2417
2493
  return {
2418
2494
  name,
2419
2495
  refId: target.refId,
@@ -2469,7 +2545,7 @@ function bucketize(rows, aggregate, bucket, range, fillZero) {
2469
2545
  const keys = fillZero ? step.range(range.from, range.to) : [...sums.keys()].sort((a, b) => a - b);
2470
2546
  const values = keys.map((k) => {
2471
2547
  const vs = sums.get(k);
2472
- return _optionalChain([vs, 'optionalAccess', _165 => _165.length]) ? reduce2(vs, aggregate) : fillZero ? 0 : null;
2548
+ return _optionalChain([vs, 'optionalAccess', _174 => _174.length]) ? reduce2(vs, aggregate) : fillZero ? 0 : null;
2473
2549
  });
2474
2550
  return { times: keys, values };
2475
2551
  }
@@ -2550,17 +2626,17 @@ function parseGazetteer(json) {
2550
2626
  };
2551
2627
  if (Array.isArray(json)) {
2552
2628
  for (const item of json) {
2553
- const lat = Number(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _166 => _166.latitude]), () => ( _optionalChain([item, 'optionalAccess', _167 => _167.lat]))));
2554
- const lon = Number(_nullishCoalesce(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _168 => _168.longitude]), () => ( _optionalChain([item, 'optionalAccess', _169 => _169.lon]))), () => ( _optionalChain([item, 'optionalAccess', _170 => _170.lng]))));
2629
+ const lat = Number(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _175 => _175.latitude]), () => ( _optionalChain([item, 'optionalAccess', _176 => _176.lat]))));
2630
+ const lon = Number(_nullishCoalesce(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _177 => _177.longitude]), () => ( _optionalChain([item, 'optionalAccess', _178 => _178.lon]))), () => ( _optionalChain([item, 'optionalAccess', _179 => _179.lng]))));
2555
2631
  if (!Number.isFinite(lat) || !Number.isFinite(lon)) continue;
2556
2632
  const p = { lon, lat };
2557
2633
  add(item.key, p);
2558
2634
  for (const k of [..._nullishCoalesce(item.keys, () => ( [])), ..._nullishCoalesce(item.keywords, () => ( []))]) add(k, p);
2559
2635
  add(item.name, p);
2560
2636
  }
2561
- } else if (_optionalChain([json, 'optionalAccess', _171 => _171.type]) === "FeatureCollection") {
2637
+ } else if (_optionalChain([json, 'optionalAccess', _180 => _180.type]) === "FeatureCollection") {
2562
2638
  for (const f of _nullishCoalesce(json.features, () => ( []))) {
2563
- const p = featurePoint(_optionalChain([f, 'optionalAccess', _172 => _172.geometry]));
2639
+ const p = featurePoint(_optionalChain([f, 'optionalAccess', _181 => _181.geometry]));
2564
2640
  if (!p) continue;
2565
2641
  add(f.id, p);
2566
2642
  for (const v of Object.values(_nullishCoalesce(f.properties, () => ( {})))) if (typeof v === "string") add(v, p);
@@ -2569,7 +2645,7 @@ function parseGazetteer(json) {
2569
2645
  return { find: (key) => _nullishCoalesce(exact.get(key), () => ( folded.get(key.toLowerCase()))) };
2570
2646
  }
2571
2647
  function featurePoint(geometry) {
2572
- if (!_optionalChain([geometry, 'optionalAccess', _173 => _173.coordinates])) return void 0;
2648
+ if (!_optionalChain([geometry, 'optionalAccess', _182 => _182.coordinates])) return void 0;
2573
2649
  if (geometry.type === "Point") {
2574
2650
  const [lon, lat] = geometry.coordinates;
2575
2651
  return Number.isFinite(lon) && Number.isFinite(lat) ? { lon, lat } : void 0;
@@ -2598,7 +2674,7 @@ function loadGazetteer(path, ds) {
2598
2674
  const json = absolute ? fetch(path).then((r) => {
2599
2675
  if (!r.ok) throw new Error(`${r.status} ${r.statusText}`);
2600
2676
  return r.json();
2601
- }) : _optionalChain([ds, 'optionalAccess', _174 => _174.publicFile]) ? ds.publicFile(path) : Promise.reject(new Error(`${path} is served by Grafana, and this dashboard has no Grafana connection`));
2677
+ }) : _optionalChain([ds, 'optionalAccess', _183 => _183.publicFile]) ? ds.publicFile(path) : Promise.reject(new Error(`${path} is served by Grafana, and this dashboard has no Grafana connection`));
2602
2678
  const run2 = json.then(parseGazetteer);
2603
2679
  run2.catch(() => loaded.get(path) === run2 && loaded.delete(path));
2604
2680
  loaded.set(path, run2);
@@ -2638,7 +2714,7 @@ function macro(path, format3, ctx) {
2638
2714
  switch (head) {
2639
2715
  case "__from":
2640
2716
  case "__to": {
2641
- const ms = head === "__from" ? _optionalChain([ctx, 'access', _175 => _175.range, 'optionalAccess', _176 => _176.from]) : _optionalChain([ctx, 'access', _177 => _177.range, 'optionalAccess', _178 => _178.to]);
2717
+ const ms = head === "__from" ? _optionalChain([ctx, 'access', _184 => _184.range, 'optionalAccess', _185 => _185.from]) : _optionalChain([ctx, 'access', _186 => _186.range, 'optionalAccess', _187 => _187.to]);
2642
2718
  if (ms == null) return void 0;
2643
2719
  if (format3 === "date" || format3 === "date:iso") return new Date(ms).toISOString();
2644
2720
  if (format3 === "date:seconds") return String(Math.floor(ms / 1e3));
@@ -2675,13 +2751,13 @@ function macro(path, format3, ctx) {
2675
2751
  }
2676
2752
  return void 0;
2677
2753
  case "__series":
2678
- return rest[0] === "name" ? _nullishCoalesce(_nullishCoalesce(d.seriesName, () => ( _optionalChain([d, 'access', _179 => _179.frame, 'optionalAccess', _180 => _180.name]))), () => ( d.fieldName)) : void 0;
2754
+ return rest[0] === "name" ? _nullishCoalesce(_nullishCoalesce(d.seriesName, () => ( _optionalChain([d, 'access', _188 => _188.frame, 'optionalAccess', _189 => _189.name]))), () => ( d.fieldName)) : void 0;
2679
2755
  case "__data": {
2680
2756
  const m = /^fields(?:\.([\w-]+)|\["([^"]*)"\]|\[(\d+)\])/.exec(rest.join("."));
2681
2757
  if (!m || !d.frame || d.row == null) return void 0;
2682
2758
  const key = _nullishCoalesce(m[1], () => ( m[2]));
2683
- const f = key != null ? d.frame.fields.find((x) => x.name === key || _optionalChain([x, 'access', _181 => _181.config, 'optionalAccess', _182 => _182.displayName]) === key) : d.frame.fields[Number(m[3])];
2684
- const v = _optionalChain([f, 'optionalAccess', _183 => _183.values, 'access', _184 => _184[d.row]]);
2759
+ const f = key != null ? d.frame.fields.find((x) => x.name === key || _optionalChain([x, 'access', _190 => _190.config, 'optionalAccess', _191 => _191.displayName]) === key) : d.frame.fields[Number(m[3])];
2760
+ const v = _optionalChain([f, 'optionalAccess', _192 => _192.values, 'access', _193 => _193[d.row]]);
2685
2761
  if (v == null) return void 0;
2686
2762
  return f.type === "time" ? String(toMillis(v)) : String(v);
2687
2763
  }
@@ -2692,9 +2768,9 @@ function urlTime(raw, ms) {
2692
2768
  return raw.trim().startsWith("now") ? encodeURIComponent(raw.trim()) : String(ms);
2693
2769
  }
2694
2770
  function allVariables(ctx) {
2695
- const names = (_nullishCoalesce(_optionalChain([ctx, 'access', _185 => _185.dashboard, 'optionalAccess', _186 => _186.templating, 'optionalAccess', _187 => _187.list]), () => ( []))).filter((v) => v.type !== "adhoc").map((v) => v.name);
2771
+ const names = (_nullishCoalesce(_optionalChain([ctx, 'access', _194 => _194.dashboard, 'optionalAccess', _195 => _195.templating, 'optionalAccess', _196 => _196.list]), () => ( []))).filter((v) => v.type !== "adhoc").map((v) => v.name);
2696
2772
  return (names.length ? names : Object.keys(ctx.values)).flatMap((n) => {
2697
- const v = _nullishCoalesce(_optionalChain([ctx, 'access', _188 => _188.scoped, 'optionalAccess', _189 => _189[n], 'optionalAccess', _190 => _190.value]), () => ( ctx.values[n]));
2773
+ const v = _nullishCoalesce(_optionalChain([ctx, 'access', _197 => _197.scoped, 'optionalAccess', _198 => _198[n], 'optionalAccess', _199 => _199.value]), () => ( ctx.values[n]));
2698
2774
  return v == null ? [] : [queryParam(n, v)];
2699
2775
  }).join("&");
2700
2776
  }
@@ -2705,7 +2781,7 @@ function parseDashboardLink(href, grafanaUrl) {
2705
2781
  const base = grafanaUrl ? /^(?:[a-z][a-z0-9+.-]*:)?\/\/([^/?#]+)([^?#]*)/i.exec(grafanaUrl.trim()) : null;
2706
2782
  if (host && (!base || base[1].toLowerCase() !== host.toLowerCase())) return null;
2707
2783
  if (scheme && !/^https?:$/i.test(scheme)) return null;
2708
- const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess', _191 => _191[2]]), () => ( ""))).replace(/\/+$/, "");
2784
+ const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess', _200 => _200[2]]), () => ( ""))).replace(/\/+$/, "");
2709
2785
  const path = prefix && rawPath.startsWith(prefix + "/") ? rawPath.slice(prefix.length) : rawPath;
2710
2786
  const p = /^\/d\/([^/]+)(?:\/[^/]*)?\/?$/.exec(path);
2711
2787
  if (!p) return null;
@@ -2729,12 +2805,12 @@ function decode(s) {
2729
2805
  }
2730
2806
  }
2731
2807
  function applyDashboardLink(dashboard, target) {
2732
- const time = target.from || target.to ? { from: target.from || _optionalChain([dashboard, 'access', _192 => _192.time, 'optionalAccess', _193 => _193.from]) || "now-6h", to: target.to || _optionalChain([dashboard, 'access', _194 => _194.time, 'optionalAccess', _195 => _195.to]) || "now" } : dashboard.time;
2733
- const list = _optionalChain([dashboard, 'access', _196 => _196.templating, 'optionalAccess', _197 => _197.list, 'access', _198 => _198.map, 'call', _199 => _199((v) => {
2808
+ const time = target.from || target.to ? { from: target.from || _optionalChain([dashboard, 'access', _201 => _201.time, 'optionalAccess', _202 => _202.from]) || "now-6h", to: target.to || _optionalChain([dashboard, 'access', _203 => _203.time, 'optionalAccess', _204 => _204.to]) || "now" } : dashboard.time;
2809
+ const list = _optionalChain([dashboard, 'access', _205 => _205.templating, 'optionalAccess', _206 => _206.list, 'access', _207 => _207.map, 'call', _208 => _208((v) => {
2734
2810
  const values = target.vars[v.name];
2735
- if (!_optionalChain([values, 'optionalAccess', _200 => _200.length])) return v;
2811
+ if (!_optionalChain([values, 'optionalAccess', _209 => _209.length])) return v;
2736
2812
  const value = v.multi ? values : values[0];
2737
- const text = (Array.isArray(value) ? value : [value]).map((x) => x === "$__all" ? "All" : _nullishCoalesce(_optionalChain([v, 'access', _201 => _201.options, 'optionalAccess', _202 => _202.find, 'call', _203 => _203((o) => o.value === x), 'optionalAccess', _204 => _204.text]), () => ( x)));
2813
+ const text = (Array.isArray(value) ? value : [value]).map((x) => x === "$__all" ? "All" : _nullishCoalesce(_optionalChain([v, 'access', _210 => _210.options, 'optionalAccess', _211 => _211.find, 'call', _212 => _212((o) => o.value === x), 'optionalAccess', _213 => _213.text]), () => ( x)));
2738
2814
  return { ...v, current: { text: v.multi ? text : text[0], value } };
2739
2815
  })]);
2740
2816
  return { ...dashboard, time, templating: list ? { ...dashboard.templating, list } : dashboard.templating };
@@ -3812,7 +3888,8 @@ var dashboard_schema_default = {
3812
3888
  type: "number"
3813
3889
  },
3814
3890
  step: {
3815
- type: "number"
3891
+ type: "number",
3892
+ description: "input-number and input-slider: what + and \u2212 (or a slider notch) move by, which also sets the precision. 1, the default, takes whole numbers only; a step with decimals takes decimals, e.g. 0.1 for a weight like 72.5."
3816
3893
  },
3817
3894
  placeholder: {
3818
3895
  type: "string"
@@ -4550,7 +4627,7 @@ function validate12(data, { instancePath = "", parentData, parentDataProperty, r
4550
4627
  var schema18 = { "type": "string", "enum": ["form", "dashboard"], "description": "The subset of the Grafana dashboard JSON model that modelform understands. Unknown keys are tolerated and ignored, so dashboards exported from Grafana load as-is. See https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/view-dashboard-json-model/\n\nmodelform adds four extensions, all of which Grafana ignores: - `kind` to say whether the document is a form or a dashboard - `localOnly` to keep a form's entries on the device that records them - `panel.mobile` to tune phone layout per panel - `input-*` panel types for data entry forms (see inputs.ts)" };
4551
4628
  var schema19 = { "type": "object", "properties": { "id": { "type": "number" }, "type": { "type": "string", "examples": ["row", "timeseries", "trend", "xychart", "stat", "gauge", "bargauge", "piechart", "barchart", "table", "text", "geomap", "input-number", "input-slider", "input-select", "input-toggle", "input-rating", "input-text", "input-counter", "input-duration", "input-group"] }, "title": { "type": "string" }, "description": { "type": "string" }, "gridPos": { "$ref": "#/definitions/GridPos" }, "datasource": { "anyOf": [{ "$ref": "#/definitions/DataSourceRef" }, { "type": "string" }, { "type": "null" }] }, "targets": { "type": "array", "items": { "$ref": "#/definitions/Target" } }, "fieldConfig": { "type": "object", "properties": { "defaults": { "$ref": "#/definitions/FieldConfig" }, "overrides": { "type": "array", "items": { "$ref": "#/definitions/FieldOverride" } } } }, "options": { "type": "object" }, "transformations": { "type": "array", "items": { "type": "object", "properties": { "id": { "type": "string" }, "options": { "type": "object" }, "disabled": { "type": "boolean" } }, "required": ["id"] }, "description": "Applied in order to the query results. See transform.ts for the ones modelform implements." }, "collapsed": { "type": "boolean", "description": "Rows only." }, "panels": { "type": "array", "items": { "$ref": "#/definitions/Panel" }, "description": "Rows only: children of a collapsed row live here instead of at the top level." }, "repeat": { "type": "string", "description": "Repeat this row (or panel) once per selected value of the named variable." }, "repeatDirection": { "type": "string", "enum": ["h", "v"], "description": "Panel repeats: side by side (`h`, wrapping at maxPerRow) or stacked (`v`)." }, "maxPerRow": { "type": "number" }, "scopedVars": { "type": "object", "additionalProperties": { "type": "object", "properties": { "text": { "type": "string" }, "value": { "type": "string" } }, "required": ["text", "value"] }, "description": "Set on each copy of a repeated row or panel: the single value it was repeated for." }, "mobile": { "$ref": "#/definitions/MobileOptions" }, "links": { "type": "array", "items": { "$ref": "#/definitions/DataLink" }, "description": "Panel links, from the panel header menu in Grafana." } }, "required": ["type", "gridPos"], "additionalProperties": {}, "allOf": [{ "if": { "properties": { "type": { "pattern": "^input-(?!group$)" } }, "required": ["type"] }, "then": { "required": ["options"], "properties": { "options": { "$ref": "#/definitions/InputOptions" } } } }, { "if": { "properties": { "type": { "const": "input-group" } }, "required": ["type"] }, "then": { "required": ["options"], "properties": { "options": { "$ref": "#/definitions/InputGroupOptions" } } } }] };
4552
4629
  var pattern1 = new RegExp("^input-(?!group$)", "u");
4553
- var schema20 = { "type": "object", "properties": { "metric": { "type": "string", "description": "The metric this input records to. Visualization queries select data by this name." }, "unit": { "type": "string" }, "min": { "type": "number" }, "max": { "type": "number" }, "step": { "type": "number" }, "placeholder": { "type": "string" }, "labels": { "type": "array", "items": { "type": "string" }, "description": 'input-slider only: text spaced evenly along the track, first at min and last at max, e.g. ["Understeer", "Neutral", "Oversteer"]. Replaces the numeric min/max labels.' }, "default": { "anyOf": [{ "type": "number" }, { "type": "string" }, { "type": "boolean" }, { "type": "string", "const": "last" }], "description": 'Initial value: a literal, or "last" to start from the most recent entry.' }, "record": { "type": "string", "enum": ["changed", "always"], "description": '"changed" (the default) records the value only when it was edited before Save; "always" records it on every Save, so a default like "last" is kept with each save.' }, "required": { "type": "boolean", "description": "Save waits until this has a value." }, "choices": { "type": "array", "items": { "$ref": "#/definitions/InputChoice" }, "description": "input-select only." }, "choicesFrom": { "type": "string", "description": "input-select only: take the choices from the app at runtime instead of `choices`, for lists that live in app data (e.g. wheel sets). Names a key of InputForm's `choices` prop." }, "multi": { "type": "boolean", "description": "input-select only: allow selecting several. Each selection is recorded as its own entry." }, "increment": { "type": "number", "description": "input-counter only: the amount each tap records (default 1)." }, "suggest": { "type": "boolean", "description": "input-text only: a single-line field that suggests values recorded earlier, matching what's typed." }, "suggestWith": { "type": "string", "description": "input-text with `suggest` only: another input's metric whose current value narrows the suggestions to values saved alongside it (e.g. configurations of the chosen track). Falls back to every earlier value when none were." } }, "required": ["metric"] };
4630
+ var schema20 = { "type": "object", "properties": { "metric": { "type": "string", "description": "The metric this input records to. Visualization queries select data by this name." }, "unit": { "type": "string" }, "min": { "type": "number" }, "max": { "type": "number" }, "step": { "type": "number", "description": "input-number and input-slider: what + and \u2212 (or a slider notch) move by, which also sets the precision. 1, the default, takes whole numbers only; a step with decimals takes decimals, e.g. 0.1 for a weight like 72.5." }, "placeholder": { "type": "string" }, "labels": { "type": "array", "items": { "type": "string" }, "description": 'input-slider only: text spaced evenly along the track, first at min and last at max, e.g. ["Understeer", "Neutral", "Oversteer"]. Replaces the numeric min/max labels.' }, "default": { "anyOf": [{ "type": "number" }, { "type": "string" }, { "type": "boolean" }, { "type": "string", "const": "last" }], "description": 'Initial value: a literal, or "last" to start from the most recent entry.' }, "record": { "type": "string", "enum": ["changed", "always"], "description": '"changed" (the default) records the value only when it was edited before Save; "always" records it on every Save, so a default like "last" is kept with each save.' }, "required": { "type": "boolean", "description": "Save waits until this has a value." }, "choices": { "type": "array", "items": { "$ref": "#/definitions/InputChoice" }, "description": "input-select only." }, "choicesFrom": { "type": "string", "description": "input-select only: take the choices from the app at runtime instead of `choices`, for lists that live in app data (e.g. wheel sets). Names a key of InputForm's `choices` prop." }, "multi": { "type": "boolean", "description": "input-select only: allow selecting several. Each selection is recorded as its own entry." }, "increment": { "type": "number", "description": "input-counter only: the amount each tap records (default 1)." }, "suggest": { "type": "boolean", "description": "input-text only: a single-line field that suggests values recorded earlier, matching what's typed." }, "suggestWith": { "type": "string", "description": "input-text with `suggest` only: another input's metric whose current value narrows the suggestions to values saved alongside it (e.g. configurations of the chosen track). Falls back to every earlier value when none were." } }, "required": ["metric"] };
4554
4631
  var schema21 = { "type": "object", "properties": { "label": { "type": "string" }, "value": { "type": ["number", "string"] } }, "required": ["label", "value"] };
4555
4632
  function validate19(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
4556
4633
  let vErrors = null;
@@ -8894,7 +8971,7 @@ function removeAt(root, pointer) {
8894
8971
  const segs = pointer.split("/").slice(1).map((s) => s.replace(/~1/g, "/").replace(/~0/g, "~"));
8895
8972
  const last = segs.pop();
8896
8973
  let parent = root;
8897
- for (const s of segs) parent = _optionalChain([parent, 'optionalAccess', _205 => _205[s]]);
8974
+ for (const s of segs) parent = _optionalChain([parent, 'optionalAccess', _214 => _214[s]]);
8898
8975
  if (Array.isArray(parent)) {
8899
8976
  parent.splice(Number(last), 1);
8900
8977
  return { array: parentOf(pointer), index: Number(last) };
@@ -9067,7 +9144,7 @@ var STANDARD = [
9067
9144
  ]
9068
9145
  }
9069
9146
  },
9070
- { path: field("color.fixedColor"), label: "Color", category: "Standard options", control: { kind: "color" }, showIf: (p) => _optionalChain([p, 'access', _206 => _206.fieldConfig, 'optionalAccess', _207 => _207.defaults, 'optionalAccess', _208 => _208.color, 'optionalAccess', _209 => _209.mode]) === "fixed" }
9147
+ { path: field("color.fixedColor"), label: "Color", category: "Standard options", control: { kind: "color" }, showIf: (p) => _optionalChain([p, 'access', _215 => _215.fieldConfig, 'optionalAccess', _216 => _216.defaults, 'optionalAccess', _217 => _217.color, 'optionalAccess', _218 => _218.mode]) === "fixed" }
9071
9148
  ];
9072
9149
  var THRESHOLDS = {
9073
9150
  path: field("thresholds"),
@@ -9093,7 +9170,7 @@ var CALC = {
9093
9170
  default: "lastNotNull",
9094
9171
  control: { kind: "select", choices: Object.entries(REDUCER_LABELS).map(([value, label]) => ({ label, value })) },
9095
9172
  stored: "string[]",
9096
- get: (p) => _optionalChain([p, 'access', _210 => _210.options, 'optionalAccess', _211 => _211.reduceOptions, 'optionalAccess', _212 => _212.calcs, 'optionalAccess', _213 => _213[0]]),
9173
+ get: (p) => _optionalChain([p, 'access', _219 => _219.options, 'optionalAccess', _220 => _220.reduceOptions, 'optionalAccess', _221 => _221.calcs, 'optionalAccess', _222 => _222[0]]),
9097
9174
  set: (p, v) => setOptionValue(p, "options.reduceOptions.calcs", v === void 0 ? void 0 : [v])
9098
9175
  };
9099
9176
  var LEGEND = {
@@ -9103,9 +9180,9 @@ var LEGEND = {
9103
9180
  help: "When there are two or more series.",
9104
9181
  default: true,
9105
9182
  control: { kind: "boolean" },
9106
- get: (p) => _optionalChain([p, 'access', _214 => _214.options, 'optionalAccess', _215 => _215.legend, 'optionalAccess', _216 => _216.showLegend]) !== false && _optionalChain([p, 'access', _217 => _217.options, 'optionalAccess', _218 => _218.legend, 'optionalAccess', _219 => _219.displayMode]) !== "hidden",
9183
+ get: (p) => _optionalChain([p, 'access', _223 => _223.options, 'optionalAccess', _224 => _224.legend, 'optionalAccess', _225 => _225.showLegend]) !== false && _optionalChain([p, 'access', _226 => _226.options, 'optionalAccess', _227 => _227.legend, 'optionalAccess', _228 => _228.displayMode]) !== "hidden",
9107
9184
  // Grafana's older displayMode "hidden" would otherwise keep it hidden.
9108
- set: (p, v) => setOptionValue(v ? setOptionValue(p, "options.legend.displayMode", _optionalChain([p, 'access', _220 => _220.options, 'optionalAccess', _221 => _221.legend, 'optionalAccess', _222 => _222.displayMode]) === "hidden" ? void 0 : _optionalChain([p, 'access', _223 => _223.options, 'optionalAccess', _224 => _224.legend, 'optionalAccess', _225 => _225.displayMode])) : p, "options.legend.showLegend", v ? void 0 : false)
9185
+ set: (p, v) => setOptionValue(v ? setOptionValue(p, "options.legend.displayMode", _optionalChain([p, 'access', _229 => _229.options, 'optionalAccess', _230 => _230.legend, 'optionalAccess', _231 => _231.displayMode]) === "hidden" ? void 0 : _optionalChain([p, 'access', _232 => _232.options, 'optionalAccess', _233 => _233.legend, 'optionalAccess', _234 => _234.displayMode])) : p, "options.legend.showLegend", v ? void 0 : false)
9109
9186
  };
9110
9187
  var AXIS_LABEL = { path: field("custom.axisLabel"), label: "Axis label", category: "Axis", control: { kind: "text" } };
9111
9188
  var AXIS_PLACEMENT = {
@@ -9359,7 +9436,7 @@ function overrideProperties(type) {
9359
9436
  return out;
9360
9437
  }
9361
9438
  function panelOverrides(panel) {
9362
- const o = _optionalChain([panel, 'access', _226 => _226.fieldConfig, 'optionalAccess', _227 => _227.overrides]);
9439
+ const o = _optionalChain([panel, 'access', _235 => _235.fieldConfig, 'optionalAccess', _236 => _236.overrides]);
9363
9440
  return Array.isArray(o) ? o : [];
9364
9441
  }
9365
9442
  function setOverrides(panel, overrides) {
@@ -9407,7 +9484,7 @@ function prepareDashboard(json, file) {
9407
9484
  });
9408
9485
  dashboard.panels.forEach((p, i) => {
9409
9486
  for (const r of cleanPanelOptions(p)) removed.push({ path: `panels[${i}]${r.path}`, message: r.message });
9410
- _optionalChain([p, 'access', _228 => _228.panels, 'optionalAccess', _229 => _229.forEach, 'call', _230 => _230((child, j) => {
9487
+ _optionalChain([p, 'access', _237 => _237.panels, 'optionalAccess', _238 => _238.forEach, 'call', _239 => _239((child, j) => {
9411
9488
  for (const r of cleanPanelOptions(child)) removed.push({ path: `panels[${i}].panels[${j}]${r.path}`, message: r.message });
9412
9489
  })]);
9413
9490
  });
@@ -9430,7 +9507,7 @@ function groupIssues(dashboard) {
9430
9507
  for (const { p, at } of located2) if (isInputPanel(p) && !recordedAt.has(p.options.metric)) recordedAt.set(p.options.metric, at);
9431
9508
  for (const { p, at } of located2) {
9432
9509
  if (p.type !== INPUT_GROUP) continue;
9433
- const fields = _optionalChain([p, 'access', _231 => _231.options, 'optionalAccess', _232 => _232.fields]);
9510
+ const fields = _optionalChain([p, 'access', _240 => _240.options, 'optionalAccess', _241 => _241.fields]);
9434
9511
  if (!Array.isArray(fields) || !fields.length) {
9435
9512
  out.push({ path: `${at}.options.fields`, message: "a group needs at least one field" });
9436
9513
  continue;
@@ -9447,7 +9524,7 @@ function groupIssues(dashboard) {
9447
9524
  else recordedAt.set(metric, fat);
9448
9525
  mine.push(metric);
9449
9526
  });
9450
- const titleFrom = _optionalChain([p, 'access', _233 => _233.options, 'optionalAccess', _234 => _234.titleFrom]);
9527
+ const titleFrom = _optionalChain([p, 'access', _242 => _242.options, 'optionalAccess', _243 => _243.titleFrom]);
9451
9528
  if (titleFrom !== void 0 && !mine.includes(titleFrom)) out.push({ path: `${at}.options.titleFrom`, message: `must be the metric of one of the group\u2019s fields` });
9452
9529
  }
9453
9530
  return out;
@@ -9458,7 +9535,7 @@ function panelProblem(p) {
9458
9535
  const g = p.gridPos;
9459
9536
  if (!isObject3(g) || !["x", "y", "w", "h"].every((k) => typeof g[k] === "number"))
9460
9537
  return { at: ".gridPos", message: "must have numeric x, y, w and h", summary: "has no usable gridPos" };
9461
- if (p.type.startsWith("input-") && p.type !== INPUT_GROUP && !nonEmptyString(_optionalChain([p, 'access', _235 => _235.options, 'optionalAccess', _236 => _236.metric]))) {
9538
+ if (p.type.startsWith("input-") && p.type !== INPUT_GROUP && !nonEmptyString(_optionalChain([p, 'access', _244 => _244.options, 'optionalAccess', _245 => _245.metric]))) {
9462
9539
  const message = `${p.type} needs a metric to record to`;
9463
9540
  return { at: ".options.metric", message, summary: message };
9464
9541
  }
@@ -9534,17 +9611,17 @@ function resolveUrl(base, rel) {
9534
9611
  function httpFetchJson(options = {}) {
9535
9612
  const seen = /* @__PURE__ */ new Map();
9536
9613
  return async (url, { accept = "application/json", signal } = {}) => {
9537
- const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access', _237 => _237.headers, 'optionalCall', _238 => _238()]), async () => ( {}));
9614
+ const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access', _246 => _246.headers, 'optionalCall', _247 => _247()]), async () => ( {}));
9538
9615
  const key = JSON.stringify([url, accept, extra]);
9539
9616
  const last = seen.get(key);
9540
9617
  const get = (etag2) => fetch(url, { headers: { Accept: accept, ...extra, ...etag2 && { "If-None-Match": etag2 } }, cache: "no-store", signal });
9541
- const res = await get(_optionalChain([last, 'optionalAccess', _239 => _239.etag])).catch((e) => {
9542
- if (!last || _optionalChain([signal, 'optionalAccess', _240 => _240.aborted])) throw e;
9618
+ const res = await get(_optionalChain([last, 'optionalAccess', _248 => _248.etag])).catch((e) => {
9619
+ if (!last || _optionalChain([signal, 'optionalAccess', _249 => _249.aborted])) throw e;
9543
9620
  seen.delete(key);
9544
9621
  return get();
9545
9622
  });
9546
9623
  if (res.status === 304 && last) return last.json;
9547
- if (!res.ok) throw new Error(_nullishCoalesce(_optionalChain([options, 'access', _241 => _241.httpError, 'optionalCall', _242 => _242(res.status)]), () => ( `HTTP ${res.status}`)));
9624
+ if (!res.ok) throw new Error(_nullishCoalesce(_optionalChain([options, 'access', _250 => _250.httpError, 'optionalCall', _251 => _251(res.status)]), () => ( `HTTP ${res.status}`)));
9548
9625
  const json = JSON.parse(await res.text());
9549
9626
  const etag = res.headers.get("ETag");
9550
9627
  if (etag) seen.set(key, { etag, json });
@@ -9666,8 +9743,8 @@ var ConfigLoader = (_class2 = class {
9666
9743
  async start() {
9667
9744
  const { url, cache: cache2 } = this.options;
9668
9745
  if (!url) return;
9669
- const cached = await _optionalChain([cache2, 'optionalAccess', _243 => _243.read, 'call', _244 => _244(), 'access', _245 => _245.catch, 'call', _246 => _246(() => null)]);
9670
- const bundle = _optionalChain([cached, 'optionalAccess', _247 => _247.url]) === url ? revalidateBundle(cached.bundle) : void 0;
9746
+ const cached = await _optionalChain([cache2, 'optionalAccess', _252 => _252.read, 'call', _253 => _253(), 'access', _254 => _254.catch, 'call', _255 => _255(() => null)]);
9747
+ const bundle = _optionalChain([cached, 'optionalAccess', _256 => _256.url]) === url ? revalidateBundle(cached.bundle) : void 0;
9671
9748
  if (cached && bundle && !this.snapshot.fetchedAt) {
9672
9749
  this.lastJson = JSON.stringify(bundle);
9673
9750
  this.set({ bundle, source: "cache", fetchedAt: cached.fetchedAt, revision: cached.revision });
@@ -9697,7 +9774,7 @@ var ConfigLoader = (_class2 = class {
9697
9774
  if (!bundle) {
9698
9775
  const errors = issues.filter((i) => i.severity === "error").length;
9699
9776
  const needsUpdate = issues.some((i) => i.code === "newer-version");
9700
- const error = unreachable ? _optionalChain([issues, 'access', _248 => _248[0], 'optionalAccess', _249 => _249.message]) : needsUpdate ? "a newer format" : errors === 1 ? "1 error" : `${errors} errors`;
9777
+ const error = unreachable ? _optionalChain([issues, 'access', _257 => _257[0], 'optionalAccess', _258 => _258.message]) : needsUpdate ? "a newer format" : errors === 1 ? "1 error" : `${errors} errors`;
9701
9778
  return this.set(
9702
9779
  { loading: false, error, unreachable: !!unreachable, needsUpdate, issues },
9703
9780
  this.snapshot.loading || error !== this.snapshot.error || !!unreachable !== !!this.snapshot.unreachable || needsUpdate !== !!this.snapshot.needsUpdate || !sameIssues(issues, this.snapshot.issues)
@@ -9707,7 +9784,7 @@ var ConfigLoader = (_class2 = class {
9707
9784
  const changed = json !== this.lastJson;
9708
9785
  this.lastJson = json;
9709
9786
  const fetchedAt = Date.now();
9710
- if (changed || revision !== this.snapshot.revision) _optionalChain([cache2, 'optionalAccess', _250 => _250.write, 'call', _251 => _251({ url, fetchedAt, bundle, revision }), 'access', _252 => _252.catch, 'call', _253 => _253(() => {
9787
+ if (changed || revision !== this.snapshot.revision) _optionalChain([cache2, 'optionalAccess', _259 => _259.write, 'call', _260 => _260({ url, fetchedAt, bundle, revision }), 'access', _261 => _261.catch, 'call', _262 => _262(() => {
9711
9788
  })]);
9712
9789
  this.set(
9713
9790
  { ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, unreachable: void 0, needsUpdate: void 0, issues },
@@ -9724,7 +9801,7 @@ var ConfigLoader = (_class2 = class {
9724
9801
  /** Stops the loader: cancels a fetch in flight, and nothing it does afterwards changes the state or the cache. */
9725
9802
  dispose() {
9726
9803
  this.disposed = true;
9727
- _optionalChain([this, 'access', _254 => _254.controller, 'optionalAccess', _255 => _255.abort, 'call', _256 => _256()]);
9804
+ _optionalChain([this, 'access', _263 => _263.controller, 'optionalAccess', _264 => _264.abort, 'call', _265 => _265()]);
9728
9805
  this.listeners.clear();
9729
9806
  }
9730
9807
  /** `notify: false` drops the patch, so the snapshot only changes when listeners hear about it. */
@@ -9745,7 +9822,7 @@ function tabIdFor(title, taken) {
9745
9822
  }
9746
9823
  function screenOfType(type, from, docs) {
9747
9824
  const shown = from ? screenDocuments(from) : [];
9748
- const firstOf = (ids) => _nullishCoalesce(_nullishCoalesce(_optionalChain([shown, 'access', _257 => _257.find, 'call', _258 => _258((d) => ids.includes(d.id)), 'optionalAccess', _259 => _259.id]), () => ( ids[0])), () => ( ""));
9825
+ const firstOf = (ids) => _nullishCoalesce(_nullishCoalesce(_optionalChain([shown, 'access', _266 => _266.find, 'call', _267 => _267((d) => ids.includes(d.id)), 'optionalAccess', _268 => _268.id]), () => ( ids[0])), () => ( ""));
9749
9826
  switch (type) {
9750
9827
  case "dashboard":
9751
9828
  return { type, dashboard: firstOf(docs.dashboards) };
@@ -9758,7 +9835,7 @@ function screenOfType(type, from, docs) {
9758
9835
  }
9759
9836
  }
9760
9837
  function screenDocuments(screen) {
9761
- switch (_optionalChain([screen, 'optionalAccess', _260 => _260.type])) {
9838
+ switch (_optionalChain([screen, 'optionalAccess', _269 => _269.type])) {
9762
9839
  case "dashboard":
9763
9840
  return [{ id: screen.dashboard, kind: "dashboard" }];
9764
9841
  case "forms":
@@ -11173,8 +11250,8 @@ function removeNode(text, path) {
11173
11250
  const tree = parseTree2(text);
11174
11251
  const value = tree && findNodeAtLocation2(tree, path);
11175
11252
  if (!value) return text;
11176
- const node = _optionalChain([value, 'access', _261 => _261.parent, 'optionalAccess', _262 => _262.type]) === "property" ? value.parent : value;
11177
- const siblings = _nullishCoalesce(_optionalChain([node, 'access', _263 => _263.parent, 'optionalAccess', _264 => _264.children]), () => ( []));
11253
+ const node = _optionalChain([value, 'access', _270 => _270.parent, 'optionalAccess', _271 => _271.type]) === "property" ? value.parent : value;
11254
+ const siblings = _nullishCoalesce(_optionalChain([node, 'access', _272 => _272.parent, 'optionalAccess', _273 => _273.children]), () => ( []));
11178
11255
  const i = siblings.indexOf(node);
11179
11256
  const next = siblings[i + 1];
11180
11257
  const prev = siblings[i - 1];
@@ -11257,20 +11334,20 @@ function removeDocumentFromManifest(text, id) {
11257
11334
  const edits = [];
11258
11335
  const removedTabs = [];
11259
11336
  for (let i = tabs.length - 1; i >= 0; i--) {
11260
- const screen = _optionalChain([tabs, 'access', _265 => _265[i], 'optionalAccess', _266 => _266.screen]);
11337
+ const screen = _optionalChain([tabs, 'access', _274 => _274[i], 'optionalAccess', _275 => _275.screen]);
11261
11338
  const at = ["tabs", i, "screen"];
11262
11339
  const removeTab = () => {
11263
11340
  edits.push({ path: ["tabs", i], remove: true });
11264
11341
  removedTabs.unshift(_nullishCoalesce(tabs[i].title, () => ( tabs[i].id)));
11265
11342
  };
11266
- if (_optionalChain([screen, 'optionalAccess', _267 => _267.type]) === "dashboard" && screen.dashboard === id) removeTab();
11267
- else if (_optionalChain([screen, 'optionalAccess', _268 => _268.type]) === "forms" && Array.isArray(screen.forms) && screen.forms.includes(id)) {
11343
+ if (_optionalChain([screen, 'optionalAccess', _276 => _276.type]) === "dashboard" && screen.dashboard === id) removeTab();
11344
+ else if (_optionalChain([screen, 'optionalAccess', _277 => _277.type]) === "forms" && Array.isArray(screen.forms) && screen.forms.includes(id)) {
11268
11345
  if (screen.forms.every((f) => f === id)) removeTab();
11269
11346
  else for (let j = screen.forms.length - 1; j >= 0; j--) if (screen.forms[j] === id) edits.push({ path: [...at, "forms", j], remove: true });
11270
- } else if (_optionalChain([screen, 'optionalAccess', _269 => _269.type]) === "menu" && Array.isArray(screen.items))
11347
+ } else if (_optionalChain([screen, 'optionalAccess', _278 => _278.type]) === "menu" && Array.isArray(screen.items))
11271
11348
  for (let j = screen.items.length - 1; j >= 0; j--) {
11272
11349
  const item = screen.items[j];
11273
- if (_optionalChain([item, 'optionalAccess', _270 => _270.dashboard]) === id || _optionalChain([item, 'optionalAccess', _271 => _271.form]) === id) edits.push({ path: [...at, "items", j], remove: true });
11350
+ if (_optionalChain([item, 'optionalAccess', _279 => _279.dashboard]) === id || _optionalChain([item, 'optionalAccess', _280 => _280.form]) === id) edits.push({ path: [...at, "items", j], remove: true });
11274
11351
  }
11275
11352
  }
11276
11353
  if (tabs.length && removedTabs.length === tabs.length) throw new Error(`Every tab shows only "${id}". Add another tab first`);
@@ -11283,21 +11360,21 @@ function renameDocumentInManifest(text, from, to, path) {
11283
11360
  if (to !== from && to in manifest.documents) throw new Error(`There\u2019s already a document "${to}"`);
11284
11361
  const edits = [];
11285
11362
  (Array.isArray(manifest.tabs) ? manifest.tabs : []).forEach((tab, i) => {
11286
- const screen = _optionalChain([tab, 'optionalAccess', _272 => _272.screen]);
11363
+ const screen = _optionalChain([tab, 'optionalAccess', _281 => _281.screen]);
11287
11364
  const at = ["tabs", i, "screen"];
11288
- if (_optionalChain([screen, 'optionalAccess', _273 => _273.type]) === "dashboard" && screen.dashboard === from) edits.push({ path: [...at, "dashboard"], value: to });
11289
- if (_optionalChain([screen, 'optionalAccess', _274 => _274.type]) === "forms" && Array.isArray(screen.forms))
11365
+ if (_optionalChain([screen, 'optionalAccess', _282 => _282.type]) === "dashboard" && screen.dashboard === from) edits.push({ path: [...at, "dashboard"], value: to });
11366
+ if (_optionalChain([screen, 'optionalAccess', _283 => _283.type]) === "forms" && Array.isArray(screen.forms))
11290
11367
  screen.forms.forEach((f, j) => f === from && edits.push({ path: [...at, "forms", j], value: to }));
11291
- if (_optionalChain([screen, 'optionalAccess', _275 => _275.type]) === "menu" && Array.isArray(screen.items))
11368
+ if (_optionalChain([screen, 'optionalAccess', _284 => _284.type]) === "menu" && Array.isArray(screen.items))
11292
11369
  screen.items.forEach((item, j) => {
11293
- if (_optionalChain([item, 'optionalAccess', _276 => _276.dashboard]) === from) edits.push({ path: [...at, "items", j, "dashboard"], value: to });
11294
- if (_optionalChain([item, 'optionalAccess', _277 => _277.form]) === from) edits.push({ path: [...at, "items", j, "form"], value: to });
11370
+ if (_optionalChain([item, 'optionalAccess', _285 => _285.dashboard]) === from) edits.push({ path: [...at, "items", j, "dashboard"], value: to });
11371
+ if (_optionalChain([item, 'optionalAccess', _286 => _286.form]) === from) edits.push({ path: [...at, "items", j, "form"], value: to });
11295
11372
  });
11296
11373
  });
11297
11374
  if (path !== void 0) edits.push({ path: ["documents", from], value: path });
11298
11375
  let out = applyJsonEdits(text, edits);
11299
11376
  if (to !== from) {
11300
- const key = _optionalChain([findNodeAtLocation2, 'call', _278 => _278(parseTree2(out), ["documents", from]), 'optionalAccess', _279 => _279.parent, 'optionalAccess', _280 => _280.children, 'optionalAccess', _281 => _281[0]]);
11377
+ const key = _optionalChain([findNodeAtLocation2, 'call', _287 => _287(parseTree2(out), ["documents", from]), 'optionalAccess', _288 => _288.parent, 'optionalAccess', _289 => _289.children, 'optionalAccess', _290 => _290[0]]);
11301
11378
  if (key) out = out.slice(0, key.offset) + JSON.stringify(to) + out.slice(key.offset + key.length);
11302
11379
  }
11303
11380
  return out;
@@ -11318,7 +11395,7 @@ function inputs(text) {
11318
11395
  if (d)
11319
11396
  for (const p of d.panels.flatMap((x) => x.type === "row" ? [x, ..._nullishCoalesce(x.panels, () => ( []))] : [x])) {
11320
11397
  if (typeof p.id !== "number") continue;
11321
- if (isInputGroup(p)) p.options.fields.forEach((f, i) => typeof _optionalChain([f, 'optionalAccess', _282 => _282.options, 'optionalAccess', _283 => _283.metric]) === "string" && out.set(`${p.id}.${i}`, { metric: f.options.metric, title: f.title }));
11398
+ if (isInputGroup(p)) p.options.fields.forEach((f, i) => typeof _optionalChain([f, 'optionalAccess', _291 => _291.options, 'optionalAccess', _292 => _292.metric]) === "string" && out.set(`${p.id}.${i}`, { metric: f.options.metric, title: f.title }));
11322
11399
  else if (isInputPanel(p)) out.set(String(p.id), { metric: p.options.metric, title: p.title });
11323
11400
  }
11324
11401
  } catch (e17) {
@@ -11328,7 +11405,7 @@ function inputs(text) {
11328
11405
  function reads(text, metric) {
11329
11406
  const d = parse2(text);
11330
11407
  const panels = d ? d.panels.flatMap((p) => p.type === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]) : [];
11331
- return panels.some((p) => (_nullishCoalesce(_optionalChain([p, 'optionalAccess', _284 => _284.targets]), () => ( []))).some((t) => t.metric === metric));
11408
+ return panels.some((p) => (_nullishCoalesce(_optionalChain([p, 'optionalAccess', _293 => _293.targets]), () => ( []))).some((t) => t.metric === metric));
11332
11409
  }
11333
11410
  function metricChanges(before, after) {
11334
11411
  const merged = { ...before, ...after };
@@ -11343,7 +11420,7 @@ function metricChanges(before, after) {
11343
11420
  for (const [file, text] of Object.entries(after)) {
11344
11421
  const old = inputs(before[file]);
11345
11422
  for (const [id, input] of inputs(text))
11346
- if (_optionalChain([old, 'access', _285 => _285.get, 'call', _286 => _286(id), 'optionalAccess', _287 => _287.metric]) === metric && input.metric !== metric) rename ??= { metric, renamedTo: input.metric, file, input: input.title, readBy };
11423
+ if (_optionalChain([old, 'access', _294 => _294.get, 'call', _295 => _295(id), 'optionalAccess', _296 => _296.metric]) === metric && input.metric !== metric) rename ??= { metric, renamedTo: input.metric, file, input: input.title, readBy };
11347
11424
  }
11348
11425
  changes.push(_nullishCoalesce(rename, () => ( { metric, readBy })));
11349
11426
  }
@@ -11383,14 +11460,14 @@ function variableWithType(v, type) {
11383
11460
  }
11384
11461
  function currentFor(v, value) {
11385
11462
  const options = variableOptions({ ...v, current: void 0 });
11386
- const text = (x) => x === ALL ? "All" : _nullishCoalesce(_optionalChain([options, 'access', _288 => _288.find, 'call', _289 => _289((o) => o.value === x), 'optionalAccess', _290 => _290.text]), () => ( x));
11463
+ const text = (x) => x === ALL ? "All" : _nullishCoalesce(_optionalChain([options, 'access', _297 => _297.find, 'call', _298 => _298((o) => o.value === x), 'optionalAccess', _299 => _299.text]), () => ( x));
11387
11464
  return Array.isArray(value) ? { text: value.map(text), value } : { text: text(value), value };
11388
11465
  }
11389
11466
  function variableWithQuery(v, query) {
11390
11467
  const { options: _, current, ...rest } = v;
11391
11468
  const next = { ...rest, query };
11392
11469
  if (v.type === "textbox" || v.type === "constant") return { ...next, current: { text: query, value: query } };
11393
- const value = selectValue(next, _optionalChain([current, 'optionalAccess', _291 => _291.value]), variableOptions(next));
11470
+ const value = selectValue(next, _optionalChain([current, 'optionalAccess', _300 => _300.value]), variableOptions(next));
11394
11471
  return { ...next, current: currentFor(next, value) };
11395
11472
  }
11396
11473
  function variableWithCurrent(v, value) {
@@ -11400,13 +11477,13 @@ function variableWithFlags(v, flags) {
11400
11477
  const next = { ...v, ...flags };
11401
11478
  if (!next.multi) delete next.multi;
11402
11479
  if (!next.includeAll) delete next.includeAll;
11403
- const raw = _optionalChain([v, 'access', _292 => _292.current, 'optionalAccess', _293 => _293.value]);
11480
+ const raw = _optionalChain([v, 'access', _301 => _301.current, 'optionalAccess', _302 => _302.value]);
11404
11481
  const current = next.multi ? raw == null ? [] : Array.isArray(raw) ? raw : [raw] : Array.isArray(raw) ? raw[0] : raw;
11405
11482
  return variableWithCurrent(next, selectValue(next, current, variableOptions({ ...next, current: void 0 })));
11406
11483
  }
11407
11484
  var refers = (name, flags) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\[${name}(:\\w+)?\\]\\]`, flags);
11408
11485
  function allPanels2(dashboard) {
11409
- return (_nullishCoalesce(dashboard.panels, () => ( []))).flatMap((p) => _optionalChain([p, 'optionalAccess', _294 => _294.type]) === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]).filter((p) => p && typeof p === "object");
11486
+ return (_nullishCoalesce(dashboard.panels, () => ( []))).flatMap((p) => _optionalChain([p, 'optionalAccess', _303 => _303.type]) === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]).filter((p) => p && typeof p === "object");
11410
11487
  }
11411
11488
  function variableUses(dashboard, name) {
11412
11489
  const re = refers(name);
@@ -11478,7 +11555,7 @@ function locate(text, tree, path) {
11478
11555
  for (let n = segs.length; n >= 0; n--) {
11479
11556
  const node = findNodeAtLocation2(tree, segs.slice(0, n));
11480
11557
  if (!node) continue;
11481
- const key = _optionalChain([node, 'access', _295 => _295.parent, 'optionalAccess', _296 => _296.type]) === "property" ? _optionalChain([node, 'access', _297 => _297.parent, 'access', _298 => _298.children, 'optionalAccess', _299 => _299[0]]) : void 0;
11558
+ const key = _optionalChain([node, 'access', _304 => _304.parent, 'optionalAccess', _305 => _305.type]) === "property" ? _optionalChain([node, 'access', _306 => _306.parent, 'access', _307 => _307.children, 'optionalAccess', _308 => _308[0]]) : void 0;
11482
11559
  if ((node.type === "object" || node.type === "array") && key) return located(text, key.offset, key.length);
11483
11560
  if (node.type === "object" || node.type === "array") return located(text, node.offset, 1);
11484
11561
  return located(text, node.offset, node.length);
@@ -11612,7 +11689,7 @@ async function errorText(res) {
11612
11689
  }
11613
11690
  }
11614
11691
  async function authHeaders(token) {
11615
- const t = await _optionalChain([token, 'optionalCall', _300 => _300()]);
11692
+ const t = await _optionalChain([token, 'optionalCall', _309 => _309()]);
11616
11693
  return t ? { Authorization: `Bearer ${t}` } : {};
11617
11694
  }
11618
11695
  var HttpConfigFiles = (_class3 = class {
@@ -11718,14 +11795,14 @@ function fetchJsonWithToken(token) {
11718
11795
  return httpFetchJson({ headers: () => authHeaders(token), httpError: (status) => status === 401 ? "not signed in" : `HTTP ${status}` });
11719
11796
  }
11720
11797
  async function readConfigFiles(source) {
11721
- const all = await _optionalChain([source, 'access', _301 => _301.readAll, 'optionalCall', _302 => _302()]);
11798
+ const all = await _optionalChain([source, 'access', _310 => _310.readAll, 'optionalCall', _311 => _311()]);
11722
11799
  const read = all ? async (p) => {
11723
11800
  if (!(p in all)) throw new Error(NOT_FOUND);
11724
11801
  return all[p];
11725
11802
  } : (p) => source.read(p);
11726
11803
  const files = { [source.manifestPath]: await read(source.manifestPath) };
11727
11804
  const { value } = parseJsonText(files[source.manifestPath]);
11728
- const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess', _303 => _303.documents]), () => ( {}));
11805
+ const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess', _312 => _312.documents]), () => ( {}));
11729
11806
  const paths = [...new Set(Object.values(documents).filter((d) => typeof d === "string"))];
11730
11807
  await Promise.all(
11731
11808
  paths.map(async (p) => {
@@ -11779,7 +11856,7 @@ var CANVAS_ROW_HEADER = 32;
11779
11856
  function panelSize(panel, mode) {
11780
11857
  const p = pos(panel);
11781
11858
  if (mode === "grid") return { span: clampW(p.w), h: clampH(p.h) };
11782
- return { span: panelSpan(panel, "phone"), h: clampH(_nullishCoalesce(_optionalChain([panel, 'access', _304 => _304.mobile, 'optionalAccess', _305 => _305.h]), () => ( p.h))) };
11859
+ return { span: panelSpan(panel, "phone"), h: clampH(_nullishCoalesce(_optionalChain([panel, 'access', _313 => _313.mobile, 'optionalAccess', _314 => _314.h]), () => ( p.h))) };
11783
11860
  }
11784
11861
  function layoutCanvas(panels, order, mode, width, override) {
11785
11862
  return mode === "grid" ? layoutGridCanvas(panels, width, override) : layoutPhoneCanvas(panels, order, width, override);
@@ -11799,7 +11876,7 @@ function layoutGridCanvas(panels, width, override) {
11799
11876
  boxes = [...boxes];
11800
11877
  boxes[override.index] = b;
11801
11878
  }
11802
- const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess', _306 => _306.index]));
11879
+ const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess', _315 => _315.index]));
11803
11880
  const items = settled.map((b, index) => {
11804
11881
  const row = isRow(panels[index]);
11805
11882
  return { index, row, x: b.x * colW, y: gridOffsetPx(b.y), width: b.w * colW - CANVAS_GAP, height: row ? gridUnitsToPx(1) : gridUnitsToPx(b.h), span: b.w, h: b.h };
@@ -11843,12 +11920,12 @@ function layoutPhoneCanvas(panels, order, width, override) {
11843
11920
  y += CANVAS_ROW_HEADER + CANVAS_GAP;
11844
11921
  continue;
11845
11922
  }
11846
- if (mode === "phone" && _optionalChain([panel, 'access', _307 => _307.mobile, 'optionalAccess', _308 => _308.hidden])) {
11923
+ if (mode === "phone" && _optionalChain([panel, 'access', _316 => _316.mobile, 'optionalAccess', _317 => _317.hidden])) {
11847
11924
  hidden.push(index);
11848
11925
  continue;
11849
11926
  }
11850
11927
  const natural = panelSize(panel, mode);
11851
- const size = _optionalChain([override, 'optionalAccess', _309 => _309.index]) === index ? { span: clampW(_nullishCoalesce(override.span, () => ( natural.span))), h: clampH(_nullishCoalesce(override.h, () => ( natural.h))) } : natural;
11928
+ const size = _optionalChain([override, 'optionalAccess', _318 => _318.index]) === index ? { span: clampW(_nullishCoalesce(override.span, () => ( natural.span))), h: clampH(_nullishCoalesce(override.h, () => ( natural.h))) } : natural;
11852
11929
  if (used + size.span > GRID_COLUMNS) flush();
11853
11930
  line.push({ index, row: false, x: 0, y: 0, width: 0, height: 0, ...size });
11854
11931
  used += size.span;
@@ -11866,7 +11943,7 @@ function dropTarget(canvas, x, y, dragging) {
11866
11943
  for (const c of pool) if (distance(c) < distance(best)) best = c;
11867
11944
  const after = best.row ? y > best.y + best.height / 2 : x > best.x + best.width / 2;
11868
11945
  if (!after) return best.index;
11869
- return _nullishCoalesce(_optionalChain([items, 'access', _310 => _310[items.indexOf(best) + 1], 'optionalAccess', _311 => _311.index]), () => ( null));
11946
+ return _nullishCoalesce(_optionalChain([items, 'access', _319 => _319[items.indexOf(best) + 1], 'optionalAccess', _320 => _320.index]), () => ( null));
11870
11947
  }
11871
11948
  function movePanel(panels, index, before) {
11872
11949
  if (before === index) return panels;
@@ -12078,9 +12155,9 @@ var refers2 = (name) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\
12078
12155
  var withChildren = (p) => [p, ...isRow(p) ? _nullishCoalesce(p.panels, () => ( [])) : []];
12079
12156
  function panelMetrics(p) {
12080
12157
  const found = [];
12081
- if (isInputType(p.type) && typeof _optionalChain([p, 'access', _312 => _312.options, 'optionalAccess', _313 => _313.metric]) === "string") found.push(p.options.metric);
12082
- if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _314 => _314.options, 'optionalAccess', _315 => _315.fields]))) {
12083
- for (const f of p.options.fields) if (typeof _optionalChain([f, 'optionalAccess', _316 => _316.options, 'optionalAccess', _317 => _317.metric]) === "string") found.push(f.options.metric);
12158
+ if (isInputType(p.type) && typeof _optionalChain([p, 'access', _321 => _321.options, 'optionalAccess', _322 => _322.metric]) === "string") found.push(p.options.metric);
12159
+ if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _323 => _323.options, 'optionalAccess', _324 => _324.fields]))) {
12160
+ for (const f of p.options.fields) if (typeof _optionalChain([f, 'optionalAccess', _325 => _325.options, 'optionalAccess', _326 => _326.metric]) === "string") found.push(f.options.metric);
12084
12161
  }
12085
12162
  for (const t of _nullishCoalesce(p.targets, () => ( []))) if (typeof t.metric === "string" && t.metric && !t.metric.startsWith("$")) found.push(t.metric);
12086
12163
  return found;
@@ -12088,15 +12165,15 @@ function panelMetrics(p) {
12088
12165
  function renameMetrics(panels, map) {
12089
12166
  const rename = (p) => {
12090
12167
  let out = p;
12091
- if (isInputType(p.type) && typeof _optionalChain([p, 'access', _318 => _318.options, 'optionalAccess', _319 => _319.metric]) === "string" && map[p.options.metric]) out = { ...out, options: { ...out.options, metric: map[p.options.metric] } };
12092
- if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _320 => _320.options, 'optionalAccess', _321 => _321.fields]))) {
12168
+ if (isInputType(p.type) && typeof _optionalChain([p, 'access', _327 => _327.options, 'optionalAccess', _328 => _328.metric]) === "string" && map[p.options.metric]) out = { ...out, options: { ...out.options, metric: map[p.options.metric] } };
12169
+ if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _329 => _329.options, 'optionalAccess', _330 => _330.fields]))) {
12093
12170
  const to = (m) => typeof m === "string" && map[m] || m;
12094
- const fields = p.options.fields.map((f) => _optionalChain([f, 'optionalAccess', _322 => _322.options]) && to(f.options.metric) !== f.options.metric ? { ...f, options: { ...f.options, metric: to(f.options.metric) } } : f);
12171
+ const fields = p.options.fields.map((f) => _optionalChain([f, 'optionalAccess', _331 => _331.options]) && to(f.options.metric) !== f.options.metric ? { ...f, options: { ...f.options, metric: to(f.options.metric) } } : f);
12095
12172
  const titleFrom = to(p.options.titleFrom);
12096
12173
  out = { ...out, options: { ...out.options, fields, ...titleFrom !== void 0 && { titleFrom } } };
12097
12174
  }
12098
- if (_optionalChain([p, 'access', _323 => _323.targets, 'optionalAccess', _324 => _324.some, 'call', _325 => _325((t) => typeof t.metric === "string" && map[t.metric])])) out = { ...out, targets: p.targets.map((t) => typeof t.metric === "string" && map[t.metric] ? { ...t, metric: map[t.metric] } : t) };
12099
- if (_optionalChain([p, 'access', _326 => _326.panels, 'optionalAccess', _327 => _327.length])) out = { ...out, panels: p.panels.map(rename) };
12175
+ if (_optionalChain([p, 'access', _332 => _332.targets, 'optionalAccess', _333 => _333.some, 'call', _334 => _334((t) => typeof t.metric === "string" && map[t.metric])])) out = { ...out, targets: p.targets.map((t) => typeof t.metric === "string" && map[t.metric] ? { ...t, metric: map[t.metric] } : t) };
12176
+ if (_optionalChain([p, 'access', _335 => _335.panels, 'optionalAccess', _336 => _336.length])) out = { ...out, panels: p.panels.map(rename) };
12100
12177
  return out;
12101
12178
  };
12102
12179
  return panels.map(rename);
@@ -12116,7 +12193,7 @@ function copyPanels(dashboard, indices) {
12116
12193
  }
12117
12194
  }
12118
12195
  const chosen = order.filter((i) => picked.has(i)).map((i) => panels[i]);
12119
- return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access', _328 => _328.templating, 'optionalAccess', _329 => _329.list]), () => ( [])));
12196
+ return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access', _337 => _337.templating, 'optionalAccess', _338 => _338.list]), () => ( [])));
12120
12197
  }
12121
12198
  function snippetOf(panels, available) {
12122
12199
  const left = Math.min(...panels.map((p) => pos2(p).x));
@@ -12184,7 +12261,7 @@ var sameVariable = (a, b) => {
12184
12261
  return strip(a) === strip(b);
12185
12262
  };
12186
12263
  function previewPaste(dashboard, snippet) {
12187
- const { added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _330 => _330.templating, 'optionalAccess', _331 => _331.list]), () => ( [])), snippet.variables);
12264
+ const { added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _339 => _339.templating, 'optionalAccess', _340 => _340.list]), () => ( [])), snippet.variables);
12188
12265
  return { added, renamed };
12189
12266
  }
12190
12267
  function mergeVariables(existing, incoming) {
@@ -12221,7 +12298,7 @@ function pasteSnippet(dashboard, snippet, options = {}) {
12221
12298
  return true;
12222
12299
  };
12223
12300
  let incoming = snippet.panels.filter(keep).map((p) => p.panels ? { ...p, panels: p.panels.filter(keep) } : p);
12224
- const { variables, added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _332 => _332.templating, 'optionalAccess', _333 => _333.list]), () => ( [])), snippet.variables);
12301
+ const { variables, added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _341 => _341.templating, 'optionalAccess', _342 => _342.list]), () => ( [])), snippet.variables);
12225
12302
  for (const [from, to] of Object.entries(renamed)) incoming = renameVariableInPanels(incoming, from, to);
12226
12303
  if (options.metrics) incoming = renameMetrics(incoming, options.metrics);
12227
12304
  const after = options.after != null ? existing[options.after] : void 0;
@@ -12286,7 +12363,7 @@ function parseTemplate(text) {
12286
12363
  if (seen.has(d.id)) return { error: `Two documents are called "${d.id}"` };
12287
12364
  seen.add(d.id);
12288
12365
  const { dashboard, issues } = prepareDashboard(d.dashboard, d.id);
12289
- if (!dashboard) return { error: `"${d.id}" can\u2019t be shown: ${_nullishCoalesce(_optionalChain([issues, 'access', _334 => _334.find, 'call', _335 => _335((x) => x.severity === "error"), 'optionalAccess', _336 => _336.message]), () => ( "it isn\u2019t a dashboard"))}` };
12366
+ if (!dashboard) return { error: `"${d.id}" can\u2019t be shown: ${_nullishCoalesce(_optionalChain([issues, 'access', _343 => _343.find, 'call', _344 => _344((x) => x.severity === "error"), 'optionalAccess', _345 => _345.message]), () => ( "it isn\u2019t a dashboard"))}` };
12290
12367
  if (dashboard.kind && dashboard.kind !== d.kind) return { error: `"${d.id}" is listed as a ${d.kind} but says it\u2019s a ${dashboard.kind}` };
12291
12368
  documents.push({ kind: d.kind, id: d.id, dashboard });
12292
12369
  }
@@ -12364,9 +12441,9 @@ function applyTemplate(manifestText, paths, template, options = {}) {
12364
12441
  }
12365
12442
  const tabIds = (_nullishCoalesce(manifest.tabs, () => ( []))).map((t) => t.id);
12366
12443
  const added = [];
12367
- let at = _nullishCoalesce(_optionalChain([manifest, 'access', _337 => _337.tabs, 'optionalAccess', _338 => _338.length]), () => ( 0));
12444
+ let at = _nullishCoalesce(_optionalChain([manifest, 'access', _346 => _346.tabs, 'optionalAccess', _347 => _347.length]), () => ( 0));
12368
12445
  for (const tab of template.tabs) {
12369
- if (!_optionalChain([options, 'access', _339 => _339.tabs, 'optionalAccess', _340 => _340.includes, 'call', _341 => _341(tab.id)])) continue;
12446
+ if (!_optionalChain([options, 'access', _348 => _348.tabs, 'optionalAccess', _349 => _349.includes, 'call', _350 => _350(tab.id)])) continue;
12370
12447
  const screen = retarget(tab.screen, ids);
12371
12448
  if (!screen) continue;
12372
12449
  const id = tabIdFor(tab.id, tabIds);
@@ -12398,7 +12475,7 @@ Forms hold input panels. Each records to a \`metric\` (lowercase words joined wi
12398
12475
 
12399
12476
  | type | what | options besides metric |
12400
12477
  |---|---|---|
12401
- | input-number | a number typed or stepped with + and \u2212 | unit, step, min, max |
12478
+ | input-number | a number typed or stepped with + and \u2212 | unit, step (1 by default: whole numbers only; give 0.1 for decimals, e.g. a weight), min, max |
12402
12479
  | input-slider | a value dragged along a range | min, max, step, unit, labels (text spread along the track) |
12403
12480
  | input-select | one of a set of choices | choices: [{ "label", "value" }], multi (allow several) |
12404
12481
  | input-toggle | yes or no (records 1 or 0) | |
@@ -12433,7 +12510,18 @@ Chart panels read the app's entries with \`"datasource": { "type": "modelform-lo
12433
12510
 
12434
12511
  Units and ranges go in \`"fieldConfig": { "defaults": { "unit": "\u2026", "min", "max", "decimals" } }\`. Units are Grafana's, e.g. "percent", "masskg", "lengthkm", "s", or "suffix: <text>" for anything else (\`"suffix: glasses"\`). Don't use trend, xychart or geomap panels.
12435
12512
 
12436
- Charts can't do arithmetic across metrics (weight \xD7 reps, a ratio of two inputs). Chart what's recorded instead, or add an input for the combined value, and say which you did in the sentence before the JSON.
12513
+ To chart a value worked out from inputs saved together on one form, e.g. a ratio, query each input as its own target and add a \`calculateField\` transformation. Series are joined on time first, so the values of one save meet in one row:
12514
+
12515
+ \`\`\`
12516
+ "targets": [ { "refId": "A", "metric": "yield" }, { "refId": "B", "metric": "dose" } ],
12517
+ "transformations": [ { "id": "calculateField", "options": { "mode": "binary", "alias": "Ratio", "replaceFields": true,
12518
+ "binary": { "left": "yield", "operator": "/", "right": "dose" } } } ]
12519
+ \`\`\`
12520
+
12521
+ - \`left\` and \`right\` are a target's metric (its \`alias\` if it has one) or a number; operators are + - * / % ^. \`"replaceFields": true\` keeps only the result; leave it out to chart the inputs beside it.
12522
+ - \`"mode": "reduceRow"\` with \`"reduce": { "reducer": "sum" | "mean" | "min" | "max", "include": ["<metric>", \u2026] }\` combines several inputs instead, e.g. a total of three scores.
12523
+ - Give both targets the same \`aggregate\` and \`bucket\`, or neither. A save missing either value has no result.
12524
+ - It doesn't work for fields inside an input-group (weight \xD7 reps per set): every item of a save shares one time. Chart what's recorded there instead, or add a field for the combined value, and say which you did in the sentence before the JSON.
12437
12525
 
12438
12526
  `;
12439
12527
  var AUTHORING_GUIDE = `# modelform templates
@@ -12590,7 +12678,7 @@ function readTemplateAnswer(text) {
12590
12678
  );
12591
12679
  const kept = new Set(template.tabs.map((t) => t.id));
12592
12680
  for (const [i, tab] of (Array.isArray(raw.tabs) ? raw.tabs : []).entries()) {
12593
- const id = _optionalChain([tab, 'optionalAccess', _342 => _342.id]);
12681
+ const id = _optionalChain([tab, 'optionalAccess', _351 => _351.id]);
12594
12682
  if (typeof id !== "string" || !kept.has(id)) warnings.push(`tabs[${i}] was left out: it needs an id, a title and a screen showing only this template\u2019s documents`);
12595
12683
  }
12596
12684
  const kinds = new Map(template.documents.map((d) => [d.id, d.kind]));
@@ -12638,9 +12726,9 @@ function readDocumentAnswer(text, kind) {
12638
12726
  return { error: e.message };
12639
12727
  }
12640
12728
  const wrapper = json;
12641
- if (_optionalChain([wrapper, 'optionalAccess', _343 => _343.$modelform]) === "template") {
12729
+ if (_optionalChain([wrapper, 'optionalAccess', _352 => _352.$modelform]) === "template") {
12642
12730
  if (!Array.isArray(wrapper.documents) || wrapper.documents.length !== 1) return { error: `That\u2019s a template, not one ${kind}` };
12643
- json = _optionalChain([wrapper, 'access', _344 => _344.documents, 'access', _345 => _345[0], 'optionalAccess', _346 => _346.dashboard]);
12731
+ json = _optionalChain([wrapper, 'access', _353 => _353.documents, 'access', _354 => _354[0], 'optionalAccess', _355 => _355.dashboard]);
12644
12732
  }
12645
12733
  if (!json || typeof json !== "object" || Array.isArray(json)) return { error: `That isn\u2019t a ${kind}` };
12646
12734
  const raw = json;
@@ -12679,8 +12767,8 @@ function documentChanges(before, after) {
12679
12767
  const what = [];
12680
12768
  if (was.title !== p.title) what.push("title");
12681
12769
  if (was.type !== p.type) what.push("type");
12682
- if (_optionalChain([was, 'access', _347 => _347.gridPos, 'optionalAccess', _348 => _348.x]) !== _optionalChain([p, 'access', _349 => _349.gridPos, 'optionalAccess', _350 => _350.x]) || _optionalChain([was, 'access', _351 => _351.gridPos, 'optionalAccess', _352 => _352.y]) !== _optionalChain([p, 'access', _353 => _353.gridPos, 'optionalAccess', _354 => _354.y])) what.push("position");
12683
- if (_optionalChain([was, 'access', _355 => _355.gridPos, 'optionalAccess', _356 => _356.w]) !== _optionalChain([p, 'access', _357 => _357.gridPos, 'optionalAccess', _358 => _358.w]) || _optionalChain([was, 'access', _359 => _359.gridPos, 'optionalAccess', _360 => _360.h]) !== _optionalChain([p, 'access', _361 => _361.gridPos, 'optionalAccess', _362 => _362.h])) what.push("size");
12770
+ if (_optionalChain([was, 'access', _356 => _356.gridPos, 'optionalAccess', _357 => _357.x]) !== _optionalChain([p, 'access', _358 => _358.gridPos, 'optionalAccess', _359 => _359.x]) || _optionalChain([was, 'access', _360 => _360.gridPos, 'optionalAccess', _361 => _361.y]) !== _optionalChain([p, 'access', _362 => _362.gridPos, 'optionalAccess', _363 => _363.y])) what.push("position");
12771
+ if (_optionalChain([was, 'access', _364 => _364.gridPos, 'optionalAccess', _365 => _365.w]) !== _optionalChain([p, 'access', _366 => _366.gridPos, 'optionalAccess', _367 => _367.w]) || _optionalChain([was, 'access', _368 => _368.gridPos, 'optionalAccess', _369 => _369.h]) !== _optionalChain([p, 'access', _370 => _370.gridPos, 'optionalAccess', _371 => _371.h])) what.push("size");
12684
12772
  if (!same(was.options, p.options)) what.push("options");
12685
12773
  if (!same(was.targets, p.targets) || !same(was.datasource, p.datasource) || !same(was.transformations, p.transformations)) what.push("queries");
12686
12774
  if (!same(was.fieldConfig, p.fieldConfig)) what.push("field config");