@modelform/react-native 0.12.0 → 0.13.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.
@@ -1567,6 +1567,246 @@ function queryErrors(results) {
1567
1567
  return Object.entries(_nullishCoalesce(results, () => ( {}))).filter(([, r]) => r.error).map(([refId, r]) => `${refId}: ${r.error}`).join("\n");
1568
1568
  }
1569
1569
 
1570
+ // src/core/speech.ts
1571
+ var UNITS = {
1572
+ zero: 0,
1573
+ oh: 0,
1574
+ nought: 0,
1575
+ one: 1,
1576
+ two: 2,
1577
+ three: 3,
1578
+ four: 4,
1579
+ five: 5,
1580
+ six: 6,
1581
+ seven: 7,
1582
+ eight: 8,
1583
+ nine: 9,
1584
+ ten: 10,
1585
+ eleven: 11,
1586
+ twelve: 12,
1587
+ thirteen: 13,
1588
+ fourteen: 14,
1589
+ fifteen: 15,
1590
+ sixteen: 16,
1591
+ seventeen: 17,
1592
+ eighteen: 18,
1593
+ nineteen: 19
1594
+ };
1595
+ var TENS = { twenty: 20, thirty: 30, forty: 40, fifty: 50, sixty: 60, seventy: 70, eighty: 80, ninety: 90 };
1596
+ var SCALES = { hundred: 100, thousand: 1e3, million: 1e6 };
1597
+ var NEGATIVE = /* @__PURE__ */ new Set(["minus", "negative"]);
1598
+ var isNumberWord = (w) => w in UNITS || w in TENS || w in SCALES;
1599
+ function words(text) {
1600
+ return text.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g, "").replace(/(\d),(\d{3})\b/g, "$1$2").replace(/(\d),(\d)/g, "$1.$2").replace(/[^a-z0-9.:\s-]/g, " ").replace(/(?<![\d])-(?=\d)/g, " minus ").replace(/-/g, " ").replace(/\.(?!\d)/g, " ").split(/\s+/).filter(Boolean);
1601
+ }
1602
+ function wordsToInteger(ws) {
1603
+ if (!ws.length) return null;
1604
+ if (ws.some((w) => w in SCALES)) {
1605
+ let total = 0;
1606
+ let current = 0;
1607
+ for (const w of ws) {
1608
+ if (w in UNITS) current += UNITS[w];
1609
+ else if (w in TENS) current += TENS[w];
1610
+ else if (w === "hundred") current = (current || 1) * 100;
1611
+ else if (w in SCALES) {
1612
+ total += (current || 1) * SCALES[w];
1613
+ current = 0;
1614
+ } else return null;
1615
+ }
1616
+ return total + current;
1617
+ }
1618
+ const groups = [];
1619
+ for (let i = 0; i < ws.length; i++) {
1620
+ const w = ws[i];
1621
+ const next = ws[i + 1];
1622
+ const nextUnit = next != null && next in UNITS && UNITS[next] > 0 && UNITS[next] < 10;
1623
+ if (w in TENS) {
1624
+ groups.push(String(TENS[w] + (nextUnit ? UNITS[next] : 0)));
1625
+ if (nextUnit) i++;
1626
+ } else if (w === "oh" && nextUnit) {
1627
+ groups.push(`0${UNITS[next]}`);
1628
+ i++;
1629
+ } else if (w in UNITS) groups.push(String(UNITS[w]));
1630
+ else return null;
1631
+ }
1632
+ return Number(groups.map((g, i) => i === 0 ? g : g.padStart(2, "0")).join(""));
1633
+ }
1634
+ function parseSpokenNumber(text) {
1635
+ const ws = words(text);
1636
+ let i = 0;
1637
+ let sign = 1;
1638
+ for (; i < ws.length; i++) {
1639
+ const w = ws[i];
1640
+ if (NEGATIVE.has(w)) sign = -1;
1641
+ else if (/^\d/.test(w) || isNumberWord(w) || w === "a" && ws[i + 1] in SCALES || w === "point" && ws[i + 1] && (/^\d/.test(ws[i + 1]) || ws[i + 1] in UNITS)) break;
1642
+ else if (w !== "and") sign = 1;
1643
+ }
1644
+ if (i >= ws.length) return null;
1645
+ const digits = /^(\d+(?:\.\d+)?)$/.exec(ws[i]);
1646
+ if (digits) {
1647
+ let n = Number(digits[1]);
1648
+ const rest = ws.slice(i + 1);
1649
+ if (!digits[1].includes(".") && rest[0] === "point") n = Number(`${digits[1]}.${_nullishCoalesce(fractionDigits(rest.slice(1)), () => ( 0))}`);
1650
+ else if (rest[0] === "and" && rest[1] === "a" && rest[2] === "half") n += 0.5;
1651
+ return sign * n;
1652
+ }
1653
+ const whole = [];
1654
+ for (; i < ws.length; i++) {
1655
+ const w = ws[i];
1656
+ if (isNumberWord(w)) whole.push(w);
1657
+ else if (w === "a" && ws[i + 1] in SCALES) whole.push("one");
1658
+ else if (w === "and" && ws[i + 1] && isNumberWord(ws[i + 1]) && whole.some((x) => x in SCALES)) continue;
1659
+ else break;
1660
+ }
1661
+ const intPart = whole.length ? wordsToInteger(whole) : 0;
1662
+ if (intPart == null) return null;
1663
+ if (ws[i] === "point") {
1664
+ const frac = fractionDigits(ws.slice(i + 1));
1665
+ return frac == null ? sign * intPart : sign * Number(`${intPart}.${frac}`);
1666
+ }
1667
+ if (ws[i] === "and" && ws[i + 1] === "a" && ws[i + 2] === "half") return sign * (intPart + 0.5);
1668
+ if (ws[i] === "and" && ws[i + 1] === "a" && ws[i + 2] === "quarter") return sign * (intPart + 0.25);
1669
+ if (!whole.length) return null;
1670
+ return sign * intPart;
1671
+ }
1672
+ function fractionDigits(ws) {
1673
+ if (ws[0] && /^\d+$/.test(ws[0])) return ws[0];
1674
+ let out = "";
1675
+ for (let i = 0; i < ws.length; i++) {
1676
+ const w = ws[i];
1677
+ if (w in UNITS && UNITS[w] < 10) out += UNITS[w];
1678
+ else if (w in TENS) {
1679
+ const next = ws[i + 1];
1680
+ if (next in UNITS && UNITS[next] > 0 && UNITS[next] < 10) {
1681
+ out += TENS[w] + UNITS[next];
1682
+ i++;
1683
+ } else out += TENS[w];
1684
+ } else if (w in UNITS) out += UNITS[w];
1685
+ else break;
1686
+ }
1687
+ return out || null;
1688
+ }
1689
+ function parseSpokenDuration(text) {
1690
+ const clock = /(?:(\d+):)?(\d+):(\d{1,2})(?:\.(\d+))?|(\d+):(\d{1,2})(?:\.(\d+))?/.exec(text);
1691
+ if (clock) {
1692
+ if (clock[3] != null) {
1693
+ const [h, m, s, f] = [Number(_nullishCoalesce(clock[1], () => ( 0))), Number(clock[2]), Number(clock[3]), _nullishCoalesce(clock[4], () => ( "0"))];
1694
+ return clock[1] != null ? h * 3600 + m * 60 + s + Number(`0.${f}`) : m * 60 + s + Number(`0.${f}`);
1695
+ }
1696
+ }
1697
+ const lower = text.toLowerCase().replace(/\ban hour\b/g, "one hour").replace(/\ba minute\b/g, "one minute").replace(/(\S+) (hours?|minutes?) and a half/g, "$1 and a half $2");
1698
+ const parts = lower.split(/\b(hours?|hrs?|minutes?|mins?|seconds?|secs?)\b/);
1699
+ const scale = (unit) => unit.startsWith("h") ? 3600 : unit.startsWith("m") ? 60 : 1;
1700
+ let total = 0;
1701
+ let found = false;
1702
+ let last = 0;
1703
+ for (let i = 0; i < parts.length; i += 2) {
1704
+ const n = parseSpokenNumber(parts[i]);
1705
+ const unit = parts[i + 1];
1706
+ const s = unit != null ? scale(unit) : last === 3600 ? 60 : last === 60 ? 1 : 0;
1707
+ if (unit != null) last = s;
1708
+ if (n == null || !s) continue;
1709
+ total += n * s;
1710
+ found = true;
1711
+ }
1712
+ if (found) return Math.round(total * 100) / 100;
1713
+ return null;
1714
+ }
1715
+ var normalize = (s) => words(s).join(" ");
1716
+ var singular = (w) => w.length > 3 && w.endsWith("s") && !w.endsWith("ss") ? w.slice(0, -1) : w;
1717
+ var loose = (s) => normalize(s).split(" ").map(singular).join(" ");
1718
+ function matchChoices(text, choices2) {
1719
+ const said = ` ${loose(text)} `;
1720
+ const hits = [];
1721
+ const byLength = [...choices2].sort((a, b) => b.label.length - a.label.length);
1722
+ for (const c of byLength) {
1723
+ const label = loose(c.label);
1724
+ if (!label) continue;
1725
+ let from = 0;
1726
+ for (; ; ) {
1727
+ const at = said.indexOf(` ${label} `, from);
1728
+ if (at < 0) break;
1729
+ const end = at + label.length + 1;
1730
+ if (!hits.some((h) => at < h.end && end > h.at)) hits.push({ at, end, value: c.value });
1731
+ from = at + 1;
1732
+ }
1733
+ }
1734
+ if (!hits.length) {
1735
+ const n = parseSpokenNumber(text);
1736
+ const c = n == null ? void 0 : choices2.find((x) => x.value === n || Number(x.label) === n || x.value === String(n));
1737
+ return c ? [c.value] : [];
1738
+ }
1739
+ const seen = /* @__PURE__ */ new Set();
1740
+ return hits.sort((a, b) => a.at - b.at).map((h) => h.value).filter((v) => !seen.has(v) && seen.add(v));
1741
+ }
1742
+ var YES = /* @__PURE__ */ new Set(["yes", "yeah", "yep", "yup", "true", "on", "done", "did", "checked", "correct", "affirmative"]);
1743
+ var NO = /* @__PURE__ */ new Set(["no", "nope", "nah", "false", "off", "not", "didnt", "didn", "unchecked", "negative"]);
1744
+ function parseSpokenYesNo(text) {
1745
+ const ws = words(text.replace(/['’]/g, ""));
1746
+ if (ws.some((w) => NO.has(w))) return false;
1747
+ if (ws.some((w) => YES.has(w))) return true;
1748
+ return null;
1749
+ }
1750
+ function spokenValue(panel, said, current = null, choices2) {
1751
+ const text = said.trim();
1752
+ if (!text) return { problem: "Didn\u2019t hear anything" };
1753
+ const o = panel.options;
1754
+ const quoted = `\u201C${text}\u201D`;
1755
+ switch (panel.type) {
1756
+ case "input-text": {
1757
+ if (o.suggest || typeof current !== "string" || !current.trim()) return { value: text };
1758
+ return { value: `${current.trimEnd()} ${text}` };
1759
+ }
1760
+ case "input-number":
1761
+ case "input-rating": {
1762
+ const n = parseSpokenNumber(text);
1763
+ if (n == null) return { problem: `Heard ${quoted}, not a number` };
1764
+ const step = panel.type === "input-rating" ? 1 : _nullishCoalesce(o.step, () => ( 1));
1765
+ return { value: Number.isInteger(step) ? Math.round(n) : n };
1766
+ }
1767
+ case "input-slider": {
1768
+ const min = _nullishCoalesce(o.min, () => ( 0));
1769
+ const max = _nullishCoalesce(o.max, () => ( 10));
1770
+ const step = _nullishCoalesce(o.step, () => ( 1));
1771
+ if (_optionalChain([o, 'access', _154 => _154.labels, 'optionalAccess', _155 => _155.length])) {
1772
+ const [hit] = matchChoices(text, o.labels.map((label, i) => ({ label, value: i })));
1773
+ if (typeof hit === "number") {
1774
+ const raw = o.labels.length === 1 ? min : min + hit / (o.labels.length - 1) * (max - min);
1775
+ return { value: Number((Math.round((raw - min) / step) * step + min).toFixed((_nullishCoalesce(String(step).split(".")[1], () => ( ""))).length)) };
1776
+ }
1777
+ }
1778
+ const n = parseSpokenNumber(text);
1779
+ if (n == null) return { problem: `Heard ${quoted}, not a number` };
1780
+ return { value: Number.isInteger(step) ? Math.round(n) : n };
1781
+ }
1782
+ case "input-duration": {
1783
+ const s = _nullishCoalesce(parseSpokenDuration(text), () => ( parseSpokenNumber(text)));
1784
+ return s == null ? { problem: `Heard ${quoted}, not a time` } : { value: s };
1785
+ }
1786
+ case "input-select": {
1787
+ const options = _nullishCoalesce(_nullishCoalesce(choices2, () => ( o.choices)), () => ( []));
1788
+ const hits = matchChoices(text, options);
1789
+ if (!hits.length) return { problem: `Heard ${quoted}, not one of the choices` };
1790
+ if (!o.multi) return { value: hits[0] };
1791
+ const had = Array.isArray(current) ? current : current == null ? [] : [current];
1792
+ return { value: [...had, ...hits.filter((h) => !had.includes(h))] };
1793
+ }
1794
+ case "input-toggle": {
1795
+ const yes = parseSpokenYesNo(text);
1796
+ return yes == null ? { problem: `Heard ${quoted}, not yes or no` } : { value: yes };
1797
+ }
1798
+ default:
1799
+ return { problem: "This input doesn\u2019t take dictation" };
1800
+ }
1801
+ }
1802
+ var DICTATION_TYPES = ["input-number", "input-text", "input-select", "input-duration"];
1803
+ var takesDictation = (panel) => DICTATION_TYPES.includes(panel.type);
1804
+ function dictationHints(panel, choices2) {
1805
+ const out = (_nullishCoalesce(_nullishCoalesce(choices2, () => ( panel.options.choices)), () => ( []))).map((c) => c.label);
1806
+ if (panel.options.unit) out.push(panel.options.unit);
1807
+ return out;
1808
+ }
1809
+
1570
1810
  // src/core/local.ts
1571
1811
  var LOCAL_DATASOURCE_TYPE = "modelform-local";
1572
1812
  var LEGACY_LOCAL_DATASOURCE_TYPE = "dashkit-local";
@@ -1643,7 +1883,7 @@ function buildFrames(target, entries, request, label, siblings = []) {
1643
1883
  const fill = _nullishCoalesce(target.fillZero, () => ( (aggregate === "sum" || aggregate === "count")));
1644
1884
  ({ times, values } = bucketize(rows, aggregate, bucket, request.range, fill));
1645
1885
  }
1646
- const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall', _154 => _154(labelKey, group)]), () => ( group));
1886
+ const display = group == null ? name : _nullishCoalesce(_optionalChain([label, 'optionalCall', _156 => _156(labelKey, group)]), () => ( group));
1647
1887
  return {
1648
1888
  name,
1649
1889
  refId: target.refId,
@@ -1699,7 +1939,7 @@ function bucketize(rows, aggregate, bucket, range, fillZero) {
1699
1939
  const keys = fillZero ? step.range(range.from, range.to) : [...sums.keys()].sort((a, b) => a - b);
1700
1940
  const values = keys.map((k) => {
1701
1941
  const vs = sums.get(k);
1702
- return _optionalChain([vs, 'optionalAccess', _155 => _155.length]) ? reduce2(vs, aggregate) : fillZero ? 0 : null;
1942
+ return _optionalChain([vs, 'optionalAccess', _157 => _157.length]) ? reduce2(vs, aggregate) : fillZero ? 0 : null;
1703
1943
  });
1704
1944
  return { times: keys, values };
1705
1945
  }
@@ -1780,17 +2020,17 @@ function parseGazetteer(json) {
1780
2020
  };
1781
2021
  if (Array.isArray(json)) {
1782
2022
  for (const item of json) {
1783
- const lat = Number(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _156 => _156.latitude]), () => ( _optionalChain([item, 'optionalAccess', _157 => _157.lat]))));
1784
- const lon = Number(_nullishCoalesce(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _158 => _158.longitude]), () => ( _optionalChain([item, 'optionalAccess', _159 => _159.lon]))), () => ( _optionalChain([item, 'optionalAccess', _160 => _160.lng]))));
2023
+ const lat = Number(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _158 => _158.latitude]), () => ( _optionalChain([item, 'optionalAccess', _159 => _159.lat]))));
2024
+ const lon = Number(_nullishCoalesce(_nullishCoalesce(_optionalChain([item, 'optionalAccess', _160 => _160.longitude]), () => ( _optionalChain([item, 'optionalAccess', _161 => _161.lon]))), () => ( _optionalChain([item, 'optionalAccess', _162 => _162.lng]))));
1785
2025
  if (!Number.isFinite(lat) || !Number.isFinite(lon)) continue;
1786
2026
  const p = { lon, lat };
1787
2027
  add(item.key, p);
1788
2028
  for (const k of [..._nullishCoalesce(item.keys, () => ( [])), ..._nullishCoalesce(item.keywords, () => ( []))]) add(k, p);
1789
2029
  add(item.name, p);
1790
2030
  }
1791
- } else if (_optionalChain([json, 'optionalAccess', _161 => _161.type]) === "FeatureCollection") {
2031
+ } else if (_optionalChain([json, 'optionalAccess', _163 => _163.type]) === "FeatureCollection") {
1792
2032
  for (const f of _nullishCoalesce(json.features, () => ( []))) {
1793
- const p = featurePoint(_optionalChain([f, 'optionalAccess', _162 => _162.geometry]));
2033
+ const p = featurePoint(_optionalChain([f, 'optionalAccess', _164 => _164.geometry]));
1794
2034
  if (!p) continue;
1795
2035
  add(f.id, p);
1796
2036
  for (const v of Object.values(_nullishCoalesce(f.properties, () => ( {})))) if (typeof v === "string") add(v, p);
@@ -1799,7 +2039,7 @@ function parseGazetteer(json) {
1799
2039
  return { find: (key) => _nullishCoalesce(exact.get(key), () => ( folded.get(key.toLowerCase()))) };
1800
2040
  }
1801
2041
  function featurePoint(geometry) {
1802
- if (!_optionalChain([geometry, 'optionalAccess', _163 => _163.coordinates])) return void 0;
2042
+ if (!_optionalChain([geometry, 'optionalAccess', _165 => _165.coordinates])) return void 0;
1803
2043
  if (geometry.type === "Point") {
1804
2044
  const [lon, lat] = geometry.coordinates;
1805
2045
  return Number.isFinite(lon) && Number.isFinite(lat) ? { lon, lat } : void 0;
@@ -1828,7 +2068,7 @@ function loadGazetteer(path, ds) {
1828
2068
  const json = absolute ? fetch(path).then((r) => {
1829
2069
  if (!r.ok) throw new Error(`${r.status} ${r.statusText}`);
1830
2070
  return r.json();
1831
- }) : _optionalChain([ds, 'optionalAccess', _164 => _164.publicFile]) ? ds.publicFile(path) : Promise.reject(new Error(`${path} is served by Grafana, and this dashboard has no Grafana connection`));
2071
+ }) : _optionalChain([ds, 'optionalAccess', _166 => _166.publicFile]) ? ds.publicFile(path) : Promise.reject(new Error(`${path} is served by Grafana, and this dashboard has no Grafana connection`));
1832
2072
  const run2 = json.then(parseGazetteer);
1833
2073
  run2.catch(() => loaded.get(path) === run2 && loaded.delete(path));
1834
2074
  loaded.set(path, run2);
@@ -1868,7 +2108,7 @@ function macro(path, format3, ctx) {
1868
2108
  switch (head) {
1869
2109
  case "__from":
1870
2110
  case "__to": {
1871
- const ms = head === "__from" ? _optionalChain([ctx, 'access', _165 => _165.range, 'optionalAccess', _166 => _166.from]) : _optionalChain([ctx, 'access', _167 => _167.range, 'optionalAccess', _168 => _168.to]);
2111
+ const ms = head === "__from" ? _optionalChain([ctx, 'access', _167 => _167.range, 'optionalAccess', _168 => _168.from]) : _optionalChain([ctx, 'access', _169 => _169.range, 'optionalAccess', _170 => _170.to]);
1872
2112
  if (ms == null) return void 0;
1873
2113
  if (format3 === "date" || format3 === "date:iso") return new Date(ms).toISOString();
1874
2114
  if (format3 === "date:seconds") return String(Math.floor(ms / 1e3));
@@ -1905,13 +2145,13 @@ function macro(path, format3, ctx) {
1905
2145
  }
1906
2146
  return void 0;
1907
2147
  case "__series":
1908
- return rest[0] === "name" ? _nullishCoalesce(_nullishCoalesce(d.seriesName, () => ( _optionalChain([d, 'access', _169 => _169.frame, 'optionalAccess', _170 => _170.name]))), () => ( d.fieldName)) : void 0;
2148
+ return rest[0] === "name" ? _nullishCoalesce(_nullishCoalesce(d.seriesName, () => ( _optionalChain([d, 'access', _171 => _171.frame, 'optionalAccess', _172 => _172.name]))), () => ( d.fieldName)) : void 0;
1909
2149
  case "__data": {
1910
2150
  const m = /^fields(?:\.([\w-]+)|\["([^"]*)"\]|\[(\d+)\])/.exec(rest.join("."));
1911
2151
  if (!m || !d.frame || d.row == null) return void 0;
1912
2152
  const key = _nullishCoalesce(m[1], () => ( m[2]));
1913
- const f = key != null ? d.frame.fields.find((x) => x.name === key || _optionalChain([x, 'access', _171 => _171.config, 'optionalAccess', _172 => _172.displayName]) === key) : d.frame.fields[Number(m[3])];
1914
- const v = _optionalChain([f, 'optionalAccess', _173 => _173.values, 'access', _174 => _174[d.row]]);
2153
+ const f = key != null ? d.frame.fields.find((x) => x.name === key || _optionalChain([x, 'access', _173 => _173.config, 'optionalAccess', _174 => _174.displayName]) === key) : d.frame.fields[Number(m[3])];
2154
+ const v = _optionalChain([f, 'optionalAccess', _175 => _175.values, 'access', _176 => _176[d.row]]);
1915
2155
  if (v == null) return void 0;
1916
2156
  return f.type === "time" ? String(toMillis(v)) : String(v);
1917
2157
  }
@@ -1922,9 +2162,9 @@ function urlTime(raw, ms) {
1922
2162
  return raw.trim().startsWith("now") ? encodeURIComponent(raw.trim()) : String(ms);
1923
2163
  }
1924
2164
  function allVariables(ctx) {
1925
- const names = (_nullishCoalesce(_optionalChain([ctx, 'access', _175 => _175.dashboard, 'optionalAccess', _176 => _176.templating, 'optionalAccess', _177 => _177.list]), () => ( []))).filter((v) => v.type !== "adhoc").map((v) => v.name);
2165
+ const names = (_nullishCoalesce(_optionalChain([ctx, 'access', _177 => _177.dashboard, 'optionalAccess', _178 => _178.templating, 'optionalAccess', _179 => _179.list]), () => ( []))).filter((v) => v.type !== "adhoc").map((v) => v.name);
1926
2166
  return (names.length ? names : Object.keys(ctx.values)).flatMap((n) => {
1927
- const v = _nullishCoalesce(_optionalChain([ctx, 'access', _178 => _178.scoped, 'optionalAccess', _179 => _179[n], 'optionalAccess', _180 => _180.value]), () => ( ctx.values[n]));
2167
+ const v = _nullishCoalesce(_optionalChain([ctx, 'access', _180 => _180.scoped, 'optionalAccess', _181 => _181[n], 'optionalAccess', _182 => _182.value]), () => ( ctx.values[n]));
1928
2168
  return v == null ? [] : [queryParam(n, v)];
1929
2169
  }).join("&");
1930
2170
  }
@@ -1935,7 +2175,7 @@ function parseDashboardLink(href, grafanaUrl) {
1935
2175
  const base = grafanaUrl ? /^(?:[a-z][a-z0-9+.-]*:)?\/\/([^/?#]+)([^?#]*)/i.exec(grafanaUrl.trim()) : null;
1936
2176
  if (host && (!base || base[1].toLowerCase() !== host.toLowerCase())) return null;
1937
2177
  if (scheme && !/^https?:$/i.test(scheme)) return null;
1938
- const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess', _181 => _181[2]]), () => ( ""))).replace(/\/+$/, "");
2178
+ const prefix = (_nullishCoalesce(_optionalChain([base, 'optionalAccess', _183 => _183[2]]), () => ( ""))).replace(/\/+$/, "");
1939
2179
  const path = prefix && rawPath.startsWith(prefix + "/") ? rawPath.slice(prefix.length) : rawPath;
1940
2180
  const p = /^\/d\/([^/]+)(?:\/[^/]*)?\/?$/.exec(path);
1941
2181
  if (!p) return null;
@@ -1959,12 +2199,12 @@ function decode(s) {
1959
2199
  }
1960
2200
  }
1961
2201
  function applyDashboardLink(dashboard, target) {
1962
- const time = target.from || target.to ? { from: target.from || _optionalChain([dashboard, 'access', _182 => _182.time, 'optionalAccess', _183 => _183.from]) || "now-6h", to: target.to || _optionalChain([dashboard, 'access', _184 => _184.time, 'optionalAccess', _185 => _185.to]) || "now" } : dashboard.time;
1963
- const list = _optionalChain([dashboard, 'access', _186 => _186.templating, 'optionalAccess', _187 => _187.list, 'access', _188 => _188.map, 'call', _189 => _189((v) => {
2202
+ const time = target.from || target.to ? { from: target.from || _optionalChain([dashboard, 'access', _184 => _184.time, 'optionalAccess', _185 => _185.from]) || "now-6h", to: target.to || _optionalChain([dashboard, 'access', _186 => _186.time, 'optionalAccess', _187 => _187.to]) || "now" } : dashboard.time;
2203
+ const list = _optionalChain([dashboard, 'access', _188 => _188.templating, 'optionalAccess', _189 => _189.list, 'access', _190 => _190.map, 'call', _191 => _191((v) => {
1964
2204
  const values = target.vars[v.name];
1965
- if (!_optionalChain([values, 'optionalAccess', _190 => _190.length])) return v;
2205
+ if (!_optionalChain([values, 'optionalAccess', _192 => _192.length])) return v;
1966
2206
  const value = v.multi ? values : values[0];
1967
- const text = (Array.isArray(value) ? value : [value]).map((x) => x === "$__all" ? "All" : _nullishCoalesce(_optionalChain([v, 'access', _191 => _191.options, 'optionalAccess', _192 => _192.find, 'call', _193 => _193((o) => o.value === x), 'optionalAccess', _194 => _194.text]), () => ( x)));
2207
+ const text = (Array.isArray(value) ? value : [value]).map((x) => x === "$__all" ? "All" : _nullishCoalesce(_optionalChain([v, 'access', _193 => _193.options, 'optionalAccess', _194 => _194.find, 'call', _195 => _195((o) => o.value === x), 'optionalAccess', _196 => _196.text]), () => ( x)));
1968
2208
  return { ...v, current: { text: v.multi ? text : text[0], value } };
1969
2209
  })]);
1970
2210
  return { ...dashboard, time, templating: list ? { ...dashboard.templating, list } : dashboard.templating };
@@ -8098,7 +8338,7 @@ function removeAt(root, pointer) {
8098
8338
  const segs = pointer.split("/").slice(1).map((s) => s.replace(/~1/g, "/").replace(/~0/g, "~"));
8099
8339
  const last = segs.pop();
8100
8340
  let parent = root;
8101
- for (const s of segs) parent = _optionalChain([parent, 'optionalAccess', _195 => _195[s]]);
8341
+ for (const s of segs) parent = _optionalChain([parent, 'optionalAccess', _197 => _197[s]]);
8102
8342
  if (Array.isArray(parent)) {
8103
8343
  parent.splice(Number(last), 1);
8104
8344
  return { array: parentOf(pointer), index: Number(last) };
@@ -8271,7 +8511,7 @@ var STANDARD = [
8271
8511
  ]
8272
8512
  }
8273
8513
  },
8274
- { path: field("color.fixedColor"), label: "Color", category: "Standard options", control: { kind: "color" }, showIf: (p) => _optionalChain([p, 'access', _196 => _196.fieldConfig, 'optionalAccess', _197 => _197.defaults, 'optionalAccess', _198 => _198.color, 'optionalAccess', _199 => _199.mode]) === "fixed" }
8514
+ { path: field("color.fixedColor"), label: "Color", category: "Standard options", control: { kind: "color" }, showIf: (p) => _optionalChain([p, 'access', _198 => _198.fieldConfig, 'optionalAccess', _199 => _199.defaults, 'optionalAccess', _200 => _200.color, 'optionalAccess', _201 => _201.mode]) === "fixed" }
8275
8515
  ];
8276
8516
  var THRESHOLDS = {
8277
8517
  path: field("thresholds"),
@@ -8297,7 +8537,7 @@ var CALC = {
8297
8537
  default: "lastNotNull",
8298
8538
  control: { kind: "select", choices: Object.entries(REDUCER_LABELS).map(([value, label]) => ({ label, value })) },
8299
8539
  stored: "string[]",
8300
- get: (p) => _optionalChain([p, 'access', _200 => _200.options, 'optionalAccess', _201 => _201.reduceOptions, 'optionalAccess', _202 => _202.calcs, 'optionalAccess', _203 => _203[0]]),
8540
+ get: (p) => _optionalChain([p, 'access', _202 => _202.options, 'optionalAccess', _203 => _203.reduceOptions, 'optionalAccess', _204 => _204.calcs, 'optionalAccess', _205 => _205[0]]),
8301
8541
  set: (p, v) => setOptionValue(p, "options.reduceOptions.calcs", v === void 0 ? void 0 : [v])
8302
8542
  };
8303
8543
  var LEGEND = {
@@ -8307,9 +8547,9 @@ var LEGEND = {
8307
8547
  help: "When there are two or more series.",
8308
8548
  default: true,
8309
8549
  control: { kind: "boolean" },
8310
- get: (p) => _optionalChain([p, 'access', _204 => _204.options, 'optionalAccess', _205 => _205.legend, 'optionalAccess', _206 => _206.showLegend]) !== false && _optionalChain([p, 'access', _207 => _207.options, 'optionalAccess', _208 => _208.legend, 'optionalAccess', _209 => _209.displayMode]) !== "hidden",
8550
+ get: (p) => _optionalChain([p, 'access', _206 => _206.options, 'optionalAccess', _207 => _207.legend, 'optionalAccess', _208 => _208.showLegend]) !== false && _optionalChain([p, 'access', _209 => _209.options, 'optionalAccess', _210 => _210.legend, 'optionalAccess', _211 => _211.displayMode]) !== "hidden",
8311
8551
  // Grafana's older displayMode "hidden" would otherwise keep it hidden.
8312
- set: (p, v) => setOptionValue(v ? setOptionValue(p, "options.legend.displayMode", _optionalChain([p, 'access', _210 => _210.options, 'optionalAccess', _211 => _211.legend, 'optionalAccess', _212 => _212.displayMode]) === "hidden" ? void 0 : _optionalChain([p, 'access', _213 => _213.options, 'optionalAccess', _214 => _214.legend, 'optionalAccess', _215 => _215.displayMode])) : p, "options.legend.showLegend", v ? void 0 : false)
8552
+ set: (p, v) => setOptionValue(v ? setOptionValue(p, "options.legend.displayMode", _optionalChain([p, 'access', _212 => _212.options, 'optionalAccess', _213 => _213.legend, 'optionalAccess', _214 => _214.displayMode]) === "hidden" ? void 0 : _optionalChain([p, 'access', _215 => _215.options, 'optionalAccess', _216 => _216.legend, 'optionalAccess', _217 => _217.displayMode])) : p, "options.legend.showLegend", v ? void 0 : false)
8313
8553
  };
8314
8554
  var AXIS_LABEL = { path: field("custom.axisLabel"), label: "Axis label", category: "Axis", control: { kind: "text" } };
8315
8555
  var AXIS_PLACEMENT = {
@@ -8563,7 +8803,7 @@ function overrideProperties(type) {
8563
8803
  return out;
8564
8804
  }
8565
8805
  function panelOverrides(panel) {
8566
- const o = _optionalChain([panel, 'access', _216 => _216.fieldConfig, 'optionalAccess', _217 => _217.overrides]);
8806
+ const o = _optionalChain([panel, 'access', _218 => _218.fieldConfig, 'optionalAccess', _219 => _219.overrides]);
8567
8807
  return Array.isArray(o) ? o : [];
8568
8808
  }
8569
8809
  function setOverrides(panel, overrides) {
@@ -8611,7 +8851,7 @@ function prepareDashboard(json, file) {
8611
8851
  });
8612
8852
  dashboard.panels.forEach((p, i) => {
8613
8853
  for (const r of cleanPanelOptions(p)) removed.push({ path: `panels[${i}]${r.path}`, message: r.message });
8614
- _optionalChain([p, 'access', _218 => _218.panels, 'optionalAccess', _219 => _219.forEach, 'call', _220 => _220((child, j) => {
8854
+ _optionalChain([p, 'access', _220 => _220.panels, 'optionalAccess', _221 => _221.forEach, 'call', _222 => _222((child, j) => {
8615
8855
  for (const r of cleanPanelOptions(child)) removed.push({ path: `panels[${i}].panels[${j}]${r.path}`, message: r.message });
8616
8856
  })]);
8617
8857
  });
@@ -8634,7 +8874,7 @@ function groupIssues(dashboard) {
8634
8874
  for (const { p, at } of located2) if (isInputPanel(p) && !recordedAt.has(p.options.metric)) recordedAt.set(p.options.metric, at);
8635
8875
  for (const { p, at } of located2) {
8636
8876
  if (p.type !== INPUT_GROUP) continue;
8637
- const fields = _optionalChain([p, 'access', _221 => _221.options, 'optionalAccess', _222 => _222.fields]);
8877
+ const fields = _optionalChain([p, 'access', _223 => _223.options, 'optionalAccess', _224 => _224.fields]);
8638
8878
  if (!Array.isArray(fields) || !fields.length) {
8639
8879
  out.push({ path: `${at}.options.fields`, message: "a group needs at least one field" });
8640
8880
  continue;
@@ -8651,7 +8891,7 @@ function groupIssues(dashboard) {
8651
8891
  else recordedAt.set(metric, fat);
8652
8892
  mine.push(metric);
8653
8893
  });
8654
- const titleFrom = _optionalChain([p, 'access', _223 => _223.options, 'optionalAccess', _224 => _224.titleFrom]);
8894
+ const titleFrom = _optionalChain([p, 'access', _225 => _225.options, 'optionalAccess', _226 => _226.titleFrom]);
8655
8895
  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` });
8656
8896
  }
8657
8897
  return out;
@@ -8662,7 +8902,7 @@ function panelProblem(p) {
8662
8902
  const g = p.gridPos;
8663
8903
  if (!isObject3(g) || !["x", "y", "w", "h"].every((k) => typeof g[k] === "number"))
8664
8904
  return { at: ".gridPos", message: "must have numeric x, y, w and h", summary: "has no usable gridPos" };
8665
- if (p.type.startsWith("input-") && p.type !== INPUT_GROUP && !nonEmptyString(_optionalChain([p, 'access', _225 => _225.options, 'optionalAccess', _226 => _226.metric]))) {
8905
+ if (p.type.startsWith("input-") && p.type !== INPUT_GROUP && !nonEmptyString(_optionalChain([p, 'access', _227 => _227.options, 'optionalAccess', _228 => _228.metric]))) {
8666
8906
  const message = `${p.type} needs a metric to record to`;
8667
8907
  return { at: ".options.metric", message, summary: message };
8668
8908
  }
@@ -8738,17 +8978,17 @@ function resolveUrl(base, rel) {
8738
8978
  function httpFetchJson(options = {}) {
8739
8979
  const seen = /* @__PURE__ */ new Map();
8740
8980
  return async (url, { accept = "application/json", signal } = {}) => {
8741
- const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access', _227 => _227.headers, 'optionalCall', _228 => _228()]), async () => ( {}));
8981
+ const extra = await _asyncNullishCoalesce(await _optionalChain([options, 'access', _229 => _229.headers, 'optionalCall', _230 => _230()]), async () => ( {}));
8742
8982
  const key = JSON.stringify([url, accept, extra]);
8743
8983
  const last = seen.get(key);
8744
8984
  const get = (etag2) => fetch(url, { headers: { Accept: accept, ...extra, ...etag2 && { "If-None-Match": etag2 } }, cache: "no-store", signal });
8745
- const res = await get(_optionalChain([last, 'optionalAccess', _229 => _229.etag])).catch((e) => {
8746
- if (!last || _optionalChain([signal, 'optionalAccess', _230 => _230.aborted])) throw e;
8985
+ const res = await get(_optionalChain([last, 'optionalAccess', _231 => _231.etag])).catch((e) => {
8986
+ if (!last || _optionalChain([signal, 'optionalAccess', _232 => _232.aborted])) throw e;
8747
8987
  seen.delete(key);
8748
8988
  return get();
8749
8989
  });
8750
8990
  if (res.status === 304 && last) return last.json;
8751
- if (!res.ok) throw new Error(_nullishCoalesce(_optionalChain([options, 'access', _231 => _231.httpError, 'optionalCall', _232 => _232(res.status)]), () => ( `HTTP ${res.status}`)));
8991
+ if (!res.ok) throw new Error(_nullishCoalesce(_optionalChain([options, 'access', _233 => _233.httpError, 'optionalCall', _234 => _234(res.status)]), () => ( `HTTP ${res.status}`)));
8752
8992
  const json = JSON.parse(await res.text());
8753
8993
  const etag = res.headers.get("ETag");
8754
8994
  if (etag) seen.set(key, { etag, json });
@@ -8870,8 +9110,8 @@ var ConfigLoader = (_class2 = class {
8870
9110
  async start() {
8871
9111
  const { url, cache: cache2 } = this.options;
8872
9112
  if (!url) return;
8873
- const cached = await _optionalChain([cache2, 'optionalAccess', _233 => _233.read, 'call', _234 => _234(), 'access', _235 => _235.catch, 'call', _236 => _236(() => null)]);
8874
- const bundle = _optionalChain([cached, 'optionalAccess', _237 => _237.url]) === url ? revalidateBundle(cached.bundle) : void 0;
9113
+ const cached = await _optionalChain([cache2, 'optionalAccess', _235 => _235.read, 'call', _236 => _236(), 'access', _237 => _237.catch, 'call', _238 => _238(() => null)]);
9114
+ const bundle = _optionalChain([cached, 'optionalAccess', _239 => _239.url]) === url ? revalidateBundle(cached.bundle) : void 0;
8875
9115
  if (cached && bundle && !this.snapshot.fetchedAt) {
8876
9116
  this.lastJson = JSON.stringify(bundle);
8877
9117
  this.set({ bundle, source: "cache", fetchedAt: cached.fetchedAt, revision: cached.revision });
@@ -8901,7 +9141,7 @@ var ConfigLoader = (_class2 = class {
8901
9141
  if (!bundle) {
8902
9142
  const errors = issues.filter((i) => i.severity === "error").length;
8903
9143
  const needsUpdate = issues.some((i) => i.code === "newer-version");
8904
- const error = unreachable ? _optionalChain([issues, 'access', _238 => _238[0], 'optionalAccess', _239 => _239.message]) : needsUpdate ? "a newer format" : errors === 1 ? "1 error" : `${errors} errors`;
9144
+ const error = unreachable ? _optionalChain([issues, 'access', _240 => _240[0], 'optionalAccess', _241 => _241.message]) : needsUpdate ? "a newer format" : errors === 1 ? "1 error" : `${errors} errors`;
8905
9145
  return this.set(
8906
9146
  { loading: false, error, unreachable: !!unreachable, needsUpdate, issues },
8907
9147
  this.snapshot.loading || error !== this.snapshot.error || !!unreachable !== !!this.snapshot.unreachable || needsUpdate !== !!this.snapshot.needsUpdate || !sameIssues(issues, this.snapshot.issues)
@@ -8911,7 +9151,7 @@ var ConfigLoader = (_class2 = class {
8911
9151
  const changed = json !== this.lastJson;
8912
9152
  this.lastJson = json;
8913
9153
  const fetchedAt = Date.now();
8914
- if (changed || revision !== this.snapshot.revision) _optionalChain([cache2, 'optionalAccess', _240 => _240.write, 'call', _241 => _241({ url, fetchedAt, bundle, revision }), 'access', _242 => _242.catch, 'call', _243 => _243(() => {
9154
+ if (changed || revision !== this.snapshot.revision) _optionalChain([cache2, 'optionalAccess', _242 => _242.write, 'call', _243 => _243({ url, fetchedAt, bundle, revision }), 'access', _244 => _244.catch, 'call', _245 => _245(() => {
8915
9155
  })]);
8916
9156
  this.set(
8917
9157
  { ...changed && { bundle }, source: "remote", fetchedAt, revision, loading: false, error: void 0, unreachable: void 0, needsUpdate: void 0, issues },
@@ -8928,7 +9168,7 @@ var ConfigLoader = (_class2 = class {
8928
9168
  /** Stops the loader: cancels a fetch in flight, and nothing it does afterwards changes the state or the cache. */
8929
9169
  dispose() {
8930
9170
  this.disposed = true;
8931
- _optionalChain([this, 'access', _244 => _244.controller, 'optionalAccess', _245 => _245.abort, 'call', _246 => _246()]);
9171
+ _optionalChain([this, 'access', _246 => _246.controller, 'optionalAccess', _247 => _247.abort, 'call', _248 => _248()]);
8932
9172
  this.listeners.clear();
8933
9173
  }
8934
9174
  /** `notify: false` drops the patch, so the snapshot only changes when listeners hear about it. */
@@ -8949,7 +9189,7 @@ function tabIdFor(title, taken) {
8949
9189
  }
8950
9190
  function screenOfType(type, from, docs) {
8951
9191
  const shown = from ? screenDocuments(from) : [];
8952
- const firstOf = (ids) => _nullishCoalesce(_nullishCoalesce(_optionalChain([shown, 'access', _247 => _247.find, 'call', _248 => _248((d) => ids.includes(d.id)), 'optionalAccess', _249 => _249.id]), () => ( ids[0])), () => ( ""));
9192
+ const firstOf = (ids) => _nullishCoalesce(_nullishCoalesce(_optionalChain([shown, 'access', _249 => _249.find, 'call', _250 => _250((d) => ids.includes(d.id)), 'optionalAccess', _251 => _251.id]), () => ( ids[0])), () => ( ""));
8953
9193
  switch (type) {
8954
9194
  case "dashboard":
8955
9195
  return { type, dashboard: firstOf(docs.dashboards) };
@@ -8962,7 +9202,7 @@ function screenOfType(type, from, docs) {
8962
9202
  }
8963
9203
  }
8964
9204
  function screenDocuments(screen) {
8965
- switch (_optionalChain([screen, 'optionalAccess', _250 => _250.type])) {
9205
+ switch (_optionalChain([screen, 'optionalAccess', _252 => _252.type])) {
8966
9206
  case "dashboard":
8967
9207
  return [{ id: screen.dashboard, kind: "dashboard" }];
8968
9208
  case "forms":
@@ -10377,8 +10617,8 @@ function removeNode(text, path) {
10377
10617
  const tree = parseTree2(text);
10378
10618
  const value = tree && findNodeAtLocation2(tree, path);
10379
10619
  if (!value) return text;
10380
- const node = _optionalChain([value, 'access', _251 => _251.parent, 'optionalAccess', _252 => _252.type]) === "property" ? value.parent : value;
10381
- const siblings = _nullishCoalesce(_optionalChain([node, 'access', _253 => _253.parent, 'optionalAccess', _254 => _254.children]), () => ( []));
10620
+ const node = _optionalChain([value, 'access', _253 => _253.parent, 'optionalAccess', _254 => _254.type]) === "property" ? value.parent : value;
10621
+ const siblings = _nullishCoalesce(_optionalChain([node, 'access', _255 => _255.parent, 'optionalAccess', _256 => _256.children]), () => ( []));
10382
10622
  const i = siblings.indexOf(node);
10383
10623
  const next = siblings[i + 1];
10384
10624
  const prev = siblings[i - 1];
@@ -10461,20 +10701,20 @@ function removeDocumentFromManifest(text, id) {
10461
10701
  const edits = [];
10462
10702
  const removedTabs = [];
10463
10703
  for (let i = tabs.length - 1; i >= 0; i--) {
10464
- const screen = _optionalChain([tabs, 'access', _255 => _255[i], 'optionalAccess', _256 => _256.screen]);
10704
+ const screen = _optionalChain([tabs, 'access', _257 => _257[i], 'optionalAccess', _258 => _258.screen]);
10465
10705
  const at = ["tabs", i, "screen"];
10466
10706
  const removeTab = () => {
10467
10707
  edits.push({ path: ["tabs", i], remove: true });
10468
10708
  removedTabs.unshift(_nullishCoalesce(tabs[i].title, () => ( tabs[i].id)));
10469
10709
  };
10470
- if (_optionalChain([screen, 'optionalAccess', _257 => _257.type]) === "dashboard" && screen.dashboard === id) removeTab();
10471
- else if (_optionalChain([screen, 'optionalAccess', _258 => _258.type]) === "forms" && Array.isArray(screen.forms) && screen.forms.includes(id)) {
10710
+ if (_optionalChain([screen, 'optionalAccess', _259 => _259.type]) === "dashboard" && screen.dashboard === id) removeTab();
10711
+ else if (_optionalChain([screen, 'optionalAccess', _260 => _260.type]) === "forms" && Array.isArray(screen.forms) && screen.forms.includes(id)) {
10472
10712
  if (screen.forms.every((f) => f === id)) removeTab();
10473
10713
  else for (let j = screen.forms.length - 1; j >= 0; j--) if (screen.forms[j] === id) edits.push({ path: [...at, "forms", j], remove: true });
10474
- } else if (_optionalChain([screen, 'optionalAccess', _259 => _259.type]) === "menu" && Array.isArray(screen.items))
10714
+ } else if (_optionalChain([screen, 'optionalAccess', _261 => _261.type]) === "menu" && Array.isArray(screen.items))
10475
10715
  for (let j = screen.items.length - 1; j >= 0; j--) {
10476
10716
  const item = screen.items[j];
10477
- if (_optionalChain([item, 'optionalAccess', _260 => _260.dashboard]) === id || _optionalChain([item, 'optionalAccess', _261 => _261.form]) === id) edits.push({ path: [...at, "items", j], remove: true });
10717
+ if (_optionalChain([item, 'optionalAccess', _262 => _262.dashboard]) === id || _optionalChain([item, 'optionalAccess', _263 => _263.form]) === id) edits.push({ path: [...at, "items", j], remove: true });
10478
10718
  }
10479
10719
  }
10480
10720
  if (tabs.length && removedTabs.length === tabs.length) throw new Error(`Every tab shows only "${id}". Add another tab first`);
@@ -10487,21 +10727,21 @@ function renameDocumentInManifest(text, from, to, path) {
10487
10727
  if (to !== from && to in manifest.documents) throw new Error(`There\u2019s already a document "${to}"`);
10488
10728
  const edits = [];
10489
10729
  (Array.isArray(manifest.tabs) ? manifest.tabs : []).forEach((tab, i) => {
10490
- const screen = _optionalChain([tab, 'optionalAccess', _262 => _262.screen]);
10730
+ const screen = _optionalChain([tab, 'optionalAccess', _264 => _264.screen]);
10491
10731
  const at = ["tabs", i, "screen"];
10492
- if (_optionalChain([screen, 'optionalAccess', _263 => _263.type]) === "dashboard" && screen.dashboard === from) edits.push({ path: [...at, "dashboard"], value: to });
10493
- if (_optionalChain([screen, 'optionalAccess', _264 => _264.type]) === "forms" && Array.isArray(screen.forms))
10732
+ if (_optionalChain([screen, 'optionalAccess', _265 => _265.type]) === "dashboard" && screen.dashboard === from) edits.push({ path: [...at, "dashboard"], value: to });
10733
+ if (_optionalChain([screen, 'optionalAccess', _266 => _266.type]) === "forms" && Array.isArray(screen.forms))
10494
10734
  screen.forms.forEach((f, j) => f === from && edits.push({ path: [...at, "forms", j], value: to }));
10495
- if (_optionalChain([screen, 'optionalAccess', _265 => _265.type]) === "menu" && Array.isArray(screen.items))
10735
+ if (_optionalChain([screen, 'optionalAccess', _267 => _267.type]) === "menu" && Array.isArray(screen.items))
10496
10736
  screen.items.forEach((item, j) => {
10497
- if (_optionalChain([item, 'optionalAccess', _266 => _266.dashboard]) === from) edits.push({ path: [...at, "items", j, "dashboard"], value: to });
10498
- if (_optionalChain([item, 'optionalAccess', _267 => _267.form]) === from) edits.push({ path: [...at, "items", j, "form"], value: to });
10737
+ if (_optionalChain([item, 'optionalAccess', _268 => _268.dashboard]) === from) edits.push({ path: [...at, "items", j, "dashboard"], value: to });
10738
+ if (_optionalChain([item, 'optionalAccess', _269 => _269.form]) === from) edits.push({ path: [...at, "items", j, "form"], value: to });
10499
10739
  });
10500
10740
  });
10501
10741
  if (path !== void 0) edits.push({ path: ["documents", from], value: path });
10502
10742
  let out = applyJsonEdits(text, edits);
10503
10743
  if (to !== from) {
10504
- const key = _optionalChain([findNodeAtLocation2, 'call', _268 => _268(parseTree2(out), ["documents", from]), 'optionalAccess', _269 => _269.parent, 'optionalAccess', _270 => _270.children, 'optionalAccess', _271 => _271[0]]);
10744
+ const key = _optionalChain([findNodeAtLocation2, 'call', _270 => _270(parseTree2(out), ["documents", from]), 'optionalAccess', _271 => _271.parent, 'optionalAccess', _272 => _272.children, 'optionalAccess', _273 => _273[0]]);
10505
10745
  if (key) out = out.slice(0, key.offset) + JSON.stringify(to) + out.slice(key.offset + key.length);
10506
10746
  }
10507
10747
  return out;
@@ -10522,7 +10762,7 @@ function inputs(text) {
10522
10762
  if (d)
10523
10763
  for (const p of d.panels.flatMap((x) => x.type === "row" ? [x, ..._nullishCoalesce(x.panels, () => ( []))] : [x])) {
10524
10764
  if (typeof p.id !== "number") continue;
10525
- if (isInputGroup(p)) p.options.fields.forEach((f, i) => typeof _optionalChain([f, 'optionalAccess', _272 => _272.options, 'optionalAccess', _273 => _273.metric]) === "string" && out.set(`${p.id}.${i}`, { metric: f.options.metric, title: f.title }));
10765
+ if (isInputGroup(p)) p.options.fields.forEach((f, i) => typeof _optionalChain([f, 'optionalAccess', _274 => _274.options, 'optionalAccess', _275 => _275.metric]) === "string" && out.set(`${p.id}.${i}`, { metric: f.options.metric, title: f.title }));
10526
10766
  else if (isInputPanel(p)) out.set(String(p.id), { metric: p.options.metric, title: p.title });
10527
10767
  }
10528
10768
  } catch (e15) {
@@ -10532,7 +10772,7 @@ function inputs(text) {
10532
10772
  function reads(text, metric) {
10533
10773
  const d = parse2(text);
10534
10774
  const panels = d ? d.panels.flatMap((p) => p.type === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]) : [];
10535
- return panels.some((p) => (_nullishCoalesce(_optionalChain([p, 'optionalAccess', _274 => _274.targets]), () => ( []))).some((t) => t.metric === metric));
10775
+ return panels.some((p) => (_nullishCoalesce(_optionalChain([p, 'optionalAccess', _276 => _276.targets]), () => ( []))).some((t) => t.metric === metric));
10536
10776
  }
10537
10777
  function metricChanges(before, after) {
10538
10778
  const merged = { ...before, ...after };
@@ -10547,7 +10787,7 @@ function metricChanges(before, after) {
10547
10787
  for (const [file, text] of Object.entries(after)) {
10548
10788
  const old = inputs(before[file]);
10549
10789
  for (const [id, input] of inputs(text))
10550
- if (_optionalChain([old, 'access', _275 => _275.get, 'call', _276 => _276(id), 'optionalAccess', _277 => _277.metric]) === metric && input.metric !== metric) rename ??= { metric, renamedTo: input.metric, file, input: input.title, readBy };
10790
+ if (_optionalChain([old, 'access', _277 => _277.get, 'call', _278 => _278(id), 'optionalAccess', _279 => _279.metric]) === metric && input.metric !== metric) rename ??= { metric, renamedTo: input.metric, file, input: input.title, readBy };
10551
10791
  }
10552
10792
  changes.push(_nullishCoalesce(rename, () => ( { metric, readBy })));
10553
10793
  }
@@ -10587,14 +10827,14 @@ function variableWithType(v, type) {
10587
10827
  }
10588
10828
  function currentFor(v, value) {
10589
10829
  const options = variableOptions({ ...v, current: void 0 });
10590
- const text = (x) => x === ALL ? "All" : _nullishCoalesce(_optionalChain([options, 'access', _278 => _278.find, 'call', _279 => _279((o) => o.value === x), 'optionalAccess', _280 => _280.text]), () => ( x));
10830
+ const text = (x) => x === ALL ? "All" : _nullishCoalesce(_optionalChain([options, 'access', _280 => _280.find, 'call', _281 => _281((o) => o.value === x), 'optionalAccess', _282 => _282.text]), () => ( x));
10591
10831
  return Array.isArray(value) ? { text: value.map(text), value } : { text: text(value), value };
10592
10832
  }
10593
10833
  function variableWithQuery(v, query) {
10594
10834
  const { options: _, current, ...rest } = v;
10595
10835
  const next = { ...rest, query };
10596
10836
  if (v.type === "textbox" || v.type === "constant") return { ...next, current: { text: query, value: query } };
10597
- const value = selectValue(next, _optionalChain([current, 'optionalAccess', _281 => _281.value]), variableOptions(next));
10837
+ const value = selectValue(next, _optionalChain([current, 'optionalAccess', _283 => _283.value]), variableOptions(next));
10598
10838
  return { ...next, current: currentFor(next, value) };
10599
10839
  }
10600
10840
  function variableWithCurrent(v, value) {
@@ -10604,13 +10844,13 @@ function variableWithFlags(v, flags) {
10604
10844
  const next = { ...v, ...flags };
10605
10845
  if (!next.multi) delete next.multi;
10606
10846
  if (!next.includeAll) delete next.includeAll;
10607
- const raw = _optionalChain([v, 'access', _282 => _282.current, 'optionalAccess', _283 => _283.value]);
10847
+ const raw = _optionalChain([v, 'access', _284 => _284.current, 'optionalAccess', _285 => _285.value]);
10608
10848
  const current = next.multi ? raw == null ? [] : Array.isArray(raw) ? raw : [raw] : Array.isArray(raw) ? raw[0] : raw;
10609
10849
  return variableWithCurrent(next, selectValue(next, current, variableOptions({ ...next, current: void 0 })));
10610
10850
  }
10611
10851
  var refers = (name, flags) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\[${name}(:\\w+)?\\]\\]`, flags);
10612
10852
  function allPanels2(dashboard) {
10613
- return (_nullishCoalesce(dashboard.panels, () => ( []))).flatMap((p) => _optionalChain([p, 'optionalAccess', _284 => _284.type]) === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]).filter((p) => p && typeof p === "object");
10853
+ return (_nullishCoalesce(dashboard.panels, () => ( []))).flatMap((p) => _optionalChain([p, 'optionalAccess', _286 => _286.type]) === "row" ? [p, ..._nullishCoalesce(p.panels, () => ( []))] : [p]).filter((p) => p && typeof p === "object");
10614
10854
  }
10615
10855
  function variableUses(dashboard, name) {
10616
10856
  const re = refers(name);
@@ -10682,7 +10922,7 @@ function locate(text, tree, path) {
10682
10922
  for (let n = segs.length; n >= 0; n--) {
10683
10923
  const node = findNodeAtLocation2(tree, segs.slice(0, n));
10684
10924
  if (!node) continue;
10685
- const key = _optionalChain([node, 'access', _285 => _285.parent, 'optionalAccess', _286 => _286.type]) === "property" ? _optionalChain([node, 'access', _287 => _287.parent, 'access', _288 => _288.children, 'optionalAccess', _289 => _289[0]]) : void 0;
10925
+ const key = _optionalChain([node, 'access', _287 => _287.parent, 'optionalAccess', _288 => _288.type]) === "property" ? _optionalChain([node, 'access', _289 => _289.parent, 'access', _290 => _290.children, 'optionalAccess', _291 => _291[0]]) : void 0;
10686
10926
  if ((node.type === "object" || node.type === "array") && key) return located(text, key.offset, key.length);
10687
10927
  if (node.type === "object" || node.type === "array") return located(text, node.offset, 1);
10688
10928
  return located(text, node.offset, node.length);
@@ -10816,7 +11056,7 @@ async function errorText(res) {
10816
11056
  }
10817
11057
  }
10818
11058
  async function authHeaders(token) {
10819
- const t = await _optionalChain([token, 'optionalCall', _290 => _290()]);
11059
+ const t = await _optionalChain([token, 'optionalCall', _292 => _292()]);
10820
11060
  return t ? { Authorization: `Bearer ${t}` } : {};
10821
11061
  }
10822
11062
  var HttpConfigFiles = (_class3 = class {
@@ -10922,14 +11162,14 @@ function fetchJsonWithToken(token) {
10922
11162
  return httpFetchJson({ headers: () => authHeaders(token), httpError: (status) => status === 401 ? "not signed in" : `HTTP ${status}` });
10923
11163
  }
10924
11164
  async function readConfigFiles(source) {
10925
- const all = await _optionalChain([source, 'access', _291 => _291.readAll, 'optionalCall', _292 => _292()]);
11165
+ const all = await _optionalChain([source, 'access', _293 => _293.readAll, 'optionalCall', _294 => _294()]);
10926
11166
  const read = all ? async (p) => {
10927
11167
  if (!(p in all)) throw new Error(NOT_FOUND);
10928
11168
  return all[p];
10929
11169
  } : (p) => source.read(p);
10930
11170
  const files = { [source.manifestPath]: await read(source.manifestPath) };
10931
11171
  const { value } = parseJsonText(files[source.manifestPath]);
10932
- const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess', _293 => _293.documents]), () => ( {}));
11172
+ const documents = _nullishCoalesce(_optionalChain([value, 'optionalAccess', _295 => _295.documents]), () => ( {}));
10933
11173
  const paths = [...new Set(Object.values(documents).filter((d) => typeof d === "string"))];
10934
11174
  await Promise.all(
10935
11175
  paths.map(async (p) => {
@@ -10983,7 +11223,7 @@ var CANVAS_ROW_HEADER = 32;
10983
11223
  function panelSize(panel, mode) {
10984
11224
  const p = pos(panel);
10985
11225
  if (mode === "grid") return { span: clampW(p.w), h: clampH(p.h) };
10986
- return { span: panelSpan(panel, "phone"), h: clampH(_nullishCoalesce(_optionalChain([panel, 'access', _294 => _294.mobile, 'optionalAccess', _295 => _295.h]), () => ( p.h))) };
11226
+ return { span: panelSpan(panel, "phone"), h: clampH(_nullishCoalesce(_optionalChain([panel, 'access', _296 => _296.mobile, 'optionalAccess', _297 => _297.h]), () => ( p.h))) };
10987
11227
  }
10988
11228
  function layoutCanvas(panels, order, mode, width, override) {
10989
11229
  return mode === "grid" ? layoutGridCanvas(panels, width, override) : layoutPhoneCanvas(panels, order, width, override);
@@ -11003,7 +11243,7 @@ function layoutGridCanvas(panels, width, override) {
11003
11243
  boxes = [...boxes];
11004
11244
  boxes[override.index] = b;
11005
11245
  }
11006
- const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess', _296 => _296.index]));
11246
+ const settled = settleBoxes(boxes, _optionalChain([override, 'optionalAccess', _298 => _298.index]));
11007
11247
  const items = settled.map((b, index) => {
11008
11248
  const row = isRow(panels[index]);
11009
11249
  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 };
@@ -11047,12 +11287,12 @@ function layoutPhoneCanvas(panels, order, width, override) {
11047
11287
  y += CANVAS_ROW_HEADER + CANVAS_GAP;
11048
11288
  continue;
11049
11289
  }
11050
- if (mode === "phone" && _optionalChain([panel, 'access', _297 => _297.mobile, 'optionalAccess', _298 => _298.hidden])) {
11290
+ if (mode === "phone" && _optionalChain([panel, 'access', _299 => _299.mobile, 'optionalAccess', _300 => _300.hidden])) {
11051
11291
  hidden.push(index);
11052
11292
  continue;
11053
11293
  }
11054
11294
  const natural = panelSize(panel, mode);
11055
- const size = _optionalChain([override, 'optionalAccess', _299 => _299.index]) === index ? { span: clampW(_nullishCoalesce(override.span, () => ( natural.span))), h: clampH(_nullishCoalesce(override.h, () => ( natural.h))) } : natural;
11295
+ const size = _optionalChain([override, 'optionalAccess', _301 => _301.index]) === index ? { span: clampW(_nullishCoalesce(override.span, () => ( natural.span))), h: clampH(_nullishCoalesce(override.h, () => ( natural.h))) } : natural;
11056
11296
  if (used + size.span > GRID_COLUMNS) flush();
11057
11297
  line.push({ index, row: false, x: 0, y: 0, width: 0, height: 0, ...size });
11058
11298
  used += size.span;
@@ -11070,7 +11310,7 @@ function dropTarget(canvas, x, y, dragging) {
11070
11310
  for (const c of pool) if (distance(c) < distance(best)) best = c;
11071
11311
  const after = best.row ? y > best.y + best.height / 2 : x > best.x + best.width / 2;
11072
11312
  if (!after) return best.index;
11073
- return _nullishCoalesce(_optionalChain([items, 'access', _300 => _300[items.indexOf(best) + 1], 'optionalAccess', _301 => _301.index]), () => ( null));
11313
+ return _nullishCoalesce(_optionalChain([items, 'access', _302 => _302[items.indexOf(best) + 1], 'optionalAccess', _303 => _303.index]), () => ( null));
11074
11314
  }
11075
11315
  function movePanel(panels, index, before) {
11076
11316
  if (before === index) return panels;
@@ -11282,9 +11522,9 @@ var refers2 = (name) => new RegExp(`\\$${name}\\b|\\$\\{${name}(:\\w+)?\\}|\\[\\
11282
11522
  var withChildren = (p) => [p, ...isRow(p) ? _nullishCoalesce(p.panels, () => ( [])) : []];
11283
11523
  function panelMetrics(p) {
11284
11524
  const found = [];
11285
- if (isInputType(p.type) && typeof _optionalChain([p, 'access', _302 => _302.options, 'optionalAccess', _303 => _303.metric]) === "string") found.push(p.options.metric);
11286
- if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _304 => _304.options, 'optionalAccess', _305 => _305.fields]))) {
11287
- for (const f of p.options.fields) if (typeof _optionalChain([f, 'optionalAccess', _306 => _306.options, 'optionalAccess', _307 => _307.metric]) === "string") found.push(f.options.metric);
11525
+ if (isInputType(p.type) && typeof _optionalChain([p, 'access', _304 => _304.options, 'optionalAccess', _305 => _305.metric]) === "string") found.push(p.options.metric);
11526
+ if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _306 => _306.options, 'optionalAccess', _307 => _307.fields]))) {
11527
+ for (const f of p.options.fields) if (typeof _optionalChain([f, 'optionalAccess', _308 => _308.options, 'optionalAccess', _309 => _309.metric]) === "string") found.push(f.options.metric);
11288
11528
  }
11289
11529
  for (const t of _nullishCoalesce(p.targets, () => ( []))) if (typeof t.metric === "string" && t.metric && !t.metric.startsWith("$")) found.push(t.metric);
11290
11530
  return found;
@@ -11292,15 +11532,15 @@ function panelMetrics(p) {
11292
11532
  function renameMetrics(panels, map) {
11293
11533
  const rename = (p) => {
11294
11534
  let out = p;
11295
- if (isInputType(p.type) && typeof _optionalChain([p, 'access', _308 => _308.options, 'optionalAccess', _309 => _309.metric]) === "string" && map[p.options.metric]) out = { ...out, options: { ...out.options, metric: map[p.options.metric] } };
11296
- if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _310 => _310.options, 'optionalAccess', _311 => _311.fields]))) {
11535
+ if (isInputType(p.type) && typeof _optionalChain([p, 'access', _310 => _310.options, 'optionalAccess', _311 => _311.metric]) === "string" && map[p.options.metric]) out = { ...out, options: { ...out.options, metric: map[p.options.metric] } };
11536
+ if (p.type === INPUT_GROUP && Array.isArray(_optionalChain([p, 'access', _312 => _312.options, 'optionalAccess', _313 => _313.fields]))) {
11297
11537
  const to = (m) => typeof m === "string" && map[m] || m;
11298
- const fields = p.options.fields.map((f) => _optionalChain([f, 'optionalAccess', _312 => _312.options]) && to(f.options.metric) !== f.options.metric ? { ...f, options: { ...f.options, metric: to(f.options.metric) } } : f);
11538
+ const fields = p.options.fields.map((f) => _optionalChain([f, 'optionalAccess', _314 => _314.options]) && to(f.options.metric) !== f.options.metric ? { ...f, options: { ...f.options, metric: to(f.options.metric) } } : f);
11299
11539
  const titleFrom = to(p.options.titleFrom);
11300
11540
  out = { ...out, options: { ...out.options, fields, ...titleFrom !== void 0 && { titleFrom } } };
11301
11541
  }
11302
- if (_optionalChain([p, 'access', _313 => _313.targets, 'optionalAccess', _314 => _314.some, 'call', _315 => _315((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) };
11303
- if (_optionalChain([p, 'access', _316 => _316.panels, 'optionalAccess', _317 => _317.length])) out = { ...out, panels: p.panels.map(rename) };
11542
+ if (_optionalChain([p, 'access', _315 => _315.targets, 'optionalAccess', _316 => _316.some, 'call', _317 => _317((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) };
11543
+ if (_optionalChain([p, 'access', _318 => _318.panels, 'optionalAccess', _319 => _319.length])) out = { ...out, panels: p.panels.map(rename) };
11304
11544
  return out;
11305
11545
  };
11306
11546
  return panels.map(rename);
@@ -11320,7 +11560,7 @@ function copyPanels(dashboard, indices) {
11320
11560
  }
11321
11561
  }
11322
11562
  const chosen = order.filter((i) => picked.has(i)).map((i) => panels[i]);
11323
- return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access', _318 => _318.templating, 'optionalAccess', _319 => _319.list]), () => ( [])));
11563
+ return snippetOf(chosen, _nullishCoalesce(_optionalChain([dashboard, 'access', _320 => _320.templating, 'optionalAccess', _321 => _321.list]), () => ( [])));
11324
11564
  }
11325
11565
  function snippetOf(panels, available) {
11326
11566
  const left = Math.min(...panels.map((p) => pos2(p).x));
@@ -11388,7 +11628,7 @@ var sameVariable = (a, b) => {
11388
11628
  return strip(a) === strip(b);
11389
11629
  };
11390
11630
  function previewPaste(dashboard, snippet) {
11391
- const { added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _320 => _320.templating, 'optionalAccess', _321 => _321.list]), () => ( [])), snippet.variables);
11631
+ const { added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _322 => _322.templating, 'optionalAccess', _323 => _323.list]), () => ( [])), snippet.variables);
11392
11632
  return { added, renamed };
11393
11633
  }
11394
11634
  function mergeVariables(existing, incoming) {
@@ -11425,7 +11665,7 @@ function pasteSnippet(dashboard, snippet, options = {}) {
11425
11665
  return true;
11426
11666
  };
11427
11667
  let incoming = snippet.panels.filter(keep).map((p) => p.panels ? { ...p, panels: p.panels.filter(keep) } : p);
11428
- const { variables, added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _322 => _322.templating, 'optionalAccess', _323 => _323.list]), () => ( [])), snippet.variables);
11668
+ const { variables, added, renamed } = mergeVariables(_nullishCoalesce(_optionalChain([dashboard, 'access', _324 => _324.templating, 'optionalAccess', _325 => _325.list]), () => ( [])), snippet.variables);
11429
11669
  for (const [from, to] of Object.entries(renamed)) incoming = renameVariableInPanels(incoming, from, to);
11430
11670
  if (options.metrics) incoming = renameMetrics(incoming, options.metrics);
11431
11671
  const after = options.after != null ? existing[options.after] : void 0;
@@ -11490,7 +11730,7 @@ function parseTemplate(text) {
11490
11730
  if (seen.has(d.id)) return { error: `Two documents are called "${d.id}"` };
11491
11731
  seen.add(d.id);
11492
11732
  const { dashboard, issues } = prepareDashboard(d.dashboard, d.id);
11493
- if (!dashboard) return { error: `"${d.id}" can\u2019t be shown: ${_nullishCoalesce(_optionalChain([issues, 'access', _324 => _324.find, 'call', _325 => _325((x) => x.severity === "error"), 'optionalAccess', _326 => _326.message]), () => ( "it isn\u2019t a dashboard"))}` };
11733
+ if (!dashboard) return { error: `"${d.id}" can\u2019t be shown: ${_nullishCoalesce(_optionalChain([issues, 'access', _326 => _326.find, 'call', _327 => _327((x) => x.severity === "error"), 'optionalAccess', _328 => _328.message]), () => ( "it isn\u2019t a dashboard"))}` };
11494
11734
  if (dashboard.kind && dashboard.kind !== d.kind) return { error: `"${d.id}" is listed as a ${d.kind} but says it\u2019s a ${dashboard.kind}` };
11495
11735
  documents.push({ kind: d.kind, id: d.id, dashboard });
11496
11736
  }
@@ -11568,9 +11808,9 @@ function applyTemplate(manifestText, paths, template, options = {}) {
11568
11808
  }
11569
11809
  const tabIds = (_nullishCoalesce(manifest.tabs, () => ( []))).map((t) => t.id);
11570
11810
  const added = [];
11571
- let at = _nullishCoalesce(_optionalChain([manifest, 'access', _327 => _327.tabs, 'optionalAccess', _328 => _328.length]), () => ( 0));
11811
+ let at = _nullishCoalesce(_optionalChain([manifest, 'access', _329 => _329.tabs, 'optionalAccess', _330 => _330.length]), () => ( 0));
11572
11812
  for (const tab of template.tabs) {
11573
- if (!_optionalChain([options, 'access', _329 => _329.tabs, 'optionalAccess', _330 => _330.includes, 'call', _331 => _331(tab.id)])) continue;
11813
+ if (!_optionalChain([options, 'access', _331 => _331.tabs, 'optionalAccess', _332 => _332.includes, 'call', _333 => _333(tab.id)])) continue;
11574
11814
  const screen = retarget(tab.screen, ids);
11575
11815
  if (!screen) continue;
11576
11816
  const id = tabIdFor(tab.id, tabIds);
@@ -11792,7 +12032,7 @@ function readTemplateAnswer(text) {
11792
12032
  );
11793
12033
  const kept = new Set(template.tabs.map((t) => t.id));
11794
12034
  for (const [i, tab] of (Array.isArray(raw.tabs) ? raw.tabs : []).entries()) {
11795
- const id = _optionalChain([tab, 'optionalAccess', _332 => _332.id]);
12035
+ const id = _optionalChain([tab, 'optionalAccess', _334 => _334.id]);
11796
12036
  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`);
11797
12037
  }
11798
12038
  const kinds = new Map(template.documents.map((d) => [d.id, d.kind]));
@@ -11840,9 +12080,9 @@ function readDocumentAnswer(text, kind) {
11840
12080
  return { error: e.message };
11841
12081
  }
11842
12082
  const wrapper = json;
11843
- if (_optionalChain([wrapper, 'optionalAccess', _333 => _333.$modelform]) === "template") {
12083
+ if (_optionalChain([wrapper, 'optionalAccess', _335 => _335.$modelform]) === "template") {
11844
12084
  if (!Array.isArray(wrapper.documents) || wrapper.documents.length !== 1) return { error: `That\u2019s a template, not one ${kind}` };
11845
- json = _optionalChain([wrapper, 'access', _334 => _334.documents, 'access', _335 => _335[0], 'optionalAccess', _336 => _336.dashboard]);
12085
+ json = _optionalChain([wrapper, 'access', _336 => _336.documents, 'access', _337 => _337[0], 'optionalAccess', _338 => _338.dashboard]);
11846
12086
  }
11847
12087
  if (!json || typeof json !== "object" || Array.isArray(json)) return { error: `That isn\u2019t a ${kind}` };
11848
12088
  const raw = json;
@@ -11881,8 +12121,8 @@ function documentChanges(before, after) {
11881
12121
  const what = [];
11882
12122
  if (was.title !== p.title) what.push("title");
11883
12123
  if (was.type !== p.type) what.push("type");
11884
- if (_optionalChain([was, 'access', _337 => _337.gridPos, 'optionalAccess', _338 => _338.x]) !== _optionalChain([p, 'access', _339 => _339.gridPos, 'optionalAccess', _340 => _340.x]) || _optionalChain([was, 'access', _341 => _341.gridPos, 'optionalAccess', _342 => _342.y]) !== _optionalChain([p, 'access', _343 => _343.gridPos, 'optionalAccess', _344 => _344.y])) what.push("position");
11885
- if (_optionalChain([was, 'access', _345 => _345.gridPos, 'optionalAccess', _346 => _346.w]) !== _optionalChain([p, 'access', _347 => _347.gridPos, 'optionalAccess', _348 => _348.w]) || _optionalChain([was, 'access', _349 => _349.gridPos, 'optionalAccess', _350 => _350.h]) !== _optionalChain([p, 'access', _351 => _351.gridPos, 'optionalAccess', _352 => _352.h])) what.push("size");
12124
+ if (_optionalChain([was, 'access', _339 => _339.gridPos, 'optionalAccess', _340 => _340.x]) !== _optionalChain([p, 'access', _341 => _341.gridPos, 'optionalAccess', _342 => _342.x]) || _optionalChain([was, 'access', _343 => _343.gridPos, 'optionalAccess', _344 => _344.y]) !== _optionalChain([p, 'access', _345 => _345.gridPos, 'optionalAccess', _346 => _346.y])) what.push("position");
12125
+ if (_optionalChain([was, 'access', _347 => _347.gridPos, 'optionalAccess', _348 => _348.w]) !== _optionalChain([p, 'access', _349 => _349.gridPos, 'optionalAccess', _350 => _350.w]) || _optionalChain([was, 'access', _351 => _351.gridPos, 'optionalAccess', _352 => _352.h]) !== _optionalChain([p, 'access', _353 => _353.gridPos, 'optionalAccess', _354 => _354.h])) what.push("size");
11886
12126
  if (!same(was.options, p.options)) what.push("options");
11887
12127
  if (!same(was.targets, p.targets) || !same(was.datasource, p.datasource) || !same(was.transformations, p.transformations)) what.push("queries");
11888
12128
  if (!same(was.fieldConfig, p.fieldConfig)) what.push("field config");
@@ -12131,4 +12371,12 @@ function documentChanges(before, after) {
12131
12371
 
12132
12372
 
12133
12373
 
12134
- exports.frameLength = frameLength; exports.timeField = timeField; exports.numberFields = numberFields; exports.fieldDisplayName = fieldDisplayName; exports.toSeries = toSeries; exports.toXYSeries = toXYSeries; exports.uniqueNames = uniqueNames; exports.toMillis = toMillis; exports.parseTime = parseTime; exports.parseRange = parseRange; exports.addTime = addTime; exports.startOf = startOf; exports.parseDuration = parseDuration; exports.calculateInterval = calculateInterval; exports.formatDuration = formatDuration; exports.TIME_PRESETS = TIME_PRESETS; exports.RELATIVE_RANGES = RELATIVE_RANGES; exports.parseLocalDateTime = parseLocalDateTime; exports.formatLocalDateTime = formatLocalDateTime; exports.timeExprError = timeExprError; exports.describeRange = describeRange; exports.zoomRange = zoomRange; exports.ALL = ALL; exports.initialVariableValues = initialVariableValues; exports.variableOptions = variableOptions; exports.variableInfo = variableInfo; exports.visibleVariables = visibleVariables; exports.isSqlDatasource = isSqlDatasource; exports.framesToOptions = framesToOptions; exports.refineOptions = refineOptions; exports.selectValue = selectValue; exports.variableReferences = variableReferences; exports.interpolate = interpolate; exports.queryParam = queryParam; exports.interpolateDeep = interpolateDeep; exports.resolveTimezone = resolveTimezone; exports.valueText = valueText; exports.GRID_COLUMNS = GRID_COLUMNS; exports.gridUnitsToPx = gridUnitsToPx; exports.gridOffsetPx = gridOffsetPx; exports.compactGrid = compactGrid; exports.isRow = isRow; exports.layoutDashboard = layoutDashboard; exports.repeatOptions = repeatOptions; exports.panelKey = panelKey; exports.panelSpan = panelSpan; exports.applyTransformations = applyTransformations; exports.DASHBOARD_DS = DASHBOARD_DS; exports.dashboardSourceIds = dashboardSourceIds; exports.panelHasQueries = panelHasQueries; exports.queryPanel = queryPanel; exports.normalizeRef = normalizeRef; exports.refreshedVariables = refreshedVariables; exports.variableDependents = variableDependents; exports.variableOrder = variableOrder; exports.resolveVariables = resolveVariables; exports.REDUCER_LABELS = REDUCER_LABELS; exports.isReducer = isReducer; exports.reduce = reduce; exports.INPUT_OPTION_KEYS = INPUT_OPTION_KEYS; exports.INPUT_TYPES = INPUT_TYPES; exports.isInputType = isInputType; exports.isInputPanel = isInputPanel; exports.INPUT_GROUP = INPUT_GROUP; exports.isFormPanelType = isFormPanelType; exports.isInputGroup = isInputGroup; exports.GROUP_FIELD_TYPES = GROUP_FIELD_TYPES; exports.groupFields = groupFields; exports.inputPanels = inputPanels; exports.documentKind = documentKind; exports.inputGroups = inputGroups; exports.plainInputPanels = plainInputPanels; exports.parseClockDigits = parseClockDigits; exports.formatClock = formatClock; exports.toEntries = toEntries; exports.newSaveId = newSaveId; exports.isEmptyItem = isEmptyItem; exports.groupToEntries = groupToEntries; exports.entriesToItems = entriesToItems; exports.groupProblems = groupProblems; exports.sameSave = sameSave; exports.inputProblem = inputProblem; exports.entryToInputValue = entryToInputValue; exports.textSuggestions = textSuggestions; exports.entriesSavedWith = entriesSavedWith; exports.formatValue = formatValue; exports.thresholdStep = thresholdStep; exports.NAMED_COLORS = NAMED_COLORS; exports.resolveColor = resolveColor; exports.SERIES_PALETTE = SERIES_PALETTE; exports.seriesColor = seriesColor; exports.mappedResult = mappedResult; exports.formatDisplay = formatDisplay; exports.valueColor = valueColor; exports.resolveFieldConfig = resolveFieldConfig; exports.fieldMatches = fieldMatches; exports.GrafanaError = GrafanaError; exports.GrafanaClient = GrafanaClient; exports.GrafanaDataSource = GrafanaDataSource; exports.fromWire = fromWire; exports.LOCAL_DATASOURCE_TYPE = LOCAL_DATASOURCE_TYPE; exports.isLocalDatasource = isLocalDatasource; exports.LocalDataSource = LocalDataSource; exports.groupField = groupField; exports.buildFrames = buildFrames; exports.MemoryEntryStore = MemoryEntryStore; exports.DEFAULT_GAZETTEER = DEFAULT_GAZETTEER; exports.parseGazetteer = parseGazetteer; exports.loadGazetteer = loadGazetteer; exports.resolveLinks = resolveLinks; exports.parseDashboardLink = parseDashboardLink; exports.applyDashboardLink = applyDashboardLink; exports.appSchema = appSchema; exports.dashboardSchema = dashboardSchema; exports.pointerToPath = pointerToPath; exports.manifestSchemaIssues = manifestSchemaIssues; exports.dashboardSchemaIssues = dashboardSchemaIssues; exports.cleanDashboard = cleanDashboard; exports.MAPPING_TYPES = MAPPING_TYPES; exports.SPECIAL_MATCHES = SPECIAL_MATCHES; exports.mappingRows = mappingRows; exports.rowsToMappings = rowsToMappings; exports.mappingRow = mappingRow; exports.mappingProblem = mappingProblem; exports.OPTION_CATEGORIES = OPTION_CATEGORIES; exports.UNIT_CHOICES = UNIT_CHOICES; exports.panelOptions = panelOptions; exports.getPath = getPath; exports.optionValue = optionValue; exports.setOption = setOption; exports.setOptionValue = setOptionValue; exports.cleanPanelOptions = cleanPanelOptions; exports.OVERRIDE_MATCHERS = OVERRIDE_MATCHERS; exports.overrideProperties = overrideProperties; exports.panelOverrides = panelOverrides; exports.setOverrides = setOverrides; exports.MANIFEST_VERSION = MANIFEST_VERSION; exports.requiredManifestVersion = requiredManifestVersion; exports.validateManifest = validateManifest; exports.prepareDashboard = prepareDashboard; exports.validateDashboard = validateDashboard2; exports.validateBundle = validateBundle; exports.resolveUrl = resolveUrl; exports.httpFetchJson = httpFetchJson; exports.defaultFetchJson = defaultFetchJson; exports.BUNDLE_TYPE = BUNDLE_TYPE; exports.BUNDLE_ACCEPT = BUNDLE_ACCEPT; exports.isBundleResponse = isBundleResponse; exports.bundleRoot = bundleRoot; exports.assembleFromResponse = assembleFromResponse; exports.assembleBundle = assembleBundle; exports.fetchBundle = fetchBundle; exports.revalidateBundle = revalidateBundle; exports.ConfigLoader = ConfigLoader; exports.tabIdFor = tabIdFor; exports.screenOfType = screenOfType; exports.screenDocuments = screenDocuments; exports.documentUses = documentUses; exports.stringifyCompact = stringifyCompact; exports.applyJsonEdits = applyJsonEdits; exports.diffJson = diffJson; exports.documentIdFor = documentIdFor; exports.removeDocumentFromManifest = removeDocumentFromManifest; exports.renameDocumentInManifest = renameDocumentInManifest; exports.metricChanges = metricChanges; exports.REFRESH_CHOICES = REFRESH_CHOICES; exports.EDITABLE_VARIABLE_TYPES = EDITABLE_VARIABLE_TYPES; exports.isEditableVariableType = isEditableVariableType; exports.variableNameError = variableNameError; exports.newVariable = newVariable; exports.variableWithType = variableWithType; exports.variableWithQuery = variableWithQuery; exports.variableWithCurrent = variableWithCurrent; exports.variableWithFlags = variableWithFlags; exports.variableUses = variableUses; exports.renameVariableInPanels = renameVariableInPanels; exports.lineColumn = lineColumn; exports.parseJsonText = parseJsonText; exports.splitPath = splitPath; exports.locate = locate; exports.checkFiles = checkFiles; exports.bundleFromFiles = bundleFromFiles; exports.formatJsonText = formatJsonText; exports.setJsonValue = setJsonValue; exports.PANEL_TYPES = PANEL_TYPES; exports.newPanel = newPanel; exports.newDocument = newDocument; exports.SaveConflictError = SaveConflictError; exports.HttpConfigFiles = HttpConfigFiles; exports.fetchJsonWithToken = fetchJsonWithToken; exports.readConfigFiles = readConfigFiles; exports.readingOrder = readingOrder; exports.repack = repack; exports.CANVAS_GAP = CANVAS_GAP; exports.CANVAS_ROW_HEADER = CANVAS_ROW_HEADER; exports.panelSize = panelSize; exports.layoutCanvas = layoutCanvas; exports.dropTarget = dropTarget; exports.movePanel = movePanel; exports.resizePanel = resizePanel; exports.setHiddenOnPhones = setHiddenOnPhones; exports.nextPanelId = nextPanelId; exports.insertPanel = insertPanel; exports.duplicatePanel = duplicatePanel; exports.removePanel = removePanel; exports.expandRow = expandRow; exports.collapseRow = collapseRow; exports.settleLayout = settleLayout; exports.placePanel = placePanel; exports.snapToGrid = snapToGrid; exports.panelEdits = panelEdits; exports.sampleEntries = sampleEntries; exports.SNIPPET_VERSION = SNIPPET_VERSION; exports.panelMetrics = panelMetrics; exports.renameMetrics = renameMetrics; exports.copyPanels = copyPanels; exports.parseSnippet = parseSnippet; exports.previewPaste = previewPaste; exports.pasteSnippet = pasteSnippet; exports.TEMPLATE_VERSION = TEMPLATE_VERSION; exports.makeTemplate = makeTemplate; exports.parseTemplate = parseTemplate; exports.templateNeeds = templateNeeds; exports.applyTemplate = applyTemplate; exports.DOCUMENT_GUIDE = DOCUMENT_GUIDE; exports.AUTHORING_GUIDE = AUTHORING_GUIDE; exports.EXAMPLE_TEMPLATE = EXAMPLE_TEMPLATE; exports.templatePrompt = templatePrompt; exports.jsonFromAnswer = jsonFromAnswer; exports.readTemplateAnswer = readTemplateAnswer; exports.fixTemplatePrompt = fixTemplatePrompt; exports.documentPrompt = documentPrompt; exports.readDocumentAnswer = readDocumentAnswer; exports.fixDocumentPrompt = fixDocumentPrompt; exports.documentChanges = documentChanges;
12374
+
12375
+
12376
+
12377
+
12378
+
12379
+
12380
+
12381
+
12382
+ exports.frameLength = frameLength; exports.timeField = timeField; exports.numberFields = numberFields; exports.fieldDisplayName = fieldDisplayName; exports.toSeries = toSeries; exports.toXYSeries = toXYSeries; exports.uniqueNames = uniqueNames; exports.toMillis = toMillis; exports.parseTime = parseTime; exports.parseRange = parseRange; exports.addTime = addTime; exports.startOf = startOf; exports.parseDuration = parseDuration; exports.calculateInterval = calculateInterval; exports.formatDuration = formatDuration; exports.TIME_PRESETS = TIME_PRESETS; exports.RELATIVE_RANGES = RELATIVE_RANGES; exports.parseLocalDateTime = parseLocalDateTime; exports.formatLocalDateTime = formatLocalDateTime; exports.timeExprError = timeExprError; exports.describeRange = describeRange; exports.zoomRange = zoomRange; exports.ALL = ALL; exports.initialVariableValues = initialVariableValues; exports.variableOptions = variableOptions; exports.variableInfo = variableInfo; exports.visibleVariables = visibleVariables; exports.isSqlDatasource = isSqlDatasource; exports.framesToOptions = framesToOptions; exports.refineOptions = refineOptions; exports.selectValue = selectValue; exports.variableReferences = variableReferences; exports.interpolate = interpolate; exports.queryParam = queryParam; exports.interpolateDeep = interpolateDeep; exports.resolveTimezone = resolveTimezone; exports.valueText = valueText; exports.GRID_COLUMNS = GRID_COLUMNS; exports.gridUnitsToPx = gridUnitsToPx; exports.gridOffsetPx = gridOffsetPx; exports.compactGrid = compactGrid; exports.isRow = isRow; exports.layoutDashboard = layoutDashboard; exports.repeatOptions = repeatOptions; exports.panelKey = panelKey; exports.panelSpan = panelSpan; exports.applyTransformations = applyTransformations; exports.DASHBOARD_DS = DASHBOARD_DS; exports.dashboardSourceIds = dashboardSourceIds; exports.panelHasQueries = panelHasQueries; exports.queryPanel = queryPanel; exports.normalizeRef = normalizeRef; exports.refreshedVariables = refreshedVariables; exports.variableDependents = variableDependents; exports.variableOrder = variableOrder; exports.resolveVariables = resolveVariables; exports.REDUCER_LABELS = REDUCER_LABELS; exports.isReducer = isReducer; exports.reduce = reduce; exports.INPUT_OPTION_KEYS = INPUT_OPTION_KEYS; exports.INPUT_TYPES = INPUT_TYPES; exports.isInputType = isInputType; exports.isInputPanel = isInputPanel; exports.INPUT_GROUP = INPUT_GROUP; exports.isFormPanelType = isFormPanelType; exports.isInputGroup = isInputGroup; exports.GROUP_FIELD_TYPES = GROUP_FIELD_TYPES; exports.groupFields = groupFields; exports.inputPanels = inputPanels; exports.documentKind = documentKind; exports.inputGroups = inputGroups; exports.plainInputPanels = plainInputPanels; exports.parseClockDigits = parseClockDigits; exports.formatClock = formatClock; exports.toEntries = toEntries; exports.newSaveId = newSaveId; exports.isEmptyItem = isEmptyItem; exports.groupToEntries = groupToEntries; exports.entriesToItems = entriesToItems; exports.groupProblems = groupProblems; exports.sameSave = sameSave; exports.inputProblem = inputProblem; exports.entryToInputValue = entryToInputValue; exports.textSuggestions = textSuggestions; exports.entriesSavedWith = entriesSavedWith; exports.formatValue = formatValue; exports.thresholdStep = thresholdStep; exports.NAMED_COLORS = NAMED_COLORS; exports.resolveColor = resolveColor; exports.SERIES_PALETTE = SERIES_PALETTE; exports.seriesColor = seriesColor; exports.mappedResult = mappedResult; exports.formatDisplay = formatDisplay; exports.valueColor = valueColor; exports.resolveFieldConfig = resolveFieldConfig; exports.fieldMatches = fieldMatches; exports.GrafanaError = GrafanaError; exports.GrafanaClient = GrafanaClient; exports.GrafanaDataSource = GrafanaDataSource; exports.fromWire = fromWire; exports.parseSpokenNumber = parseSpokenNumber; exports.parseSpokenDuration = parseSpokenDuration; exports.matchChoices = matchChoices; exports.parseSpokenYesNo = parseSpokenYesNo; exports.spokenValue = spokenValue; exports.DICTATION_TYPES = DICTATION_TYPES; exports.takesDictation = takesDictation; exports.dictationHints = dictationHints; exports.LOCAL_DATASOURCE_TYPE = LOCAL_DATASOURCE_TYPE; exports.isLocalDatasource = isLocalDatasource; exports.LocalDataSource = LocalDataSource; exports.groupField = groupField; exports.buildFrames = buildFrames; exports.MemoryEntryStore = MemoryEntryStore; exports.DEFAULT_GAZETTEER = DEFAULT_GAZETTEER; exports.parseGazetteer = parseGazetteer; exports.loadGazetteer = loadGazetteer; exports.resolveLinks = resolveLinks; exports.parseDashboardLink = parseDashboardLink; exports.applyDashboardLink = applyDashboardLink; exports.appSchema = appSchema; exports.dashboardSchema = dashboardSchema; exports.pointerToPath = pointerToPath; exports.manifestSchemaIssues = manifestSchemaIssues; exports.dashboardSchemaIssues = dashboardSchemaIssues; exports.cleanDashboard = cleanDashboard; exports.MAPPING_TYPES = MAPPING_TYPES; exports.SPECIAL_MATCHES = SPECIAL_MATCHES; exports.mappingRows = mappingRows; exports.rowsToMappings = rowsToMappings; exports.mappingRow = mappingRow; exports.mappingProblem = mappingProblem; exports.OPTION_CATEGORIES = OPTION_CATEGORIES; exports.UNIT_CHOICES = UNIT_CHOICES; exports.panelOptions = panelOptions; exports.getPath = getPath; exports.optionValue = optionValue; exports.setOption = setOption; exports.setOptionValue = setOptionValue; exports.cleanPanelOptions = cleanPanelOptions; exports.OVERRIDE_MATCHERS = OVERRIDE_MATCHERS; exports.overrideProperties = overrideProperties; exports.panelOverrides = panelOverrides; exports.setOverrides = setOverrides; exports.MANIFEST_VERSION = MANIFEST_VERSION; exports.requiredManifestVersion = requiredManifestVersion; exports.validateManifest = validateManifest; exports.prepareDashboard = prepareDashboard; exports.validateDashboard = validateDashboard2; exports.validateBundle = validateBundle; exports.resolveUrl = resolveUrl; exports.httpFetchJson = httpFetchJson; exports.defaultFetchJson = defaultFetchJson; exports.BUNDLE_TYPE = BUNDLE_TYPE; exports.BUNDLE_ACCEPT = BUNDLE_ACCEPT; exports.isBundleResponse = isBundleResponse; exports.bundleRoot = bundleRoot; exports.assembleFromResponse = assembleFromResponse; exports.assembleBundle = assembleBundle; exports.fetchBundle = fetchBundle; exports.revalidateBundle = revalidateBundle; exports.ConfigLoader = ConfigLoader; exports.tabIdFor = tabIdFor; exports.screenOfType = screenOfType; exports.screenDocuments = screenDocuments; exports.documentUses = documentUses; exports.stringifyCompact = stringifyCompact; exports.applyJsonEdits = applyJsonEdits; exports.diffJson = diffJson; exports.documentIdFor = documentIdFor; exports.removeDocumentFromManifest = removeDocumentFromManifest; exports.renameDocumentInManifest = renameDocumentInManifest; exports.metricChanges = metricChanges; exports.REFRESH_CHOICES = REFRESH_CHOICES; exports.EDITABLE_VARIABLE_TYPES = EDITABLE_VARIABLE_TYPES; exports.isEditableVariableType = isEditableVariableType; exports.variableNameError = variableNameError; exports.newVariable = newVariable; exports.variableWithType = variableWithType; exports.variableWithQuery = variableWithQuery; exports.variableWithCurrent = variableWithCurrent; exports.variableWithFlags = variableWithFlags; exports.variableUses = variableUses; exports.renameVariableInPanels = renameVariableInPanels; exports.lineColumn = lineColumn; exports.parseJsonText = parseJsonText; exports.splitPath = splitPath; exports.locate = locate; exports.checkFiles = checkFiles; exports.bundleFromFiles = bundleFromFiles; exports.formatJsonText = formatJsonText; exports.setJsonValue = setJsonValue; exports.PANEL_TYPES = PANEL_TYPES; exports.newPanel = newPanel; exports.newDocument = newDocument; exports.SaveConflictError = SaveConflictError; exports.HttpConfigFiles = HttpConfigFiles; exports.fetchJsonWithToken = fetchJsonWithToken; exports.readConfigFiles = readConfigFiles; exports.readingOrder = readingOrder; exports.repack = repack; exports.CANVAS_GAP = CANVAS_GAP; exports.CANVAS_ROW_HEADER = CANVAS_ROW_HEADER; exports.panelSize = panelSize; exports.layoutCanvas = layoutCanvas; exports.dropTarget = dropTarget; exports.movePanel = movePanel; exports.resizePanel = resizePanel; exports.setHiddenOnPhones = setHiddenOnPhones; exports.nextPanelId = nextPanelId; exports.insertPanel = insertPanel; exports.duplicatePanel = duplicatePanel; exports.removePanel = removePanel; exports.expandRow = expandRow; exports.collapseRow = collapseRow; exports.settleLayout = settleLayout; exports.placePanel = placePanel; exports.snapToGrid = snapToGrid; exports.panelEdits = panelEdits; exports.sampleEntries = sampleEntries; exports.SNIPPET_VERSION = SNIPPET_VERSION; exports.panelMetrics = panelMetrics; exports.renameMetrics = renameMetrics; exports.copyPanels = copyPanels; exports.parseSnippet = parseSnippet; exports.previewPaste = previewPaste; exports.pasteSnippet = pasteSnippet; exports.TEMPLATE_VERSION = TEMPLATE_VERSION; exports.makeTemplate = makeTemplate; exports.parseTemplate = parseTemplate; exports.templateNeeds = templateNeeds; exports.applyTemplate = applyTemplate; exports.DOCUMENT_GUIDE = DOCUMENT_GUIDE; exports.AUTHORING_GUIDE = AUTHORING_GUIDE; exports.EXAMPLE_TEMPLATE = EXAMPLE_TEMPLATE; exports.templatePrompt = templatePrompt; exports.jsonFromAnswer = jsonFromAnswer; exports.readTemplateAnswer = readTemplateAnswer; exports.fixTemplatePrompt = fixTemplatePrompt; exports.documentPrompt = documentPrompt; exports.readDocumentAnswer = readDocumentAnswer; exports.fixDocumentPrompt = fixDocumentPrompt; exports.documentChanges = documentChanges;