vite-plugin-kiru 0.32.0-preview.0 → 0.32.0-preview.2

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.
package/dist/index.js CHANGED
@@ -27,7 +27,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
27
  // ../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js
28
28
  var require_sourcemap_codec_umd = __commonJS({
29
29
  "../../node_modules/.pnpm/@jridgewell+sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js"(exports, module) {
30
- (function(global, factory) {
30
+ (function(global2, factory) {
31
31
  if (typeof exports === "object" && typeof module !== "undefined") {
32
32
  factory(module);
33
33
  module.exports = def(module);
@@ -39,8 +39,8 @@ var require_sourcemap_codec_umd = __commonJS({
39
39
  } else {
40
40
  const mod = { exports: {} };
41
41
  factory(mod);
42
- global = typeof globalThis !== "undefined" ? globalThis : global || self;
43
- global.sourcemapCodec = def(mod);
42
+ global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self;
43
+ global2.sourcemapCodec = def(mod);
44
44
  }
45
45
  function def(m) {
46
46
  return "default" in m.exports ? m.exports.default : m.exports;
@@ -1716,784 +1716,328 @@ var require_magic_string_cjs = __commonJS({
1716
1716
  });
1717
1717
 
1718
1718
  // src/index.ts
1719
- import path7 from "node:path";
1720
-
1721
- // src/codegen/shared.ts
1722
- var import_magic_string = __toESM(require_magic_string_cjs(), 1);
1719
+ import path8 from "node:path";
1723
1720
 
1724
- // src/codegen/ast.ts
1725
- function findNode(node, predicate, maxDepth = Infinity) {
1726
- let res = null;
1727
- walk(node, {
1728
- "*": (node2, ctx) => {
1729
- if (predicate(node2)) {
1730
- res = node2;
1731
- ctx.exit();
1732
- }
1733
- if (ctx.stack.length >= maxDepth) ctx.exitBranch();
1734
- }
1735
- });
1736
- return res;
1737
- }
1738
- function walk(node, visitor) {
1739
- const ctx = {
1740
- stack: [],
1741
- exit: exitWalk,
1742
- exitBranch
1721
+ // ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
1722
+ var balanced = (a, b, str) => {
1723
+ const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
1724
+ const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
1725
+ const r = ma !== null && mb != null && range(ma, mb, str);
1726
+ return r && {
1727
+ start: r[0],
1728
+ end: r[1],
1729
+ pre: str.slice(0, r[0]),
1730
+ body: str.slice(r[0] + ma.length, r[1]),
1731
+ post: str.slice(r[1] + mb.length)
1743
1732
  };
1744
- try {
1745
- walk_impl(node, visitor, ctx);
1746
- } catch (error) {
1747
- if (error === "walk:exit") return;
1748
- throw error;
1749
- }
1750
- }
1751
- var exitWalk = () => {
1752
- throw "walk:exit";
1753
- };
1754
- var exitBranch = () => {
1755
- throw "walk:exit-branch";
1756
1733
  };
1757
- var flushCallbacks = (callbacks) => {
1758
- while (callbacks.length) {
1759
- callbacks.pop()();
1760
- }
1734
+ var maybeMatch = (reg, str) => {
1735
+ const m = str.match(reg);
1736
+ return m ? m[0] : null;
1761
1737
  };
1762
- function walk_impl(node, visitor, ctx) {
1763
- const onExitCallbacks = [];
1764
- try {
1765
- {
1766
- const cb = visitor[node.type]?.(node, ctx);
1767
- if (cb instanceof Function) onExitCallbacks.push(cb);
1768
- }
1769
- {
1770
- const cb = visitor["*"]?.(node, ctx);
1771
- if (cb instanceof Function) onExitCallbacks.push(cb);
1772
- }
1773
- } catch (error) {
1774
- if (error === "walk:exit-branch") {
1775
- flushCallbacks(onExitCallbacks);
1776
- return;
1738
+ var range = (a, b, str) => {
1739
+ let begs, beg, left, right = void 0, result;
1740
+ let ai = str.indexOf(a);
1741
+ let bi = str.indexOf(b, ai + 1);
1742
+ let i = ai;
1743
+ if (ai >= 0 && bi > 0) {
1744
+ if (a === b) {
1745
+ return [ai, bi];
1777
1746
  }
1778
- throw error;
1779
- }
1780
- ctx.stack.push(node);
1781
- [
1782
- node.arguments,
1783
- node.declarations,
1784
- node.properties,
1785
- node.property,
1786
- node.cases,
1787
- node.body,
1788
- node.consequent,
1789
- node.init,
1790
- node.argument,
1791
- node.alternate,
1792
- node.callee,
1793
- node.declaration,
1794
- node.expression,
1795
- node.expressions,
1796
- node.left,
1797
- node.right
1798
- ].filter(Boolean).forEach((a) => {
1799
- if (Array.isArray(a)) {
1800
- for (let i = 0; i < a.length; i++) {
1801
- walk_impl(a[i], visitor, ctx);
1747
+ begs = [];
1748
+ left = str.length;
1749
+ while (i >= 0 && !result) {
1750
+ if (i === ai) {
1751
+ begs.push(i);
1752
+ ai = str.indexOf(a, i + 1);
1753
+ } else if (begs.length === 1) {
1754
+ const r = begs.pop();
1755
+ if (r !== void 0)
1756
+ result = [r, bi];
1757
+ } else {
1758
+ beg = begs.pop();
1759
+ if (beg !== void 0 && beg < left) {
1760
+ left = beg;
1761
+ right = bi;
1762
+ }
1763
+ bi = str.indexOf(b, i + 1);
1802
1764
  }
1803
- return;
1765
+ i = ai < bi && ai >= 0 ? ai : bi;
1804
1766
  }
1805
- if (typeof a === "object" && "type" in a) {
1806
- walk_impl(a, visitor, ctx);
1807
- return;
1767
+ if (begs.length && right !== void 0) {
1768
+ result = [left, right];
1808
1769
  }
1809
- });
1810
- if (node.type === "Property" && node.value && typeof node.value === "object") {
1811
- walk_impl(node.value, visitor, ctx);
1812
1770
  }
1813
- ctx.stack.pop();
1814
- flushCallbacks(onExitCallbacks);
1815
- }
1771
+ return result;
1772
+ };
1816
1773
 
1817
- // src/codegen/shared.ts
1818
- function createAliasHandler(name, namespace = "kiru") {
1819
- const aliases = /* @__PURE__ */ new Set();
1820
- const isMatchingCallExpression = (node) => node.type === "CallExpression" && node.callee?.type === "Identifier" && typeof node.callee.name === "string" && aliases.has(node.callee.name);
1821
- const addAliases = (node) => {
1822
- if (node.source?.value !== namespace) return false;
1823
- let didAdd = false;
1824
- const specifiers = node.specifiers || [];
1825
- for (let i = 0; i < specifiers.length; i++) {
1826
- const specifier = specifiers[i];
1827
- if (specifier.imported && specifier.imported.name === name && !!specifier.local) {
1828
- aliases.add(specifier.local.name);
1829
- didAdd = true;
1830
- }
1831
- }
1832
- return didAdd;
1833
- };
1834
- return { name, aliases, addAliases, isMatchingCallExpression };
1774
+ // ../../node_modules/.pnpm/@isaacs+brace-expansion@5.0.0/node_modules/@isaacs/brace-expansion/dist/esm/index.js
1775
+ var escSlash = "\0SLASH" + Math.random() + "\0";
1776
+ var escOpen = "\0OPEN" + Math.random() + "\0";
1777
+ var escClose = "\0CLOSE" + Math.random() + "\0";
1778
+ var escComma = "\0COMMA" + Math.random() + "\0";
1779
+ var escPeriod = "\0PERIOD" + Math.random() + "\0";
1780
+ var escSlashPattern = new RegExp(escSlash, "g");
1781
+ var escOpenPattern = new RegExp(escOpen, "g");
1782
+ var escClosePattern = new RegExp(escClose, "g");
1783
+ var escCommaPattern = new RegExp(escComma, "g");
1784
+ var escPeriodPattern = new RegExp(escPeriod, "g");
1785
+ var slashPattern = /\\\\/g;
1786
+ var openPattern = /\\{/g;
1787
+ var closePattern = /\\}/g;
1788
+ var commaPattern = /\\,/g;
1789
+ var periodPattern = /\\./g;
1790
+ function numeric(str) {
1791
+ return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
1835
1792
  }
1836
- function isComponent(node, bodyNodes) {
1837
- const isTlf = isTopLevelFunction(node, bodyNodes);
1838
- if (!isTlf) return false;
1839
- const name = findNodeName(node);
1840
- if (name === null) return false;
1841
- const charCode = name.charCodeAt(0);
1842
- return charCode >= 65 && charCode <= 90;
1793
+ function escapeBraces(str) {
1794
+ return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
1843
1795
  }
1844
- function findNodeName(node) {
1845
- if (node.id?.name) return node.id.name;
1846
- if (node.declaration?.id?.name) return node.declaration.id.name;
1847
- if (node.declaration?.declarations?.[0]?.id?.name)
1848
- return node.declaration.declarations[0].id.name;
1849
- if (node.declarations?.[0]?.id?.name) return node.declarations[0].id.name;
1850
- return null;
1796
+ function unescapeBraces(str) {
1797
+ return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
1851
1798
  }
1852
- function findFunctionBodyNodes(node, name, bodyNodes) {
1853
- let dec = node.declaration;
1854
- if (!dec) {
1855
- for (const _node of bodyNodes) {
1856
- if (_node.type === "VariableDeclaration") {
1857
- if (_node.declarations?.[0]?.id?.name === name) {
1858
- dec = _node;
1859
- break;
1860
- }
1861
- } else if (_node.type === "FunctionDeclaration") {
1862
- if (_node.id?.name === name) {
1863
- dec = _node;
1864
- break;
1865
- }
1866
- }
1867
- }
1799
+ function parseCommaParts(str) {
1800
+ if (!str) {
1801
+ return [""];
1868
1802
  }
1869
- if (!dec) {
1870
- throw new Error(
1871
- "[vite-plugin-kiru]: failed to find declaration for component"
1872
- );
1803
+ const parts = [];
1804
+ const m = balanced("{", "}", str);
1805
+ if (!m) {
1806
+ return str.split(",");
1873
1807
  }
1874
- if (dec.type === "FunctionDeclaration" && dec.body && !Array.isArray(dec.body) && dec.body.type === "BlockStatement") {
1875
- return dec.body.body;
1876
- } else if (dec.type === "VariableDeclaration") {
1877
- if (!Array.isArray(dec.declarations)) {
1878
- return null;
1879
- }
1880
- for (const _dec of dec.declarations) {
1881
- if (_dec.id?.name !== name) continue;
1882
- if (_dec.init?.type === "ArrowFunctionExpression" || _dec.init?.type === "FunctionExpression") {
1883
- return _dec.init.body.body;
1884
- } else if (_dec.init?.type === "CallExpression" && _dec.init.arguments) {
1885
- const nodes = [];
1886
- for (const arg of _dec.init.arguments) {
1887
- if (isFuncDecOrExpr(arg) && arg.body && !Array.isArray(arg.body) && Array.isArray(arg.body.body)) {
1888
- nodes.push(...arg.body.body);
1889
- }
1890
- }
1891
- return nodes;
1892
- }
1893
- }
1808
+ const { pre, body, post } = m;
1809
+ const p = pre.split(",");
1810
+ p[p.length - 1] += "{" + body + "}";
1811
+ const postParts = parseCommaParts(post);
1812
+ if (post.length) {
1813
+ ;
1814
+ p[p.length - 1] += postParts.shift();
1815
+ p.push.apply(p, postParts);
1894
1816
  }
1895
- return null;
1817
+ parts.push.apply(parts, p);
1818
+ return parts;
1896
1819
  }
1897
- function isFuncDecOrExpr(node) {
1898
- if (!node) return false;
1899
- if (node.type === "VariableDeclaration") {
1900
- return isFuncDecOrExpr(node.declarations?.[0]?.init);
1820
+ function expand(str) {
1821
+ if (!str) {
1822
+ return [];
1901
1823
  }
1902
- return [
1903
- "FunctionDeclaration",
1904
- "FunctionExpression",
1905
- "ArrowFunctionExpression"
1906
- ].includes(node.type);
1907
- }
1908
- function isTopLevelFunction(node, bodyNodes) {
1909
- if (isFuncDecOrExpr(node)) {
1910
- return true;
1911
- }
1912
- switch (node.type) {
1913
- case "VariableDeclaration":
1914
- case "ExportNamedDeclaration":
1915
- if (node.declaration) {
1916
- return isFuncDecOrExpr(node.declaration);
1917
- } else if (node.declarations) {
1918
- return !!findNode(node, isFuncDecOrExpr);
1919
- }
1920
- const name = findNodeName(node);
1921
- if (name === null) return false;
1922
- const dec = findFunctionBodyNodes(node, name, bodyNodes);
1923
- if (!dec) return false;
1924
- return isFuncDecOrExpr(dec[0]);
1925
- case "ExportDefaultDeclaration":
1926
- return isFuncDecOrExpr(node.declaration);
1824
+ if (str.slice(0, 2) === "{}") {
1825
+ str = "\\{\\}" + str.slice(2);
1927
1826
  }
1928
- return false;
1929
- }
1930
-
1931
- // src/codegen/hmr.ts
1932
- import fs from "node:fs";
1933
- var UNNAMED_WATCH_PREAMBLE = `
1934
-
1935
- if (import.meta.hot && "window" in globalThis) {
1936
- window.__kiru.HMRContext?.signals.registerNextWatch();
1827
+ return expand_(escapeBraces(str), true).map(unescapeBraces);
1937
1828
  }
1938
- `;
1939
- function prepareHMR(ctx) {
1940
- const { code, ast, fileLinkFormatter, filePath } = ctx;
1941
- try {
1942
- const hotVars = findHotVars(code, ast.body, filePath);
1943
- if (hotVars.size === 0 && !code.hasChanged()) return;
1944
- code.prepend(`
1945
- if (import.meta.hot && "window" in globalThis) {
1946
- window.__kiru.HMRContext?.prepare("${filePath}");
1829
+ function embrace(str) {
1830
+ return "{" + str + "}";
1947
1831
  }
1948
- `);
1949
- code.append(`
1950
- if (import.meta.hot && "window" in globalThis) {
1951
- import.meta.hot.accept();
1952
- ${createHMRRegistrationBlurb(hotVars, fileLinkFormatter, filePath)}
1832
+ function isPadded(el) {
1833
+ return /^-?0\d/.test(el);
1953
1834
  }
1954
- `);
1955
- } catch (error) {
1956
- console.error(
1957
- "[vite-plugin-kiru]: HMR preparation failed for",
1958
- filePath,
1959
- error
1960
- );
1961
- }
1835
+ function lte(i, y) {
1836
+ return i <= y;
1962
1837
  }
1963
- function createHMRRegistrationBlurb(hotVars, fileLinkFormatter, filePath) {
1964
- const src = fs.readFileSync(filePath, "utf-8");
1965
- const entries = Array.from(hotVars).map(({ name, type }) => {
1966
- const key = JSON.stringify(name);
1967
- const line = findHotVarLineInSrc(src, name);
1968
- return ` ${key}: {
1969
- type: "${type}",
1970
- value: ${name},
1971
- link: "${fileLinkFormatter(filePath, line)}"
1972
- }`;
1973
- });
1974
- return `
1975
- window.__kiru.HMRContext?.register({
1976
- ${entries.join(",\n")}
1977
- });`;
1838
+ function gte(i, y) {
1839
+ return i >= y;
1978
1840
  }
1979
- function findHotVarLineInSrc(src, name) {
1980
- const lines = src.split("\n");
1981
- const potentialMatches = [
1982
- `const ${name}`,
1983
- `let ${name}`,
1984
- `var ${name}`,
1985
- `function ${name}`,
1986
- `export const ${name}`,
1987
- `export let ${name}`,
1988
- `export var ${name}`,
1989
- `export default ${name}`,
1990
- `export function ${name}`,
1991
- `export default function ${name}`
1992
- ];
1993
- for (let i = 0; i < lines.length; i++) {
1994
- const line = lines[i];
1995
- for (let j = 0; j < potentialMatches.length; j++) {
1996
- if (line.startsWith(potentialMatches[j])) return i + 1;
1841
+ function expand_(str, isTop) {
1842
+ const expansions = [];
1843
+ const m = balanced("{", "}", str);
1844
+ if (!m)
1845
+ return [str];
1846
+ const pre = m.pre;
1847
+ const post = m.post.length ? expand_(m.post, false) : [""];
1848
+ if (/\$$/.test(m.pre)) {
1849
+ for (let k = 0; k < post.length; k++) {
1850
+ const expansion = pre + "{" + m.body + "}" + post[k];
1851
+ expansions.push(expansion);
1997
1852
  }
1998
- }
1999
- return 0;
2000
- }
2001
- var exprAssign = [
2002
- "ExpressionStatement",
2003
- "AssignmentExpression"
2004
- ];
2005
- var allowedHotVarParentStacks = [
2006
- ["VariableDeclaration", "VariableDeclarator"],
2007
- exprAssign,
2008
- ["ExportNamedDeclaration", "VariableDeclaration", "VariableDeclarator"]
2009
- ];
2010
- function findHotVars(code, bodyNodes, _id) {
2011
- const hotVars = /* @__PURE__ */ new Set();
2012
- const aliasHandlers = [
2013
- "createStore",
2014
- "signal",
2015
- "computed",
2016
- "watch",
2017
- "createContext",
2018
- "lazy"
2019
- ].map((name) => createAliasHandler(name));
2020
- aliasHandlers.push(createAliasHandler("definePageConfig", "kiru/router"));
2021
- for (const node of bodyNodes) {
2022
- if (node.type === "ImportDeclaration") {
2023
- for (const aliasHandler of aliasHandlers) {
2024
- aliasHandler.addAliases(node);
1853
+ } else {
1854
+ const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
1855
+ const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
1856
+ const isSequence = isNumericSequence || isAlphaSequence;
1857
+ const isOptions = m.body.indexOf(",") >= 0;
1858
+ if (!isSequence && !isOptions) {
1859
+ if (m.post.match(/,(?!,).*\}/)) {
1860
+ str = m.pre + "{" + m.body + escClose + m.post;
1861
+ return expand_(str);
2025
1862
  }
2026
- continue;
1863
+ return [str];
2027
1864
  }
2028
- if (isComponent(node, bodyNodes)) {
2029
- addHotVarDesc(node, hotVars, "component");
2030
- continue;
1865
+ let n;
1866
+ if (isSequence) {
1867
+ n = m.body.split(/\.\./);
1868
+ } else {
1869
+ n = parseCommaParts(m.body);
1870
+ if (n.length === 1 && n[0] !== void 0) {
1871
+ n = expand_(n[0], false).map(embrace);
1872
+ if (n.length === 1) {
1873
+ return post.map((p) => m.pre + n[0] + p);
1874
+ }
1875
+ }
2031
1876
  }
2032
- for (const aliasHandler of aliasHandlers) {
2033
- walk(node, {
2034
- CallExpression: (node2, ctx) => {
2035
- if (!aliasHandler.isMatchingCallExpression(node2)) {
2036
- return ctx.exitBranch();
2037
- }
2038
- if (aliasHandler.name === "watch" && ctx.stack.length === 1 && ctx.stack[0].type === "ExpressionStatement") {
2039
- code.appendRight(node2.start, UNNAMED_WATCH_PREAMBLE);
2040
- return ctx.exit();
1877
+ let N;
1878
+ if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
1879
+ const x = numeric(n[0]);
1880
+ const y = numeric(n[1]);
1881
+ const width = Math.max(n[0].length, n[1].length);
1882
+ let incr = n.length === 3 && n[2] !== void 0 ? Math.abs(numeric(n[2])) : 1;
1883
+ let test = lte;
1884
+ const reverse = y < x;
1885
+ if (reverse) {
1886
+ incr *= -1;
1887
+ test = gte;
1888
+ }
1889
+ const pad = n.some(isPadded);
1890
+ N = [];
1891
+ for (let i = x; test(i, y); i += incr) {
1892
+ let c;
1893
+ if (isAlphaSequence) {
1894
+ c = String.fromCharCode(i);
1895
+ if (c === "\\") {
1896
+ c = "";
2041
1897
  }
2042
- const matchingParentStack = allowedHotVarParentStacks.find(
2043
- (stack) => {
2044
- return stack.every((type, i) => ctx.stack[i]?.type === type);
1898
+ } else {
1899
+ c = String(i);
1900
+ if (pad) {
1901
+ const need = width - c.length;
1902
+ if (need > 0) {
1903
+ const z = new Array(need + 1).join("0");
1904
+ if (i < 0) {
1905
+ c = "-" + z + c.slice(1);
1906
+ } else {
1907
+ c = z + c;
1908
+ }
2045
1909
  }
2046
- );
2047
- if (!matchingParentStack) {
2048
- return ctx.exitBranch();
2049
- }
2050
- if (matchingParentStack === exprAssign) {
2051
- const [_expr, assign] = ctx.stack;
2052
- const name2 = assign.left?.name;
2053
- if (!name2) return ctx.exit();
2054
- hotVars.add({
2055
- type: aliasHandler.name,
2056
- name: name2
2057
- });
2058
- return ctx.exit();
2059
- }
2060
- const remainingStack = ctx.stack.slice(matchingParentStack.length);
2061
- if (remainingStack.some(
2062
- (n) => n.type !== "ObjectExpression" && n.type !== "Property"
2063
- )) {
2064
- return ctx.exitBranch();
2065
1910
  }
2066
- const name = ctx.stack.reduce((acc, item) => {
2067
- switch (item.type) {
2068
- case "VariableDeclarator":
2069
- return item.id.name;
2070
- case "Property":
2071
- if (!item.key) return acc;
2072
- if (item.key.name) return `${acc}.${item.key.name}`;
2073
- if (item.key.raw) return `${acc}[${item.key.raw}]`;
2074
- return acc;
2075
- }
2076
- return acc;
2077
- }, "");
2078
- hotVars.add({ type: aliasHandler.name, name });
2079
- ctx.exitBranch();
2080
1911
  }
2081
- });
1912
+ N.push(c);
1913
+ }
1914
+ } else {
1915
+ N = [];
1916
+ for (let j = 0; j < n.length; j++) {
1917
+ N.push.apply(N, expand_(n[j], false));
1918
+ }
1919
+ }
1920
+ for (let j = 0; j < N.length; j++) {
1921
+ for (let k = 0; k < post.length; k++) {
1922
+ const expansion = pre + N[j] + post[k];
1923
+ if (!isTop || isSequence || expansion) {
1924
+ expansions.push(expansion);
1925
+ }
1926
+ }
2082
1927
  }
2083
1928
  }
2084
- return hotVars;
1929
+ return expansions;
2085
1930
  }
2086
- function addHotVarDesc(node, names, type) {
2087
- const name = findNodeName(node);
2088
- if (name == null && type === "component") {
2089
- console.error("[vite-plugin-kiru]: failed to find component name", node);
2090
- throw new Error("[vite-plugin-kiru]: Component name not found");
2091
- }
2092
- if (name !== null) {
2093
- names.add({ type, name });
1931
+
1932
+ // ../../node_modules/.pnpm/minimatch@10.1.1/node_modules/minimatch/dist/esm/assert-valid-pattern.js
1933
+ var MAX_PATTERN_LENGTH = 1024 * 64;
1934
+ var assertValidPattern = (pattern) => {
1935
+ if (typeof pattern !== "string") {
1936
+ throw new TypeError("invalid pattern");
2094
1937
  }
2095
- }
1938
+ if (pattern.length > MAX_PATTERN_LENGTH) {
1939
+ throw new TypeError("pattern is too long");
1940
+ }
1941
+ };
2096
1942
 
2097
- // src/codegen/devOnlyHooks.ts
2098
- function prepareDevOnlyHooks(ctx) {
2099
- const { code, ast, isBuild } = ctx;
2100
- replaceOnHMRCallbacks(code, ast, isBuild);
2101
- }
2102
- var VITE_IMPORT_META_HOT_ACCEPT = `if ("window" in globalThis) {
2103
- if (import.meta.hot) {
2104
- import.meta.hot.accept(%);
2105
- }
2106
- }`;
2107
- function replaceOnHMRCallbacks(code, ast, isBuild) {
2108
- const onHMRAliasHandler = createAliasHandler("onHMR", "vite-plugin-kiru");
2109
- for (const node of ast.body) {
2110
- if (node.type === "ImportDeclaration") {
2111
- if (onHMRAliasHandler.addAliases(node) && isBuild) {
2112
- code.update(node.start, node.end, "");
2113
- }
1943
+ // ../../node_modules/.pnpm/minimatch@10.1.1/node_modules/minimatch/dist/esm/brace-expressions.js
1944
+ var posixClasses = {
1945
+ "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
1946
+ "[:alpha:]": ["\\p{L}\\p{Nl}", true],
1947
+ "[:ascii:]": ["\\x00-\\x7f", false],
1948
+ "[:blank:]": ["\\p{Zs}\\t", true],
1949
+ "[:cntrl:]": ["\\p{Cc}", true],
1950
+ "[:digit:]": ["\\p{Nd}", true],
1951
+ "[:graph:]": ["\\p{Z}\\p{C}", true, true],
1952
+ "[:lower:]": ["\\p{Ll}", true],
1953
+ "[:print:]": ["\\p{C}", true],
1954
+ "[:punct:]": ["\\p{P}", true],
1955
+ "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
1956
+ "[:upper:]": ["\\p{Lu}", true],
1957
+ "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
1958
+ "[:xdigit:]": ["A-Fa-f0-9", false]
1959
+ };
1960
+ var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
1961
+ var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
1962
+ var rangesToString = (ranges) => ranges.join("");
1963
+ var parseClass = (glob2, position) => {
1964
+ const pos = position;
1965
+ if (glob2.charAt(pos) !== "[") {
1966
+ throw new Error("not in a brace expression");
1967
+ }
1968
+ const ranges = [];
1969
+ const negs = [];
1970
+ let i = pos + 1;
1971
+ let sawStart = false;
1972
+ let uflag = false;
1973
+ let escaping = false;
1974
+ let negate = false;
1975
+ let endPos = pos;
1976
+ let rangeStart = "";
1977
+ WHILE: while (i < glob2.length) {
1978
+ const c = glob2.charAt(i);
1979
+ if ((c === "!" || c === "^") && i === pos + 1) {
1980
+ negate = true;
1981
+ i++;
2114
1982
  continue;
2115
1983
  }
2116
- walk(node, {
2117
- CallExpression: (node2, ctx) => {
2118
- if (onHMRAliasHandler.isMatchingCallExpression(node2)) {
2119
- try {
2120
- if (isBuild) {
2121
- code.update(node2.start, node2.end, "");
2122
- return;
2123
- }
2124
- const callback = node2.arguments[0];
2125
- const callbackRaw = code.original.substring(
2126
- callback.start,
2127
- callback.end
2128
- );
2129
- code.update(
2130
- node2.start,
2131
- node2.end,
2132
- VITE_IMPORT_META_HOT_ACCEPT.replace("%", callbackRaw)
2133
- );
2134
- } finally {
2135
- ctx.exitBranch();
1984
+ if (c === "]" && sawStart && !escaping) {
1985
+ endPos = i + 1;
1986
+ break;
1987
+ }
1988
+ sawStart = true;
1989
+ if (c === "\\") {
1990
+ if (!escaping) {
1991
+ escaping = true;
1992
+ i++;
1993
+ continue;
1994
+ }
1995
+ }
1996
+ if (c === "[" && !escaping) {
1997
+ for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
1998
+ if (glob2.startsWith(cls, i)) {
1999
+ if (rangeStart) {
2000
+ return ["$.", false, glob2.length - pos, true];
2136
2001
  }
2002
+ i += cls.length;
2003
+ if (neg)
2004
+ negs.push(unip);
2005
+ else
2006
+ ranges.push(unip);
2007
+ uflag = uflag || u;
2008
+ continue WHILE;
2137
2009
  }
2138
2010
  }
2139
- });
2140
- }
2141
- }
2142
-
2143
- // src/ansi.ts
2144
- var colors = {
2145
- black: "\x1B[30m",
2146
- black_bright: "\x1B[90m",
2147
- red: "\x1B[31m",
2148
- red_bright: "\x1B[91m",
2149
- green: "\x1B[32m",
2150
- green_bright: "\x1B[92m",
2151
- yellow: "\x1B[33m",
2152
- yellow_bright: "\x1B[93m",
2153
- blue: "\x1B[34m",
2154
- blue_bright: "\x1B[94m",
2155
- magenta: "\x1B[35m",
2156
- magenta_bright: "\x1B[95m",
2157
- cyan: "\x1B[36m",
2158
- cyan_bright: "\x1B[96m",
2159
- white: "\x1B[37m",
2160
- white_bright: "\x1B[97m",
2161
- reset: "\x1B[0m"
2162
- };
2163
- var ANSI = tEntries(colors).reduce((acc, [key, value]) => {
2164
- acc[key] = (str) => `${value}${str}${colors.reset}`;
2165
- return acc;
2166
- }, {});
2167
- function tEntries(obj) {
2168
- return Object.entries(obj);
2169
- }
2170
-
2171
- // src/config.ts
2172
- import path3 from "node:path";
2173
-
2174
- // src/utils.ts
2175
- import path2 from "node:path";
2176
-
2177
- // ../../node_modules/.pnpm/@isaacs+balanced-match@4.0.1/node_modules/@isaacs/balanced-match/dist/esm/index.js
2178
- var balanced = (a, b, str) => {
2179
- const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
2180
- const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
2181
- const r = ma !== null && mb != null && range(ma, mb, str);
2182
- return r && {
2183
- start: r[0],
2184
- end: r[1],
2185
- pre: str.slice(0, r[0]),
2186
- body: str.slice(r[0] + ma.length, r[1]),
2187
- post: str.slice(r[1] + mb.length)
2188
- };
2189
- };
2190
- var maybeMatch = (reg, str) => {
2191
- const m = str.match(reg);
2192
- return m ? m[0] : null;
2193
- };
2194
- var range = (a, b, str) => {
2195
- let begs, beg, left, right = void 0, result;
2196
- let ai = str.indexOf(a);
2197
- let bi = str.indexOf(b, ai + 1);
2198
- let i = ai;
2199
- if (ai >= 0 && bi > 0) {
2200
- if (a === b) {
2201
- return [ai, bi];
2202
2011
  }
2203
- begs = [];
2204
- left = str.length;
2205
- while (i >= 0 && !result) {
2206
- if (i === ai) {
2207
- begs.push(i);
2208
- ai = str.indexOf(a, i + 1);
2209
- } else if (begs.length === 1) {
2210
- const r = begs.pop();
2211
- if (r !== void 0)
2212
- result = [r, bi];
2213
- } else {
2214
- beg = begs.pop();
2215
- if (beg !== void 0 && beg < left) {
2216
- left = beg;
2217
- right = bi;
2218
- }
2219
- bi = str.indexOf(b, i + 1);
2012
+ escaping = false;
2013
+ if (rangeStart) {
2014
+ if (c > rangeStart) {
2015
+ ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
2016
+ } else if (c === rangeStart) {
2017
+ ranges.push(braceEscape(c));
2220
2018
  }
2221
- i = ai < bi && ai >= 0 ? ai : bi;
2019
+ rangeStart = "";
2020
+ i++;
2021
+ continue;
2222
2022
  }
2223
- if (begs.length && right !== void 0) {
2224
- result = [left, right];
2023
+ if (glob2.startsWith("-]", i + 1)) {
2024
+ ranges.push(braceEscape(c + "-"));
2025
+ i += 2;
2026
+ continue;
2027
+ }
2028
+ if (glob2.startsWith("-", i + 1)) {
2029
+ rangeStart = c;
2030
+ i += 2;
2031
+ continue;
2225
2032
  }
2033
+ ranges.push(braceEscape(c));
2034
+ i++;
2226
2035
  }
2227
- return result;
2228
- };
2229
-
2230
- // ../../node_modules/.pnpm/@isaacs+brace-expansion@5.0.0/node_modules/@isaacs/brace-expansion/dist/esm/index.js
2231
- var escSlash = "\0SLASH" + Math.random() + "\0";
2232
- var escOpen = "\0OPEN" + Math.random() + "\0";
2233
- var escClose = "\0CLOSE" + Math.random() + "\0";
2234
- var escComma = "\0COMMA" + Math.random() + "\0";
2235
- var escPeriod = "\0PERIOD" + Math.random() + "\0";
2236
- var escSlashPattern = new RegExp(escSlash, "g");
2237
- var escOpenPattern = new RegExp(escOpen, "g");
2238
- var escClosePattern = new RegExp(escClose, "g");
2239
- var escCommaPattern = new RegExp(escComma, "g");
2240
- var escPeriodPattern = new RegExp(escPeriod, "g");
2241
- var slashPattern = /\\\\/g;
2242
- var openPattern = /\\{/g;
2243
- var closePattern = /\\}/g;
2244
- var commaPattern = /\\,/g;
2245
- var periodPattern = /\\./g;
2246
- function numeric(str) {
2247
- return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
2248
- }
2249
- function escapeBraces(str) {
2250
- return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
2251
- }
2252
- function unescapeBraces(str) {
2253
- return str.replace(escSlashPattern, "\\").replace(escOpenPattern, "{").replace(escClosePattern, "}").replace(escCommaPattern, ",").replace(escPeriodPattern, ".");
2254
- }
2255
- function parseCommaParts(str) {
2256
- if (!str) {
2257
- return [""];
2036
+ if (endPos < i) {
2037
+ return ["", false, 0, false];
2258
2038
  }
2259
- const parts = [];
2260
- const m = balanced("{", "}", str);
2261
- if (!m) {
2262
- return str.split(",");
2263
- }
2264
- const { pre, body, post } = m;
2265
- const p = pre.split(",");
2266
- p[p.length - 1] += "{" + body + "}";
2267
- const postParts = parseCommaParts(post);
2268
- if (post.length) {
2269
- ;
2270
- p[p.length - 1] += postParts.shift();
2271
- p.push.apply(p, postParts);
2272
- }
2273
- parts.push.apply(parts, p);
2274
- return parts;
2275
- }
2276
- function expand(str) {
2277
- if (!str) {
2278
- return [];
2279
- }
2280
- if (str.slice(0, 2) === "{}") {
2281
- str = "\\{\\}" + str.slice(2);
2282
- }
2283
- return expand_(escapeBraces(str), true).map(unescapeBraces);
2284
- }
2285
- function embrace(str) {
2286
- return "{" + str + "}";
2287
- }
2288
- function isPadded(el) {
2289
- return /^-?0\d/.test(el);
2290
- }
2291
- function lte(i, y) {
2292
- return i <= y;
2293
- }
2294
- function gte(i, y) {
2295
- return i >= y;
2296
- }
2297
- function expand_(str, isTop) {
2298
- const expansions = [];
2299
- const m = balanced("{", "}", str);
2300
- if (!m)
2301
- return [str];
2302
- const pre = m.pre;
2303
- const post = m.post.length ? expand_(m.post, false) : [""];
2304
- if (/\$$/.test(m.pre)) {
2305
- for (let k = 0; k < post.length; k++) {
2306
- const expansion = pre + "{" + m.body + "}" + post[k];
2307
- expansions.push(expansion);
2308
- }
2309
- } else {
2310
- const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
2311
- const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
2312
- const isSequence = isNumericSequence || isAlphaSequence;
2313
- const isOptions = m.body.indexOf(",") >= 0;
2314
- if (!isSequence && !isOptions) {
2315
- if (m.post.match(/,(?!,).*\}/)) {
2316
- str = m.pre + "{" + m.body + escClose + m.post;
2317
- return expand_(str);
2318
- }
2319
- return [str];
2320
- }
2321
- let n;
2322
- if (isSequence) {
2323
- n = m.body.split(/\.\./);
2324
- } else {
2325
- n = parseCommaParts(m.body);
2326
- if (n.length === 1 && n[0] !== void 0) {
2327
- n = expand_(n[0], false).map(embrace);
2328
- if (n.length === 1) {
2329
- return post.map((p) => m.pre + n[0] + p);
2330
- }
2331
- }
2332
- }
2333
- let N;
2334
- if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
2335
- const x = numeric(n[0]);
2336
- const y = numeric(n[1]);
2337
- const width = Math.max(n[0].length, n[1].length);
2338
- let incr = n.length === 3 && n[2] !== void 0 ? Math.abs(numeric(n[2])) : 1;
2339
- let test = lte;
2340
- const reverse = y < x;
2341
- if (reverse) {
2342
- incr *= -1;
2343
- test = gte;
2344
- }
2345
- const pad = n.some(isPadded);
2346
- N = [];
2347
- for (let i = x; test(i, y); i += incr) {
2348
- let c;
2349
- if (isAlphaSequence) {
2350
- c = String.fromCharCode(i);
2351
- if (c === "\\") {
2352
- c = "";
2353
- }
2354
- } else {
2355
- c = String(i);
2356
- if (pad) {
2357
- const need = width - c.length;
2358
- if (need > 0) {
2359
- const z = new Array(need + 1).join("0");
2360
- if (i < 0) {
2361
- c = "-" + z + c.slice(1);
2362
- } else {
2363
- c = z + c;
2364
- }
2365
- }
2366
- }
2367
- }
2368
- N.push(c);
2369
- }
2370
- } else {
2371
- N = [];
2372
- for (let j = 0; j < n.length; j++) {
2373
- N.push.apply(N, expand_(n[j], false));
2374
- }
2375
- }
2376
- for (let j = 0; j < N.length; j++) {
2377
- for (let k = 0; k < post.length; k++) {
2378
- const expansion = pre + N[j] + post[k];
2379
- if (!isTop || isSequence || expansion) {
2380
- expansions.push(expansion);
2381
- }
2382
- }
2383
- }
2384
- }
2385
- return expansions;
2386
- }
2387
-
2388
- // ../../node_modules/.pnpm/minimatch@10.1.1/node_modules/minimatch/dist/esm/assert-valid-pattern.js
2389
- var MAX_PATTERN_LENGTH = 1024 * 64;
2390
- var assertValidPattern = (pattern) => {
2391
- if (typeof pattern !== "string") {
2392
- throw new TypeError("invalid pattern");
2393
- }
2394
- if (pattern.length > MAX_PATTERN_LENGTH) {
2395
- throw new TypeError("pattern is too long");
2396
- }
2397
- };
2398
-
2399
- // ../../node_modules/.pnpm/minimatch@10.1.1/node_modules/minimatch/dist/esm/brace-expressions.js
2400
- var posixClasses = {
2401
- "[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", true],
2402
- "[:alpha:]": ["\\p{L}\\p{Nl}", true],
2403
- "[:ascii:]": ["\\x00-\\x7f", false],
2404
- "[:blank:]": ["\\p{Zs}\\t", true],
2405
- "[:cntrl:]": ["\\p{Cc}", true],
2406
- "[:digit:]": ["\\p{Nd}", true],
2407
- "[:graph:]": ["\\p{Z}\\p{C}", true, true],
2408
- "[:lower:]": ["\\p{Ll}", true],
2409
- "[:print:]": ["\\p{C}", true],
2410
- "[:punct:]": ["\\p{P}", true],
2411
- "[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", true],
2412
- "[:upper:]": ["\\p{Lu}", true],
2413
- "[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", true],
2414
- "[:xdigit:]": ["A-Fa-f0-9", false]
2415
- };
2416
- var braceEscape = (s) => s.replace(/[[\]\\-]/g, "\\$&");
2417
- var regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
2418
- var rangesToString = (ranges) => ranges.join("");
2419
- var parseClass = (glob2, position) => {
2420
- const pos = position;
2421
- if (glob2.charAt(pos) !== "[") {
2422
- throw new Error("not in a brace expression");
2423
- }
2424
- const ranges = [];
2425
- const negs = [];
2426
- let i = pos + 1;
2427
- let sawStart = false;
2428
- let uflag = false;
2429
- let escaping = false;
2430
- let negate = false;
2431
- let endPos = pos;
2432
- let rangeStart = "";
2433
- WHILE: while (i < glob2.length) {
2434
- const c = glob2.charAt(i);
2435
- if ((c === "!" || c === "^") && i === pos + 1) {
2436
- negate = true;
2437
- i++;
2438
- continue;
2439
- }
2440
- if (c === "]" && sawStart && !escaping) {
2441
- endPos = i + 1;
2442
- break;
2443
- }
2444
- sawStart = true;
2445
- if (c === "\\") {
2446
- if (!escaping) {
2447
- escaping = true;
2448
- i++;
2449
- continue;
2450
- }
2451
- }
2452
- if (c === "[" && !escaping) {
2453
- for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
2454
- if (glob2.startsWith(cls, i)) {
2455
- if (rangeStart) {
2456
- return ["$.", false, glob2.length - pos, true];
2457
- }
2458
- i += cls.length;
2459
- if (neg)
2460
- negs.push(unip);
2461
- else
2462
- ranges.push(unip);
2463
- uflag = uflag || u;
2464
- continue WHILE;
2465
- }
2466
- }
2467
- }
2468
- escaping = false;
2469
- if (rangeStart) {
2470
- if (c > rangeStart) {
2471
- ranges.push(braceEscape(rangeStart) + "-" + braceEscape(c));
2472
- } else if (c === rangeStart) {
2473
- ranges.push(braceEscape(c));
2474
- }
2475
- rangeStart = "";
2476
- i++;
2477
- continue;
2478
- }
2479
- if (glob2.startsWith("-]", i + 1)) {
2480
- ranges.push(braceEscape(c + "-"));
2481
- i += 2;
2482
- continue;
2483
- }
2484
- if (glob2.startsWith("-", i + 1)) {
2485
- rangeStart = c;
2486
- i += 2;
2487
- continue;
2488
- }
2489
- ranges.push(braceEscape(c));
2490
- i++;
2491
- }
2492
- if (endPos < i) {
2493
- return ["", false, 0, false];
2494
- }
2495
- if (!ranges.length && !negs.length) {
2496
- return ["$.", false, glob2.length - pos, true];
2039
+ if (!ranges.length && !negs.length) {
2040
+ return ["$.", false, glob2.length - pos, true];
2497
2041
  }
2498
2042
  if (negs.length === 0 && ranges.length === 1 && /^\\?.$/.test(ranges[0]) && !negate) {
2499
2043
  const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
@@ -3662,69 +3206,506 @@ var Minimatch = class {
3662
3206
  } catch (ex) {
3663
3207
  this.regexp = false;
3664
3208
  }
3665
- return this.regexp;
3209
+ return this.regexp;
3210
+ }
3211
+ slashSplit(p) {
3212
+ if (this.preserveMultipleSlashes) {
3213
+ return p.split("/");
3214
+ } else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
3215
+ return ["", ...p.split(/\/+/)];
3216
+ } else {
3217
+ return p.split(/\/+/);
3218
+ }
3219
+ }
3220
+ match(f, partial = this.partial) {
3221
+ this.debug("match", f, this.pattern);
3222
+ if (this.comment) {
3223
+ return false;
3224
+ }
3225
+ if (this.empty) {
3226
+ return f === "";
3227
+ }
3228
+ if (f === "/" && partial) {
3229
+ return true;
3230
+ }
3231
+ const options = this.options;
3232
+ if (this.isWindows) {
3233
+ f = f.split("\\").join("/");
3234
+ }
3235
+ const ff = this.slashSplit(f);
3236
+ this.debug(this.pattern, "split", ff);
3237
+ const set = this.set;
3238
+ this.debug(this.pattern, "set", set);
3239
+ let filename = ff[ff.length - 1];
3240
+ if (!filename) {
3241
+ for (let i = ff.length - 2; !filename && i >= 0; i--) {
3242
+ filename = ff[i];
3243
+ }
3244
+ }
3245
+ for (let i = 0; i < set.length; i++) {
3246
+ const pattern = set[i];
3247
+ let file = ff;
3248
+ if (options.matchBase && pattern.length === 1) {
3249
+ file = [filename];
3250
+ }
3251
+ const hit = this.matchOne(file, pattern, partial);
3252
+ if (hit) {
3253
+ if (options.flipNegate) {
3254
+ return true;
3255
+ }
3256
+ return !this.negate;
3257
+ }
3258
+ }
3259
+ if (options.flipNegate) {
3260
+ return false;
3261
+ }
3262
+ return this.negate;
3263
+ }
3264
+ static defaults(def) {
3265
+ return minimatch.defaults(def).Minimatch;
3266
+ }
3267
+ };
3268
+ minimatch.AST = AST;
3269
+ minimatch.Minimatch = Minimatch;
3270
+ minimatch.escape = escape;
3271
+ minimatch.unescape = unescape2;
3272
+
3273
+ // src/codegen/shared.ts
3274
+ var import_magic_string = __toESM(require_magic_string_cjs(), 1);
3275
+
3276
+ // src/codegen/ast.ts
3277
+ function findNode(node, predicate, maxDepth = Infinity) {
3278
+ let res = null;
3279
+ walk(node, {
3280
+ "*": (node2, ctx) => {
3281
+ if (predicate(node2)) {
3282
+ res = node2;
3283
+ ctx.exit();
3284
+ }
3285
+ if (ctx.stack.length >= maxDepth) ctx.exitBranch();
3286
+ }
3287
+ });
3288
+ return res;
3289
+ }
3290
+ function walk(node, visitor) {
3291
+ const ctx = {
3292
+ stack: [],
3293
+ exit: exitWalk,
3294
+ exitBranch
3295
+ };
3296
+ try {
3297
+ walk_impl(node, visitor, ctx);
3298
+ } catch (error) {
3299
+ if (error === "walk:exit") return;
3300
+ throw error;
3301
+ }
3302
+ }
3303
+ var exitWalk = () => {
3304
+ throw "walk:exit";
3305
+ };
3306
+ var exitBranch = () => {
3307
+ throw "walk:exit-branch";
3308
+ };
3309
+ var flushCallbacks = (callbacks) => {
3310
+ while (callbacks.length) {
3311
+ callbacks.pop()();
3312
+ }
3313
+ };
3314
+ function walk_impl(node, visitor, ctx) {
3315
+ const onExitCallbacks = [];
3316
+ try {
3317
+ {
3318
+ const cb = visitor[node.type]?.(node, ctx);
3319
+ if (cb instanceof Function) onExitCallbacks.push(cb);
3320
+ }
3321
+ {
3322
+ const cb = visitor["*"]?.(node, ctx);
3323
+ if (cb instanceof Function) onExitCallbacks.push(cb);
3324
+ }
3325
+ } catch (error) {
3326
+ if (error === "walk:exit-branch") {
3327
+ flushCallbacks(onExitCallbacks);
3328
+ return;
3329
+ }
3330
+ throw error;
3331
+ }
3332
+ ctx.stack.push(node);
3333
+ [
3334
+ node.arguments,
3335
+ node.declarations,
3336
+ node.properties,
3337
+ node.property,
3338
+ node.cases,
3339
+ node.body,
3340
+ node.consequent,
3341
+ node.init,
3342
+ node.argument,
3343
+ node.alternate,
3344
+ node.callee,
3345
+ node.declaration,
3346
+ node.expression,
3347
+ node.expressions,
3348
+ node.left,
3349
+ node.right
3350
+ ].filter(Boolean).forEach((a) => {
3351
+ if (Array.isArray(a)) {
3352
+ for (let i = 0; i < a.length; i++) {
3353
+ walk_impl(a[i], visitor, ctx);
3354
+ }
3355
+ return;
3356
+ }
3357
+ if (typeof a === "object" && "type" in a) {
3358
+ walk_impl(a, visitor, ctx);
3359
+ return;
3360
+ }
3361
+ });
3362
+ if (node.type === "Property" && node.value && typeof node.value === "object") {
3363
+ walk_impl(node.value, visitor, ctx);
3364
+ }
3365
+ ctx.stack.pop();
3366
+ flushCallbacks(onExitCallbacks);
3367
+ }
3368
+
3369
+ // src/codegen/shared.ts
3370
+ function createAliasHandler(name, namespace = "kiru") {
3371
+ const aliases = /* @__PURE__ */ new Set();
3372
+ const isMatchingCallExpression = (node) => node.type === "CallExpression" && node.callee?.type === "Identifier" && typeof node.callee.name === "string" && aliases.has(node.callee.name);
3373
+ const addAliases = (node) => {
3374
+ if (node.source?.value !== namespace) return false;
3375
+ let didAdd = false;
3376
+ const specifiers = node.specifiers || [];
3377
+ for (let i = 0; i < specifiers.length; i++) {
3378
+ const specifier = specifiers[i];
3379
+ if (specifier.imported && specifier.imported.name === name && !!specifier.local) {
3380
+ aliases.add(specifier.local.name);
3381
+ didAdd = true;
3382
+ }
3383
+ }
3384
+ return didAdd;
3385
+ };
3386
+ return { name, aliases, addAliases, isMatchingCallExpression };
3387
+ }
3388
+ function isComponent(node, bodyNodes) {
3389
+ const isTlf = isTopLevelFunction(node, bodyNodes);
3390
+ if (!isTlf) return false;
3391
+ const name = findNodeName(node);
3392
+ if (name === null) return false;
3393
+ const charCode = name.charCodeAt(0);
3394
+ return charCode >= 65 && charCode <= 90;
3395
+ }
3396
+ function findNodeName(node) {
3397
+ if (node.id?.name) return node.id.name;
3398
+ if (node.declaration?.id?.name) return node.declaration.id.name;
3399
+ if (node.declaration?.declarations?.[0]?.id?.name)
3400
+ return node.declaration.declarations[0].id.name;
3401
+ if (node.declarations?.[0]?.id?.name) return node.declarations[0].id.name;
3402
+ return null;
3403
+ }
3404
+ function findFunctionBodyNodes(node, name, bodyNodes) {
3405
+ let dec = node.declaration;
3406
+ if (!dec) {
3407
+ for (const _node of bodyNodes) {
3408
+ if (_node.type === "VariableDeclaration") {
3409
+ if (_node.declarations?.[0]?.id?.name === name) {
3410
+ dec = _node;
3411
+ break;
3412
+ }
3413
+ } else if (_node.type === "FunctionDeclaration") {
3414
+ if (_node.id?.name === name) {
3415
+ dec = _node;
3416
+ break;
3417
+ }
3418
+ }
3419
+ }
3420
+ }
3421
+ if (!dec) {
3422
+ throw new Error(
3423
+ "[vite-plugin-kiru]: failed to find declaration for component"
3424
+ );
3425
+ }
3426
+ if (dec.type === "FunctionDeclaration" && dec.body && !Array.isArray(dec.body) && dec.body.type === "BlockStatement") {
3427
+ return dec.body.body;
3428
+ } else if (dec.type === "VariableDeclaration") {
3429
+ if (!Array.isArray(dec.declarations)) {
3430
+ return null;
3431
+ }
3432
+ for (const _dec of dec.declarations) {
3433
+ if (_dec.id?.name !== name) continue;
3434
+ if (_dec.init?.type === "ArrowFunctionExpression" || _dec.init?.type === "FunctionExpression") {
3435
+ return _dec.init.body.body;
3436
+ } else if (_dec.init?.type === "CallExpression" && _dec.init.arguments) {
3437
+ const nodes = [];
3438
+ for (const arg of _dec.init.arguments) {
3439
+ if (isFuncDecOrExpr(arg) && arg.body && !Array.isArray(arg.body) && Array.isArray(arg.body.body)) {
3440
+ nodes.push(...arg.body.body);
3441
+ }
3442
+ }
3443
+ return nodes;
3444
+ }
3445
+ }
3446
+ }
3447
+ return null;
3448
+ }
3449
+ function isFuncDecOrExpr(node) {
3450
+ if (!node) return false;
3451
+ if (node.type === "VariableDeclaration") {
3452
+ return isFuncDecOrExpr(node.declarations?.[0]?.init);
3453
+ }
3454
+ return [
3455
+ "FunctionDeclaration",
3456
+ "FunctionExpression",
3457
+ "ArrowFunctionExpression"
3458
+ ].includes(node.type);
3459
+ }
3460
+ function isTopLevelFunction(node, bodyNodes) {
3461
+ if (isFuncDecOrExpr(node)) {
3462
+ return true;
3463
+ }
3464
+ switch (node.type) {
3465
+ case "VariableDeclaration":
3466
+ case "ExportNamedDeclaration":
3467
+ if (node.declaration) {
3468
+ return isFuncDecOrExpr(node.declaration);
3469
+ } else if (node.declarations) {
3470
+ return !!findNode(node, isFuncDecOrExpr);
3471
+ }
3472
+ const name = findNodeName(node);
3473
+ if (name === null) return false;
3474
+ const dec = findFunctionBodyNodes(node, name, bodyNodes);
3475
+ if (!dec) return false;
3476
+ return isFuncDecOrExpr(dec[0]);
3477
+ case "ExportDefaultDeclaration":
3478
+ return isFuncDecOrExpr(node.declaration);
3479
+ }
3480
+ return false;
3481
+ }
3482
+
3483
+ // src/codegen/hmr.ts
3484
+ import fs from "node:fs";
3485
+ var UNNAMED_WATCH_PREAMBLE = `
3486
+
3487
+ if (import.meta.hot && "window" in globalThis) {
3488
+ window.__kiru.HMRContext?.signals.registerNextWatch();
3489
+ }
3490
+ `;
3491
+ function prepareHMR(ctx) {
3492
+ const { code, ast, fileLinkFormatter, id: filePath } = ctx;
3493
+ try {
3494
+ const { hotVars, didWrite } = findHotVars(
3495
+ code,
3496
+ ast.body,
3497
+ filePath
3498
+ );
3499
+ if (hotVars.size === 0 && !didWrite) return;
3500
+ code.prepend(`
3501
+ if (import.meta.hot && "window" in globalThis) {
3502
+ window.__kiru.HMRContext?.prepare("${filePath}");
3503
+ }
3504
+ `);
3505
+ code.append(`
3506
+ if (import.meta.hot && "window" in globalThis) {
3507
+ import.meta.hot.accept();
3508
+ ${createHMRRegistrationBlurb(hotVars, fileLinkFormatter, filePath)}
3509
+ }
3510
+ `);
3511
+ } catch (error) {
3512
+ console.error(
3513
+ "[vite-plugin-kiru]: HMR preparation failed for",
3514
+ filePath,
3515
+ error
3516
+ );
3517
+ }
3518
+ }
3519
+ function createHMRRegistrationBlurb(hotVars, fileLinkFormatter, filePath) {
3520
+ const src = fs.readFileSync(filePath, "utf-8");
3521
+ const entries = Array.from(hotVars).map(({ name, type }) => {
3522
+ const key = JSON.stringify(name);
3523
+ const line = findHotVarLineInSrc(src, name);
3524
+ return ` ${key}: {
3525
+ type: "${type}",
3526
+ value: ${name},
3527
+ link: "${fileLinkFormatter(filePath, line)}"
3528
+ }`;
3529
+ });
3530
+ return `
3531
+ window.__kiru.HMRContext?.register({
3532
+ ${entries.join(",\n")}
3533
+ });`;
3534
+ }
3535
+ function findHotVarLineInSrc(src, name) {
3536
+ const lines = src.split("\n");
3537
+ const potentialMatches = [
3538
+ `const ${name}`,
3539
+ `let ${name}`,
3540
+ `var ${name}`,
3541
+ `function ${name}`,
3542
+ `export const ${name}`,
3543
+ `export let ${name}`,
3544
+ `export var ${name}`,
3545
+ `export default ${name}`,
3546
+ `export function ${name}`,
3547
+ `export default function ${name}`
3548
+ ];
3549
+ for (let i = 0; i < lines.length; i++) {
3550
+ const line = lines[i];
3551
+ for (let j = 0; j < potentialMatches.length; j++) {
3552
+ if (line.startsWith(potentialMatches[j])) return i + 1;
3553
+ }
3554
+ }
3555
+ return 0;
3556
+ }
3557
+ var exprAssign = [
3558
+ "ExpressionStatement",
3559
+ "AssignmentExpression"
3560
+ ];
3561
+ var allowedHotVarParentStacks = [
3562
+ ["VariableDeclaration", "VariableDeclarator"],
3563
+ exprAssign,
3564
+ ["ExportNamedDeclaration", "VariableDeclaration", "VariableDeclarator"]
3565
+ ];
3566
+ function findHotVars(code, bodyNodes, _id) {
3567
+ const hotVars = /* @__PURE__ */ new Set();
3568
+ let didWrite = false;
3569
+ const aliasHandlers = [
3570
+ "createStore",
3571
+ "signal",
3572
+ "computed",
3573
+ "watch",
3574
+ "createContext",
3575
+ "lazy"
3576
+ ].map((name) => createAliasHandler(name));
3577
+ aliasHandlers.push(createAliasHandler("definePageConfig", "kiru/router"));
3578
+ for (const node of bodyNodes) {
3579
+ if (node.type === "ImportDeclaration") {
3580
+ for (const aliasHandler of aliasHandlers) {
3581
+ aliasHandler.addAliases(node);
3582
+ }
3583
+ continue;
3584
+ }
3585
+ if (isComponent(node, bodyNodes)) {
3586
+ addHotVarDesc(node, hotVars, "component");
3587
+ continue;
3588
+ }
3589
+ for (const aliasHandler of aliasHandlers) {
3590
+ walk(node, {
3591
+ CallExpression: (node2, ctx) => {
3592
+ if (!aliasHandler.isMatchingCallExpression(node2)) {
3593
+ return ctx.exitBranch();
3594
+ }
3595
+ if (aliasHandler.name === "watch" && ctx.stack.length === 1 && ctx.stack[0].type === "ExpressionStatement") {
3596
+ code.appendRight(node2.start, UNNAMED_WATCH_PREAMBLE);
3597
+ didWrite = true;
3598
+ return ctx.exit();
3599
+ }
3600
+ const matchingParentStack = allowedHotVarParentStacks.find(
3601
+ (stack) => {
3602
+ return stack.every((type, i) => ctx.stack[i]?.type === type);
3603
+ }
3604
+ );
3605
+ if (!matchingParentStack) {
3606
+ return ctx.exitBranch();
3607
+ }
3608
+ if (matchingParentStack === exprAssign) {
3609
+ const [_expr, assign] = ctx.stack;
3610
+ const name2 = assign.left?.name;
3611
+ if (!name2) return ctx.exit();
3612
+ hotVars.add({
3613
+ type: aliasHandler.name,
3614
+ name: name2
3615
+ });
3616
+ return ctx.exit();
3617
+ }
3618
+ const remainingStack = ctx.stack.slice(matchingParentStack.length);
3619
+ if (remainingStack.some(
3620
+ (n) => n.type !== "ObjectExpression" && n.type !== "Property"
3621
+ )) {
3622
+ return ctx.exitBranch();
3623
+ }
3624
+ const name = ctx.stack.reduce((acc, item) => {
3625
+ switch (item.type) {
3626
+ case "VariableDeclarator":
3627
+ return item.id.name;
3628
+ case "Property":
3629
+ if (!item.key) return acc;
3630
+ if (item.key.name) return `${acc}.${item.key.name}`;
3631
+ if (item.key.raw) return `${acc}[${item.key.raw}]`;
3632
+ return acc;
3633
+ }
3634
+ return acc;
3635
+ }, "");
3636
+ hotVars.add({ type: aliasHandler.name, name });
3637
+ ctx.exitBranch();
3638
+ }
3639
+ });
3640
+ }
3666
3641
  }
3667
- slashSplit(p) {
3668
- if (this.preserveMultipleSlashes) {
3669
- return p.split("/");
3670
- } else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
3671
- return ["", ...p.split(/\/+/)];
3672
- } else {
3673
- return p.split(/\/+/);
3674
- }
3642
+ return {
3643
+ hotVars,
3644
+ didWrite
3645
+ };
3646
+ }
3647
+ function addHotVarDesc(node, names, type) {
3648
+ const name = findNodeName(node);
3649
+ if (name == null && type === "component") {
3650
+ console.error("[vite-plugin-kiru]: failed to find component name", node);
3651
+ throw new Error("[vite-plugin-kiru]: Component name not found");
3675
3652
  }
3676
- match(f, partial = this.partial) {
3677
- this.debug("match", f, this.pattern);
3678
- if (this.comment) {
3679
- return false;
3680
- }
3681
- if (this.empty) {
3682
- return f === "";
3683
- }
3684
- if (f === "/" && partial) {
3685
- return true;
3686
- }
3687
- const options = this.options;
3688
- if (this.isWindows) {
3689
- f = f.split("\\").join("/");
3690
- }
3691
- const ff = this.slashSplit(f);
3692
- this.debug(this.pattern, "split", ff);
3693
- const set = this.set;
3694
- this.debug(this.pattern, "set", set);
3695
- let filename = ff[ff.length - 1];
3696
- if (!filename) {
3697
- for (let i = ff.length - 2; !filename && i >= 0; i--) {
3698
- filename = ff[i];
3653
+ if (name !== null) {
3654
+ names.add({ type, name });
3655
+ }
3656
+ }
3657
+
3658
+ // src/codegen/devOnlyHooks.ts
3659
+ function prepareDevOnlyHooks(ctx) {
3660
+ const { code, ast, isBuild } = ctx;
3661
+ replaceOnHMRCallbacks(code, ast, isBuild);
3662
+ }
3663
+ var VITE_IMPORT_META_HOT_ACCEPT = `if ("window" in globalThis) {
3664
+ if (import.meta.hot) {
3665
+ import.meta.hot.accept(%);
3666
+ }
3667
+ }`;
3668
+ function replaceOnHMRCallbacks(code, ast, isBuild) {
3669
+ const onHMRAliasHandler = createAliasHandler("onHMR", "vite-plugin-kiru");
3670
+ for (const node of ast.body) {
3671
+ if (node.type === "ImportDeclaration") {
3672
+ if (onHMRAliasHandler.addAliases(node) && isBuild) {
3673
+ code.update(node.start, node.end, "");
3699
3674
  }
3675
+ continue;
3700
3676
  }
3701
- for (let i = 0; i < set.length; i++) {
3702
- const pattern = set[i];
3703
- let file = ff;
3704
- if (options.matchBase && pattern.length === 1) {
3705
- file = [filename];
3706
- }
3707
- const hit = this.matchOne(file, pattern, partial);
3708
- if (hit) {
3709
- if (options.flipNegate) {
3710
- return true;
3677
+ walk(node, {
3678
+ CallExpression: (node2, ctx) => {
3679
+ if (onHMRAliasHandler.isMatchingCallExpression(node2)) {
3680
+ try {
3681
+ if (isBuild) {
3682
+ code.update(node2.start, node2.end, "");
3683
+ return;
3684
+ }
3685
+ const callback = node2.arguments[0];
3686
+ const callbackRaw = code.original.substring(
3687
+ callback.start,
3688
+ callback.end
3689
+ );
3690
+ code.update(
3691
+ node2.start,
3692
+ node2.end,
3693
+ VITE_IMPORT_META_HOT_ACCEPT.replace("%", callbackRaw)
3694
+ );
3695
+ } finally {
3696
+ ctx.exitBranch();
3697
+ }
3711
3698
  }
3712
- return !this.negate;
3713
3699
  }
3714
- }
3715
- if (options.flipNegate) {
3716
- return false;
3717
- }
3718
- return this.negate;
3719
- }
3720
- static defaults(def) {
3721
- return minimatch.defaults(def).Minimatch;
3700
+ });
3722
3701
  }
3723
- };
3724
- minimatch.AST = AST;
3725
- minimatch.Minimatch = Minimatch;
3726
- minimatch.escape = escape;
3727
- minimatch.unescape = unescape2;
3702
+ }
3703
+
3704
+ // src/globals.ts
3705
+ import path3 from "node:path";
3706
+
3707
+ // src/utils.ts
3708
+ import path2 from "node:path";
3728
3709
 
3729
3710
  // ../../node_modules/.pnpm/glob@12.0.0/node_modules/glob/dist/esm/glob.js
3730
3711
  import { fileURLToPath as fileURLToPath2 } from "node:url";
@@ -6280,12 +6261,12 @@ var PathBase = class {
6280
6261
  /**
6281
6262
  * Get the Path object referenced by the string path, resolved from this Path
6282
6263
  */
6283
- resolve(path8) {
6284
- if (!path8) {
6264
+ resolve(path9) {
6265
+ if (!path9) {
6285
6266
  return this;
6286
6267
  }
6287
- const rootPath = this.getRootString(path8);
6288
- const dir = path8.substring(rootPath.length);
6268
+ const rootPath = this.getRootString(path9);
6269
+ const dir = path9.substring(rootPath.length);
6289
6270
  const dirParts = dir.split(this.splitSep);
6290
6271
  const result = rootPath ? this.getRoot(rootPath).#resolveParts(dirParts) : this.#resolveParts(dirParts);
6291
6272
  return result;
@@ -7037,8 +7018,8 @@ var PathWin32 = class _PathWin32 extends PathBase {
7037
7018
  /**
7038
7019
  * @internal
7039
7020
  */
7040
- getRootString(path8) {
7041
- return win32.parse(path8).root;
7021
+ getRootString(path9) {
7022
+ return win32.parse(path9).root;
7042
7023
  }
7043
7024
  /**
7044
7025
  * @internal
@@ -7084,8 +7065,8 @@ var PathPosix = class _PathPosix extends PathBase {
7084
7065
  /**
7085
7066
  * @internal
7086
7067
  */
7087
- getRootString(path8) {
7088
- return path8.startsWith("/") ? "/" : "";
7068
+ getRootString(path9) {
7069
+ return path9.startsWith("/") ? "/" : "";
7089
7070
  }
7090
7071
  /**
7091
7072
  * @internal
@@ -7174,11 +7155,11 @@ var PathScurryBase = class {
7174
7155
  /**
7175
7156
  * Get the depth of a provided path, string, or the cwd
7176
7157
  */
7177
- depth(path8 = this.cwd) {
7178
- if (typeof path8 === "string") {
7179
- path8 = this.cwd.resolve(path8);
7158
+ depth(path9 = this.cwd) {
7159
+ if (typeof path9 === "string") {
7160
+ path9 = this.cwd.resolve(path9);
7180
7161
  }
7181
- return path8.depth();
7162
+ return path9.depth();
7182
7163
  }
7183
7164
  /**
7184
7165
  * Return the cache of child entries. Exposed so subclasses can create
@@ -7665,9 +7646,9 @@ var PathScurryBase = class {
7665
7646
  process2();
7666
7647
  return results;
7667
7648
  }
7668
- chdir(path8 = this.cwd) {
7649
+ chdir(path9 = this.cwd) {
7669
7650
  const oldCwd = this.cwd;
7670
- this.cwd = typeof path8 === "string" ? this.cwd.resolve(path8) : path8;
7651
+ this.cwd = typeof path9 === "string" ? this.cwd.resolve(path9) : path9;
7671
7652
  this.cwd[setAsCwd](oldCwd);
7672
7653
  }
7673
7654
  };
@@ -8023,8 +8004,8 @@ var MatchRecord = class {
8023
8004
  }
8024
8005
  // match, absolute, ifdir
8025
8006
  entries() {
8026
- return [...this.store.entries()].map(([path8, n]) => [
8027
- path8,
8007
+ return [...this.store.entries()].map(([path9, n]) => [
8008
+ path9,
8028
8009
  !!(n & 2),
8029
8010
  !!(n & 1)
8030
8011
  ]);
@@ -8229,9 +8210,9 @@ var GlobUtil = class {
8229
8210
  signal;
8230
8211
  maxDepth;
8231
8212
  includeChildMatches;
8232
- constructor(patterns, path8, opts) {
8213
+ constructor(patterns, path9, opts) {
8233
8214
  this.patterns = patterns;
8234
- this.path = path8;
8215
+ this.path = path9;
8235
8216
  this.opts = opts;
8236
8217
  this.#sep = !opts.posix && opts.platform === "win32" ? "\\" : "/";
8237
8218
  this.includeChildMatches = opts.includeChildMatches !== false;
@@ -8250,11 +8231,11 @@ var GlobUtil = class {
8250
8231
  });
8251
8232
  }
8252
8233
  }
8253
- #ignored(path8) {
8254
- return this.seen.has(path8) || !!this.#ignore?.ignored?.(path8);
8234
+ #ignored(path9) {
8235
+ return this.seen.has(path9) || !!this.#ignore?.ignored?.(path9);
8255
8236
  }
8256
- #childrenIgnored(path8) {
8257
- return !!this.#ignore?.childrenIgnored?.(path8);
8237
+ #childrenIgnored(path9) {
8238
+ return !!this.#ignore?.childrenIgnored?.(path9);
8258
8239
  }
8259
8240
  // backpressure mechanism
8260
8241
  pause() {
@@ -8469,8 +8450,8 @@ var GlobUtil = class {
8469
8450
  };
8470
8451
  var GlobWalker = class extends GlobUtil {
8471
8452
  matches = /* @__PURE__ */ new Set();
8472
- constructor(patterns, path8, opts) {
8473
- super(patterns, path8, opts);
8453
+ constructor(patterns, path9, opts) {
8454
+ super(patterns, path9, opts);
8474
8455
  }
8475
8456
  matchEmit(e) {
8476
8457
  this.matches.add(e);
@@ -8507,8 +8488,8 @@ var GlobWalker = class extends GlobUtil {
8507
8488
  };
8508
8489
  var GlobStream = class extends GlobUtil {
8509
8490
  results;
8510
- constructor(patterns, path8, opts) {
8511
- super(patterns, path8, opts);
8491
+ constructor(patterns, path9, opts) {
8492
+ super(patterns, path9, opts);
8512
8493
  this.results = new Minipass({
8513
8494
  signal: this.signal,
8514
8495
  objectMode: true
@@ -8801,6 +8782,34 @@ var glob = Object.assign(glob_, {
8801
8782
  });
8802
8783
  glob.glob = glob;
8803
8784
 
8785
+ // src/ansi.ts
8786
+ var colors = {
8787
+ black: "\x1B[30m",
8788
+ black_bright: "\x1B[90m",
8789
+ red: "\x1B[31m",
8790
+ red_bright: "\x1B[91m",
8791
+ green: "\x1B[32m",
8792
+ green_bright: "\x1B[92m",
8793
+ yellow: "\x1B[33m",
8794
+ yellow_bright: "\x1B[93m",
8795
+ blue: "\x1B[34m",
8796
+ blue_bright: "\x1B[94m",
8797
+ magenta: "\x1B[35m",
8798
+ magenta_bright: "\x1B[95m",
8799
+ cyan: "\x1B[36m",
8800
+ cyan_bright: "\x1B[96m",
8801
+ white: "\x1B[37m",
8802
+ white_bright: "\x1B[97m",
8803
+ reset: "\x1B[0m"
8804
+ };
8805
+ var ANSI = tEntries(colors).reduce((acc, [key, value]) => {
8806
+ acc[key] = (str) => `${value}${str}${colors.reset}`;
8807
+ return acc;
8808
+ }, {});
8809
+ function tEntries(obj) {
8810
+ return Object.entries(obj);
8811
+ }
8812
+
8804
8813
  // src/utils.ts
8805
8814
  function createLogger(state) {
8806
8815
  return (...data) => {
@@ -8808,14 +8817,14 @@ function createLogger(state) {
8808
8817
  console.log(ANSI.cyan("[vite-plugin-kiru]"), ...data);
8809
8818
  };
8810
8819
  }
8811
- function resolveUserDocument(projectRoot, options) {
8820
+ function resolveUserDocument(projectRoot2, options) {
8812
8821
  const { dir, document } = options;
8813
- const fp = path2.resolve(projectRoot, dir, document).replace(/\\/g, "/");
8822
+ const fp = path2.resolve(projectRoot2, dir, document).replace(/\\/g, "/");
8814
8823
  const matches = globSync(fp);
8815
8824
  if (!matches.length) {
8816
8825
  throw new Error(`Document not found at ${fp}`);
8817
8826
  }
8818
- return path2.resolve(projectRoot, matches[0]).replace(/\\/g, "/");
8827
+ return path2.resolve(projectRoot2, matches[0]).replace(/\\/g, "/");
8819
8828
  }
8820
8829
  var TRANSFORMABLE_EXTENSIONS = /* @__PURE__ */ new Set([
8821
8830
  ".tsx",
@@ -8843,10 +8852,11 @@ function shouldTransformFile(id, state) {
8843
8852
  var VIRTUAL_CONFIG_ID = "virtual:kiru:config";
8844
8853
  var VIRTUAL_ENTRY_SERVER_ID = "virtual:kiru:entry-server";
8845
8854
  var VIRTUAL_ENTRY_CLIENT_ID = "virtual:kiru:entry-client";
8846
- async function createVirtualModules(projectRoot, options, mode) {
8847
- const userDoc = resolveUserDocument(projectRoot, options);
8855
+ function createVirtualModules_SSG(projectRoot2, options) {
8856
+ const userDoc = resolveUserDocument(projectRoot2, options);
8857
+ const documentModuleId = userDoc.substring(projectRoot2.length);
8858
+ const { dir, baseUrl, page, layout, guard, transition } = options;
8848
8859
  function createConfigModule() {
8849
- const { dir, baseUrl, page, layout, guard, transition } = options;
8850
8860
  return `
8851
8861
  import { formatViteImportMap, normalizePrefixPath } from "kiru/router/utils"
8852
8862
 
@@ -8861,19 +8871,6 @@ export { dir, baseUrl, pages, layouts, guards, transition }
8861
8871
  `;
8862
8872
  }
8863
8873
  function createEntryServerModule() {
8864
- if (mode === "ssr") {
8865
- return `
8866
- import { render as kiruServerRender } from "kiru/router/ssr"
8867
- import Document from "${userDoc}"
8868
- import * as config from "${VIRTUAL_CONFIG_ID}"
8869
-
8870
- export const documentModuleId = "${userDoc.substring(projectRoot.length)}"
8871
-
8872
- export async function render(url, ctx) {
8873
- return kiruServerRender(url, { ...ctx, ...config, Document })
8874
- }
8875
- `;
8876
- }
8877
8874
  return `
8878
8875
  import {
8879
8876
  render as kiruStaticRender,
@@ -8882,7 +8879,7 @@ import {
8882
8879
  import Document from "${userDoc}"
8883
8880
  import * as config from "${VIRTUAL_CONFIG_ID}"
8884
8881
 
8885
- export const documentModuleId = "${userDoc.substring(projectRoot.length)}"
8882
+ export const documentModuleId = "${documentModuleId}"
8886
8883
 
8887
8884
  export async function render(url, ctx) {
8888
8885
  return kiruStaticRender(url, { ...ctx, ...config, Document })
@@ -8894,21 +8891,85 @@ export async function generateStaticPaths() {
8894
8891
  `;
8895
8892
  }
8896
8893
  function createEntryClientModule() {
8897
- if (mode === "ssr") {
8898
- return `
8894
+ return `
8899
8895
  import { initClient } from "kiru/router/client"
8900
8896
  import * as config from "${VIRTUAL_CONFIG_ID}"
8901
8897
  import "${userDoc}"
8902
8898
 
8903
- initClient({ ...config, hydrationMode: "dynamic" })
8899
+ initClient({ ...config })
8904
8900
  `;
8905
- }
8901
+ }
8902
+ return {
8903
+ [VIRTUAL_CONFIG_ID]: createConfigModule,
8904
+ [VIRTUAL_ENTRY_SERVER_ID]: createEntryServerModule,
8905
+ [VIRTUAL_ENTRY_CLIENT_ID]: createEntryClientModule
8906
+ };
8907
+ }
8908
+ function createVirtualModules_SSR(projectRoot2, options) {
8909
+ const userDoc = resolveUserDocument(projectRoot2, options);
8910
+ const documentModuleId = userDoc.substring(projectRoot2.length);
8911
+ const { dir, baseUrl, page, layout, guard, remote, transition, secret } = options;
8912
+ function createConfigModule() {
8913
+ return `
8914
+ import { formatViteImportMap, normalizePrefixPath } from "kiru/router/utils"
8915
+
8916
+ const dir = normalizePrefixPath("${dir}")
8917
+ const baseUrl = normalizePrefixPath("${baseUrl}")
8918
+ const pages = formatViteImportMap(import.meta.glob(["/**/${page}"]), dir, baseUrl)
8919
+ const layouts = formatViteImportMap(import.meta.glob(["/**/${layout}"]), dir, baseUrl)
8920
+ const guards = formatViteImportMap(import.meta.glob(["/**/${guard}"]), dir, baseUrl)
8921
+ const remotes = formatViteImportMap(import.meta.glob(["/**/${remote}"]), dir, baseUrl)
8922
+ const transition = ${transition}
8923
+ const actions = new Map()
8924
+
8925
+ let token
8926
+ if ("window" in globalThis) {
8927
+ try {
8928
+ const s = document.querySelector("[k-request-token]")
8929
+ token = s.innerHTML
8930
+ s.remove()
8931
+ } catch {}
8932
+ }
8933
+
8934
+ globalThis.__kiru_serverActions ??= {
8935
+ register: (id, a) => actions.set(id, a),
8936
+ dispatch: async (id, ...args) => {
8937
+ const r = await fetch(\`/?action=\${id}\`, {
8938
+ method: "POST",
8939
+ headers: { "Content-Type": "application/json", "x-kiru-token": token },
8940
+ body: JSON.stringify(args)
8941
+ })
8942
+ if (!r.ok) throw new Error("Action failed")
8943
+ return r.json()
8944
+ }
8945
+ }
8946
+
8947
+ export { dir, baseUrl, pages, actions, layouts, guards, remotes, transition }
8948
+ `;
8949
+ }
8950
+ function createEntryServerModule() {
8951
+ return `
8952
+ import { render as kiruServerRender } from "kiru/router/ssr"
8953
+ import Document from "${userDoc}"
8954
+ import * as config from "${VIRTUAL_CONFIG_ID}"
8955
+
8956
+ export const remoteFunctionSecret = "${secret}"
8957
+ export const documentModuleId = "${documentModuleId}"
8958
+
8959
+ export async function render(url, ctx) {
8960
+ return kiruServerRender(url, { ...ctx, ...config, Document })
8961
+ }
8962
+
8963
+ export { config }
8964
+ `;
8965
+ }
8966
+ function createEntryClientModule() {
8906
8967
  return `
8907
8968
  import { initClient } from "kiru/router/client"
8908
8969
  import * as config from "${VIRTUAL_CONFIG_ID}"
8909
8970
  import "${userDoc}"
8910
8971
 
8911
- initClient({ ...config })
8972
+ initClient({ ...config, hydrationMode: "dynamic" })
8912
8973
  `;
8913
8974
  }
8914
8975
  return {
@@ -8918,7 +8979,78 @@ initClient({ ...config })
8918
8979
  };
8919
8980
  }
8920
8981
 
8982
+ // src/globals.ts
8983
+ var $KIRU_SERVER_GLOBAL = Symbol.for("kiru.server.global");
8984
+ var projectRoot = process.cwd().replace(/\\/g, "/");
8985
+ var serverOutDirAbs = path3.resolve(projectRoot, "dist/server");
8986
+ var manifestPath = path3.resolve(serverOutDirAbs, "vite-manifest.json");
8987
+ var global = globalThis[$KIRU_SERVER_GLOBAL] ??= {
8988
+ viteDevServer: null,
8989
+ serverEntryModule: Promise.withResolvers(),
8990
+ route: null,
8991
+ loadedRemoteModules: /* @__PURE__ */ new Map()
8992
+ };
8993
+ function setServerEntryModule(server) {
8994
+ global.serverEntryModule.resolve(server);
8995
+ }
8996
+
8997
+ // src/codegen/remote.ts
8998
+ function prepareRemoteFunctions(ctx) {
8999
+ const { code, isServer, ast } = ctx;
9000
+ const bodyNodes = ast.body;
9001
+ const matches = findExportedNamedFunctions(bodyNodes);
9002
+ if (matches.length === 0) return;
9003
+ if (isServer) {
9004
+ return server_performServerActionRegistrations(matches, code);
9005
+ }
9006
+ client_formatServerActionsFile(bodyNodes, matches, code);
9007
+ }
9008
+ function server_performServerActionRegistrations(matches, code) {
9009
+ code.append(`const __$a__ = {};
9010
+ `);
9011
+ for (const { name } of matches) {
9012
+ code.append(`__$a__["${name}"] = ${name};
9013
+ `);
9014
+ }
9015
+ code.append(
9016
+ `globalThis.__kiru_serverActions.register("${global.route}", __$a__);
9017
+ `
9018
+ );
9019
+ }
9020
+ function client_formatServerActionsFile(bodyNodes, matches, code) {
9021
+ code.prepend(
9022
+ `const __$r__ = "${global.route}"; const __$d__ = globalThis.__kiru_serverActions.dispatch;
9023
+ `
9024
+ );
9025
+ bodyNodes.forEach((node) => {
9026
+ const match2 = matches.find((match3) => match3.node === node);
9027
+ if (!match2) {
9028
+ code.overwrite(node.start, node.end, "");
9029
+ return;
9030
+ }
9031
+ code.overwrite(
9032
+ node.start,
9033
+ node.end,
9034
+ `export async function ${match2.name}() { return __$d__(\`\${__$r__}.${match2.name}\`, ...arguments); }`
9035
+ );
9036
+ });
9037
+ }
9038
+ function findExportedNamedFunctions(bodyNodes) {
9039
+ let i = 0;
9040
+ const matches = [];
9041
+ for (const node of bodyNodes) {
9042
+ if (node.type === "ExportNamedDeclaration" && node.declaration?.type === "FunctionDeclaration") {
9043
+ matches.push({
9044
+ node,
9045
+ name: node.declaration.id?.name || `anonymous_fn_${i++}`
9046
+ });
9047
+ }
9048
+ }
9049
+ return matches;
9050
+ }
9051
+
8921
9052
  // src/config.ts
9053
+ import path4 from "node:path";
8922
9054
  var defaultEsBuildOptions = {
8923
9055
  jsxInject: `import { createElement as _jsx, Fragment as _jsxFragment } from "kiru"`,
8924
9056
  jsx: "transform",
@@ -8939,17 +9071,26 @@ var defaultSSGOptions = {
8939
9071
  maxConcurrentRenders: 100
8940
9072
  }
8941
9073
  };
9074
+ function generateRemoteFunctionTokenSecret() {
9075
+ const secret = [];
9076
+ for (let i = 0; i < 32; i++) {
9077
+ secret.push(String.fromCharCode(Math.floor(Math.random() * 256)));
9078
+ }
9079
+ return secret.join("");
9080
+ }
8942
9081
  var defaultSSROptions = {
9082
+ secret: generateRemoteFunctionTokenSecret(),
8943
9083
  baseUrl: "/",
8944
9084
  dir: "src/pages",
8945
9085
  document: "document.{tsx,jsx}",
8946
9086
  page: "index.{tsx,jsx}",
9087
+ remote: "remote.{ts,js}",
8947
9088
  layout: "layout.{tsx,jsx}",
8948
9089
  guard: "guard.{ts,js}",
8949
9090
  transition: false
8950
9091
  };
8951
9092
  function createPluginState(opts = {}) {
8952
- let fileLinkFormatter = (path8, line) => `vscode://file/${path8}:${line}`;
9093
+ let fileLinkFormatter = (path9, line) => `vscode://file/${path9}:${line}`;
8953
9094
  let dtClientPathname = "/__devtools__";
8954
9095
  if (typeof opts.devtools === "object") {
8955
9096
  dtClientPathname = opts.devtools.dtClientPathname ?? dtClientPathname;
@@ -9019,7 +9160,17 @@ function createPluginState(opts = {}) {
9019
9160
  if (ssr.baseUrl && !ssr.baseUrl.startsWith("/")) {
9020
9161
  throw new Error("[vite-plugin-kiru]: ssr.baseUrl must start with '/'");
9021
9162
  }
9022
- const { baseUrl, dir, document, page, layout, guard, transition } = defaultSSROptions;
9163
+ const {
9164
+ baseUrl,
9165
+ dir,
9166
+ document,
9167
+ page,
9168
+ remote,
9169
+ layout,
9170
+ guard,
9171
+ transition,
9172
+ secret
9173
+ } = defaultSSROptions;
9023
9174
  return {
9024
9175
  ...state,
9025
9176
  ssrOptions: {
@@ -9027,9 +9178,11 @@ function createPluginState(opts = {}) {
9027
9178
  dir,
9028
9179
  document,
9029
9180
  page,
9181
+ remote,
9030
9182
  layout,
9031
9183
  guard,
9032
9184
  transition,
9185
+ secret,
9033
9186
  ...ssr
9034
9187
  }
9035
9188
  };
@@ -9085,9 +9238,9 @@ function updatePluginState(state, config, opts) {
9085
9238
  const isBuild = config.command === "build";
9086
9239
  const isSSRBuild = !!config.build?.ssr;
9087
9240
  const devtoolsEnabled = opts.devtools !== false && !isBuild && !isProduction;
9088
- const projectRoot = config.root.replace(/\\/g, "/") ?? process.cwd().replace(/\\/g, "/");
9241
+ const projectRoot2 = config.root.replace(/\\/g, "/") ?? process.cwd().replace(/\\/g, "/");
9089
9242
  const includedPaths = (opts.include ?? []).map(
9090
- (p) => path3.resolve(projectRoot, p).replace(/\\/g, "/")
9243
+ (p) => path4.resolve(projectRoot2, p).replace(/\\/g, "/")
9091
9244
  );
9092
9245
  const outDir = config.build.outDir ?? "dist";
9093
9246
  const normalizedOut = outDir.replace(/\\/g, "/");
@@ -9098,7 +9251,7 @@ function updatePluginState(state, config, opts) {
9098
9251
  isBuild,
9099
9252
  isSSRBuild,
9100
9253
  devtoolsEnabled,
9101
- projectRoot,
9254
+ projectRoot: projectRoot2,
9102
9255
  includedPaths,
9103
9256
  outDir,
9104
9257
  baseOutDir,
@@ -9122,35 +9275,35 @@ var dist_default = `<!DOCTYPE html>
9122
9275
  <link rel="icon" type="image/svg+xml" href="./favicon.svg" />
9123
9276
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
9124
9277
  <title>Kiru Devtools</title>
9125
- <script type="module" crossorigin>(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const eu="production",de=eu==="development",za=Symbol.for("kiru.signal"),nu=Symbol.for("kiru.context"),Ri=Symbol.for("kiru.contextProvider"),zt=Symbol.for("kiru.fragment"),Ha=Symbol.for("kiru.error"),Va=Symbol.for("kiru.memo"),to=Symbol.for("kiru.errorBoundary"),iu=Symbol.for("kiru.streamData"),su=Symbol.for("kiru.devFileLink"),ou=50,gn="kiru:deferred",ie=2,ae=4,Ni=8,le=16,Ba=32,ds=64,Ke=128,ru=/^on:?/,Wa=new Set(["animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","path","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","title","tspan","use"]),au=new Set(["allowfullscreen","autofocus","autoplay","async","checked","compact","controls","contenteditable","declare","default","defer","disabled","download","hidden","inert","ismap","multiple","nohref","noresize","noshade","novalidate","nowrap","open","popover","readonly","required","sandbox","scoped","selected","sortable","spellcheck","translate","wrap"]),lu=new Map([["acceptCharset","accept-charset"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["httpEquiv","http-equiv"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Re={current:null},ja={current:0},Ht={current:"window"in globalThis?"dom":"string"},cu={current:"dynamic"};var $a;class Ze extends Error{constructor(t){const n=typeof t=="string"?t:t.message;super(n),this[$a]=!0,typeof t!="string"&&(this.fatal=t?.fatal)}static isKiruError(t){return t instanceof Error&&t[Ha]===!0}}$a=Ha;const Qe={parentStack:[],childIdxStack:[],eventDeferrals:new Map,parent:function(){return this.parentStack[this.parentStack.length-1]},clear:function(){this.parentStack.length=0,this.childIdxStack.length=0},pop:function(){this.parentStack.pop(),this.childIdxStack.pop()},push:function(e){this.parentStack.push(e),this.childIdxStack.push(0)},currentChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]]},nextChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]++]},bumpChildIndex:function(){this.childIdxStack[this.childIdxStack.length-1]++},captureEvents:function(e){Go(e,!0),this.eventDeferrals.set(e,[])},resetEvents:function(e){this.eventDeferrals.delete(e)},releaseEvents:function(e){Go(e,!1);const t=this.eventDeferrals.get(e);for(;t?.length;)t.shift()()}},uu=e=>{const t=e.target;!e.isTrusted||!t||Qe.eventDeferrals.get(t)?.push(()=>t.dispatchEvent(e))},Go=(e,t)=>{for(const n in e)if(n.startsWith("on")){const i=n.substring(2);e[t?"addEventListener":"removeEventListener"](i,uu,{passive:!0})}};let eo=!1,ps=!1;const Ua=e=>{e.preventDefault(),e.stopPropagation(),ps=!0};let Oe=null;function hu(){eo=!0,Oe=document.activeElement,Oe&&Oe!==document.body&&Oe.addEventListener("blur",Ua)}function fu(){ps&&(Oe.removeEventListener("blur",Ua),Oe.isConnected&&Oe.focus(),ps=!1),eo=!1}function du(e){const t=e.type;return t=="#text"?Ya(e):Wa.has(t)?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)}function Ya(e){const{nodeValue:t}=e.props;if(!W.isSignal(t))return document.createTextNode(t);const n=t.peek()??"",i=document.createTextNode(n);return ms(e,i,t),i}function pu(e,t,n){const i=gs.get(e)??{},s=i[t]=o=>{if(eo){o.preventDefault(),o.stopPropagation();return}n(o)};return gs.set(e,i),s}const gs=new WeakMap;function Xa(e){const{dom:t,prev:n,props:i,cleanups:s}=e,o=n?.props??{},r=i??{},a=Ht.current==="hydrate";if(t instanceof Text){const f=r.nodeValue;!W.isSignal(f)&&t.nodeValue!==f&&(t.nodeValue=f);return}const l=[];for(const f in o)l.push(f);for(const f in r)f in o||l.push(f);for(let f=0;f<l.length;f++){const d=l[f],m=o[d],y=r[d];if(Cs.isEvent(d)){if(m!==y||a){const x=d.replace(ru,""),v=x==="focus"||x==="blur",w=gs.get(e);d in o&&t.removeEventListener(x,v?w?.[x]:m),d in r&&t.addEventListener(x,v?pu(e,x,y):y)}continue}if(!(Cs.isInternalProp(d)&&d!=="innerHTML")&&m!==y){if(W.isSignal(m)&&s){const x=s[d];x&&(x(),delete s[d])}if(W.isSignal(y)){xu(e,t,d,y,m);continue}gi(t,d,y,m)}}const c=o.ref,u=r.ref;c!==u&&(c&&Os(c,null),u&&Os(u,t))}function gu(e){return e.multiple?Array.from(e.selectedOptions).map(t=>t.value):e.value}function qa(e,t){if(!e.multiple||t===void 0||t===null||t===""){e.value=t;return}Array.from(e.options).forEach(n=>{n.selected=t.indexOf(n.value)>-1})}const mu={value:"input",checked:"change",open:"toggle",volume:"volumechange",playbackRate:"ratechange",currentTime:"timeupdate"},bu=["progress","meter","number","range"];function xu(e,t,n,i,s){const o=e.cleanups??(e.cleanups={}),[r,a]=n.split(":");if(r!=="bind"){o[n]=i.subscribe((E,C)=>{E!==C&&gi(t,n,E,C)});const w=i.peek(),k=tn(s);if(w===k)return;gi(t,n,w,k);return}const l=mu[a];if(!l)return;const c=t instanceof HTMLSelectElement,u=c?w=>qa(t,w):w=>t[a]=w,f=w=>{u(w)},d=w=>{i.sneak(w),i.notify(k=>k!==f)};let m;if(a==="value"){const w=bu.indexOf(t.type)!==-1;m=()=>{let k=t.value;c?k=gu(t):typeof i.peek()=="number"&&w&&(k=t.valueAsNumber),d(k)}}else m=w=>{const k=w.target[a];a==="currentTime"&&i.peek()===k||d(k)};t.addEventListener(l,m);const y=i.subscribe(f);o[n]=()=>{t.removeEventListener(l,m),y()};const x=i.peek(),v=tn(s);x!==v&&gi(t,a,x,v)}function ms(e,t,n){(e.cleanups??(e.cleanups={})).nodeValue=n.subscribe((i,s)=>{i!==s&&(t.nodeValue=i)})}function yu(e){if(e.type!=="#text"||!W.isSignal(e.props.nodeValue))return;const t=tn(e.props.nodeValue);if(t!=null)return;const n=Ya(e);return Qe.parent().appendChild(n),n}function vu(e){const t=Qe.nextChild()??yu(e);if(!t)throw new Ze({message:"Hydration mismatch - no node found",vNode:e});let n=t.nodeName;if(Wa.has(n)||(n=n.toLowerCase()),e.type!==n)throw new Ze({message:\`Hydration mismatch - expected node of type \${e.type.toString()} but received \${n}\`,vNode:e});if(e.dom=t,e.type!=="#text"&&!(e.flags&le)){Xa(e);return}W.isSignal(e.props.nodeValue)&&ms(e,t,e.props.nodeValue);let i=e,s=e.sibling;for(;s&&s.type==="#text";){const o=s;Qe.bumpChildIndex();const r=String(tn(i.props.nodeValue)??""),a=i.dom.splitText(r.length);o.dom=a,W.isSignal(o.props.nodeValue)&&ms(o,a,o.props.nodeValue),i=s,s=s.sibling}}function Ga(e,t,n,i=!1){if(n===null)return e.removeAttribute(t),!0;switch(typeof n){case"undefined":case"function":case"symbol":return e.removeAttribute(t),!0;case"boolean":if(i&&!n)return e.removeAttribute(t),!0}return!1}function _u(e,t,n){const i=au.has(t);Ga(e,t,n,i)||e.setAttribute(t,i&&typeof n=="boolean"?"":String(n))}const wu=["INPUT","TEXTAREA"],Su=e=>wu.indexOf(e.nodeName)>-1;function gi(e,t,n,i){switch(t){case"style":return Mu(e,n,i);case"className":return Tu(e,n);case"innerHTML":return ku(e,n);case"muted":e.muted=!!n;return;case"value":if(e.nodeName==="SELECT")return qa(e,n);const s=n==null?"":String(n);if(Su(e)){e.value=s;return}e.setAttribute("value",s);return;case"checked":if(e.nodeName==="INPUT"){e.checked=!!n;return}e.setAttribute("checked",String(n));return;default:return _u(e,Xu(t),n)}}function ku(e,t){if(t==null||typeof t=="boolean"){e.innerHTML="";return}e.innerHTML=String(t)}function Tu(e,t){const n=tn(t);if(!n)return e.removeAttribute("class");e.setAttribute("class",n)}function Mu(e,t,n){if(Ga(e,"style",t))return;if(typeof t=="string"){e.setAttribute("style",t);return}let i={};typeof n=="string"?e.setAttribute("style",""):typeof n=="object"&&n&&(i=n);const s=t;new Set([...Object.keys(i),...Object.keys(s)]).forEach(r=>{const a=i[r],l=s[r];if(a!==l){if(l===void 0){e.style[r]="";return}e.style[r]=l}})}function Eu(e){let t=e.parent,n=t?.dom;for(;t&&!n;)t=t.parent,n=t?.dom;if(!n||!t){if(!e.parent&&e.dom)return e;throw new Ze({message:"No DOM parent found while attempting to place node.",vNode:e})}return t}function Cu(e,t){const{node:n,lastChild:i}=t,s=e.dom;if(i){i.after(s);return}const o=Ka(e,n);if(o){n.dom.insertBefore(s,o);return}n.dom.appendChild(s)}function Ka(e,t){let n=e;for(;n;){let i=n.sibling;for(;i;){if(!(i.flags&(ae|le))){const s=Ou(i);if(s?.isConnected)return s}i=i.sibling}if(n=n.parent,!n||n.flags&le||n===t)return}}function Ou(e){let t=e;for(;t;){if(t.dom)return t.dom;if(t.flags&le)return;t=t.child}}function Pu(e){if(Ht.current==="hydrate")return Fi(e,wi);const t={node:e.dom?e:Eu(e)};bs(e,t,(e.flags&ae)>0),e.dom&&!(e.flags&le)&&Za(e,t,!1),wi(e)}function bs(e,t,n){let i=e.child;for(;i;){if(i.flags&ds){i.flags&ae&&Au(i,t),wi(i),i=i.sibling;continue}i.dom?(bs(i,{node:i},!1),i.flags&le||Za(i,t,n)):bs(i,t,(i.flags&ae)>0||n),wi(i),i=i.sibling}}function Za(e,t,n){(n||!e.dom.isConnected||e.flags&ae)&&Cu(e,t),(!e.prev||e.flags&ie)&&Xa(e),t.lastChild=e.dom}function Du(e){e===e.parent?.child&&(e.parent.child=e.sibling),Fi(e,t=>{const{hooks:n,subs:i,cleanups:s,dom:o,props:{ref:r}}=t;for(i?.forEach(a=>a()),s&&Object.values(s).forEach(a=>a());n?.length;)n.pop().cleanup?.();o&&(o.isConnected&&!(t.flags&le)&&o.remove(),r&&Os(r,null),delete t.dom)}),e.parent=null}function Au(e,t){if(!e.child)return;const n=[];if(Qa(e.child,n),n.length===0)return;const{node:i,lastChild:s}=t;if(s)s.after(...n);else{const o=Ka(e,i),r=i.dom;o?o.before(...n):r.append(...n)}t.lastChild=n[n.length-1]}function Qa(e,t){let n=e;for(;n;)n.dom?t.push(n.dom):n.child&&Qa(n.child,t),n=n.sibling}function g(e,t=null,...n){e===Tt&&(e=zt);const i=t===null?{}:t,s=dl(i.key),o=n.length;return o===1?i.children=n[0]:o>1&&(i.children=n),{type:e,key:s,props:i}}function Tt({children:e,key:t}){return{type:zt,key:dl(t),props:{children:e}}}function Ja(e){return typeof e=="function"&&typeof e[Va]?.arePropsEqual=="function"}function tl(e,t=null,n={},i=null,s=0){e===Tt&&(e=zt);const o=t?t.depth+1:0;return{type:e,key:i,props:n,parent:t,index:s,depth:o,flags:0,child:null,sibling:null,prev:null,deletions:null}}function no(e,t){return Array.isArray(t)?Lu(e,t):Iu(e,t)}function Iu(e,t){const n=e.child;if(n===null)return il(e,t);const i=n.sibling,s=el(e,n,t);if(s!==null)return n&&n!==s&&!s.prev?xs(e,n):i&&xs(e,i),s;{const o=rl(n),r=sl(o,e,0,t);if(r!==null){const a=r.prev;if(a!==null){const l=a.key;o.delete(l===null?a.index:l)}mi(r,0,0)}return o.forEach(a=>vi(e,a)),r}}function Lu(e,t){let n=null,i=null,s=e.child,o=null,r=0,a=0;for(;s!==null&&a<t.length;a++){s.index>a?(o=s,s=null):o=s.sibling;const c=el(e,s,t[a]);if(c===null){s===null&&(s=o);break}s&&!c.prev&&vi(e,s),r=mi(c,r,a),i===null?n=c:i.sibling=c,i=c,s=o}if(a===t.length)return xs(e,s),n;if(s===null){for(;a<t.length;a++){const c=il(e,t[a]);c!==null&&(r=mi(c,r,a),i===null?n=c:i.sibling=c,i=c)}return n}const l=rl(s);for(;a<t.length;a++){const c=sl(l,e,a,t[a]);if(c!==null){const u=c.prev;if(u!==null){const f=u.key;l.delete(f===null?u.index:f)}r=mi(c,r,a),i===null?n=c:i.sibling=c,i=c}}return l.forEach(c=>vi(e,c)),n}function el(e,t,n){const i=t===null?null:t.key;return so(n)?i!==null||t?.type==="#text"&&W.isSignal(t.props.nodeValue)?null:Ko(e,t,""+n):W.isSignal(n)?t&&t.props.nodeValue!==n?null:Ko(e,t,n):io(n)?n.key!==i?null:Ru(e,t,n):Array.isArray(n)?i!==null?null:nl(e,t,n):null}function Ko(e,t,n){return t===null||t.type!=="#text"?Nt(e,"#text",{nodeValue:n}):(t.props.nodeValue!==n&&(t.props.nodeValue=n,t.flags|=ie),t.sibling=null,t)}function Ru(e,t,n){let{type:i,props:s,key:o}=n;return i===zt?nl(e,t,s.children||[],s):t?.type===i?(t.index=0,t.sibling=null,typeof i=="string"?ol(t.props,s)&&(t.flags|=ie):t.flags|=ie,t.props=s,t):Nt(e,i,s,o)}function nl(e,t,n,i={}){return t===null||t.type!==zt?Nt(e,zt,{children:n,...i}):(t.props={...t.props,...i,children:n},t.flags|=ie,t.sibling=null,t)}function il(e,t){return so(t)?Nt(e,"#text",{nodeValue:""+t}):W.isSignal(t)?Nt(e,"#text",{nodeValue:t}):io(t)?Nt(e,t.type,t.props,t.key):Array.isArray(t)?Nt(e,zt,{children:t}):null}function mi(e,t,n){e.index=n;const i=e.prev;if(i!==null){const s=i.index;return s<t?(e.flags|=ae,t):s}else return e.flags|=ae,t}function sl(e,t,n,i){if(W.isSignal(i)||so(i)){const o=e.get(n);if(o){if(o.props.nodeValue===i)return o;o.type==="#text"&&W.isSignal(o.props.nodeValue)&&o.cleanups?.nodeValue?.()}return Nt(t,"#text",{nodeValue:i},null,n)}if(io(i)){const{type:o,props:r,key:a}=i,l=e.get(a===null?n:a);return l?.type===o?(typeof o=="string"?ol(l.props,r)&&(l.flags|=ie):l.flags|=ie,l.props=r,l.sibling=null,l.index=n,l):Nt(t,o,r,a,n)}if(Array.isArray(i)){const o=e.get(n);return o?(o.flags|=ie,o.props.children=i,o):Nt(t,zt,{children:i},null,n)}return null}function ol(e,t){const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!0;for(let s of n)if(!(s==="children"||s==="key")&&e[s]!==t[s])return!0;return!1}function rl(e){const t=new Map;for(;e;){const n=e.key;t.set(n===null?e.index:n,e),e=e.sibling}return t}function vi(e,t){e.deletions===null?e.deletions=[t]:e.deletions.push(t)}function xs(e,t){for(;t;)vi(e,t),t=t.sibling}function Nt(e,t,n,i=null,s=0){const o=tl(t,e,n,i,s);return o.flags|=ae,typeof t=="function"&&Ja(t)&&(o.flags|=Ba,o.arePropsEqual=t[Va].arePropsEqual),o}let Xt=[],Je=!1,ys=[],vs=[],_s=!1,ws=!1,Ss=!1,ks=0,al=[],Ts=[],ll=-1;function Nu(e){if(Je){ys.push(e);return}e()}function cl(){Je&&(window.cancelAnimationFrame(ll),ul())}function Zo(e){e.flags|=Ke,Xt.push(e),Je=!0,cl()}function zn(e){if(Ht.current==="hydrate")return Nu(()=>Ms(e));Ms(e)}function Fu(){Je||(Je=!0,ll=window.requestAnimationFrame(ul))}function zu(){for(Je=!1;ys.length;)ys.shift()()}function Ms(e){if(_s&&(ws=!0),Re.current===e){Ss=!0;return}if(!(e.flags&(Ke|Ni))){if(e.flags|=Ke,!Xt.length)return Xt.push(e),Fu();Xt.push(e)}}function Hu(e){Fi(e,t=>t.flags|=Ni),vs.push(e)}const Vu=(e,t)=>t.depth-e.depth;let te=null;function ul(){let e=1;for(hu();Xt.length;){Xt.length>e&&Xt.sort(Vu),te=Xt.shift(),e=Xt.length;const t=te.flags;if(!(t&Ni)&&t&Ke){let n=te;for(;n=Bu(n););for(;vs.length;)Du(vs.pop());Pu(te),te.flags&=~Ke}}if(fu(),_s=!0,Ji(al),_s=!1,ws)return Uu(),Ji(Ts),ws=!1,ks++,cl();ks=0,zu(),Ji(Ts)}function Bu(e){let t=!0;try{typeof e.type=="string"?$u(e):Gu(e.type)?Wu(e):t=ju(e)}catch(i){const s=th(e);if(s){const o=s.error=i instanceof Error?i:new Error(String(i));return s.props.onError?.(o),s.depth<te.depth&&(te=s),s}if(Ze.isKiruError(i)){if(i.customNodeStack&&setTimeout(()=>{throw new Error(i.customNodeStack)}),i.fatal)throw i;console.error(i);return}setTimeout(()=>{throw i})}if(e.deletions!==null&&(e.deletions.forEach(Hu),e.deletions=null),t&&e.child)return e.child;let n=e;for(;n;){if(n.immediateEffects&&(al.push(...n.immediateEffects),n.immediateEffects=void 0),n.effects&&(Ts.push(...n.effects),n.effects=void 0),n===te)return;if(n.sibling)return n.sibling;n=n.parent,Ht.current==="hydrate"&&n?.dom&&Qe.pop()}}function Wu(e){const{props:t,type:n}=e;let i=t.children;if(n===Ri){const{props:{dependents:s,value:o},prev:r}=e;s.size&&r&&r.props.value!==o&&s.forEach(Ms)}else if(n===to){const s=e,{error:o}=s;o&&(i=typeof t.fallback=="function"?t.fallback(o):t.fallback,delete s.error)}e.child=no(e,i)}function ju(e){const{type:t,props:n,subs:i,prev:s,flags:o}=e;if(o&Ba){if(e.memoizedProps=n,s?.memoizedProps&&e.arePropsEqual(s.memoizedProps,n)&&!e.hmrUpdated)return e.flags|=ds,!1;e.flags&=~ds}try{Re.current=e;let r,a=0;do e.flags&=~Ke,Ss=!1,ja.current=0,i&&(i.forEach(l=>l()),i.clear()),r=t(n);while(Ss);return e.child=no(e,r),!0}finally{Re.current=null}}function $u(e){const{props:t,type:n}=e;e.dom||(Ht.current==="hydrate"?vu(e):e.dom=du(e)),n!=="#text"&&(e.child=no(e,t.children),e.child&&Ht.current==="hydrate"&&Qe.push(e.dom))}function Uu(){if(ks>ou)throw new Ze("Maximum update depth exceeded. This can happen when a component repeatedly calls setState during render or in useLayoutEffect. Kiru limits the number of nested updates to prevent infinite loops.")}function Ji(e){for(let t=0;t<e.length;t++)e[t]();e.length=0}var Qo;(function(e){e.Start="start",e.End="end"})(Qo||(Qo={}));const pe=()=>{const e=hl("useRequestUpdate");return()=>zn(e)};function _t(e,t,n){const i=hl(e),s=(a,l)=>{if(l?.immediate){(i.immediateEffects??(i.immediateEffects=[])).push(a);return}(i.effects??(i.effects=[])).push(a)},o=ja.current++;let r=i.hooks?.at(o);try{const a=r??(typeof t=="function"?t():{...t});return i.hooks??(i.hooks=[]),i.hooks[o]=a,n({hook:a,isInit:!r,update:()=>zn(i),queueEffect:s,vNode:i,index:o})}catch(a){throw a}}function hl(e){const t=Re.current;if(!t)throw new Ze(\`Hook "\${e}" must be used at the top level of a component or inside another composite hook.\`);return t}function Hn(e){e.cleanup&&(e.cleanup(),e.cleanup=void 0)}function He(e,t){return e===void 0||t===void 0||e.length!==t.length||e.length>0&&t.some((n,i)=>!Object.is(n,e[i]))}const Es={stack:new Array,current:function(){return this.stack[this.stack.length-1]}},Ye=new Map;var fl;class W{constructor(t,n){this[fl]=!0,this.$id=nh(),this.$value=t,n&&(this.displayName=n),this.$subs=new Set}get value(){return this.onBeforeRead?.(),W.entangle(this),this.$value}set value(t){Object.is(this.$value,t)||(this.$prevValue=this.$value,this.$value=t,this.notify())}peek(){return this.onBeforeRead?.(),this.$value}sneak(t){this.$prevValue=this.$value,this.$value=t}toString(){return this.onBeforeRead?.(),W.entangle(this),\`\${this.$value}\`}subscribe(t){return this.$subs.add(t),()=>this.$subs.delete(t)}notify(t){this.$subs.forEach(n=>{if(!(t&&!t(n)))return n(this.$value,this.$prevValue)})}static isSignal(t){return typeof t=="object"&&!!t&&za in t}static subscribers(t){return t.$subs}static makeReadonly(t){const n=Object.getOwnPropertyDescriptor(t,"value");return n&&!n.writable?t:Object.defineProperty(t,"value",{get:function(){return W.entangle(this),this.$value},configurable:!0})}static makeWritable(t){const n=Object.getOwnPropertyDescriptor(t,"value");return n&&n.writable?t:Object.defineProperty(t,"value",{get:function(){return W.entangle(this),this.$value},set:function(i){this.$value=i,this.notify()},configurable:!0})}static entangle(t){const n=Re.current,i=Es.current();if(i){(!n||n&&yt())&&i.set(t.$id,t);return}if(!n||!yt())return;const s=t.subscribe(()=>zn(n));(n.subs??(n.subs=new Set)).add(s)}static configure(t,n){t.onBeforeRead=n}static dispose(t){t.$isDisposed=!0,t.$subs.clear()}}fl=za;const G=(e,t)=>new W(e,t),J=(e,t)=>_t("useSignal",{signal:null},({hook:n,isInit:i,isHMR:s})=>(i&&(n.cleanup=()=>W.dispose(n.signal),n.signal=new W(e,t)),n.signal));function tn(e,t=!1){return W.isSignal(e)?t?e.value:e.peek():e}const Yu=()=>{Ye.forEach(e=>e()),Ye.clear()};function _i(...e){return e.filter(Boolean).join(" ")}const Jo=new Set(["children","ref","key","innerHTML"]),Cs={isInternalProp:e=>Jo.has(e),isEvent:e=>e.startsWith("on"),isStringRenderableProperty:e=>!Jo.has(e)&&!Cs.isEvent(e)};function Xu(e){switch(e){case"className":return"class";case"htmlFor":return"for";case"tabIndex":case"formAction":case"formMethod":case"formEncType":case"contentEditable":case"spellCheck":case"allowFullScreen":case"autoPlay":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"noModule":case"noValidate":case"popoverTarget":case"popoverTargetAction":case"playsInline":case"readOnly":case"itemscope":case"rowSpan":case"crossOrigin":return e.toLowerCase();default:return e.indexOf("-")>-1?e:e.startsWith("aria")?"aria-"+e.substring(4).toLowerCase():lu.get(e)||e}}const tr=Object.freeze(()=>{});function Os(e,t){if(typeof e=="function"){e(t);return}if(W.isSignal(e)){e.value=t;return}e.current=t}function yt(){return Ht.current==="dom"||Ht.current==="hydrate"}function qu(e){return(e.flags&Ni)!==0}function io(e){return typeof e=="object"&&e!==null&&"type"in e}function so(e){return typeof e=="string"&&e!==""||typeof e=="number"||typeof e=="bigint"}function Gu(e){return e===zt||e===Ri||e===to}function Ku(e){return e.type===zt}function Zu(e){return typeof e.type=="function"&&"displayName"in e.type&&e.type.displayName==="Kiru.lazy"}function Qu(e){return typeof e.type=="function"&&Ja(e.type)}function wi(e){const{props:{children:t,...n},key:i,memoizedProps:s,index:o}=e;e.prev={props:n,key:i,memoizedProps:s,index:o},e.flags&=-15}function Fi(e,t){t(e);let n=e.child;for(;n;)t(n),n.child&&Fi(n,t),n=n.sibling}function Ju(e,t){let n=e.parent;for(;n;){if(t(n))return n;n=n.parent}return null}function th(e){return Ju(e,t=>t.type===to)}function dl(e){return e===void 0?null:typeof e=="string"||typeof e=="number"?e:null}const eh="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-";function nh(e=10,t=eh){let n="";for(let i=0;i<e;i++)n+=t[Math.random()*t.length|0];return n}function ih(){const e=new Set,t=new WeakMap,n=new Map;function i(a,l,c){n.get(a)?.forEach(u=>u(l,c))}function s(a,l){n.has(a)||n.set(a,new Set),n.get(a).add(l)}function o(a,l){n.get(a)?.delete(l)}const r={get apps(){return Array.from(e)},emit:i,on:s,off:o};return s("mount",(a,l)=>{e.add(a),l&&typeof l=="function"&&t.set(a,{requestUpdate:l})}),s("unmount",a=>{e.delete(a),t.delete(a)}),r}function sh(e){const{id:t,subs:n,fn:i,deps:s=[],onDepChanged:o}=e;let r;Ye.delete(t);const a=!!Re.current&&!yt();a||(r=new Map,Es.stack.push(r));const l=i(...s.map(c=>c.value));if(!a){for(const[u,f]of n)r.has(u)||(f(),n.delete(u));const c=()=>{Ye.size||queueMicrotask(Yu),Ye.set(t,o)};for(const[u,f]of r){if(n.has(u))continue;const d=f.subscribe(c);n.set(u,d)}Es.stack.pop()}return l}class Ee extends W{constructor(t,n){super(void 0,n),this.$getter=t,this.$unsubs=new Map,this.$isDirty=!0,W.configure(this,()=>{this.$isDirty&&Ee.run(this)})}get value(){return super.value}set value(t){}subscribe(t){return this.$isDirty&&Ee.run(this),super.subscribe(t)}static dispose(t){Ee.stop(t),W.dispose(t)}static updateGetter(t,n){const i=t;i.$getter=n,i.$isDirty=!0,Ee.run(i),!Object.is(i.$value,i.$prevValue)&&i.notify()}static stop(t){const{$id:n,$unsubs:i}=t;Ye.delete(n),i.forEach(s=>s()),i.clear(),t.$isDirty=!0}static run(t){const n=t,{$id:i,$getter:s,$unsubs:o}=n,r=sh({id:i,subs:o,fn:()=>s(n.$value),onDepChanged:()=>{n.$isDirty=!0,t.$subs.size&&(Ee.run(n),!Object.is(n.$value,n.$prevValue)&&n.notify())}});n.sneak(r),n.$isDirty=!1}}function Vn(e,t){return new Ee(e,t)}let oh=0;function rh(e,t,n){const i=ah(t),s=oh++,o={id:s,name:\`App-\${s}\`,rootNode:i,render:r,unmount:a};function r(l){i.props.children=l,Zo(i)}function a(){i.props.children=null,Zo(i),window.__kiru.emit("unmount",o)}return r(e),window.__kiru.emit("mount",o,zn),o}function ah(e){const t=tl(e.nodeName.toLowerCase());return t.flags|=le,t.dom=e,t}function ge(e){return yt()?_t("useState",{state:void 0,dispatch:tr},({hook:t,isInit:n,update:i,isHMR:s})=>(n&&(t.state=typeof e=="function"?e():e,t.dispatch=o=>{const r=typeof o=="function"?o(t.state):o;Object.is(t.state,r)||(t.state=r,i())}),[t.state,t.dispatch])):[typeof e=="function"?e():e,tr]}function lh(e){const t={[nu]:!0,Provider:({value:n,children:i})=>{const[s]=ge(()=>new Set);return g(Ri,{value:n,ctx:t,dependents:s},typeof i=="function"?i(n):i)},default:()=>e,set displayName(n){this.Provider.displayName=n},get displayName(){return this.Provider.displayName||"Anonymous Context"}};return t}function Xe(e,t){return yt()?_t("useCallback",{callback:e,deps:t},({hook:n,isHMR:i})=>(He(t,n.deps)&&(n.deps=t,n.callback=e),n.callback)):e}function ch(e,t=!0){return _t("useContext",{context:e,warnIfNotFound:t},uh)}const uh=({hook:e,isInit:t,vNode:n})=>{if(t){let i=n.parent;for(;i;){if(i.type===Ri){const s=i,{ctx:o,value:r,dependents:a}=s.props;if(o===e.context)return a.add(n),e.cleanup=()=>a.delete(n),e.provider=s,r}i=i.parent}}return e.provider?e.provider.props.value:e.context.default()};function rt(e,t){if(yt())return _t("useEffect",{deps:t},({hook:n,isInit:i,isHMR:s,queueEffect:o})=>{(i||He(t,n.deps))&&(n.deps=t,Hn(n),o(()=>{const r=e();typeof r=="function"&&(n.cleanup=r)}))})}function pl(){return _t("useId",hh,fh)}const hh=()=>({id:"",idx:0}),fh=({hook:e,isInit:t,vNode:n})=>{if(t||n.index!==e.idx){e.idx=n.index;const i=[];let s=n;for(;s;)i.push(s.index),i.push(s.depth),s=s.parent;e.id=\`k:\${BigInt(i.join("")).toString(36)}\`}return e.id};function oo(e,t){if(yt())return _t("useLayoutEffect",{deps:t},({hook:n,isInit:i,isHMR:s,queueEffect:o})=>{(i||He(t,n.deps))&&(n.deps=t,Hn(n),o(()=>{const r=e();typeof r=="function"&&(n.cleanup=r)},{immediate:!0}))})}function Si(e,t){return yt()?_t("useMemo",{deps:t,value:void 0},({hook:n,isInit:i,isHMR:s})=>((i||He(t,n.deps))&&(n.deps=t,n.value=e()),n.value)):e()}const er=new WeakMap;function dh(e,t){const n=pl(),i=J(!0);return _t("usePromise",{},({hook:s,isInit:o,vNode:r,update:a})=>{if(o||He(t,s.deps)){i.value=!0,s.deps=t,Hn(s);const l=s.abortController=new AbortController;s.cleanup=()=>l.abort();const c=er.get(r)??0;er.set(r,c+1);const u=\`\${n}:data:\${c}\`;let f;Ht.current==="string"?f=Promise.resolve():Ht.current==="hydrate"&&cu.current==="dynamic"?f=ph(u,l.signal):f=e(l.signal);const d={id:u,state:"pending"},m=s.promise=Object.assign(f,d,{isPending:i,refresh:()=>{s.deps=void 0,a()}});m.then(y=>{m.state="fulfilled",m.value=y,i.value=!1}).catch(y=>{m.state="rejected",m.error=y instanceof Error?y:new Error(y)})}return s.promise})}function ph(e,t){return new Promise((n,i)=>{const s=window[gn]??(window[gn]=new Map),o=s.get(e);if(o){const{data:a,error:l}=o;return s.delete(e),l?i(l):n(a)}const r=a=>{const{detail:l}=a;if(l.id===e){s.delete(e),window.removeEventListener(gn,r);const{data:c,error:u}=l;if(u)return i(u);n(c)}};window.addEventListener(gn,r),t.addEventListener("abort",()=>{window.removeEventListener(gn,r),i()})})}function Ne(e){return yt()?_t("useRef",{ref:{current:e}},({hook:t,isInit:n,isHMR:i})=>t.ref):{current:e}}function nr(e){return e instanceof Promise&&"id"in e&&"state"in e}function Ps(e){const{from:t,children:n,fallback:i,mode:s}=e,o=Ne(null),r=new Set;let a;if(nr(t))r.add(t),a=t.value;else if(W.isSignal(t))a=t.value;else{const l={};for(const c in t){const u=t[c];nr(u)&&r.add(u),l[c]=u.value}a=l}if(r.size===0)return n(a);if(!yt())throw{[iu]:{fallback:i,data:Array.from(r)}};for(const l of r){if(l.state==="rejected")throw l.error;if(l.state==="pending"){const c=Re.current;return Promise.allSettled(r).then(()=>zn(c)),s!=="fallback"&&o.current?n(o.current,!0):i}}return o.current=a,n(a,!1)}"window"in globalThis&&(window.__KIRU_LAZY_CACHE??(window.__KIRU_LAZY_CACHE=new Map));var ir;"window"in globalThis&&!globalThis.__KIRU_DEVTOOLS__&&((ir=globalThis.window).__kiru??(ir.__kiru=ih()));function gh(e,t){if(!e)throw new Error(t)}function mh(...e){return e.filter(Boolean).join(" ")}function ro(e,t,n){let i=e;for(let s=0;s<t.length;s++){const o=t[s];s===t.length-1?i[o]=n:i=i[o]}}function ao(e){return e.type.displayName??(e.type.name||"Anonymous Function")}const bh=e=>e[su]??null;function An(e){return e.name==="kiru.devtools"}function gl(e){return Array.from(e.entries())}function xh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e},g("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),g("path",{d:"M12 9v11"}),g("path",{d:"M2 9h13a2 2 0 0 1 2 2v9"}))}function ce(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"m9 18 6-6-6-6"}))}function yh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),g("circle",{cx:"12",cy:"12",r:"3"}))}function vh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6"}),g("path",{d:"m21 3-9 9"}),g("path",{d:"M15 3h6v6"}))}function _h(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z"}),g("path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z"}),g("path",{d:"M3 5a2 2 0 0 0 2 2h3"}),g("path",{d:"M3 3v13a2 2 0 0 0 2 2h3"}))}function wh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"m12 14 4-4"}),g("path",{d:"M3.34 19a10 10 0 1 1 17.32 0"}))}function Sh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("circle",{cx:"12",cy:"12",r:"10"}),g("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),g("path",{d:"M2 12h20"}))}function ml(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),g("path",{d:"M21 3v5h-5"}),g("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),g("path",{d:"M8 16H3v5"}))}function kh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e},g("path",{d:"M22 8.35V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8.35A2 2 0 0 1 3.26 6.5l8-3.2a2 2 0 0 1 1.48 0l8 3.2A2 2 0 0 1 22 8.35Z"}),g("path",{d:"M6 18h12"}),g("path",{d:"M6 14h12"}),g("rect",{width:"12",height:"12",x:"6",y:"10"}))}function Th(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),g("path",{d:"M8 12h8"}),g("path",{d:"m12 16 4-4-4-4"}))}function lo(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),g("path",{d:"M12 9v4"}),g("path",{d:"M12 17h.01"}))}function bl({title:e,children:t,className:n,disabled:i,...s}){const[o,r]=ge(!0);rt(()=>{!o&&i&&r(!0)},[i]);const a=Xe(l=>{l.preventDefault(),l.stopImmediatePropagation(),r(c=>!c)},[]);return g("div",{className:"flex flex-col"},g("button",{onclick:a,disabled:i,className:\`\${i?"opacity-50 cursor-default":"cursor-pointer"}\`},g("span",{className:"flex items-center gap-2 font-medium"},g(ce,{className:\`transition \${o?"":"rotate-90"}\`}),e)),o?null:g("div",{className:\`p-2 \${n||""}\`,...s},t))}const co={arrayChunkSize:10,objectKeysChunkSize:100};function xl(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const i in n)if(typeof t[i]!=typeof e[i]||typeof e[i]=="object"&&!xl(e[i],t[i]))return!1;return!0}function yl(e,t,n){for(const i in t)typeof e[i]>"u"&&(e[i]=structuredClone(t[i]));for(const i in e)typeof e[i]=="object"?yl(e[i],t[i],n):n(e,i,e[i])}let vl={...co};const sr=localStorage.getItem("kiru.devtools.userSettings");if(sr)try{const e=JSON.parse(sr);xl(co,e)&&(vl=e)}catch(e){console.error("kiru.devtools.userSettings error",e)}const _l=lh({userSettings:null,saveUserSettings:()=>{}}),zi=()=>ch(_l);function Mh({children:e}){const[t,n]=ge(vl),i=s=>{localStorage.setItem("kiru.devtools.userSettings",JSON.stringify(s)),n(s)};return g(_l.Provider,{value:{userSettings:t,saveUserSettings:i}},e)}function Eh(){const{userSettings:e,saveUserSettings:t}=zi();return g("div",{className:"rounded bg-neutral-400 bg-opacity-5 border border-white border-opacity-10 overflow-hidden"},g(me,{border:!1,data:e,onChange:(n,i)=>{const s={...e};ro(s,n,i),yl(s,co,(o,r,a)=>{o[r]=a<1?1:a}),t(s)},mutable:!0,objectRefAcc:[]}))}const Ch=Object.freeze(()=>{});function me({data:e,onChange:t,mutable:n,objectRefAcc:i,keys:s=[],className:o,border:r=!0}){const{userSettings:{objectKeysChunkSize:a}}=zi(),[l,c]=ge(0),u=Si(()=>Object.keys(e).slice(0,(l+1)*a),[l,a,e]),f=()=>{u.forEach(m=>{typeof e[m]=="object"&&i.splice(i.indexOf(e[m]),1)}),c(l+1)},d=u.length<Object.keys(e).length;return g(Tt,null,g("div",{className:mh("flex flex-col items-start w-full",r&&"border border-neutral-700",tn(o))},u.map(m=>{const y=s.concat(m),x=y.join(".");return g("div",{key:x,"data-key":x,className:"flex flex-col items-start w-full gap-2 pl-2 py-1 pr-1 border-b border-neutral-700 last:border-b-0"},g(uo,{value:e[m],onChange:t,keys:y,path:x,label:m,mutable:n,objectRefAcc:i}))})),d&&g("button",{onclick:f,title:"Show more",className:"p-1 border font-bold border-neutral-700 hover:bg-neutral-700"},g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},g("circle",{cx:"12",cy:"12",r:"1"}),g("circle",{cx:"19",cy:"12",r:"1"}),g("circle",{cx:"5",cy:"12",r:"1"}))))}function ki(e,t){Array.isArray(e)?(t(e),e.forEach(n=>ki(n,t))):typeof e=="object"&&e!==null&&(t(e),Object.values(e).forEach(n=>ki(n,t)))}function uo({value:e,onChange:t,keys:n,path:i,mutable:s,objectRefAcc:o,label:r}){const{userSettings:{arrayChunkSize:a}}=zi(),[l,c]=ge(!0),u=r!==void 0&&g("label",{htmlFor:i,className:"text-xs truncate",title:i,children:r});if(e===null)return g(mt,null,u,g(Qt,null,"null"));if(e===void 0)return g(mt,null,u,g(Qt,null,"undefined"));const f=window.opener?window.opener.Node:Node;if(e instanceof f)return g(mt,null,u,g(Qt,null,"<",g("span",{style:{color:"#f0a05e"}},e.nodeName),"/>"));const d=window.opener?window.opener.Error:Error;if(e instanceof d)return g(mt,null,u,"cause"in e&&e.cause?g(Qt,null,e.message," (",String(e.cause),")"):g(Qt,null,e.message));const m=y=>t(n,y);switch(typeof e){case"string":return g(mt,null,u,g(ts,{disabled:!s,id:i,type:"text",value:e,onchange:y=>m(y.target.value)}));case"number":return g(mt,null,u,g(ts,{disabled:!s,id:i,type:"number",value:e,placeholder:"NaN",onchange:y=>m(Number(y.target.value))}));case"bigint":return g(mt,null,u,g(ts,{disabled:!s,id:i,type:"number",value:e.toString(),onchange:y=>m(BigInt(y.target.value))}));case"boolean":return g(mt,null,u,g("input",{disabled:!s,id:i,type:"checkbox",checked:e,onchange:y=>m(y.target.checked),className:"accent-red-500"}));case"function":return g(mt,null,u,g(Qt,null,\`\u0192 \${e.name||"anonymous"}()\`));default:return Array.isArray(e)?g(mt,null,g("button",{className:"text-xs flex items-center gap-1 cursor-pointer w-full",title:i,onclick:()=>{ki(e,y=>o.splice(o.indexOf(y),1)),c(y=>!y)}},r,g(ce,{width:10,height:10,className:\`transition \${l?"":"rotate-90"}\`})),l?g(Qt,null,"Array(",e.length,")"):e.length>a?g(Oh,{array:e,objectRefAcc:o}):g("div",{className:"flex flex-col items-start gap-1 w-full"},e.map((y,x)=>g(uo,{value:y,onChange:t,keys:[...n,x.toString()],path:i.concat(".",x.toString()),label:x.toString(),mutable:s,objectRefAcc:o})))):o.includes(e)?g(mt,null,u,g(Qt,null,"Object(circular reference)")):(o.push(e),g(mt,null,g("button",{className:"text-xs flex items-center gap-1 cursor-pointer w-full",title:i,onclick:()=>{ki(e,y=>o.splice(o.indexOf(y),1)),c(y=>!y)}},r,g(ce,{width:10,height:10,className:\`transition \${l?"":"rotate-90"}\`})),l?null:g(me,{data:e,onChange:t,keys:n,mutable:s,objectRefAcc:o})))}}function mt({children:e}){return g("div",{className:"flex flex-col items-start gap-1 w-full"},e)}function ts(e){return g("input",{className:"flex-grow text-xs px-2 py-1 text-neutral-300 w-full",...e})}function Qt({children:e}){return g("small",{className:"text-neutral-300"},g("i",null,e))}function Oh({array:e,objectRefAcc:t}){const{userSettings:{arrayChunkSize:n}}=zi(),i=e.length,s=Math.ceil(i/n);return g("div",{className:"flex flex-col items-start gap-1 w-full"},Array.from({length:s}).map((o,r)=>g(Ph,{array:e,range:{start:r*n,end:(r+1)*n},objectRefAcc:t})))}function Ph({array:e,range:t,objectRefAcc:n}){const[i,s]=ge(!0);let o;return i?o=void 0:o=e.slice(t.start,t.end),g("div",{className:"flex flex-col items-start gap-1 w-full"},g("button",{className:"text-xs flex items-center gap-1 cursor-pointer w-full",onclick:()=>{n.splice(n.indexOf(e),1),s(r=>!r)}},"[",t.start,"..",(t.end<e.length?t.end:e.length)-1,"]",g(ce,{width:10,height:10,className:\`transition \${i?"":"rotate-90"}\`})),o&&g("div",{className:"flex flex-col items-start gap-1 w-full"},o.map((r,a)=>g(uo,{value:r,onChange:Ch,label:(t.start+a).toString(),keys:[a.toString()],path:a.toString(),mutable:!1,objectRefAcc:n}))))}const Dh="kiru-devtools";"window"in globalThis&&(window.__devtoolsSelection??=null,window.__devtoolsNodeUpdatePtr??=null);class Ah extends BroadcastChannel{send(t){super.postMessage(t)}removeEventListener(t){return super.removeEventListener("message",t)}addEventListener(t){return super.addEventListener("message",t)}}const Fe=new Ah(Dh);function Hi({fn:e,onclick:t}){const n=Si(()=>bh(e),[e]);return n?g("a",{className:"flex items-center gap-1 text-[10px] opacity-50 hover:opacity-100 transition-opacity",href:n,onclick:i=>{i.preventDefault(),Fe.send({type:"open-editor",fileLink:n}),t?.(i)},title:"Open in editor"},"Open in editor",g(vh,{width:"0.65rem",height:"0.65rem"})):null}function Ih({selectedApp:e,selectedNode:t,setSelectedNode:n,kiruGlobal:i}){const s=pe();rt(()=>{const l=c=>{c===e&&(qu(t)?n(null):s())};return i?.on("update",l),()=>i?.off("update",l)},[]);const o=()=>{const l=window.opener;if(!t||!l){console.error("invalid refresh state",{w:l,selectedNode:t});return}l.__devtoolsNodeUpdatePtr=t,Fe.send({type:"update-node"}),console.debug("[kiru]: sent refresh message",t)},r={...t.props};delete r.children;const a=Nh(t);return g("div",{className:"flex-grow p-2 sticky top-0"},g("h2",{className:"flex justify-between items-center font-bold mb-2 pb-2 border-b-2 border-neutral-800"},g("div",{className:"flex gap-2 items-center"},"<"+ao(t)+">",g(Hi,{fn:t.type})),g("button",{onclick:o},g(ml,{className:"w-5 h-5"}))),g(bl,{title:"props",disabled:Object.keys(r).length===0},g(me,{data:r,onChange:()=>{},mutable:!1,objectRefAcc:[]})),g(wl,{node:a,selectedApp:e}))}function Lh(e){return e.name==="devtools:useHookDebugGroup"}function Rh(e){return Ds in e}const Ds=Symbol.for("devtools.hookGroup");function Nh(e){const t={parent:null,name:"hooks",children:[],[Ds]:!0};if(e.hooks?.length){let n=t;for(let i=0;i<e.hooks.length;i++){const s=e.hooks[i];if(Lh(s)){switch(s.action){case"start":const o={parent:n,name:s.displayName,children:[],[Ds]:!0};n.children.push(o),n=o;break;case"end":if(n.name!==s.displayName||n.parent===null)throw new Error("useHookDebugGroup:end called with no start");n=n.parent;break}continue}n.children.push(s)}}return t}function wl({node:e,selectedApp:t,depth:n=0}){if(Rh(e))return g(bl,{title:e.name,className:"bg-[#ffffff04] border border-[#fff1] flex flex-col gap-2 pl-6",disabled:e.children.length===0},e.children.map(u=>g(wl,{node:u,selectedApp:t,depth:n+1})));const{name:i,dev:s,cleanup:o,...r}=e,a=s?.devtools,l=typeof a?.get=="function"?a.get():r;return g("div",null,g("i",{className:"text-neutral-300 text-sm"},i||"anonymous hook"),g("div",{className:"p-2"},g(me,{data:l,onChange:(u,f)=>{if(!t||!a?.set||!a?.get)return;const d=a.get();ro(d,u,f),a.set(d)},mutable:!!a?.set,objectRefAcc:[]})))}const Ae=(e,t,n={})=>{rt(()=>{let i=window;const s=n?.ref?.();return s?i=s:n.ref&&console.warn("useEventListener ref failed, using window"),i.addEventListener(e,t,n),()=>{i.removeEventListener(e,t,n)}},[t])},Fh=()=>{const e=J({x:0,y:0}),t=J({x:0,y:0}),n=J({x:0,y:0});return Ae("mousemove",i=>{e.value={x:i.x,y:i.y},t.value={x:i.movementX,y:i.movementY},n.value={x:i.clientX,y:i.clientY}}),{mouse:e,delta:t,client:n}},Qn="window"in globalThis&&"ResizeObserver"in globalThis.window,zh=(e,t,n=void 0)=>yt()?Qn?_t("useResizeObserver",{resizeObserver:null,deps:[e.current]},({isInit:i,hook:s,queueEffect:o})=>(i&&(s.resizeObserver=new ResizeObserver(t),s.cleanup=()=>{s.resizeObserver?.disconnect?.(),s.resizeObserver=null}),o(()=>{He([e.current],s.deps)&&(s.deps=[e.current],s.resizeObserver?.disconnect?.(),e.current&&s.resizeObserver?.observe(e.current,n))}),{isSupported:Qn,start:()=>{s.resizeObserver==null&&(s.resizeObserver=new ResizeObserver(t),e.current&&s.resizeObserver.observe(e.current,n),s.cleanup=()=>{s.resizeObserver?.disconnect?.(),s.resizeObserver=null})},stop:()=>{Hn(s)}})):{isSupported:Qn,start:()=>{},stop:()=>{}}:{isSupported:Qn,start:()=>{},stop:()=>{}},Jn="window"in globalThis&&"MutationObserver"in globalThis.window,Hh=(e,t,n=void 0)=>yt()?Jn?_t("useMutationObserver",{mutationObserver:null,deps:[e.current]},({isInit:i,hook:s,queueEffect:o})=>(i?(o(()=>{s.deps=[e.current],s.mutationObserver=new MutationObserver(t),e.current&&s.mutationObserver.observe(e.current,n)}),s.cleanup=()=>{s.mutationObserver?.disconnect?.(),s.mutationObserver=null}):He([e.current],s.deps)&&(s.deps=[e.current],s.mutationObserver?.disconnect?.(),e.current&&s.mutationObserver?.observe(e.current,n)),{isSupported:Jn,start:()=>{s.mutationObserver==null&&(s.mutationObserver=new MutationObserver(t),e.current&&s.mutationObserver.observe(e.current,n),s.cleanup=()=>{s.mutationObserver?.disconnect?.(),s.mutationObserver=null})},stop:()=>{Hn(s)}})):{isSupported:Jn,start:()=>{},stop:()=>{}}:{isSupported:Jn,start:()=>{},stop:()=>{}},Vh=(e,t={windowScroll:!0,windowResize:!0})=>{const n=t?.windowScroll??!0,i=t?.windowResize??!0,s=t.immediate??!0,o=J(0),r=J(0),a=J(0),l=J(0),c=J(0),u=J(0),f=J(0),d=J(0),m=()=>{const y=e.current;if(!y){o.value=0,r.value=0,a.value=0,l.value=0,c.value=0,u.value=0,f.value=0,d.value=0;return}const x=y.getBoundingClientRect();o.value=x.width,r.value=x.height,a.value=x.top,l.value=x.right,c.value=x.bottom,u.value=x.left,f.value=x.x,d.value=x.y};return zh(e,m),Hh(e,m,{attributeFilter:["style","class"]}),Ae("scroll",()=>{n&&m()},{capture:!0,passive:!0}),Ae("resize",()=>{i&&m()},{passive:!0}),oo(()=>{s&&m()},[]),{width:o,height:r,top:a,right:l,bottom:c,left:u,x:f,y:d,update:m}};function Bh(e){return typeof e=="function"?e:typeof e=="string"?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}const or=(e,t,n={})=>{const{ref:i,eventName:s="keydown",passive:o=!1}=n,r=Bh(e);return Ae(s,l=>{l.repeat&&!n.repeat||r(l)&&t(l)},{ref:i,passive:o})};function ho({value:e,className:t,...n}){const i=pl();return g("div",{className:_i("w-full p-2 z-10","bg-[#1d1d1d] border border-white border-opacity-10 rounded",t?.toString()),...n},g("input",{className:_i("px-2 py-1 w-full rounded focus:outline focus:outline-primary","bg-[#212121] border border-white border-opacity-10 rounded"),placeholder:"Filter...",type:"text",autocomplete:i+Math.random().toString(36).substring(2,15),name:"filter-search",id:"filter-search","bind:value":e}))}let U;"window"in globalThis&&window.opener&&(U=window.opener.__kiru);const qe=G(!1);Fe.addEventListener(e=>{e.data.type==="set-inspect-enabled"&&(qe.value=e.data.value)});const Sl=(U?.apps??[]).filter(e=>!An(e)),se=G(Sl);G(null);const Lt=G(Sl[0]??null),oe=G(null);U?.on("mount",e=>{An(e)||(se.value=[...se.peek(),e],Lt.peek()===null&&(Lt.value=e))});U?.on("unmount",e=>{se.value=se.peek().filter(t=>t!==e),Lt.peek()===e&&(Lt.value=se.peek()[0]??null)});const As=G(new Map),Rt=G(null),fo=G("");function Wh(e){return e.type.displayName??(e.type.name||"Anonymous Function")}function jh(e,t){const n=t.toLowerCase();return e.every(i=>n.includes(i))}function Is(e){return typeof e.type=="function"&&!Ku(e)&&!Zu(e)&&!Qu(e)}function $h(e){let t=[e];for(;t.length;){const n=t.pop();if(Is(n))return!0;n.child&&t.push(n.child),n.sibling&&t.push(n.sibling)}return!1}const Uh=(e,t)=>{const n=[t.parent];for(;n.length;){const i=n.pop();if(e===i)return!0;i?.parent&&n.push(i.parent)}return!1};function Ls(e,t){if(!e)return null;const n=t(e),i=Ls(e.sibling,t),s=Ls(e.child,t);return n?{ref:e,sibling:i??null,child:s??null}:i||s||null}function Ti({node:e,traverseSiblings:t=!0}){const[n,i]=ge(!0),o=oe.value===e,r=Si(()=>crypto.randomUUID(),[]),a=Si(()=>Rt.value==null?null:Uh(e,Rt.value),[Rt.value,e]);rt(()=>{a&&i(!1)},[a]),rt(()=>{if(!(!e||!Is(e)))return As.peek().set(r,{vNode:e,setCollapsed:i}),()=>{As.peek().delete(r)}});const l=fo.value;if(!e)return null;if(!Is(e)||l.length>0&&!jh(l.toLowerCase().split(" "),e.type.name))return g(Tt,null,e.child&&g(Ti,{node:e.child}),t&&g(rr,{node:e}));const c=e.child&&$h(e.child);return g(Tt,null,g("div",{className:"pl-4 mb-1"},g("h2",{onclick:()=>{Rt.value=null,oe.value=o?null:e},className:\`flex gap-2 items-center cursor-pointer mb-1 scroll-m-12 \${o?"font-medium bg-primary selected-vnode":""}\`,"data-id":r},c&&g(ce,{className:\`cursor-pointer transition \${n?"":"rotate-90"}\`,onclick:u=>{u.preventDefault(),u.stopImmediatePropagation(),Rt.value=null,i(f=>!f)}}),g("div",{className:c?"":"ml-6"},g("span",{className:o?"":"text-neutral-400"},"<"),g("span",{className:o?"":"text-primary"},Wh(e)),g("span",{className:o?"":"text-neutral-400"},">"))),!n&&e.child||a!=null&&a&&e.child?g(Ti,{node:e.child}):null),t&&g(rr,{node:e}))}function rr({node:e}){if(!e)return null;let t=[],n=e.sibling;for(;n;)t.push(n),n=n.sibling;return g(Tt,null,t.map(i=>g(Ti,{node:i,traverseSiblings:!1})))}const Yh=()=>{const e=Ne(null),t=r=>{if(!r)return null;const a=r.getAttribute("data-id");if(a!=null)return As.peek().get(a)},n=r=>{if(!r)return;const a=t(r);a!=null&&(r.scrollIntoView({behavior:"smooth"}),oe.value=a.vNode)},i=r=>{if(!r||r===document.body)return null;const a=r.parentElement,l=a?.nextElementSibling?.querySelector("h2[data-id]");return l||i(a)},s=()=>{const r=document.querySelector("h2[data-id]");n(r)},o=()=>{const r=document.querySelectorAll("h2[data-id]"),a=r.item(r.length-1);a&&n(a)};return or(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],r=>{if(Rt.value&&(Rt.value=null),document.activeElement&&document.activeElement instanceof HTMLInputElement&&document.activeElement!=e.current)return;r.preventDefault();const a=document.querySelector(".selected-vnode");if(a===null){r.key==="ArrowDown"?s():r.key==="ArrowUp"&&o();return}if(r.key==="ArrowRight"){const l=t(a);l&&l.setCollapsed(!1);return}else if(r.key==="ArrowLeft"){const l=t(a);l&&l.setCollapsed(!0);return}if(r.key==="ArrowDown"){const l=a?.nextElementSibling?.querySelector("h2[data-id]");if(l)return n(l);const c=a.parentElement?.nextElementSibling?.querySelector("h2[data-id]");if(c)return n(c);const u=i(a);return u?n(u):s()}else if(r.key==="ArrowUp"){const l=a.parentElement?.previousElementSibling;if(l?.matches("h2[data-id]"))return n(l);const c=l?.querySelectorAll("h2[data-id]");return c?.length!=null&&c?.length>=1?n(c?.item?.(c.length-1)):o()}}),or("l",r=>{r.ctrlKey&&(r.preventDefault(),e.current?.focus({preventScroll:!1}))}),{searchRef:e}},Xh=e=>{fo.value=e.target.value,Rt.value&&(Rt.value=null)};function qh(){const{searchRef:e}=Yh(),t=Lt.value;return g("div",{className:"flex-grow p-2 sticky top-0"},g("div",{className:"flex gap-4 pb-2 border-b-2 border-neutral-800 mb-2 items-center"},g("input",{ref:e,className:"bg-[#171616] px-1 py-2 w-full focus:outline focus:outline-primary",placeholder:"Search for component",type:"text",value:fo,oninput:Xh})),t?.rootNode&&g(Ti,{node:t.rootNode}))}const kl=e=>{const{mouse:t}=Fh(),n=J(null),i=J(0),s=J(0),o=Ne(null),r=Vh(o),a=Ne(null),[l,c]=Array.isArray(e.children)?e.children:[];return oo(()=>{a.current&&(s.value=a.current.clientWidth/2)},[a.current]),Ae("mouseup",Xe(()=>n.value=null,[])),Ae("mousemove",Xe(u=>{if(n.value==null||a.current==null)return;const f=Math.max(i.value+u.x-n.value.x,250);s.value=Math.min(f,a.current.clientWidth-250)},[])),Ae("resize",Xe(()=>{a.current!=null&&a.current.clientWidth-250<s.value&&(s.value=Math.max(a.current.clientWidth-250,250))},[])),g("div",{onmousemove:u=>{u.x},ref:a,className:"flex-grow grid gap-2 items-start w-full relative",style:{gridTemplateColumns:\`\${s}px 1fr\`}},g("div",{ref:o,className:"firstContainer w-full h-full"},l),r.width.value!=0&&g("div",{className:"w-8 flex justify-center h-full absolute top-0 -translate-x-1/2 cursor-col-resize z-[9999]",style:{left:\`\${r.width}px\`},onmousedown:u=>{u.preventDefault(),n.value={...t.value},i.value=s.value}},g("div",{className:"dividerLine w-[5px] bg-neutral-800 h-full"})),g("div",{className:"secondContainer h-full"},c))},Gh=()=>g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-square-mouse-pointer"},g("path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"}),g("path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"})),Kh=()=>{qe.value=!qe.value,Fe.send({type:"set-inspect-enabled",value:qe.value})};function Zh(){const e=Lt.value,t=oe.value,n=pe();return rt(()=>{const i=s=>{s===e&&n()};return U?.on("update",i),()=>U?.off("update",i)},[Lt]),rt(()=>{const i=s=>{if(s.data.type!=="select-node")return;gh(window.__devtoolsSelection,"no selection ptr");const{app:o,node:r}=window.__devtoolsSelection;window.__devtoolsSelection=null,Lt.value=o,oe.value=r,Rt.value=r,qe.value=!1};return Fe.addEventListener(i),()=>Fe.removeEventListener(i)},[Lt]),g(Tt,null,g("div",{className:"flex items-center justify-between gap-4 p-2 bg-neutral-400 bg-opacity-5 border border-white border-opacity-10 rounded"},g("div",{className:"flex items-center gap-4"},g("select",{className:"px-2 py-1 bg-neutral-800 text-neutral-100 rounded border border-white border-opacity-10",value:e?.name??"",onchange:i=>Lt.value=se.peek().find(s=>s.name===i.currentTarget.value)??null},g("option",{value:"",disabled:!0},"Select App"),se.value.map(i=>g("option",{key:i.id,value:i.name},i.name))),g("button",{title:"Toggle Component Inspection",onclick:Kh,className:\`p-1 rounded \${qe.value?"bg-neutral-900":""}\`},g(Gh,null)))),g(kl,null,e&&g(qh,null),t&&e&&g(Ih,{selectedApp:e,selectedNode:t,setSelectedNode:i=>oe.value=i,kiruGlobal:U})))}const Rs=G({}),Ce=G([]);U?.stores?.subscribe(e=>{Rs.value=e,Ce.value=Ce.value.filter(t=>Object.values(Rs.value).includes(t))});const Tl=G(""),Qh=Vn(()=>Tl.value.toLowerCase().split(" ").filter(e=>e.length>0));function Jh(e){return Qh.value.every(t=>e.toLowerCase().includes(t))}function tf(){const e=Object.entries(Rs.value);return e.length===0?g("div",{className:"flex flex-col items-center justify-center h-full text-neutral-400"},g(lo,null),g("h2",{className:"text-lg italic"},"No stores detected")):g("div",{className:"flex flex-col gap-2 items-start"},g(ho,{value:Tl,className:"sticky top-0"}),g("div",{className:"flex flex-col gap-2 w-full"},e.filter(([t])=>Jh(t)).map(([t,n])=>g(ef,{key:t,name:t,store:n}))))}function ef({name:e,store:t}){const n=Ce.value.includes(t),i=pe(),{value:s}=Ml(t);oo(()=>{const r=t.subscribe(()=>i());return()=>r()},[]);const o=Xe(()=>{n?Ce.value=Ce.value.filter(r=>r!==t):Ce.value=[...Ce.value,t]},[n]);return g("div",{className:"flex flex-col"},g("button",{onclick:o,className:"flex items-center gap-2 justify-between p-2 border border-white border-opacity-10 cursor-pointer"+(n?" bg-white bg-opacity-5 text-neutral-100 rounded-t":" hover:bg-white hover:bg-opacity-10 text-neutral-400 rounded")},e,g("div",{className:"flex gap-2"},g(Hi,{fn:t,onclick:r=>r.stopPropagation()}),g(ce,{className:"transition-all"+(n?" rotate-90":"")}))),n&&g("div",{className:"flex flex-col gap-2 p-2 border border-white border-opacity-10"},g(me,{data:{value:s},mutable:!0,objectRefAcc:[],onChange:(r,a)=>{const l=structuredClone({value:s});ro(l,r,a),t.setState(l.value)}}),g(nf,{store:t})))}function nf({store:e}){const t=se.value;return t.length===0?null:g(Tt,null,t.map(n=>g(sf,{store:e,app:n})))}const ar=Symbol.for("kiru.hmrAccept"),Ml=e=>{if(ar in e)return e[ar].provide().current;throw new Error("Unable to get store subscribers")};function sf({store:e,app:t}){const n=pe(),{subscribers:i,nodeStateMap:s}=Ml(e),o=t.rootNode.child;if(rt(()=>{const a=l=>{l===t&&n()};return U?.on("update",a),()=>U?.off("update",a)},[]),!o)return null;const r=Ls(o,a=>i.has(a));return g("div",{className:"flex flex-col gap-2 p-2 rounded-b border border-white border-opacity-10"},g("b",null,t.name),r&&g("ul",{className:"pl-8"},g(Ns,{node:r,nodeStateMap:s})))}function Ns({node:e,nodeStateMap:t}){const[n,i]=ge(!1),o=t.get(e.ref)?.slices??[];return g(Tt,null,g("li",{className:"flex flex-col gap-2"},g("div",{className:"flex flex-col border border-white border-opacity-10 rounded"+(n?" bg-white bg-opacity-5 text-neutral-100":" hover:bg-white hover:bg-opacity-10 text-neutral-400")},g("button",{onclick:()=>i(!n),className:"flex gap-2 p-2 justify-between cursor-pointer"},g("span",null,"<"+ao(e.ref)+" />"),g("div",{className:"flex gap-2 items-center"},g(Hi,{fn:e.ref.type,onclick:r=>r.stopPropagation()}),g(ce,{className:"transition-all"+(n?" rotate-90":"")}))),n&&g("div",{className:"flex flex-col gap-2 p-2 bg-[#1a1a1a]"},o.length===0&&g("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},g("h5",{className:"border-b border-white border-opacity-10"},"No slices")),o.map(r=>g("div",{className:"flex flex-col gap-2"},g("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},g("h5",{className:"border-b border-white border-opacity-10"},"Slice:"),g("pre",{className:"text-neutral-400"},g(me,{data:{value:r.value},mutable:!1,objectRefAcc:[],onChange:()=>{}}))),g("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},g("h5",{className:"border-b border-white border-opacity-10"},"SliceFn:"),g("pre",{className:"text-neutral-400"},r.sliceFn?r.sliceFn.toString():"null")),r.eq&&g("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},g("h5",{className:"border-b border-white border-opacity-10"},"eq:"),g("pre",{className:"text-neutral-400"},r.eq.toString())))))),e.child&&g("ul",{className:"pl-8 flex flex-col gap-2"},g(Ns,{node:e.child,nodeStateMap:t}))),e.sibling&&g(Ns,{node:e.sibling,nodeStateMap:t}))}/*!
9278
+ <script type="module" crossorigin>(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const r of o.addedNodes)r.tagName==="LINK"&&r.rel==="modulepreload"&&i(r)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();const iu="production",de=iu==="development",Ha=Symbol.for("kiru.signal"),su=Symbol.for("kiru.context"),Li=Symbol.for("kiru.contextProvider"),zt=Symbol.for("kiru.fragment"),Va=Symbol.for("kiru.error"),Ba=Symbol.for("kiru.memo"),to=Symbol.for("kiru.errorBoundary"),ou=Symbol.for("kiru.streamData"),ru=Symbol.for("kiru.devFileLink"),au=50,gn="kiru:deferred",ie=2,ae=4,Ri=8,le=16,Wa=32,ds=64,Ke=128,lu=/^on:?/,ja=new Set(["animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","path","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","title","tspan","use"]),cu=new Set(["allowfullscreen","autofocus","autoplay","async","checked","compact","controls","contenteditable","declare","default","defer","disabled","download","hidden","inert","ismap","multiple","nohref","noresize","noshade","novalidate","nowrap","open","popover","readonly","required","sandbox","scoped","selected","sortable","spellcheck","translate","wrap"]),uu=new Map([["acceptCharset","accept-charset"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["httpEquiv","http-equiv"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),Re={current:null},$a={current:0},Ht={current:"window"in globalThis?"dom":"string"},hu={current:"dynamic"};var Ua;class Ze extends Error{constructor(t){const n=typeof t=="string"?t:t.message;super(n),this[Ua]=!0,typeof t!="string"&&(this.fatal=t?.fatal)}static isKiruError(t){return t instanceof Error&&t[Va]===!0}}Ua=Va;const Qe={parentStack:[],childIdxStack:[],eventDeferrals:new Map,parent:function(){return this.parentStack[this.parentStack.length-1]},clear:function(){this.parentStack.length=0,this.childIdxStack.length=0},pop:function(){this.parentStack.pop(),this.childIdxStack.pop()},push:function(e){this.parentStack.push(e),this.childIdxStack.push(0)},currentChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]]},nextChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]++]},bumpChildIndex:function(){this.childIdxStack[this.childIdxStack.length-1]++},captureEvents:function(e){Go(e,!0),this.eventDeferrals.set(e,[])},resetEvents:function(e){this.eventDeferrals.delete(e)},releaseEvents:function(e){Go(e,!1);const t=this.eventDeferrals.get(e);for(;t?.length;)t.shift()()}},fu=e=>{const t=e.target;!e.isTrusted||!t||Qe.eventDeferrals.get(t)?.push(()=>t.dispatchEvent(e))},Go=(e,t)=>{for(const n in e)if(n.startsWith("on")){const i=n.substring(2);e[t?"addEventListener":"removeEventListener"](i,fu,{passive:!0})}};let eo=!1,ps=!1;const Ya=e=>{e.preventDefault(),e.stopPropagation(),ps=!0};let Oe=null;function du(){eo=!0,Oe=document.activeElement,Oe&&Oe!==document.body&&Oe.addEventListener("blur",Ya)}function pu(){ps&&(Oe.removeEventListener("blur",Ya),Oe.isConnected&&Oe.focus(),ps=!1),eo=!1}function gu(e){const t=e.type;return t=="#text"?Xa(e):ja.has(t)?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)}function Xa(e){const{nodeValue:t}=e.props;if(!W.isSignal(t))return document.createTextNode(t);const n=t.peek()??"",i=document.createTextNode(n);return ms(e,i,t),i}function mu(e,t,n){const i=gs.get(e)??{},s=i[t]=o=>{if(eo){o.preventDefault(),o.stopPropagation();return}n(o)};return gs.set(e,i),s}const gs=new WeakMap;function qa(e){const{dom:t,prev:n,props:i,cleanups:s}=e,o=n?.props??{},r=i??{},a=Ht.current==="hydrate";if(t instanceof Text){const f=r.nodeValue;!W.isSignal(f)&&t.nodeValue!==f&&(t.nodeValue=f);return}const l=[];for(const f in o)l.push(f);for(const f in r)f in o||l.push(f);for(let f=0;f<l.length;f++){const d=l[f],m=o[d],y=r[d];if(Cs.isEvent(d)){if(m!==y||a){const x=d.replace(lu,""),v=x==="focus"||x==="blur",w=gs.get(e);d in o&&t.removeEventListener(x,v?w?.[x]:m),d in r&&t.addEventListener(x,v?mu(e,x,y):y)}continue}if(!(Cs.isInternalProp(d)&&d!=="innerHTML")&&m!==y){if(W.isSignal(m)&&s){const x=s[d];x&&(x(),delete s[d])}if(W.isSignal(y)){vu(e,t,d,y,m);continue}pi(t,d,y,m)}}const c=o.ref,u=r.ref;c!==u&&(c&&Os(c,null),u&&Os(u,t))}function bu(e){return e.multiple?Array.from(e.selectedOptions).map(t=>t.value):e.value}function Ga(e,t){if(!e.multiple||t===void 0||t===null||t===""){e.value=t;return}Array.from(e.options).forEach(n=>{n.selected=t.indexOf(n.value)>-1})}const xu={value:"input",checked:"change",open:"toggle",volume:"volumechange",playbackRate:"ratechange",currentTime:"timeupdate"},yu=["progress","meter","number","range"];function vu(e,t,n,i,s){const o=e.cleanups??(e.cleanups={}),[r,a]=n.split(":");if(r!=="bind"){o[n]=i.subscribe((E,C)=>{E!==C&&pi(t,n,E,C)});const w=i.peek(),k=tn(s);if(w===k)return;pi(t,n,w,k);return}const l=xu[a];if(!l)return;const c=t instanceof HTMLSelectElement,u=c?w=>Ga(t,w):w=>t[a]=w,f=w=>{u(w)},d=w=>{i.sneak(w),i.notify(k=>k!==f)};let m;if(a==="value"){const w=yu.indexOf(t.type)!==-1;m=()=>{let k=t.value;c?k=bu(t):typeof i.peek()=="number"&&w&&(k=t.valueAsNumber),d(k)}}else m=w=>{const k=w.target[a];a==="currentTime"&&i.peek()===k||d(k)};t.addEventListener(l,m);const y=i.subscribe(f);o[n]=()=>{t.removeEventListener(l,m),y()};const x=i.peek(),v=tn(s);x!==v&&pi(t,a,x,v)}function ms(e,t,n){(e.cleanups??(e.cleanups={})).nodeValue=n.subscribe((i,s)=>{i!==s&&(t.nodeValue=i)})}function _u(e){if(e.type!=="#text"||!W.isSignal(e.props.nodeValue))return;const t=tn(e.props.nodeValue);if(t!=null)return;const n=Xa(e);return Qe.parent().appendChild(n),n}function wu(e){const t=Qe.nextChild()??_u(e);if(!t)throw new Ze({message:"Hydration mismatch - no node found",vNode:e});let n=t.nodeName;if(ja.has(n)||(n=n.toLowerCase()),e.type!==n)throw new Ze({message:\`Hydration mismatch - expected node of type \${e.type.toString()} but received \${n}\`,vNode:e});if(e.dom=t,e.type!=="#text"&&!(e.flags&le)){qa(e);return}W.isSignal(e.props.nodeValue)&&ms(e,t,e.props.nodeValue);let i=e,s=e.sibling;for(;s&&s.type==="#text";){const o=s;Qe.bumpChildIndex();const r=String(tn(i.props.nodeValue)??""),a=i.dom.splitText(r.length);o.dom=a,W.isSignal(o.props.nodeValue)&&ms(o,a,o.props.nodeValue),i=s,s=s.sibling}}function Ka(e,t,n,i=!1){if(n===null)return e.removeAttribute(t),!0;switch(typeof n){case"undefined":case"function":case"symbol":return e.removeAttribute(t),!0;case"boolean":if(i&&!n)return e.removeAttribute(t),!0}return!1}function Su(e,t,n){const i=cu.has(t);Ka(e,t,n,i)||e.setAttribute(t,i&&typeof n=="boolean"?"":String(n))}const ku=["INPUT","TEXTAREA"],Tu=e=>ku.indexOf(e.nodeName)>-1;function pi(e,t,n,i){switch(t){case"style":return Cu(e,n,i);case"className":return Eu(e,n);case"innerHTML":return Mu(e,n);case"muted":e.muted=!!n;return;case"value":if(e.nodeName==="SELECT")return Ga(e,n);const s=n==null?"":String(n);if(Tu(e)){e.value=s;return}e.setAttribute("value",s);return;case"checked":if(e.nodeName==="INPUT"){e.checked=!!n;return}e.setAttribute("checked",String(n));return;default:return Su(e,qu(t),n)}}function Mu(e,t){if(t==null||typeof t=="boolean"){e.innerHTML="";return}e.innerHTML=String(t)}function Eu(e,t){const n=tn(t);if(!n)return e.removeAttribute("class");e.setAttribute("class",n)}function Cu(e,t,n){if(Ka(e,"style",t))return;if(typeof t=="string"){e.setAttribute("style",t);return}let i={};typeof n=="string"?e.setAttribute("style",""):typeof n=="object"&&n&&(i=n);const s=t;new Set([...Object.keys(i),...Object.keys(s)]).forEach(r=>{const a=i[r],l=s[r];if(a!==l){if(l===void 0){e.style[r]="";return}e.style[r]=l}})}function Ou(e){let t=e.parent,n=t?.dom;for(;t&&!n;)t=t.parent,n=t?.dom;if(!n||!t){if(!e.parent&&e.dom)return e;throw new Ze({message:"No DOM parent found while attempting to place node.",vNode:e})}return t}function Pu(e,t){const{node:n,lastChild:i}=t,s=e.dom;if(i){i.after(s);return}const o=Za(e,n);if(o){n.dom.insertBefore(s,o);return}n.dom.appendChild(s)}function Za(e,t){let n=e;for(;n;){let i=n.sibling;for(;i;){if(!(i.flags&(ae|le))){const s=Du(i);if(s?.isConnected)return s}i=i.sibling}if(n=n.parent,!n||n.flags&le||n===t)return}}function Du(e){let t=e;for(;t;){if(t.dom)return t.dom;if(t.flags&le)return;t=t.child}}function Au(e){if(Ht.current==="hydrate")return Fi(e,_i);const t={node:e.dom?e:Ou(e)};bs(e,t,(e.flags&ae)>0),e.dom&&!(e.flags&le)&&Qa(e,t,!1),_i(e)}function bs(e,t,n){let i=e.child;for(;i;){if(i.flags&ds){i.flags&ae&&Lu(i,t),_i(i),i=i.sibling;continue}i.dom?(bs(i,{node:i},!1),i.flags&le||Qa(i,t,n)):bs(i,t,(i.flags&ae)>0||n),_i(i),i=i.sibling}}function Qa(e,t,n){(n||!e.dom.isConnected||e.flags&ae)&&Pu(e,t),(!e.prev||e.flags&ie)&&qa(e),t.lastChild=e.dom}function Iu(e){e===e.parent?.child&&(e.parent.child=e.sibling),Fi(e,t=>{const{hooks:n,subs:i,cleanups:s,dom:o,props:{ref:r}}=t;for(i?.forEach(a=>a()),s&&Object.values(s).forEach(a=>a());n?.length;)try{n.pop().cleanup?.()}catch{}o&&(o.isConnected&&!(t.flags&le)&&o.remove(),r&&Os(r,null),delete t.dom)}),e.parent=null}function Lu(e,t){if(!e.child)return;const n=[];if(Ja(e.child,n),n.length===0)return;const{node:i,lastChild:s}=t;if(s)s.after(...n);else{const o=Za(e,i),r=i.dom;o?o.before(...n):r.append(...n)}t.lastChild=n[n.length-1]}function Ja(e,t){let n=e;for(;n;)n.dom?t.push(n.dom):n.child&&Ja(n.child,t),n=n.sibling}function g(e,t=null,...n){e===Tt&&(e=zt);const i=t===null?{}:t,s=gl(i.key),o=n.length;return o===1?i.children=n[0]:o>1&&(i.children=n),{type:e,key:s,props:i}}function Tt({children:e,key:t}){return{type:zt,key:gl(t),props:{children:e}}}function tl(e){return typeof e=="function"&&typeof e[Ba]?.arePropsEqual=="function"}function el(e,t=null,n={},i=null,s=0){e===Tt&&(e=zt);const o=t?t.depth+1:0;return{type:e,key:i,props:n,parent:t,index:s,depth:o,flags:0,child:null,sibling:null,prev:null,deletions:null}}function no(e,t){return Array.isArray(t)?Nu(e,t):Ru(e,t)}function Ru(e,t){const n=e.child;if(n===null)return sl(e,t);const i=n.sibling,s=nl(e,n,t);if(s!==null)return n&&n!==s&&!s.prev?xs(e,n):i&&xs(e,i),s;{const o=al(n),r=ol(o,e,0,t);if(r!==null){const a=r.prev;if(a!==null){const l=a.key;o.delete(l===null?a.index:l)}gi(r,0,0)}return o.forEach(a=>yi(e,a)),r}}function Nu(e,t){let n=null,i=null,s=e.child,o=null,r=0,a=0;for(;s!==null&&a<t.length;a++){s.index>a?(o=s,s=null):o=s.sibling;const c=nl(e,s,t[a]);if(c===null){s===null&&(s=o);break}s&&!c.prev&&yi(e,s),r=gi(c,r,a),i===null?n=c:i.sibling=c,i=c,s=o}if(a===t.length)return xs(e,s),n;if(s===null){for(;a<t.length;a++){const c=sl(e,t[a]);c!==null&&(r=gi(c,r,a),i===null?n=c:i.sibling=c,i=c)}return n}const l=al(s);for(;a<t.length;a++){const c=ol(l,e,a,t[a]);if(c!==null){const u=c.prev;if(u!==null){const f=u.key;l.delete(f===null?u.index:f)}r=gi(c,r,a),i===null?n=c:i.sibling=c,i=c}}return l.forEach(c=>yi(e,c)),n}function nl(e,t,n){const i=t===null?null:t.key;return so(n)?i!==null||t?.type==="#text"&&W.isSignal(t.props.nodeValue)?null:Ko(e,t,""+n):W.isSignal(n)?t&&t.props.nodeValue!==n?null:Ko(e,t,n):io(n)?n.key!==i?null:Fu(e,t,n):Array.isArray(n)?i!==null?null:il(e,t,n):null}function Ko(e,t,n){return t===null||t.type!=="#text"?Nt(e,"#text",{nodeValue:n}):(t.props.nodeValue!==n&&(t.props.nodeValue=n,t.flags|=ie),t.sibling=null,t)}function Fu(e,t,n){let{type:i,props:s,key:o}=n;return i===zt?il(e,t,s.children||[],s):t?.type===i?(t.index=0,t.sibling=null,typeof i=="string"?rl(t.props,s)&&(t.flags|=ie):t.flags|=ie,t.props=s,t):Nt(e,i,s,o)}function il(e,t,n,i={}){return t===null||t.type!==zt?Nt(e,zt,{children:n,...i}):(t.props={...t.props,...i,children:n},t.flags|=ie,t.sibling=null,t)}function sl(e,t){return so(t)?Nt(e,"#text",{nodeValue:""+t}):W.isSignal(t)?Nt(e,"#text",{nodeValue:t}):io(t)?Nt(e,t.type,t.props,t.key):Array.isArray(t)?Nt(e,zt,{children:t}):null}function gi(e,t,n){e.index=n;const i=e.prev;if(i!==null){const s=i.index;return s<t?(e.flags|=ae,t):s}else return e.flags|=ae,t}function ol(e,t,n,i){if(W.isSignal(i)||so(i)){const o=e.get(n);if(o){if(o.props.nodeValue===i)return o;o.type==="#text"&&W.isSignal(o.props.nodeValue)&&o.cleanups?.nodeValue?.()}return Nt(t,"#text",{nodeValue:i},null,n)}if(io(i)){const{type:o,props:r,key:a}=i,l=e.get(a===null?n:a);return l?.type===o?(typeof o=="string"?rl(l.props,r)&&(l.flags|=ie):l.flags|=ie,l.props=r,l.sibling=null,l.index=n,l):Nt(t,o,r,a,n)}if(Array.isArray(i)){const o=e.get(n);return o?(o.flags|=ie,o.props.children=i,o):Nt(t,zt,{children:i},null,n)}return null}function rl(e,t){const n=Object.keys(e),i=Object.keys(t);if(n.length!==i.length)return!0;for(let s of n)if(!(s==="children"||s==="key")&&e[s]!==t[s])return!0;return!1}function al(e){const t=new Map;for(;e;){const n=e.key;t.set(n===null?e.index:n,e),e=e.sibling}return t}function yi(e,t){e.deletions===null?e.deletions=[t]:e.deletions.push(t)}function xs(e,t){for(;t;)yi(e,t),t=t.sibling}function Nt(e,t,n,i=null,s=0){const o=el(t,e,n,i,s);return o.flags|=ae,typeof t=="function"&&tl(t)&&(o.flags|=Wa,o.arePropsEqual=t[Ba].arePropsEqual),o}let Xt=[],Je=!1,ys=[],vs=[],_s=!1,ws=!1,Ss=!1,ks=0,ll=[],Ts=[],cl=-1;function ul(e){if(!e)return new Promise(ul);if(Je){ys.push(e);return}e()}function hl(){Je&&(window.cancelAnimationFrame(cl),fl())}function Zo(e){e.flags|=Ke,Xt.push(e),Je=!0,hl()}function zn(e){if(Ht.current==="hydrate")return ul(()=>Ms(e));Ms(e)}function zu(){Je||(Je=!0,cl=window.requestAnimationFrame(fl))}function Hu(){for(Je=!1;ys.length;)ys.shift()()}function Ms(e){if(_s&&(ws=!0),Re.current===e){Ss=!0;return}if(!(e.flags&(Ke|Ri))){if(e.flags|=Ke,!Xt.length)return Xt.push(e),zu();Xt.push(e)}}function Vu(e){Fi(e,t=>t.flags|=Ri),vs.push(e)}const Bu=(e,t)=>t.depth-e.depth;let te=null;function fl(){let e=1;for(du();Xt.length;){Xt.length>e&&Xt.sort(Bu),te=Xt.shift(),e=Xt.length;const t=te.flags;if(!(t&Ri)&&t&Ke){let n=te;for(;n=Wu(n););for(;vs.length;)Iu(vs.pop());Au(te),te.flags&=~Ke}}if(pu(),_s=!0,Ji(ll),_s=!1,ws)return Yu(),Ji(Ts),ws=!1,ks++,hl();ks=0,Hu(),Ji(Ts)}function Wu(e){let t=!0;try{typeof e.type=="string"?Uu(e):Qu(e.type)?ju(e):t=$u(e)}catch(i){const s=ih(e);if(s){const o=s.error=i instanceof Error?i:new Error(String(i));return s.props.onError?.(o),s.depth<te.depth&&(te=s),s}if(Ze.isKiruError(i)){if(i.customNodeStack&&setTimeout(()=>{throw new Error(i.customNodeStack)}),i.fatal)throw i;console.error(i);return}setTimeout(()=>{throw i})}if(e.deletions!==null&&(e.deletions.forEach(Vu),e.deletions=null),t&&e.child)return e.child;let n=e;for(;n;){if(n.immediateEffects&&(ll.push(...n.immediateEffects),n.immediateEffects=void 0),n.effects&&(Ts.push(...n.effects),n.effects=void 0),n===te)return;if(n.sibling)return n.sibling;n=n.parent,Ht.current==="hydrate"&&n?.dom&&Qe.pop()}}function ju(e){const{props:t,type:n}=e;let i=t.children;if(n===Li){const{props:{dependents:s,value:o},prev:r}=e;s.size&&r&&r.props.value!==o&&s.forEach(Ms)}else if(n===to){const s=e,{error:o}=s;o&&(i=typeof t.fallback=="function"?t.fallback(o):t.fallback,delete s.error)}e.child=no(e,i)}function $u(e){const{type:t,props:n,subs:i,prev:s,flags:o}=e;if(o&Wa){if(e.memoizedProps=n,s?.memoizedProps&&e.arePropsEqual(s.memoizedProps,n)&&!e.hmrUpdated)return e.flags|=ds,!1;e.flags&=~ds}try{Re.current=e;let r,a=0;do e.flags&=~Ke,Ss=!1,$a.current=0,i&&(i.forEach(l=>l()),i.clear()),r=t(n);while(Ss);return e.child=no(e,r),!0}finally{Re.current=null}}function Uu(e){const{props:t,type:n}=e;e.dom||(Ht.current==="hydrate"?wu(e):e.dom=gu(e)),n!=="#text"&&(e.child=no(e,t.children),e.child&&Ht.current==="hydrate"&&Qe.push(e.dom))}function Yu(){if(ks>au)throw new Ze("Maximum update depth exceeded. This can happen when a component repeatedly calls setState during render or in useLayoutEffect. Kiru limits the number of nested updates to prevent infinite loops.")}function Ji(e){for(let t=0;t<e.length;t++)e[t]();e.length=0}var Qo;(function(e){e.Start="start",e.End="end"})(Qo||(Qo={}));const pe=()=>{const e=dl("useRequestUpdate");return()=>zn(e)};function _t(e,t,n){const i=dl(e),s=(a,l)=>{if(l?.immediate){(i.immediateEffects??(i.immediateEffects=[])).push(a);return}(i.effects??(i.effects=[])).push(a)},o=$a.current++;let r=i.hooks?.at(o);try{const a=r??(typeof t=="function"?t():{...t});return i.hooks??(i.hooks=[]),i.hooks[o]=a,n({hook:a,isInit:!r,update:()=>zn(i),queueEffect:s,vNode:i,index:o})}catch(a){throw a}}function dl(e){const t=Re.current;if(!t)throw new Ze(\`Hook "\${e}" must be used at the top level of a component or inside another composite hook.\`);return t}function Ni(e){e.cleanup&&(e.cleanup(),e.cleanup=void 0)}function He(e,t){return e===void 0||t===void 0||e.length!==t.length||e.length>0&&t.some((n,i)=>!Object.is(n,e[i]))}const Es={stack:new Array,current:function(){return this.stack[this.stack.length-1]}},Ye=new Map;var pl;class W{constructor(t,n){this[pl]=!0,this.$id=Ku(),this.$value=t,n&&(this.displayName=n),this.$subs=new Set}get value(){return this.onBeforeRead?.(),W.entangle(this),this.$value}set value(t){Object.is(this.$value,t)||(this.$prevValue=this.$value,this.$value=t,this.notify())}peek(){return this.onBeforeRead?.(),this.$value}sneak(t){this.$prevValue=this.$value,this.$value=t}toString(){return this.onBeforeRead?.(),W.entangle(this),\`\${this.$value}\`}subscribe(t){return this.$subs.add(t),()=>this.$subs.delete(t)}notify(t){this.$subs.forEach(n=>{if(!(t&&!t(n)))return n(this.$value,this.$prevValue)})}static isSignal(t){return typeof t=="object"&&!!t&&Ha in t}static subscribers(t){return t.$subs}static makeReadonly(t){const n=Object.getOwnPropertyDescriptor(t,"value");return n&&!n.writable?t:Object.defineProperty(t,"value",{get:function(){return W.entangle(this),this.$value},configurable:!0})}static makeWritable(t){const n=Object.getOwnPropertyDescriptor(t,"value");return n&&n.writable?t:Object.defineProperty(t,"value",{get:function(){return W.entangle(this),this.$value},set:function(i){this.$value=i,this.notify()},configurable:!0})}static entangle(t){const n=Re.current,i=Es.current();if(i){(!n||n&&yt())&&i.set(t.$id,t);return}if(!n||!yt())return;const s=t.subscribe(()=>zn(n));(n.subs??(n.subs=new Set)).add(s)}static configure(t,n){t.onBeforeRead=n}static dispose(t){t.$isDisposed=!0,t.$subs.clear()}}pl=Ha;const G=(e,t)=>new W(e,t),J=(e,t)=>_t("useSignal",{signal:null},({hook:n,isInit:i,isHMR:s})=>(i&&(n.cleanup=()=>W.dispose(n.signal),n.signal=new W(e,t)),n.signal));function tn(e,t=!1){return W.isSignal(e)?t?e.value:e.peek():e}const Xu=()=>{Ye.forEach(e=>e()),Ye.clear()};function vi(...e){return e.filter(Boolean).join(" ")}const Jo=new Set(["children","ref","key","innerHTML"]),Cs={isInternalProp:e=>Jo.has(e),isEvent:e=>e.startsWith("on"),isStringRenderableProperty:e=>!Jo.has(e)&&!Cs.isEvent(e)};function qu(e){switch(e){case"className":return"class";case"htmlFor":return"for";case"tabIndex":case"formAction":case"formMethod":case"formEncType":case"contentEditable":case"spellCheck":case"allowFullScreen":case"autoPlay":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"noModule":case"noValidate":case"popoverTarget":case"popoverTargetAction":case"playsInline":case"readOnly":case"itemscope":case"rowSpan":case"crossOrigin":return e.toLowerCase();default:return e.indexOf("-")>-1?e:e.startsWith("aria")?"aria-"+e.substring(4).toLowerCase():uu.get(e)||e}}const Gu="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-";function Ku(e=10,t=Gu){let n="";for(let i=0;i<e;i++)n+=t[Math.random()*t.length|0];return n}const tr=Object.freeze(()=>{});function Os(e,t){if(typeof e=="function"){e(t);return}if(W.isSignal(e)){e.value=t;return}e.current=t}function yt(){return Ht.current==="dom"||Ht.current==="hydrate"}function Zu(e){return(e.flags&Ri)!==0}function io(e){return typeof e=="object"&&e!==null&&"type"in e}function so(e){return typeof e=="string"&&e!==""||typeof e=="number"||typeof e=="bigint"}function Qu(e){return e===zt||e===Li||e===to}function Ju(e){return e.type===zt}function th(e){return typeof e.type=="function"&&"displayName"in e.type&&e.type.displayName==="Kiru.lazy"}function eh(e){return typeof e.type=="function"&&tl(e.type)}function _i(e){const{props:{children:t,...n},key:i,memoizedProps:s,index:o}=e;e.prev={props:n,key:i,memoizedProps:s,index:o},e.flags&=-15}function Fi(e,t){t(e);let n=e.child;for(;n;)t(n),n.child&&Fi(n,t),n=n.sibling}function nh(e,t){let n=e.parent;for(;n;){if(t(n))return n;n=n.parent}return null}function ih(e){return nh(e,t=>t.type===to)}function gl(e){return e===void 0?null:typeof e=="string"||typeof e=="number"?e:null}function sh(){const e=new Set,t=new WeakMap,n=new Map;function i(a,l,c){n.get(a)?.forEach(u=>u(l,c))}function s(a,l){n.has(a)||n.set(a,new Set),n.get(a).add(l)}function o(a,l){n.get(a)?.delete(l)}const r={get apps(){return Array.from(e)},emit:i,on:s,off:o};return s("mount",(a,l)=>{e.add(a),l&&typeof l=="function"&&t.set(a,{requestUpdate:l})}),s("unmount",a=>{e.delete(a),t.delete(a)}),r}function oh(e){const{id:t,subs:n,fn:i,deps:s=[],onDepChanged:o}=e;let r;Ye.delete(t);const a=!!Re.current&&!yt();a||(r=new Map,Es.stack.push(r));const l=i(...s.map(c=>c.value));if(!a){for(const[u,f]of n)r.has(u)||(f(),n.delete(u));const c=()=>{Ye.size||queueMicrotask(Xu),Ye.set(t,o)};for(const[u,f]of r){if(n.has(u))continue;const d=f.subscribe(c);n.set(u,d)}Es.stack.pop()}return l}class Ee extends W{constructor(t,n){super(void 0,n),this.$getter=t,this.$unsubs=new Map,this.$isDirty=!0,W.configure(this,()=>{this.$isDirty&&Ee.run(this)})}get value(){return super.value}set value(t){}subscribe(t){return this.$isDirty&&Ee.run(this),super.subscribe(t)}static dispose(t){Ee.stop(t),W.dispose(t)}static updateGetter(t,n){const i=t;i.$getter=n,i.$isDirty=!0,Ee.run(i),!Object.is(i.$value,i.$prevValue)&&i.notify()}static stop(t){const{$id:n,$unsubs:i}=t;Ye.delete(n),i.forEach(s=>s()),i.clear(),t.$isDirty=!0}static run(t){const n=t,{$id:i,$getter:s,$unsubs:o}=n,r=oh({id:i,subs:o,fn:()=>s(n.$value),onDepChanged:()=>{n.$isDirty=!0,t.$subs.size&&(Ee.run(n),!Object.is(n.$value,n.$prevValue)&&n.notify())}});n.sneak(r),n.$isDirty=!1}}function Hn(e,t){return new Ee(e,t)}let rh=0;function ah(e,t,n){const i=lh(t),s=rh++,o={id:s,name:\`App-\${s}\`,rootNode:i,render:r,unmount:a};function r(l){i.props.children=l,Zo(i)}function a(){i.props.children=null,Zo(i),window.__kiru.emit("unmount",o)}return r(e),window.__kiru.emit("mount",o,zn),o}function lh(e){const t=el(e.nodeName.toLowerCase());return t.flags|=le,t.dom=e,t}function ge(e){return yt()?_t("useState",{state:void 0,dispatch:tr},({hook:t,isInit:n,update:i,isHMR:s})=>(n&&(t.state=typeof e=="function"?e():e,t.dispatch=o=>{const r=typeof o=="function"?o(t.state):o;Object.is(t.state,r)||(t.state=r,i())}),[t.state,t.dispatch])):[typeof e=="function"?e():e,tr]}function ch(e){const t={[su]:!0,Provider:({value:n,children:i})=>{const[s]=ge(()=>new Set);return g(Li,{value:n,ctx:t,dependents:s},typeof i=="function"?i(n):i)},default:()=>e,set displayName(n){this.Provider.displayName=n},get displayName(){return this.Provider.displayName||"Anonymous Context"}};return t}function Xe(e,t){return yt()?_t("useCallback",{callback:e,deps:t},({hook:n,isHMR:i})=>(He(t,n.deps)&&(n.deps=t,n.callback=e),n.callback)):e}function uh(e,t=!0){return _t("useContext",{context:e,warnIfNotFound:t},hh)}const hh=({hook:e,isInit:t,vNode:n})=>{if(t){let i=n.parent;for(;i;){if(i.type===Li){const s=i,{ctx:o,value:r,dependents:a}=s.props;if(o===e.context)return a.add(n),e.cleanup=()=>a.delete(n),e.provider=s,r}i=i.parent}}return e.provider?e.provider.props.value:e.context.default()};function rt(e,t){if(yt())return _t("useEffect",{deps:t},({hook:n,isInit:i,isHMR:s,queueEffect:o})=>{(i||He(t,n.deps))&&(n.deps=t,Ni(n),o(()=>{const r=e();typeof r=="function"&&(n.cleanup=r)}))})}function ml(){return _t("useId",fh,dh)}const fh=()=>({id:"",idx:0}),dh=({hook:e,isInit:t,vNode:n})=>{if(t||n.index!==e.idx){e.idx=n.index;const i=[];let s=n;for(;s;)i.push(s.index),i.push(s.depth),s=s.parent;e.id=\`k:\${BigInt(i.join("")).toString(36)}\`}return e.id};function oo(e,t){if(yt())return _t("useLayoutEffect",{deps:t},({hook:n,isInit:i,isHMR:s,queueEffect:o})=>{(i||He(t,n.deps))&&(n.deps=t,Ni(n),o(()=>{const r=e();typeof r=="function"&&(n.cleanup=r)},{immediate:!0}))})}function wi(e,t){return yt()?_t("useMemo",{deps:t,value:void 0},({hook:n,isInit:i,isHMR:s})=>((i||He(t,n.deps))&&(n.deps=t,n.value=e()),n.value)):e()}function er(e){return e instanceof Promise&&"id"in e&&"state"in e}function nr(e,t,n={},i=null){const o=Object.assign(t,{id:e,state:"pending"},n);return o.then(r=>{o.state="fulfilled",o.value=r},r=>{o.state="rejected",o.error=r instanceof Error?r:new Error(String(r))}).finally(i),o}async function ph(e,t){const n=window[gn]??(window[gn]=new Map),i=n.get(e);if(i){n.delete(e);const{data:s,error:o}=i;return o?Promise.reject(o):Promise.resolve(s)}return new Promise((s,o)=>{const r=a=>{const{detail:l}=a;if(l.id===e){n.delete(e),window.removeEventListener(gn,r);const{data:c,error:u}=l;if(u)return o(u);s(c)}};window.addEventListener(gn,r),t?.addEventListener("abort",()=>{window.removeEventListener(gn,r),o("aborted")})})}const ir=new WeakMap;function gh(e,t){const n=ml(),i=J(!0);return _t("usePromise",{},({hook:s,isInit:o,vNode:r,update:a})=>{if(o){s.epoch=0,s.cleanup=()=>s.abortController?.abort("aborted");const l=ir.get(r)??0;ir.set(r,l+1);const c=s.promiseId=\`\${n}:data:\${l}\`,u=s.refresh=f=>{if(typeof f!="function")return delete s.deps,a();s.cleanup();const d=(s.abortController=new AbortController).signal,m=Promise.try(f,d).then(()=>e(d)),y=++s.epoch;s.promise=nr(c,m,{isPending:i,refresh:u},()=>y===s.epoch&&(i.value=!1)),i.value=!0,a()}}if(o||He(t,s.deps)){i.value=!0,s.deps=t,s.cleanup();const l=(s.abortController=new AbortController).signal,{promiseId:c,refresh:u}=s;let f;Ht.current==="string"?f=Promise.resolve():Ht.current==="hydrate"&&hu.current==="dynamic"?f=ph(c,l):f=e(l);const d=++s.epoch;s.promise=nr(c,f,{isPending:i,refresh:u},()=>d===s.epoch&&(i.value=!1))}return s.promise})}function Ne(e){return yt()?_t("useRef",{ref:{current:e}},({hook:t,isInit:n,isHMR:i})=>t.ref):{current:e}}const sr=Symbol("no value");function Ps(e){const{from:t,children:n,fallback:i,mode:s}=e,o=Ne(sr),r=new Set;let a;if(er(t))r.add(t),a=t.value;else if(W.isSignal(t))a=t.value;else{const l={};for(const c in t){const u=t[c];er(u)&&r.add(u),l[c]=u.value}a=l}if(r.size===0)return n(a);if(!yt())throw{[ou]:{fallback:i,data:Array.from(r)}};for(const l of r){if(l.state==="rejected")throw l.error;if(l.state==="pending"){const c=Re.current;return Promise.allSettled(r).then(()=>zn(c)),s!=="fallback"&&o.current!==sr?n(o.current,!0):i}}return o.current=a,n(a,!1)}"window"in globalThis&&(window.__KIRU_LAZY_CACHE??(window.__KIRU_LAZY_CACHE=new Map));"window"in globalThis&&!globalThis.__KIRU_DEVTOOLS__&&(window.__kiru??(window.__kiru=sh()));function mh(e,t){if(!e)throw new Error(t)}function bh(...e){return e.filter(Boolean).join(" ")}function ro(e,t,n){let i=e;for(let s=0;s<t.length;s++){const o=t[s];s===t.length-1?i[o]=n:i=i[o]}}function ao(e){return e.type.displayName??(e.type.name||"Anonymous Function")}const xh=e=>e[ru]??null;function An(e){return e.name==="kiru.devtools"}function bl(e){return Array.from(e.entries())}function yh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e},g("rect",{width:"20",height:"16",x:"2",y:"4",rx:"2"}),g("path",{d:"M12 9v11"}),g("path",{d:"M2 9h13a2 2 0 0 1 2 2v9"}))}function ce(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"m9 18 6-6-6-6"}))}function vh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),g("circle",{cx:"12",cy:"12",r:"3"}))}function _h(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6"}),g("path",{d:"m21 3-9 9"}),g("path",{d:"M15 3h6v6"}))}function wh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z"}),g("path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z"}),g("path",{d:"M3 5a2 2 0 0 0 2 2h3"}),g("path",{d:"M3 3v13a2 2 0 0 0 2 2h3"}))}function Sh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"m12 14 4-4"}),g("path",{d:"M3.34 19a10 10 0 1 1 17.32 0"}))}function kh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("circle",{cx:"12",cy:"12",r:"10"}),g("path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20"}),g("path",{d:"M2 12h20"}))}function xl(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"}),g("path",{d:"M21 3v5h-5"}),g("path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"}),g("path",{d:"M8 16H3v5"}))}function Th(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...e},g("path",{d:"M22 8.35V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8.35A2 2 0 0 1 3.26 6.5l8-3.2a2 2 0 0 1 1.48 0l8 3.2A2 2 0 0 1 22 8.35Z"}),g("path",{d:"M6 18h12"}),g("path",{d:"M6 14h12"}),g("rect",{width:"12",height:"12",x:"6",y:"10"}))}function Mh(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),g("path",{d:"M8 12h8"}),g("path",{d:"m12 16 4-4-4-4"}))}function lo(e){return g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",...e},g("path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"}),g("path",{d:"M12 9v4"}),g("path",{d:"M12 17h.01"}))}function yl({title:e,children:t,className:n,disabled:i,...s}){const[o,r]=ge(!0);rt(()=>{!o&&i&&r(!0)},[i]);const a=Xe(l=>{l.preventDefault(),l.stopImmediatePropagation(),r(c=>!c)},[]);return g("div",{className:"flex flex-col"},g("button",{onclick:a,disabled:i,className:\`\${i?"opacity-50 cursor-default":"cursor-pointer"}\`},g("span",{className:"flex items-center gap-2 font-medium"},g(ce,{className:\`transition \${o?"":"rotate-90"}\`}),e)),o?null:g("div",{className:\`p-2 \${n||""}\`,...s},t))}const co={arrayChunkSize:10,objectKeysChunkSize:100};function vl(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const i in n)if(typeof t[i]!=typeof e[i]||typeof e[i]=="object"&&!vl(e[i],t[i]))return!1;return!0}function _l(e,t,n){for(const i in t)typeof e[i]>"u"&&(e[i]=structuredClone(t[i]));for(const i in e)typeof e[i]=="object"?_l(e[i],t[i],n):n(e,i,e[i])}let wl={...co};const or=localStorage.getItem("kiru.devtools.userSettings");if(or)try{const e=JSON.parse(or);vl(co,e)&&(wl=e)}catch(e){console.error("kiru.devtools.userSettings error",e)}const Sl=ch({userSettings:null,saveUserSettings:()=>{}}),zi=()=>uh(Sl);function Eh({children:e}){const[t,n]=ge(wl),i=s=>{localStorage.setItem("kiru.devtools.userSettings",JSON.stringify(s)),n(s)};return g(Sl.Provider,{value:{userSettings:t,saveUserSettings:i}},e)}function Ch(){const{userSettings:e,saveUserSettings:t}=zi();return g("div",{className:"rounded bg-neutral-400 bg-opacity-5 border border-white border-opacity-10 overflow-hidden"},g(me,{border:!1,data:e,onChange:(n,i)=>{const s={...e};ro(s,n,i),_l(s,co,(o,r,a)=>{o[r]=a<1?1:a}),t(s)},mutable:!0,objectRefAcc:[]}))}const Oh=Object.freeze(()=>{});function me({data:e,onChange:t,mutable:n,objectRefAcc:i,keys:s=[],className:o,border:r=!0}){const{userSettings:{objectKeysChunkSize:a}}=zi(),[l,c]=ge(0),u=wi(()=>Object.keys(e).slice(0,(l+1)*a),[l,a,e]),f=()=>{u.forEach(m=>{typeof e[m]=="object"&&i.splice(i.indexOf(e[m]),1)}),c(l+1)},d=u.length<Object.keys(e).length;return g(Tt,null,g("div",{className:bh("flex flex-col items-start w-full",r&&"border border-neutral-700",tn(o))},u.map(m=>{const y=s.concat(m),x=y.join(".");return g("div",{key:x,"data-key":x,className:"flex flex-col items-start w-full gap-2 pl-2 py-1 pr-1 border-b border-neutral-700 last:border-b-0"},g(uo,{value:e[m],onChange:t,keys:y,path:x,label:m,mutable:n,objectRefAcc:i}))})),d&&g("button",{onclick:f,title:"Show more",className:"p-1 border font-bold border-neutral-700 hover:bg-neutral-700"},g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1rem",height:"1rem",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},g("circle",{cx:"12",cy:"12",r:"1"}),g("circle",{cx:"19",cy:"12",r:"1"}),g("circle",{cx:"5",cy:"12",r:"1"}))))}function Si(e,t){Array.isArray(e)?(t(e),e.forEach(n=>Si(n,t))):typeof e=="object"&&e!==null&&(t(e),Object.values(e).forEach(n=>Si(n,t)))}function uo({value:e,onChange:t,keys:n,path:i,mutable:s,objectRefAcc:o,label:r}){const{userSettings:{arrayChunkSize:a}}=zi(),[l,c]=ge(!0),u=r!==void 0&&g("label",{htmlFor:i,className:"text-xs truncate",title:i,children:r});if(e===null)return g(mt,null,u,g(Qt,null,"null"));if(e===void 0)return g(mt,null,u,g(Qt,null,"undefined"));const f=window.opener?window.opener.Node:Node;if(e instanceof f)return g(mt,null,u,g(Qt,null,"<",g("span",{style:{color:"#f0a05e"}},e.nodeName),"/>"));const d=window.opener?window.opener.Error:Error;if(e instanceof d)return g(mt,null,u,"cause"in e&&e.cause?g(Qt,null,e.message," (",String(e.cause),")"):g(Qt,null,e.message));const m=y=>t(n,y);switch(typeof e){case"string":return g(mt,null,u,g(ts,{disabled:!s,id:i,type:"text",value:e,onchange:y=>m(y.target.value)}));case"number":return g(mt,null,u,g(ts,{disabled:!s,id:i,type:"number",value:e,placeholder:"NaN",onchange:y=>m(Number(y.target.value))}));case"bigint":return g(mt,null,u,g(ts,{disabled:!s,id:i,type:"number",value:e.toString(),onchange:y=>m(BigInt(y.target.value))}));case"boolean":return g(mt,null,u,g("input",{disabled:!s,id:i,type:"checkbox",checked:e,onchange:y=>m(y.target.checked),className:"accent-red-500"}));case"function":return g(mt,null,u,g(Qt,null,\`\u0192 \${e.name||"anonymous"}()\`));default:return Array.isArray(e)?g(mt,null,g("button",{className:"text-xs flex items-center gap-1 cursor-pointer w-full",title:i,onclick:()=>{Si(e,y=>o.splice(o.indexOf(y),1)),c(y=>!y)}},r,g(ce,{width:10,height:10,className:\`transition \${l?"":"rotate-90"}\`})),l?g(Qt,null,"Array(",e.length,")"):e.length>a?g(Ph,{array:e,objectRefAcc:o}):g("div",{className:"flex flex-col items-start gap-1 w-full"},e.map((y,x)=>g(uo,{value:y,onChange:t,keys:[...n,x.toString()],path:i.concat(".",x.toString()),label:x.toString(),mutable:s,objectRefAcc:o})))):o.includes(e)?g(mt,null,u,g(Qt,null,"Object(circular reference)")):(o.push(e),g(mt,null,g("button",{className:"text-xs flex items-center gap-1 cursor-pointer w-full",title:i,onclick:()=>{Si(e,y=>o.splice(o.indexOf(y),1)),c(y=>!y)}},r,g(ce,{width:10,height:10,className:\`transition \${l?"":"rotate-90"}\`})),l?null:g(me,{data:e,onChange:t,keys:n,mutable:s,objectRefAcc:o})))}}function mt({children:e}){return g("div",{className:"flex flex-col items-start gap-1 w-full"},e)}function ts(e){return g("input",{className:"flex-grow text-xs px-2 py-1 text-neutral-300 w-full",...e})}function Qt({children:e}){return g("small",{className:"text-neutral-300"},g("i",null,e))}function Ph({array:e,objectRefAcc:t}){const{userSettings:{arrayChunkSize:n}}=zi(),i=e.length,s=Math.ceil(i/n);return g("div",{className:"flex flex-col items-start gap-1 w-full"},Array.from({length:s}).map((o,r)=>g(Dh,{array:e,range:{start:r*n,end:(r+1)*n},objectRefAcc:t})))}function Dh({array:e,range:t,objectRefAcc:n}){const[i,s]=ge(!0);let o;return i?o=void 0:o=e.slice(t.start,t.end),g("div",{className:"flex flex-col items-start gap-1 w-full"},g("button",{className:"text-xs flex items-center gap-1 cursor-pointer w-full",onclick:()=>{n.splice(n.indexOf(e),1),s(r=>!r)}},"[",t.start,"..",(t.end<e.length?t.end:e.length)-1,"]",g(ce,{width:10,height:10,className:\`transition \${i?"":"rotate-90"}\`})),o&&g("div",{className:"flex flex-col items-start gap-1 w-full"},o.map((r,a)=>g(uo,{value:r,onChange:Oh,label:(t.start+a).toString(),keys:[a.toString()],path:a.toString(),mutable:!1,objectRefAcc:n}))))}const Ah="kiru-devtools";"window"in globalThis&&(window.__devtoolsSelection??=null,window.__devtoolsNodeUpdatePtr??=null);class Ih extends BroadcastChannel{send(t){super.postMessage(t)}removeEventListener(t){return super.removeEventListener("message",t)}addEventListener(t){return super.addEventListener("message",t)}}const Fe=new Ih(Ah);function Hi({fn:e,onclick:t}){const n=wi(()=>xh(e),[e]);return n?g("a",{className:"flex items-center gap-1 text-[10px] opacity-50 hover:opacity-100 transition-opacity",href:n,onclick:i=>{i.preventDefault(),Fe.send({type:"open-editor",fileLink:n}),t?.(i)},title:"Open in editor"},"Open in editor",g(_h,{width:"0.65rem",height:"0.65rem"})):null}function Lh({selectedApp:e,selectedNode:t,setSelectedNode:n,kiruGlobal:i}){const s=pe();rt(()=>{const l=c=>{c===e&&(Zu(t)?n(null):s())};return i?.on("update",l),()=>i?.off("update",l)},[]);const o=()=>{const l=window.opener;if(!t||!l){console.error("invalid refresh state",{w:l,selectedNode:t});return}l.__devtoolsNodeUpdatePtr=t,Fe.send({type:"update-node"}),console.debug("[kiru]: sent refresh message",t)},r={...t.props};delete r.children;const a=Fh(t);return g("div",{className:"flex-grow p-2 sticky top-0"},g("h2",{className:"flex justify-between items-center font-bold mb-2 pb-2 border-b-2 border-neutral-800"},g("div",{className:"flex gap-2 items-center"},"<"+ao(t)+">",g(Hi,{fn:t.type})),g("button",{onclick:o},g(xl,{className:"w-5 h-5"}))),g(yl,{title:"props",disabled:Object.keys(r).length===0},g(me,{data:r,onChange:()=>{},mutable:!1,objectRefAcc:[]})),g(kl,{node:a,selectedApp:e}))}function Rh(e){return e.name==="devtools:useHookDebugGroup"}function Nh(e){return Ds in e}const Ds=Symbol.for("devtools.hookGroup");function Fh(e){const t={parent:null,name:"hooks",children:[],[Ds]:!0};if(e.hooks?.length){let n=t;for(let i=0;i<e.hooks.length;i++){const s=e.hooks[i];if(Rh(s)){switch(s.action){case"start":const o={parent:n,name:s.displayName,children:[],[Ds]:!0};n.children.push(o),n=o;break;case"end":if(n.name!==s.displayName||n.parent===null)throw new Error("useHookDebugGroup:end called with no start");n=n.parent;break}continue}n.children.push(s)}}return t}function kl({node:e,selectedApp:t,depth:n=0}){if(Nh(e))return g(yl,{title:e.name,className:"bg-[#ffffff04] border border-[#fff1] flex flex-col gap-2 pl-6",disabled:e.children.length===0},e.children.map(u=>g(kl,{node:u,selectedApp:t,depth:n+1})));const{name:i,dev:s,cleanup:o,...r}=e,a=s?.devtools,l=typeof a?.get=="function"?a.get():r;return g("div",null,g("i",{className:"text-neutral-300 text-sm"},i||"anonymous hook"),g("div",{className:"p-2"},g(me,{data:l,onChange:(u,f)=>{if(!t||!a?.set||!a?.get)return;const d=a.get();ro(d,u,f),a.set(d)},mutable:!!a?.set,objectRefAcc:[]})))}const Ae=(e,t,n={})=>{rt(()=>{let i=window;const s=n?.ref?.();return s?i=s:n.ref&&console.warn("useEventListener ref failed, using window"),i.addEventListener(e,t,n),()=>{i.removeEventListener(e,t,n)}},[t])},zh=()=>{const e=J({x:0,y:0}),t=J({x:0,y:0}),n=J({x:0,y:0});return Ae("mousemove",i=>{e.value={x:i.x,y:i.y},t.value={x:i.movementX,y:i.movementY},n.value={x:i.clientX,y:i.clientY}}),{mouse:e,delta:t,client:n}},Zn="window"in globalThis&&"ResizeObserver"in globalThis.window,Hh=(e,t,n=void 0)=>yt()?Zn?_t("useResizeObserver",{resizeObserver:null,deps:[e.current]},({isInit:i,hook:s,queueEffect:o})=>(i&&(s.resizeObserver=new ResizeObserver(t),s.cleanup=()=>{s.resizeObserver?.disconnect?.(),s.resizeObserver=null}),o(()=>{He([e.current],s.deps)&&(s.deps=[e.current],s.resizeObserver?.disconnect?.(),e.current&&s.resizeObserver?.observe(e.current,n))}),{isSupported:Zn,start:()=>{s.resizeObserver==null&&(s.resizeObserver=new ResizeObserver(t),e.current&&s.resizeObserver.observe(e.current,n),s.cleanup=()=>{s.resizeObserver?.disconnect?.(),s.resizeObserver=null})},stop:()=>{Ni(s)}})):{isSupported:Zn,start:()=>{},stop:()=>{}}:{isSupported:Zn,start:()=>{},stop:()=>{}},Qn="window"in globalThis&&"MutationObserver"in globalThis.window,Vh=(e,t,n=void 0)=>yt()?Qn?_t("useMutationObserver",{mutationObserver:null,deps:[e.current]},({isInit:i,hook:s,queueEffect:o})=>(i?(o(()=>{s.deps=[e.current],s.mutationObserver=new MutationObserver(t),e.current&&s.mutationObserver.observe(e.current,n)}),s.cleanup=()=>{s.mutationObserver?.disconnect?.(),s.mutationObserver=null}):He([e.current],s.deps)&&(s.deps=[e.current],s.mutationObserver?.disconnect?.(),e.current&&s.mutationObserver?.observe(e.current,n)),{isSupported:Qn,start:()=>{s.mutationObserver==null&&(s.mutationObserver=new MutationObserver(t),e.current&&s.mutationObserver.observe(e.current,n),s.cleanup=()=>{s.mutationObserver?.disconnect?.(),s.mutationObserver=null})},stop:()=>{Ni(s)}})):{isSupported:Qn,start:()=>{},stop:()=>{}}:{isSupported:Qn,start:()=>{},stop:()=>{}},Bh=(e,t={windowScroll:!0,windowResize:!0})=>{const n=t?.windowScroll??!0,i=t?.windowResize??!0,s=t.immediate??!0,o=J(0),r=J(0),a=J(0),l=J(0),c=J(0),u=J(0),f=J(0),d=J(0),m=()=>{const y=e.current;if(!y){o.value=0,r.value=0,a.value=0,l.value=0,c.value=0,u.value=0,f.value=0,d.value=0;return}const x=y.getBoundingClientRect();o.value=x.width,r.value=x.height,a.value=x.top,l.value=x.right,c.value=x.bottom,u.value=x.left,f.value=x.x,d.value=x.y};return Hh(e,m),Vh(e,m,{attributeFilter:["style","class"]}),Ae("scroll",()=>{n&&m()},{capture:!0,passive:!0}),Ae("resize",()=>{i&&m()},{passive:!0}),oo(()=>{s&&m()},[]),{width:o,height:r,top:a,right:l,bottom:c,left:u,x:f,y:d,update:m}};function Wh(e){return typeof e=="function"?e:typeof e=="string"?t=>t.key===e:Array.isArray(e)?t=>e.includes(t.key):()=>!0}const rr=(e,t,n={})=>{const{ref:i,eventName:s="keydown",passive:o=!1}=n,r=Wh(e);return Ae(s,l=>{l.repeat&&!n.repeat||r(l)&&t(l)},{ref:i,passive:o})};function ho({value:e,className:t,...n}){const i=ml();return g("div",{className:vi("w-full p-2 z-10","bg-[#1d1d1d] border border-white border-opacity-10 rounded",t?.toString()),...n},g("input",{className:vi("px-2 py-1 w-full rounded focus:outline focus:outline-primary","bg-[#212121] border border-white border-opacity-10 rounded"),placeholder:"Filter...",type:"text",autocomplete:i+Math.random().toString(36).substring(2,15),name:"filter-search",id:"filter-search","bind:value":e}))}let U;"window"in globalThis&&window.opener&&(U=window.opener.__kiru);const qe=G(!1);Fe.addEventListener(e=>{e.data.type==="set-inspect-enabled"&&(qe.value=e.data.value)});const Tl=(U?.apps??[]).filter(e=>!An(e)),se=G(Tl);G(null);const Lt=G(Tl[0]??null),oe=G(null);U?.on("mount",e=>{An(e)||(se.value=[...se.peek(),e],Lt.peek()===null&&(Lt.value=e))});U?.on("unmount",e=>{se.value=se.peek().filter(t=>t!==e),Lt.peek()===e&&(Lt.value=se.peek()[0]??null)});const As=G(new Map),Rt=G(null),fo=G("");function jh(e){return e.type.displayName??(e.type.name||"Anonymous Function")}function $h(e,t){const n=t.toLowerCase();return e.every(i=>n.includes(i))}function Is(e){return typeof e.type=="function"&&!Ju(e)&&!th(e)&&!eh(e)}function Uh(e){let t=[e];for(;t.length;){const n=t.pop();if(Is(n))return!0;n.child&&t.push(n.child),n.sibling&&t.push(n.sibling)}return!1}const Yh=(e,t)=>{const n=[t.parent];for(;n.length;){const i=n.pop();if(e===i)return!0;i?.parent&&n.push(i.parent)}return!1};function Ls(e,t){if(!e)return null;const n=t(e),i=Ls(e.sibling,t),s=Ls(e.child,t);return n?{ref:e,sibling:i??null,child:s??null}:i||s||null}function ki({node:e,traverseSiblings:t=!0}){const[n,i]=ge(!0),o=oe.value===e,r=wi(()=>crypto.randomUUID(),[]),a=wi(()=>Rt.value==null?null:Yh(e,Rt.value),[Rt.value,e]);rt(()=>{a&&i(!1)},[a]),rt(()=>{if(!(!e||!Is(e)))return As.peek().set(r,{vNode:e,setCollapsed:i}),()=>{As.peek().delete(r)}});const l=fo.value;if(!e)return null;if(!Is(e)||l.length>0&&!$h(l.toLowerCase().split(" "),e.type.name))return g(Tt,null,e.child&&g(ki,{node:e.child}),t&&g(ar,{node:e}));const c=e.child&&Uh(e.child);return g(Tt,null,g("div",{className:"pl-4 mb-1"},g("h2",{onclick:()=>{Rt.value=null,oe.value=o?null:e},className:\`flex gap-2 items-center cursor-pointer mb-1 scroll-m-12 \${o?"font-medium bg-primary selected-vnode":""}\`,"data-id":r},c&&g(ce,{className:\`cursor-pointer transition \${n?"":"rotate-90"}\`,onclick:u=>{u.preventDefault(),u.stopImmediatePropagation(),Rt.value=null,i(f=>!f)}}),g("div",{className:c?"":"ml-6"},g("span",{className:o?"":"text-neutral-400"},"<"),g("span",{className:o?"":"text-primary"},jh(e)),g("span",{className:o?"":"text-neutral-400"},">"))),!n&&e.child||a!=null&&a&&e.child?g(ki,{node:e.child}):null),t&&g(ar,{node:e}))}function ar({node:e}){if(!e)return null;let t=[],n=e.sibling;for(;n;)t.push(n),n=n.sibling;return g(Tt,null,t.map(i=>g(ki,{node:i,traverseSiblings:!1})))}const Xh=()=>{const e=Ne(null),t=r=>{if(!r)return null;const a=r.getAttribute("data-id");if(a!=null)return As.peek().get(a)},n=r=>{if(!r)return;const a=t(r);a!=null&&(r.scrollIntoView({behavior:"smooth"}),oe.value=a.vNode)},i=r=>{if(!r||r===document.body)return null;const a=r.parentElement,l=a?.nextElementSibling?.querySelector("h2[data-id]");return l||i(a)},s=()=>{const r=document.querySelector("h2[data-id]");n(r)},o=()=>{const r=document.querySelectorAll("h2[data-id]"),a=r.item(r.length-1);a&&n(a)};return rr(["ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],r=>{if(Rt.value&&(Rt.value=null),document.activeElement&&document.activeElement instanceof HTMLInputElement&&document.activeElement!=e.current)return;r.preventDefault();const a=document.querySelector(".selected-vnode");if(a===null){r.key==="ArrowDown"?s():r.key==="ArrowUp"&&o();return}if(r.key==="ArrowRight"){const l=t(a);l&&l.setCollapsed(!1);return}else if(r.key==="ArrowLeft"){const l=t(a);l&&l.setCollapsed(!0);return}if(r.key==="ArrowDown"){const l=a?.nextElementSibling?.querySelector("h2[data-id]");if(l)return n(l);const c=a.parentElement?.nextElementSibling?.querySelector("h2[data-id]");if(c)return n(c);const u=i(a);return u?n(u):s()}else if(r.key==="ArrowUp"){const l=a.parentElement?.previousElementSibling;if(l?.matches("h2[data-id]"))return n(l);const c=l?.querySelectorAll("h2[data-id]");return c?.length!=null&&c?.length>=1?n(c?.item?.(c.length-1)):o()}}),rr("l",r=>{r.ctrlKey&&(r.preventDefault(),e.current?.focus({preventScroll:!1}))}),{searchRef:e}},qh=e=>{fo.value=e.target.value,Rt.value&&(Rt.value=null)};function Gh(){const{searchRef:e}=Xh(),t=Lt.value;return g("div",{className:"flex-grow p-2 sticky top-0"},g("div",{className:"flex gap-4 pb-2 border-b-2 border-neutral-800 mb-2 items-center"},g("input",{ref:e,className:"bg-[#171616] px-1 py-2 w-full focus:outline focus:outline-primary",placeholder:"Search for component",type:"text",value:fo,oninput:qh})),t?.rootNode&&g(ki,{node:t.rootNode}))}const Ml=e=>{const{mouse:t}=zh(),n=J(null),i=J(0),s=J(0),o=Ne(null),r=Bh(o),a=Ne(null),[l,c]=Array.isArray(e.children)?e.children:[];return oo(()=>{a.current&&(s.value=a.current.clientWidth/2)},[a.current]),Ae("mouseup",Xe(()=>n.value=null,[])),Ae("mousemove",Xe(u=>{if(n.value==null||a.current==null)return;const f=Math.max(i.value+u.x-n.value.x,250);s.value=Math.min(f,a.current.clientWidth-250)},[])),Ae("resize",Xe(()=>{a.current!=null&&a.current.clientWidth-250<s.value&&(s.value=Math.max(a.current.clientWidth-250,250))},[])),g("div",{onmousemove:u=>{u.x},ref:a,className:"flex-grow grid gap-2 items-start w-full relative",style:{gridTemplateColumns:\`\${s}px 1fr\`}},g("div",{ref:o,className:"firstContainer w-full h-full"},l),r.width.value!=0&&g("div",{className:"w-8 flex justify-center h-full absolute top-0 -translate-x-1/2 cursor-col-resize z-[9999]",style:{left:\`\${r.width}px\`},onmousedown:u=>{u.preventDefault(),n.value={...t.value},i.value=s.value}},g("div",{className:"dividerLine w-[5px] bg-neutral-800 h-full"})),g("div",{className:"secondContainer h-full"},c))},Kh=()=>g("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-square-mouse-pointer"},g("path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"}),g("path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"})),Zh=()=>{qe.value=!qe.value,Fe.send({type:"set-inspect-enabled",value:qe.value})};function Qh(){const e=Lt.value,t=oe.value,n=pe();return rt(()=>{const i=s=>{s===e&&n()};return U?.on("update",i),()=>U?.off("update",i)},[Lt]),rt(()=>{const i=s=>{if(s.data.type!=="select-node")return;mh(window.__devtoolsSelection,"no selection ptr");const{app:o,node:r}=window.__devtoolsSelection;window.__devtoolsSelection=null,Lt.value=o,oe.value=r,Rt.value=r,qe.value=!1};return Fe.addEventListener(i),()=>Fe.removeEventListener(i)},[Lt]),g(Tt,null,g("div",{className:"flex items-center justify-between gap-4 p-2 bg-neutral-400 bg-opacity-5 border border-white border-opacity-10 rounded"},g("div",{className:"flex items-center gap-4"},g("select",{className:"px-2 py-1 bg-neutral-800 text-neutral-100 rounded border border-white border-opacity-10",value:e?.name??"",onchange:i=>Lt.value=se.peek().find(s=>s.name===i.currentTarget.value)??null},g("option",{value:"",disabled:!0},"Select App"),se.value.map(i=>g("option",{key:i.id,value:i.name},i.name))),g("button",{title:"Toggle Component Inspection",onclick:Zh,className:\`p-1 rounded \${qe.value?"bg-neutral-900":""}\`},g(Kh,null)))),g(Ml,null,e&&g(Gh,null),t&&e&&g(Lh,{selectedApp:e,selectedNode:t,setSelectedNode:i=>oe.value=i,kiruGlobal:U})))}const Rs=G({}),Ce=G([]);U?.stores?.subscribe(e=>{Rs.value=e,Ce.value=Ce.value.filter(t=>Object.values(Rs.value).includes(t))});const El=G(""),Jh=Hn(()=>El.value.toLowerCase().split(" ").filter(e=>e.length>0));function tf(e){return Jh.value.every(t=>e.toLowerCase().includes(t))}function ef(){const e=Object.entries(Rs.value);return e.length===0?g("div",{className:"flex flex-col items-center justify-center h-full text-neutral-400"},g(lo,null),g("h2",{className:"text-lg italic"},"No stores detected")):g("div",{className:"flex flex-col gap-2 items-start"},g(ho,{value:El,className:"sticky top-0"}),g("div",{className:"flex flex-col gap-2 w-full"},e.filter(([t])=>tf(t)).map(([t,n])=>g(nf,{key:t,name:t,store:n}))))}function nf({name:e,store:t}){const n=Ce.value.includes(t),i=pe(),{value:s}=Cl(t);oo(()=>{const r=t.subscribe(()=>i());return()=>r()},[]);const o=Xe(()=>{n?Ce.value=Ce.value.filter(r=>r!==t):Ce.value=[...Ce.value,t]},[n]);return g("div",{className:"flex flex-col"},g("button",{onclick:o,className:"flex items-center gap-2 justify-between p-2 border border-white border-opacity-10 cursor-pointer"+(n?" bg-white bg-opacity-5 text-neutral-100 rounded-t":" hover:bg-white hover:bg-opacity-10 text-neutral-400 rounded")},e,g("div",{className:"flex gap-2"},g(Hi,{fn:t,onclick:r=>r.stopPropagation()}),g(ce,{className:"transition-all"+(n?" rotate-90":"")}))),n&&g("div",{className:"flex flex-col gap-2 p-2 border border-white border-opacity-10"},g(me,{data:{value:s},mutable:!0,objectRefAcc:[],onChange:(r,a)=>{const l=structuredClone({value:s});ro(l,r,a),t.setState(l.value)}}),g(sf,{store:t})))}function sf({store:e}){const t=se.value;return t.length===0?null:g(Tt,null,t.map(n=>g(of,{store:e,app:n})))}const lr=Symbol.for("kiru.hmrAccept"),Cl=e=>{if(lr in e)return e[lr].provide().current;throw new Error("Unable to get store subscribers")};function of({store:e,app:t}){const n=pe(),{subscribers:i,nodeStateMap:s}=Cl(e),o=t.rootNode.child;if(rt(()=>{const a=l=>{l===t&&n()};return U?.on("update",a),()=>U?.off("update",a)},[]),!o)return null;const r=Ls(o,a=>i.has(a));return g("div",{className:"flex flex-col gap-2 p-2 rounded-b border border-white border-opacity-10"},g("b",null,t.name),r&&g("ul",{className:"pl-8"},g(Ns,{node:r,nodeStateMap:s})))}function Ns({node:e,nodeStateMap:t}){const[n,i]=ge(!1),o=t.get(e.ref)?.slices??[];return g(Tt,null,g("li",{className:"flex flex-col gap-2"},g("div",{className:"flex flex-col border border-white border-opacity-10 rounded"+(n?" bg-white bg-opacity-5 text-neutral-100":" hover:bg-white hover:bg-opacity-10 text-neutral-400")},g("button",{onclick:()=>i(!n),className:"flex gap-2 p-2 justify-between cursor-pointer"},g("span",null,"<"+ao(e.ref)+" />"),g("div",{className:"flex gap-2 items-center"},g(Hi,{fn:e.ref.type,onclick:r=>r.stopPropagation()}),g(ce,{className:"transition-all"+(n?" rotate-90":"")}))),n&&g("div",{className:"flex flex-col gap-2 p-2 bg-[#1a1a1a]"},o.length===0&&g("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},g("h5",{className:"border-b border-white border-opacity-10"},"No slices")),o.map(r=>g("div",{className:"flex flex-col gap-2"},g("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},g("h5",{className:"border-b border-white border-opacity-10"},"Slice:"),g("pre",{className:"text-neutral-400"},g(me,{data:{value:r.value},mutable:!1,objectRefAcc:[],onChange:()=>{}}))),g("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},g("h5",{className:"border-b border-white border-opacity-10"},"SliceFn:"),g("pre",{className:"text-neutral-400"},r.sliceFn?r.sliceFn.toString():"null")),r.eq&&g("div",{className:"p-2 bg-black bg-opacity-30 text-sm"},g("h5",{className:"border-b border-white border-opacity-10"},"eq:"),g("pre",{className:"text-neutral-400"},r.eq.toString())))))),e.child&&g("ul",{className:"pl-8 flex flex-col gap-2"},g(Ns,{node:e.child,nodeStateMap:t}))),e.sibling&&g(Ns,{node:e.sibling,nodeStateMap:t}))}/*!
9126
9279
  * @kurkle/color v0.3.4
9127
9280
  * https://github.com/kurkle/color#readme
9128
9281
  * (c) 2024 Jukka Kurkela
9129
9282
  * Released under the MIT License
9130
- */function Bn(e){return e+.5|0}const ee=(e,t,n)=>Math.max(Math.min(e,n),t);function wn(e){return ee(Bn(e*2.55),0,255)}function re(e){return ee(Bn(e*255),0,255)}function Yt(e){return ee(Bn(e/2.55)/100,0,1)}function lr(e){return ee(Bn(e*100),0,100)}const bt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Fs=[..."0123456789ABCDEF"],of=e=>Fs[e&15],rf=e=>Fs[(e&240)>>4]+Fs[e&15],ti=e=>(e&240)>>4===(e&15),af=e=>ti(e.r)&&ti(e.g)&&ti(e.b)&&ti(e.a);function lf(e){var t=e.length,n;return e[0]==="#"&&(t===4||t===5?n={r:255&bt[e[1]]*17,g:255&bt[e[2]]*17,b:255&bt[e[3]]*17,a:t===5?bt[e[4]]*17:255}:(t===7||t===9)&&(n={r:bt[e[1]]<<4|bt[e[2]],g:bt[e[3]]<<4|bt[e[4]],b:bt[e[5]]<<4|bt[e[6]],a:t===9?bt[e[7]]<<4|bt[e[8]]:255})),n}const cf=(e,t)=>e<255?t(e):"";function uf(e){var t=af(e)?of:rf;return e?"#"+t(e.r)+t(e.g)+t(e.b)+cf(e.a,t):void 0}const hf=/^(hsla?|hwb|hsv)\\(\\s*([-+.e\\d]+)(?:deg)?[\\s,]+([-+.e\\d]+)%[\\s,]+([-+.e\\d]+)%(?:[\\s,]+([-+.e\\d]+)(%)?)?\\s*\\)$/;function El(e,t,n){const i=t*Math.min(n,1-n),s=(o,r=(o+e/30)%12)=>n-i*Math.max(Math.min(r-3,9-r,1),-1);return[s(0),s(8),s(4)]}function ff(e,t,n){const i=(s,o=(s+e/60)%6)=>n-n*t*Math.max(Math.min(o,4-o,1),0);return[i(5),i(3),i(1)]}function df(e,t,n){const i=El(e,1,.5);let s;for(t+n>1&&(s=1/(t+n),t*=s,n*=s),s=0;s<3;s++)i[s]*=1-t-n,i[s]+=t;return i}function pf(e,t,n,i,s){return e===s?(t-n)/i+(t<n?6:0):t===s?(n-e)/i+2:(e-t)/i+4}function po(e){const n=e.r/255,i=e.g/255,s=e.b/255,o=Math.max(n,i,s),r=Math.min(n,i,s),a=(o+r)/2;let l,c,u;return o!==r&&(u=o-r,c=a>.5?u/(2-o-r):u/(o+r),l=pf(n,i,s,u,o),l=l*60+.5),[l|0,c||0,a]}function go(e,t,n,i){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,i)).map(re)}function mo(e,t,n){return go(El,e,t,n)}function gf(e,t,n){return go(df,e,t,n)}function mf(e,t,n){return go(ff,e,t,n)}function Cl(e){return(e%360+360)%360}function bf(e){const t=hf.exec(e);let n=255,i;if(!t)return;t[5]!==i&&(n=t[6]?wn(+t[5]):re(+t[5]));const s=Cl(+t[2]),o=+t[3]/100,r=+t[4]/100;return t[1]==="hwb"?i=gf(s,o,r):t[1]==="hsv"?i=mf(s,o,r):i=mo(s,o,r),{r:i[0],g:i[1],b:i[2],a:n}}function xf(e,t){var n=po(e);n[0]=Cl(n[0]+t),n=mo(n),e.r=n[0],e.g=n[1],e.b=n[2]}function yf(e){if(!e)return;const t=po(e),n=t[0],i=lr(t[1]),s=lr(t[2]);return e.a<255?\`hsla(\${n}, \${i}%, \${s}%, \${Yt(e.a)})\`:\`hsl(\${n}, \${i}%, \${s}%)\`}const cr={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},ur={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function vf(){const e={},t=Object.keys(ur),n=Object.keys(cr);let i,s,o,r,a;for(i=0;i<t.length;i++){for(r=a=t[i],s=0;s<n.length;s++)o=n[s],a=a.replace(o,cr[o]);o=parseInt(ur[r],16),e[a]=[o>>16&255,o>>8&255,o&255]}return e}let ei;function _f(e){ei||(ei=vf(),ei.transparent=[0,0,0,0]);const t=ei[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}const wf=/^rgba?\\(\\s*([-+.\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?(?:[\\s,/]+([-+.e\\d]+)(%)?)?\\s*\\)$/;function Sf(e){const t=wf.exec(e);let n=255,i,s,o;if(t){if(t[7]!==i){const r=+t[7];n=t[8]?wn(r):ee(r*255,0,255)}return i=+t[1],s=+t[3],o=+t[5],i=255&(t[2]?wn(i):ee(i,0,255)),s=255&(t[4]?wn(s):ee(s,0,255)),o=255&(t[6]?wn(o):ee(o,0,255)),{r:i,g:s,b:o,a:n}}}function kf(e){return e&&(e.a<255?\`rgba(\${e.r}, \${e.g}, \${e.b}, \${Yt(e.a)})\`:\`rgb(\${e.r}, \${e.g}, \${e.b})\`)}const es=e=>e<=.0031308?e*12.92:Math.pow(e,1/2.4)*1.055-.055,Ue=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4);function Tf(e,t,n){const i=Ue(Yt(e.r)),s=Ue(Yt(e.g)),o=Ue(Yt(e.b));return{r:re(es(i+n*(Ue(Yt(t.r))-i))),g:re(es(s+n*(Ue(Yt(t.g))-s))),b:re(es(o+n*(Ue(Yt(t.b))-o))),a:e.a+n*(t.a-e.a)}}function ni(e,t,n){if(e){let i=po(e);i[t]=Math.max(0,Math.min(i[t]+i[t]*n,t===0?360:1)),i=mo(i),e.r=i[0],e.g=i[1],e.b=i[2]}}function Ol(e,t){return e&&Object.assign(t||{},e)}function hr(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=re(e[3]))):(t=Ol(e,{r:0,g:0,b:0,a:1}),t.a=re(t.a)),t}function Mf(e){return e.charAt(0)==="r"?Sf(e):bf(e)}class In{constructor(t){if(t instanceof In)return t;const n=typeof t;let i;n==="object"?i=hr(t):n==="string"&&(i=lf(t)||_f(t)||Mf(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=Ol(this._rgb);return t&&(t.a=Yt(t.a)),t}set rgb(t){this._rgb=hr(t)}rgbString(){return this._valid?kf(this._rgb):void 0}hexString(){return this._valid?uf(this._rgb):void 0}hslString(){return this._valid?yf(this._rgb):void 0}mix(t,n){if(t){const i=this.rgb,s=t.rgb;let o;const r=n===o?.5:n,a=2*r-1,l=i.a-s.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;o=1-c,i.r=255&c*i.r+o*s.r+.5,i.g=255&c*i.g+o*s.g+.5,i.b=255&c*i.b+o*s.b+.5,i.a=r*i.a+(1-r)*s.a,this.rgb=i}return this}interpolate(t,n){return t&&(this._rgb=Tf(this._rgb,t._rgb,n)),this}clone(){return new In(this.rgb)}alpha(t){return this._rgb.a=re(t),this}clearer(t){const n=this._rgb;return n.a*=1-t,this}greyscale(){const t=this._rgb,n=Bn(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=n,this}opaquer(t){const n=this._rgb;return n.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return ni(this._rgb,2,t),this}darken(t){return ni(this._rgb,2,-t),this}saturate(t){return ni(this._rgb,1,t),this}desaturate(t){return ni(this._rgb,1,-t),this}rotate(t){return xf(this._rgb,t),this}}/*!
9283
+ */function Vn(e){return e+.5|0}const ee=(e,t,n)=>Math.max(Math.min(e,n),t);function wn(e){return ee(Vn(e*2.55),0,255)}function re(e){return ee(Vn(e*255),0,255)}function Yt(e){return ee(Vn(e/2.55)/100,0,1)}function cr(e){return ee(Vn(e*100),0,100)}const bt={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},Fs=[..."0123456789ABCDEF"],rf=e=>Fs[e&15],af=e=>Fs[(e&240)>>4]+Fs[e&15],Jn=e=>(e&240)>>4===(e&15),lf=e=>Jn(e.r)&&Jn(e.g)&&Jn(e.b)&&Jn(e.a);function cf(e){var t=e.length,n;return e[0]==="#"&&(t===4||t===5?n={r:255&bt[e[1]]*17,g:255&bt[e[2]]*17,b:255&bt[e[3]]*17,a:t===5?bt[e[4]]*17:255}:(t===7||t===9)&&(n={r:bt[e[1]]<<4|bt[e[2]],g:bt[e[3]]<<4|bt[e[4]],b:bt[e[5]]<<4|bt[e[6]],a:t===9?bt[e[7]]<<4|bt[e[8]]:255})),n}const uf=(e,t)=>e<255?t(e):"";function hf(e){var t=lf(e)?rf:af;return e?"#"+t(e.r)+t(e.g)+t(e.b)+uf(e.a,t):void 0}const ff=/^(hsla?|hwb|hsv)\\(\\s*([-+.e\\d]+)(?:deg)?[\\s,]+([-+.e\\d]+)%[\\s,]+([-+.e\\d]+)%(?:[\\s,]+([-+.e\\d]+)(%)?)?\\s*\\)$/;function Ol(e,t,n){const i=t*Math.min(n,1-n),s=(o,r=(o+e/30)%12)=>n-i*Math.max(Math.min(r-3,9-r,1),-1);return[s(0),s(8),s(4)]}function df(e,t,n){const i=(s,o=(s+e/60)%6)=>n-n*t*Math.max(Math.min(o,4-o,1),0);return[i(5),i(3),i(1)]}function pf(e,t,n){const i=Ol(e,1,.5);let s;for(t+n>1&&(s=1/(t+n),t*=s,n*=s),s=0;s<3;s++)i[s]*=1-t-n,i[s]+=t;return i}function gf(e,t,n,i,s){return e===s?(t-n)/i+(t<n?6:0):t===s?(n-e)/i+2:(e-t)/i+4}function po(e){const n=e.r/255,i=e.g/255,s=e.b/255,o=Math.max(n,i,s),r=Math.min(n,i,s),a=(o+r)/2;let l,c,u;return o!==r&&(u=o-r,c=a>.5?u/(2-o-r):u/(o+r),l=gf(n,i,s,u,o),l=l*60+.5),[l|0,c||0,a]}function go(e,t,n,i){return(Array.isArray(t)?e(t[0],t[1],t[2]):e(t,n,i)).map(re)}function mo(e,t,n){return go(Ol,e,t,n)}function mf(e,t,n){return go(pf,e,t,n)}function bf(e,t,n){return go(df,e,t,n)}function Pl(e){return(e%360+360)%360}function xf(e){const t=ff.exec(e);let n=255,i;if(!t)return;t[5]!==i&&(n=t[6]?wn(+t[5]):re(+t[5]));const s=Pl(+t[2]),o=+t[3]/100,r=+t[4]/100;return t[1]==="hwb"?i=mf(s,o,r):t[1]==="hsv"?i=bf(s,o,r):i=mo(s,o,r),{r:i[0],g:i[1],b:i[2],a:n}}function yf(e,t){var n=po(e);n[0]=Pl(n[0]+t),n=mo(n),e.r=n[0],e.g=n[1],e.b=n[2]}function vf(e){if(!e)return;const t=po(e),n=t[0],i=cr(t[1]),s=cr(t[2]);return e.a<255?\`hsla(\${n}, \${i}%, \${s}%, \${Yt(e.a)})\`:\`hsl(\${n}, \${i}%, \${s}%)\`}const ur={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},hr={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function _f(){const e={},t=Object.keys(hr),n=Object.keys(ur);let i,s,o,r,a;for(i=0;i<t.length;i++){for(r=a=t[i],s=0;s<n.length;s++)o=n[s],a=a.replace(o,ur[o]);o=parseInt(hr[r],16),e[a]=[o>>16&255,o>>8&255,o&255]}return e}let ti;function wf(e){ti||(ti=_f(),ti.transparent=[0,0,0,0]);const t=ti[e.toLowerCase()];return t&&{r:t[0],g:t[1],b:t[2],a:t.length===4?t[3]:255}}const Sf=/^rgba?\\(\\s*([-+.\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?[\\s,]+([-+.e\\d]+)(%)?(?:[\\s,/]+([-+.e\\d]+)(%)?)?\\s*\\)$/;function kf(e){const t=Sf.exec(e);let n=255,i,s,o;if(t){if(t[7]!==i){const r=+t[7];n=t[8]?wn(r):ee(r*255,0,255)}return i=+t[1],s=+t[3],o=+t[5],i=255&(t[2]?wn(i):ee(i,0,255)),s=255&(t[4]?wn(s):ee(s,0,255)),o=255&(t[6]?wn(o):ee(o,0,255)),{r:i,g:s,b:o,a:n}}}function Tf(e){return e&&(e.a<255?\`rgba(\${e.r}, \${e.g}, \${e.b}, \${Yt(e.a)})\`:\`rgb(\${e.r}, \${e.g}, \${e.b})\`)}const es=e=>e<=.0031308?e*12.92:Math.pow(e,1/2.4)*1.055-.055,Ue=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4);function Mf(e,t,n){const i=Ue(Yt(e.r)),s=Ue(Yt(e.g)),o=Ue(Yt(e.b));return{r:re(es(i+n*(Ue(Yt(t.r))-i))),g:re(es(s+n*(Ue(Yt(t.g))-s))),b:re(es(o+n*(Ue(Yt(t.b))-o))),a:e.a+n*(t.a-e.a)}}function ei(e,t,n){if(e){let i=po(e);i[t]=Math.max(0,Math.min(i[t]+i[t]*n,t===0?360:1)),i=mo(i),e.r=i[0],e.g=i[1],e.b=i[2]}}function Dl(e,t){return e&&Object.assign(t||{},e)}function fr(e){var t={r:0,g:0,b:0,a:255};return Array.isArray(e)?e.length>=3&&(t={r:e[0],g:e[1],b:e[2],a:255},e.length>3&&(t.a=re(e[3]))):(t=Dl(e,{r:0,g:0,b:0,a:1}),t.a=re(t.a)),t}function Ef(e){return e.charAt(0)==="r"?kf(e):xf(e)}class In{constructor(t){if(t instanceof In)return t;const n=typeof t;let i;n==="object"?i=fr(t):n==="string"&&(i=cf(t)||wf(t)||Ef(t)),this._rgb=i,this._valid=!!i}get valid(){return this._valid}get rgb(){var t=Dl(this._rgb);return t&&(t.a=Yt(t.a)),t}set rgb(t){this._rgb=fr(t)}rgbString(){return this._valid?Tf(this._rgb):void 0}hexString(){return this._valid?hf(this._rgb):void 0}hslString(){return this._valid?vf(this._rgb):void 0}mix(t,n){if(t){const i=this.rgb,s=t.rgb;let o;const r=n===o?.5:n,a=2*r-1,l=i.a-s.a,c=((a*l===-1?a:(a+l)/(1+a*l))+1)/2;o=1-c,i.r=255&c*i.r+o*s.r+.5,i.g=255&c*i.g+o*s.g+.5,i.b=255&c*i.b+o*s.b+.5,i.a=r*i.a+(1-r)*s.a,this.rgb=i}return this}interpolate(t,n){return t&&(this._rgb=Mf(this._rgb,t._rgb,n)),this}clone(){return new In(this.rgb)}alpha(t){return this._rgb.a=re(t),this}clearer(t){const n=this._rgb;return n.a*=1-t,this}greyscale(){const t=this._rgb,n=Vn(t.r*.3+t.g*.59+t.b*.11);return t.r=t.g=t.b=n,this}opaquer(t){const n=this._rgb;return n.a*=1+t,this}negate(){const t=this._rgb;return t.r=255-t.r,t.g=255-t.g,t.b=255-t.b,this}lighten(t){return ei(this._rgb,2,t),this}darken(t){return ei(this._rgb,2,-t),this}saturate(t){return ei(this._rgb,1,t),this}desaturate(t){return ei(this._rgb,1,-t),this}rotate(t){return yf(this._rgb,t),this}}/*!
9131
9284
  * Chart.js v4.5.0
9132
9285
  * https://www.chartjs.org
9133
9286
  * (c) 2025 Chart.js Contributors
9134
9287
  * Released under the MIT License
9135
- */function jt(){}const Ef=(()=>{let e=0;return()=>e++})();function B(e){return e==null}function tt(e){if(Array.isArray&&Array.isArray(e))return!0;const t=Object.prototype.toString.call(e);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function V(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function vt(e){return(typeof e=="number"||e instanceof Number)&&isFinite(+e)}function Pt(e,t){return vt(e)?e:t}function R(e,t){return typeof e>"u"?t:e}const Cf=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100*t:+e;function I(e,t,n){if(e&&typeof e.call=="function")return e.apply(n,t)}function F(e,t,n,i){let s,o,r;if(tt(e))for(o=e.length,s=0;s<o;s++)t.call(n,e[s],s);else if(V(e))for(r=Object.keys(e),o=r.length,s=0;s<o;s++)t.call(n,e[r[s]],r[s])}function Mi(e,t){let n,i,s,o;if(!e||!t||e.length!==t.length)return!1;for(n=0,i=e.length;n<i;++n)if(s=e[n],o=t[n],s.datasetIndex!==o.datasetIndex||s.index!==o.index)return!1;return!0}function Ei(e){if(tt(e))return e.map(Ei);if(V(e)){const t=Object.create(null),n=Object.keys(e),i=n.length;let s=0;for(;s<i;++s)t[n[s]]=Ei(e[n[s]]);return t}return e}function Pl(e){return["__proto__","prototype","constructor"].indexOf(e)===-1}function Of(e,t,n,i){if(!Pl(e))return;const s=t[e],o=n[e];V(s)&&V(o)?Ln(s,o,i):t[e]=Ei(o)}function Ln(e,t,n){const i=tt(t)?t:[t],s=i.length;if(!V(e))return e;n=n||{};const o=n.merger||Of;let r;for(let a=0;a<s;++a){if(r=i[a],!V(r))continue;const l=Object.keys(r);for(let c=0,u=l.length;c<u;++c)o(l[c],e,r,n)}return e}function Mn(e,t){return Ln(e,t,{merger:Pf})}function Pf(e,t,n){if(!Pl(e))return;const i=t[e],s=n[e];V(i)&&V(s)?Mn(i,s):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=Ei(s))}const fr={"":e=>e,x:e=>e.x,y:e=>e.y};function Df(e){const t=e.split("."),n=[];let i="";for(const s of t)i+=s,i.endsWith("\\\\")?i=i.slice(0,-1)+".":(n.push(i),i="");return n}function Af(e){const t=Df(e);return n=>{for(const i of t){if(i==="")break;n=n&&n[i]}return n}}function Ci(e,t){return(fr[t]||(fr[t]=Af(t)))(e)}function bo(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Oi=e=>typeof e<"u",ue=e=>typeof e=="function",dr=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0};function If(e){return e.type==="mouseup"||e.type==="click"||e.type==="contextmenu"}const et=Math.PI,Ft=2*et,Lf=Ft+et,Pi=Number.POSITIVE_INFINITY,Rf=et/180,kt=et/2,Se=et/4,pr=et*2/3,Dl=Math.log10,he=Math.sign;function Ie(e,t,n){return Math.abs(e-t)<n}function gr(e){const t=Math.round(e);e=Ie(e,t,e/1e3)?t:e;const n=Math.pow(10,Math.floor(Dl(e))),i=e/n;return(i<=1?1:i<=2?2:i<=5?5:10)*n}function Nf(e){const t=[],n=Math.sqrt(e);let i;for(i=1;i<n;i++)e%i===0&&(t.push(i),t.push(e/i));return n===(n|0)&&t.push(n),t.sort((s,o)=>s-o).pop(),t}function Ff(e){return typeof e=="symbol"||typeof e=="object"&&e!==null&&!(Symbol.toPrimitive in e||"toString"in e||"valueOf"in e)}function Rn(e){return!Ff(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function zf(e,t){const n=Math.round(e);return n-t<=e&&n+t>=e}function Hf(e,t,n){let i,s,o;for(i=0,s=e.length;i<s;i++)o=e[i][n],isNaN(o)||(t.min=Math.min(t.min,o),t.max=Math.max(t.max,o))}function Pe(e){return e*(et/180)}function Vf(e){return e*(180/et)}function mr(e){if(!vt(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function Bf(e,t){const n=t.x-e.x,i=t.y-e.y,s=Math.sqrt(n*n+i*i);let o=Math.atan2(i,n);return o<-.5*et&&(o+=Ft),{angle:o,distance:s}}function zs(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Wf(e,t){return(e-t+Lf)%Ft-et}function Jt(e){return(e%Ft+Ft)%Ft}function Al(e,t,n,i){const s=Jt(e),o=Jt(t),r=Jt(n),a=Jt(o-s),l=Jt(r-s),c=Jt(s-o),u=Jt(s-r);return s===o||s===r||i&&o===r||a>l&&c<u}function xt(e,t,n){return Math.max(t,Math.min(n,e))}function jf(e){return xt(e,-32768,32767)}function Sn(e,t,n,i=1e-6){return e>=Math.min(t,n)-i&&e<=Math.max(t,n)+i}function xo(e,t,n){n=n||(r=>e[r]<t);let i=e.length-1,s=0,o;for(;i-s>1;)o=s+i>>1,n(o)?s=o:i=o;return{lo:s,hi:i}}const De=(e,t,n,i)=>xo(e,n,i?s=>{const o=e[s][t];return o<n||o===n&&e[s+1][t]===n}:s=>e[s][t]<n),$f=(e,t,n)=>xo(e,n,i=>e[i][t]>=n);function Uf(e,t,n){let i=0,s=e.length;for(;i<s&&e[i]<t;)i++;for(;s>i&&e[s-1]>n;)s--;return i>0||s<e.length?e.slice(i,s):e}const Il=["push","pop","shift","splice","unshift"];function Yf(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),Il.forEach(n=>{const i="_onData"+bo(n),s=e[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!1,value(...o){const r=s.apply(this,o);return e._chartjs.listeners.forEach(a=>{typeof a[i]=="function"&&a[i](...o)}),r}})})}function br(e,t){const n=e._chartjs;if(!n)return;const i=n.listeners,s=i.indexOf(t);s!==-1&&i.splice(s,1),!(i.length>0)&&(Il.forEach(o=>{delete e[o]}),delete e._chartjs)}function Xf(e){const t=new Set(e);return t.size===e.length?e:Array.from(t)}const Ll=(function(){return typeof window>"u"?function(e){return e()}:window.requestAnimationFrame})();function Rl(e,t){let n=[],i=!1;return function(...s){n=s,i||(i=!0,Ll.call(window,()=>{i=!1,e.apply(t,n)}))}}function qf(e,t){let n;return function(...i){return t?(clearTimeout(n),n=setTimeout(e,t,i)):e.apply(this,i),t}}const Nl=e=>e==="start"?"left":e==="end"?"right":"center",ft=(e,t,n)=>e==="start"?t:e==="end"?n:(t+n)/2,Gf=(e,t,n,i)=>e===(i?"left":"right")?n:e==="center"?(t+n)/2:t;function Kf(e,t,n){const i=t.length;let s=0,o=i;if(e._sorted){const{iScale:r,vScale:a,_parsed:l}=e,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=r.axis,{min:f,max:d,minDefined:m,maxDefined:y}=r.getUserBounds();if(m){if(s=Math.min(De(l,u,f).lo,n?i:De(t,u,r.getPixelForValue(f)).lo),c){const x=l.slice(0,s+1).reverse().findIndex(v=>!B(v[a.axis]));s-=Math.max(0,x)}s=xt(s,0,i-1)}if(y){let x=Math.max(De(l,r.axis,d,!0).hi+1,n?0:De(t,u,r.getPixelForValue(d),!0).hi+1);if(c){const v=l.slice(x-1).findIndex(w=>!B(w[a.axis]));x+=Math.max(0,v)}o=xt(x,s,i)-s}else o=i-s}return{start:s,count:o}}function Zf(e){const{xScale:t,yScale:n,_scaleRanges:i}=e,s={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!i)return e._scaleRanges=s,!0;const o=i.xmin!==t.min||i.xmax!==t.max||i.ymin!==n.min||i.ymax!==n.max;return Object.assign(i,s),o}const ii=e=>e===0||e===1,xr=(e,t,n)=>-(Math.pow(2,10*(e-=1))*Math.sin((e-t)*Ft/n)),yr=(e,t,n)=>Math.pow(2,-10*e)*Math.sin((e-t)*Ft/n)+1,En={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>(e-=1)*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-((e-=1)*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>(e-=1)*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*kt)+1,easeOutSine:e=>Math.sin(e*kt),easeInOutSine:e=>-.5*(Math.cos(et*e)-1),easeInExpo:e=>e===0?0:Math.pow(2,10*(e-1)),easeOutExpo:e=>e===1?1:-Math.pow(2,-10*e)+1,easeInOutExpo:e=>ii(e)?e:e<.5?.5*Math.pow(2,10*(e*2-1)):.5*(-Math.pow(2,-10*(e*2-1))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1-(e-=1)*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>ii(e)?e:xr(e,.075,.3),easeOutElastic:e=>ii(e)?e:yr(e,.075,.3),easeInOutElastic(e){return ii(e)?e:e<.5?.5*xr(e*2,.1125,.45):.5+.5*yr(e*2-1,.1125,.45)},easeInBack(e){return e*e*((1.70158+1)*e-1.70158)},easeOutBack(e){return(e-=1)*e*((1.70158+1)*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-En.easeOutBounce(1-e),easeOutBounce(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},easeInOutBounce:e=>e<.5?En.easeInBounce(e*2)*.5:En.easeOutBounce(e*2-1)*.5+.5};function yo(e){if(e&&typeof e=="object"){const t=e.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function vr(e){return yo(e)?e:new In(e)}function ns(e){return yo(e)?e:new In(e).saturate(.5).darken(.1).hexString()}const Qf=["x","y","borderWidth","radius","tension"],Jf=["color","borderColor","backgroundColor"];function td(e){e.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),e.set("animations",{colors:{type:"color",properties:Jf},numbers:{type:"number",properties:Qf}}),e.describe("animations",{_fallback:"animation"}),e.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>t|0}}}})}function ed(e){e.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const _r=new Map;function nd(e,t){t=t||{};const n=e+JSON.stringify(t);let i=_r.get(n);return i||(i=new Intl.NumberFormat(e,t),_r.set(n,i)),i}function Fl(e,t,n){return nd(t,n).format(e)}const id={values(e){return tt(e)?e:""+e},numeric(e,t,n){if(e===0)return"0";const i=this.chart.options.locale;let s,o=e;if(n.length>1){const c=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(c<1e-4||c>1e15)&&(s="scientific"),o=sd(e,n)}const r=Dl(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),l={notation:s,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),Fl(e,i,l)}};function sd(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var zl={formatters:id};function od(e){e.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,n)=>n.lineWidth,tickColor:(t,n)=>n.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:zl.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),e.route("scale.ticks","color","","color"),e.route("scale.grid","color","","borderColor"),e.route("scale.border","color","","borderColor"),e.route("scale.title","color","","color"),e.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),e.describe("scales",{_fallback:"scale"}),e.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}const ze=Object.create(null),Hs=Object.create(null);function Cn(e,t){if(!t)return e;const n=t.split(".");for(let i=0,s=n.length;i<s;++i){const o=n[i];e=e[o]||(e[o]=Object.create(null))}return e}function is(e,t,n){return typeof t=="string"?Ln(Cn(e,t),n):Ln(Cn(e,""),t)}class rd{constructor(t,n){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=i=>i.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(i,s)=>ns(s.backgroundColor),this.hoverBorderColor=(i,s)=>ns(s.borderColor),this.hoverColor=(i,s)=>ns(s.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(n)}set(t,n){return is(this,t,n)}get(t){return Cn(this,t)}describe(t,n){return is(Hs,t,n)}override(t,n){return is(ze,t,n)}route(t,n,i,s){const o=Cn(this,t),r=Cn(this,i),a="_"+n;Object.defineProperties(o,{[a]:{value:o[n],writable:!0},[n]:{enumerable:!0,get(){const l=this[a],c=r[s];return V(l)?Object.assign({},c,l):R(l,c)},set(l){this[a]=l}}})}apply(t){t.forEach(n=>n(this))}}var Y=new rd({_scriptable:e=>!e.startsWith("on"),_indexable:e=>e!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[td,ed,od]);function ad(e){return!e||B(e.size)||B(e.family)?null:(e.style?e.style+" ":"")+(e.weight?e.weight+" ":"")+e.size+"px "+e.family}function wr(e,t,n,i,s){let o=t[s];return o||(o=t[s]=e.measureText(s).width,n.push(s)),o>i&&(i=o),i}function ke(e,t,n){const i=e.currentDevicePixelRatio,s=n!==0?Math.max(n/2,.5):0;return Math.round((t-s)*i)/i+s}function Sr(e,t){!t&&!e||(t=t||e.getContext("2d"),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function Vs(e,t,n,i){Hl(e,t,n,i,null)}function Hl(e,t,n,i,s){let o,r,a,l,c,u,f,d;const m=t.pointStyle,y=t.rotation,x=t.radius;let v=(y||0)*Rf;if(m&&typeof m=="object"&&(o=m.toString(),o==="[object HTMLImageElement]"||o==="[object HTMLCanvasElement]")){e.save(),e.translate(n,i),e.rotate(v),e.drawImage(m,-m.width/2,-m.height/2,m.width,m.height),e.restore();return}if(!(isNaN(x)||x<=0)){switch(e.beginPath(),m){default:s?e.ellipse(n,i,s/2,x,0,0,Ft):e.arc(n,i,x,0,Ft),e.closePath();break;case"triangle":u=s?s/2:x,e.moveTo(n+Math.sin(v)*u,i-Math.cos(v)*x),v+=pr,e.lineTo(n+Math.sin(v)*u,i-Math.cos(v)*x),v+=pr,e.lineTo(n+Math.sin(v)*u,i-Math.cos(v)*x),e.closePath();break;case"rectRounded":c=x*.516,l=x-c,r=Math.cos(v+Se)*l,f=Math.cos(v+Se)*(s?s/2-c:l),a=Math.sin(v+Se)*l,d=Math.sin(v+Se)*(s?s/2-c:l),e.arc(n-f,i-a,c,v-et,v-kt),e.arc(n+d,i-r,c,v-kt,v),e.arc(n+f,i+a,c,v,v+kt),e.arc(n-d,i+r,c,v+kt,v+et),e.closePath();break;case"rect":if(!y){l=Math.SQRT1_2*x,u=s?s/2:l,e.rect(n-u,i-l,2*u,2*l);break}v+=Se;case"rectRot":f=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,d=Math.sin(v)*(s?s/2:x),e.moveTo(n-f,i-a),e.lineTo(n+d,i-r),e.lineTo(n+f,i+a),e.lineTo(n-d,i+r),e.closePath();break;case"crossRot":v+=Se;case"cross":f=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,d=Math.sin(v)*(s?s/2:x),e.moveTo(n-f,i-a),e.lineTo(n+f,i+a),e.moveTo(n+d,i-r),e.lineTo(n-d,i+r);break;case"star":f=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,d=Math.sin(v)*(s?s/2:x),e.moveTo(n-f,i-a),e.lineTo(n+f,i+a),e.moveTo(n+d,i-r),e.lineTo(n-d,i+r),v+=Se,f=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,d=Math.sin(v)*(s?s/2:x),e.moveTo(n-f,i-a),e.lineTo(n+f,i+a),e.moveTo(n+d,i-r),e.lineTo(n-d,i+r);break;case"line":r=s?s/2:Math.cos(v)*x,a=Math.sin(v)*x,e.moveTo(n-r,i-a),e.lineTo(n+r,i+a);break;case"dash":e.moveTo(n,i),e.lineTo(n+Math.cos(v)*(s?s/2:x),i+Math.sin(v)*x);break;case!1:e.closePath();break}e.fill(),t.borderWidth>0&&e.stroke()}}function en(e,t,n){return n=n||.5,!t||e&&e.x>t.left-n&&e.x<t.right+n&&e.y>t.top-n&&e.y<t.bottom+n}function vo(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function _o(e){e.restore()}function ld(e,t,n,i,s){if(!t)return e.lineTo(n.x,n.y);if(s==="middle"){const o=(t.x+n.x)/2;e.lineTo(o,t.y),e.lineTo(o,n.y)}else s==="after"!=!!i?e.lineTo(t.x,n.y):e.lineTo(n.x,t.y);e.lineTo(n.x,n.y)}function cd(e,t,n,i){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(i?t.cp1x:t.cp2x,i?t.cp1y:t.cp2y,i?n.cp2x:n.cp1x,i?n.cp2y:n.cp1y,n.x,n.y)}function ud(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),B(t.rotation)||e.rotate(t.rotation),t.color&&(e.fillStyle=t.color),t.textAlign&&(e.textAlign=t.textAlign),t.textBaseline&&(e.textBaseline=t.textBaseline)}function hd(e,t,n,i,s){if(s.strikethrough||s.underline){const o=e.measureText(i),r=t-o.actualBoundingBoxLeft,a=t+o.actualBoundingBoxRight,l=n-o.actualBoundingBoxAscent,c=n+o.actualBoundingBoxDescent,u=s.strikethrough?(l+c)/2:c;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=s.decorationWidth||2,e.moveTo(r,u),e.lineTo(a,u),e.stroke()}}function fd(e,t){const n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function Di(e,t,n,i,s,o={}){const r=tt(t)?t:[t],a=o.strokeWidth>0&&o.strokeColor!=="";let l,c;for(e.save(),e.font=s.string,ud(e,o),l=0;l<r.length;++l)c=r[l],o.backdrop&&fd(e,o.backdrop),a&&(o.strokeColor&&(e.strokeStyle=o.strokeColor),B(o.strokeWidth)||(e.lineWidth=o.strokeWidth),e.strokeText(c,n,i,o.maxWidth)),e.fillText(c,n,i,o.maxWidth),hd(e,n,i,c,o),i+=Number(s.lineHeight);e.restore()}function Bs(e,t){const{x:n,y:i,w:s,h:o,radius:r}=t;e.arc(n+r.topLeft,i+r.topLeft,r.topLeft,1.5*et,et,!0),e.lineTo(n,i+o-r.bottomLeft),e.arc(n+r.bottomLeft,i+o-r.bottomLeft,r.bottomLeft,et,kt,!0),e.lineTo(n+s-r.bottomRight,i+o),e.arc(n+s-r.bottomRight,i+o-r.bottomRight,r.bottomRight,kt,0,!0),e.lineTo(n+s,i+r.topRight),e.arc(n+s-r.topRight,i+r.topRight,r.topRight,0,-kt,!0),e.lineTo(n+r.topLeft,i)}const dd=/^(normal|(\\d+(?:\\.\\d+)?)(px|em|%)?)$/,pd=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function gd(e,t){const n=(""+e).match(dd);if(!n||n[1]==="normal")return t*1.2;switch(e=+n[2],n[3]){case"px":return e;case"%":e/=100;break}return t*e}const md=e=>+e||0;function Vl(e,t){const n={},i=V(t),s=i?Object.keys(t):t,o=V(e)?i?r=>R(e[r],e[t[r]]):r=>e[r]:()=>e;for(const r of s)n[r]=md(o(r));return n}function bd(e){return Vl(e,{top:"y",right:"x",bottom:"y",left:"x"})}function On(e){return Vl(e,["topLeft","topRight","bottomLeft","bottomRight"])}function Mt(e){const t=bd(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function ht(e,t){e=e||{},t=t||Y.font;let n=R(e.size,t.size);typeof n=="string"&&(n=parseInt(n,10));let i=R(e.style,t.style);i&&!(""+i).match(pd)&&(console.warn('Invalid font style specified: "'+i+'"'),i=void 0);const s={family:R(e.family,t.family),lineHeight:gd(R(e.lineHeight,t.lineHeight),n),size:n,style:i,weight:R(e.weight,t.weight),string:""};return s.string=ad(s),s}function si(e,t,n,i){let s,o,r;for(s=0,o=e.length;s<o;++s)if(r=e[s],r!==void 0&&r!==void 0)return r}function xd(e,t,n){const{min:i,max:s}=e,o=Cf(t,(s-i)/2),r=(a,l)=>n&&a===0?0:a+l;return{min:r(i,-Math.abs(o)),max:r(s,o)}}function Ve(e,t){return Object.assign(Object.create(e),t)}function wo(e,t=[""],n,i,s=()=>e[0]){const o=n||e;typeof i>"u"&&(i=$l("_fallback",e));const r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:e,_rootScopes:o,_fallback:i,_getTarget:s,override:a=>wo([a,...e],t,o,i)};return new Proxy(r,{deleteProperty(a,l){return delete a[l],delete a._keys,delete e[0][l],!0},get(a,l){return Wl(a,l,()=>Md(l,t,e,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(a,l){return Tr(a).includes(l)},ownKeys(a){return Tr(a)},set(a,l,c){const u=a._storage||(a._storage=s());return a[l]=u[l]=c,delete a._keys,!0}})}function nn(e,t,n,i){const s={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:Bl(e,i),setContext:o=>nn(e,o,n,i),override:o=>nn(e.override(o),t,n,i)};return new Proxy(s,{deleteProperty(o,r){return delete o[r],delete e[r],!0},get(o,r,a){return Wl(o,r,()=>vd(o,r,a))},getOwnPropertyDescriptor(o,r){return o._descriptors.allKeys?Reflect.has(e,r)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,r)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(o,r){return Reflect.has(e,r)},ownKeys(){return Reflect.ownKeys(e)},set(o,r,a){return e[r]=a,delete o[r],!0}})}function Bl(e,t={scriptable:!0,indexable:!0}){const{_scriptable:n=t.scriptable,_indexable:i=t.indexable,_allKeys:s=t.allKeys}=e;return{allKeys:s,scriptable:n,indexable:i,isScriptable:ue(n)?n:()=>n,isIndexable:ue(i)?i:()=>i}}const yd=(e,t)=>e?e+bo(t):t,So=(e,t)=>V(t)&&e!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function Wl(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t==="constructor")return e[t];const i=n();return e[t]=i,i}function vd(e,t,n){const{_proxy:i,_context:s,_subProxy:o,_descriptors:r}=e;let a=i[t];return ue(a)&&r.isScriptable(t)&&(a=_d(t,a,e,n)),tt(a)&&a.length&&(a=wd(t,a,e,r.isIndexable)),So(t,a)&&(a=nn(a,s,o&&o[t],r)),a}function _d(e,t,n,i){const{_proxy:s,_context:o,_subProxy:r,_stack:a}=n;if(a.has(e))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+e);a.add(e);let l=t(o,r||i);return a.delete(e),So(e,l)&&(l=ko(s._scopes,s,e,l)),l}function wd(e,t,n,i){const{_proxy:s,_context:o,_subProxy:r,_descriptors:a}=n;if(typeof o.index<"u"&&i(e))return t[o.index%t.length];if(V(t[0])){const l=t,c=s._scopes.filter(u=>u!==l);t=[];for(const u of l){const f=ko(c,s,e,u);t.push(nn(f,o,r&&r[e],a))}}return t}function jl(e,t,n){return ue(e)?e(t,n):e}const Sd=(e,t)=>e===!0?t:typeof e=="string"?Ci(t,e):void 0;function kd(e,t,n,i,s){for(const o of t){const r=Sd(n,o);if(r){e.add(r);const a=jl(r._fallback,n,s);if(typeof a<"u"&&a!==n&&a!==i)return a}else if(r===!1&&typeof i<"u"&&n!==i)return null}return!1}function ko(e,t,n,i){const s=t._rootScopes,o=jl(t._fallback,n,i),r=[...e,...s],a=new Set;a.add(i);let l=kr(a,r,n,o||n,i);return l===null||typeof o<"u"&&o!==n&&(l=kr(a,r,o,l,i),l===null)?!1:wo(Array.from(a),[""],s,o,()=>Td(t,n,i))}function kr(e,t,n,i,s){for(;n;)n=kd(e,t,n,i,s);return n}function Td(e,t,n){const i=e._getTarget();t in i||(i[t]={});const s=i[t];return tt(s)&&V(n)?n:s||{}}function Md(e,t,n,i){let s;for(const o of t)if(s=$l(yd(o,e),n),typeof s<"u")return So(e,s)?ko(n,i,e,s):s}function $l(e,t){for(const n of t){if(!n)continue;const i=n[e];if(typeof i<"u")return i}}function Tr(e){let t=e._keys;return t||(t=e._keys=Ed(e._scopes)),t}function Ed(e){const t=new Set;for(const n of e)for(const i of Object.keys(n).filter(s=>!s.startsWith("_")))t.add(i);return Array.from(t)}const Cd=Number.EPSILON||1e-14,sn=(e,t)=>t<e.length&&!e[t].skip&&e[t],Ul=e=>e==="x"?"y":"x";function Od(e,t,n,i){const s=e.skip?t:e,o=t,r=n.skip?t:n,a=zs(o,s),l=zs(r,o);let c=a/(a+l),u=l/(a+l);c=isNaN(c)?0:c,u=isNaN(u)?0:u;const f=i*c,d=i*u;return{previous:{x:o.x-f*(r.x-s.x),y:o.y-f*(r.y-s.y)},next:{x:o.x+d*(r.x-s.x),y:o.y+d*(r.y-s.y)}}}function Pd(e,t,n){const i=e.length;let s,o,r,a,l,c=sn(e,0);for(let u=0;u<i-1;++u)if(l=c,c=sn(e,u+1),!(!l||!c)){if(Ie(t[u],0,Cd)){n[u]=n[u+1]=0;continue}s=n[u]/t[u],o=n[u+1]/t[u],a=Math.pow(s,2)+Math.pow(o,2),!(a<=9)&&(r=3/Math.sqrt(a),n[u]=s*r*t[u],n[u+1]=o*r*t[u])}}function Dd(e,t,n="x"){const i=Ul(n),s=e.length;let o,r,a,l=sn(e,0);for(let c=0;c<s;++c){if(r=a,a=l,l=sn(e,c+1),!a)continue;const u=a[n],f=a[i];r&&(o=(u-r[n])/3,a[\`cp1\${n}\`]=u-o,a[\`cp1\${i}\`]=f-o*t[c]),l&&(o=(l[n]-u)/3,a[\`cp2\${n}\`]=u+o,a[\`cp2\${i}\`]=f+o*t[c])}}function Ad(e,t="x"){const n=Ul(t),i=e.length,s=Array(i).fill(0),o=Array(i);let r,a,l,c=sn(e,0);for(r=0;r<i;++r)if(a=l,l=c,c=sn(e,r+1),!!l){if(c){const u=c[t]-l[t];s[r]=u!==0?(c[n]-l[n])/u:0}o[r]=a?c?he(s[r-1])!==he(s[r])?0:(s[r-1]+s[r])/2:s[r-1]:s[r]}Pd(e,s,o),Dd(e,o,t)}function oi(e,t,n){return Math.max(Math.min(e,n),t)}function Id(e,t){let n,i,s,o,r,a=en(e[0],t);for(n=0,i=e.length;n<i;++n)r=o,o=a,a=n<i-1&&en(e[n+1],t),o&&(s=e[n],r&&(s.cp1x=oi(s.cp1x,t.left,t.right),s.cp1y=oi(s.cp1y,t.top,t.bottom)),a&&(s.cp2x=oi(s.cp2x,t.left,t.right),s.cp2y=oi(s.cp2y,t.top,t.bottom)))}function Ld(e,t,n,i,s){let o,r,a,l;if(t.spanGaps&&(e=e.filter(c=>!c.skip)),t.cubicInterpolationMode==="monotone")Ad(e,s);else{let c=i?e[e.length-1]:e[0];for(o=0,r=e.length;o<r;++o)a=e[o],l=Od(c,a,e[Math.min(o+1,r-(i?0:1))%r],t.tension),a.cp1x=l.previous.x,a.cp1y=l.previous.y,a.cp2x=l.next.x,a.cp2y=l.next.y,c=a}t.capBezierPoints&&Id(e,n)}function To(){return typeof window<"u"&&typeof document<"u"}function Mo(e){let t=e.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function Ai(e,t,n){let i;return typeof e=="string"?(i=parseInt(e,10),e.indexOf("%")!==-1&&(i=i/100*t.parentNode[n])):i=e,i}const Vi=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function Rd(e,t){return Vi(e).getPropertyValue(t)}const Nd=["top","right","bottom","left"];function Le(e,t,n){const i={};n=n?"-"+n:"";for(let s=0;s<4;s++){const o=Nd[s];i[o]=parseFloat(e[t+"-"+o+n])||0}return i.width=i.left+i.right,i.height=i.top+i.bottom,i}const Fd=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function zd(e,t){const n=e.touches,i=n&&n.length?n[0]:e,{offsetX:s,offsetY:o}=i;let r=!1,a,l;if(Fd(s,o,e.target))a=s,l=o;else{const c=t.getBoundingClientRect();a=i.clientX-c.left,l=i.clientY-c.top,r=!0}return{x:a,y:l,box:r}}function It(e,t){if("native"in e)return e;const{canvas:n,currentDevicePixelRatio:i}=t,s=Vi(n),o=s.boxSizing==="border-box",r=Le(s,"padding"),a=Le(s,"border","width"),{x:l,y:c,box:u}=zd(e,n),f=r.left+(u&&a.left),d=r.top+(u&&a.top);let{width:m,height:y}=t;return o&&(m-=r.width+a.width,y-=r.height+a.height),{x:Math.round((l-f)/m*n.width/i),y:Math.round((c-d)/y*n.height/i)}}function Hd(e,t,n){let i,s;if(t===void 0||n===void 0){const o=e&&Mo(e);if(!o)t=e.clientWidth,n=e.clientHeight;else{const r=o.getBoundingClientRect(),a=Vi(o),l=Le(a,"border","width"),c=Le(a,"padding");t=r.width-c.width-l.width,n=r.height-c.height-l.height,i=Ai(a.maxWidth,o,"clientWidth"),s=Ai(a.maxHeight,o,"clientHeight")}}return{width:t,height:n,maxWidth:i||Pi,maxHeight:s||Pi}}const ri=e=>Math.round(e*10)/10;function Vd(e,t,n,i){const s=Vi(e),o=Le(s,"margin"),r=Ai(s.maxWidth,e,"clientWidth")||Pi,a=Ai(s.maxHeight,e,"clientHeight")||Pi,l=Hd(e,t,n);let{width:c,height:u}=l;if(s.boxSizing==="content-box"){const d=Le(s,"border","width"),m=Le(s,"padding");c-=m.width+d.width,u-=m.height+d.height}return c=Math.max(0,c-o.width),u=Math.max(0,i?c/i:u-o.height),c=ri(Math.min(c,r,l.maxWidth)),u=ri(Math.min(u,a,l.maxHeight)),c&&!u&&(u=ri(c/2)),(t!==void 0||n!==void 0)&&i&&l.height&&u>l.height&&(u=l.height,c=ri(Math.floor(u*i))),{width:c,height:u}}function Mr(e,t,n){const i=t||1,s=Math.floor(e.height*i),o=Math.floor(e.width*i);e.height=Math.floor(e.height),e.width=Math.floor(e.width);const r=e.canvas;return r.style&&(n||!r.style.height&&!r.style.width)&&(r.style.height=\`\${e.height}px\`,r.style.width=\`\${e.width}px\`),e.currentDevicePixelRatio!==i||r.height!==s||r.width!==o?(e.currentDevicePixelRatio=i,r.height=s,r.width=o,e.ctx.setTransform(i,0,0,i,0,0),!0):!1}const Bd=(function(){let e=!1;try{const t={get passive(){return e=!0,!1}};To()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return e})();function Er(e,t){const n=Rd(e,t),i=n&&n.match(/^(\\d+)(\\.\\d+)?px$/);return i?+i[1]:void 0}function Me(e,t,n,i){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function Wd(e,t,n,i){return{x:e.x+n*(t.x-e.x),y:i==="middle"?n<.5?e.y:t.y:i==="after"?n<1?e.y:t.y:n>0?t.y:e.y}}function jd(e,t,n,i){const s={x:e.cp2x,y:e.cp2y},o={x:t.cp1x,y:t.cp1y},r=Me(e,s,n),a=Me(s,o,n),l=Me(o,t,n),c=Me(r,a,n),u=Me(a,l,n);return Me(c,u,n)}const $d=function(e,t){return{x(n){return e+e+t-n},setWidth(n){t=n},textAlign(n){return n==="center"?n:n==="right"?"left":"right"},xPlus(n,i){return n-i},leftForLtr(n,i){return n-i}}},Ud=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function Ge(e,t,n){return e?$d(t,n):Ud()}function Yl(e,t){let n,i;(t==="ltr"||t==="rtl")&&(n=e.canvas.style,i=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",t,"important"),e.prevTextDirection=i)}function Xl(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty("direction",t[0],t[1]))}function ql(e){return e==="angle"?{between:Al,compare:Wf,normalize:Jt}:{between:Sn,compare:(t,n)=>t-n,normalize:t=>t}}function Cr({start:e,end:t,count:n,loop:i,style:s}){return{start:e%n,end:t%n,loop:i&&(t-e+1)%n===0,style:s}}function Yd(e,t,n){const{property:i,start:s,end:o}=n,{between:r,normalize:a}=ql(i),l=t.length;let{start:c,end:u,loop:f}=e,d,m;if(f){for(c+=l,u+=l,d=0,m=l;d<m&&r(a(t[c%l][i]),s,o);++d)c--,u--;c%=l,u%=l}return u<c&&(u+=l),{start:c,end:u,loop:f,style:e.style}}function Xd(e,t,n){if(!n)return[e];const{property:i,start:s,end:o}=n,r=t.length,{compare:a,between:l,normalize:c}=ql(i),{start:u,end:f,loop:d,style:m}=Yd(e,t,n),y=[];let x=!1,v=null,w,k,E;const C=()=>l(s,E,w)&&a(s,E)!==0,T=()=>a(o,w)===0||l(o,E,w),D=()=>x||C(),P=()=>!x||T();for(let O=u,A=u;O<=f;++O)k=t[O%r],!k.skip&&(w=c(k[i]),w!==E&&(x=l(w,s,o),v===null&&D()&&(v=a(w,s)===0?O:A),v!==null&&P()&&(y.push(Cr({start:v,end:O,loop:d,count:r,style:m})),v=null),A=O,E=w));return v!==null&&y.push(Cr({start:v,end:f,loop:d,count:r,style:m})),y}function qd(e,t){const n=[],i=e.segments;for(let s=0;s<i.length;s++){const o=Xd(i[s],e.points,t);o.length&&n.push(...o)}return n}function Gd(e,t,n,i){let s=0,o=t-1;if(n&&!i)for(;s<t&&!e[s].skip;)s++;for(;s<t&&e[s].skip;)s++;for(s%=t,n&&(o+=s);o>s&&e[o%t].skip;)o--;return o%=t,{start:s,end:o}}function Kd(e,t,n,i){const s=e.length,o=[];let r=t,a=e[t],l;for(l=t+1;l<=n;++l){const c=e[l%s];c.skip||c.stop?a.skip||(i=!1,o.push({start:t%s,end:(l-1)%s,loop:i}),t=r=c.stop?l:null):(r=l,a.skip&&(t=l)),a=c}return r!==null&&o.push({start:t%s,end:r%s,loop:i}),o}function Zd(e,t){const n=e.points,i=e.options.spanGaps,s=n.length;if(!s)return[];const o=!!e._loop,{start:r,end:a}=Gd(n,s,o,i);if(i===!0)return Or(e,[{start:r,end:a,loop:o}],n,t);const l=a<r?a+s:a,c=!!e._fullLoop&&r===0&&a===s-1;return Or(e,Kd(n,r,l,c),n,t)}function Or(e,t,n,i){return!i||!i.setContext||!n?t:Qd(e,t,n,i)}function Qd(e,t,n,i){const s=e._chart.getContext(),o=Pr(e.options),{_datasetIndex:r,options:{spanGaps:a}}=e,l=n.length,c=[];let u=o,f=t[0].start,d=f;function m(y,x,v,w){const k=a?-1:1;if(y!==x){for(y+=l;n[y%l].skip;)y-=k;for(;n[x%l].skip;)x+=k;y%l!==x%l&&(c.push({start:y%l,end:x%l,loop:v,style:w}),u=w,f=x%l)}}for(const y of t){f=a?f:y.start;let x=n[f%l],v;for(d=f+1;d<=y.end;d++){const w=n[d%l];v=Pr(i.setContext(Ve(s,{type:"segment",p0:x,p1:w,p0DataIndex:(d-1)%l,p1DataIndex:d%l,datasetIndex:r}))),Jd(v,u)&&m(f,d-1,y.loop,u),x=w,u=v}f<d-1&&m(f,d-1,y.loop,u)}return c}function Pr(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function Jd(e,t){if(!t)return!1;const n=[],i=function(s,o){return yo(o)?(n.includes(o)||n.push(o),n.indexOf(o)):o};return JSON.stringify(e,i)!==JSON.stringify(t,i)}function ai(e,t,n){return e.options.clip?e[n]:t[n]}function tp(e,t){const{xScale:n,yScale:i}=e;return n&&i?{left:ai(n,t,"left"),right:ai(n,t,"right"),top:ai(i,t,"top"),bottom:ai(i,t,"bottom")}:t}function ep(e,t){const n=t._clip;if(n.disabled)return!1;const i=tp(t,e.chartArea);return{left:n.left===!1?0:i.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:i.right+(n.right===!0?0:n.right),top:n.top===!1?0:i.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:i.bottom+(n.bottom===!0?0:n.bottom)}}/*!
9288
+ */function jt(){}const Cf=(()=>{let e=0;return()=>e++})();function B(e){return e==null}function tt(e){if(Array.isArray&&Array.isArray(e))return!0;const t=Object.prototype.toString.call(e);return t.slice(0,7)==="[object"&&t.slice(-6)==="Array]"}function V(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function vt(e){return(typeof e=="number"||e instanceof Number)&&isFinite(+e)}function Pt(e,t){return vt(e)?e:t}function R(e,t){return typeof e>"u"?t:e}const Of=(e,t)=>typeof e=="string"&&e.endsWith("%")?parseFloat(e)/100*t:+e;function I(e,t,n){if(e&&typeof e.call=="function")return e.apply(n,t)}function F(e,t,n,i){let s,o,r;if(tt(e))for(o=e.length,s=0;s<o;s++)t.call(n,e[s],s);else if(V(e))for(r=Object.keys(e),o=r.length,s=0;s<o;s++)t.call(n,e[r[s]],r[s])}function Ti(e,t){let n,i,s,o;if(!e||!t||e.length!==t.length)return!1;for(n=0,i=e.length;n<i;++n)if(s=e[n],o=t[n],s.datasetIndex!==o.datasetIndex||s.index!==o.index)return!1;return!0}function Mi(e){if(tt(e))return e.map(Mi);if(V(e)){const t=Object.create(null),n=Object.keys(e),i=n.length;let s=0;for(;s<i;++s)t[n[s]]=Mi(e[n[s]]);return t}return e}function Al(e){return["__proto__","prototype","constructor"].indexOf(e)===-1}function Pf(e,t,n,i){if(!Al(e))return;const s=t[e],o=n[e];V(s)&&V(o)?Ln(s,o,i):t[e]=Mi(o)}function Ln(e,t,n){const i=tt(t)?t:[t],s=i.length;if(!V(e))return e;n=n||{};const o=n.merger||Pf;let r;for(let a=0;a<s;++a){if(r=i[a],!V(r))continue;const l=Object.keys(r);for(let c=0,u=l.length;c<u;++c)o(l[c],e,r,n)}return e}function Mn(e,t){return Ln(e,t,{merger:Df})}function Df(e,t,n){if(!Al(e))return;const i=t[e],s=n[e];V(i)&&V(s)?Mn(i,s):Object.prototype.hasOwnProperty.call(t,e)||(t[e]=Mi(s))}const dr={"":e=>e,x:e=>e.x,y:e=>e.y};function Af(e){const t=e.split("."),n=[];let i="";for(const s of t)i+=s,i.endsWith("\\\\")?i=i.slice(0,-1)+".":(n.push(i),i="");return n}function If(e){const t=Af(e);return n=>{for(const i of t){if(i==="")break;n=n&&n[i]}return n}}function Ei(e,t){return(dr[t]||(dr[t]=If(t)))(e)}function bo(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Ci=e=>typeof e<"u",ue=e=>typeof e=="function",pr=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0};function Lf(e){return e.type==="mouseup"||e.type==="click"||e.type==="contextmenu"}const et=Math.PI,Ft=2*et,Rf=Ft+et,Oi=Number.POSITIVE_INFINITY,Nf=et/180,kt=et/2,Se=et/4,gr=et*2/3,Il=Math.log10,he=Math.sign;function Ie(e,t,n){return Math.abs(e-t)<n}function mr(e){const t=Math.round(e);e=Ie(e,t,e/1e3)?t:e;const n=Math.pow(10,Math.floor(Il(e))),i=e/n;return(i<=1?1:i<=2?2:i<=5?5:10)*n}function Ff(e){const t=[],n=Math.sqrt(e);let i;for(i=1;i<n;i++)e%i===0&&(t.push(i),t.push(e/i));return n===(n|0)&&t.push(n),t.sort((s,o)=>s-o).pop(),t}function zf(e){return typeof e=="symbol"||typeof e=="object"&&e!==null&&!(Symbol.toPrimitive in e||"toString"in e||"valueOf"in e)}function Rn(e){return!zf(e)&&!isNaN(parseFloat(e))&&isFinite(e)}function Hf(e,t){const n=Math.round(e);return n-t<=e&&n+t>=e}function Vf(e,t,n){let i,s,o;for(i=0,s=e.length;i<s;i++)o=e[i][n],isNaN(o)||(t.min=Math.min(t.min,o),t.max=Math.max(t.max,o))}function Pe(e){return e*(et/180)}function Bf(e){return e*(180/et)}function br(e){if(!vt(e))return;let t=1,n=0;for(;Math.round(e*t)/t!==e;)t*=10,n++;return n}function Wf(e,t){const n=t.x-e.x,i=t.y-e.y,s=Math.sqrt(n*n+i*i);let o=Math.atan2(i,n);return o<-.5*et&&(o+=Ft),{angle:o,distance:s}}function zs(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function jf(e,t){return(e-t+Rf)%Ft-et}function Jt(e){return(e%Ft+Ft)%Ft}function Ll(e,t,n,i){const s=Jt(e),o=Jt(t),r=Jt(n),a=Jt(o-s),l=Jt(r-s),c=Jt(s-o),u=Jt(s-r);return s===o||s===r||i&&o===r||a>l&&c<u}function xt(e,t,n){return Math.max(t,Math.min(n,e))}function $f(e){return xt(e,-32768,32767)}function Sn(e,t,n,i=1e-6){return e>=Math.min(t,n)-i&&e<=Math.max(t,n)+i}function xo(e,t,n){n=n||(r=>e[r]<t);let i=e.length-1,s=0,o;for(;i-s>1;)o=s+i>>1,n(o)?s=o:i=o;return{lo:s,hi:i}}const De=(e,t,n,i)=>xo(e,n,i?s=>{const o=e[s][t];return o<n||o===n&&e[s+1][t]===n}:s=>e[s][t]<n),Uf=(e,t,n)=>xo(e,n,i=>e[i][t]>=n);function Yf(e,t,n){let i=0,s=e.length;for(;i<s&&e[i]<t;)i++;for(;s>i&&e[s-1]>n;)s--;return i>0||s<e.length?e.slice(i,s):e}const Rl=["push","pop","shift","splice","unshift"];function Xf(e,t){if(e._chartjs){e._chartjs.listeners.push(t);return}Object.defineProperty(e,"_chartjs",{configurable:!0,enumerable:!1,value:{listeners:[t]}}),Rl.forEach(n=>{const i="_onData"+bo(n),s=e[n];Object.defineProperty(e,n,{configurable:!0,enumerable:!1,value(...o){const r=s.apply(this,o);return e._chartjs.listeners.forEach(a=>{typeof a[i]=="function"&&a[i](...o)}),r}})})}function xr(e,t){const n=e._chartjs;if(!n)return;const i=n.listeners,s=i.indexOf(t);s!==-1&&i.splice(s,1),!(i.length>0)&&(Rl.forEach(o=>{delete e[o]}),delete e._chartjs)}function qf(e){const t=new Set(e);return t.size===e.length?e:Array.from(t)}const Nl=(function(){return typeof window>"u"?function(e){return e()}:window.requestAnimationFrame})();function Fl(e,t){let n=[],i=!1;return function(...s){n=s,i||(i=!0,Nl.call(window,()=>{i=!1,e.apply(t,n)}))}}function Gf(e,t){let n;return function(...i){return t?(clearTimeout(n),n=setTimeout(e,t,i)):e.apply(this,i),t}}const zl=e=>e==="start"?"left":e==="end"?"right":"center",ft=(e,t,n)=>e==="start"?t:e==="end"?n:(t+n)/2,Kf=(e,t,n,i)=>e===(i?"left":"right")?n:e==="center"?(t+n)/2:t;function Zf(e,t,n){const i=t.length;let s=0,o=i;if(e._sorted){const{iScale:r,vScale:a,_parsed:l}=e,c=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null,u=r.axis,{min:f,max:d,minDefined:m,maxDefined:y}=r.getUserBounds();if(m){if(s=Math.min(De(l,u,f).lo,n?i:De(t,u,r.getPixelForValue(f)).lo),c){const x=l.slice(0,s+1).reverse().findIndex(v=>!B(v[a.axis]));s-=Math.max(0,x)}s=xt(s,0,i-1)}if(y){let x=Math.max(De(l,r.axis,d,!0).hi+1,n?0:De(t,u,r.getPixelForValue(d),!0).hi+1);if(c){const v=l.slice(x-1).findIndex(w=>!B(w[a.axis]));x+=Math.max(0,v)}o=xt(x,s,i)-s}else o=i-s}return{start:s,count:o}}function Qf(e){const{xScale:t,yScale:n,_scaleRanges:i}=e,s={xmin:t.min,xmax:t.max,ymin:n.min,ymax:n.max};if(!i)return e._scaleRanges=s,!0;const o=i.xmin!==t.min||i.xmax!==t.max||i.ymin!==n.min||i.ymax!==n.max;return Object.assign(i,s),o}const ni=e=>e===0||e===1,yr=(e,t,n)=>-(Math.pow(2,10*(e-=1))*Math.sin((e-t)*Ft/n)),vr=(e,t,n)=>Math.pow(2,-10*e)*Math.sin((e-t)*Ft/n)+1,En={linear:e=>e,easeInQuad:e=>e*e,easeOutQuad:e=>-e*(e-2),easeInOutQuad:e=>(e/=.5)<1?.5*e*e:-.5*(--e*(e-2)-1),easeInCubic:e=>e*e*e,easeOutCubic:e=>(e-=1)*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeInQuart:e=>e*e*e*e,easeOutQuart:e=>-((e-=1)*e*e*e-1),easeInOutQuart:e=>(e/=.5)<1?.5*e*e*e*e:-.5*((e-=2)*e*e*e-2),easeInQuint:e=>e*e*e*e*e,easeOutQuint:e=>(e-=1)*e*e*e*e+1,easeInOutQuint:e=>(e/=.5)<1?.5*e*e*e*e*e:.5*((e-=2)*e*e*e*e+2),easeInSine:e=>-Math.cos(e*kt)+1,easeOutSine:e=>Math.sin(e*kt),easeInOutSine:e=>-.5*(Math.cos(et*e)-1),easeInExpo:e=>e===0?0:Math.pow(2,10*(e-1)),easeOutExpo:e=>e===1?1:-Math.pow(2,-10*e)+1,easeInOutExpo:e=>ni(e)?e:e<.5?.5*Math.pow(2,10*(e*2-1)):.5*(-Math.pow(2,-10*(e*2-1))+2),easeInCirc:e=>e>=1?e:-(Math.sqrt(1-e*e)-1),easeOutCirc:e=>Math.sqrt(1-(e-=1)*e),easeInOutCirc:e=>(e/=.5)<1?-.5*(Math.sqrt(1-e*e)-1):.5*(Math.sqrt(1-(e-=2)*e)+1),easeInElastic:e=>ni(e)?e:yr(e,.075,.3),easeOutElastic:e=>ni(e)?e:vr(e,.075,.3),easeInOutElastic(e){return ni(e)?e:e<.5?.5*yr(e*2,.1125,.45):.5+.5*vr(e*2-1,.1125,.45)},easeInBack(e){return e*e*((1.70158+1)*e-1.70158)},easeOutBack(e){return(e-=1)*e*((1.70158+1)*e+1.70158)+1},easeInOutBack(e){let t=1.70158;return(e/=.5)<1?.5*(e*e*(((t*=1.525)+1)*e-t)):.5*((e-=2)*e*(((t*=1.525)+1)*e+t)+2)},easeInBounce:e=>1-En.easeOutBounce(1-e),easeOutBounce(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375},easeInOutBounce:e=>e<.5?En.easeInBounce(e*2)*.5:En.easeOutBounce(e*2-1)*.5+.5};function yo(e){if(e&&typeof e=="object"){const t=e.toString();return t==="[object CanvasPattern]"||t==="[object CanvasGradient]"}return!1}function _r(e){return yo(e)?e:new In(e)}function ns(e){return yo(e)?e:new In(e).saturate(.5).darken(.1).hexString()}const Jf=["x","y","borderWidth","radius","tension"],td=["color","borderColor","backgroundColor"];function ed(e){e.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),e.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:t=>t!=="onProgress"&&t!=="onComplete"&&t!=="fn"}),e.set("animations",{colors:{type:"color",properties:td},numbers:{type:"number",properties:Jf}}),e.describe("animations",{_fallback:"animation"}),e.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:t=>t|0}}}})}function nd(e){e.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const wr=new Map;function id(e,t){t=t||{};const n=e+JSON.stringify(t);let i=wr.get(n);return i||(i=new Intl.NumberFormat(e,t),wr.set(n,i)),i}function Hl(e,t,n){return id(t,n).format(e)}const sd={values(e){return tt(e)?e:""+e},numeric(e,t,n){if(e===0)return"0";const i=this.chart.options.locale;let s,o=e;if(n.length>1){const c=Math.max(Math.abs(n[0].value),Math.abs(n[n.length-1].value));(c<1e-4||c>1e15)&&(s="scientific"),o=od(e,n)}const r=Il(Math.abs(o)),a=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),l={notation:s,minimumFractionDigits:a,maximumFractionDigits:a};return Object.assign(l,this.options.ticks.format),Hl(e,i,l)}};function od(e,t){let n=t.length>3?t[2].value-t[1].value:t[1].value-t[0].value;return Math.abs(n)>=1&&e!==Math.floor(e)&&(n=e-Math.floor(e)),n}var Vl={formatters:sd};function rd(e){e.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(t,n)=>n.lineWidth,tickColor:(t,n)=>n.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:Vl.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),e.route("scale.ticks","color","","color"),e.route("scale.grid","color","","borderColor"),e.route("scale.border","color","","borderColor"),e.route("scale.title","color","","color"),e.describe("scale",{_fallback:!1,_scriptable:t=>!t.startsWith("before")&&!t.startsWith("after")&&t!=="callback"&&t!=="parser",_indexable:t=>t!=="borderDash"&&t!=="tickBorderDash"&&t!=="dash"}),e.describe("scales",{_fallback:"scale"}),e.describe("scale.ticks",{_scriptable:t=>t!=="backdropPadding"&&t!=="callback",_indexable:t=>t!=="backdropPadding"})}const ze=Object.create(null),Hs=Object.create(null);function Cn(e,t){if(!t)return e;const n=t.split(".");for(let i=0,s=n.length;i<s;++i){const o=n[i];e=e[o]||(e[o]=Object.create(null))}return e}function is(e,t,n){return typeof t=="string"?Ln(Cn(e,t),n):Ln(Cn(e,""),t)}class ad{constructor(t,n){this.animation=void 0,this.backgroundColor="rgba(0,0,0,0.1)",this.borderColor="rgba(0,0,0,0.1)",this.color="#666",this.datasets={},this.devicePixelRatio=i=>i.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(i,s)=>ns(s.backgroundColor),this.hoverBorderColor=(i,s)=>ns(s.borderColor),this.hoverColor=(i,s)=>ns(s.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(t),this.apply(n)}set(t,n){return is(this,t,n)}get(t){return Cn(this,t)}describe(t,n){return is(Hs,t,n)}override(t,n){return is(ze,t,n)}route(t,n,i,s){const o=Cn(this,t),r=Cn(this,i),a="_"+n;Object.defineProperties(o,{[a]:{value:o[n],writable:!0},[n]:{enumerable:!0,get(){const l=this[a],c=r[s];return V(l)?Object.assign({},c,l):R(l,c)},set(l){this[a]=l}}})}apply(t){t.forEach(n=>n(this))}}var Y=new ad({_scriptable:e=>!e.startsWith("on"),_indexable:e=>e!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[ed,nd,rd]);function ld(e){return!e||B(e.size)||B(e.family)?null:(e.style?e.style+" ":"")+(e.weight?e.weight+" ":"")+e.size+"px "+e.family}function Sr(e,t,n,i,s){let o=t[s];return o||(o=t[s]=e.measureText(s).width,n.push(s)),o>i&&(i=o),i}function ke(e,t,n){const i=e.currentDevicePixelRatio,s=n!==0?Math.max(n/2,.5):0;return Math.round((t-s)*i)/i+s}function kr(e,t){!t&&!e||(t=t||e.getContext("2d"),t.save(),t.resetTransform(),t.clearRect(0,0,e.width,e.height),t.restore())}function Vs(e,t,n,i){Bl(e,t,n,i,null)}function Bl(e,t,n,i,s){let o,r,a,l,c,u,f,d;const m=t.pointStyle,y=t.rotation,x=t.radius;let v=(y||0)*Nf;if(m&&typeof m=="object"&&(o=m.toString(),o==="[object HTMLImageElement]"||o==="[object HTMLCanvasElement]")){e.save(),e.translate(n,i),e.rotate(v),e.drawImage(m,-m.width/2,-m.height/2,m.width,m.height),e.restore();return}if(!(isNaN(x)||x<=0)){switch(e.beginPath(),m){default:s?e.ellipse(n,i,s/2,x,0,0,Ft):e.arc(n,i,x,0,Ft),e.closePath();break;case"triangle":u=s?s/2:x,e.moveTo(n+Math.sin(v)*u,i-Math.cos(v)*x),v+=gr,e.lineTo(n+Math.sin(v)*u,i-Math.cos(v)*x),v+=gr,e.lineTo(n+Math.sin(v)*u,i-Math.cos(v)*x),e.closePath();break;case"rectRounded":c=x*.516,l=x-c,r=Math.cos(v+Se)*l,f=Math.cos(v+Se)*(s?s/2-c:l),a=Math.sin(v+Se)*l,d=Math.sin(v+Se)*(s?s/2-c:l),e.arc(n-f,i-a,c,v-et,v-kt),e.arc(n+d,i-r,c,v-kt,v),e.arc(n+f,i+a,c,v,v+kt),e.arc(n-d,i+r,c,v+kt,v+et),e.closePath();break;case"rect":if(!y){l=Math.SQRT1_2*x,u=s?s/2:l,e.rect(n-u,i-l,2*u,2*l);break}v+=Se;case"rectRot":f=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,d=Math.sin(v)*(s?s/2:x),e.moveTo(n-f,i-a),e.lineTo(n+d,i-r),e.lineTo(n+f,i+a),e.lineTo(n-d,i+r),e.closePath();break;case"crossRot":v+=Se;case"cross":f=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,d=Math.sin(v)*(s?s/2:x),e.moveTo(n-f,i-a),e.lineTo(n+f,i+a),e.moveTo(n+d,i-r),e.lineTo(n-d,i+r);break;case"star":f=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,d=Math.sin(v)*(s?s/2:x),e.moveTo(n-f,i-a),e.lineTo(n+f,i+a),e.moveTo(n+d,i-r),e.lineTo(n-d,i+r),v+=Se,f=Math.cos(v)*(s?s/2:x),r=Math.cos(v)*x,a=Math.sin(v)*x,d=Math.sin(v)*(s?s/2:x),e.moveTo(n-f,i-a),e.lineTo(n+f,i+a),e.moveTo(n+d,i-r),e.lineTo(n-d,i+r);break;case"line":r=s?s/2:Math.cos(v)*x,a=Math.sin(v)*x,e.moveTo(n-r,i-a),e.lineTo(n+r,i+a);break;case"dash":e.moveTo(n,i),e.lineTo(n+Math.cos(v)*(s?s/2:x),i+Math.sin(v)*x);break;case!1:e.closePath();break}e.fill(),t.borderWidth>0&&e.stroke()}}function en(e,t,n){return n=n||.5,!t||e&&e.x>t.left-n&&e.x<t.right+n&&e.y>t.top-n&&e.y<t.bottom+n}function vo(e,t){e.save(),e.beginPath(),e.rect(t.left,t.top,t.right-t.left,t.bottom-t.top),e.clip()}function _o(e){e.restore()}function cd(e,t,n,i,s){if(!t)return e.lineTo(n.x,n.y);if(s==="middle"){const o=(t.x+n.x)/2;e.lineTo(o,t.y),e.lineTo(o,n.y)}else s==="after"!=!!i?e.lineTo(t.x,n.y):e.lineTo(n.x,t.y);e.lineTo(n.x,n.y)}function ud(e,t,n,i){if(!t)return e.lineTo(n.x,n.y);e.bezierCurveTo(i?t.cp1x:t.cp2x,i?t.cp1y:t.cp2y,i?n.cp2x:n.cp1x,i?n.cp2y:n.cp1y,n.x,n.y)}function hd(e,t){t.translation&&e.translate(t.translation[0],t.translation[1]),B(t.rotation)||e.rotate(t.rotation),t.color&&(e.fillStyle=t.color),t.textAlign&&(e.textAlign=t.textAlign),t.textBaseline&&(e.textBaseline=t.textBaseline)}function fd(e,t,n,i,s){if(s.strikethrough||s.underline){const o=e.measureText(i),r=t-o.actualBoundingBoxLeft,a=t+o.actualBoundingBoxRight,l=n-o.actualBoundingBoxAscent,c=n+o.actualBoundingBoxDescent,u=s.strikethrough?(l+c)/2:c;e.strokeStyle=e.fillStyle,e.beginPath(),e.lineWidth=s.decorationWidth||2,e.moveTo(r,u),e.lineTo(a,u),e.stroke()}}function dd(e,t){const n=e.fillStyle;e.fillStyle=t.color,e.fillRect(t.left,t.top,t.width,t.height),e.fillStyle=n}function Pi(e,t,n,i,s,o={}){const r=tt(t)?t:[t],a=o.strokeWidth>0&&o.strokeColor!=="";let l,c;for(e.save(),e.font=s.string,hd(e,o),l=0;l<r.length;++l)c=r[l],o.backdrop&&dd(e,o.backdrop),a&&(o.strokeColor&&(e.strokeStyle=o.strokeColor),B(o.strokeWidth)||(e.lineWidth=o.strokeWidth),e.strokeText(c,n,i,o.maxWidth)),e.fillText(c,n,i,o.maxWidth),fd(e,n,i,c,o),i+=Number(s.lineHeight);e.restore()}function Bs(e,t){const{x:n,y:i,w:s,h:o,radius:r}=t;e.arc(n+r.topLeft,i+r.topLeft,r.topLeft,1.5*et,et,!0),e.lineTo(n,i+o-r.bottomLeft),e.arc(n+r.bottomLeft,i+o-r.bottomLeft,r.bottomLeft,et,kt,!0),e.lineTo(n+s-r.bottomRight,i+o),e.arc(n+s-r.bottomRight,i+o-r.bottomRight,r.bottomRight,kt,0,!0),e.lineTo(n+s,i+r.topRight),e.arc(n+s-r.topRight,i+r.topRight,r.topRight,0,-kt,!0),e.lineTo(n+r.topLeft,i)}const pd=/^(normal|(\\d+(?:\\.\\d+)?)(px|em|%)?)$/,gd=/^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;function md(e,t){const n=(""+e).match(pd);if(!n||n[1]==="normal")return t*1.2;switch(e=+n[2],n[3]){case"px":return e;case"%":e/=100;break}return t*e}const bd=e=>+e||0;function Wl(e,t){const n={},i=V(t),s=i?Object.keys(t):t,o=V(e)?i?r=>R(e[r],e[t[r]]):r=>e[r]:()=>e;for(const r of s)n[r]=bd(o(r));return n}function xd(e){return Wl(e,{top:"y",right:"x",bottom:"y",left:"x"})}function On(e){return Wl(e,["topLeft","topRight","bottomLeft","bottomRight"])}function Mt(e){const t=xd(e);return t.width=t.left+t.right,t.height=t.top+t.bottom,t}function ht(e,t){e=e||{},t=t||Y.font;let n=R(e.size,t.size);typeof n=="string"&&(n=parseInt(n,10));let i=R(e.style,t.style);i&&!(""+i).match(gd)&&(console.warn('Invalid font style specified: "'+i+'"'),i=void 0);const s={family:R(e.family,t.family),lineHeight:md(R(e.lineHeight,t.lineHeight),n),size:n,style:i,weight:R(e.weight,t.weight),string:""};return s.string=ld(s),s}function ii(e,t,n,i){let s,o,r;for(s=0,o=e.length;s<o;++s)if(r=e[s],r!==void 0&&r!==void 0)return r}function yd(e,t,n){const{min:i,max:s}=e,o=Of(t,(s-i)/2),r=(a,l)=>n&&a===0?0:a+l;return{min:r(i,-Math.abs(o)),max:r(s,o)}}function Ve(e,t){return Object.assign(Object.create(e),t)}function wo(e,t=[""],n,i,s=()=>e[0]){const o=n||e;typeof i>"u"&&(i=Yl("_fallback",e));const r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:e,_rootScopes:o,_fallback:i,_getTarget:s,override:a=>wo([a,...e],t,o,i)};return new Proxy(r,{deleteProperty(a,l){return delete a[l],delete a._keys,delete e[0][l],!0},get(a,l){return $l(a,l,()=>Ed(l,t,e,a))},getOwnPropertyDescriptor(a,l){return Reflect.getOwnPropertyDescriptor(a._scopes[0],l)},getPrototypeOf(){return Reflect.getPrototypeOf(e[0])},has(a,l){return Mr(a).includes(l)},ownKeys(a){return Mr(a)},set(a,l,c){const u=a._storage||(a._storage=s());return a[l]=u[l]=c,delete a._keys,!0}})}function nn(e,t,n,i){const s={_cacheable:!1,_proxy:e,_context:t,_subProxy:n,_stack:new Set,_descriptors:jl(e,i),setContext:o=>nn(e,o,n,i),override:o=>nn(e.override(o),t,n,i)};return new Proxy(s,{deleteProperty(o,r){return delete o[r],delete e[r],!0},get(o,r,a){return $l(o,r,()=>_d(o,r,a))},getOwnPropertyDescriptor(o,r){return o._descriptors.allKeys?Reflect.has(e,r)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(e,r)},getPrototypeOf(){return Reflect.getPrototypeOf(e)},has(o,r){return Reflect.has(e,r)},ownKeys(){return Reflect.ownKeys(e)},set(o,r,a){return e[r]=a,delete o[r],!0}})}function jl(e,t={scriptable:!0,indexable:!0}){const{_scriptable:n=t.scriptable,_indexable:i=t.indexable,_allKeys:s=t.allKeys}=e;return{allKeys:s,scriptable:n,indexable:i,isScriptable:ue(n)?n:()=>n,isIndexable:ue(i)?i:()=>i}}const vd=(e,t)=>e?e+bo(t):t,So=(e,t)=>V(t)&&e!=="adapters"&&(Object.getPrototypeOf(t)===null||t.constructor===Object);function $l(e,t,n){if(Object.prototype.hasOwnProperty.call(e,t)||t==="constructor")return e[t];const i=n();return e[t]=i,i}function _d(e,t,n){const{_proxy:i,_context:s,_subProxy:o,_descriptors:r}=e;let a=i[t];return ue(a)&&r.isScriptable(t)&&(a=wd(t,a,e,n)),tt(a)&&a.length&&(a=Sd(t,a,e,r.isIndexable)),So(t,a)&&(a=nn(a,s,o&&o[t],r)),a}function wd(e,t,n,i){const{_proxy:s,_context:o,_subProxy:r,_stack:a}=n;if(a.has(e))throw new Error("Recursion detected: "+Array.from(a).join("->")+"->"+e);a.add(e);let l=t(o,r||i);return a.delete(e),So(e,l)&&(l=ko(s._scopes,s,e,l)),l}function Sd(e,t,n,i){const{_proxy:s,_context:o,_subProxy:r,_descriptors:a}=n;if(typeof o.index<"u"&&i(e))return t[o.index%t.length];if(V(t[0])){const l=t,c=s._scopes.filter(u=>u!==l);t=[];for(const u of l){const f=ko(c,s,e,u);t.push(nn(f,o,r&&r[e],a))}}return t}function Ul(e,t,n){return ue(e)?e(t,n):e}const kd=(e,t)=>e===!0?t:typeof e=="string"?Ei(t,e):void 0;function Td(e,t,n,i,s){for(const o of t){const r=kd(n,o);if(r){e.add(r);const a=Ul(r._fallback,n,s);if(typeof a<"u"&&a!==n&&a!==i)return a}else if(r===!1&&typeof i<"u"&&n!==i)return null}return!1}function ko(e,t,n,i){const s=t._rootScopes,o=Ul(t._fallback,n,i),r=[...e,...s],a=new Set;a.add(i);let l=Tr(a,r,n,o||n,i);return l===null||typeof o<"u"&&o!==n&&(l=Tr(a,r,o,l,i),l===null)?!1:wo(Array.from(a),[""],s,o,()=>Md(t,n,i))}function Tr(e,t,n,i,s){for(;n;)n=Td(e,t,n,i,s);return n}function Md(e,t,n){const i=e._getTarget();t in i||(i[t]={});const s=i[t];return tt(s)&&V(n)?n:s||{}}function Ed(e,t,n,i){let s;for(const o of t)if(s=Yl(vd(o,e),n),typeof s<"u")return So(e,s)?ko(n,i,e,s):s}function Yl(e,t){for(const n of t){if(!n)continue;const i=n[e];if(typeof i<"u")return i}}function Mr(e){let t=e._keys;return t||(t=e._keys=Cd(e._scopes)),t}function Cd(e){const t=new Set;for(const n of e)for(const i of Object.keys(n).filter(s=>!s.startsWith("_")))t.add(i);return Array.from(t)}const Od=Number.EPSILON||1e-14,sn=(e,t)=>t<e.length&&!e[t].skip&&e[t],Xl=e=>e==="x"?"y":"x";function Pd(e,t,n,i){const s=e.skip?t:e,o=t,r=n.skip?t:n,a=zs(o,s),l=zs(r,o);let c=a/(a+l),u=l/(a+l);c=isNaN(c)?0:c,u=isNaN(u)?0:u;const f=i*c,d=i*u;return{previous:{x:o.x-f*(r.x-s.x),y:o.y-f*(r.y-s.y)},next:{x:o.x+d*(r.x-s.x),y:o.y+d*(r.y-s.y)}}}function Dd(e,t,n){const i=e.length;let s,o,r,a,l,c=sn(e,0);for(let u=0;u<i-1;++u)if(l=c,c=sn(e,u+1),!(!l||!c)){if(Ie(t[u],0,Od)){n[u]=n[u+1]=0;continue}s=n[u]/t[u],o=n[u+1]/t[u],a=Math.pow(s,2)+Math.pow(o,2),!(a<=9)&&(r=3/Math.sqrt(a),n[u]=s*r*t[u],n[u+1]=o*r*t[u])}}function Ad(e,t,n="x"){const i=Xl(n),s=e.length;let o,r,a,l=sn(e,0);for(let c=0;c<s;++c){if(r=a,a=l,l=sn(e,c+1),!a)continue;const u=a[n],f=a[i];r&&(o=(u-r[n])/3,a[\`cp1\${n}\`]=u-o,a[\`cp1\${i}\`]=f-o*t[c]),l&&(o=(l[n]-u)/3,a[\`cp2\${n}\`]=u+o,a[\`cp2\${i}\`]=f+o*t[c])}}function Id(e,t="x"){const n=Xl(t),i=e.length,s=Array(i).fill(0),o=Array(i);let r,a,l,c=sn(e,0);for(r=0;r<i;++r)if(a=l,l=c,c=sn(e,r+1),!!l){if(c){const u=c[t]-l[t];s[r]=u!==0?(c[n]-l[n])/u:0}o[r]=a?c?he(s[r-1])!==he(s[r])?0:(s[r-1]+s[r])/2:s[r-1]:s[r]}Dd(e,s,o),Ad(e,o,t)}function si(e,t,n){return Math.max(Math.min(e,n),t)}function Ld(e,t){let n,i,s,o,r,a=en(e[0],t);for(n=0,i=e.length;n<i;++n)r=o,o=a,a=n<i-1&&en(e[n+1],t),o&&(s=e[n],r&&(s.cp1x=si(s.cp1x,t.left,t.right),s.cp1y=si(s.cp1y,t.top,t.bottom)),a&&(s.cp2x=si(s.cp2x,t.left,t.right),s.cp2y=si(s.cp2y,t.top,t.bottom)))}function Rd(e,t,n,i,s){let o,r,a,l;if(t.spanGaps&&(e=e.filter(c=>!c.skip)),t.cubicInterpolationMode==="monotone")Id(e,s);else{let c=i?e[e.length-1]:e[0];for(o=0,r=e.length;o<r;++o)a=e[o],l=Pd(c,a,e[Math.min(o+1,r-(i?0:1))%r],t.tension),a.cp1x=l.previous.x,a.cp1y=l.previous.y,a.cp2x=l.next.x,a.cp2y=l.next.y,c=a}t.capBezierPoints&&Ld(e,n)}function To(){return typeof window<"u"&&typeof document<"u"}function Mo(e){let t=e.parentNode;return t&&t.toString()==="[object ShadowRoot]"&&(t=t.host),t}function Di(e,t,n){let i;return typeof e=="string"?(i=parseInt(e,10),e.indexOf("%")!==-1&&(i=i/100*t.parentNode[n])):i=e,i}const Vi=e=>e.ownerDocument.defaultView.getComputedStyle(e,null);function Nd(e,t){return Vi(e).getPropertyValue(t)}const Fd=["top","right","bottom","left"];function Le(e,t,n){const i={};n=n?"-"+n:"";for(let s=0;s<4;s++){const o=Fd[s];i[o]=parseFloat(e[t+"-"+o+n])||0}return i.width=i.left+i.right,i.height=i.top+i.bottom,i}const zd=(e,t,n)=>(e>0||t>0)&&(!n||!n.shadowRoot);function Hd(e,t){const n=e.touches,i=n&&n.length?n[0]:e,{offsetX:s,offsetY:o}=i;let r=!1,a,l;if(zd(s,o,e.target))a=s,l=o;else{const c=t.getBoundingClientRect();a=i.clientX-c.left,l=i.clientY-c.top,r=!0}return{x:a,y:l,box:r}}function It(e,t){if("native"in e)return e;const{canvas:n,currentDevicePixelRatio:i}=t,s=Vi(n),o=s.boxSizing==="border-box",r=Le(s,"padding"),a=Le(s,"border","width"),{x:l,y:c,box:u}=Hd(e,n),f=r.left+(u&&a.left),d=r.top+(u&&a.top);let{width:m,height:y}=t;return o&&(m-=r.width+a.width,y-=r.height+a.height),{x:Math.round((l-f)/m*n.width/i),y:Math.round((c-d)/y*n.height/i)}}function Vd(e,t,n){let i,s;if(t===void 0||n===void 0){const o=e&&Mo(e);if(!o)t=e.clientWidth,n=e.clientHeight;else{const r=o.getBoundingClientRect(),a=Vi(o),l=Le(a,"border","width"),c=Le(a,"padding");t=r.width-c.width-l.width,n=r.height-c.height-l.height,i=Di(a.maxWidth,o,"clientWidth"),s=Di(a.maxHeight,o,"clientHeight")}}return{width:t,height:n,maxWidth:i||Oi,maxHeight:s||Oi}}const oi=e=>Math.round(e*10)/10;function Bd(e,t,n,i){const s=Vi(e),o=Le(s,"margin"),r=Di(s.maxWidth,e,"clientWidth")||Oi,a=Di(s.maxHeight,e,"clientHeight")||Oi,l=Vd(e,t,n);let{width:c,height:u}=l;if(s.boxSizing==="content-box"){const d=Le(s,"border","width"),m=Le(s,"padding");c-=m.width+d.width,u-=m.height+d.height}return c=Math.max(0,c-o.width),u=Math.max(0,i?c/i:u-o.height),c=oi(Math.min(c,r,l.maxWidth)),u=oi(Math.min(u,a,l.maxHeight)),c&&!u&&(u=oi(c/2)),(t!==void 0||n!==void 0)&&i&&l.height&&u>l.height&&(u=l.height,c=oi(Math.floor(u*i))),{width:c,height:u}}function Er(e,t,n){const i=t||1,s=Math.floor(e.height*i),o=Math.floor(e.width*i);e.height=Math.floor(e.height),e.width=Math.floor(e.width);const r=e.canvas;return r.style&&(n||!r.style.height&&!r.style.width)&&(r.style.height=\`\${e.height}px\`,r.style.width=\`\${e.width}px\`),e.currentDevicePixelRatio!==i||r.height!==s||r.width!==o?(e.currentDevicePixelRatio=i,r.height=s,r.width=o,e.ctx.setTransform(i,0,0,i,0,0),!0):!1}const Wd=(function(){let e=!1;try{const t={get passive(){return e=!0,!1}};To()&&(window.addEventListener("test",null,t),window.removeEventListener("test",null,t))}catch{}return e})();function Cr(e,t){const n=Nd(e,t),i=n&&n.match(/^(\\d+)(\\.\\d+)?px$/);return i?+i[1]:void 0}function Me(e,t,n,i){return{x:e.x+n*(t.x-e.x),y:e.y+n*(t.y-e.y)}}function jd(e,t,n,i){return{x:e.x+n*(t.x-e.x),y:i==="middle"?n<.5?e.y:t.y:i==="after"?n<1?e.y:t.y:n>0?t.y:e.y}}function $d(e,t,n,i){const s={x:e.cp2x,y:e.cp2y},o={x:t.cp1x,y:t.cp1y},r=Me(e,s,n),a=Me(s,o,n),l=Me(o,t,n),c=Me(r,a,n),u=Me(a,l,n);return Me(c,u,n)}const Ud=function(e,t){return{x(n){return e+e+t-n},setWidth(n){t=n},textAlign(n){return n==="center"?n:n==="right"?"left":"right"},xPlus(n,i){return n-i},leftForLtr(n,i){return n-i}}},Yd=function(){return{x(e){return e},setWidth(e){},textAlign(e){return e},xPlus(e,t){return e+t},leftForLtr(e,t){return e}}};function Ge(e,t,n){return e?Ud(t,n):Yd()}function ql(e,t){let n,i;(t==="ltr"||t==="rtl")&&(n=e.canvas.style,i=[n.getPropertyValue("direction"),n.getPropertyPriority("direction")],n.setProperty("direction",t,"important"),e.prevTextDirection=i)}function Gl(e,t){t!==void 0&&(delete e.prevTextDirection,e.canvas.style.setProperty("direction",t[0],t[1]))}function Kl(e){return e==="angle"?{between:Ll,compare:jf,normalize:Jt}:{between:Sn,compare:(t,n)=>t-n,normalize:t=>t}}function Or({start:e,end:t,count:n,loop:i,style:s}){return{start:e%n,end:t%n,loop:i&&(t-e+1)%n===0,style:s}}function Xd(e,t,n){const{property:i,start:s,end:o}=n,{between:r,normalize:a}=Kl(i),l=t.length;let{start:c,end:u,loop:f}=e,d,m;if(f){for(c+=l,u+=l,d=0,m=l;d<m&&r(a(t[c%l][i]),s,o);++d)c--,u--;c%=l,u%=l}return u<c&&(u+=l),{start:c,end:u,loop:f,style:e.style}}function qd(e,t,n){if(!n)return[e];const{property:i,start:s,end:o}=n,r=t.length,{compare:a,between:l,normalize:c}=Kl(i),{start:u,end:f,loop:d,style:m}=Xd(e,t,n),y=[];let x=!1,v=null,w,k,E;const C=()=>l(s,E,w)&&a(s,E)!==0,T=()=>a(o,w)===0||l(o,E,w),D=()=>x||C(),P=()=>!x||T();for(let O=u,A=u;O<=f;++O)k=t[O%r],!k.skip&&(w=c(k[i]),w!==E&&(x=l(w,s,o),v===null&&D()&&(v=a(w,s)===0?O:A),v!==null&&P()&&(y.push(Or({start:v,end:O,loop:d,count:r,style:m})),v=null),A=O,E=w));return v!==null&&y.push(Or({start:v,end:f,loop:d,count:r,style:m})),y}function Gd(e,t){const n=[],i=e.segments;for(let s=0;s<i.length;s++){const o=qd(i[s],e.points,t);o.length&&n.push(...o)}return n}function Kd(e,t,n,i){let s=0,o=t-1;if(n&&!i)for(;s<t&&!e[s].skip;)s++;for(;s<t&&e[s].skip;)s++;for(s%=t,n&&(o+=s);o>s&&e[o%t].skip;)o--;return o%=t,{start:s,end:o}}function Zd(e,t,n,i){const s=e.length,o=[];let r=t,a=e[t],l;for(l=t+1;l<=n;++l){const c=e[l%s];c.skip||c.stop?a.skip||(i=!1,o.push({start:t%s,end:(l-1)%s,loop:i}),t=r=c.stop?l:null):(r=l,a.skip&&(t=l)),a=c}return r!==null&&o.push({start:t%s,end:r%s,loop:i}),o}function Qd(e,t){const n=e.points,i=e.options.spanGaps,s=n.length;if(!s)return[];const o=!!e._loop,{start:r,end:a}=Kd(n,s,o,i);if(i===!0)return Pr(e,[{start:r,end:a,loop:o}],n,t);const l=a<r?a+s:a,c=!!e._fullLoop&&r===0&&a===s-1;return Pr(e,Zd(n,r,l,c),n,t)}function Pr(e,t,n,i){return!i||!i.setContext||!n?t:Jd(e,t,n,i)}function Jd(e,t,n,i){const s=e._chart.getContext(),o=Dr(e.options),{_datasetIndex:r,options:{spanGaps:a}}=e,l=n.length,c=[];let u=o,f=t[0].start,d=f;function m(y,x,v,w){const k=a?-1:1;if(y!==x){for(y+=l;n[y%l].skip;)y-=k;for(;n[x%l].skip;)x+=k;y%l!==x%l&&(c.push({start:y%l,end:x%l,loop:v,style:w}),u=w,f=x%l)}}for(const y of t){f=a?f:y.start;let x=n[f%l],v;for(d=f+1;d<=y.end;d++){const w=n[d%l];v=Dr(i.setContext(Ve(s,{type:"segment",p0:x,p1:w,p0DataIndex:(d-1)%l,p1DataIndex:d%l,datasetIndex:r}))),tp(v,u)&&m(f,d-1,y.loop,u),x=w,u=v}f<d-1&&m(f,d-1,y.loop,u)}return c}function Dr(e){return{backgroundColor:e.backgroundColor,borderCapStyle:e.borderCapStyle,borderDash:e.borderDash,borderDashOffset:e.borderDashOffset,borderJoinStyle:e.borderJoinStyle,borderWidth:e.borderWidth,borderColor:e.borderColor}}function tp(e,t){if(!t)return!1;const n=[],i=function(s,o){return yo(o)?(n.includes(o)||n.push(o),n.indexOf(o)):o};return JSON.stringify(e,i)!==JSON.stringify(t,i)}function ri(e,t,n){return e.options.clip?e[n]:t[n]}function ep(e,t){const{xScale:n,yScale:i}=e;return n&&i?{left:ri(n,t,"left"),right:ri(n,t,"right"),top:ri(i,t,"top"),bottom:ri(i,t,"bottom")}:t}function np(e,t){const n=t._clip;if(n.disabled)return!1;const i=ep(t,e.chartArea);return{left:n.left===!1?0:i.left-(n.left===!0?0:n.left),right:n.right===!1?e.width:i.right+(n.right===!0?0:n.right),top:n.top===!1?0:i.top-(n.top===!0?0:n.top),bottom:n.bottom===!1?e.height:i.bottom+(n.bottom===!0?0:n.bottom)}}/*!
9136
9289
  * Chart.js v4.5.0
9137
9290
  * https://www.chartjs.org
9138
9291
  * (c) 2025 Chart.js Contributors
9139
9292
  * Released under the MIT License
9140
- */class np{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,n,i,s){const o=n.listeners[s],r=n.duration;o.forEach(a=>a({chart:t,initial:n.initial,numSteps:r,currentStep:Math.min(i-n.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=Ll.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let n=0;this._charts.forEach((i,s)=>{if(!i.running||!i.items.length)return;const o=i.items;let r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>i.duration&&(i.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(s.draw(),this._notify(s,i,t,"progress")),o.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),n+=o.length}),this._lastDate=t,n===0&&(this._running=!1)}_getAnims(t){const n=this._charts;let i=n.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(t,i)),i}listen(t,n,i){this._getAnims(t).listeners[n].push(i)}add(t,n){!n||!n.length||this._getAnims(t).items.push(...n)}has(t){return this._getAnims(t).items.length>0}start(t){const n=this._charts.get(t);n&&(n.running=!0,n.start=Date.now(),n.duration=n.items.reduce((i,s)=>Math.max(i,s._duration),0),this._refresh())}running(t){if(!this._running)return!1;const n=this._charts.get(t);return!(!n||!n.running||!n.items.length)}stop(t){const n=this._charts.get(t);if(!n||!n.items.length)return;const i=n.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();n.items=[],this._notify(t,n,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var $t=new np;const Dr="transparent",ip={boolean(e,t,n){return n>.5?t:e},color(e,t,n){const i=vr(e||Dr),s=i.valid&&vr(t||Dr);return s&&s.valid?s.mix(i,n).hexString():t},number(e,t,n){return e+(t-e)*n}};class sp{constructor(t,n,i,s){const o=n[i];s=si([t.to,s,o,t.from]);const r=si([t.from,o,s]);this._active=!0,this._fn=t.fn||ip[t.type||typeof r],this._easing=En[t.easing]||En.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=n,this._prop=i,this._from=r,this._to=s,this._promises=void 0}active(){return this._active}update(t,n,i){if(this._active){this._notify(!1);const s=this._target[this._prop],o=i-this._start,r=this._duration-o;this._start=i,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=si([t.to,n,s,t.from]),this._from=si([t.from,s,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const n=t-this._start,i=this._duration,s=this._prop,o=this._from,r=this._loop,a=this._to;let l;if(this._active=o!==a&&(r||n<i),!this._active){this._target[s]=a,this._notify(!0);return}if(n<0){this._target[s]=o;return}l=n/i%2,l=r&&l>1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[s]=this._fn(o,a,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((n,i)=>{t.push({res:n,rej:i})})}_notify(t){const n=t?"res":"rej",i=this._promises||[];for(let s=0;s<i.length;s++)i[s][n]()}}class Gl{constructor(t,n){this._chart=t,this._properties=new Map,this.configure(n)}configure(t){if(!V(t))return;const n=Object.keys(Y.animation),i=this._properties;Object.getOwnPropertyNames(t).forEach(s=>{const o=t[s];if(!V(o))return;const r={};for(const a of n)r[a]=o[a];(tt(o.properties)&&o.properties||[s]).forEach(a=>{(a===s||!i.has(a))&&i.set(a,r)})})}_animateOptions(t,n){const i=n.options,s=rp(t,i);if(!s)return[];const o=this._createAnimations(s,i);return i.$shared&&op(t.options.$animations,i).then(()=>{t.options=i},()=>{}),o}_createAnimations(t,n){const i=this._properties,s=[],o=t.$animations||(t.$animations={}),r=Object.keys(n),a=Date.now();let l;for(l=r.length-1;l>=0;--l){const c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){s.push(...this._animateOptions(t,n));continue}const u=n[c];let f=o[c];const d=i.get(c);if(f)if(d&&f.active()){f.update(d,u,a);continue}else f.cancel();if(!d||!d.duration){t[c]=u;continue}o[c]=f=new sp(d,t,c,u),s.push(f)}return s}update(t,n){if(this._properties.size===0){Object.assign(t,n);return}const i=this._createAnimations(t,n);if(i.length)return $t.add(this._chart,i),!0}}function op(e,t){const n=[],i=Object.keys(t);for(let s=0;s<i.length;s++){const o=e[i[s]];o&&o.active()&&n.push(o.wait())}return Promise.all(n)}function rp(e,t){if(!t)return;let n=e.options;if(!n){e.options=t;return}return n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n}function Ar(e,t){const n=e&&e.options||{},i=n.reverse,s=n.min===void 0?t:0,o=n.max===void 0?t:0;return{start:i?o:s,end:i?s:o}}function ap(e,t,n){if(n===!1)return!1;const i=Ar(e,n),s=Ar(t,n);return{top:s.end,right:i.end,bottom:s.start,left:i.start}}function lp(e){let t,n,i,s;return V(e)?(t=e.top,n=e.right,i=e.bottom,s=e.left):t=n=i=s=e,{top:t,right:n,bottom:i,left:s,disabled:e===!1}}function Kl(e,t){const n=[],i=e._getSortedDatasetMetas(t);let s,o;for(s=0,o=i.length;s<o;++s)n.push(i[s].index);return n}function Ir(e,t,n,i={}){const s=e.keys,o=i.mode==="single";let r,a,l,c;if(t===null)return;let u=!1;for(r=0,a=s.length;r<a;++r){if(l=+s[r],l===n){if(u=!0,i.all)continue;break}c=e.values[l],vt(c)&&(o||t===0||he(t)===he(c))&&(t+=c)}return!u&&!i.all?0:t}function cp(e,t){const{iScale:n,vScale:i}=t,s=n.axis==="x"?"x":"y",o=i.axis==="x"?"x":"y",r=Object.keys(e),a=new Array(r.length);let l,c,u;for(l=0,c=r.length;l<c;++l)u=r[l],a[l]={[s]:u,[o]:e[u]};return a}function ss(e,t){const n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function up(e,t,n){return\`\${e.id}.\${t.id}.\${n.stack||n.type}\`}function hp(e){const{min:t,max:n,minDefined:i,maxDefined:s}=e.getUserBounds();return{min:i?t:Number.NEGATIVE_INFINITY,max:s?n:Number.POSITIVE_INFINITY}}function fp(e,t,n){const i=e[t]||(e[t]={});return i[n]||(i[n]={})}function Lr(e,t,n,i){for(const s of t.getMatchingVisibleMetas(i).reverse()){const o=e[s.index];if(n&&o>0||!n&&o<0)return s.index}return null}function Rr(e,t){const{chart:n,_cachedMeta:i}=e,s=n._stacks||(n._stacks={}),{iScale:o,vScale:r,index:a}=i,l=o.axis,c=r.axis,u=up(o,r,i),f=t.length;let d;for(let m=0;m<f;++m){const y=t[m],{[l]:x,[c]:v}=y,w=y._stacks||(y._stacks={});d=w[c]=fp(s,u,x),d[a]=v,d._top=Lr(d,r,!0,i.type),d._bottom=Lr(d,r,!1,i.type);const k=d._visualValues||(d._visualValues={});k[a]=v}}function os(e,t){const n=e.scales;return Object.keys(n).filter(i=>n[i].axis===t).shift()}function dp(e,t){return Ve(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function pp(e,t,n){return Ve(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}function mn(e,t){const n=e.controller.index,i=e.vScale&&e.vScale.axis;if(i){t=t||e._parsed;for(const s of t){const o=s._stacks;if(!o||o[i]===void 0||o[i][n]===void 0)return;delete o[i][n],o[i]._visualValues!==void 0&&o[i]._visualValues[n]!==void 0&&delete o[i]._visualValues[n]}}}const rs=e=>e==="reset"||e==="none",Nr=(e,t)=>t?e:Object.assign({},e),gp=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Kl(n,!0),values:null};class Zl{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,n){this.chart=t,this._ctx=t.ctx,this.index=n,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=ss(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&mn(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,n=this._cachedMeta,i=this.getDataset(),s=(f,d,m,y)=>f==="x"?d:f==="r"?y:m,o=n.xAxisID=R(i.xAxisID,os(t,"x")),r=n.yAxisID=R(i.yAxisID,os(t,"y")),a=n.rAxisID=R(i.rAxisID,os(t,"r")),l=n.indexAxis,c=n.iAxisID=s(l,o,r,a),u=n.vAxisID=s(l,r,o,a);n.xScale=this.getScaleForId(o),n.yScale=this.getScaleForId(r),n.rScale=this.getScaleForId(a),n.iScale=this.getScaleForId(c),n.vScale=this.getScaleForId(u)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const n=this._cachedMeta;return t===n.iScale?n.vScale:n.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&br(this._data,this),t._stacked&&mn(t)}_dataCheck(){const t=this.getDataset(),n=t.data||(t.data=[]),i=this._data;if(V(n)){const s=this._cachedMeta;this._data=cp(n,s)}else if(i!==n){if(i){br(i,this);const s=this._cachedMeta;mn(s),s._parsed=[]}n&&Object.isExtensible(n)&&Yf(n,this),this._syncList=[],this._data=n}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const n=this._cachedMeta,i=this.getDataset();let s=!1;this._dataCheck();const o=n._stacked;n._stacked=ss(n.vScale,n),n.stack!==i.stack&&(s=!0,mn(n),n.stack=i.stack),this._resyncElements(t),(s||o!==n._stacked)&&(Rr(this,n._parsed),n._stacked=ss(n.vScale,n))}configure(){const t=this.chart.config,n=t.datasetScopeKeys(this._type),i=t.getOptionScopes(this.getDataset(),n,!0);this.options=t.createResolver(i,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,n){const{_cachedMeta:i,_data:s}=this,{iScale:o,_stacked:r}=i,a=o.axis;let l=t===0&&n===s.length?!0:i._sorted,c=t>0&&i._parsed[t-1],u,f,d;if(this._parsing===!1)i._parsed=s,i._sorted=!0,d=s;else{tt(s[t])?d=this.parseArrayData(i,s,t,n):V(s[t])?d=this.parseObjectData(i,s,t,n):d=this.parsePrimitiveData(i,s,t,n);const m=()=>f[a]===null||c&&f[a]<c[a];for(u=0;u<n;++u)i._parsed[u+t]=f=d[u],l&&(m()&&(l=!1),c=f);i._sorted=l}r&&Rr(this,d)}parsePrimitiveData(t,n,i,s){const{iScale:o,vScale:r}=t,a=o.axis,l=r.axis,c=o.getLabels(),u=o===r,f=new Array(s);let d,m,y;for(d=0,m=s;d<m;++d)y=d+i,f[d]={[a]:u||o.parse(c[y],y),[l]:r.parse(n[y],y)};return f}parseArrayData(t,n,i,s){const{xScale:o,yScale:r}=t,a=new Array(s);let l,c,u,f;for(l=0,c=s;l<c;++l)u=l+i,f=n[u],a[l]={x:o.parse(f[0],u),y:r.parse(f[1],u)};return a}parseObjectData(t,n,i,s){const{xScale:o,yScale:r}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=new Array(s);let u,f,d,m;for(u=0,f=s;u<f;++u)d=u+i,m=n[d],c[u]={x:o.parse(Ci(m,a),d),y:r.parse(Ci(m,l),d)};return c}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,n,i){const s=this.chart,o=this._cachedMeta,r=n[t.axis],a={keys:Kl(s,!0),values:n._stacks[t.axis]._visualValues};return Ir(a,r,o.index,{mode:i})}updateRangeFromParsed(t,n,i,s){const o=i[n.axis];let r=o===null?NaN:o;const a=s&&i._stacks[n.axis];s&&a&&(s.values=a,r=Ir(s,o,this._cachedMeta.index)),t.min=Math.min(t.min,r),t.max=Math.max(t.max,r)}getMinMax(t,n){const i=this._cachedMeta,s=i._parsed,o=i._sorted&&t===i.iScale,r=s.length,a=this._getOtherScale(t),l=gp(n,i,this.chart),c={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:u,max:f}=hp(a);let d,m;function y(){m=s[d];const x=m[a.axis];return!vt(m[t.axis])||u>x||f<x}for(d=0;d<r&&!(!y()&&(this.updateRangeFromParsed(c,t,m,l),o));++d);if(o){for(d=r-1;d>=0;--d)if(!y()){this.updateRangeFromParsed(c,t,m,l);break}}return c}getAllParsedValues(t){const n=this._cachedMeta._parsed,i=[];let s,o,r;for(s=0,o=n.length;s<o;++s)r=n[s][t.axis],vt(r)&&i.push(r);return i}getMaxOverflow(){return!1}getLabelAndValue(t){const n=this._cachedMeta,i=n.iScale,s=n.vScale,o=this.getParsed(t);return{label:i?""+i.getLabelForValue(o[i.axis]):"",value:s?""+s.getLabelForValue(o[s.axis]):""}}_update(t){const n=this._cachedMeta;this.update(t||"default"),n._clip=lp(R(this.options.clip,ap(n.xScale,n.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,n=this.chart,i=this._cachedMeta,s=i.data||[],o=n.chartArea,r=[],a=this._drawStart||0,l=this._drawCount||s.length-a,c=this.options.drawActiveElementsOnTop;let u;for(i.dataset&&i.dataset.draw(t,o,a,l),u=a;u<a+l;++u){const f=s[u];f.hidden||(f.active&&c?r.push(f):f.draw(t,o))}for(u=0;u<r.length;++u)r[u].draw(t,o)}getStyle(t,n){const i=n?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(i):this.resolveDataElementOptions(t||0,i)}getContext(t,n,i){const s=this.getDataset();let o;if(t>=0&&t<this._cachedMeta.data.length){const r=this._cachedMeta.data[t];o=r.$context||(r.$context=pp(this.getContext(),t,r)),o.parsed=this.getParsed(t),o.raw=s.data[t],o.index=o.dataIndex=t}else o=this.$context||(this.$context=dp(this.chart.getContext(),this.index)),o.dataset=s,o.index=o.datasetIndex=this.index;return o.active=!!n,o.mode=i,o}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,n){return this._resolveElementOptions(this.dataElementType.id,n,t)}_resolveElementOptions(t,n="default",i){const s=n==="active",o=this._cachedDataOpts,r=t+"-"+n,a=o[r],l=this.enableOptionSharing&&Oi(i);if(a)return Nr(a,l);const c=this.chart.config,u=c.datasetElementScopeKeys(this._type,t),f=s?[\`\${t}Hover\`,"hover",t,""]:[t,""],d=c.getOptionScopes(this.getDataset(),u),m=Object.keys(Y.elements[t]),y=()=>this.getContext(i,s,n),x=c.resolveNamedOptions(d,m,y,f);return x.$shared&&(x.$shared=l,o[r]=Object.freeze(Nr(x,l))),x}_resolveAnimations(t,n,i){const s=this.chart,o=this._cachedDataOpts,r=\`animation-\${n}\`,a=o[r];if(a)return a;let l;if(s.options.animation!==!1){const u=this.chart.config,f=u.datasetAnimationScopeKeys(this._type,n),d=u.getOptionScopes(this.getDataset(),f);l=u.createResolver(d,this.getContext(t,i,n))}const c=new Gl(s,l&&l.animations);return l&&l._cacheable&&(o[r]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,n){return!n||rs(t)||this.chart._animationsDisabled}_getSharedOptions(t,n){const i=this.resolveDataElementOptions(t,n),s=this._sharedOptions,o=this.getSharedOptions(i),r=this.includeOptions(n,o)||o!==s;return this.updateSharedOptions(o,n,i),{sharedOptions:o,includeOptions:r}}updateElement(t,n,i,s){rs(s)?Object.assign(t,i):this._resolveAnimations(n,s).update(t,i)}updateSharedOptions(t,n,i){t&&!rs(n)&&this._resolveAnimations(void 0,n).update(t,i)}_setStyle(t,n,i,s){t.active=s;const o=this.getStyle(n,s);this._resolveAnimations(n,i,s).update(t,{options:!s&&this.getSharedOptions(o)||o})}removeHoverStyle(t,n,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,n,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const n=this._data,i=this._cachedMeta.data;for(const[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const s=i.length,o=n.length,r=Math.min(o,s);r&&this.parse(0,r),o>s?this._insertElements(s,o-s,t):o<s&&this._removeElements(o,s-o)}_insertElements(t,n,i=!0){const s=this._cachedMeta,o=s.data,r=t+n;let a;const l=c=>{for(c.length+=n,a=c.length-1;a>=r;a--)c[a]=c[a-n]};for(l(o),a=t;a<r;++a)o[a]=new this.dataElementType;this._parsing&&l(s._parsed),this.parse(t,n),i&&this.updateElements(o,t,n,"reset")}updateElements(t,n,i,s){}_removeElements(t,n){const i=this._cachedMeta;if(this._parsing){const s=i._parsed.splice(t,n);i._stacked&&mn(i,s)}i.data.splice(t,n)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[n,i,s]=t;this[n](i,s)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,n){n&&this._sync(["_removeElements",t,n]);const i=arguments.length-2;i&&this._sync(["_insertElements",t,i])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}class mp extends Zl{static id="line";static defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const n=this._cachedMeta,{dataset:i,data:s=[],_dataset:o}=n,r=this.chart._animationsDisabled;let{start:a,count:l}=Kf(n,s,r);this._drawStart=a,this._drawCount=l,Zf(n)&&(a=0,l=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!o._decimated,i.points=s;const c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:c},t),this.updateElements(s,a,l,t)}updateElements(t,n,i,s){const o=s==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:u,includeOptions:f}=this._getSharedOptions(n,s),d=r.axis,m=a.axis,{spanGaps:y,segment:x}=this.options,v=Rn(y)?y:Number.POSITIVE_INFINITY,w=this.chart._animationsDisabled||o||s==="none",k=n+i,E=t.length;let C=n>0&&this.getParsed(n-1);for(let T=0;T<E;++T){const D=t[T],P=w?D:{};if(T<n||T>=k){P.skip=!0;continue}const O=this.getParsed(T),A=B(O[m]),z=P[d]=r.getPixelForValue(O[d],T),L=P[m]=o||A?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,O,l):O[m],T);P.skip=isNaN(z)||isNaN(L)||A,P.stop=T>0&&Math.abs(O[d]-C[d])>v,x&&(P.parsed=O,P.raw=c.data[T]),f&&(P.options=u||this.resolveDataElementOptions(T,D.active?"active":s)),w||this.updateElement(D,T,P,s),C=O}}getMaxOverflow(){const t=this._cachedMeta,n=t.dataset,i=n.options&&n.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const o=s[0].size(this.resolveDataElementOptions(0)),r=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}function Te(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Eo{static override(t){Object.assign(Eo.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Te()}parse(){return Te()}format(){return Te()}add(){return Te()}diff(){return Te()}startOf(){return Te()}endOf(){return Te()}}var bp={_date:Eo};function xp(e,t,n,i){const{controller:s,data:o,_sorted:r}=e,a=s._cachedMeta.iScale,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&r&&o.length){const c=a._reversePixels?$f:De;if(i){if(s._sharedOptions){const u=o[0],f=typeof u.getRange=="function"&&u.getRange(t);if(f){const d=c(o,t,n-f),m=c(o,t,n+f);return{lo:d.lo,hi:m.hi}}}}else{const u=c(o,t,n);if(l){const{vScale:f}=s._cachedMeta,{_parsed:d}=e,m=d.slice(0,u.lo+1).reverse().findIndex(x=>!B(x[f.axis]));u.lo-=Math.max(0,m);const y=d.slice(u.hi).findIndex(x=>!B(x[f.axis]));u.hi+=Math.max(0,y)}return u}}return{lo:0,hi:o.length-1}}function Bi(e,t,n,i,s){const o=e.getSortedVisibleDatasetMetas(),r=n[t];for(let a=0,l=o.length;a<l;++a){const{index:c,data:u}=o[a],{lo:f,hi:d}=xp(o[a],t,r,s);for(let m=f;m<=d;++m){const y=u[m];y.skip||i(y,c,m)}}}function yp(e){const t=e.indexOf("x")!==-1,n=e.indexOf("y")!==-1;return function(i,s){const o=t?Math.abs(i.x-s.x):0,r=n?Math.abs(i.y-s.y):0;return Math.sqrt(Math.pow(o,2)+Math.pow(r,2))}}function as(e,t,n,i,s){const o=[];return!s&&!e.isPointInArea(t)||Bi(e,n,t,function(a,l,c){!s&&!en(a,e.chartArea,0)||a.inRange(t.x,t.y,i)&&o.push({element:a,datasetIndex:l,index:c})},!0),o}function vp(e,t,n,i){let s=[];function o(r,a,l){const{startAngle:c,endAngle:u}=r.getProps(["startAngle","endAngle"],i),{angle:f}=Bf(r,{x:t.x,y:t.y});Al(f,c,u)&&s.push({element:r,datasetIndex:a,index:l})}return Bi(e,n,t,o),s}function _p(e,t,n,i,s,o){let r=[];const a=yp(n);let l=Number.POSITIVE_INFINITY;function c(u,f,d){const m=u.inRange(t.x,t.y,s);if(i&&!m)return;const y=u.getCenterPoint(s);if(!(!!o||e.isPointInArea(y))&&!m)return;const v=a(t,y);v<l?(r=[{element:u,datasetIndex:f,index:d}],l=v):v===l&&r.push({element:u,datasetIndex:f,index:d})}return Bi(e,n,t,c),r}function ls(e,t,n,i,s,o){return!o&&!e.isPointInArea(t)?[]:n==="r"&&!i?vp(e,t,n,s):_p(e,t,n,i,s,o)}function Fr(e,t,n,i,s){const o=[],r=n==="x"?"inXRange":"inYRange";let a=!1;return Bi(e,n,t,(l,c,u)=>{l[r]&&l[r](t[n],s)&&(o.push({element:l,datasetIndex:c,index:u}),a=a||l.inRange(t.x,t.y,s))}),i&&!a?[]:o}var wp={modes:{index(e,t,n,i){const s=It(t,e),o=n.axis||"x",r=n.includeInvisible||!1,a=n.intersect?as(e,s,o,i,r):ls(e,s,o,!1,i,r),l=[];return a.length?(e.getSortedVisibleDatasetMetas().forEach(c=>{const u=a[0].index,f=c.data[u];f&&!f.skip&&l.push({element:f,datasetIndex:c.index,index:u})}),l):[]},dataset(e,t,n,i){const s=It(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;let a=n.intersect?as(e,s,o,i,r):ls(e,s,o,!1,i,r);if(a.length>0){const l=a[0].datasetIndex,c=e.getDatasetMeta(l).data;a=[];for(let u=0;u<c.length;++u)a.push({element:c[u],datasetIndex:l,index:u})}return a},point(e,t,n,i){const s=It(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return as(e,s,o,i,r)},nearest(e,t,n,i){const s=It(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return ls(e,s,o,n.intersect,i,r)},x(e,t,n,i){const s=It(t,e);return Fr(e,s,"x",n.intersect,i)},y(e,t,n,i){const s=It(t,e);return Fr(e,s,"y",n.intersect,i)}}};const Ql=["left","top","right","bottom"];function bn(e,t){return e.filter(n=>n.pos===t)}function zr(e,t){return e.filter(n=>Ql.indexOf(n.pos)===-1&&n.box.axis===t)}function xn(e,t){return e.sort((n,i)=>{const s=t?i:n,o=t?n:i;return s.weight===o.weight?s.index-o.index:s.weight-o.weight})}function Sp(e){const t=[];let n,i,s,o,r,a;for(n=0,i=(e||[]).length;n<i;++n)s=e[n],{position:o,options:{stack:r,stackWeight:a=1}}=s,t.push({index:n,box:s,pos:o,horizontal:s.isHorizontal(),weight:s.weight,stack:r&&o+r,stackWeight:a});return t}function kp(e){const t={};for(const n of e){const{stack:i,pos:s,stackWeight:o}=n;if(!i||!Ql.includes(s))continue;const r=t[i]||(t[i]={count:0,placed:0,weight:0,size:0});r.count++,r.weight+=o}return t}function Tp(e,t){const n=kp(e),{vBoxMaxWidth:i,hBoxMaxHeight:s}=t;let o,r,a;for(o=0,r=e.length;o<r;++o){a=e[o];const{fullSize:l}=a.box,c=n[a.stack],u=c&&a.stackWeight/c.weight;a.horizontal?(a.width=u?u*i:l&&t.availableWidth,a.height=s):(a.width=i,a.height=u?u*s:l&&t.availableHeight)}return n}function Mp(e){const t=Sp(e),n=xn(t.filter(c=>c.box.fullSize),!0),i=xn(bn(t,"left"),!0),s=xn(bn(t,"right")),o=xn(bn(t,"top"),!0),r=xn(bn(t,"bottom")),a=zr(t,"x"),l=zr(t,"y");return{fullSize:n,leftAndTop:i.concat(o),rightAndBottom:s.concat(l).concat(r).concat(a),chartArea:bn(t,"chartArea"),vertical:i.concat(s).concat(l),horizontal:o.concat(r).concat(a)}}function Hr(e,t,n,i){return Math.max(e[n],t[n])+Math.max(e[i],t[i])}function Jl(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function Ep(e,t,n,i){const{pos:s,box:o}=n,r=e.maxPadding;if(!V(s)){n.size&&(e[s]-=n.size);const f=i[n.stack]||{size:0,count:1};f.size=Math.max(f.size,n.horizontal?o.height:o.width),n.size=f.size/f.count,e[s]+=n.size}o.getPadding&&Jl(r,o.getPadding());const a=Math.max(0,t.outerWidth-Hr(r,e,"left","right")),l=Math.max(0,t.outerHeight-Hr(r,e,"top","bottom")),c=a!==e.w,u=l!==e.h;return e.w=a,e.h=l,n.horizontal?{same:c,other:u}:{same:u,other:c}}function Cp(e){const t=e.maxPadding;function n(i){const s=Math.max(t[i]-e[i],0);return e[i]+=s,s}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}function Op(e,t){const n=t.maxPadding;function i(s){const o={left:0,top:0,right:0,bottom:0};return s.forEach(r=>{o[r]=Math.max(t[r],n[r])}),o}return i(e?["left","right"]:["top","bottom"])}function kn(e,t,n,i){const s=[];let o,r,a,l,c,u;for(o=0,r=e.length,c=0;o<r;++o){a=e[o],l=a.box,l.update(a.width||t.w,a.height||t.h,Op(a.horizontal,t));const{same:f,other:d}=Ep(t,n,a,i);c|=f&&s.length,u=u||d,l.fullSize||s.push(a)}return c&&kn(s,t,n,i)||u}function li(e,t,n,i,s){e.top=n,e.left=t,e.right=t+i,e.bottom=n+s,e.width=i,e.height=s}function Vr(e,t,n,i){const s=n.padding;let{x:o,y:r}=t;for(const a of e){const l=a.box,c=i[a.stack]||{placed:0,weight:1},u=a.stackWeight/c.weight||1;if(a.horizontal){const f=t.w*u,d=c.size||l.height;Oi(c.start)&&(r=c.start),l.fullSize?li(l,s.left,r,n.outerWidth-s.right-s.left,d):li(l,t.left+c.placed,r,f,d),c.start=r,c.placed+=f,r=l.bottom}else{const f=t.h*u,d=c.size||l.width;Oi(c.start)&&(o=c.start),l.fullSize?li(l,o,s.top,d,n.outerHeight-s.bottom-s.top):li(l,o,t.top+c.placed,d,f),c.start=o,c.placed+=f,o=l.right}}t.x=o,t.y=r}var ne={addBox(e,t){e.boxes||(e.boxes=[]),t.fullSize=t.fullSize||!1,t.position=t.position||"top",t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(n){t.draw(n)}}]},e.boxes.push(t)},removeBox(e,t){const n=e.boxes?e.boxes.indexOf(t):-1;n!==-1&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,i){if(!e)return;const s=Mt(e.options.layout.padding),o=Math.max(t-s.width,0),r=Math.max(n-s.height,0),a=Mp(e.boxes),l=a.vertical,c=a.horizontal;F(e.boxes,x=>{typeof x.beforeLayout=="function"&&x.beforeLayout()});const u=l.reduce((x,v)=>v.box.options&&v.box.options.display===!1?x:x+1,0)||1,f=Object.freeze({outerWidth:t,outerHeight:n,padding:s,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/u,hBoxMaxHeight:r/2}),d=Object.assign({},s);Jl(d,Mt(i));const m=Object.assign({maxPadding:d,w:o,h:r,x:s.left,y:s.top},s),y=Tp(l.concat(c),f);kn(a.fullSize,m,f,y),kn(l,m,f,y),kn(c,m,f,y)&&kn(l,m,f,y),Cp(m),Vr(a.leftAndTop,m,f,y),m.x+=m.w,m.y+=m.h,Vr(a.rightAndBottom,m,f,y),e.chartArea={left:m.left,top:m.top,right:m.left+m.w,bottom:m.top+m.h,height:m.h,width:m.w},F(a.chartArea,x=>{const v=x.box;Object.assign(v,e.chartArea),v.update(m.w,m.h,{left:0,top:0,right:0,bottom:0})})}};class tc{acquireContext(t,n){}releaseContext(t){return!1}addEventListener(t,n,i){}removeEventListener(t,n,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,n,i,s){return n=Math.max(0,n||t.width),i=i||t.height,{width:n,height:Math.max(0,s?Math.floor(n/s):i)}}isAttached(t){return!0}updateConfig(t){}}class Pp extends tc{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const bi="$chartjs",Dp={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},Br=e=>e===null||e==="";function Ap(e,t){const n=e.style,i=e.getAttribute("height"),s=e.getAttribute("width");if(e[bi]={initial:{height:i,width:s,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",Br(s)){const o=Er(e,"width");o!==void 0&&(e.width=o)}if(Br(i))if(e.style.height==="")e.height=e.width/(t||2);else{const o=Er(e,"height");o!==void 0&&(e.height=o)}return e}const ec=Bd?{passive:!0}:!1;function Ip(e,t,n){e&&e.addEventListener(t,n,ec)}function Lp(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,ec)}function Rp(e,t){const n=Dp[e.type]||e.type,{x:i,y:s}=It(e,t);return{type:n,chart:t,native:e,x:i!==void 0?i:null,y:s!==void 0?s:null}}function Ii(e,t){for(const n of e)if(n===t||n.contains(t))return!0}function Np(e,t,n){const i=e.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||Ii(a.addedNodes,i),r=r&&!Ii(a.removedNodes,i);r&&n()});return s.observe(document,{childList:!0,subtree:!0}),s}function Fp(e,t,n){const i=e.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||Ii(a.removedNodes,i),r=r&&!Ii(a.addedNodes,i);r&&n()});return s.observe(document,{childList:!0,subtree:!0}),s}const Nn=new Map;let Wr=0;function nc(){const e=window.devicePixelRatio;e!==Wr&&(Wr=e,Nn.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function zp(e,t){Nn.size||window.addEventListener("resize",nc),Nn.set(e,t)}function Hp(e){Nn.delete(e),Nn.size||window.removeEventListener("resize",nc)}function Vp(e,t,n){const i=e.canvas,s=i&&Mo(i);if(!s)return;const o=Rl((a,l)=>{const c=s.clientWidth;n(a,l),c<s.clientWidth&&n()},window),r=new ResizeObserver(a=>{const l=a[0],c=l.contentRect.width,u=l.contentRect.height;c===0&&u===0||o(c,u)});return r.observe(s),zp(e,o),r}function cs(e,t,n){n&&n.disconnect(),t==="resize"&&Hp(e)}function Bp(e,t,n){const i=e.canvas,s=Rl(o=>{e.ctx!==null&&n(Rp(o,e))},e);return Ip(i,t,s),s}class Wp extends tc{acquireContext(t,n){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(Ap(t,n),i):null}releaseContext(t){const n=t.canvas;if(!n[bi])return!1;const i=n[bi].initial;["height","width"].forEach(o=>{const r=i[o];B(r)?n.removeAttribute(o):n.setAttribute(o,r)});const s=i.style||{};return Object.keys(s).forEach(o=>{n.style[o]=s[o]}),n.width=n.width,delete n[bi],!0}addEventListener(t,n,i){this.removeEventListener(t,n);const s=t.$proxies||(t.$proxies={}),r={attach:Np,detach:Fp,resize:Vp}[n]||Bp;s[n]=r(t,n,i)}removeEventListener(t,n){const i=t.$proxies||(t.$proxies={}),s=i[n];if(!s)return;({attach:cs,detach:cs,resize:cs}[n]||Lp)(t,n,s),i[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,n,i,s){return Vd(t,n,i,s)}isAttached(t){const n=t&&Mo(t);return!!(n&&n.isConnected)}}function jp(e){return!To()||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?Pp:Wp}class on{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:n,y:i}=this.getProps(["x","y"],t);return{x:n,y:i}}hasValue(){return Rn(this.x)&&Rn(this.y)}getProps(t,n){const i=this.$animations;if(!n||!i)return this;const s={};return t.forEach(o=>{s[o]=i[o]&&i[o].active()?i[o]._to:this[o]}),s}}function $p(e,t){const n=e.options.ticks,i=Up(e),s=Math.min(n.maxTicksLimit||i,i),o=n.major.enabled?Xp(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>s)return qp(t,c,o,r/s),c;const u=Yp(o,t,s);if(r>0){let f,d;const m=r>1?Math.round((l-a)/(r-1)):null;for(ci(t,c,u,B(m)?0:a-m,a),f=0,d=r-1;f<d;f++)ci(t,c,u,o[f],o[f+1]);return ci(t,c,u,l,B(m)?t.length:l+m),c}return ci(t,c,u),c}function Up(e){const t=e.options.offset,n=e._tickSize(),i=e._length/n+(t?0:1),s=e._maxLength/n;return Math.floor(Math.min(i,s))}function Yp(e,t,n){const i=Gp(e),s=t.length/n;if(!i)return Math.max(s,1);const o=Nf(i);for(let r=0,a=o.length-1;r<a;r++){const l=o[r];if(l>s)return l}return Math.max(s,1)}function Xp(e){const t=[];let n,i;for(n=0,i=e.length;n<i;n++)e[n].major&&t.push(n);return t}function qp(e,t,n,i){let s=0,o=n[0],r;for(i=Math.ceil(i),r=0;r<e.length;r++)r===o&&(t.push(e[r]),s++,o=n[s*i])}function ci(e,t,n,i,s){const o=R(i,0),r=Math.min(R(s,e.length),e.length);let a=0,l,c,u;for(n=Math.ceil(n),s&&(l=s-i,n=l/Math.floor(l/n)),u=o;u<0;)a++,u=Math.round(o+a*n);for(c=Math.max(o,0);c<r;c++)c===u&&(t.push(e[c]),a++,u=Math.round(o+a*n))}function Gp(e){const t=e.length;let n,i;if(t<2)return!1;for(i=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==i)return!1;return i}const Kp=e=>e==="left"?"right":e==="right"?"left":e,jr=(e,t,n)=>t==="top"||t==="left"?e[t]+n:e[t]-n,$r=(e,t)=>Math.min(t||e,e);function Ur(e,t){const n=[],i=e.length/t,s=e.length;let o=0;for(;o<s;o+=i)n.push(e[Math.floor(o)]);return n}function Zp(e,t,n){const i=e.ticks.length,s=Math.min(t,i-1),o=e._startPixel,r=e._endPixel,a=1e-6;let l=e.getPixelForTick(s),c;if(!(n&&(i===1?c=Math.max(l-o,r-l):t===0?c=(e.getPixelForTick(1)-l)/2:c=(l-e.getPixelForTick(s-1))/2,l+=s<t?c:-c,l<o-a||l>r+a)))return l}function Qp(e,t){F(e,n=>{const i=n.gc,s=i.length/2;let o;if(s>t){for(o=0;o<s;++o)delete n.data[i[o]];i.splice(0,s)}})}function yn(e){return e.drawTicks?e.tickLength:0}function Yr(e,t){if(!e.display)return 0;const n=ht(e.font,t),i=Mt(e.padding);return(tt(e.text)?e.text.length:1)*n.lineHeight+i.height}function Jp(e,t){return Ve(e,{scale:t,type:"scale"})}function tg(e,t,n){return Ve(e,{tick:n,index:t,type:"tick"})}function eg(e,t,n){let i=Nl(e);return(n&&t!=="right"||!n&&t==="right")&&(i=Kp(i)),i}function ng(e,t,n,i){const{top:s,left:o,bottom:r,right:a,chart:l}=e,{chartArea:c,scales:u}=l;let f=0,d,m,y;const x=r-s,v=a-o;if(e.isHorizontal()){if(m=ft(i,o,a),V(n)){const w=Object.keys(n)[0],k=n[w];y=u[w].getPixelForValue(k)+x-t}else n==="center"?y=(c.bottom+c.top)/2+x-t:y=jr(e,n,t);d=a-o}else{if(V(n)){const w=Object.keys(n)[0],k=n[w];m=u[w].getPixelForValue(k)-v+t}else n==="center"?m=(c.left+c.right)/2-v+t:m=jr(e,n,t);y=ft(i,r,s),f=n==="left"?-kt:kt}return{titleX:m,titleY:y,maxWidth:d,rotation:f}}class rn extends on{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,n){return t}getUserBounds(){let{_userMin:t,_userMax:n,_suggestedMin:i,_suggestedMax:s}=this;return t=Pt(t,Number.POSITIVE_INFINITY),n=Pt(n,Number.NEGATIVE_INFINITY),i=Pt(i,Number.POSITIVE_INFINITY),s=Pt(s,Number.NEGATIVE_INFINITY),{min:Pt(t,i),max:Pt(n,s),minDefined:vt(t),maxDefined:vt(n)}}getMinMax(t){let{min:n,max:i,minDefined:s,maxDefined:o}=this.getUserBounds(),r;if(s&&o)return{min:n,max:i};const a=this.getMatchingVisibleMetas();for(let l=0,c=a.length;l<c;++l)r=a[l].controller.getMinMax(this,t),s||(n=Math.min(n,r.min)),o||(i=Math.max(i,r.max));return n=o&&n>i?i:n,i=s&&n>i?n:i,{min:Pt(n,Pt(i,n)),max:Pt(i,Pt(n,i))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){I(this.options.beforeUpdate,[this])}update(t,n,i){const{beginAtZero:s,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=n,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=xd(this,o,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a<this.ticks.length;this._convertTicksToLabels(l?Ur(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),r.display&&(r.autoSkip||r.source==="auto")&&(this.ticks=$p(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),l&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,n,i;this.isHorizontal()?(n=this.left,i=this.right):(n=this.top,i=this.bottom,t=!t),this._startPixel=n,this._endPixel=i,this._reversePixels=t,this._length=i-n,this._alignToPixels=this.options.alignToPixels}afterUpdate(){I(this.options.afterUpdate,[this])}beforeSetDimensions(){I(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){I(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),I(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){I(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const n=this.options.ticks;let i,s,o;for(i=0,s=t.length;i<s;i++)o=t[i],o.label=I(n.callback,[o.value,i,t],this)}afterTickToLabelConversion(){I(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){I(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,n=t.ticks,i=$r(this.ticks.length,t.ticks.maxTicksLimit),s=n.minRotation||0,o=n.maxRotation;let r=s,a,l,c;if(!this._isVisible()||!n.display||s>=o||i<=1||!this.isHorizontal()){this.labelRotation=s;return}const u=this._getLabelSizes(),f=u.widest.width,d=u.highest.height,m=xt(this.chart.width-f,0,this.maxWidth);a=t.offset?this.maxWidth/i:m/(i-1),f+6>a&&(a=m/(i-(t.offset?.5:1)),l=this.maxHeight-yn(t.grid)-n.padding-Yr(t.title,this.chart.options.font),c=Math.sqrt(f*f+d*d),r=Vf(Math.min(Math.asin(xt((u.highest.height+6)/a,-1,1)),Math.asin(xt(l/c,-1,1))-Math.asin(xt(d/c,-1,1)))),r=Math.max(s,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){I(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){I(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:n,options:{ticks:i,title:s,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const l=Yr(s,n.options.font);if(a?(t.width=this.maxWidth,t.height=yn(o)+l):(t.height=this.maxHeight,t.width=yn(o)+l),i.display&&this.ticks.length){const{first:c,last:u,widest:f,highest:d}=this._getLabelSizes(),m=i.padding*2,y=Pe(this.labelRotation),x=Math.cos(y),v=Math.sin(y);if(a){const w=i.mirror?0:v*f.width+x*d.height;t.height=Math.min(this.maxHeight,t.height+w+m)}else{const w=i.mirror?0:x*f.width+v*d.height;t.width=Math.min(this.maxWidth,t.width+w+m)}this._calculatePadding(c,u,v,x)}}this._handleMargins(),a?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,n,i,s){const{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const u=this.getPixelForTick(0)-this.left,f=this.right-this.getPixelForTick(this.ticks.length-1);let d=0,m=0;l?c?(d=s*t.width,m=i*n.height):(d=i*t.height,m=s*n.width):o==="start"?m=n.width:o==="end"?d=t.width:o!=="inner"&&(d=t.width/2,m=n.width/2),this.paddingLeft=Math.max((d-u+r)*this.width/(this.width-u),0),this.paddingRight=Math.max((m-f+r)*this.width/(this.width-f),0)}else{let u=n.height/2,f=t.height/2;o==="start"?(u=0,f=t.height):o==="end"&&(u=n.height,f=0),this.paddingTop=u+r,this.paddingBottom=f+r}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){I(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:n}=this.options;return n==="top"||n==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let n,i;for(n=0,i=t.length;n<i;n++)B(t[n].label)&&(t.splice(n,1),i--,n--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const n=this.options.ticks.sampleSize;let i=this.ticks;n<i.length&&(i=Ur(i,n)),this._labelSizes=t=this._computeLabelSizes(i,i.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,n,i){const{ctx:s,_longestTextCache:o}=this,r=[],a=[],l=Math.floor(n/$r(n,i));let c=0,u=0,f,d,m,y,x,v,w,k,E,C,T;for(f=0;f<n;f+=l){if(y=t[f].label,x=this._resolveTickFontOptions(f),s.font=v=x.string,w=o[v]=o[v]||{data:{},gc:[]},k=x.lineHeight,E=C=0,!B(y)&&!tt(y))E=wr(s,w.data,w.gc,E,y),C=k;else if(tt(y))for(d=0,m=y.length;d<m;++d)T=y[d],!B(T)&&!tt(T)&&(E=wr(s,w.data,w.gc,E,T),C+=k);r.push(E),a.push(C),c=Math.max(E,c),u=Math.max(C,u)}Qp(o,n);const D=r.indexOf(c),P=a.indexOf(u),O=A=>({width:r[A]||0,height:a[A]||0});return{first:O(0),last:O(n-1),widest:O(D),highest:O(P),widths:r,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,n){return NaN}getValueForPixel(t){}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const n=this._startPixel+t*this._length;return jf(this._alignToPixels?ke(this.chart,n,0):n)}getDecimalForPixel(t){const n=(t-this._startPixel)/this._length;return this._reversePixels?1-n:n}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:n}=this;return t<0&&n<0?n:t>0&&n>0?t:0}getContext(t){const n=this.ticks||[];if(t>=0&&t<n.length){const i=n[t];return i.$context||(i.$context=tg(this.getContext(),t,i))}return this.$context||(this.$context=Jp(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,n=Pe(this.labelRotation),i=Math.abs(Math.cos(n)),s=Math.abs(Math.sin(n)),o=this._getLabelSizes(),r=t.autoSkipPadding||0,a=o?o.widest.width+r:0,l=o?o.highest.height+r:0;return this.isHorizontal()?l*i>a*s?a/i:l/s:l*s<a*i?l/i:a/s}_isVisible(){const t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const n=this.axis,i=this.chart,s=this.options,{grid:o,position:r,border:a}=s,l=o.offset,c=this.isHorizontal(),f=this.ticks.length+(l?1:0),d=yn(o),m=[],y=a.setContext(this.getContext()),x=y.display?y.width:0,v=x/2,w=function(q){return ke(i,q,x)};let k,E,C,T,D,P,O,A,z,L,H,Z;if(r==="top")k=w(this.bottom),P=this.bottom-d,A=k-v,L=w(t.top)+v,Z=t.bottom;else if(r==="bottom")k=w(this.top),L=t.top,Z=w(t.bottom)-v,P=k+v,A=this.top+d;else if(r==="left")k=w(this.right),D=this.right-d,O=k-v,z=w(t.left)+v,H=t.right;else if(r==="right")k=w(this.left),z=t.left,H=w(t.right)-v,D=k+v,O=this.left+d;else if(n==="x"){if(r==="center")k=w((t.top+t.bottom)/2+.5);else if(V(r)){const q=Object.keys(r)[0],it=r[q];k=w(this.chart.scales[q].getPixelForValue(it))}L=t.top,Z=t.bottom,P=k+v,A=P+d}else if(n==="y"){if(r==="center")k=w((t.left+t.right)/2);else if(V(r)){const q=Object.keys(r)[0],it=r[q];k=w(this.chart.scales[q].getPixelForValue(it))}D=k-v,O=D-d,z=t.left,H=t.right}const nt=R(s.ticks.maxTicksLimit,f),j=Math.max(1,Math.ceil(f/nt));for(E=0;E<f;E+=j){const q=this.getContext(E),it=o.setContext(q),We=a.setContext(q),be=it.lineWidth,Gt=it.color,je=We.dash||[],dt=We.dashOffset,xe=it.tickWidth,wt=it.tickColor,ye=it.tickBorderDash||[],Vt=it.tickBorderDashOffset;C=Zp(this,E,l),C!==void 0&&(T=ke(i,C,be),c?D=O=z=H=T:P=A=L=Z=T,m.push({tx1:D,ty1:P,tx2:O,ty2:A,x1:z,y1:L,x2:H,y2:Z,width:be,color:Gt,borderDash:je,borderDashOffset:dt,tickWidth:xe,tickColor:wt,tickBorderDash:ye,tickBorderDashOffset:Vt}))}return this._ticksLength=f,this._borderValue=k,m}_computeLabelItems(t){const n=this.axis,i=this.options,{position:s,ticks:o}=i,r=this.isHorizontal(),a=this.ticks,{align:l,crossAlign:c,padding:u,mirror:f}=o,d=yn(i.grid),m=d+u,y=f?-u:m,x=-Pe(this.labelRotation),v=[];let w,k,E,C,T,D,P,O,A,z,L,H,Z="middle";if(s==="top")D=this.bottom-y,P=this._getXAxisLabelAlignment();else if(s==="bottom")D=this.top+y,P=this._getXAxisLabelAlignment();else if(s==="left"){const j=this._getYAxisLabelAlignment(d);P=j.textAlign,T=j.x}else if(s==="right"){const j=this._getYAxisLabelAlignment(d);P=j.textAlign,T=j.x}else if(n==="x"){if(s==="center")D=(t.top+t.bottom)/2+m;else if(V(s)){const j=Object.keys(s)[0],q=s[j];D=this.chart.scales[j].getPixelForValue(q)+m}P=this._getXAxisLabelAlignment()}else if(n==="y"){if(s==="center")T=(t.left+t.right)/2-m;else if(V(s)){const j=Object.keys(s)[0],q=s[j];T=this.chart.scales[j].getPixelForValue(q)}P=this._getYAxisLabelAlignment(d).textAlign}n==="y"&&(l==="start"?Z="top":l==="end"&&(Z="bottom"));const nt=this._getLabelSizes();for(w=0,k=a.length;w<k;++w){E=a[w],C=E.label;const j=o.setContext(this.getContext(w));O=this.getPixelForTick(w)+o.labelOffset,A=this._resolveTickFontOptions(w),z=A.lineHeight,L=tt(C)?C.length:1;const q=L/2,it=j.color,We=j.textStrokeColor,be=j.textStrokeWidth;let Gt=P;r?(T=O,P==="inner"&&(w===k-1?Gt=this.options.reverse?"left":"right":w===0?Gt=this.options.reverse?"right":"left":Gt="center"),s==="top"?c==="near"||x!==0?H=-L*z+z/2:c==="center"?H=-nt.highest.height/2-q*z+z:H=-nt.highest.height+z/2:c==="near"||x!==0?H=z/2:c==="center"?H=nt.highest.height/2-q*z:H=nt.highest.height-L*z,f&&(H*=-1),x!==0&&!j.showLabelBackdrop&&(T+=z/2*Math.sin(x))):(D=O,H=(1-L)*z/2);let je;if(j.showLabelBackdrop){const dt=Mt(j.backdropPadding),xe=nt.heights[w],wt=nt.widths[w];let ye=H-dt.top,Vt=0-dt.left;switch(Z){case"middle":ye-=xe/2;break;case"bottom":ye-=xe;break}switch(P){case"center":Vt-=wt/2;break;case"right":Vt-=wt;break;case"inner":w===k-1?Vt-=wt:w>0&&(Vt-=wt/2);break}je={left:Vt,top:ye,width:wt+dt.width,height:xe+dt.height,color:j.backdropColor}}v.push({label:C,font:A,textOffset:H,options:{rotation:x,color:it,strokeColor:We,strokeWidth:be,textAlign:Gt,textBaseline:Z,translation:[T,D],backdrop:je}})}return v}_getXAxisLabelAlignment(){const{position:t,ticks:n}=this.options;if(-Pe(this.labelRotation))return t==="top"?"left":"right";let s="center";return n.align==="start"?s="left":n.align==="end"?s="right":n.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(t){const{position:n,ticks:{crossAlign:i,mirror:s,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,l=r.widest.width;let c,u;return n==="left"?s?(u=this.right+o,i==="near"?c="left":i==="center"?(c="center",u+=l/2):(c="right",u+=l)):(u=this.right-a,i==="near"?c="right":i==="center"?(c="center",u-=l/2):(c="left",u=this.left)):n==="right"?s?(u=this.left+o,i==="near"?c="right":i==="center"?(c="center",u-=l/2):(c="left",u-=l)):(u=this.left+a,i==="near"?c="left":i==="center"?(c="center",u+=l/2):(c="right",u=this.right)):c="right",{textAlign:c,x:u}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,n=this.options.position;if(n==="left"||n==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(n==="top"||n==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:n},left:i,top:s,width:o,height:r}=this;n&&(t.save(),t.fillStyle=n,t.fillRect(i,s,o,r),t.restore())}getLineWidthForValue(t){const n=this.options.grid;if(!this._isVisible()||!n.display)return 0;const s=this.ticks.findIndex(o=>o.value===t);return s>=0?n.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){const n=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,r;const a=(l,c,u)=>{!u.width||!u.color||(i.save(),i.lineWidth=u.width,i.strokeStyle=u.color,i.setLineDash(u.borderDash||[]),i.lineDashOffset=u.borderDashOffset,i.beginPath(),i.moveTo(l.x,l.y),i.lineTo(c.x,c.y),i.stroke(),i.restore())};if(n.display)for(o=0,r=s.length;o<r;++o){const l=s[o];n.drawOnChartArea&&a({x:l.x1,y:l.y1},{x:l.x2,y:l.y2},l),n.drawTicks&&a({x:l.tx1,y:l.ty1},{x:l.tx2,y:l.ty2},{color:l.tickColor,width:l.tickWidth,borderDash:l.tickBorderDash,borderDashOffset:l.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:n,options:{border:i,grid:s}}=this,o=i.setContext(this.getContext()),r=i.display?o.width:0;if(!r)return;const a=s.setContext(this.getContext(0)).lineWidth,l=this._borderValue;let c,u,f,d;this.isHorizontal()?(c=ke(t,this.left,r)-r/2,u=ke(t,this.right,a)+a/2,f=d=l):(f=ke(t,this.top,r)-r/2,d=ke(t,this.bottom,a)+a/2,c=u=l),n.save(),n.lineWidth=o.width,n.strokeStyle=o.color,n.beginPath(),n.moveTo(c,f),n.lineTo(u,d),n.stroke(),n.restore()}drawLabels(t){if(!this.options.ticks.display)return;const i=this.ctx,s=this._computeLabelArea();s&&vo(i,s);const o=this.getLabelItems(t);for(const r of o){const a=r.options,l=r.font,c=r.label,u=r.textOffset;Di(i,c,0,u,l,a)}s&&_o(i)}drawTitle(){const{ctx:t,options:{position:n,title:i,reverse:s}}=this;if(!i.display)return;const o=ht(i.font),r=Mt(i.padding),a=i.align;let l=o.lineHeight/2;n==="bottom"||n==="center"||V(n)?(l+=r.bottom,tt(i.text)&&(l+=o.lineHeight*(i.text.length-1))):l+=r.top;const{titleX:c,titleY:u,maxWidth:f,rotation:d}=ng(this,l,n,a);Di(t,i.text,0,0,o,{color:i.color,maxWidth:f,rotation:d,textAlign:eg(a,n,s),textBaseline:"middle",translation:[c,u]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,n=t.ticks&&t.ticks.z||0,i=R(t.grid&&t.grid.z,-1),s=R(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==rn.prototype.draw?[{z:n,draw:o=>{this.draw(o)}}]:[{z:i,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:n,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const n=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let o,r;for(o=0,r=n.length;o<r;++o){const a=n[o];a[i]===this.id&&(!t||a.type===t)&&s.push(a)}return s}_resolveTickFontOptions(t){const n=this.options.ticks.setContext(this.getContext(t));return ht(n.font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class ui{constructor(t,n,i){this.type=t,this.scope=n,this.override=i,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const n=Object.getPrototypeOf(t);let i;og(n)&&(i=this.register(n));const s=this.items,o=t.id,r=this.scope+"."+o;if(!o)throw new Error("class does not have id: "+t);return o in s||(s[o]=t,ig(t,r,i),this.override&&Y.override(t.id,t.overrides)),r}get(t){return this.items[t]}unregister(t){const n=this.items,i=t.id,s=this.scope;i in n&&delete n[i],s&&i in Y[s]&&(delete Y[s][i],this.override&&delete ze[i])}}function ig(e,t,n){const i=Ln(Object.create(null),[n?Y.get(n):{},Y.get(t),e.defaults]);Y.set(t,i),e.defaultRoutes&&sg(t,e.defaultRoutes),e.descriptors&&Y.describe(t,e.descriptors)}function sg(e,t){Object.keys(t).forEach(n=>{const i=n.split("."),s=i.pop(),o=[e].concat(i).join("."),r=t[n].split("."),a=r.pop(),l=r.join(".");Y.route(o,s,l,a)})}function og(e){return"id"in e&&"defaults"in e}class rg{constructor(){this.controllers=new ui(Zl,"datasets",!0),this.elements=new ui(on,"elements"),this.plugins=new ui(Object,"plugins"),this.scales=new ui(rn,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,n,i){[...n].forEach(s=>{const o=i||this._getRegistryForType(s);i||o.isForType(s)||o===this.plugins&&s.id?this._exec(t,o,s):F(s,r=>{const a=i||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,n,i){const s=bo(t);I(i["before"+s],[],i),n[t](i),I(i["after"+s],[],i)}_getRegistryForType(t){for(let n=0;n<this._typedRegistries.length;n++){const i=this._typedRegistries[n];if(i.isForType(t))return i}return this.plugins}_get(t,n,i){const s=n.get(t);if(s===void 0)throw new Error('"'+t+'" is not a registered '+i+".");return s}}var At=new rg;class ag{constructor(){this._init=[]}notify(t,n,i,s){n==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install"));const o=s?this._descriptors(t).filter(s):this._descriptors(t),r=this._notify(o,t,n,i);return n==="afterDestroy"&&(this._notify(o,t,"stop"),this._notify(this._init,t,"uninstall")),r}_notify(t,n,i,s){s=s||{};for(const o of t){const r=o.plugin,a=r[i],l=[n,s,o.options];if(I(a,l,r)===!1&&s.cancelable)return!1}return!0}invalidate(){B(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const n=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),n}_createDescriptors(t,n){const i=t&&t.config,s=R(i.options&&i.options.plugins,{}),o=lg(i);return s===!1&&!n?[]:ug(t,o,s,n)}_notifyStateChanges(t){const n=this._oldCache||[],i=this._cache,s=(o,r)=>o.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(s(n,i),t,"stop"),this._notify(s(i,n),t,"start")}}function lg(e){const t={},n=[],i=Object.keys(At.plugins.items);for(let o=0;o<i.length;o++)n.push(At.getPlugin(i[o]));const s=e.plugins||[];for(let o=0;o<s.length;o++){const r=s[o];n.indexOf(r)===-1&&(n.push(r),t[r.id]=!0)}return{plugins:n,localIds:t}}function cg(e,t){return!t&&e===!1?null:e===!0?{}:e}function ug(e,{plugins:t,localIds:n},i,s){const o=[],r=e.getContext();for(const a of t){const l=a.id,c=cg(i[l],s);c!==null&&o.push({plugin:a,options:hg(e.config,{plugin:a,local:n[l]},c,r)})}return o}function hg(e,{plugin:t,local:n},i,s){const o=e.pluginScopeKeys(t),r=e.getOptionScopes(i,o);return n&&t.defaults&&r.push(t.defaults),e.createResolver(r,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Ws(e,t){const n=Y.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function fg(e,t){let n=e;return e==="_index_"?n=t:e==="_value_"&&(n=t==="x"?"y":"x"),n}function dg(e,t){return e===t?"_index_":"_value_"}function Xr(e){if(e==="x"||e==="y"||e==="r")return e}function pg(e){if(e==="top"||e==="bottom")return"x";if(e==="left"||e==="right")return"y"}function js(e,...t){if(Xr(e))return e;for(const n of t){const i=n.axis||pg(n.position)||e.length>1&&Xr(e[0].toLowerCase());if(i)return i}throw new Error(\`Cannot determine type of '\${e}' axis. Please provide 'axis' or 'position' option.\`)}function qr(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function gg(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(i=>i.xAxisID===e||i.yAxisID===e);if(n.length)return qr(e,"x",n[0])||qr(e,"y",n[0])}return{}}function mg(e,t){const n=ze[e.type]||{scales:{}},i=t.scales||{},s=Ws(e.type,t),o=Object.create(null);return Object.keys(i).forEach(r=>{const a=i[r];if(!V(a))return console.error(\`Invalid scale configuration for scale: \${r}\`);if(a._proxy)return console.warn(\`Ignoring resolver passed as options for scale: \${r}\`);const l=js(r,a,gg(r,e),Y.scales[a.type]),c=dg(l,s),u=n.scales||{};o[r]=Mn(Object.create(null),[{axis:l},a,u[l],u[c]])}),e.data.datasets.forEach(r=>{const a=r.type||e.type,l=r.indexAxis||Ws(a,t),u=(ze[a]||{}).scales||{};Object.keys(u).forEach(f=>{const d=fg(f,l),m=r[d+"AxisID"]||d;o[m]=o[m]||Object.create(null),Mn(o[m],[{axis:d},i[m],u[f]])})}),Object.keys(o).forEach(r=>{const a=o[r];Mn(a,[Y.scales[a.type],Y.scale])}),o}function ic(e){const t=e.options||(e.options={});t.plugins=R(t.plugins,{}),t.scales=mg(e,t)}function sc(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function bg(e){return e=e||{},e.data=sc(e.data),ic(e),e}const Gr=new Map,oc=new Set;function hi(e,t){let n=Gr.get(e);return n||(n=t(),Gr.set(e,n),oc.add(n)),n}const vn=(e,t,n)=>{const i=Ci(t,n);i!==void 0&&e.add(i)};class xg{constructor(t){this._config=bg(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=sc(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),ic(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return hi(t,()=>[[\`datasets.\${t}\`,""]])}datasetAnimationScopeKeys(t,n){return hi(\`\${t}.transition.\${n}\`,()=>[[\`datasets.\${t}.transitions.\${n}\`,\`transitions.\${n}\`],[\`datasets.\${t}\`,""]])}datasetElementScopeKeys(t,n){return hi(\`\${t}-\${n}\`,()=>[[\`datasets.\${t}.elements.\${n}\`,\`datasets.\${t}\`,\`elements.\${n}\`,""]])}pluginScopeKeys(t){const n=t.id,i=this.type;return hi(\`\${i}-plugin-\${n}\`,()=>[[\`plugins.\${n}\`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){const i=this._scopeCache;let s=i.get(t);return(!s||n)&&(s=new Map,i.set(t,s)),s}getOptionScopes(t,n,i){const{options:s,type:o}=this,r=this._cachedScopes(t,i),a=r.get(n);if(a)return a;const l=new Set;n.forEach(u=>{t&&(l.add(t),u.forEach(f=>vn(l,t,f))),u.forEach(f=>vn(l,s,f)),u.forEach(f=>vn(l,ze[o]||{},f)),u.forEach(f=>vn(l,Y,f)),u.forEach(f=>vn(l,Hs,f))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),oc.has(n)&&r.set(n,c),c}chartOptionScopes(){const{options:t,type:n}=this;return[t,ze[n]||{},Y.datasets[n]||{},{type:n},Y,Hs]}resolveNamedOptions(t,n,i,s=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=Kr(this._resolverCache,t,s);let l=r;if(vg(r,n)){o.$shared=!1,i=ue(i)?i():i;const c=this.createResolver(t,i,a);l=nn(r,i,c)}for(const c of n)o[c]=l[c];return o}createResolver(t,n,i=[""],s){const{resolver:o}=Kr(this._resolverCache,t,i);return V(n)?nn(o,n,void 0,s):o}}function Kr(e,t,n){let i=e.get(t);i||(i=new Map,e.set(t,i));const s=n.join();let o=i.get(s);return o||(o={resolver:wo(t,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},i.set(s,o)),o}const yg=e=>V(e)&&Object.getOwnPropertyNames(e).some(t=>ue(e[t]));function vg(e,t){const{isScriptable:n,isIndexable:i}=Bl(e);for(const s of t){const o=n(s),r=i(s),a=(r||o)&&e[s];if(o&&(ue(a)||yg(a))||r&&tt(a))return!0}return!1}var _g="4.5.0";const wg=["top","bottom","left","right","chartArea"];function Zr(e,t){return e==="top"||e==="bottom"||wg.indexOf(e)===-1&&t==="x"}function Qr(e,t){return function(n,i){return n[e]===i[e]?n[t]-i[t]:n[e]-i[e]}}function Jr(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),I(n&&n.onComplete,[e],t)}function Sg(e){const t=e.chart,n=t.options.animation;I(n&&n.onProgress,[e],t)}function rc(e){return To()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const xi={},ta=e=>{const t=rc(e);return Object.values(xi).filter(n=>n.canvas===t).pop()};function kg(e,t,n){const i=Object.keys(e);for(const s of i){const o=+s;if(o>=t){const r=e[s];delete e[s],(n>0||o>t)&&(e[o+n]=r)}}}function Tg(e,t,n,i){return!n||e.type==="mouseout"?null:i?t:e}class $s{static defaults=Y;static instances=xi;static overrides=ze;static registry=At;static version=_g;static getChart=ta;static register(...t){At.add(...t),ea()}static unregister(...t){At.remove(...t),ea()}constructor(t,n){const i=this.config=new xg(n),s=rc(t),o=ta(s);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const r=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||jp(s)),this.platform.updateConfig(i);const a=this.platform.acquireContext(s,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,u=l&&l.width;if(this.id=Ef(),this.ctx=a,this.canvas=l,this.width=u,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new ag,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=qf(f=>this.update(f),r.resizeDelay||0),this._dataChanges=[],xi[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}$t.listen(this,"complete",Jr),$t.listen(this,"progress",Sg),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:n},width:i,height:s,_aspectRatio:o}=this;return B(t)?n&&o?o:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return At}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Mr(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return Sr(this.canvas,this.ctx),this}stop(){return $t.stop(this),this}resize(t,n){$t.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){const i=this.options,s=this.canvas,o=i.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(s,t,n,o),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,Mr(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),I(i.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const n=this.options.scales||{};F(n,(i,s)=>{i.id=s})}buildOrUpdateScales(){const t=this.options,n=t.scales,i=this.scales,s=Object.keys(i).reduce((r,a)=>(r[a]=!1,r),{});let o=[];n&&(o=o.concat(Object.keys(n).map(r=>{const a=n[r],l=js(r,a),c=l==="r",u=l==="x";return{options:a,dposition:c?"chartArea":u?"bottom":"left",dtype:c?"radialLinear":u?"category":"linear"}}))),F(o,r=>{const a=r.options,l=a.id,c=js(l,a),u=R(a.type,r.dtype);(a.position===void 0||Zr(a.position,c)!==Zr(r.dposition))&&(a.position=r.dposition),s[l]=!0;let f=null;if(l in i&&i[l].type===u)f=i[l];else{const d=At.getScale(u);f=new d({id:l,type:u,ctx:this.ctx,chart:this}),i[f.id]=f}f.init(a,t)}),F(s,(r,a)=>{r||delete i[a]}),F(i,r=>{ne.configure(this,r,r.options),ne.addBox(this,r)})}_updateMetasets(){const t=this._metasets,n=this.data.datasets.length,i=t.length;if(t.sort((s,o)=>s.index-o.index),i>n){for(let s=n;s<i;++s)this._destroyDatasetMeta(s);t.splice(n,i-n)}this._sortedMetasets=t.slice(0).sort(Qr("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:n}}=this;t.length>n.length&&delete this._stacks,t.forEach((i,s)=>{n.filter(o=>o===i._dataset).length===0&&this._destroyDatasetMeta(s)})}buildOrUpdateControllers(){const t=[],n=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=n.length;i<s;i++){const o=n[i];let r=this.getDatasetMeta(i);const a=o.type||this.config.type;if(r.type&&r.type!==a&&(this._destroyDatasetMeta(i),r=this.getDatasetMeta(i)),r.type=a,r.indexAxis=o.indexAxis||Ws(a,this.options),r.order=o.order||0,r.index=i,r.label=""+o.label,r.visible=this.isDatasetVisible(i),r.controller)r.controller.updateIndex(i),r.controller.linkScales();else{const l=At.getController(a),{datasetElementType:c,dataElementType:u}=Y.datasets[a];Object.assign(l,{dataElementType:At.getElement(u),datasetElementType:c&&At.getElement(c)}),r.controller=new l(this,i),t.push(r.controller)}}return this._updateMetasets(),t}_resetElements(){F(this.data.datasets,(t,n)=>{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const n=this.config;n.update();const i=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let c=0,u=this.data.datasets.length;c<u;c++){const{controller:f}=this.getDatasetMeta(c),d=!s&&o.indexOf(f)===-1;f.buildOrUpdateElements(d),r=Math.max(+f.getMaxOverflow(),r)}r=this._minPadding=i.layout.autoPadding?r:0,this._updateLayout(r),s||F(o,c=>{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Qr("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){F(this.scales,t=>{ne.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,n=new Set(Object.keys(this._listeners)),i=new Set(t.events);(!dr(n,i)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:o}of n){const r=i==="_removeElements"?-o:o;kg(t,s,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const n=this.data.datasets.length,i=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),s=i(0);for(let o=1;o<n;o++)if(!dr(s,i(o)))return;return Array.from(s).map(o=>o.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;ne.update(this,this.width,this.height,t);const n=this.chartArea,i=n.width<=0||n.height<=0;this._layers=[],F(this.boxes,s=>{i&&s.position==="chartArea"||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,o)=>{s._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,i=this.data.datasets.length;n<i;++n)this.getDatasetMeta(n).controller.configure();for(let n=0,i=this.data.datasets.length;n<i;++n)this._updateDataset(n,ue(t)?t({datasetIndex:n}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,n){const i=this.getDatasetMeta(t),s={meta:i,index:t,mode:n,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",s)!==!1&&(i.controller._update(n),s.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",s))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&($t.has(this)?this.attached&&!$t.running(this)&&$t.start(this):(this.draw(),Jr({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:i,height:s}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(i,s)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins("beforeDraw",{cancelable:!0})===!1)return;const n=this._layers;for(t=0;t<n.length&&n[t].z<=0;++t)n[t].draw(this.chartArea);for(this._drawDatasets();t<n.length;++t)n[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const n=this._sortedMetasets,i=[];let s,o;for(s=0,o=n.length;s<o;++s){const r=n[s];(!t||r.visible)&&i.push(r)}return i}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})===!1)return;const t=this.getSortedVisibleDatasetMetas();for(let n=t.length-1;n>=0;--n)this._drawDataset(t[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const n=this.ctx,i={meta:t,index:t.index,cancelable:!0},s=ep(this,t);this.notifyPlugins("beforeDatasetDraw",i)!==!1&&(s&&vo(n,s),t.controller.draw(),s&&_o(n),i.cancelable=!1,this.notifyPlugins("afterDatasetDraw",i))}isPointInArea(t){return en(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,i,s){const o=wp.modes[n];return typeof o=="function"?o(this,t,i,s):[]}getDatasetMeta(t){const n=this.data.datasets[t],i=this._metasets;let s=i.filter(o=>o&&o._dataset===n).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:t,_dataset:n,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=Ve(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const n=this.data.datasets[t];if(!n)return!1;const i=this.getDatasetMeta(t);return typeof i.hidden=="boolean"?!i.hidden:!n.hidden}setDatasetVisibility(t,n){const i=this.getDatasetMeta(t);i.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,i){const s=i?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,s);Oi(n)?(o.data[n].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),r.update(o,{visible:i}),this.update(a=>a.datasetIndex===t?s:void 0))}hide(t,n){this._updateVisibility(t,n,!1)}show(t,n){this._updateVisibility(t,n,!0)}_destroyDatasetMeta(t){const n=this._metasets[t];n&&n.controller&&n.controller._destroy(),delete this._metasets[t]}_stop(){let t,n;for(this.stop(),$t.remove(this),t=0,n=this.data.datasets.length;t<n;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:n}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),Sr(t,n),this.platform.releaseContext(n),this.canvas=null,this.ctx=null),delete xi[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,n=this.platform,i=(o,r)=>{n.addEventListener(this,o,r),t[o]=r},s=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};F(this.options.events,o=>i(o,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,n=this.platform,i=(l,c)=>{n.addEventListener(this,l,c),t[l]=c},s=(l,c)=>{t[l]&&(n.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)};let r;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",o),i("detach",r)};r=()=>{this.attached=!1,s("resize",o),this._stop(),this._resize(0,0),i("attach",a)},n.isAttached(this.canvas)?a():r()}unbindEvents(){F(this._listeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._listeners={},F(this._responsiveListeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,n,i){const s=i?"set":"remove";let o,r,a,l;for(n==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+s+"DatasetHoverStyle"]()),a=0,l=t.length;a<l;++a){r=t[a];const c=r&&this.getDatasetMeta(r.datasetIndex).controller;c&&c[s+"HoverStyle"](r.element,r.datasetIndex,r.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const n=this._active||[],i=t.map(({datasetIndex:o,index:r})=>{const a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!Mi(i,n)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,n))}notifyPlugins(t,n,i){return this._plugins.notify(this,t,n,i)}isPluginEnabled(t){return this._plugins._cache.filter(n=>n.plugin.id===t).length===1}_updateHoverStyles(t,n,i){const s=this.options.hover,o=(l,c)=>l.filter(u=>!c.some(f=>u.datasetIndex===f.datasetIndex&&u.index===f.index)),r=o(n,t),a=i?t:o(t,n);r.length&&this.updateHoverStyle(r,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,n){const i={event:t,replay:n,cancelable:!0,inChartArea:this.isPointInArea(t)},s=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",i,s)===!1)return;const o=this._handleEvent(t,n,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(o||i.changed)&&this.render(),this}_handleEvent(t,n,i){const{_active:s=[],options:o}=this,r=n,a=this._getActiveElements(t,s,i,r),l=If(t),c=Tg(t,this._lastEvent,i,l);i&&(this._lastEvent=null,I(o.onHover,[t,a,this],this),l&&I(o.onClick,[t,a,this],this));const u=!Mi(a,s);return(u||n)&&(this._active=a,this._updateHoverStyles(a,s,n)),this._lastEvent=c,u}_getActiveElements(t,n,i,s){if(t.type==="mouseout")return[];if(!i)return n;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,s)}}function ea(){return F($s.instances,e=>e._plugins.invalidate())}function ac(e,t,n=t){e.lineCap=R(n.borderCapStyle,t.borderCapStyle),e.setLineDash(R(n.borderDash,t.borderDash)),e.lineDashOffset=R(n.borderDashOffset,t.borderDashOffset),e.lineJoin=R(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=R(n.borderWidth,t.borderWidth),e.strokeStyle=R(n.borderColor,t.borderColor)}function Mg(e,t,n){e.lineTo(n.x,n.y)}function Eg(e){return e.stepped?ld:e.tension||e.cubicInterpolationMode==="monotone"?cd:Mg}function lc(e,t,n={}){const i=e.length,{start:s=0,end:o=i-1}=n,{start:r,end:a}=t,l=Math.max(s,r),c=Math.min(o,a),u=s<r&&o<r||s>a&&o>a;return{count:i,start:l,loop:t.loop,ilen:c<l&&!u?i+c-l:c-l}}function Cg(e,t,n,i){const{points:s,options:o}=t,{count:r,start:a,loop:l,ilen:c}=lc(s,n,i),u=Eg(o);let{move:f=!0,reverse:d}=i||{},m,y,x;for(m=0;m<=c;++m)y=s[(a+(d?c-m:m))%r],!y.skip&&(f?(e.moveTo(y.x,y.y),f=!1):u(e,x,y,d,o.stepped),x=y);return l&&(y=s[(a+(d?c:0))%r],u(e,x,y,d,o.stepped)),!!l}function Og(e,t,n,i){const s=t.points,{count:o,start:r,ilen:a}=lc(s,n,i),{move:l=!0,reverse:c}=i||{};let u=0,f=0,d,m,y,x,v,w;const k=C=>(r+(c?a-C:C))%o,E=()=>{x!==v&&(e.lineTo(u,v),e.lineTo(u,x),e.lineTo(u,w))};for(l&&(m=s[k(0)],e.moveTo(m.x,m.y)),d=0;d<=a;++d){if(m=s[k(d)],m.skip)continue;const C=m.x,T=m.y,D=C|0;D===y?(T<x?x=T:T>v&&(v=T),u=(f*u+C)/++f):(E(),e.lineTo(C,T),y=D,f=0,x=v=T),w=T}E()}function Us(e){const t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!n?Og:Cg}function Pg(e){return e.stepped?Wd:e.tension||e.cubicInterpolationMode==="monotone"?jd:Me}function Dg(e,t,n,i){let s=t._path;s||(s=t._path=new Path2D,t.path(s,n,i)&&s.closePath()),ac(e,t.options),e.stroke(s)}function Ag(e,t,n,i){const{segments:s,options:o}=t,r=Us(t);for(const a of s)ac(e,o,a.style),e.beginPath(),r(e,t,a,{start:n,end:n+i-1})&&e.closePath(),e.stroke()}const Ig=typeof Path2D=="function";function Lg(e,t,n,i){Ig&&!t.options.segment?Dg(e,t,n,i):Ag(e,t,n,i)}class Rg extends on{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,n){const i=this.options;if((i.tension||i.cubicInterpolationMode==="monotone")&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;Ld(this._points,i,t,s,n),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Zd(this,this.options.segment))}first(){const t=this.segments,n=this.points;return t.length&&n[t[0].start]}last(){const t=this.segments,n=this.points,i=t.length;return i&&n[t[i-1].end]}interpolate(t,n){const i=this.options,s=t[n],o=this.points,r=qd(this,{property:n,start:s,end:s});if(!r.length)return;const a=[],l=Pg(i);let c,u;for(c=0,u=r.length;c<u;++c){const{start:f,end:d}=r[c],m=o[f],y=o[d];if(m===y){a.push(m);continue}const x=Math.abs((s-m[n])/(y[n]-m[n])),v=l(m,y,x,i.stepped);v[n]=t[n],a.push(v)}return a.length===1?a[0]:a}pathSegment(t,n,i){return Us(this)(t,this,n,i)}path(t,n,i){const s=this.segments,o=Us(this);let r=this._loop;n=n||0,i=i||this.points.length-n;for(const a of s)r&=o(t,this,a,{start:n,end:n+i-1});return!!r}draw(t,n,i,s){const o=this.options||{};(this.points||[]).length&&o.borderWidth&&(t.save(),Lg(t,this,i,s),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function na(e,t,n,i){const s=e.options,{[n]:o}=e.getProps([n],i);return Math.abs(t-o)<s.radius+s.hitRadius}class Ng extends on{static id="point";parsed;skip;stop;static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,n,i){const s=this.options,{x:o,y:r}=this.getProps(["x","y"],i);return Math.pow(t-o,2)+Math.pow(n-r,2)<Math.pow(s.hitRadius+s.radius,2)}inXRange(t,n){return na(this,t,"x",n)}inYRange(t,n){return na(this,t,"y",n)}getCenterPoint(t){const{x:n,y:i}=this.getProps(["x","y"],t);return{x:n,y:i}}size(t){t=t||this.options||{};let n=t.radius||0;n=Math.max(n,n&&t.hoverRadius||0);const i=n&&t.borderWidth||0;return(n+i)*2}draw(t,n){const i=this.options;this.skip||i.radius<.1||!en(this,n,this.size(i)/2)||(t.strokeStyle=i.borderColor,t.lineWidth=i.borderWidth,t.fillStyle=i.backgroundColor,Vs(t,i,this.x,this.y))}getRange(){const t=this.options||{};return t.radius+t.hitRadius}}const ia=(e,t)=>{let{boxHeight:n=t,boxWidth:i=t}=e;return e.usePointStyle&&(n=Math.min(n,t),i=e.pointStyleWidth||Math.min(i,t)),{boxWidth:i,boxHeight:n,itemHeight:Math.max(t,n)}},Fg=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index;class sa extends on{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n,i){this.maxWidth=t,this.maxHeight=n,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let n=I(t.generateLabels,[this.chart],this)||[];t.filter&&(n=n.filter(i=>t.filter(i,this.chart.data))),t.sort&&(n=n.sort((i,s)=>t.sort(i,s,this.chart.data))),this.options.reverse&&n.reverse(),this.legendItems=n}fit(){const{options:t,ctx:n}=this;if(!t.display){this.width=this.height=0;return}const i=t.labels,s=ht(i.font),o=s.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=ia(i,o);let c,u;n.font=s.string,this.isHorizontal()?(c=this.maxWidth,u=this._fitRows(r,o,a,l)+10):(u=this.maxHeight,c=this._fitCols(r,s,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(u,t.maxHeight||this.maxHeight)}_fitRows(t,n,i,s){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],u=s+a;let f=t;o.textAlign="left",o.textBaseline="middle";let d=-1,m=-u;return this.legendItems.forEach((y,x)=>{const v=i+n/2+o.measureText(y.text).width;(x===0||c[c.length-1]+v+2*a>r)&&(f+=u,c[c.length-(x>0?0:1)]=0,m+=u,d++),l[x]={left:0,top:m,row:d,width:v,height:s},c[c.length-1]+=v+a}),f}_fitCols(t,n,i,s){const{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],u=r-t;let f=a,d=0,m=0,y=0,x=0;return this.legendItems.forEach((v,w)=>{const{itemWidth:k,itemHeight:E}=zg(i,n,o,v,s);w>0&&m+E+2*a>u&&(f+=d+a,c.push({width:d,height:m}),y+=d+a,x++,d=m=0),l[w]={left:y,top:m,col:x,width:k,height:E},d=Math.max(d,k),m+=E+a}),f+=d,c.push({width:d,height:m}),f}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:i,labels:{padding:s},rtl:o}}=this,r=Ge(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=ft(i,this.left+s,this.right-this.lineWidths[a]);for(const c of n)a!==c.row&&(a=c.row,l=ft(i,this.left+s,this.right-this.lineWidths[a])),c.top+=this.top+t+s,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+s}else{let a=0,l=ft(i,this.top+t+s,this.bottom-this.columnSizes[a].height);for(const c of n)c.col!==a&&(a=c.col,l=ft(i,this.top+t+s,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+s,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+s}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;vo(t,this),this._draw(),_o(t)}}_draw(){const{options:t,columnSizes:n,lineWidths:i,ctx:s}=this,{align:o,labels:r}=t,a=Y.color,l=Ge(t.rtl,this.left,this.width),c=ht(r.font),{padding:u}=r,f=c.size,d=f/2;let m;this.drawTitle(),s.textAlign=l.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:y,boxHeight:x,itemHeight:v}=ia(r,f),w=function(D,P,O){if(isNaN(y)||y<=0||isNaN(x)||x<0)return;s.save();const A=R(O.lineWidth,1);if(s.fillStyle=R(O.fillStyle,a),s.lineCap=R(O.lineCap,"butt"),s.lineDashOffset=R(O.lineDashOffset,0),s.lineJoin=R(O.lineJoin,"miter"),s.lineWidth=A,s.strokeStyle=R(O.strokeStyle,a),s.setLineDash(R(O.lineDash,[])),r.usePointStyle){const z={radius:x*Math.SQRT2/2,pointStyle:O.pointStyle,rotation:O.rotation,borderWidth:A},L=l.xPlus(D,y/2),H=P+d;Hl(s,z,L,H,r.pointStyleWidth&&y)}else{const z=P+Math.max((f-x)/2,0),L=l.leftForLtr(D,y),H=On(O.borderRadius);s.beginPath(),Object.values(H).some(Z=>Z!==0)?Bs(s,{x:L,y:z,w:y,h:x,radius:H}):s.rect(L,z,y,x),s.fill(),A!==0&&s.stroke()}s.restore()},k=function(D,P,O){Di(s,O.text,D,P+v/2,c,{strikethrough:O.hidden,textAlign:l.textAlign(O.textAlign)})},E=this.isHorizontal(),C=this._computeTitleHeight();E?m={x:ft(o,this.left+u,this.right-i[0]),y:this.top+u+C,line:0}:m={x:this.left+u,y:ft(o,this.top+C+u,this.bottom-n[0].height),line:0},Yl(this.ctx,t.textDirection);const T=v+u;this.legendItems.forEach((D,P)=>{s.strokeStyle=D.fontColor,s.fillStyle=D.fontColor;const O=s.measureText(D.text).width,A=l.textAlign(D.textAlign||(D.textAlign=r.textAlign)),z=y+d+O;let L=m.x,H=m.y;l.setWidth(this.width),E?P>0&&L+z+u>this.right&&(H=m.y+=T,m.line++,L=m.x=ft(o,this.left+u,this.right-i[m.line])):P>0&&H+T>this.bottom&&(L=m.x=L+n[m.line].width+u,m.line++,H=m.y=ft(o,this.top+C+u,this.bottom-n[m.line].height));const Z=l.x(L);if(w(Z,H,D),L=Gf(A,L+y+d,E?L+z:this.right,t.rtl),k(l.x(L),H,D),E)m.x+=z+u;else if(typeof D.text!="string"){const nt=c.lineHeight;m.y+=cc(D,nt)+u}else m.y+=T}),Xl(this.ctx,t.textDirection)}drawTitle(){const t=this.options,n=t.title,i=ht(n.font),s=Mt(n.padding);if(!n.display)return;const o=Ge(t.rtl,this.left,this.width),r=this.ctx,a=n.position,l=i.size/2,c=s.top+l;let u,f=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),u=this.top+c,f=ft(t.align,f,this.right-d);else{const y=this.columnSizes.reduce((x,v)=>Math.max(x,v.height),0);u=c+ft(t.align,this.top,this.bottom-y-t.labels.padding-this._computeTitleHeight())}const m=ft(a,f,f+d);r.textAlign=o.textAlign(Nl(a)),r.textBaseline="middle",r.strokeStyle=n.color,r.fillStyle=n.color,r.font=i.string,Di(r,n.text,m,u,i)}_computeTitleHeight(){const t=this.options.title,n=ht(t.font),i=Mt(t.padding);return t.display?n.lineHeight+i.height:0}_getLegendItemAt(t,n){let i,s,o;if(Sn(t,this.left,this.right)&&Sn(n,this.top,this.bottom)){for(o=this.legendHitBoxes,i=0;i<o.length;++i)if(s=o[i],Sn(t,s.left,s.left+s.width)&&Sn(n,s.top,s.top+s.height))return this.legendItems[i]}return null}handleEvent(t){const n=this.options;if(!Bg(t.type,n))return;const i=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){const s=this._hoveredItem,o=Fg(s,i);s&&!o&&I(n.onLeave,[t,s,this],this),this._hoveredItem=i,i&&!o&&I(n.onHover,[t,i,this],this)}else i&&I(n.onClick,[t,i,this],this)}}function zg(e,t,n,i,s){const o=Hg(i,e,t,n),r=Vg(s,i,t.lineHeight);return{itemWidth:o,itemHeight:r}}function Hg(e,t,n,i){let s=e.text;return s&&typeof s!="string"&&(s=s.reduce((o,r)=>o.length>r.length?o:r)),t+n.size/2+i.measureText(s).width}function Vg(e,t,n){let i=e;return typeof t.text!="string"&&(i=cc(t,n)),i}function cc(e,t){const n=e.text?e.text.length:0;return t*n}function Bg(e,t){return!!((e==="mousemove"||e==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(e==="click"||e==="mouseup"))}var Wg={id:"legend",_element:sa,start(e,t,n){const i=e.legend=new sa({ctx:e.ctx,options:n,chart:e});ne.configure(e,i,n),ne.addBox(e,i)},stop(e){ne.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){const i=e.legend;ne.configure(e,i,n),i.options=n},afterUpdate(e){const t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){const i=t.datasetIndex,s=n.chart;s.isDatasetVisible(i)?(s.hide(i),t.hidden=!0):(s.show(i),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){const t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:i,textAlign:s,color:o,useBorderRadius:r,borderRadius:a}}=e.legend.options;return e._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(n?0:void 0),u=Mt(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(u.width+u.height)/4,strokeStyle:c.borderColor,pointStyle:i||c.pointStyle,rotation:c.rotation,textAlign:s||c.textAlign,borderRadius:r&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:e=>!e.startsWith("on"),labels:{_scriptable:e=>!["generateLabels","filter","sort"].includes(e)}}};const Tn={average(e){if(!e.length)return!1;let t,n,i=new Set,s=0,o=0;for(t=0,n=e.length;t<n;++t){const a=e[t].element;if(a&&a.hasValue()){const l=a.tooltipPosition();i.add(l.x),s+=l.y,++o}}return o===0||i.size===0?!1:{x:[...i].reduce((a,l)=>a+l)/i.size,y:s/o}},nearest(e,t){if(!e.length)return!1;let n=t.x,i=t.y,s=Number.POSITIVE_INFINITY,o,r,a;for(o=0,r=e.length;o<r;++o){const l=e[o].element;if(l&&l.hasValue()){const c=l.getCenterPoint(),u=zs(t,c);u<s&&(s=u,a=l)}}if(a){const l=a.tooltipPosition();n=l.x,i=l.y}return{x:n,y:i}}};function Dt(e,t){return t&&(tt(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function Ut(e){return(typeof e=="string"||e instanceof String)&&e.indexOf(\`
9293
+ */class ip{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(t,n,i,s){const o=n.listeners[s],r=n.duration;o.forEach(a=>a({chart:t,initial:n.initial,numSteps:r,currentStep:Math.min(i-n.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=Nl.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(t=Date.now()){let n=0;this._charts.forEach((i,s)=>{if(!i.running||!i.items.length)return;const o=i.items;let r=o.length-1,a=!1,l;for(;r>=0;--r)l=o[r],l._active?(l._total>i.duration&&(i.duration=l._total),l.tick(t),a=!0):(o[r]=o[o.length-1],o.pop());a&&(s.draw(),this._notify(s,i,t,"progress")),o.length||(i.running=!1,this._notify(s,i,t,"complete"),i.initial=!1),n+=o.length}),this._lastDate=t,n===0&&(this._running=!1)}_getAnims(t){const n=this._charts;let i=n.get(t);return i||(i={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},n.set(t,i)),i}listen(t,n,i){this._getAnims(t).listeners[n].push(i)}add(t,n){!n||!n.length||this._getAnims(t).items.push(...n)}has(t){return this._getAnims(t).items.length>0}start(t){const n=this._charts.get(t);n&&(n.running=!0,n.start=Date.now(),n.duration=n.items.reduce((i,s)=>Math.max(i,s._duration),0),this._refresh())}running(t){if(!this._running)return!1;const n=this._charts.get(t);return!(!n||!n.running||!n.items.length)}stop(t){const n=this._charts.get(t);if(!n||!n.items.length)return;const i=n.items;let s=i.length-1;for(;s>=0;--s)i[s].cancel();n.items=[],this._notify(t,n,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var $t=new ip;const Ar="transparent",sp={boolean(e,t,n){return n>.5?t:e},color(e,t,n){const i=_r(e||Ar),s=i.valid&&_r(t||Ar);return s&&s.valid?s.mix(i,n).hexString():t},number(e,t,n){return e+(t-e)*n}};class op{constructor(t,n,i,s){const o=n[i];s=ii([t.to,s,o,t.from]);const r=ii([t.from,o,s]);this._active=!0,this._fn=t.fn||sp[t.type||typeof r],this._easing=En[t.easing]||En.linear,this._start=Math.floor(Date.now()+(t.delay||0)),this._duration=this._total=Math.floor(t.duration),this._loop=!!t.loop,this._target=n,this._prop=i,this._from=r,this._to=s,this._promises=void 0}active(){return this._active}update(t,n,i){if(this._active){this._notify(!1);const s=this._target[this._prop],o=i-this._start,r=this._duration-o;this._start=i,this._duration=Math.floor(Math.max(r,t.duration)),this._total+=o,this._loop=!!t.loop,this._to=ii([t.to,n,s,t.from]),this._from=ii([t.from,s,n])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(t){const n=t-this._start,i=this._duration,s=this._prop,o=this._from,r=this._loop,a=this._to;let l;if(this._active=o!==a&&(r||n<i),!this._active){this._target[s]=a,this._notify(!0);return}if(n<0){this._target[s]=o;return}l=n/i%2,l=r&&l>1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[s]=this._fn(o,a,l)}wait(){const t=this._promises||(this._promises=[]);return new Promise((n,i)=>{t.push({res:n,rej:i})})}_notify(t){const n=t?"res":"rej",i=this._promises||[];for(let s=0;s<i.length;s++)i[s][n]()}}class Zl{constructor(t,n){this._chart=t,this._properties=new Map,this.configure(n)}configure(t){if(!V(t))return;const n=Object.keys(Y.animation),i=this._properties;Object.getOwnPropertyNames(t).forEach(s=>{const o=t[s];if(!V(o))return;const r={};for(const a of n)r[a]=o[a];(tt(o.properties)&&o.properties||[s]).forEach(a=>{(a===s||!i.has(a))&&i.set(a,r)})})}_animateOptions(t,n){const i=n.options,s=ap(t,i);if(!s)return[];const o=this._createAnimations(s,i);return i.$shared&&rp(t.options.$animations,i).then(()=>{t.options=i},()=>{}),o}_createAnimations(t,n){const i=this._properties,s=[],o=t.$animations||(t.$animations={}),r=Object.keys(n),a=Date.now();let l;for(l=r.length-1;l>=0;--l){const c=r[l];if(c.charAt(0)==="$")continue;if(c==="options"){s.push(...this._animateOptions(t,n));continue}const u=n[c];let f=o[c];const d=i.get(c);if(f)if(d&&f.active()){f.update(d,u,a);continue}else f.cancel();if(!d||!d.duration){t[c]=u;continue}o[c]=f=new op(d,t,c,u),s.push(f)}return s}update(t,n){if(this._properties.size===0){Object.assign(t,n);return}const i=this._createAnimations(t,n);if(i.length)return $t.add(this._chart,i),!0}}function rp(e,t){const n=[],i=Object.keys(t);for(let s=0;s<i.length;s++){const o=e[i[s]];o&&o.active()&&n.push(o.wait())}return Promise.all(n)}function ap(e,t){if(!t)return;let n=e.options;if(!n){e.options=t;return}return n.$shared&&(e.options=n=Object.assign({},n,{$shared:!1,$animations:{}})),n}function Ir(e,t){const n=e&&e.options||{},i=n.reverse,s=n.min===void 0?t:0,o=n.max===void 0?t:0;return{start:i?o:s,end:i?s:o}}function lp(e,t,n){if(n===!1)return!1;const i=Ir(e,n),s=Ir(t,n);return{top:s.end,right:i.end,bottom:s.start,left:i.start}}function cp(e){let t,n,i,s;return V(e)?(t=e.top,n=e.right,i=e.bottom,s=e.left):t=n=i=s=e,{top:t,right:n,bottom:i,left:s,disabled:e===!1}}function Ql(e,t){const n=[],i=e._getSortedDatasetMetas(t);let s,o;for(s=0,o=i.length;s<o;++s)n.push(i[s].index);return n}function Lr(e,t,n,i={}){const s=e.keys,o=i.mode==="single";let r,a,l,c;if(t===null)return;let u=!1;for(r=0,a=s.length;r<a;++r){if(l=+s[r],l===n){if(u=!0,i.all)continue;break}c=e.values[l],vt(c)&&(o||t===0||he(t)===he(c))&&(t+=c)}return!u&&!i.all?0:t}function up(e,t){const{iScale:n,vScale:i}=t,s=n.axis==="x"?"x":"y",o=i.axis==="x"?"x":"y",r=Object.keys(e),a=new Array(r.length);let l,c,u;for(l=0,c=r.length;l<c;++l)u=r[l],a[l]={[s]:u,[o]:e[u]};return a}function ss(e,t){const n=e&&e.options.stacked;return n||n===void 0&&t.stack!==void 0}function hp(e,t,n){return\`\${e.id}.\${t.id}.\${n.stack||n.type}\`}function fp(e){const{min:t,max:n,minDefined:i,maxDefined:s}=e.getUserBounds();return{min:i?t:Number.NEGATIVE_INFINITY,max:s?n:Number.POSITIVE_INFINITY}}function dp(e,t,n){const i=e[t]||(e[t]={});return i[n]||(i[n]={})}function Rr(e,t,n,i){for(const s of t.getMatchingVisibleMetas(i).reverse()){const o=e[s.index];if(n&&o>0||!n&&o<0)return s.index}return null}function Nr(e,t){const{chart:n,_cachedMeta:i}=e,s=n._stacks||(n._stacks={}),{iScale:o,vScale:r,index:a}=i,l=o.axis,c=r.axis,u=hp(o,r,i),f=t.length;let d;for(let m=0;m<f;++m){const y=t[m],{[l]:x,[c]:v}=y,w=y._stacks||(y._stacks={});d=w[c]=dp(s,u,x),d[a]=v,d._top=Rr(d,r,!0,i.type),d._bottom=Rr(d,r,!1,i.type);const k=d._visualValues||(d._visualValues={});k[a]=v}}function os(e,t){const n=e.scales;return Object.keys(n).filter(i=>n[i].axis===t).shift()}function pp(e,t){return Ve(e,{active:!1,dataset:void 0,datasetIndex:t,index:t,mode:"default",type:"dataset"})}function gp(e,t,n){return Ve(e,{active:!1,dataIndex:t,parsed:void 0,raw:void 0,element:n,index:t,mode:"default",type:"data"})}function mn(e,t){const n=e.controller.index,i=e.vScale&&e.vScale.axis;if(i){t=t||e._parsed;for(const s of t){const o=s._stacks;if(!o||o[i]===void 0||o[i][n]===void 0)return;delete o[i][n],o[i]._visualValues!==void 0&&o[i]._visualValues[n]!==void 0&&delete o[i]._visualValues[n]}}}const rs=e=>e==="reset"||e==="none",Fr=(e,t)=>t?e:Object.assign({},e),mp=(e,t,n)=>e&&!t.hidden&&t._stacked&&{keys:Ql(n,!0),values:null};class Jl{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,n){this.chart=t,this._ctx=t.ctx,this.index=n,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const t=this._cachedMeta;this.configure(),this.linkScales(),t._stacked=ss(t.vScale,t),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&mn(this._cachedMeta),this.index=t}linkScales(){const t=this.chart,n=this._cachedMeta,i=this.getDataset(),s=(f,d,m,y)=>f==="x"?d:f==="r"?y:m,o=n.xAxisID=R(i.xAxisID,os(t,"x")),r=n.yAxisID=R(i.yAxisID,os(t,"y")),a=n.rAxisID=R(i.rAxisID,os(t,"r")),l=n.indexAxis,c=n.iAxisID=s(l,o,r,a),u=n.vAxisID=s(l,r,o,a);n.xScale=this.getScaleForId(o),n.yScale=this.getScaleForId(r),n.rScale=this.getScaleForId(a),n.iScale=this.getScaleForId(c),n.vScale=this.getScaleForId(u)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const n=this._cachedMeta;return t===n.iScale?n.vScale:n.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&xr(this._data,this),t._stacked&&mn(t)}_dataCheck(){const t=this.getDataset(),n=t.data||(t.data=[]),i=this._data;if(V(n)){const s=this._cachedMeta;this._data=up(n,s)}else if(i!==n){if(i){xr(i,this);const s=this._cachedMeta;mn(s),s._parsed=[]}n&&Object.isExtensible(n)&&Xf(n,this),this._syncList=[],this._data=n}}addElements(){const t=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const n=this._cachedMeta,i=this.getDataset();let s=!1;this._dataCheck();const o=n._stacked;n._stacked=ss(n.vScale,n),n.stack!==i.stack&&(s=!0,mn(n),n.stack=i.stack),this._resyncElements(t),(s||o!==n._stacked)&&(Nr(this,n._parsed),n._stacked=ss(n.vScale,n))}configure(){const t=this.chart.config,n=t.datasetScopeKeys(this._type),i=t.getOptionScopes(this.getDataset(),n,!0);this.options=t.createResolver(i,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(t,n){const{_cachedMeta:i,_data:s}=this,{iScale:o,_stacked:r}=i,a=o.axis;let l=t===0&&n===s.length?!0:i._sorted,c=t>0&&i._parsed[t-1],u,f,d;if(this._parsing===!1)i._parsed=s,i._sorted=!0,d=s;else{tt(s[t])?d=this.parseArrayData(i,s,t,n):V(s[t])?d=this.parseObjectData(i,s,t,n):d=this.parsePrimitiveData(i,s,t,n);const m=()=>f[a]===null||c&&f[a]<c[a];for(u=0;u<n;++u)i._parsed[u+t]=f=d[u],l&&(m()&&(l=!1),c=f);i._sorted=l}r&&Nr(this,d)}parsePrimitiveData(t,n,i,s){const{iScale:o,vScale:r}=t,a=o.axis,l=r.axis,c=o.getLabels(),u=o===r,f=new Array(s);let d,m,y;for(d=0,m=s;d<m;++d)y=d+i,f[d]={[a]:u||o.parse(c[y],y),[l]:r.parse(n[y],y)};return f}parseArrayData(t,n,i,s){const{xScale:o,yScale:r}=t,a=new Array(s);let l,c,u,f;for(l=0,c=s;l<c;++l)u=l+i,f=n[u],a[l]={x:o.parse(f[0],u),y:r.parse(f[1],u)};return a}parseObjectData(t,n,i,s){const{xScale:o,yScale:r}=t,{xAxisKey:a="x",yAxisKey:l="y"}=this._parsing,c=new Array(s);let u,f,d,m;for(u=0,f=s;u<f;++u)d=u+i,m=n[d],c[u]={x:o.parse(Ei(m,a),d),y:r.parse(Ei(m,l),d)};return c}getParsed(t){return this._cachedMeta._parsed[t]}getDataElement(t){return this._cachedMeta.data[t]}applyStack(t,n,i){const s=this.chart,o=this._cachedMeta,r=n[t.axis],a={keys:Ql(s,!0),values:n._stacks[t.axis]._visualValues};return Lr(a,r,o.index,{mode:i})}updateRangeFromParsed(t,n,i,s){const o=i[n.axis];let r=o===null?NaN:o;const a=s&&i._stacks[n.axis];s&&a&&(s.values=a,r=Lr(s,o,this._cachedMeta.index)),t.min=Math.min(t.min,r),t.max=Math.max(t.max,r)}getMinMax(t,n){const i=this._cachedMeta,s=i._parsed,o=i._sorted&&t===i.iScale,r=s.length,a=this._getOtherScale(t),l=mp(n,i,this.chart),c={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY},{min:u,max:f}=fp(a);let d,m;function y(){m=s[d];const x=m[a.axis];return!vt(m[t.axis])||u>x||f<x}for(d=0;d<r&&!(!y()&&(this.updateRangeFromParsed(c,t,m,l),o));++d);if(o){for(d=r-1;d>=0;--d)if(!y()){this.updateRangeFromParsed(c,t,m,l);break}}return c}getAllParsedValues(t){const n=this._cachedMeta._parsed,i=[];let s,o,r;for(s=0,o=n.length;s<o;++s)r=n[s][t.axis],vt(r)&&i.push(r);return i}getMaxOverflow(){return!1}getLabelAndValue(t){const n=this._cachedMeta,i=n.iScale,s=n.vScale,o=this.getParsed(t);return{label:i?""+i.getLabelForValue(o[i.axis]):"",value:s?""+s.getLabelForValue(o[s.axis]):""}}_update(t){const n=this._cachedMeta;this.update(t||"default"),n._clip=cp(R(this.options.clip,lp(n.xScale,n.yScale,this.getMaxOverflow())))}update(t){}draw(){const t=this._ctx,n=this.chart,i=this._cachedMeta,s=i.data||[],o=n.chartArea,r=[],a=this._drawStart||0,l=this._drawCount||s.length-a,c=this.options.drawActiveElementsOnTop;let u;for(i.dataset&&i.dataset.draw(t,o,a,l),u=a;u<a+l;++u){const f=s[u];f.hidden||(f.active&&c?r.push(f):f.draw(t,o))}for(u=0;u<r.length;++u)r[u].draw(t,o)}getStyle(t,n){const i=n?"active":"default";return t===void 0&&this._cachedMeta.dataset?this.resolveDatasetElementOptions(i):this.resolveDataElementOptions(t||0,i)}getContext(t,n,i){const s=this.getDataset();let o;if(t>=0&&t<this._cachedMeta.data.length){const r=this._cachedMeta.data[t];o=r.$context||(r.$context=gp(this.getContext(),t,r)),o.parsed=this.getParsed(t),o.raw=s.data[t],o.index=o.dataIndex=t}else o=this.$context||(this.$context=pp(this.chart.getContext(),this.index)),o.dataset=s,o.index=o.datasetIndex=this.index;return o.active=!!n,o.mode=i,o}resolveDatasetElementOptions(t){return this._resolveElementOptions(this.datasetElementType.id,t)}resolveDataElementOptions(t,n){return this._resolveElementOptions(this.dataElementType.id,n,t)}_resolveElementOptions(t,n="default",i){const s=n==="active",o=this._cachedDataOpts,r=t+"-"+n,a=o[r],l=this.enableOptionSharing&&Ci(i);if(a)return Fr(a,l);const c=this.chart.config,u=c.datasetElementScopeKeys(this._type,t),f=s?[\`\${t}Hover\`,"hover",t,""]:[t,""],d=c.getOptionScopes(this.getDataset(),u),m=Object.keys(Y.elements[t]),y=()=>this.getContext(i,s,n),x=c.resolveNamedOptions(d,m,y,f);return x.$shared&&(x.$shared=l,o[r]=Object.freeze(Fr(x,l))),x}_resolveAnimations(t,n,i){const s=this.chart,o=this._cachedDataOpts,r=\`animation-\${n}\`,a=o[r];if(a)return a;let l;if(s.options.animation!==!1){const u=this.chart.config,f=u.datasetAnimationScopeKeys(this._type,n),d=u.getOptionScopes(this.getDataset(),f);l=u.createResolver(d,this.getContext(t,i,n))}const c=new Zl(s,l&&l.animations);return l&&l._cacheable&&(o[r]=Object.freeze(c)),c}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,n){return!n||rs(t)||this.chart._animationsDisabled}_getSharedOptions(t,n){const i=this.resolveDataElementOptions(t,n),s=this._sharedOptions,o=this.getSharedOptions(i),r=this.includeOptions(n,o)||o!==s;return this.updateSharedOptions(o,n,i),{sharedOptions:o,includeOptions:r}}updateElement(t,n,i,s){rs(s)?Object.assign(t,i):this._resolveAnimations(n,s).update(t,i)}updateSharedOptions(t,n,i){t&&!rs(n)&&this._resolveAnimations(void 0,n).update(t,i)}_setStyle(t,n,i,s){t.active=s;const o=this.getStyle(n,s);this._resolveAnimations(n,i,s).update(t,{options:!s&&this.getSharedOptions(o)||o})}removeHoverStyle(t,n,i){this._setStyle(t,i,"active",!1)}setHoverStyle(t,n,i){this._setStyle(t,i,"active",!0)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!1)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",!0)}_resyncElements(t){const n=this._data,i=this._cachedMeta.data;for(const[a,l,c]of this._syncList)this[a](l,c);this._syncList=[];const s=i.length,o=n.length,r=Math.min(o,s);r&&this.parse(0,r),o>s?this._insertElements(s,o-s,t):o<s&&this._removeElements(o,s-o)}_insertElements(t,n,i=!0){const s=this._cachedMeta,o=s.data,r=t+n;let a;const l=c=>{for(c.length+=n,a=c.length-1;a>=r;a--)c[a]=c[a-n]};for(l(o),a=t;a<r;++a)o[a]=new this.dataElementType;this._parsing&&l(s._parsed),this.parse(t,n),i&&this.updateElements(o,t,n,"reset")}updateElements(t,n,i,s){}_removeElements(t,n){const i=this._cachedMeta;if(this._parsing){const s=i._parsed.splice(t,n);i._stacked&&mn(i,s)}i.data.splice(t,n)}_sync(t){if(this._parsing)this._syncList.push(t);else{const[n,i,s]=t;this[n](i,s)}this.chart._dataChanges.push([this.index,...t])}_onDataPush(){const t=arguments.length;this._sync(["_insertElements",this.getDataset().data.length-t,t])}_onDataPop(){this._sync(["_removeElements",this._cachedMeta.data.length-1,1])}_onDataShift(){this._sync(["_removeElements",0,1])}_onDataSplice(t,n){n&&this._sync(["_removeElements",t,n]);const i=arguments.length-2;i&&this._sync(["_insertElements",t,i])}_onDataUnshift(){this._sync(["_insertElements",0,arguments.length])}}class bp extends Jl{static id="line";static defaults={datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1};static overrides={scales:{_index_:{type:"category"},_value_:{type:"linear"}}};initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(t){const n=this._cachedMeta,{dataset:i,data:s=[],_dataset:o}=n,r=this.chart._animationsDisabled;let{start:a,count:l}=Zf(n,s,r);this._drawStart=a,this._drawCount=l,Qf(n)&&(a=0,l=s.length),i._chart=this.chart,i._datasetIndex=this.index,i._decimated=!!o._decimated,i.points=s;const c=this.resolveDatasetElementOptions(t);this.options.showLine||(c.borderWidth=0),c.segment=this.options.segment,this.updateElement(i,void 0,{animated:!r,options:c},t),this.updateElements(s,a,l,t)}updateElements(t,n,i,s){const o=s==="reset",{iScale:r,vScale:a,_stacked:l,_dataset:c}=this._cachedMeta,{sharedOptions:u,includeOptions:f}=this._getSharedOptions(n,s),d=r.axis,m=a.axis,{spanGaps:y,segment:x}=this.options,v=Rn(y)?y:Number.POSITIVE_INFINITY,w=this.chart._animationsDisabled||o||s==="none",k=n+i,E=t.length;let C=n>0&&this.getParsed(n-1);for(let T=0;T<E;++T){const D=t[T],P=w?D:{};if(T<n||T>=k){P.skip=!0;continue}const O=this.getParsed(T),A=B(O[m]),z=P[d]=r.getPixelForValue(O[d],T),L=P[m]=o||A?a.getBasePixel():a.getPixelForValue(l?this.applyStack(a,O,l):O[m],T);P.skip=isNaN(z)||isNaN(L)||A,P.stop=T>0&&Math.abs(O[d]-C[d])>v,x&&(P.parsed=O,P.raw=c.data[T]),f&&(P.options=u||this.resolveDataElementOptions(T,D.active?"active":s)),w||this.updateElement(D,T,P,s),C=O}}getMaxOverflow(){const t=this._cachedMeta,n=t.dataset,i=n.options&&n.options.borderWidth||0,s=t.data||[];if(!s.length)return i;const o=s[0].size(this.resolveDataElementOptions(0)),r=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(i,o,r)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis),super.draw()}}function Te(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class Eo{static override(t){Object.assign(Eo.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Te()}parse(){return Te()}format(){return Te()}add(){return Te()}diff(){return Te()}startOf(){return Te()}endOf(){return Te()}}var xp={_date:Eo};function yp(e,t,n,i){const{controller:s,data:o,_sorted:r}=e,a=s._cachedMeta.iScale,l=e.dataset&&e.dataset.options?e.dataset.options.spanGaps:null;if(a&&t===a.axis&&t!=="r"&&r&&o.length){const c=a._reversePixels?Uf:De;if(i){if(s._sharedOptions){const u=o[0],f=typeof u.getRange=="function"&&u.getRange(t);if(f){const d=c(o,t,n-f),m=c(o,t,n+f);return{lo:d.lo,hi:m.hi}}}}else{const u=c(o,t,n);if(l){const{vScale:f}=s._cachedMeta,{_parsed:d}=e,m=d.slice(0,u.lo+1).reverse().findIndex(x=>!B(x[f.axis]));u.lo-=Math.max(0,m);const y=d.slice(u.hi).findIndex(x=>!B(x[f.axis]));u.hi+=Math.max(0,y)}return u}}return{lo:0,hi:o.length-1}}function Bi(e,t,n,i,s){const o=e.getSortedVisibleDatasetMetas(),r=n[t];for(let a=0,l=o.length;a<l;++a){const{index:c,data:u}=o[a],{lo:f,hi:d}=yp(o[a],t,r,s);for(let m=f;m<=d;++m){const y=u[m];y.skip||i(y,c,m)}}}function vp(e){const t=e.indexOf("x")!==-1,n=e.indexOf("y")!==-1;return function(i,s){const o=t?Math.abs(i.x-s.x):0,r=n?Math.abs(i.y-s.y):0;return Math.sqrt(Math.pow(o,2)+Math.pow(r,2))}}function as(e,t,n,i,s){const o=[];return!s&&!e.isPointInArea(t)||Bi(e,n,t,function(a,l,c){!s&&!en(a,e.chartArea,0)||a.inRange(t.x,t.y,i)&&o.push({element:a,datasetIndex:l,index:c})},!0),o}function _p(e,t,n,i){let s=[];function o(r,a,l){const{startAngle:c,endAngle:u}=r.getProps(["startAngle","endAngle"],i),{angle:f}=Wf(r,{x:t.x,y:t.y});Ll(f,c,u)&&s.push({element:r,datasetIndex:a,index:l})}return Bi(e,n,t,o),s}function wp(e,t,n,i,s,o){let r=[];const a=vp(n);let l=Number.POSITIVE_INFINITY;function c(u,f,d){const m=u.inRange(t.x,t.y,s);if(i&&!m)return;const y=u.getCenterPoint(s);if(!(!!o||e.isPointInArea(y))&&!m)return;const v=a(t,y);v<l?(r=[{element:u,datasetIndex:f,index:d}],l=v):v===l&&r.push({element:u,datasetIndex:f,index:d})}return Bi(e,n,t,c),r}function ls(e,t,n,i,s,o){return!o&&!e.isPointInArea(t)?[]:n==="r"&&!i?_p(e,t,n,s):wp(e,t,n,i,s,o)}function zr(e,t,n,i,s){const o=[],r=n==="x"?"inXRange":"inYRange";let a=!1;return Bi(e,n,t,(l,c,u)=>{l[r]&&l[r](t[n],s)&&(o.push({element:l,datasetIndex:c,index:u}),a=a||l.inRange(t.x,t.y,s))}),i&&!a?[]:o}var Sp={modes:{index(e,t,n,i){const s=It(t,e),o=n.axis||"x",r=n.includeInvisible||!1,a=n.intersect?as(e,s,o,i,r):ls(e,s,o,!1,i,r),l=[];return a.length?(e.getSortedVisibleDatasetMetas().forEach(c=>{const u=a[0].index,f=c.data[u];f&&!f.skip&&l.push({element:f,datasetIndex:c.index,index:u})}),l):[]},dataset(e,t,n,i){const s=It(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;let a=n.intersect?as(e,s,o,i,r):ls(e,s,o,!1,i,r);if(a.length>0){const l=a[0].datasetIndex,c=e.getDatasetMeta(l).data;a=[];for(let u=0;u<c.length;++u)a.push({element:c[u],datasetIndex:l,index:u})}return a},point(e,t,n,i){const s=It(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return as(e,s,o,i,r)},nearest(e,t,n,i){const s=It(t,e),o=n.axis||"xy",r=n.includeInvisible||!1;return ls(e,s,o,n.intersect,i,r)},x(e,t,n,i){const s=It(t,e);return zr(e,s,"x",n.intersect,i)},y(e,t,n,i){const s=It(t,e);return zr(e,s,"y",n.intersect,i)}}};const tc=["left","top","right","bottom"];function bn(e,t){return e.filter(n=>n.pos===t)}function Hr(e,t){return e.filter(n=>tc.indexOf(n.pos)===-1&&n.box.axis===t)}function xn(e,t){return e.sort((n,i)=>{const s=t?i:n,o=t?n:i;return s.weight===o.weight?s.index-o.index:s.weight-o.weight})}function kp(e){const t=[];let n,i,s,o,r,a;for(n=0,i=(e||[]).length;n<i;++n)s=e[n],{position:o,options:{stack:r,stackWeight:a=1}}=s,t.push({index:n,box:s,pos:o,horizontal:s.isHorizontal(),weight:s.weight,stack:r&&o+r,stackWeight:a});return t}function Tp(e){const t={};for(const n of e){const{stack:i,pos:s,stackWeight:o}=n;if(!i||!tc.includes(s))continue;const r=t[i]||(t[i]={count:0,placed:0,weight:0,size:0});r.count++,r.weight+=o}return t}function Mp(e,t){const n=Tp(e),{vBoxMaxWidth:i,hBoxMaxHeight:s}=t;let o,r,a;for(o=0,r=e.length;o<r;++o){a=e[o];const{fullSize:l}=a.box,c=n[a.stack],u=c&&a.stackWeight/c.weight;a.horizontal?(a.width=u?u*i:l&&t.availableWidth,a.height=s):(a.width=i,a.height=u?u*s:l&&t.availableHeight)}return n}function Ep(e){const t=kp(e),n=xn(t.filter(c=>c.box.fullSize),!0),i=xn(bn(t,"left"),!0),s=xn(bn(t,"right")),o=xn(bn(t,"top"),!0),r=xn(bn(t,"bottom")),a=Hr(t,"x"),l=Hr(t,"y");return{fullSize:n,leftAndTop:i.concat(o),rightAndBottom:s.concat(l).concat(r).concat(a),chartArea:bn(t,"chartArea"),vertical:i.concat(s).concat(l),horizontal:o.concat(r).concat(a)}}function Vr(e,t,n,i){return Math.max(e[n],t[n])+Math.max(e[i],t[i])}function ec(e,t){e.top=Math.max(e.top,t.top),e.left=Math.max(e.left,t.left),e.bottom=Math.max(e.bottom,t.bottom),e.right=Math.max(e.right,t.right)}function Cp(e,t,n,i){const{pos:s,box:o}=n,r=e.maxPadding;if(!V(s)){n.size&&(e[s]-=n.size);const f=i[n.stack]||{size:0,count:1};f.size=Math.max(f.size,n.horizontal?o.height:o.width),n.size=f.size/f.count,e[s]+=n.size}o.getPadding&&ec(r,o.getPadding());const a=Math.max(0,t.outerWidth-Vr(r,e,"left","right")),l=Math.max(0,t.outerHeight-Vr(r,e,"top","bottom")),c=a!==e.w,u=l!==e.h;return e.w=a,e.h=l,n.horizontal?{same:c,other:u}:{same:u,other:c}}function Op(e){const t=e.maxPadding;function n(i){const s=Math.max(t[i]-e[i],0);return e[i]+=s,s}e.y+=n("top"),e.x+=n("left"),n("right"),n("bottom")}function Pp(e,t){const n=t.maxPadding;function i(s){const o={left:0,top:0,right:0,bottom:0};return s.forEach(r=>{o[r]=Math.max(t[r],n[r])}),o}return i(e?["left","right"]:["top","bottom"])}function kn(e,t,n,i){const s=[];let o,r,a,l,c,u;for(o=0,r=e.length,c=0;o<r;++o){a=e[o],l=a.box,l.update(a.width||t.w,a.height||t.h,Pp(a.horizontal,t));const{same:f,other:d}=Cp(t,n,a,i);c|=f&&s.length,u=u||d,l.fullSize||s.push(a)}return c&&kn(s,t,n,i)||u}function ai(e,t,n,i,s){e.top=n,e.left=t,e.right=t+i,e.bottom=n+s,e.width=i,e.height=s}function Br(e,t,n,i){const s=n.padding;let{x:o,y:r}=t;for(const a of e){const l=a.box,c=i[a.stack]||{placed:0,weight:1},u=a.stackWeight/c.weight||1;if(a.horizontal){const f=t.w*u,d=c.size||l.height;Ci(c.start)&&(r=c.start),l.fullSize?ai(l,s.left,r,n.outerWidth-s.right-s.left,d):ai(l,t.left+c.placed,r,f,d),c.start=r,c.placed+=f,r=l.bottom}else{const f=t.h*u,d=c.size||l.width;Ci(c.start)&&(o=c.start),l.fullSize?ai(l,o,s.top,d,n.outerHeight-s.bottom-s.top):ai(l,o,t.top+c.placed,d,f),c.start=o,c.placed+=f,o=l.right}}t.x=o,t.y=r}var ne={addBox(e,t){e.boxes||(e.boxes=[]),t.fullSize=t.fullSize||!1,t.position=t.position||"top",t.weight=t.weight||0,t._layers=t._layers||function(){return[{z:0,draw(n){t.draw(n)}}]},e.boxes.push(t)},removeBox(e,t){const n=e.boxes?e.boxes.indexOf(t):-1;n!==-1&&e.boxes.splice(n,1)},configure(e,t,n){t.fullSize=n.fullSize,t.position=n.position,t.weight=n.weight},update(e,t,n,i){if(!e)return;const s=Mt(e.options.layout.padding),o=Math.max(t-s.width,0),r=Math.max(n-s.height,0),a=Ep(e.boxes),l=a.vertical,c=a.horizontal;F(e.boxes,x=>{typeof x.beforeLayout=="function"&&x.beforeLayout()});const u=l.reduce((x,v)=>v.box.options&&v.box.options.display===!1?x:x+1,0)||1,f=Object.freeze({outerWidth:t,outerHeight:n,padding:s,availableWidth:o,availableHeight:r,vBoxMaxWidth:o/2/u,hBoxMaxHeight:r/2}),d=Object.assign({},s);ec(d,Mt(i));const m=Object.assign({maxPadding:d,w:o,h:r,x:s.left,y:s.top},s),y=Mp(l.concat(c),f);kn(a.fullSize,m,f,y),kn(l,m,f,y),kn(c,m,f,y)&&kn(l,m,f,y),Op(m),Br(a.leftAndTop,m,f,y),m.x+=m.w,m.y+=m.h,Br(a.rightAndBottom,m,f,y),e.chartArea={left:m.left,top:m.top,right:m.left+m.w,bottom:m.top+m.h,height:m.h,width:m.w},F(a.chartArea,x=>{const v=x.box;Object.assign(v,e.chartArea),v.update(m.w,m.h,{left:0,top:0,right:0,bottom:0})})}};class nc{acquireContext(t,n){}releaseContext(t){return!1}addEventListener(t,n,i){}removeEventListener(t,n,i){}getDevicePixelRatio(){return 1}getMaximumSize(t,n,i,s){return n=Math.max(0,n||t.width),i=i||t.height,{width:n,height:Math.max(0,s?Math.floor(n/s):i)}}isAttached(t){return!0}updateConfig(t){}}class Dp extends nc{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=!1}}const mi="$chartjs",Ap={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},Wr=e=>e===null||e==="";function Ip(e,t){const n=e.style,i=e.getAttribute("height"),s=e.getAttribute("width");if(e[mi]={initial:{height:i,width:s,style:{display:n.display,height:n.height,width:n.width}}},n.display=n.display||"block",n.boxSizing=n.boxSizing||"border-box",Wr(s)){const o=Cr(e,"width");o!==void 0&&(e.width=o)}if(Wr(i))if(e.style.height==="")e.height=e.width/(t||2);else{const o=Cr(e,"height");o!==void 0&&(e.height=o)}return e}const ic=Wd?{passive:!0}:!1;function Lp(e,t,n){e&&e.addEventListener(t,n,ic)}function Rp(e,t,n){e&&e.canvas&&e.canvas.removeEventListener(t,n,ic)}function Np(e,t){const n=Ap[e.type]||e.type,{x:i,y:s}=It(e,t);return{type:n,chart:t,native:e,x:i!==void 0?i:null,y:s!==void 0?s:null}}function Ai(e,t){for(const n of e)if(n===t||n.contains(t))return!0}function Fp(e,t,n){const i=e.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||Ai(a.addedNodes,i),r=r&&!Ai(a.removedNodes,i);r&&n()});return s.observe(document,{childList:!0,subtree:!0}),s}function zp(e,t,n){const i=e.canvas,s=new MutationObserver(o=>{let r=!1;for(const a of o)r=r||Ai(a.removedNodes,i),r=r&&!Ai(a.addedNodes,i);r&&n()});return s.observe(document,{childList:!0,subtree:!0}),s}const Nn=new Map;let jr=0;function sc(){const e=window.devicePixelRatio;e!==jr&&(jr=e,Nn.forEach((t,n)=>{n.currentDevicePixelRatio!==e&&t()}))}function Hp(e,t){Nn.size||window.addEventListener("resize",sc),Nn.set(e,t)}function Vp(e){Nn.delete(e),Nn.size||window.removeEventListener("resize",sc)}function Bp(e,t,n){const i=e.canvas,s=i&&Mo(i);if(!s)return;const o=Fl((a,l)=>{const c=s.clientWidth;n(a,l),c<s.clientWidth&&n()},window),r=new ResizeObserver(a=>{const l=a[0],c=l.contentRect.width,u=l.contentRect.height;c===0&&u===0||o(c,u)});return r.observe(s),Hp(e,o),r}function cs(e,t,n){n&&n.disconnect(),t==="resize"&&Vp(e)}function Wp(e,t,n){const i=e.canvas,s=Fl(o=>{e.ctx!==null&&n(Np(o,e))},e);return Lp(i,t,s),s}class jp extends nc{acquireContext(t,n){const i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(Ip(t,n),i):null}releaseContext(t){const n=t.canvas;if(!n[mi])return!1;const i=n[mi].initial;["height","width"].forEach(o=>{const r=i[o];B(r)?n.removeAttribute(o):n.setAttribute(o,r)});const s=i.style||{};return Object.keys(s).forEach(o=>{n.style[o]=s[o]}),n.width=n.width,delete n[mi],!0}addEventListener(t,n,i){this.removeEventListener(t,n);const s=t.$proxies||(t.$proxies={}),r={attach:Fp,detach:zp,resize:Bp}[n]||Wp;s[n]=r(t,n,i)}removeEventListener(t,n){const i=t.$proxies||(t.$proxies={}),s=i[n];if(!s)return;({attach:cs,detach:cs,resize:cs}[n]||Rp)(t,n,s),i[n]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,n,i,s){return Bd(t,n,i,s)}isAttached(t){const n=t&&Mo(t);return!!(n&&n.isConnected)}}function $p(e){return!To()||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas?Dp:jp}class on{static defaults={};static defaultRoutes=void 0;x;y;active=!1;options;$animations;tooltipPosition(t){const{x:n,y:i}=this.getProps(["x","y"],t);return{x:n,y:i}}hasValue(){return Rn(this.x)&&Rn(this.y)}getProps(t,n){const i=this.$animations;if(!n||!i)return this;const s={};return t.forEach(o=>{s[o]=i[o]&&i[o].active()?i[o]._to:this[o]}),s}}function Up(e,t){const n=e.options.ticks,i=Yp(e),s=Math.min(n.maxTicksLimit||i,i),o=n.major.enabled?qp(t):[],r=o.length,a=o[0],l=o[r-1],c=[];if(r>s)return Gp(t,c,o,r/s),c;const u=Xp(o,t,s);if(r>0){let f,d;const m=r>1?Math.round((l-a)/(r-1)):null;for(li(t,c,u,B(m)?0:a-m,a),f=0,d=r-1;f<d;f++)li(t,c,u,o[f],o[f+1]);return li(t,c,u,l,B(m)?t.length:l+m),c}return li(t,c,u),c}function Yp(e){const t=e.options.offset,n=e._tickSize(),i=e._length/n+(t?0:1),s=e._maxLength/n;return Math.floor(Math.min(i,s))}function Xp(e,t,n){const i=Kp(e),s=t.length/n;if(!i)return Math.max(s,1);const o=Ff(i);for(let r=0,a=o.length-1;r<a;r++){const l=o[r];if(l>s)return l}return Math.max(s,1)}function qp(e){const t=[];let n,i;for(n=0,i=e.length;n<i;n++)e[n].major&&t.push(n);return t}function Gp(e,t,n,i){let s=0,o=n[0],r;for(i=Math.ceil(i),r=0;r<e.length;r++)r===o&&(t.push(e[r]),s++,o=n[s*i])}function li(e,t,n,i,s){const o=R(i,0),r=Math.min(R(s,e.length),e.length);let a=0,l,c,u;for(n=Math.ceil(n),s&&(l=s-i,n=l/Math.floor(l/n)),u=o;u<0;)a++,u=Math.round(o+a*n);for(c=Math.max(o,0);c<r;c++)c===u&&(t.push(e[c]),a++,u=Math.round(o+a*n))}function Kp(e){const t=e.length;let n,i;if(t<2)return!1;for(i=e[0],n=1;n<t;++n)if(e[n]-e[n-1]!==i)return!1;return i}const Zp=e=>e==="left"?"right":e==="right"?"left":e,$r=(e,t,n)=>t==="top"||t==="left"?e[t]+n:e[t]-n,Ur=(e,t)=>Math.min(t||e,e);function Yr(e,t){const n=[],i=e.length/t,s=e.length;let o=0;for(;o<s;o+=i)n.push(e[Math.floor(o)]);return n}function Qp(e,t,n){const i=e.ticks.length,s=Math.min(t,i-1),o=e._startPixel,r=e._endPixel,a=1e-6;let l=e.getPixelForTick(s),c;if(!(n&&(i===1?c=Math.max(l-o,r-l):t===0?c=(e.getPixelForTick(1)-l)/2:c=(l-e.getPixelForTick(s-1))/2,l+=s<t?c:-c,l<o-a||l>r+a)))return l}function Jp(e,t){F(e,n=>{const i=n.gc,s=i.length/2;let o;if(s>t){for(o=0;o<s;++o)delete n.data[i[o]];i.splice(0,s)}})}function yn(e){return e.drawTicks?e.tickLength:0}function Xr(e,t){if(!e.display)return 0;const n=ht(e.font,t),i=Mt(e.padding);return(tt(e.text)?e.text.length:1)*n.lineHeight+i.height}function tg(e,t){return Ve(e,{scale:t,type:"scale"})}function eg(e,t,n){return Ve(e,{tick:n,index:t,type:"tick"})}function ng(e,t,n){let i=zl(e);return(n&&t!=="right"||!n&&t==="right")&&(i=Zp(i)),i}function ig(e,t,n,i){const{top:s,left:o,bottom:r,right:a,chart:l}=e,{chartArea:c,scales:u}=l;let f=0,d,m,y;const x=r-s,v=a-o;if(e.isHorizontal()){if(m=ft(i,o,a),V(n)){const w=Object.keys(n)[0],k=n[w];y=u[w].getPixelForValue(k)+x-t}else n==="center"?y=(c.bottom+c.top)/2+x-t:y=$r(e,n,t);d=a-o}else{if(V(n)){const w=Object.keys(n)[0],k=n[w];m=u[w].getPixelForValue(k)-v+t}else n==="center"?m=(c.left+c.right)/2-v+t:m=$r(e,n,t);y=ft(i,r,s),f=n==="left"?-kt:kt}return{titleX:m,titleY:y,maxWidth:d,rotation:f}}class rn extends on{constructor(t){super(),this.id=t.id,this.type=t.type,this.options=void 0,this.ctx=t.ctx,this.chart=t.chart,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this._margins={left:0,right:0,top:0,bottom:0},this.maxWidth=void 0,this.maxHeight=void 0,this.paddingTop=void 0,this.paddingBottom=void 0,this.paddingLeft=void 0,this.paddingRight=void 0,this.axis=void 0,this.labelRotation=void 0,this.min=void 0,this.max=void 0,this._range=void 0,this.ticks=[],this._gridLineItems=null,this._labelItems=null,this._labelSizes=null,this._length=0,this._maxLength=0,this._longestTextCache={},this._startPixel=void 0,this._endPixel=void 0,this._reversePixels=!1,this._userMax=void 0,this._userMin=void 0,this._suggestedMax=void 0,this._suggestedMin=void 0,this._ticksLength=0,this._borderValue=0,this._cache={},this._dataLimitsCached=!1,this.$context=void 0}init(t){this.options=t.setContext(this.getContext()),this.axis=t.axis,this._userMin=this.parse(t.min),this._userMax=this.parse(t.max),this._suggestedMin=this.parse(t.suggestedMin),this._suggestedMax=this.parse(t.suggestedMax)}parse(t,n){return t}getUserBounds(){let{_userMin:t,_userMax:n,_suggestedMin:i,_suggestedMax:s}=this;return t=Pt(t,Number.POSITIVE_INFINITY),n=Pt(n,Number.NEGATIVE_INFINITY),i=Pt(i,Number.POSITIVE_INFINITY),s=Pt(s,Number.NEGATIVE_INFINITY),{min:Pt(t,i),max:Pt(n,s),minDefined:vt(t),maxDefined:vt(n)}}getMinMax(t){let{min:n,max:i,minDefined:s,maxDefined:o}=this.getUserBounds(),r;if(s&&o)return{min:n,max:i};const a=this.getMatchingVisibleMetas();for(let l=0,c=a.length;l<c;++l)r=a[l].controller.getMinMax(this,t),s||(n=Math.min(n,r.min)),o||(i=Math.max(i,r.max));return n=o&&n>i?i:n,i=s&&n>i?n:i,{min:Pt(n,Pt(i,n)),max:Pt(i,Pt(n,i))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(t))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){I(this.options.beforeUpdate,[this])}update(t,n,i){const{beginAtZero:s,grace:o,ticks:r}=this.options,a=r.sampleSize;this.beforeUpdate(),this.maxWidth=t,this.maxHeight=n,this._margins=i=Object.assign({left:0,right:0,top:0,bottom:0},i),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+i.left+i.right:this.height+i.top+i.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=yd(this,o,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=a<this.ticks.length;this._convertTicksToLabels(l?Yr(this.ticks,a):this.ticks),this.configure(),this.beforeCalculateLabelRotation(),this.calculateLabelRotation(),this.afterCalculateLabelRotation(),r.display&&(r.autoSkip||r.source==="auto")&&(this.ticks=Up(this,this.ticks),this._labelSizes=null,this.afterAutoSkip()),l&&this._convertTicksToLabels(this.ticks),this.beforeFit(),this.fit(),this.afterFit(),this.afterUpdate()}configure(){let t=this.options.reverse,n,i;this.isHorizontal()?(n=this.left,i=this.right):(n=this.top,i=this.bottom,t=!t),this._startPixel=n,this._endPixel=i,this._reversePixels=t,this._length=i-n,this._alignToPixels=this.options.alignToPixels}afterUpdate(){I(this.options.afterUpdate,[this])}beforeSetDimensions(){I(this.options.beforeSetDimensions,[this])}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=0,this.right=this.width):(this.height=this.maxHeight,this.top=0,this.bottom=this.height),this.paddingLeft=0,this.paddingTop=0,this.paddingRight=0,this.paddingBottom=0}afterSetDimensions(){I(this.options.afterSetDimensions,[this])}_callHooks(t){this.chart.notifyPlugins(t,this.getContext()),I(this.options[t],[this])}beforeDataLimits(){this._callHooks("beforeDataLimits")}determineDataLimits(){}afterDataLimits(){this._callHooks("afterDataLimits")}beforeBuildTicks(){this._callHooks("beforeBuildTicks")}buildTicks(){return[]}afterBuildTicks(){this._callHooks("afterBuildTicks")}beforeTickToLabelConversion(){I(this.options.beforeTickToLabelConversion,[this])}generateTickLabels(t){const n=this.options.ticks;let i,s,o;for(i=0,s=t.length;i<s;i++)o=t[i],o.label=I(n.callback,[o.value,i,t],this)}afterTickToLabelConversion(){I(this.options.afterTickToLabelConversion,[this])}beforeCalculateLabelRotation(){I(this.options.beforeCalculateLabelRotation,[this])}calculateLabelRotation(){const t=this.options,n=t.ticks,i=Ur(this.ticks.length,t.ticks.maxTicksLimit),s=n.minRotation||0,o=n.maxRotation;let r=s,a,l,c;if(!this._isVisible()||!n.display||s>=o||i<=1||!this.isHorizontal()){this.labelRotation=s;return}const u=this._getLabelSizes(),f=u.widest.width,d=u.highest.height,m=xt(this.chart.width-f,0,this.maxWidth);a=t.offset?this.maxWidth/i:m/(i-1),f+6>a&&(a=m/(i-(t.offset?.5:1)),l=this.maxHeight-yn(t.grid)-n.padding-Xr(t.title,this.chart.options.font),c=Math.sqrt(f*f+d*d),r=Bf(Math.min(Math.asin(xt((u.highest.height+6)/a,-1,1)),Math.asin(xt(l/c,-1,1))-Math.asin(xt(d/c,-1,1)))),r=Math.max(s,Math.min(o,r))),this.labelRotation=r}afterCalculateLabelRotation(){I(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){I(this.options.beforeFit,[this])}fit(){const t={width:0,height:0},{chart:n,options:{ticks:i,title:s,grid:o}}=this,r=this._isVisible(),a=this.isHorizontal();if(r){const l=Xr(s,n.options.font);if(a?(t.width=this.maxWidth,t.height=yn(o)+l):(t.height=this.maxHeight,t.width=yn(o)+l),i.display&&this.ticks.length){const{first:c,last:u,widest:f,highest:d}=this._getLabelSizes(),m=i.padding*2,y=Pe(this.labelRotation),x=Math.cos(y),v=Math.sin(y);if(a){const w=i.mirror?0:v*f.width+x*d.height;t.height=Math.min(this.maxHeight,t.height+w+m)}else{const w=i.mirror?0:x*f.width+v*d.height;t.width=Math.min(this.maxWidth,t.width+w+m)}this._calculatePadding(c,u,v,x)}}this._handleMargins(),a?(this.width=this._length=n.width-this._margins.left-this._margins.right,this.height=t.height):(this.width=t.width,this.height=this._length=n.height-this._margins.top-this._margins.bottom)}_calculatePadding(t,n,i,s){const{ticks:{align:o,padding:r},position:a}=this.options,l=this.labelRotation!==0,c=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const u=this.getPixelForTick(0)-this.left,f=this.right-this.getPixelForTick(this.ticks.length-1);let d=0,m=0;l?c?(d=s*t.width,m=i*n.height):(d=i*t.height,m=s*n.width):o==="start"?m=n.width:o==="end"?d=t.width:o!=="inner"&&(d=t.width/2,m=n.width/2),this.paddingLeft=Math.max((d-u+r)*this.width/(this.width-u),0),this.paddingRight=Math.max((m-f+r)*this.width/(this.width-f),0)}else{let u=n.height/2,f=t.height/2;o==="start"?(u=0,f=t.height):o==="end"&&(u=n.height,f=0),this.paddingTop=u+r,this.paddingBottom=f+r}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){I(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:n}=this.options;return n==="top"||n==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion(),this.generateTickLabels(t);let n,i;for(n=0,i=t.length;n<i;n++)B(t[n].label)&&(t.splice(n,1),i--,n--);this.afterTickToLabelConversion()}_getLabelSizes(){let t=this._labelSizes;if(!t){const n=this.options.ticks.sampleSize;let i=this.ticks;n<i.length&&(i=Yr(i,n)),this._labelSizes=t=this._computeLabelSizes(i,i.length,this.options.ticks.maxTicksLimit)}return t}_computeLabelSizes(t,n,i){const{ctx:s,_longestTextCache:o}=this,r=[],a=[],l=Math.floor(n/Ur(n,i));let c=0,u=0,f,d,m,y,x,v,w,k,E,C,T;for(f=0;f<n;f+=l){if(y=t[f].label,x=this._resolveTickFontOptions(f),s.font=v=x.string,w=o[v]=o[v]||{data:{},gc:[]},k=x.lineHeight,E=C=0,!B(y)&&!tt(y))E=Sr(s,w.data,w.gc,E,y),C=k;else if(tt(y))for(d=0,m=y.length;d<m;++d)T=y[d],!B(T)&&!tt(T)&&(E=Sr(s,w.data,w.gc,E,T),C+=k);r.push(E),a.push(C),c=Math.max(E,c),u=Math.max(C,u)}Jp(o,n);const D=r.indexOf(c),P=a.indexOf(u),O=A=>({width:r[A]||0,height:a[A]||0});return{first:O(0),last:O(n-1),widest:O(D),highest:O(P),widths:r,heights:a}}getLabelForValue(t){return t}getPixelForValue(t,n){return NaN}getValueForPixel(t){}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const n=this._startPixel+t*this._length;return $f(this._alignToPixels?ke(this.chart,n,0):n)}getDecimalForPixel(t){const n=(t-this._startPixel)/this._length;return this._reversePixels?1-n:n}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:n}=this;return t<0&&n<0?n:t>0&&n>0?t:0}getContext(t){const n=this.ticks||[];if(t>=0&&t<n.length){const i=n[t];return i.$context||(i.$context=eg(this.getContext(),t,i))}return this.$context||(this.$context=tg(this.chart.getContext(),this))}_tickSize(){const t=this.options.ticks,n=Pe(this.labelRotation),i=Math.abs(Math.cos(n)),s=Math.abs(Math.sin(n)),o=this._getLabelSizes(),r=t.autoSkipPadding||0,a=o?o.widest.width+r:0,l=o?o.highest.height+r:0;return this.isHorizontal()?l*i>a*s?a/i:l/s:l*s<a*i?l/i:a/s}_isVisible(){const t=this.options.display;return t!=="auto"?!!t:this.getMatchingVisibleMetas().length>0}_computeGridLineItems(t){const n=this.axis,i=this.chart,s=this.options,{grid:o,position:r,border:a}=s,l=o.offset,c=this.isHorizontal(),f=this.ticks.length+(l?1:0),d=yn(o),m=[],y=a.setContext(this.getContext()),x=y.display?y.width:0,v=x/2,w=function(q){return ke(i,q,x)};let k,E,C,T,D,P,O,A,z,L,H,Z;if(r==="top")k=w(this.bottom),P=this.bottom-d,A=k-v,L=w(t.top)+v,Z=t.bottom;else if(r==="bottom")k=w(this.top),L=t.top,Z=w(t.bottom)-v,P=k+v,A=this.top+d;else if(r==="left")k=w(this.right),D=this.right-d,O=k-v,z=w(t.left)+v,H=t.right;else if(r==="right")k=w(this.left),z=t.left,H=w(t.right)-v,D=k+v,O=this.left+d;else if(n==="x"){if(r==="center")k=w((t.top+t.bottom)/2+.5);else if(V(r)){const q=Object.keys(r)[0],it=r[q];k=w(this.chart.scales[q].getPixelForValue(it))}L=t.top,Z=t.bottom,P=k+v,A=P+d}else if(n==="y"){if(r==="center")k=w((t.left+t.right)/2);else if(V(r)){const q=Object.keys(r)[0],it=r[q];k=w(this.chart.scales[q].getPixelForValue(it))}D=k-v,O=D-d,z=t.left,H=t.right}const nt=R(s.ticks.maxTicksLimit,f),j=Math.max(1,Math.ceil(f/nt));for(E=0;E<f;E+=j){const q=this.getContext(E),it=o.setContext(q),We=a.setContext(q),be=it.lineWidth,Gt=it.color,je=We.dash||[],dt=We.dashOffset,xe=it.tickWidth,wt=it.tickColor,ye=it.tickBorderDash||[],Vt=it.tickBorderDashOffset;C=Qp(this,E,l),C!==void 0&&(T=ke(i,C,be),c?D=O=z=H=T:P=A=L=Z=T,m.push({tx1:D,ty1:P,tx2:O,ty2:A,x1:z,y1:L,x2:H,y2:Z,width:be,color:Gt,borderDash:je,borderDashOffset:dt,tickWidth:xe,tickColor:wt,tickBorderDash:ye,tickBorderDashOffset:Vt}))}return this._ticksLength=f,this._borderValue=k,m}_computeLabelItems(t){const n=this.axis,i=this.options,{position:s,ticks:o}=i,r=this.isHorizontal(),a=this.ticks,{align:l,crossAlign:c,padding:u,mirror:f}=o,d=yn(i.grid),m=d+u,y=f?-u:m,x=-Pe(this.labelRotation),v=[];let w,k,E,C,T,D,P,O,A,z,L,H,Z="middle";if(s==="top")D=this.bottom-y,P=this._getXAxisLabelAlignment();else if(s==="bottom")D=this.top+y,P=this._getXAxisLabelAlignment();else if(s==="left"){const j=this._getYAxisLabelAlignment(d);P=j.textAlign,T=j.x}else if(s==="right"){const j=this._getYAxisLabelAlignment(d);P=j.textAlign,T=j.x}else if(n==="x"){if(s==="center")D=(t.top+t.bottom)/2+m;else if(V(s)){const j=Object.keys(s)[0],q=s[j];D=this.chart.scales[j].getPixelForValue(q)+m}P=this._getXAxisLabelAlignment()}else if(n==="y"){if(s==="center")T=(t.left+t.right)/2-m;else if(V(s)){const j=Object.keys(s)[0],q=s[j];T=this.chart.scales[j].getPixelForValue(q)}P=this._getYAxisLabelAlignment(d).textAlign}n==="y"&&(l==="start"?Z="top":l==="end"&&(Z="bottom"));const nt=this._getLabelSizes();for(w=0,k=a.length;w<k;++w){E=a[w],C=E.label;const j=o.setContext(this.getContext(w));O=this.getPixelForTick(w)+o.labelOffset,A=this._resolveTickFontOptions(w),z=A.lineHeight,L=tt(C)?C.length:1;const q=L/2,it=j.color,We=j.textStrokeColor,be=j.textStrokeWidth;let Gt=P;r?(T=O,P==="inner"&&(w===k-1?Gt=this.options.reverse?"left":"right":w===0?Gt=this.options.reverse?"right":"left":Gt="center"),s==="top"?c==="near"||x!==0?H=-L*z+z/2:c==="center"?H=-nt.highest.height/2-q*z+z:H=-nt.highest.height+z/2:c==="near"||x!==0?H=z/2:c==="center"?H=nt.highest.height/2-q*z:H=nt.highest.height-L*z,f&&(H*=-1),x!==0&&!j.showLabelBackdrop&&(T+=z/2*Math.sin(x))):(D=O,H=(1-L)*z/2);let je;if(j.showLabelBackdrop){const dt=Mt(j.backdropPadding),xe=nt.heights[w],wt=nt.widths[w];let ye=H-dt.top,Vt=0-dt.left;switch(Z){case"middle":ye-=xe/2;break;case"bottom":ye-=xe;break}switch(P){case"center":Vt-=wt/2;break;case"right":Vt-=wt;break;case"inner":w===k-1?Vt-=wt:w>0&&(Vt-=wt/2);break}je={left:Vt,top:ye,width:wt+dt.width,height:xe+dt.height,color:j.backdropColor}}v.push({label:C,font:A,textOffset:H,options:{rotation:x,color:it,strokeColor:We,strokeWidth:be,textAlign:Gt,textBaseline:Z,translation:[T,D],backdrop:je}})}return v}_getXAxisLabelAlignment(){const{position:t,ticks:n}=this.options;if(-Pe(this.labelRotation))return t==="top"?"left":"right";let s="center";return n.align==="start"?s="left":n.align==="end"?s="right":n.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(t){const{position:n,ticks:{crossAlign:i,mirror:s,padding:o}}=this.options,r=this._getLabelSizes(),a=t+o,l=r.widest.width;let c,u;return n==="left"?s?(u=this.right+o,i==="near"?c="left":i==="center"?(c="center",u+=l/2):(c="right",u+=l)):(u=this.right-a,i==="near"?c="right":i==="center"?(c="center",u-=l/2):(c="left",u=this.left)):n==="right"?s?(u=this.left+o,i==="near"?c="right":i==="center"?(c="center",u-=l/2):(c="left",u-=l)):(u=this.left+a,i==="near"?c="left":i==="center"?(c="center",u+=l/2):(c="right",u=this.right)):c="right",{textAlign:c,x:u}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart,n=this.options.position;if(n==="left"||n==="right")return{top:0,left:this.left,bottom:t.height,right:this.right};if(n==="top"||n==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:t.width}}drawBackground(){const{ctx:t,options:{backgroundColor:n},left:i,top:s,width:o,height:r}=this;n&&(t.save(),t.fillStyle=n,t.fillRect(i,s,o,r),t.restore())}getLineWidthForValue(t){const n=this.options.grid;if(!this._isVisible()||!n.display)return 0;const s=this.ticks.findIndex(o=>o.value===t);return s>=0?n.setContext(this.getContext(s)).lineWidth:0}drawGrid(t){const n=this.options.grid,i=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let o,r;const a=(l,c,u)=>{!u.width||!u.color||(i.save(),i.lineWidth=u.width,i.strokeStyle=u.color,i.setLineDash(u.borderDash||[]),i.lineDashOffset=u.borderDashOffset,i.beginPath(),i.moveTo(l.x,l.y),i.lineTo(c.x,c.y),i.stroke(),i.restore())};if(n.display)for(o=0,r=s.length;o<r;++o){const l=s[o];n.drawOnChartArea&&a({x:l.x1,y:l.y1},{x:l.x2,y:l.y2},l),n.drawTicks&&a({x:l.tx1,y:l.ty1},{x:l.tx2,y:l.ty2},{color:l.tickColor,width:l.tickWidth,borderDash:l.tickBorderDash,borderDashOffset:l.tickBorderDashOffset})}}drawBorder(){const{chart:t,ctx:n,options:{border:i,grid:s}}=this,o=i.setContext(this.getContext()),r=i.display?o.width:0;if(!r)return;const a=s.setContext(this.getContext(0)).lineWidth,l=this._borderValue;let c,u,f,d;this.isHorizontal()?(c=ke(t,this.left,r)-r/2,u=ke(t,this.right,a)+a/2,f=d=l):(f=ke(t,this.top,r)-r/2,d=ke(t,this.bottom,a)+a/2,c=u=l),n.save(),n.lineWidth=o.width,n.strokeStyle=o.color,n.beginPath(),n.moveTo(c,f),n.lineTo(u,d),n.stroke(),n.restore()}drawLabels(t){if(!this.options.ticks.display)return;const i=this.ctx,s=this._computeLabelArea();s&&vo(i,s);const o=this.getLabelItems(t);for(const r of o){const a=r.options,l=r.font,c=r.label,u=r.textOffset;Pi(i,c,0,u,l,a)}s&&_o(i)}drawTitle(){const{ctx:t,options:{position:n,title:i,reverse:s}}=this;if(!i.display)return;const o=ht(i.font),r=Mt(i.padding),a=i.align;let l=o.lineHeight/2;n==="bottom"||n==="center"||V(n)?(l+=r.bottom,tt(i.text)&&(l+=o.lineHeight*(i.text.length-1))):l+=r.top;const{titleX:c,titleY:u,maxWidth:f,rotation:d}=ig(this,l,n,a);Pi(t,i.text,0,0,o,{color:i.color,maxWidth:f,rotation:d,textAlign:ng(a,n,s),textBaseline:"middle",translation:[c,u]})}draw(t){this._isVisible()&&(this.drawBackground(),this.drawGrid(t),this.drawBorder(),this.drawTitle(),this.drawLabels(t))}_layers(){const t=this.options,n=t.ticks&&t.ticks.z||0,i=R(t.grid&&t.grid.z,-1),s=R(t.border&&t.border.z,0);return!this._isVisible()||this.draw!==rn.prototype.draw?[{z:n,draw:o=>{this.draw(o)}}]:[{z:i,draw:o=>{this.drawBackground(),this.drawGrid(o),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:n,draw:o=>{this.drawLabels(o)}}]}getMatchingVisibleMetas(t){const n=this.chart.getSortedVisibleDatasetMetas(),i=this.axis+"AxisID",s=[];let o,r;for(o=0,r=n.length;o<r;++o){const a=n[o];a[i]===this.id&&(!t||a.type===t)&&s.push(a)}return s}_resolveTickFontOptions(t){const n=this.options.ticks.setContext(this.getContext(t));return ht(n.font)}_maxDigits(){const t=this._resolveTickFontOptions(0).lineHeight;return(this.isHorizontal()?this.width:this.height)/t}}class ci{constructor(t,n,i){this.type=t,this.scope=n,this.override=i,this.items=Object.create(null)}isForType(t){return Object.prototype.isPrototypeOf.call(this.type.prototype,t.prototype)}register(t){const n=Object.getPrototypeOf(t);let i;rg(n)&&(i=this.register(n));const s=this.items,o=t.id,r=this.scope+"."+o;if(!o)throw new Error("class does not have id: "+t);return o in s||(s[o]=t,sg(t,r,i),this.override&&Y.override(t.id,t.overrides)),r}get(t){return this.items[t]}unregister(t){const n=this.items,i=t.id,s=this.scope;i in n&&delete n[i],s&&i in Y[s]&&(delete Y[s][i],this.override&&delete ze[i])}}function sg(e,t,n){const i=Ln(Object.create(null),[n?Y.get(n):{},Y.get(t),e.defaults]);Y.set(t,i),e.defaultRoutes&&og(t,e.defaultRoutes),e.descriptors&&Y.describe(t,e.descriptors)}function og(e,t){Object.keys(t).forEach(n=>{const i=n.split("."),s=i.pop(),o=[e].concat(i).join("."),r=t[n].split("."),a=r.pop(),l=r.join(".");Y.route(o,s,l,a)})}function rg(e){return"id"in e&&"defaults"in e}class ag{constructor(){this.controllers=new ci(Jl,"datasets",!0),this.elements=new ci(on,"elements"),this.plugins=new ci(Object,"plugins"),this.scales=new ci(rn,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,n,i){[...n].forEach(s=>{const o=i||this._getRegistryForType(s);i||o.isForType(s)||o===this.plugins&&s.id?this._exec(t,o,s):F(s,r=>{const a=i||this._getRegistryForType(r);this._exec(t,a,r)})})}_exec(t,n,i){const s=bo(t);I(i["before"+s],[],i),n[t](i),I(i["after"+s],[],i)}_getRegistryForType(t){for(let n=0;n<this._typedRegistries.length;n++){const i=this._typedRegistries[n];if(i.isForType(t))return i}return this.plugins}_get(t,n,i){const s=n.get(t);if(s===void 0)throw new Error('"'+t+'" is not a registered '+i+".");return s}}var At=new ag;class lg{constructor(){this._init=[]}notify(t,n,i,s){n==="beforeInit"&&(this._init=this._createDescriptors(t,!0),this._notify(this._init,t,"install"));const o=s?this._descriptors(t).filter(s):this._descriptors(t),r=this._notify(o,t,n,i);return n==="afterDestroy"&&(this._notify(o,t,"stop"),this._notify(this._init,t,"uninstall")),r}_notify(t,n,i,s){s=s||{};for(const o of t){const r=o.plugin,a=r[i],l=[n,s,o.options];if(I(a,l,r)===!1&&s.cancelable)return!1}return!0}invalidate(){B(this._cache)||(this._oldCache=this._cache,this._cache=void 0)}_descriptors(t){if(this._cache)return this._cache;const n=this._cache=this._createDescriptors(t);return this._notifyStateChanges(t),n}_createDescriptors(t,n){const i=t&&t.config,s=R(i.options&&i.options.plugins,{}),o=cg(i);return s===!1&&!n?[]:hg(t,o,s,n)}_notifyStateChanges(t){const n=this._oldCache||[],i=this._cache,s=(o,r)=>o.filter(a=>!r.some(l=>a.plugin.id===l.plugin.id));this._notify(s(n,i),t,"stop"),this._notify(s(i,n),t,"start")}}function cg(e){const t={},n=[],i=Object.keys(At.plugins.items);for(let o=0;o<i.length;o++)n.push(At.getPlugin(i[o]));const s=e.plugins||[];for(let o=0;o<s.length;o++){const r=s[o];n.indexOf(r)===-1&&(n.push(r),t[r.id]=!0)}return{plugins:n,localIds:t}}function ug(e,t){return!t&&e===!1?null:e===!0?{}:e}function hg(e,{plugins:t,localIds:n},i,s){const o=[],r=e.getContext();for(const a of t){const l=a.id,c=ug(i[l],s);c!==null&&o.push({plugin:a,options:fg(e.config,{plugin:a,local:n[l]},c,r)})}return o}function fg(e,{plugin:t,local:n},i,s){const o=e.pluginScopeKeys(t),r=e.getOptionScopes(i,o);return n&&t.defaults&&r.push(t.defaults),e.createResolver(r,s,[""],{scriptable:!1,indexable:!1,allKeys:!0})}function Ws(e,t){const n=Y.datasets[e]||{};return((t.datasets||{})[e]||{}).indexAxis||t.indexAxis||n.indexAxis||"x"}function dg(e,t){let n=e;return e==="_index_"?n=t:e==="_value_"&&(n=t==="x"?"y":"x"),n}function pg(e,t){return e===t?"_index_":"_value_"}function qr(e){if(e==="x"||e==="y"||e==="r")return e}function gg(e){if(e==="top"||e==="bottom")return"x";if(e==="left"||e==="right")return"y"}function js(e,...t){if(qr(e))return e;for(const n of t){const i=n.axis||gg(n.position)||e.length>1&&qr(e[0].toLowerCase());if(i)return i}throw new Error(\`Cannot determine type of '\${e}' axis. Please provide 'axis' or 'position' option.\`)}function Gr(e,t,n){if(n[t+"AxisID"]===e)return{axis:t}}function mg(e,t){if(t.data&&t.data.datasets){const n=t.data.datasets.filter(i=>i.xAxisID===e||i.yAxisID===e);if(n.length)return Gr(e,"x",n[0])||Gr(e,"y",n[0])}return{}}function bg(e,t){const n=ze[e.type]||{scales:{}},i=t.scales||{},s=Ws(e.type,t),o=Object.create(null);return Object.keys(i).forEach(r=>{const a=i[r];if(!V(a))return console.error(\`Invalid scale configuration for scale: \${r}\`);if(a._proxy)return console.warn(\`Ignoring resolver passed as options for scale: \${r}\`);const l=js(r,a,mg(r,e),Y.scales[a.type]),c=pg(l,s),u=n.scales||{};o[r]=Mn(Object.create(null),[{axis:l},a,u[l],u[c]])}),e.data.datasets.forEach(r=>{const a=r.type||e.type,l=r.indexAxis||Ws(a,t),u=(ze[a]||{}).scales||{};Object.keys(u).forEach(f=>{const d=dg(f,l),m=r[d+"AxisID"]||d;o[m]=o[m]||Object.create(null),Mn(o[m],[{axis:d},i[m],u[f]])})}),Object.keys(o).forEach(r=>{const a=o[r];Mn(a,[Y.scales[a.type],Y.scale])}),o}function oc(e){const t=e.options||(e.options={});t.plugins=R(t.plugins,{}),t.scales=bg(e,t)}function rc(e){return e=e||{},e.datasets=e.datasets||[],e.labels=e.labels||[],e}function xg(e){return e=e||{},e.data=rc(e.data),oc(e),e}const Kr=new Map,ac=new Set;function ui(e,t){let n=Kr.get(e);return n||(n=t(),Kr.set(e,n),ac.add(n)),n}const vn=(e,t,n)=>{const i=Ei(t,n);i!==void 0&&e.add(i)};class yg{constructor(t){this._config=xg(t),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=rc(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache(),oc(t)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(t){return ui(t,()=>[[\`datasets.\${t}\`,""]])}datasetAnimationScopeKeys(t,n){return ui(\`\${t}.transition.\${n}\`,()=>[[\`datasets.\${t}.transitions.\${n}\`,\`transitions.\${n}\`],[\`datasets.\${t}\`,""]])}datasetElementScopeKeys(t,n){return ui(\`\${t}-\${n}\`,()=>[[\`datasets.\${t}.elements.\${n}\`,\`datasets.\${t}\`,\`elements.\${n}\`,""]])}pluginScopeKeys(t){const n=t.id,i=this.type;return ui(\`\${i}-plugin-\${n}\`,()=>[[\`plugins.\${n}\`,...t.additionalOptionScopes||[]]])}_cachedScopes(t,n){const i=this._scopeCache;let s=i.get(t);return(!s||n)&&(s=new Map,i.set(t,s)),s}getOptionScopes(t,n,i){const{options:s,type:o}=this,r=this._cachedScopes(t,i),a=r.get(n);if(a)return a;const l=new Set;n.forEach(u=>{t&&(l.add(t),u.forEach(f=>vn(l,t,f))),u.forEach(f=>vn(l,s,f)),u.forEach(f=>vn(l,ze[o]||{},f)),u.forEach(f=>vn(l,Y,f)),u.forEach(f=>vn(l,Hs,f))});const c=Array.from(l);return c.length===0&&c.push(Object.create(null)),ac.has(n)&&r.set(n,c),c}chartOptionScopes(){const{options:t,type:n}=this;return[t,ze[n]||{},Y.datasets[n]||{},{type:n},Y,Hs]}resolveNamedOptions(t,n,i,s=[""]){const o={$shared:!0},{resolver:r,subPrefixes:a}=Zr(this._resolverCache,t,s);let l=r;if(_g(r,n)){o.$shared=!1,i=ue(i)?i():i;const c=this.createResolver(t,i,a);l=nn(r,i,c)}for(const c of n)o[c]=l[c];return o}createResolver(t,n,i=[""],s){const{resolver:o}=Zr(this._resolverCache,t,i);return V(n)?nn(o,n,void 0,s):o}}function Zr(e,t,n){let i=e.get(t);i||(i=new Map,e.set(t,i));const s=n.join();let o=i.get(s);return o||(o={resolver:wo(t,n),subPrefixes:n.filter(a=>!a.toLowerCase().includes("hover"))},i.set(s,o)),o}const vg=e=>V(e)&&Object.getOwnPropertyNames(e).some(t=>ue(e[t]));function _g(e,t){const{isScriptable:n,isIndexable:i}=jl(e);for(const s of t){const o=n(s),r=i(s),a=(r||o)&&e[s];if(o&&(ue(a)||vg(a))||r&&tt(a))return!0}return!1}var wg="4.5.0";const Sg=["top","bottom","left","right","chartArea"];function Qr(e,t){return e==="top"||e==="bottom"||Sg.indexOf(e)===-1&&t==="x"}function Jr(e,t){return function(n,i){return n[e]===i[e]?n[t]-i[t]:n[e]-i[e]}}function ta(e){const t=e.chart,n=t.options.animation;t.notifyPlugins("afterRender"),I(n&&n.onComplete,[e],t)}function kg(e){const t=e.chart,n=t.options.animation;I(n&&n.onProgress,[e],t)}function lc(e){return To()&&typeof e=="string"?e=document.getElementById(e):e&&e.length&&(e=e[0]),e&&e.canvas&&(e=e.canvas),e}const bi={},ea=e=>{const t=lc(e);return Object.values(bi).filter(n=>n.canvas===t).pop()};function Tg(e,t,n){const i=Object.keys(e);for(const s of i){const o=+s;if(o>=t){const r=e[s];delete e[s],(n>0||o>t)&&(e[o+n]=r)}}}function Mg(e,t,n,i){return!n||e.type==="mouseout"?null:i?t:e}class $s{static defaults=Y;static instances=bi;static overrides=ze;static registry=At;static version=wg;static getChart=ea;static register(...t){At.add(...t),na()}static unregister(...t){At.remove(...t),na()}constructor(t,n){const i=this.config=new yg(n),s=lc(t),o=ea(s);if(o)throw new Error("Canvas is already in use. Chart with ID '"+o.id+"' must be destroyed before the canvas with ID '"+o.canvas.id+"' can be reused.");const r=i.createResolver(i.chartOptionScopes(),this.getContext());this.platform=new(i.platform||$p(s)),this.platform.updateConfig(i);const a=this.platform.acquireContext(s,r.aspectRatio),l=a&&a.canvas,c=l&&l.height,u=l&&l.width;if(this.id=Cf(),this.ctx=a,this.canvas=l,this.width=u,this.height=c,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new lg,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=Gf(f=>this.update(f),r.resizeDelay||0),this._dataChanges=[],bi[this.id]=this,!a||!l){console.error("Failed to create chart: can't acquire context from the given item");return}$t.listen(this,"complete",ta),$t.listen(this,"progress",kg),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:n},width:i,height:s,_aspectRatio:o}=this;return B(t)?n&&o?o:s?i/s:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return At}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():Er(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return kr(this.canvas,this.ctx),this}stop(){return $t.stop(this),this}resize(t,n){$t.running(this)?this._resizeBeforeDraw={width:t,height:n}:this._resize(t,n)}_resize(t,n){const i=this.options,s=this.canvas,o=i.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(s,t,n,o),a=i.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,Er(this,a,!0)&&(this.notifyPlugins("resize",{size:r}),I(i.onResize,[this,r],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const n=this.options.scales||{};F(n,(i,s)=>{i.id=s})}buildOrUpdateScales(){const t=this.options,n=t.scales,i=this.scales,s=Object.keys(i).reduce((r,a)=>(r[a]=!1,r),{});let o=[];n&&(o=o.concat(Object.keys(n).map(r=>{const a=n[r],l=js(r,a),c=l==="r",u=l==="x";return{options:a,dposition:c?"chartArea":u?"bottom":"left",dtype:c?"radialLinear":u?"category":"linear"}}))),F(o,r=>{const a=r.options,l=a.id,c=js(l,a),u=R(a.type,r.dtype);(a.position===void 0||Qr(a.position,c)!==Qr(r.dposition))&&(a.position=r.dposition),s[l]=!0;let f=null;if(l in i&&i[l].type===u)f=i[l];else{const d=At.getScale(u);f=new d({id:l,type:u,ctx:this.ctx,chart:this}),i[f.id]=f}f.init(a,t)}),F(s,(r,a)=>{r||delete i[a]}),F(i,r=>{ne.configure(this,r,r.options),ne.addBox(this,r)})}_updateMetasets(){const t=this._metasets,n=this.data.datasets.length,i=t.length;if(t.sort((s,o)=>s.index-o.index),i>n){for(let s=n;s<i;++s)this._destroyDatasetMeta(s);t.splice(n,i-n)}this._sortedMetasets=t.slice(0).sort(Jr("order","index"))}_removeUnreferencedMetasets(){const{_metasets:t,data:{datasets:n}}=this;t.length>n.length&&delete this._stacks,t.forEach((i,s)=>{n.filter(o=>o===i._dataset).length===0&&this._destroyDatasetMeta(s)})}buildOrUpdateControllers(){const t=[],n=this.data.datasets;let i,s;for(this._removeUnreferencedMetasets(),i=0,s=n.length;i<s;i++){const o=n[i];let r=this.getDatasetMeta(i);const a=o.type||this.config.type;if(r.type&&r.type!==a&&(this._destroyDatasetMeta(i),r=this.getDatasetMeta(i)),r.type=a,r.indexAxis=o.indexAxis||Ws(a,this.options),r.order=o.order||0,r.index=i,r.label=""+o.label,r.visible=this.isDatasetVisible(i),r.controller)r.controller.updateIndex(i),r.controller.linkScales();else{const l=At.getController(a),{datasetElementType:c,dataElementType:u}=Y.datasets[a];Object.assign(l,{dataElementType:At.getElement(u),datasetElementType:c&&At.getElement(c)}),r.controller=new l(this,i),t.push(r.controller)}}return this._updateMetasets(),t}_resetElements(){F(this.data.datasets,(t,n)=>{this.getDatasetMeta(n).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(t){const n=this.config;n.update();const i=this._options=n.createResolver(n.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!i.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:t,cancelable:!0})===!1)return;const o=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let c=0,u=this.data.datasets.length;c<u;c++){const{controller:f}=this.getDatasetMeta(c),d=!s&&o.indexOf(f)===-1;f.buildOrUpdateElements(d),r=Math.max(+f.getMaxOverflow(),r)}r=this._minPadding=i.layout.autoPadding?r:0,this._updateLayout(r),s||F(o,c=>{c.reset()}),this._updateDatasets(t),this.notifyPlugins("afterUpdate",{mode:t}),this._layers.sort(Jr("z","_idx"));const{_active:a,_lastEvent:l}=this;l?this._eventHandler(l,!0):a.length&&this._updateHoverStyles(a,a,!0),this.render()}_updateScales(){F(this.scales,t=>{ne.removeBox(this,t)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options,n=new Set(Object.keys(this._listeners)),i=new Set(t.events);(!pr(n,i)||!!this._responsiveListeners!==t.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:t}=this,n=this._getUniformDataChanges()||[];for(const{method:i,start:s,count:o}of n){const r=i==="_removeElements"?-o:o;Tg(t,s,r)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const n=this.data.datasets.length,i=o=>new Set(t.filter(r=>r[0]===o).map((r,a)=>a+","+r.splice(1).join(","))),s=i(0);for(let o=1;o<n;o++)if(!pr(s,i(o)))return;return Array.from(s).map(o=>o.split(",")).map(o=>({method:o[1],start:+o[2],count:+o[3]}))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;ne.update(this,this.width,this.height,t);const n=this.chartArea,i=n.width<=0||n.height<=0;this._layers=[],F(this.boxes,s=>{i&&s.position==="chartArea"||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,o)=>{s._idx=o}),this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:!0})!==!1){for(let n=0,i=this.data.datasets.length;n<i;++n)this.getDatasetMeta(n).controller.configure();for(let n=0,i=this.data.datasets.length;n<i;++n)this._updateDataset(n,ue(t)?t({datasetIndex:n}):t);this.notifyPlugins("afterDatasetsUpdate",{mode:t})}}_updateDataset(t,n){const i=this.getDatasetMeta(t),s={meta:i,index:t,mode:n,cancelable:!0};this.notifyPlugins("beforeDatasetUpdate",s)!==!1&&(i.controller._update(n),s.cancelable=!1,this.notifyPlugins("afterDatasetUpdate",s))}render(){this.notifyPlugins("beforeRender",{cancelable:!0})!==!1&&($t.has(this)?this.attached&&!$t.running(this)&&$t.start(this):(this.draw(),ta({chart:this})))}draw(){let t;if(this._resizeBeforeDraw){const{width:i,height:s}=this._resizeBeforeDraw;this._resizeBeforeDraw=null,this._resize(i,s)}if(this.clear(),this.width<=0||this.height<=0||this.notifyPlugins("beforeDraw",{cancelable:!0})===!1)return;const n=this._layers;for(t=0;t<n.length&&n[t].z<=0;++t)n[t].draw(this.chartArea);for(this._drawDatasets();t<n.length;++t)n[t].draw(this.chartArea);this.notifyPlugins("afterDraw")}_getSortedDatasetMetas(t){const n=this._sortedMetasets,i=[];let s,o;for(s=0,o=n.length;s<o;++s){const r=n[s];(!t||r.visible)&&i.push(r)}return i}getSortedVisibleDatasetMetas(){return this._getSortedDatasetMetas(!0)}_drawDatasets(){if(this.notifyPlugins("beforeDatasetsDraw",{cancelable:!0})===!1)return;const t=this.getSortedVisibleDatasetMetas();for(let n=t.length-1;n>=0;--n)this._drawDataset(t[n]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const n=this.ctx,i={meta:t,index:t.index,cancelable:!0},s=np(this,t);this.notifyPlugins("beforeDatasetDraw",i)!==!1&&(s&&vo(n,s),t.controller.draw(),s&&_o(n),i.cancelable=!1,this.notifyPlugins("afterDatasetDraw",i))}isPointInArea(t){return en(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,n,i,s){const o=Sp.modes[n];return typeof o=="function"?o(this,t,i,s):[]}getDatasetMeta(t){const n=this.data.datasets[t],i=this._metasets;let s=i.filter(o=>o&&o._dataset===n).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:n&&n.order||0,index:t,_dataset:n,_parsed:[],_sorted:!1},i.push(s)),s}getContext(){return this.$context||(this.$context=Ve(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const n=this.data.datasets[t];if(!n)return!1;const i=this.getDatasetMeta(t);return typeof i.hidden=="boolean"?!i.hidden:!n.hidden}setDatasetVisibility(t,n){const i=this.getDatasetMeta(t);i.hidden=!n}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,n,i){const s=i?"show":"hide",o=this.getDatasetMeta(t),r=o.controller._resolveAnimations(void 0,s);Ci(n)?(o.data[n].hidden=!i,this.update()):(this.setDatasetVisibility(t,i),r.update(o,{visible:i}),this.update(a=>a.datasetIndex===t?s:void 0))}hide(t,n){this._updateVisibility(t,n,!1)}show(t,n){this._updateVisibility(t,n,!0)}_destroyDatasetMeta(t){const n=this._metasets[t];n&&n.controller&&n.controller._destroy(),delete this._metasets[t]}_stop(){let t,n;for(this.stop(),$t.remove(this),t=0,n=this.data.datasets.length;t<n;++t)this._destroyDatasetMeta(t)}destroy(){this.notifyPlugins("beforeDestroy");const{canvas:t,ctx:n}=this;this._stop(),this.config.clearCache(),t&&(this.unbindEvents(),kr(t,n),this.platform.releaseContext(n),this.canvas=null,this.ctx=null),delete bi[this.id],this.notifyPlugins("afterDestroy")}toBase64Image(...t){return this.canvas.toDataURL(...t)}bindEvents(){this.bindUserEvents(),this.options.responsive?this.bindResponsiveEvents():this.attached=!0}bindUserEvents(){const t=this._listeners,n=this.platform,i=(o,r)=>{n.addEventListener(this,o,r),t[o]=r},s=(o,r,a)=>{o.offsetX=r,o.offsetY=a,this._eventHandler(o)};F(this.options.events,o=>i(o,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners,n=this.platform,i=(l,c)=>{n.addEventListener(this,l,c),t[l]=c},s=(l,c)=>{t[l]&&(n.removeEventListener(this,l,c),delete t[l])},o=(l,c)=>{this.canvas&&this.resize(l,c)};let r;const a=()=>{s("attach",a),this.attached=!0,this.resize(),i("resize",o),i("detach",r)};r=()=>{this.attached=!1,s("resize",o),this._stop(),this._resize(0,0),i("attach",a)},n.isAttached(this.canvas)?a():r()}unbindEvents(){F(this._listeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._listeners={},F(this._responsiveListeners,(t,n)=>{this.platform.removeEventListener(this,n,t)}),this._responsiveListeners=void 0}updateHoverStyle(t,n,i){const s=i?"set":"remove";let o,r,a,l;for(n==="dataset"&&(o=this.getDatasetMeta(t[0].datasetIndex),o.controller["_"+s+"DatasetHoverStyle"]()),a=0,l=t.length;a<l;++a){r=t[a];const c=r&&this.getDatasetMeta(r.datasetIndex).controller;c&&c[s+"HoverStyle"](r.element,r.datasetIndex,r.index)}}getActiveElements(){return this._active||[]}setActiveElements(t){const n=this._active||[],i=t.map(({datasetIndex:o,index:r})=>{const a=this.getDatasetMeta(o);if(!a)throw new Error("No dataset found at index "+o);return{datasetIndex:o,element:a.data[r],index:r}});!Ti(i,n)&&(this._active=i,this._lastEvent=null,this._updateHoverStyles(i,n))}notifyPlugins(t,n,i){return this._plugins.notify(this,t,n,i)}isPluginEnabled(t){return this._plugins._cache.filter(n=>n.plugin.id===t).length===1}_updateHoverStyles(t,n,i){const s=this.options.hover,o=(l,c)=>l.filter(u=>!c.some(f=>u.datasetIndex===f.datasetIndex&&u.index===f.index)),r=o(n,t),a=i?t:o(t,n);r.length&&this.updateHoverStyle(r,s.mode,!1),a.length&&s.mode&&this.updateHoverStyle(a,s.mode,!0)}_eventHandler(t,n){const i={event:t,replay:n,cancelable:!0,inChartArea:this.isPointInArea(t)},s=r=>(r.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",i,s)===!1)return;const o=this._handleEvent(t,n,i.inChartArea);return i.cancelable=!1,this.notifyPlugins("afterEvent",i,s),(o||i.changed)&&this.render(),this}_handleEvent(t,n,i){const{_active:s=[],options:o}=this,r=n,a=this._getActiveElements(t,s,i,r),l=Lf(t),c=Mg(t,this._lastEvent,i,l);i&&(this._lastEvent=null,I(o.onHover,[t,a,this],this),l&&I(o.onClick,[t,a,this],this));const u=!Ti(a,s);return(u||n)&&(this._active=a,this._updateHoverStyles(a,s,n)),this._lastEvent=c,u}_getActiveElements(t,n,i,s){if(t.type==="mouseout")return[];if(!i)return n;const o=this.options.hover;return this.getElementsAtEventForMode(t,o.mode,o,s)}}function na(){return F($s.instances,e=>e._plugins.invalidate())}function cc(e,t,n=t){e.lineCap=R(n.borderCapStyle,t.borderCapStyle),e.setLineDash(R(n.borderDash,t.borderDash)),e.lineDashOffset=R(n.borderDashOffset,t.borderDashOffset),e.lineJoin=R(n.borderJoinStyle,t.borderJoinStyle),e.lineWidth=R(n.borderWidth,t.borderWidth),e.strokeStyle=R(n.borderColor,t.borderColor)}function Eg(e,t,n){e.lineTo(n.x,n.y)}function Cg(e){return e.stepped?cd:e.tension||e.cubicInterpolationMode==="monotone"?ud:Eg}function uc(e,t,n={}){const i=e.length,{start:s=0,end:o=i-1}=n,{start:r,end:a}=t,l=Math.max(s,r),c=Math.min(o,a),u=s<r&&o<r||s>a&&o>a;return{count:i,start:l,loop:t.loop,ilen:c<l&&!u?i+c-l:c-l}}function Og(e,t,n,i){const{points:s,options:o}=t,{count:r,start:a,loop:l,ilen:c}=uc(s,n,i),u=Cg(o);let{move:f=!0,reverse:d}=i||{},m,y,x;for(m=0;m<=c;++m)y=s[(a+(d?c-m:m))%r],!y.skip&&(f?(e.moveTo(y.x,y.y),f=!1):u(e,x,y,d,o.stepped),x=y);return l&&(y=s[(a+(d?c:0))%r],u(e,x,y,d,o.stepped)),!!l}function Pg(e,t,n,i){const s=t.points,{count:o,start:r,ilen:a}=uc(s,n,i),{move:l=!0,reverse:c}=i||{};let u=0,f=0,d,m,y,x,v,w;const k=C=>(r+(c?a-C:C))%o,E=()=>{x!==v&&(e.lineTo(u,v),e.lineTo(u,x),e.lineTo(u,w))};for(l&&(m=s[k(0)],e.moveTo(m.x,m.y)),d=0;d<=a;++d){if(m=s[k(d)],m.skip)continue;const C=m.x,T=m.y,D=C|0;D===y?(T<x?x=T:T>v&&(v=T),u=(f*u+C)/++f):(E(),e.lineTo(C,T),y=D,f=0,x=v=T),w=T}E()}function Us(e){const t=e.options,n=t.borderDash&&t.borderDash.length;return!e._decimated&&!e._loop&&!t.tension&&t.cubicInterpolationMode!=="monotone"&&!t.stepped&&!n?Pg:Og}function Dg(e){return e.stepped?jd:e.tension||e.cubicInterpolationMode==="monotone"?$d:Me}function Ag(e,t,n,i){let s=t._path;s||(s=t._path=new Path2D,t.path(s,n,i)&&s.closePath()),cc(e,t.options),e.stroke(s)}function Ig(e,t,n,i){const{segments:s,options:o}=t,r=Us(t);for(const a of s)cc(e,o,a.style),e.beginPath(),r(e,t,a,{start:n,end:n+i-1})&&e.closePath(),e.stroke()}const Lg=typeof Path2D=="function";function Rg(e,t,n,i){Lg&&!t.options.segment?Ag(e,t,n,i):Ig(e,t,n,i)}class Ng extends on{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:!0,cubicInterpolationMode:"default",fill:!1,spanGaps:!1,stepped:!1,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:!0,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,t&&Object.assign(this,t)}updateControlPoints(t,n){const i=this.options;if((i.tension||i.cubicInterpolationMode==="monotone")&&!i.stepped&&!this._pointsUpdated){const s=i.spanGaps?this._loop:this._fullLoop;Rd(this._points,i,t,s,n),this._pointsUpdated=!0}}set points(t){this._points=t,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=Qd(this,this.options.segment))}first(){const t=this.segments,n=this.points;return t.length&&n[t[0].start]}last(){const t=this.segments,n=this.points,i=t.length;return i&&n[t[i-1].end]}interpolate(t,n){const i=this.options,s=t[n],o=this.points,r=Gd(this,{property:n,start:s,end:s});if(!r.length)return;const a=[],l=Dg(i);let c,u;for(c=0,u=r.length;c<u;++c){const{start:f,end:d}=r[c],m=o[f],y=o[d];if(m===y){a.push(m);continue}const x=Math.abs((s-m[n])/(y[n]-m[n])),v=l(m,y,x,i.stepped);v[n]=t[n],a.push(v)}return a.length===1?a[0]:a}pathSegment(t,n,i){return Us(this)(t,this,n,i)}path(t,n,i){const s=this.segments,o=Us(this);let r=this._loop;n=n||0,i=i||this.points.length-n;for(const a of s)r&=o(t,this,a,{start:n,end:n+i-1});return!!r}draw(t,n,i,s){const o=this.options||{};(this.points||[]).length&&o.borderWidth&&(t.save(),Rg(t,this,i,s),t.restore()),this.animated&&(this._pointsUpdated=!1,this._path=void 0)}}function ia(e,t,n,i){const s=e.options,{[n]:o}=e.getProps([n],i);return Math.abs(t-o)<s.radius+s.hitRadius}class Fg extends on{static id="point";parsed;skip;stop;static defaults={borderWidth:1,hitRadius:1,hoverBorderWidth:1,hoverRadius:4,pointStyle:"circle",radius:3,rotation:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};constructor(t){super(),this.options=void 0,this.parsed=void 0,this.skip=void 0,this.stop=void 0,t&&Object.assign(this,t)}inRange(t,n,i){const s=this.options,{x:o,y:r}=this.getProps(["x","y"],i);return Math.pow(t-o,2)+Math.pow(n-r,2)<Math.pow(s.hitRadius+s.radius,2)}inXRange(t,n){return ia(this,t,"x",n)}inYRange(t,n){return ia(this,t,"y",n)}getCenterPoint(t){const{x:n,y:i}=this.getProps(["x","y"],t);return{x:n,y:i}}size(t){t=t||this.options||{};let n=t.radius||0;n=Math.max(n,n&&t.hoverRadius||0);const i=n&&t.borderWidth||0;return(n+i)*2}draw(t,n){const i=this.options;this.skip||i.radius<.1||!en(this,n,this.size(i)/2)||(t.strokeStyle=i.borderColor,t.lineWidth=i.borderWidth,t.fillStyle=i.backgroundColor,Vs(t,i,this.x,this.y))}getRange(){const t=this.options||{};return t.radius+t.hitRadius}}const sa=(e,t)=>{let{boxHeight:n=t,boxWidth:i=t}=e;return e.usePointStyle&&(n=Math.min(n,t),i=e.pointStyleWidth||Math.min(i,t)),{boxWidth:i,boxHeight:n,itemHeight:Math.max(t,n)}},zg=(e,t)=>e!==null&&t!==null&&e.datasetIndex===t.datasetIndex&&e.index===t.index;class oa extends on{constructor(t){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=t.chart,this.options=t.options,this.ctx=t.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(t,n,i){this.maxWidth=t,this.maxHeight=n,this._margins=i,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const t=this.options.labels||{};let n=I(t.generateLabels,[this.chart],this)||[];t.filter&&(n=n.filter(i=>t.filter(i,this.chart.data))),t.sort&&(n=n.sort((i,s)=>t.sort(i,s,this.chart.data))),this.options.reverse&&n.reverse(),this.legendItems=n}fit(){const{options:t,ctx:n}=this;if(!t.display){this.width=this.height=0;return}const i=t.labels,s=ht(i.font),o=s.size,r=this._computeTitleHeight(),{boxWidth:a,itemHeight:l}=sa(i,o);let c,u;n.font=s.string,this.isHorizontal()?(c=this.maxWidth,u=this._fitRows(r,o,a,l)+10):(u=this.maxHeight,c=this._fitCols(r,s,a,l)+10),this.width=Math.min(c,t.maxWidth||this.maxWidth),this.height=Math.min(u,t.maxHeight||this.maxHeight)}_fitRows(t,n,i,s){const{ctx:o,maxWidth:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.lineWidths=[0],u=s+a;let f=t;o.textAlign="left",o.textBaseline="middle";let d=-1,m=-u;return this.legendItems.forEach((y,x)=>{const v=i+n/2+o.measureText(y.text).width;(x===0||c[c.length-1]+v+2*a>r)&&(f+=u,c[c.length-(x>0?0:1)]=0,m+=u,d++),l[x]={left:0,top:m,row:d,width:v,height:s},c[c.length-1]+=v+a}),f}_fitCols(t,n,i,s){const{ctx:o,maxHeight:r,options:{labels:{padding:a}}}=this,l=this.legendHitBoxes=[],c=this.columnSizes=[],u=r-t;let f=a,d=0,m=0,y=0,x=0;return this.legendItems.forEach((v,w)=>{const{itemWidth:k,itemHeight:E}=Hg(i,n,o,v,s);w>0&&m+E+2*a>u&&(f+=d+a,c.push({width:d,height:m}),y+=d+a,x++,d=m=0),l[w]={left:y,top:m,col:x,width:k,height:E},d=Math.max(d,k),m+=E+a}),f+=d,c.push({width:d,height:m}),f}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight(),{legendHitBoxes:n,options:{align:i,labels:{padding:s},rtl:o}}=this,r=Ge(o,this.left,this.width);if(this.isHorizontal()){let a=0,l=ft(i,this.left+s,this.right-this.lineWidths[a]);for(const c of n)a!==c.row&&(a=c.row,l=ft(i,this.left+s,this.right-this.lineWidths[a])),c.top+=this.top+t+s,c.left=r.leftForLtr(r.x(l),c.width),l+=c.width+s}else{let a=0,l=ft(i,this.top+t+s,this.bottom-this.columnSizes[a].height);for(const c of n)c.col!==a&&(a=c.col,l=ft(i,this.top+t+s,this.bottom-this.columnSizes[a].height)),c.top=l,c.left+=this.left+s,c.left=r.leftForLtr(r.x(c.left),c.width),l+=c.height+s}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;vo(t,this),this._draw(),_o(t)}}_draw(){const{options:t,columnSizes:n,lineWidths:i,ctx:s}=this,{align:o,labels:r}=t,a=Y.color,l=Ge(t.rtl,this.left,this.width),c=ht(r.font),{padding:u}=r,f=c.size,d=f/2;let m;this.drawTitle(),s.textAlign=l.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=c.string;const{boxWidth:y,boxHeight:x,itemHeight:v}=sa(r,f),w=function(D,P,O){if(isNaN(y)||y<=0||isNaN(x)||x<0)return;s.save();const A=R(O.lineWidth,1);if(s.fillStyle=R(O.fillStyle,a),s.lineCap=R(O.lineCap,"butt"),s.lineDashOffset=R(O.lineDashOffset,0),s.lineJoin=R(O.lineJoin,"miter"),s.lineWidth=A,s.strokeStyle=R(O.strokeStyle,a),s.setLineDash(R(O.lineDash,[])),r.usePointStyle){const z={radius:x*Math.SQRT2/2,pointStyle:O.pointStyle,rotation:O.rotation,borderWidth:A},L=l.xPlus(D,y/2),H=P+d;Bl(s,z,L,H,r.pointStyleWidth&&y)}else{const z=P+Math.max((f-x)/2,0),L=l.leftForLtr(D,y),H=On(O.borderRadius);s.beginPath(),Object.values(H).some(Z=>Z!==0)?Bs(s,{x:L,y:z,w:y,h:x,radius:H}):s.rect(L,z,y,x),s.fill(),A!==0&&s.stroke()}s.restore()},k=function(D,P,O){Pi(s,O.text,D,P+v/2,c,{strikethrough:O.hidden,textAlign:l.textAlign(O.textAlign)})},E=this.isHorizontal(),C=this._computeTitleHeight();E?m={x:ft(o,this.left+u,this.right-i[0]),y:this.top+u+C,line:0}:m={x:this.left+u,y:ft(o,this.top+C+u,this.bottom-n[0].height),line:0},ql(this.ctx,t.textDirection);const T=v+u;this.legendItems.forEach((D,P)=>{s.strokeStyle=D.fontColor,s.fillStyle=D.fontColor;const O=s.measureText(D.text).width,A=l.textAlign(D.textAlign||(D.textAlign=r.textAlign)),z=y+d+O;let L=m.x,H=m.y;l.setWidth(this.width),E?P>0&&L+z+u>this.right&&(H=m.y+=T,m.line++,L=m.x=ft(o,this.left+u,this.right-i[m.line])):P>0&&H+T>this.bottom&&(L=m.x=L+n[m.line].width+u,m.line++,H=m.y=ft(o,this.top+C+u,this.bottom-n[m.line].height));const Z=l.x(L);if(w(Z,H,D),L=Kf(A,L+y+d,E?L+z:this.right,t.rtl),k(l.x(L),H,D),E)m.x+=z+u;else if(typeof D.text!="string"){const nt=c.lineHeight;m.y+=hc(D,nt)+u}else m.y+=T}),Gl(this.ctx,t.textDirection)}drawTitle(){const t=this.options,n=t.title,i=ht(n.font),s=Mt(n.padding);if(!n.display)return;const o=Ge(t.rtl,this.left,this.width),r=this.ctx,a=n.position,l=i.size/2,c=s.top+l;let u,f=this.left,d=this.width;if(this.isHorizontal())d=Math.max(...this.lineWidths),u=this.top+c,f=ft(t.align,f,this.right-d);else{const y=this.columnSizes.reduce((x,v)=>Math.max(x,v.height),0);u=c+ft(t.align,this.top,this.bottom-y-t.labels.padding-this._computeTitleHeight())}const m=ft(a,f,f+d);r.textAlign=o.textAlign(zl(a)),r.textBaseline="middle",r.strokeStyle=n.color,r.fillStyle=n.color,r.font=i.string,Pi(r,n.text,m,u,i)}_computeTitleHeight(){const t=this.options.title,n=ht(t.font),i=Mt(t.padding);return t.display?n.lineHeight+i.height:0}_getLegendItemAt(t,n){let i,s,o;if(Sn(t,this.left,this.right)&&Sn(n,this.top,this.bottom)){for(o=this.legendHitBoxes,i=0;i<o.length;++i)if(s=o[i],Sn(t,s.left,s.left+s.width)&&Sn(n,s.top,s.top+s.height))return this.legendItems[i]}return null}handleEvent(t){const n=this.options;if(!Wg(t.type,n))return;const i=this._getLegendItemAt(t.x,t.y);if(t.type==="mousemove"||t.type==="mouseout"){const s=this._hoveredItem,o=zg(s,i);s&&!o&&I(n.onLeave,[t,s,this],this),this._hoveredItem=i,i&&!o&&I(n.onHover,[t,i,this],this)}else i&&I(n.onClick,[t,i,this],this)}}function Hg(e,t,n,i,s){const o=Vg(i,e,t,n),r=Bg(s,i,t.lineHeight);return{itemWidth:o,itemHeight:r}}function Vg(e,t,n,i){let s=e.text;return s&&typeof s!="string"&&(s=s.reduce((o,r)=>o.length>r.length?o:r)),t+n.size/2+i.measureText(s).width}function Bg(e,t,n){let i=e;return typeof t.text!="string"&&(i=hc(t,n)),i}function hc(e,t){const n=e.text?e.text.length:0;return t*n}function Wg(e,t){return!!((e==="mousemove"||e==="mouseout")&&(t.onHover||t.onLeave)||t.onClick&&(e==="click"||e==="mouseup"))}var jg={id:"legend",_element:oa,start(e,t,n){const i=e.legend=new oa({ctx:e.ctx,options:n,chart:e});ne.configure(e,i,n),ne.addBox(e,i)},stop(e){ne.removeBox(e,e.legend),delete e.legend},beforeUpdate(e,t,n){const i=e.legend;ne.configure(e,i,n),i.options=n},afterUpdate(e){const t=e.legend;t.buildLabels(),t.adjustHitBoxes()},afterEvent(e,t){t.replay||e.legend.handleEvent(t.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(e,t,n){const i=t.datasetIndex,s=n.chart;s.isDatasetVisible(i)?(s.hide(i),t.hidden=!0):(s.show(i),t.hidden=!1)},onHover:null,onLeave:null,labels:{color:e=>e.chart.options.color,boxWidth:40,padding:10,generateLabels(e){const t=e.data.datasets,{labels:{usePointStyle:n,pointStyle:i,textAlign:s,color:o,useBorderRadius:r,borderRadius:a}}=e.legend.options;return e._getSortedDatasetMetas().map(l=>{const c=l.controller.getStyle(n?0:void 0),u=Mt(c.borderWidth);return{text:t[l.index].label,fillStyle:c.backgroundColor,fontColor:o,hidden:!l.visible,lineCap:c.borderCapStyle,lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:(u.width+u.height)/4,strokeStyle:c.borderColor,pointStyle:i||c.pointStyle,rotation:c.rotation,textAlign:s||c.textAlign,borderRadius:r&&(a||c.borderRadius),datasetIndex:l.index}},this)}},title:{color:e=>e.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:e=>!e.startsWith("on"),labels:{_scriptable:e=>!["generateLabels","filter","sort"].includes(e)}}};const Tn={average(e){if(!e.length)return!1;let t,n,i=new Set,s=0,o=0;for(t=0,n=e.length;t<n;++t){const a=e[t].element;if(a&&a.hasValue()){const l=a.tooltipPosition();i.add(l.x),s+=l.y,++o}}return o===0||i.size===0?!1:{x:[...i].reduce((a,l)=>a+l)/i.size,y:s/o}},nearest(e,t){if(!e.length)return!1;let n=t.x,i=t.y,s=Number.POSITIVE_INFINITY,o,r,a;for(o=0,r=e.length;o<r;++o){const l=e[o].element;if(l&&l.hasValue()){const c=l.getCenterPoint(),u=zs(t,c);u<s&&(s=u,a=l)}}if(a){const l=a.tooltipPosition();n=l.x,i=l.y}return{x:n,y:i}}};function Dt(e,t){return t&&(tt(t)?Array.prototype.push.apply(e,t):e.push(t)),e}function Ut(e){return(typeof e=="string"||e instanceof String)&&e.indexOf(\`
9141
9294
  \`)>-1?e.split(\`
9142
- \`):e}function jg(e,t){const{element:n,datasetIndex:i,index:s}=t,o=e.getDatasetMeta(i).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:e,label:r,parsed:o.getParsed(s),raw:e.data.datasets[i].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:n}}function oa(e,t){const n=e.chart.ctx,{body:i,footer:s,title:o}=e,{boxWidth:r,boxHeight:a}=t,l=ht(t.bodyFont),c=ht(t.titleFont),u=ht(t.footerFont),f=o.length,d=s.length,m=i.length,y=Mt(t.padding);let x=y.height,v=0,w=i.reduce((C,T)=>C+T.before.length+T.lines.length+T.after.length,0);if(w+=e.beforeBody.length+e.afterBody.length,f&&(x+=f*c.lineHeight+(f-1)*t.titleSpacing+t.titleMarginBottom),w){const C=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;x+=m*C+(w-m)*l.lineHeight+(w-1)*t.bodySpacing}d&&(x+=t.footerMarginTop+d*u.lineHeight+(d-1)*t.footerSpacing);let k=0;const E=function(C){v=Math.max(v,n.measureText(C).width+k)};return n.save(),n.font=c.string,F(e.title,E),n.font=l.string,F(e.beforeBody.concat(e.afterBody),E),k=t.displayColors?r+2+t.boxPadding:0,F(i,C=>{F(C.before,E),F(C.lines,E),F(C.after,E)}),k=0,n.font=u.string,F(e.footer,E),n.restore(),v+=y.width,{width:v,height:x}}function $g(e,t){const{y:n,height:i}=t;return n<i/2?"top":n>e.height-i/2?"bottom":"center"}function Ug(e,t,n,i){const{x:s,width:o}=i,r=n.caretSize+n.caretPadding;if(e==="left"&&s+o+r>t.width||e==="right"&&s-o-r<0)return!0}function Yg(e,t,n,i){const{x:s,width:o}=n,{width:r,chartArea:{left:a,right:l}}=e;let c="center";return i==="center"?c=s<=(a+l)/2?"left":"right":s<=o/2?c="left":s>=r-o/2&&(c="right"),Ug(c,e,t,n)&&(c="center"),c}function ra(e,t,n){const i=n.yAlign||t.yAlign||$g(e,n);return{xAlign:n.xAlign||t.xAlign||Yg(e,t,n,i),yAlign:i}}function Xg(e,t){let{x:n,width:i}=e;return t==="right"?n-=i:t==="center"&&(n-=i/2),n}function qg(e,t,n){let{y:i,height:s}=e;return t==="top"?i+=n:t==="bottom"?i-=s+n:i-=s/2,i}function aa(e,t,n,i){const{caretSize:s,caretPadding:o,cornerRadius:r}=e,{xAlign:a,yAlign:l}=n,c=s+o,{topLeft:u,topRight:f,bottomLeft:d,bottomRight:m}=On(r);let y=Xg(t,a);const x=qg(t,l,c);return l==="center"?a==="left"?y+=c:a==="right"&&(y-=c):a==="left"?y-=Math.max(u,d)+s:a==="right"&&(y+=Math.max(f,m)+s),{x:xt(y,0,i.width-t.width),y:xt(x,0,i.height-t.height)}}function fi(e,t,n){const i=Mt(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-i.right:e.x+i.left}function la(e){return Dt([],Ut(e))}function Gg(e,t,n){return Ve(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function ca(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const uc={beforeTitle:jt,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,i=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex<i)return n[t.dataIndex]}return""},afterTitle:jt,beforeBody:jt,beforeLabel:jt,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return B(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:jt,afterBody:jt,beforeFooter:jt,footer:jt,afterFooter:jt};function lt(e,t,n,i){const s=e[t].call(n,i);return typeof s>"u"?uc[t].call(n,i):s}class ua extends on{static positioners=Tn;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,i=this.options.setContext(this.getContext()),s=i.enabled&&n.options.animation&&i.animations,o=new Gl(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=Gg(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:i}=n,s=lt(i,"beforeTitle",this,t),o=lt(i,"title",this,t),r=lt(i,"afterTitle",this,t);let a=[];return a=Dt(a,Ut(s)),a=Dt(a,Ut(o)),a=Dt(a,Ut(r)),a}getBeforeBody(t,n){return la(lt(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:i}=n,s=[];return F(t,o=>{const r={before:[],lines:[],after:[]},a=ca(i,o);Dt(r.before,Ut(lt(a,"beforeLabel",this,o))),Dt(r.lines,lt(a,"label",this,o)),Dt(r.after,Ut(lt(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,n){return la(lt(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:i}=n,s=lt(i,"beforeFooter",this,t),o=lt(i,"footer",this,t),r=lt(i,"afterFooter",this,t);let a=[];return a=Dt(a,Ut(s)),a=Dt(a,Ut(o)),a=Dt(a,Ut(r)),a}_createItems(t){const n=this._active,i=this.chart.data,s=[],o=[],r=[];let a=[],l,c;for(l=0,c=n.length;l<c;++l)a.push(jg(this.chart,n[l]));return t.filter&&(a=a.filter((u,f,d)=>t.filter(u,f,d,i))),t.itemSort&&(a=a.sort((u,f)=>t.itemSort(u,f,i))),F(a,u=>{const f=ca(t.callbacks,u);s.push(lt(f,"labelColor",this,u)),o.push(lt(f,"labelPointStyle",this,u)),r.push(lt(f,"labelTextColor",this,u))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,n){const i=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=Tn[i.position].call(this,s,this._eventPosition);r=this._createItems(i),this.title=this.getTitle(r,i),this.beforeBody=this.getBeforeBody(r,i),this.body=this.getBody(r,i),this.afterBody=this.getAfterBody(r,i),this.footer=this.getFooter(r,i);const l=this._size=oa(this,i),c=Object.assign({},a,l),u=ra(this.chart,i,c),f=aa(i,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,o={opacity:1,x:f.x,y:f.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,i,s){const o=this.getCaretPosition(t,i,s);n.lineTo(o.x1,o.y1),n.lineTo(o.x2,o.y2),n.lineTo(o.x3,o.y3)}getCaretPosition(t,n,i){const{xAlign:s,yAlign:o}=this,{caretSize:r,cornerRadius:a}=i,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:f}=On(a),{x:d,y:m}=t,{width:y,height:x}=n;let v,w,k,E,C,T;return o==="center"?(C=m+x/2,s==="left"?(v=d,w=v-r,E=C+r,T=C-r):(v=d+y,w=v+r,E=C-r,T=C+r),k=v):(s==="left"?w=d+Math.max(l,u)+r:s==="right"?w=d+y-Math.max(c,f)-r:w=this.caretX,o==="top"?(E=m,C=E-r,v=w-r,k=w+r):(E=m+x,C=E+r,v=w+r,k=w-r),T=E),{x1:v,x2:w,x3:k,y1:E,y2:C,y3:T}}drawTitle(t,n,i){const s=this.title,o=s.length;let r,a,l;if(o){const c=Ge(i.rtl,this.x,this.width);for(t.x=fi(this,i.titleAlign,i),n.textAlign=c.textAlign(i.titleAlign),n.textBaseline="middle",r=ht(i.titleFont),a=i.titleSpacing,n.fillStyle=i.titleColor,n.font=r.string,l=0;l<o;++l)n.fillText(s[l],c.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+a,l+1===o&&(t.y+=i.titleMarginBottom-a)}}_drawColorBox(t,n,i,s,o){const r=this.labelColors[i],a=this.labelPointStyles[i],{boxHeight:l,boxWidth:c}=o,u=ht(o.bodyFont),f=fi(this,"left",o),d=s.x(f),m=l<u.lineHeight?(u.lineHeight-l)/2:0,y=n.y+m;if(o.usePointStyle){const x={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},v=s.leftForLtr(d,c)+c/2,w=y+l/2;t.strokeStyle=o.multiKeyBackground,t.fillStyle=o.multiKeyBackground,Vs(t,x,v,w),t.strokeStyle=r.borderColor,t.fillStyle=r.backgroundColor,Vs(t,x,v,w)}else{t.lineWidth=V(r.borderWidth)?Math.max(...Object.values(r.borderWidth)):r.borderWidth||1,t.strokeStyle=r.borderColor,t.setLineDash(r.borderDash||[]),t.lineDashOffset=r.borderDashOffset||0;const x=s.leftForLtr(d,c),v=s.leftForLtr(s.xPlus(d,1),c-2),w=On(r.borderRadius);Object.values(w).some(k=>k!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,Bs(t,{x,y,w:c,h:l,radius:w}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),Bs(t,{x:v,y:y+1,w:c-2,h:l-2,radius:w}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(x,y,c,l),t.strokeRect(x,y,c,l),t.fillStyle=r.backgroundColor,t.fillRect(v,y+1,c-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,n,i){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=i,f=ht(i.bodyFont);let d=f.lineHeight,m=0;const y=Ge(i.rtl,this.x,this.width),x=function(O){n.fillText(O,y.x(t.x+m),t.y+d/2),t.y+=d+o},v=y.textAlign(r);let w,k,E,C,T,D,P;for(n.textAlign=r,n.textBaseline="middle",n.font=f.string,t.x=fi(this,v,i),n.fillStyle=i.bodyColor,F(this.beforeBody,x),m=a&&v!=="right"?r==="center"?c/2+u:c+2+u:0,C=0,D=s.length;C<D;++C){for(w=s[C],k=this.labelTextColors[C],n.fillStyle=k,F(w.before,x),E=w.lines,a&&E.length&&(this._drawColorBox(n,t,C,y,i),d=Math.max(f.lineHeight,l)),T=0,P=E.length;T<P;++T)x(E[T]),d=f.lineHeight;F(w.after,x)}m=0,d=f.lineHeight,F(this.afterBody,x),t.y-=o}drawFooter(t,n,i){const s=this.footer,o=s.length;let r,a;if(o){const l=Ge(i.rtl,this.x,this.width);for(t.x=fi(this,i.footerAlign,i),t.y+=i.footerMarginTop,n.textAlign=l.textAlign(i.footerAlign),n.textBaseline="middle",r=ht(i.footerFont),n.fillStyle=i.footerColor,n.font=r.string,a=0;a<o;++a)n.fillText(s[a],l.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+i.footerSpacing}}drawBackground(t,n,i,s){const{xAlign:o,yAlign:r}=this,{x:a,y:l}=t,{width:c,height:u}=i,{topLeft:f,topRight:d,bottomLeft:m,bottomRight:y}=On(s.cornerRadius);n.fillStyle=s.backgroundColor,n.strokeStyle=s.borderColor,n.lineWidth=s.borderWidth,n.beginPath(),n.moveTo(a+f,l),r==="top"&&this.drawCaret(t,n,i,s),n.lineTo(a+c-d,l),n.quadraticCurveTo(a+c,l,a+c,l+d),r==="center"&&o==="right"&&this.drawCaret(t,n,i,s),n.lineTo(a+c,l+u-y),n.quadraticCurveTo(a+c,l+u,a+c-y,l+u),r==="bottom"&&this.drawCaret(t,n,i,s),n.lineTo(a+m,l+u),n.quadraticCurveTo(a,l+u,a,l+u-m),r==="center"&&o==="left"&&this.drawCaret(t,n,i,s),n.lineTo(a,l+f),n.quadraticCurveTo(a,l,a+f,l),n.closePath(),n.fill(),s.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,i=this.$animations,s=i&&i.x,o=i&&i.y;if(s||o){const r=Tn[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=oa(this,t),l=Object.assign({},r,this._size),c=ra(n,t,l),u=aa(t,l,c,n);(s._to!==u.x||o._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,u))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(n);const s={width:this.width,height:this.height},o={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const r=Mt(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(o,t,s,n),Yl(t,n.textDirection),o.y+=r.top,this.drawTitle(o,t,n),this.drawBody(o,t,n),this.drawFooter(o,t,n),Xl(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const i=this._active,s=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!Mi(i,s),r=this._positionChanged(s,n);(o||r)&&(this._active=s,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,i=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,o=this._active||[],r=this._getActiveElements(t,o,n,i),a=this._positionChanged(r,t),l=n||!Mi(r,o)||a;return l&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),l}_getActiveElements(t,n,i,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const r=this.chart.getElementsAtEventForMode(t,o.mode,o,i);return o.reverse&&r.reverse(),r}_positionChanged(t,n){const{caretX:i,caretY:s,options:o}=this,r=Tn[o.position].call(this,t,n);return r!==!1&&(i!==r.x||s!==r.y)}}var Kg={id:"tooltip",_element:ua,positioners:Tn,afterInit(e,t,n){n&&(e.tooltip=new ua({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:uc},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const Zg=(e,t,n,i)=>(typeof t=="string"?(n=e.push(t)-1,i.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Qg(e,t,n,i){const s=e.indexOf(t);if(s===-1)return Zg(e,t,n,i);const o=e.lastIndexOf(t);return s!==o?n:s}const Jg=(e,t)=>e===null?null:xt(Math.round(e),0,t);function ha(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class tm extends rn{static id="category";static defaults={ticks:{callback:ha}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const i=this.getLabels();for(const{index:s,label:o}of n)i[s]===o&&i.splice(s,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(B(t))return null;const i=this.getLabels();return n=isFinite(n)&&i[n]===t?n:Qg(i,t,R(n,t),this._addedLabels),Jg(n,i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(i=0),n||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,n=this.max,i=this.options.offset,s=[];let o=this.getLabels();o=t===0&&n===o.length-1?o:o.slice(t,n+1),this._valueRange=Math.max(o.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let r=t;r<=n;r++)s.push({value:r});return s}getLabelForValue(t){return ha.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function em(e,t){const n=[],{bounds:s,step:o,min:r,max:a,precision:l,count:c,maxTicks:u,maxDigits:f,includeBounds:d}=e,m=o||1,y=u-1,{min:x,max:v}=t,w=!B(r),k=!B(a),E=!B(c),C=(v-x)/(f+1);let T=gr((v-x)/y/m)*m,D,P,O,A;if(T<1e-14&&!w&&!k)return[{value:x},{value:v}];A=Math.ceil(v/T)-Math.floor(x/T),A>y&&(T=gr(A*T/y/m)*m),B(l)||(D=Math.pow(10,l),T=Math.ceil(T*D)/D),s==="ticks"?(P=Math.floor(x/T)*T,O=Math.ceil(v/T)*T):(P=x,O=v),w&&k&&o&&zf((a-r)/o,T/1e3)?(A=Math.round(Math.min((a-r)/T,u)),T=(a-r)/A,P=r,O=a):E?(P=w?r:P,O=k?a:O,A=c-1,T=(O-P)/A):(A=(O-P)/T,Ie(A,Math.round(A),T/1e3)?A=Math.round(A):A=Math.ceil(A));const z=Math.max(mr(T),mr(P));D=Math.pow(10,B(l)?z:l),P=Math.round(P*D)/D,O=Math.round(O*D)/D;let L=0;for(w&&(d&&P!==r?(n.push({value:r}),P<r&&L++,Ie(Math.round((P+L*T)*D)/D,r,fa(r,C,e))&&L++):P<r&&L++);L<A;++L){const H=Math.round((P+L*T)*D)/D;if(k&&H>a)break;n.push({value:H})}return k&&d&&O!==a?n.length&&Ie(n[n.length-1].value,a,fa(a,C,e))?n[n.length-1].value=a:n.push({value:a}):(!k||O===a)&&n.push({value:O}),n}function fa(e,t,{horizontal:n,minRotation:i}){const s=Pe(i),o=(n?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+e).length;return Math.min(t/o,r)}class nm extends rn{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return B(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:i}=this.getUserBounds();let{min:s,max:o}=this;const r=l=>s=n?s:l,a=l=>o=i?o:l;if(t){const l=he(s),c=he(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(s===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:i}=t,s;return i?(s=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,s>1e3&&(console.warn(\`scales.\${this.id}.ticks.stepSize: \${i} would result generating up to \${s} ticks. Limiting to 1000.\`),s=1e3)):(s=this.computeTickLimit(),n=n||11),n&&(s=Math.min(n,s)),s}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const s={maxTicks:i,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},o=this._range||this,r=em(s,o);return t.bounds==="ticks"&&Hf(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let n=this.min,i=this.max;if(super.configure(),this.options.offset&&t.length){const s=(i-n)/Math.max(t.length-1,1)/2;n-=s,i+=s}this._startValue=n,this._endValue=i,this._valueRange=i-n}getLabelForValue(t){return Fl(t,this.chart.options.locale,this.options.ticks.format)}}class im extends nm{static id="linear";static defaults={ticks:{callback:zl.formatters.numeric}};determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=vt(t)?t:0,this.max=vt(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,i=Pe(this.options.ticks.minRotation),s=(t?Math.sin(i):Math.cos(i))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,o.lineHeight/s))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const Wi={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ut=Object.keys(Wi);function da(e,t){return e-t}function pa(e,t){if(B(t))return null;const n=e._adapter,{parser:i,round:s,isoWeekday:o}=e._parseOpts;let r=t;return typeof i=="function"&&(r=i(r)),vt(r)||(r=typeof i=="string"?n.parse(r,i):n.parse(r)),r===null?null:(s&&(r=s==="week"&&(Rn(o)||o===!0)?n.startOf(r,"isoWeek",o):n.startOf(r,s)),+r)}function ga(e,t,n,i){const s=ut.length;for(let o=ut.indexOf(e);o<s-1;++o){const r=Wi[ut[o]],a=r.steps?r.steps:Number.MAX_SAFE_INTEGER;if(r.common&&Math.ceil((n-t)/(a*r.size))<=i)return ut[o]}return ut[s-1]}function sm(e,t,n,i,s){for(let o=ut.length-1;o>=ut.indexOf(n);o--){const r=ut[o];if(Wi[r].common&&e._adapter.diff(s,i,r)>=t-1)return r}return ut[n?ut.indexOf(n):0]}function om(e){for(let t=ut.indexOf(e)+1,n=ut.length;t<n;++t)if(Wi[ut[t]].common)return ut[t]}function ma(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:i,hi:s}=xo(n,t),o=n[i]>=t?n[i]:n[s];e[o]=!0}}function rm(e,t,n,i){const s=e._adapter,o=+s.startOf(t[0].value,i),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+s.add(a,1,i))l=n[a],l>=0&&(t[l].major=!0);return t}function ba(e,t,n){const i=[],s={},o=t.length;let r,a;for(r=0;r<o;++r)a=t[r],s[a]=r,i.push({value:a,major:!1});return o===0||!n?i:rm(e,i,s,n)}class xa extends rn{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const i=t.time||(t.time={}),s=this._adapter=new bp._date(t.adapters.date);s.init(n),Mn(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:pa(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,i=t.time.unit||"day";let{min:s,max:o,minDefined:r,maxDefined:a}=this.getUserBounds();function l(c){!r&&!isNaN(c.min)&&(s=Math.min(s,c.min)),!a&&!isNaN(c.max)&&(o=Math.max(o,c.max))}(!r||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),s=vt(s)&&!isNaN(s)?s:+n.startOf(Date.now(),i),o=vt(o)&&!isNaN(o)?o:+n.endOf(Date.now(),i)+1,this.min=Math.min(s,o-1),this.max=Math.max(s+1,o)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],i=t[t.length-1]),{min:n,max:i}}buildTicks(){const t=this.options,n=t.time,i=t.ticks,s=i.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const o=this.min,r=this.max,a=Uf(s,o,r);return this._unit=n.unit||(i.autoSkip?ga(n.minUnit,this.min,this.max,this._getLabelCapacity(o)):sm(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!i.major.enabled||this._unit==="year"?void 0:om(this._unit),this.initOffsets(s),t.reverse&&a.reverse(),ba(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,i=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?n=1-s:n=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?i=o:i=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;n=xt(n,0,r),i=xt(i,0,r),this._offsets={start:n,end:i,factor:1/(n+1+i)}}_generate(){const t=this._adapter,n=this.min,i=this.max,s=this.options,o=s.time,r=o.unit||ga(o.minUnit,n,i,this._getLabelCapacity(n)),a=R(s.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=Rn(l)||l===!0,u={};let f=n,d,m;if(c&&(f=+t.startOf(f,"isoWeek",l)),f=+t.startOf(f,c?"day":r),t.diff(i,n,r)>1e5*a)throw new Error(n+" and "+i+" are too far apart with stepSize of "+a+" "+r);const y=s.ticks.source==="data"&&this.getDataTimestamps();for(d=f,m=0;d<i;d=+t.add(d,a,r),m++)ma(u,d,y);return(d===i||s.bounds==="ticks"||m===1)&&ma(u,d,y),Object.keys(u).sort(da).map(x=>+x)}getLabelForValue(t){const n=this._adapter,i=this.options.time;return i.tooltipFormat?n.format(t,i.tooltipFormat):n.format(t,i.displayFormats.datetime)}format(t,n){const s=this.options.time.displayFormats,o=this._unit,r=n||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,n,i,s){const o=this.options,r=o.ticks.callback;if(r)return I(r,[t,n,i],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],f=c&&a[c],d=i[n],m=c&&f&&d&&d.major;return this._adapter.format(t,s||(m?f:u))}generateTickLabels(t){let n,i,s;for(n=0,i=t.length;n<i;++n)s=t[n],s.label=this._tickFormatFunction(s.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,i=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+i)*n.factor)}getValueForPixel(t){const n=this._offsets,i=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+i*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,i=this.ctx.measureText(t).width,s=Pe(this.isHorizontal()?n.maxRotation:n.minRotation),o=Math.cos(s),r=Math.sin(s),a=this._resolveTickFontOptions(0).size;return{w:i*o+a*r,h:i*r+a*o}}_getLabelCapacity(t){const n=this.options.time,i=n.displayFormats,s=i[n.unit]||i.millisecond,o=this._tickFormatFunction(t,0,ba(this,[t],this._majorUnit),s),r=this._getLabelSize(o),a=Math.floor(this.isHorizontal()?this.width/r.w:this.height/r.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],n,i;if(t.length)return t;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(n=0,i=s.length;n<i;++n)t=t.concat(s[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,i;if(t.length)return t;const s=this.getLabels();for(n=0,i=s.length;n<i;++n)t.push(pa(this,s[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return Xf(t.sort(da))}}function di(e,t,n){let i=0,s=e.length-1,o,r,a,l;n?(t>=e[i].pos&&t<=e[s].pos&&({lo:i,hi:s}=De(e,"pos",t)),{pos:o,time:a}=e[i],{pos:r,time:l}=e[s]):(t>=e[i].time&&t<=e[s].time&&({lo:i,hi:s}=De(e,"time",t)),{time:o,pos:a}=e[i],{time:r,pos:l}=e[s]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class gb extends xa{static id="timeseries";static defaults=xa.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=di(n,this.min),this._tableRange=di(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:i}=this,s=[],o=[];let r,a,l,c,u;for(r=0,a=t.length;r<a;++r)c=t[r],c>=n&&c<=i&&s.push(c);if(s.length<2)return[{time:n,pos:0},{time:i,pos:1}];for(r=0,a=s.length;r<a;++r)u=s[r+1],l=s[r-1],c=s[r],Math.round((u+l)/2)!==c&&o.push({time:c,pos:r/(a-1)});return o}_generate(){const t=this.min,n=this.max;let i=super.getDataTimestamps();return(!i.includes(t)||!i.length)&&i.splice(0,0,t),(!i.includes(n)||i.length===1)&&i.push(n),i.sort((s,o)=>s-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),i=this.getLabelTimestamps();return n.length&&i.length?t=this.normalize(n.concat(i)):t=n.length?n:i,t=this._cache.all=t,t}getDecimalForValue(t){return(di(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,i=this.getDecimalForPixel(t)/n.factor-n.end;return di(this._table,i*this._tableRange+this._minPos,!0)}}function am(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var us={exports:{}};/*! Hammer.JS - v2.0.7 - 2016-04-22
9295
+ \`):e}function $g(e,t){const{element:n,datasetIndex:i,index:s}=t,o=e.getDatasetMeta(i).controller,{label:r,value:a}=o.getLabelAndValue(s);return{chart:e,label:r,parsed:o.getParsed(s),raw:e.data.datasets[i].data[s],formattedValue:a,dataset:o.getDataset(),dataIndex:s,datasetIndex:i,element:n}}function ra(e,t){const n=e.chart.ctx,{body:i,footer:s,title:o}=e,{boxWidth:r,boxHeight:a}=t,l=ht(t.bodyFont),c=ht(t.titleFont),u=ht(t.footerFont),f=o.length,d=s.length,m=i.length,y=Mt(t.padding);let x=y.height,v=0,w=i.reduce((C,T)=>C+T.before.length+T.lines.length+T.after.length,0);if(w+=e.beforeBody.length+e.afterBody.length,f&&(x+=f*c.lineHeight+(f-1)*t.titleSpacing+t.titleMarginBottom),w){const C=t.displayColors?Math.max(a,l.lineHeight):l.lineHeight;x+=m*C+(w-m)*l.lineHeight+(w-1)*t.bodySpacing}d&&(x+=t.footerMarginTop+d*u.lineHeight+(d-1)*t.footerSpacing);let k=0;const E=function(C){v=Math.max(v,n.measureText(C).width+k)};return n.save(),n.font=c.string,F(e.title,E),n.font=l.string,F(e.beforeBody.concat(e.afterBody),E),k=t.displayColors?r+2+t.boxPadding:0,F(i,C=>{F(C.before,E),F(C.lines,E),F(C.after,E)}),k=0,n.font=u.string,F(e.footer,E),n.restore(),v+=y.width,{width:v,height:x}}function Ug(e,t){const{y:n,height:i}=t;return n<i/2?"top":n>e.height-i/2?"bottom":"center"}function Yg(e,t,n,i){const{x:s,width:o}=i,r=n.caretSize+n.caretPadding;if(e==="left"&&s+o+r>t.width||e==="right"&&s-o-r<0)return!0}function Xg(e,t,n,i){const{x:s,width:o}=n,{width:r,chartArea:{left:a,right:l}}=e;let c="center";return i==="center"?c=s<=(a+l)/2?"left":"right":s<=o/2?c="left":s>=r-o/2&&(c="right"),Yg(c,e,t,n)&&(c="center"),c}function aa(e,t,n){const i=n.yAlign||t.yAlign||Ug(e,n);return{xAlign:n.xAlign||t.xAlign||Xg(e,t,n,i),yAlign:i}}function qg(e,t){let{x:n,width:i}=e;return t==="right"?n-=i:t==="center"&&(n-=i/2),n}function Gg(e,t,n){let{y:i,height:s}=e;return t==="top"?i+=n:t==="bottom"?i-=s+n:i-=s/2,i}function la(e,t,n,i){const{caretSize:s,caretPadding:o,cornerRadius:r}=e,{xAlign:a,yAlign:l}=n,c=s+o,{topLeft:u,topRight:f,bottomLeft:d,bottomRight:m}=On(r);let y=qg(t,a);const x=Gg(t,l,c);return l==="center"?a==="left"?y+=c:a==="right"&&(y-=c):a==="left"?y-=Math.max(u,d)+s:a==="right"&&(y+=Math.max(f,m)+s),{x:xt(y,0,i.width-t.width),y:xt(x,0,i.height-t.height)}}function hi(e,t,n){const i=Mt(n.padding);return t==="center"?e.x+e.width/2:t==="right"?e.x+e.width-i.right:e.x+i.left}function ca(e){return Dt([],Ut(e))}function Kg(e,t,n){return Ve(e,{tooltip:t,tooltipItems:n,type:"tooltip"})}function ua(e,t){const n=t&&t.dataset&&t.dataset.tooltip&&t.dataset.tooltip.callbacks;return n?e.override(n):e}const fc={beforeTitle:jt,title(e){if(e.length>0){const t=e[0],n=t.chart.data.labels,i=n?n.length:0;if(this&&this.options&&this.options.mode==="dataset")return t.dataset.label||"";if(t.label)return t.label;if(i>0&&t.dataIndex<i)return n[t.dataIndex]}return""},afterTitle:jt,beforeBody:jt,beforeLabel:jt,label(e){if(this&&this.options&&this.options.mode==="dataset")return e.label+": "+e.formattedValue||e.formattedValue;let t=e.dataset.label||"";t&&(t+=": ");const n=e.formattedValue;return B(n)||(t+=n),t},labelColor(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{borderColor:n.borderColor,backgroundColor:n.backgroundColor,borderWidth:n.borderWidth,borderDash:n.borderDash,borderDashOffset:n.borderDashOffset,borderRadius:0}},labelTextColor(){return this.options.bodyColor},labelPointStyle(e){const n=e.chart.getDatasetMeta(e.datasetIndex).controller.getStyle(e.dataIndex);return{pointStyle:n.pointStyle,rotation:n.rotation}},afterLabel:jt,afterBody:jt,beforeFooter:jt,footer:jt,afterFooter:jt};function lt(e,t,n,i){const s=e[t].call(n,i);return typeof s>"u"?fc[t].call(n,i):s}class ha extends on{static positioners=Tn;constructor(t){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=t.chart,this.options=t.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(t){this.options=t,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const t=this._cachedAnimations;if(t)return t;const n=this.chart,i=this.options.setContext(this.getContext()),s=i.enabled&&n.options.animation&&i.animations,o=new Zl(this.chart,s);return s._cacheable&&(this._cachedAnimations=Object.freeze(o)),o}getContext(){return this.$context||(this.$context=Kg(this.chart.getContext(),this,this._tooltipItems))}getTitle(t,n){const{callbacks:i}=n,s=lt(i,"beforeTitle",this,t),o=lt(i,"title",this,t),r=lt(i,"afterTitle",this,t);let a=[];return a=Dt(a,Ut(s)),a=Dt(a,Ut(o)),a=Dt(a,Ut(r)),a}getBeforeBody(t,n){return ca(lt(n.callbacks,"beforeBody",this,t))}getBody(t,n){const{callbacks:i}=n,s=[];return F(t,o=>{const r={before:[],lines:[],after:[]},a=ua(i,o);Dt(r.before,Ut(lt(a,"beforeLabel",this,o))),Dt(r.lines,lt(a,"label",this,o)),Dt(r.after,Ut(lt(a,"afterLabel",this,o))),s.push(r)}),s}getAfterBody(t,n){return ca(lt(n.callbacks,"afterBody",this,t))}getFooter(t,n){const{callbacks:i}=n,s=lt(i,"beforeFooter",this,t),o=lt(i,"footer",this,t),r=lt(i,"afterFooter",this,t);let a=[];return a=Dt(a,Ut(s)),a=Dt(a,Ut(o)),a=Dt(a,Ut(r)),a}_createItems(t){const n=this._active,i=this.chart.data,s=[],o=[],r=[];let a=[],l,c;for(l=0,c=n.length;l<c;++l)a.push($g(this.chart,n[l]));return t.filter&&(a=a.filter((u,f,d)=>t.filter(u,f,d,i))),t.itemSort&&(a=a.sort((u,f)=>t.itemSort(u,f,i))),F(a,u=>{const f=ua(t.callbacks,u);s.push(lt(f,"labelColor",this,u)),o.push(lt(f,"labelPointStyle",this,u)),r.push(lt(f,"labelTextColor",this,u))}),this.labelColors=s,this.labelPointStyles=o,this.labelTextColors=r,this.dataPoints=a,a}update(t,n){const i=this.options.setContext(this.getContext()),s=this._active;let o,r=[];if(!s.length)this.opacity!==0&&(o={opacity:0});else{const a=Tn[i.position].call(this,s,this._eventPosition);r=this._createItems(i),this.title=this.getTitle(r,i),this.beforeBody=this.getBeforeBody(r,i),this.body=this.getBody(r,i),this.afterBody=this.getAfterBody(r,i),this.footer=this.getFooter(r,i);const l=this._size=ra(this,i),c=Object.assign({},a,l),u=aa(this.chart,i,c),f=la(i,c,u,this.chart);this.xAlign=u.xAlign,this.yAlign=u.yAlign,o={opacity:1,x:f.x,y:f.y,width:l.width,height:l.height,caretX:a.x,caretY:a.y}}this._tooltipItems=r,this.$context=void 0,o&&this._resolveAnimations().update(this,o),t&&i.external&&i.external.call(this,{chart:this.chart,tooltip:this,replay:n})}drawCaret(t,n,i,s){const o=this.getCaretPosition(t,i,s);n.lineTo(o.x1,o.y1),n.lineTo(o.x2,o.y2),n.lineTo(o.x3,o.y3)}getCaretPosition(t,n,i){const{xAlign:s,yAlign:o}=this,{caretSize:r,cornerRadius:a}=i,{topLeft:l,topRight:c,bottomLeft:u,bottomRight:f}=On(a),{x:d,y:m}=t,{width:y,height:x}=n;let v,w,k,E,C,T;return o==="center"?(C=m+x/2,s==="left"?(v=d,w=v-r,E=C+r,T=C-r):(v=d+y,w=v+r,E=C-r,T=C+r),k=v):(s==="left"?w=d+Math.max(l,u)+r:s==="right"?w=d+y-Math.max(c,f)-r:w=this.caretX,o==="top"?(E=m,C=E-r,v=w-r,k=w+r):(E=m+x,C=E+r,v=w+r,k=w-r),T=E),{x1:v,x2:w,x3:k,y1:E,y2:C,y3:T}}drawTitle(t,n,i){const s=this.title,o=s.length;let r,a,l;if(o){const c=Ge(i.rtl,this.x,this.width);for(t.x=hi(this,i.titleAlign,i),n.textAlign=c.textAlign(i.titleAlign),n.textBaseline="middle",r=ht(i.titleFont),a=i.titleSpacing,n.fillStyle=i.titleColor,n.font=r.string,l=0;l<o;++l)n.fillText(s[l],c.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+a,l+1===o&&(t.y+=i.titleMarginBottom-a)}}_drawColorBox(t,n,i,s,o){const r=this.labelColors[i],a=this.labelPointStyles[i],{boxHeight:l,boxWidth:c}=o,u=ht(o.bodyFont),f=hi(this,"left",o),d=s.x(f),m=l<u.lineHeight?(u.lineHeight-l)/2:0,y=n.y+m;if(o.usePointStyle){const x={radius:Math.min(c,l)/2,pointStyle:a.pointStyle,rotation:a.rotation,borderWidth:1},v=s.leftForLtr(d,c)+c/2,w=y+l/2;t.strokeStyle=o.multiKeyBackground,t.fillStyle=o.multiKeyBackground,Vs(t,x,v,w),t.strokeStyle=r.borderColor,t.fillStyle=r.backgroundColor,Vs(t,x,v,w)}else{t.lineWidth=V(r.borderWidth)?Math.max(...Object.values(r.borderWidth)):r.borderWidth||1,t.strokeStyle=r.borderColor,t.setLineDash(r.borderDash||[]),t.lineDashOffset=r.borderDashOffset||0;const x=s.leftForLtr(d,c),v=s.leftForLtr(s.xPlus(d,1),c-2),w=On(r.borderRadius);Object.values(w).some(k=>k!==0)?(t.beginPath(),t.fillStyle=o.multiKeyBackground,Bs(t,{x,y,w:c,h:l,radius:w}),t.fill(),t.stroke(),t.fillStyle=r.backgroundColor,t.beginPath(),Bs(t,{x:v,y:y+1,w:c-2,h:l-2,radius:w}),t.fill()):(t.fillStyle=o.multiKeyBackground,t.fillRect(x,y,c,l),t.strokeRect(x,y,c,l),t.fillStyle=r.backgroundColor,t.fillRect(v,y+1,c-2,l-2))}t.fillStyle=this.labelTextColors[i]}drawBody(t,n,i){const{body:s}=this,{bodySpacing:o,bodyAlign:r,displayColors:a,boxHeight:l,boxWidth:c,boxPadding:u}=i,f=ht(i.bodyFont);let d=f.lineHeight,m=0;const y=Ge(i.rtl,this.x,this.width),x=function(O){n.fillText(O,y.x(t.x+m),t.y+d/2),t.y+=d+o},v=y.textAlign(r);let w,k,E,C,T,D,P;for(n.textAlign=r,n.textBaseline="middle",n.font=f.string,t.x=hi(this,v,i),n.fillStyle=i.bodyColor,F(this.beforeBody,x),m=a&&v!=="right"?r==="center"?c/2+u:c+2+u:0,C=0,D=s.length;C<D;++C){for(w=s[C],k=this.labelTextColors[C],n.fillStyle=k,F(w.before,x),E=w.lines,a&&E.length&&(this._drawColorBox(n,t,C,y,i),d=Math.max(f.lineHeight,l)),T=0,P=E.length;T<P;++T)x(E[T]),d=f.lineHeight;F(w.after,x)}m=0,d=f.lineHeight,F(this.afterBody,x),t.y-=o}drawFooter(t,n,i){const s=this.footer,o=s.length;let r,a;if(o){const l=Ge(i.rtl,this.x,this.width);for(t.x=hi(this,i.footerAlign,i),t.y+=i.footerMarginTop,n.textAlign=l.textAlign(i.footerAlign),n.textBaseline="middle",r=ht(i.footerFont),n.fillStyle=i.footerColor,n.font=r.string,a=0;a<o;++a)n.fillText(s[a],l.x(t.x),t.y+r.lineHeight/2),t.y+=r.lineHeight+i.footerSpacing}}drawBackground(t,n,i,s){const{xAlign:o,yAlign:r}=this,{x:a,y:l}=t,{width:c,height:u}=i,{topLeft:f,topRight:d,bottomLeft:m,bottomRight:y}=On(s.cornerRadius);n.fillStyle=s.backgroundColor,n.strokeStyle=s.borderColor,n.lineWidth=s.borderWidth,n.beginPath(),n.moveTo(a+f,l),r==="top"&&this.drawCaret(t,n,i,s),n.lineTo(a+c-d,l),n.quadraticCurveTo(a+c,l,a+c,l+d),r==="center"&&o==="right"&&this.drawCaret(t,n,i,s),n.lineTo(a+c,l+u-y),n.quadraticCurveTo(a+c,l+u,a+c-y,l+u),r==="bottom"&&this.drawCaret(t,n,i,s),n.lineTo(a+m,l+u),n.quadraticCurveTo(a,l+u,a,l+u-m),r==="center"&&o==="left"&&this.drawCaret(t,n,i,s),n.lineTo(a,l+f),n.quadraticCurveTo(a,l,a+f,l),n.closePath(),n.fill(),s.borderWidth>0&&n.stroke()}_updateAnimationTarget(t){const n=this.chart,i=this.$animations,s=i&&i.x,o=i&&i.y;if(s||o){const r=Tn[t.position].call(this,this._active,this._eventPosition);if(!r)return;const a=this._size=ra(this,t),l=Object.assign({},r,this._size),c=aa(n,t,l),u=la(t,l,c,n);(s._to!==u.x||o._to!==u.y)&&(this.xAlign=c.xAlign,this.yAlign=c.yAlign,this.width=a.width,this.height=a.height,this.caretX=r.x,this.caretY=r.y,this._resolveAnimations().update(this,u))}}_willRender(){return!!this.opacity}draw(t){const n=this.options.setContext(this.getContext());let i=this.opacity;if(!i)return;this._updateAnimationTarget(n);const s={width:this.width,height:this.height},o={x:this.x,y:this.y};i=Math.abs(i)<.001?0:i;const r=Mt(n.padding),a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;n.enabled&&a&&(t.save(),t.globalAlpha=i,this.drawBackground(o,t,s,n),ql(t,n.textDirection),o.y+=r.top,this.drawTitle(o,t,n),this.drawBody(o,t,n),this.drawFooter(o,t,n),Gl(t,n.textDirection),t.restore())}getActiveElements(){return this._active||[]}setActiveElements(t,n){const i=this._active,s=t.map(({datasetIndex:a,index:l})=>{const c=this.chart.getDatasetMeta(a);if(!c)throw new Error("Cannot find a dataset at index "+a);return{datasetIndex:a,element:c.data[l],index:l}}),o=!Ti(i,s),r=this._positionChanged(s,n);(o||r)&&(this._active=s,this._eventPosition=n,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(t,n,i=!0){if(n&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const s=this.options,o=this._active||[],r=this._getActiveElements(t,o,n,i),a=this._positionChanged(r,t),l=n||!Ti(r,o)||a;return l&&(this._active=r,(s.enabled||s.external)&&(this._eventPosition={x:t.x,y:t.y},this.update(!0,n))),l}_getActiveElements(t,n,i,s){const o=this.options;if(t.type==="mouseout")return[];if(!s)return n.filter(a=>this.chart.data.datasets[a.datasetIndex]&&this.chart.getDatasetMeta(a.datasetIndex).controller.getParsed(a.index)!==void 0);const r=this.chart.getElementsAtEventForMode(t,o.mode,o,i);return o.reverse&&r.reverse(),r}_positionChanged(t,n){const{caretX:i,caretY:s,options:o}=this,r=Tn[o.position].call(this,t,n);return r!==!1&&(i!==r.x||s!==r.y)}}var Zg={id:"tooltip",_element:ha,positioners:Tn,afterInit(e,t,n){n&&(e.tooltip=new ha({chart:e,options:n}))},beforeUpdate(e,t,n){e.tooltip&&e.tooltip.initialize(n)},reset(e,t,n){e.tooltip&&e.tooltip.initialize(n)},afterDraw(e){const t=e.tooltip;if(t&&t._willRender()){const n={tooltip:t};if(e.notifyPlugins("beforeTooltipDraw",{...n,cancelable:!0})===!1)return;t.draw(e.ctx),e.notifyPlugins("afterTooltipDraw",n)}},afterEvent(e,t){if(e.tooltip){const n=t.replay;e.tooltip.handleEvent(t.event,n,t.inChartArea)&&(t.changed=!0)}},defaults:{enabled:!0,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(e,t)=>t.bodyFont.size,boxWidth:(e,t)=>t.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:fc},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:e=>e!=="filter"&&e!=="itemSort"&&e!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const Qg=(e,t,n,i)=>(typeof t=="string"?(n=e.push(t)-1,i.unshift({index:n,label:t})):isNaN(t)&&(n=null),n);function Jg(e,t,n,i){const s=e.indexOf(t);if(s===-1)return Qg(e,t,n,i);const o=e.lastIndexOf(t);return s!==o?n:s}const tm=(e,t)=>e===null?null:xt(Math.round(e),0,t);function fa(e){const t=this.getLabels();return e>=0&&e<t.length?t[e]:e}class em extends rn{static id="category";static defaults={ticks:{callback:fa}};constructor(t){super(t),this._startValue=void 0,this._valueRange=0,this._addedLabels=[]}init(t){const n=this._addedLabels;if(n.length){const i=this.getLabels();for(const{index:s,label:o}of n)i[s]===o&&i.splice(s,1);this._addedLabels=[]}super.init(t)}parse(t,n){if(B(t))return null;const i=this.getLabels();return n=isFinite(n)&&i[n]===t?n:Jg(i,t,R(n,t),this._addedLabels),tm(n,i.length-1)}determineDataLimits(){const{minDefined:t,maxDefined:n}=this.getUserBounds();let{min:i,max:s}=this.getMinMax(!0);this.options.bounds==="ticks"&&(t||(i=0),n||(s=this.getLabels().length-1)),this.min=i,this.max=s}buildTicks(){const t=this.min,n=this.max,i=this.options.offset,s=[];let o=this.getLabels();o=t===0&&n===o.length-1?o:o.slice(t,n+1),this._valueRange=Math.max(o.length-(i?0:1),1),this._startValue=this.min-(i?.5:0);for(let r=t;r<=n;r++)s.push({value:r});return s}getLabelForValue(t){return fa.call(this,t)}configure(){super.configure(),this.isHorizontal()||(this._reversePixels=!this._reversePixels)}getPixelForValue(t){return typeof t!="number"&&(t=this.parse(t)),t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getPixelForTick(t){const n=this.ticks;return t<0||t>n.length-1?null:this.getPixelForValue(n[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function nm(e,t){const n=[],{bounds:s,step:o,min:r,max:a,precision:l,count:c,maxTicks:u,maxDigits:f,includeBounds:d}=e,m=o||1,y=u-1,{min:x,max:v}=t,w=!B(r),k=!B(a),E=!B(c),C=(v-x)/(f+1);let T=mr((v-x)/y/m)*m,D,P,O,A;if(T<1e-14&&!w&&!k)return[{value:x},{value:v}];A=Math.ceil(v/T)-Math.floor(x/T),A>y&&(T=mr(A*T/y/m)*m),B(l)||(D=Math.pow(10,l),T=Math.ceil(T*D)/D),s==="ticks"?(P=Math.floor(x/T)*T,O=Math.ceil(v/T)*T):(P=x,O=v),w&&k&&o&&Hf((a-r)/o,T/1e3)?(A=Math.round(Math.min((a-r)/T,u)),T=(a-r)/A,P=r,O=a):E?(P=w?r:P,O=k?a:O,A=c-1,T=(O-P)/A):(A=(O-P)/T,Ie(A,Math.round(A),T/1e3)?A=Math.round(A):A=Math.ceil(A));const z=Math.max(br(T),br(P));D=Math.pow(10,B(l)?z:l),P=Math.round(P*D)/D,O=Math.round(O*D)/D;let L=0;for(w&&(d&&P!==r?(n.push({value:r}),P<r&&L++,Ie(Math.round((P+L*T)*D)/D,r,da(r,C,e))&&L++):P<r&&L++);L<A;++L){const H=Math.round((P+L*T)*D)/D;if(k&&H>a)break;n.push({value:H})}return k&&d&&O!==a?n.length&&Ie(n[n.length-1].value,a,da(a,C,e))?n[n.length-1].value=a:n.push({value:a}):(!k||O===a)&&n.push({value:O}),n}function da(e,t,{horizontal:n,minRotation:i}){const s=Pe(i),o=(n?Math.sin(s):Math.cos(s))||.001,r=.75*t*(""+e).length;return Math.min(t/o,r)}class im extends rn{constructor(t){super(t),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(t,n){return B(t)||(typeof t=="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options,{minDefined:n,maxDefined:i}=this.getUserBounds();let{min:s,max:o}=this;const r=l=>s=n?s:l,a=l=>o=i?o:l;if(t){const l=he(s),c=he(o);l<0&&c<0?a(0):l>0&&c>0&&r(0)}if(s===o){let l=o===0?1:Math.abs(o*.05);a(o+l),t||r(s-l)}this.min=s,this.max=o}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:n,stepSize:i}=t,s;return i?(s=Math.ceil(this.max/i)-Math.floor(this.min/i)+1,s>1e3&&(console.warn(\`scales.\${this.id}.ticks.stepSize: \${i} would result generating up to \${s} ticks. Limiting to 1000.\`),s=1e3)):(s=this.computeTickLimit(),n=n||11),n&&(s=Math.min(n,s)),s}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options,n=t.ticks;let i=this.getTickLimit();i=Math.max(2,i);const s={maxTicks:i,bounds:t.bounds,min:t.min,max:t.max,precision:n.precision,step:n.stepSize,count:n.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:n.minRotation||0,includeBounds:n.includeBounds!==!1},o=this._range||this,r=nm(s,o);return t.bounds==="ticks"&&Vf(r,this,"value"),t.reverse?(r.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),r}configure(){const t=this.ticks;let n=this.min,i=this.max;if(super.configure(),this.options.offset&&t.length){const s=(i-n)/Math.max(t.length-1,1)/2;n-=s,i+=s}this._startValue=n,this._endValue=i,this._valueRange=i-n}getLabelForValue(t){return Hl(t,this.chart.options.locale,this.options.ticks.format)}}class sm extends im{static id="linear";static defaults={ticks:{callback:Vl.formatters.numeric}};determineDataLimits(){const{min:t,max:n}=this.getMinMax(!0);this.min=vt(t)?t:0,this.max=vt(n)?n:1,this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal(),n=t?this.width:this.height,i=Pe(this.options.ticks.minRotation),s=(t?Math.sin(i):Math.cos(i))||.001,o=this._resolveTickFontOptions(0);return Math.ceil(n/Math.min(40,o.lineHeight/s))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const Wi={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},ut=Object.keys(Wi);function pa(e,t){return e-t}function ga(e,t){if(B(t))return null;const n=e._adapter,{parser:i,round:s,isoWeekday:o}=e._parseOpts;let r=t;return typeof i=="function"&&(r=i(r)),vt(r)||(r=typeof i=="string"?n.parse(r,i):n.parse(r)),r===null?null:(s&&(r=s==="week"&&(Rn(o)||o===!0)?n.startOf(r,"isoWeek",o):n.startOf(r,s)),+r)}function ma(e,t,n,i){const s=ut.length;for(let o=ut.indexOf(e);o<s-1;++o){const r=Wi[ut[o]],a=r.steps?r.steps:Number.MAX_SAFE_INTEGER;if(r.common&&Math.ceil((n-t)/(a*r.size))<=i)return ut[o]}return ut[s-1]}function om(e,t,n,i,s){for(let o=ut.length-1;o>=ut.indexOf(n);o--){const r=ut[o];if(Wi[r].common&&e._adapter.diff(s,i,r)>=t-1)return r}return ut[n?ut.indexOf(n):0]}function rm(e){for(let t=ut.indexOf(e)+1,n=ut.length;t<n;++t)if(Wi[ut[t]].common)return ut[t]}function ba(e,t,n){if(!n)e[t]=!0;else if(n.length){const{lo:i,hi:s}=xo(n,t),o=n[i]>=t?n[i]:n[s];e[o]=!0}}function am(e,t,n,i){const s=e._adapter,o=+s.startOf(t[0].value,i),r=t[t.length-1].value;let a,l;for(a=o;a<=r;a=+s.add(a,1,i))l=n[a],l>=0&&(t[l].major=!0);return t}function xa(e,t,n){const i=[],s={},o=t.length;let r,a;for(r=0;r<o;++r)a=t[r],s[a]=r,i.push({value:a,major:!1});return o===0||!n?i:am(e,i,s,n)}class ya extends rn{static id="time";static defaults={bounds:"data",adapters:{},time:{parser:!1,unit:!1,round:!1,isoWeekday:!1,minUnit:"millisecond",displayFormats:{}},ticks:{source:"auto",callback:!1,major:{enabled:!1}}};constructor(t){super(t),this._cache={data:[],labels:[],all:[]},this._unit="day",this._majorUnit=void 0,this._offsets={},this._normalized=!1,this._parseOpts=void 0}init(t,n={}){const i=t.time||(t.time={}),s=this._adapter=new xp._date(t.adapters.date);s.init(n),Mn(i.displayFormats,s.formats()),this._parseOpts={parser:i.parser,round:i.round,isoWeekday:i.isoWeekday},super.init(t),this._normalized=n.normalized}parse(t,n){return t===void 0?null:ga(this,t)}beforeLayout(){super.beforeLayout(),this._cache={data:[],labels:[],all:[]}}determineDataLimits(){const t=this.options,n=this._adapter,i=t.time.unit||"day";let{min:s,max:o,minDefined:r,maxDefined:a}=this.getUserBounds();function l(c){!r&&!isNaN(c.min)&&(s=Math.min(s,c.min)),!a&&!isNaN(c.max)&&(o=Math.max(o,c.max))}(!r||!a)&&(l(this._getLabelBounds()),(t.bounds!=="ticks"||t.ticks.source!=="labels")&&l(this.getMinMax(!1))),s=vt(s)&&!isNaN(s)?s:+n.startOf(Date.now(),i),o=vt(o)&&!isNaN(o)?o:+n.endOf(Date.now(),i)+1,this.min=Math.min(s,o-1),this.max=Math.max(s+1,o)}_getLabelBounds(){const t=this.getLabelTimestamps();let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;return t.length&&(n=t[0],i=t[t.length-1]),{min:n,max:i}}buildTicks(){const t=this.options,n=t.time,i=t.ticks,s=i.source==="labels"?this.getLabelTimestamps():this._generate();t.bounds==="ticks"&&s.length&&(this.min=this._userMin||s[0],this.max=this._userMax||s[s.length-1]);const o=this.min,r=this.max,a=Yf(s,o,r);return this._unit=n.unit||(i.autoSkip?ma(n.minUnit,this.min,this.max,this._getLabelCapacity(o)):om(this,a.length,n.minUnit,this.min,this.max)),this._majorUnit=!i.major.enabled||this._unit==="year"?void 0:rm(this._unit),this.initOffsets(s),t.reverse&&a.reverse(),xa(this,a,this._majorUnit)}afterAutoSkip(){this.options.offsetAfterAutoskip&&this.initOffsets(this.ticks.map(t=>+t.value))}initOffsets(t=[]){let n=0,i=0,s,o;this.options.offset&&t.length&&(s=this.getDecimalForValue(t[0]),t.length===1?n=1-s:n=(this.getDecimalForValue(t[1])-s)/2,o=this.getDecimalForValue(t[t.length-1]),t.length===1?i=o:i=(o-this.getDecimalForValue(t[t.length-2]))/2);const r=t.length<3?.5:.25;n=xt(n,0,r),i=xt(i,0,r),this._offsets={start:n,end:i,factor:1/(n+1+i)}}_generate(){const t=this._adapter,n=this.min,i=this.max,s=this.options,o=s.time,r=o.unit||ma(o.minUnit,n,i,this._getLabelCapacity(n)),a=R(s.ticks.stepSize,1),l=r==="week"?o.isoWeekday:!1,c=Rn(l)||l===!0,u={};let f=n,d,m;if(c&&(f=+t.startOf(f,"isoWeek",l)),f=+t.startOf(f,c?"day":r),t.diff(i,n,r)>1e5*a)throw new Error(n+" and "+i+" are too far apart with stepSize of "+a+" "+r);const y=s.ticks.source==="data"&&this.getDataTimestamps();for(d=f,m=0;d<i;d=+t.add(d,a,r),m++)ba(u,d,y);return(d===i||s.bounds==="ticks"||m===1)&&ba(u,d,y),Object.keys(u).sort(pa).map(x=>+x)}getLabelForValue(t){const n=this._adapter,i=this.options.time;return i.tooltipFormat?n.format(t,i.tooltipFormat):n.format(t,i.displayFormats.datetime)}format(t,n){const s=this.options.time.displayFormats,o=this._unit,r=n||s[o];return this._adapter.format(t,r)}_tickFormatFunction(t,n,i,s){const o=this.options,r=o.ticks.callback;if(r)return I(r,[t,n,i],this);const a=o.time.displayFormats,l=this._unit,c=this._majorUnit,u=l&&a[l],f=c&&a[c],d=i[n],m=c&&f&&d&&d.major;return this._adapter.format(t,s||(m?f:u))}generateTickLabels(t){let n,i,s;for(n=0,i=t.length;n<i;++n)s=t[n],s.label=this._tickFormatFunction(s.value,n,t)}getDecimalForValue(t){return t===null?NaN:(t-this.min)/(this.max-this.min)}getPixelForValue(t){const n=this._offsets,i=this.getDecimalForValue(t);return this.getPixelForDecimal((n.start+i)*n.factor)}getValueForPixel(t){const n=this._offsets,i=this.getDecimalForPixel(t)/n.factor-n.end;return this.min+i*(this.max-this.min)}_getLabelSize(t){const n=this.options.ticks,i=this.ctx.measureText(t).width,s=Pe(this.isHorizontal()?n.maxRotation:n.minRotation),o=Math.cos(s),r=Math.sin(s),a=this._resolveTickFontOptions(0).size;return{w:i*o+a*r,h:i*r+a*o}}_getLabelCapacity(t){const n=this.options.time,i=n.displayFormats,s=i[n.unit]||i.millisecond,o=this._tickFormatFunction(t,0,xa(this,[t],this._majorUnit),s),r=this._getLabelSize(o),a=Math.floor(this.isHorizontal()?this.width/r.w:this.height/r.h)-1;return a>0?a:1}getDataTimestamps(){let t=this._cache.data||[],n,i;if(t.length)return t;const s=this.getMatchingVisibleMetas();if(this._normalized&&s.length)return this._cache.data=s[0].controller.getAllParsedValues(this);for(n=0,i=s.length;n<i;++n)t=t.concat(s[n].controller.getAllParsedValues(this));return this._cache.data=this.normalize(t)}getLabelTimestamps(){const t=this._cache.labels||[];let n,i;if(t.length)return t;const s=this.getLabels();for(n=0,i=s.length;n<i;++n)t.push(ga(this,s[n]));return this._cache.labels=this._normalized?t:this.normalize(t)}normalize(t){return qf(t.sort(pa))}}function fi(e,t,n){let i=0,s=e.length-1,o,r,a,l;n?(t>=e[i].pos&&t<=e[s].pos&&({lo:i,hi:s}=De(e,"pos",t)),{pos:o,time:a}=e[i],{pos:r,time:l}=e[s]):(t>=e[i].time&&t<=e[s].time&&({lo:i,hi:s}=De(e,"time",t)),{time:o,pos:a}=e[i],{time:r,pos:l}=e[s]);const c=r-o;return c?a+(l-a)*(t-o)/c:a}class mb extends ya{static id="timeseries";static defaults=ya.defaults;constructor(t){super(t),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable(),n=this._table=this.buildLookupTable(t);this._minPos=fi(n,this.min),this._tableRange=fi(n,this.max)-this._minPos,super.initOffsets(t)}buildLookupTable(t){const{min:n,max:i}=this,s=[],o=[];let r,a,l,c,u;for(r=0,a=t.length;r<a;++r)c=t[r],c>=n&&c<=i&&s.push(c);if(s.length<2)return[{time:n,pos:0},{time:i,pos:1}];for(r=0,a=s.length;r<a;++r)u=s[r+1],l=s[r-1],c=s[r],Math.round((u+l)/2)!==c&&o.push({time:c,pos:r/(a-1)});return o}_generate(){const t=this.min,n=this.max;let i=super.getDataTimestamps();return(!i.includes(t)||!i.length)&&i.splice(0,0,t),(!i.includes(n)||i.length===1)&&i.push(n),i.sort((s,o)=>s-o)}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const n=this.getDataTimestamps(),i=this.getLabelTimestamps();return n.length&&i.length?t=this.normalize(n.concat(i)):t=n.length?n:i,t=this._cache.all=t,t}getDecimalForValue(t){return(fi(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const n=this._offsets,i=this.getDecimalForPixel(t)/n.factor-n.end;return fi(this._table,i*this._tableRange+this._minPos,!0)}}function lm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var us={exports:{}};/*! Hammer.JS - v2.0.7 - 2016-04-22
9143
9296
  * http://hammerjs.github.io/
9144
9297
  *
9145
9298
  * Copyright (c) 2016 Jorik Tangelder;
9146
- * Licensed under the MIT license */var ya;function lm(){return ya||(ya=1,(function(e){(function(t,n,i,s){var o=["","webkit","Moz","MS","ms","o"],r=n.createElement("div"),a="function",l=Math.round,c=Math.abs,u=Date.now;function f(h,p,b){return setTimeout(E(h,b),p)}function d(h,p,b){return Array.isArray(h)?(m(h,b[p],b),!0):!1}function m(h,p,b){var _;if(h)if(h.forEach)h.forEach(p,b);else if(h.length!==s)for(_=0;_<h.length;)p.call(b,h[_],_,h),_++;else for(_ in h)h.hasOwnProperty(_)&&p.call(b,h[_],_,h)}function y(h,p,b){var _="DEPRECATED METHOD: "+p+\`
9299
+ * Licensed under the MIT license */var va;function cm(){return va||(va=1,(function(e){(function(t,n,i,s){var o=["","webkit","Moz","MS","ms","o"],r=n.createElement("div"),a="function",l=Math.round,c=Math.abs,u=Date.now;function f(h,p,b){return setTimeout(E(h,b),p)}function d(h,p,b){return Array.isArray(h)?(m(h,b[p],b),!0):!1}function m(h,p,b){var _;if(h)if(h.forEach)h.forEach(p,b);else if(h.length!==s)for(_=0;_<h.length;)p.call(b,h[_],_,h),_++;else for(_ in h)h.hasOwnProperty(_)&&p.call(b,h[_],_,h)}function y(h,p,b){var _="DEPRECATED METHOD: "+p+\`
9147
9300
  \`+b+\` AT
9148
- \`;return function(){var S=new Error("get-stack-trace"),M=S&&S.stack?S.stack.replace(/^[^\\(]+?[\\n$]/gm,"").replace(/^\\s+at\\s+/gm,"").replace(/^Object.<anonymous>\\s*\\(/gm,"{anonymous}()@"):"Unknown Stack Trace",N=t.console&&(t.console.warn||t.console.log);return N&&N.call(t.console,_,M),h.apply(this,arguments)}}var x;typeof Object.assign!="function"?x=function(p){if(p===s||p===null)throw new TypeError("Cannot convert undefined or null to object");for(var b=Object(p),_=1;_<arguments.length;_++){var S=arguments[_];if(S!==s&&S!==null)for(var M in S)S.hasOwnProperty(M)&&(b[M]=S[M])}return b}:x=Object.assign;var v=y(function(p,b,_){for(var S=Object.keys(b),M=0;M<S.length;)(!_||_&&p[S[M]]===s)&&(p[S[M]]=b[S[M]]),M++;return p},"extend","Use \`assign\`."),w=y(function(p,b){return v(p,b,!0)},"merge","Use \`assign\`.");function k(h,p,b){var _=p.prototype,S;S=h.prototype=Object.create(_),S.constructor=h,S._super=_,b&&x(S,b)}function E(h,p){return function(){return h.apply(p,arguments)}}function C(h,p){return typeof h==a?h.apply(p&&p[0]||s,p):h}function T(h,p){return h===s?p:h}function D(h,p,b){m(z(p),function(_){h.addEventListener(_,b,!1)})}function P(h,p,b){m(z(p),function(_){h.removeEventListener(_,b,!1)})}function O(h,p){for(;h;){if(h==p)return!0;h=h.parentNode}return!1}function A(h,p){return h.indexOf(p)>-1}function z(h){return h.trim().split(/\\s+/g)}function L(h,p,b){if(h.indexOf&&!b)return h.indexOf(p);for(var _=0;_<h.length;){if(b&&h[_][b]==p||!b&&h[_]===p)return _;_++}return-1}function H(h){return Array.prototype.slice.call(h,0)}function Z(h,p,b){for(var _=[],S=[],M=0;M<h.length;){var N=h[M][p];L(S,N)<0&&_.push(h[M]),S[M]=N,M++}return _=_.sort(function(Q,ot){return Q[p]>ot[p]}),_}function nt(h,p){for(var b,_,S=p[0].toUpperCase()+p.slice(1),M=0;M<o.length;){if(b=o[M],_=b?b+S:p,_ in h)return _;M++}return s}var j=1;function q(){return j++}function it(h){var p=h.ownerDocument||h;return p.defaultView||p.parentWindow||t}var We=/mobile|tablet|ip(ad|hone|od)|android/i,be="ontouchstart"in t,Gt=nt(t,"PointerEvent")!==s,je=be&&We.test(navigator.userAgent),dt="touch",xe="pen",wt="mouse",ye="kinect",Vt=25,st=1,ve=2,X=4,at=8,Wn=1,ln=2,cn=4,un=8,hn=16,Et=ln|cn,_e=un|hn,Po=Et|_e,Do=["x","y"],jn=["clientX","clientY"];function pt(h,p){var b=this;this.manager=h,this.callback=p,this.element=h.element,this.target=h.options.inputTarget,this.domHandler=function(_){C(h.options.enable,[h])&&b.handler(_)},this.init()}pt.prototype={handler:function(){},init:function(){this.evEl&&D(this.element,this.evEl,this.domHandler),this.evTarget&&D(this.target,this.evTarget,this.domHandler),this.evWin&&D(it(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&P(this.element,this.evEl,this.domHandler),this.evTarget&&P(this.target,this.evTarget,this.domHandler),this.evWin&&P(it(this.element),this.evWin,this.domHandler)}};function Cc(h){var p,b=h.options.inputClass;return b?p=b:Gt?p=$i:je?p=Yn:be?p=Ui:p=Un,new p(h,Oc)}function Oc(h,p,b){var _=b.pointers.length,S=b.changedPointers.length,M=p&st&&_-S===0,N=p&(X|at)&&_-S===0;b.isFirst=!!M,b.isFinal=!!N,M&&(h.session={}),b.eventType=p,Pc(h,b),h.emit("hammer.input",b),h.recognize(b),h.session.prevInput=b}function Pc(h,p){var b=h.session,_=p.pointers,S=_.length;b.firstInput||(b.firstInput=Ao(p)),S>1&&!b.firstMultiple?b.firstMultiple=Ao(p):S===1&&(b.firstMultiple=!1);var M=b.firstInput,N=b.firstMultiple,K=N?N.center:M.center,Q=p.center=Io(_);p.timeStamp=u(),p.deltaTime=p.timeStamp-M.timeStamp,p.angle=ji(K,Q),p.distance=$n(K,Q),Dc(b,p),p.offsetDirection=Ro(p.deltaX,p.deltaY);var ot=Lo(p.deltaTime,p.deltaX,p.deltaY);p.overallVelocityX=ot.x,p.overallVelocityY=ot.y,p.overallVelocity=c(ot.x)>c(ot.y)?ot.x:ot.y,p.scale=N?Lc(N.pointers,_):1,p.rotation=N?Ic(N.pointers,_):0,p.maxPointers=b.prevInput?p.pointers.length>b.prevInput.maxPointers?p.pointers.length:b.prevInput.maxPointers:p.pointers.length,Ac(b,p);var Ot=h.element;O(p.srcEvent.target,Ot)&&(Ot=p.srcEvent.target),p.target=Ot}function Dc(h,p){var b=p.center,_=h.offsetDelta||{},S=h.prevDelta||{},M=h.prevInput||{};(p.eventType===st||M.eventType===X)&&(S=h.prevDelta={x:M.deltaX||0,y:M.deltaY||0},_=h.offsetDelta={x:b.x,y:b.y}),p.deltaX=S.x+(b.x-_.x),p.deltaY=S.y+(b.y-_.y)}function Ac(h,p){var b=h.lastInterval||p,_=p.timeStamp-b.timeStamp,S,M,N,K;if(p.eventType!=at&&(_>Vt||b.velocity===s)){var Q=p.deltaX-b.deltaX,ot=p.deltaY-b.deltaY,Ot=Lo(_,Q,ot);M=Ot.x,N=Ot.y,S=c(Ot.x)>c(Ot.y)?Ot.x:Ot.y,K=Ro(Q,ot),h.lastInterval=p}else S=b.velocity,M=b.velocityX,N=b.velocityY,K=b.direction;p.velocity=S,p.velocityX=M,p.velocityY=N,p.direction=K}function Ao(h){for(var p=[],b=0;b<h.pointers.length;)p[b]={clientX:l(h.pointers[b].clientX),clientY:l(h.pointers[b].clientY)},b++;return{timeStamp:u(),pointers:p,center:Io(p),deltaX:h.deltaX,deltaY:h.deltaY}}function Io(h){var p=h.length;if(p===1)return{x:l(h[0].clientX),y:l(h[0].clientY)};for(var b=0,_=0,S=0;S<p;)b+=h[S].clientX,_+=h[S].clientY,S++;return{x:l(b/p),y:l(_/p)}}function Lo(h,p,b){return{x:p/h||0,y:b/h||0}}function Ro(h,p){return h===p?Wn:c(h)>=c(p)?h<0?ln:cn:p<0?un:hn}function $n(h,p,b){b||(b=Do);var _=p[b[0]]-h[b[0]],S=p[b[1]]-h[b[1]];return Math.sqrt(_*_+S*S)}function ji(h,p,b){b||(b=Do);var _=p[b[0]]-h[b[0]],S=p[b[1]]-h[b[1]];return Math.atan2(S,_)*180/Math.PI}function Ic(h,p){return ji(p[1],p[0],jn)+ji(h[1],h[0],jn)}function Lc(h,p){return $n(p[0],p[1],jn)/$n(h[0],h[1],jn)}var Rc={mousedown:st,mousemove:ve,mouseup:X},Nc="mousedown",Fc="mousemove mouseup";function Un(){this.evEl=Nc,this.evWin=Fc,this.pressed=!1,pt.apply(this,arguments)}k(Un,pt,{handler:function(p){var b=Rc[p.type];b&st&&p.button===0&&(this.pressed=!0),b&ve&&p.which!==1&&(b=X),this.pressed&&(b&X&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[p],changedPointers:[p],pointerType:wt,srcEvent:p}))}});var zc={pointerdown:st,pointermove:ve,pointerup:X,pointercancel:at,pointerout:at},Hc={2:dt,3:xe,4:wt,5:ye},No="pointerdown",Fo="pointermove pointerup pointercancel";t.MSPointerEvent&&!t.PointerEvent&&(No="MSPointerDown",Fo="MSPointerMove MSPointerUp MSPointerCancel");function $i(){this.evEl=No,this.evWin=Fo,pt.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}k($i,pt,{handler:function(p){var b=this.store,_=!1,S=p.type.toLowerCase().replace("ms",""),M=zc[S],N=Hc[p.pointerType]||p.pointerType,K=N==dt,Q=L(b,p.pointerId,"pointerId");M&st&&(p.button===0||K)?Q<0&&(b.push(p),Q=b.length-1):M&(X|at)&&(_=!0),!(Q<0)&&(b[Q]=p,this.callback(this.manager,M,{pointers:b,changedPointers:[p],pointerType:N,srcEvent:p}),_&&b.splice(Q,1))}});var Vc={touchstart:st,touchmove:ve,touchend:X,touchcancel:at},Bc="touchstart",Wc="touchstart touchmove touchend touchcancel";function zo(){this.evTarget=Bc,this.evWin=Wc,this.started=!1,pt.apply(this,arguments)}k(zo,pt,{handler:function(p){var b=Vc[p.type];if(b===st&&(this.started=!0),!!this.started){var _=jc.call(this,p,b);b&(X|at)&&_[0].length-_[1].length===0&&(this.started=!1),this.callback(this.manager,b,{pointers:_[0],changedPointers:_[1],pointerType:dt,srcEvent:p})}}});function jc(h,p){var b=H(h.touches),_=H(h.changedTouches);return p&(X|at)&&(b=Z(b.concat(_),"identifier")),[b,_]}var $c={touchstart:st,touchmove:ve,touchend:X,touchcancel:at},Uc="touchstart touchmove touchend touchcancel";function Yn(){this.evTarget=Uc,this.targetIds={},pt.apply(this,arguments)}k(Yn,pt,{handler:function(p){var b=$c[p.type],_=Yc.call(this,p,b);_&&this.callback(this.manager,b,{pointers:_[0],changedPointers:_[1],pointerType:dt,srcEvent:p})}});function Yc(h,p){var b=H(h.touches),_=this.targetIds;if(p&(st|ve)&&b.length===1)return _[b[0].identifier]=!0,[b,b];var S,M,N=H(h.changedTouches),K=[],Q=this.target;if(M=b.filter(function(ot){return O(ot.target,Q)}),p===st)for(S=0;S<M.length;)_[M[S].identifier]=!0,S++;for(S=0;S<N.length;)_[N[S].identifier]&&K.push(N[S]),p&(X|at)&&delete _[N[S].identifier],S++;if(K.length)return[Z(M.concat(K),"identifier"),K]}var Xc=2500,Ho=25;function Ui(){pt.apply(this,arguments);var h=E(this.handler,this);this.touch=new Yn(this.manager,h),this.mouse=new Un(this.manager,h),this.primaryTouch=null,this.lastTouches=[]}k(Ui,pt,{handler:function(p,b,_){var S=_.pointerType==dt,M=_.pointerType==wt;if(!(M&&_.sourceCapabilities&&_.sourceCapabilities.firesTouchEvents)){if(S)qc.call(this,b,_);else if(M&&Gc.call(this,_))return;this.callback(p,b,_)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});function qc(h,p){h&st?(this.primaryTouch=p.changedPointers[0].identifier,Vo.call(this,p)):h&(X|at)&&Vo.call(this,p)}function Vo(h){var p=h.changedPointers[0];if(p.identifier===this.primaryTouch){var b={x:p.clientX,y:p.clientY};this.lastTouches.push(b);var _=this.lastTouches,S=function(){var M=_.indexOf(b);M>-1&&_.splice(M,1)};setTimeout(S,Xc)}}function Gc(h){for(var p=h.srcEvent.clientX,b=h.srcEvent.clientY,_=0;_<this.lastTouches.length;_++){var S=this.lastTouches[_],M=Math.abs(p-S.x),N=Math.abs(b-S.y);if(M<=Ho&&N<=Ho)return!0}return!1}var Bo=nt(r.style,"touchAction"),Wo=Bo!==s,jo="compute",$o="auto",Yi="manipulation",we="none",fn="pan-x",dn="pan-y",Xn=Zc();function Xi(h,p){this.manager=h,this.set(p)}Xi.prototype={set:function(h){h==jo&&(h=this.compute()),Wo&&this.manager.element.style&&Xn[h]&&(this.manager.element.style[Bo]=h),this.actions=h.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var h=[];return m(this.manager.recognizers,function(p){C(p.options.enable,[p])&&(h=h.concat(p.getTouchAction()))}),Kc(h.join(" "))},preventDefaults:function(h){var p=h.srcEvent,b=h.offsetDirection;if(this.manager.session.prevented){p.preventDefault();return}var _=this.actions,S=A(_,we)&&!Xn[we],M=A(_,dn)&&!Xn[dn],N=A(_,fn)&&!Xn[fn];if(S){var K=h.pointers.length===1,Q=h.distance<2,ot=h.deltaTime<250;if(K&&Q&&ot)return}if(!(N&&M)&&(S||M&&b&Et||N&&b&_e))return this.preventSrc(p)},preventSrc:function(h){this.manager.session.prevented=!0,h.preventDefault()}};function Kc(h){if(A(h,we))return we;var p=A(h,fn),b=A(h,dn);return p&&b?we:p||b?p?fn:dn:A(h,Yi)?Yi:$o}function Zc(){if(!Wo)return!1;var h={},p=t.CSS&&t.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(b){h[b]=p?t.CSS.supports("touch-action",b):!0}),h}var qn=1,gt=2,$e=4,Kt=8,Bt=Kt,pn=16,Ct=32;function Wt(h){this.options=x({},this.defaults,h||{}),this.id=q(),this.manager=null,this.options.enable=T(this.options.enable,!0),this.state=qn,this.simultaneous={},this.requireFail=[]}Wt.prototype={defaults:{},set:function(h){return x(this.options,h),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(h){if(d(h,"recognizeWith",this))return this;var p=this.simultaneous;return h=Gn(h,this),p[h.id]||(p[h.id]=h,h.recognizeWith(this)),this},dropRecognizeWith:function(h){return d(h,"dropRecognizeWith",this)?this:(h=Gn(h,this),delete this.simultaneous[h.id],this)},requireFailure:function(h){if(d(h,"requireFailure",this))return this;var p=this.requireFail;return h=Gn(h,this),L(p,h)===-1&&(p.push(h),h.requireFailure(this)),this},dropRequireFailure:function(h){if(d(h,"dropRequireFailure",this))return this;h=Gn(h,this);var p=L(this.requireFail,h);return p>-1&&this.requireFail.splice(p,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(h){return!!this.simultaneous[h.id]},emit:function(h){var p=this,b=this.state;function _(S){p.manager.emit(S,h)}b<Kt&&_(p.options.event+Uo(b)),_(p.options.event),h.additionalEvent&&_(h.additionalEvent),b>=Kt&&_(p.options.event+Uo(b))},tryEmit:function(h){if(this.canEmit())return this.emit(h);this.state=Ct},canEmit:function(){for(var h=0;h<this.requireFail.length;){if(!(this.requireFail[h].state&(Ct|qn)))return!1;h++}return!0},recognize:function(h){var p=x({},h);if(!C(this.options.enable,[this,p])){this.reset(),this.state=Ct;return}this.state&(Bt|pn|Ct)&&(this.state=qn),this.state=this.process(p),this.state&(gt|$e|Kt|pn)&&this.tryEmit(p)},process:function(h){},getTouchAction:function(){},reset:function(){}};function Uo(h){return h&pn?"cancel":h&Kt?"end":h&$e?"move":h&gt?"start":""}function Yo(h){return h==hn?"down":h==un?"up":h==ln?"left":h==cn?"right":""}function Gn(h,p){var b=p.manager;return b?b.get(h):h}function St(){Wt.apply(this,arguments)}k(St,Wt,{defaults:{pointers:1},attrTest:function(h){var p=this.options.pointers;return p===0||h.pointers.length===p},process:function(h){var p=this.state,b=h.eventType,_=p&(gt|$e),S=this.attrTest(h);return _&&(b&at||!S)?p|pn:_||S?b&X?p|Kt:p&gt?p|$e:gt:Ct}});function Kn(){St.apply(this,arguments),this.pX=null,this.pY=null}k(Kn,St,{defaults:{event:"pan",threshold:10,pointers:1,direction:Po},getTouchAction:function(){var h=this.options.direction,p=[];return h&Et&&p.push(dn),h&_e&&p.push(fn),p},directionTest:function(h){var p=this.options,b=!0,_=h.distance,S=h.direction,M=h.deltaX,N=h.deltaY;return S&p.direction||(p.direction&Et?(S=M===0?Wn:M<0?ln:cn,b=M!=this.pX,_=Math.abs(h.deltaX)):(S=N===0?Wn:N<0?un:hn,b=N!=this.pY,_=Math.abs(h.deltaY))),h.direction=S,b&&_>p.threshold&&S&p.direction},attrTest:function(h){return St.prototype.attrTest.call(this,h)&&(this.state&gt||!(this.state&gt)&&this.directionTest(h))},emit:function(h){this.pX=h.deltaX,this.pY=h.deltaY;var p=Yo(h.direction);p&&(h.additionalEvent=this.options.event+p),this._super.emit.call(this,h)}});function qi(){St.apply(this,arguments)}k(qi,St,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[we]},attrTest:function(h){return this._super.attrTest.call(this,h)&&(Math.abs(h.scale-1)>this.options.threshold||this.state&gt)},emit:function(h){if(h.scale!==1){var p=h.scale<1?"in":"out";h.additionalEvent=this.options.event+p}this._super.emit.call(this,h)}});function Gi(){Wt.apply(this,arguments),this._timer=null,this._input=null}k(Gi,Wt,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[$o]},process:function(h){var p=this.options,b=h.pointers.length===p.pointers,_=h.distance<p.threshold,S=h.deltaTime>p.time;if(this._input=h,!_||!b||h.eventType&(X|at)&&!S)this.reset();else if(h.eventType&st)this.reset(),this._timer=f(function(){this.state=Bt,this.tryEmit()},p.time,this);else if(h.eventType&X)return Bt;return Ct},reset:function(){clearTimeout(this._timer)},emit:function(h){this.state===Bt&&(h&&h.eventType&X?this.manager.emit(this.options.event+"up",h):(this._input.timeStamp=u(),this.manager.emit(this.options.event,this._input)))}});function Ki(){St.apply(this,arguments)}k(Ki,St,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[we]},attrTest:function(h){return this._super.attrTest.call(this,h)&&(Math.abs(h.rotation)>this.options.threshold||this.state&gt)}});function Zi(){St.apply(this,arguments)}k(Zi,St,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:Et|_e,pointers:1},getTouchAction:function(){return Kn.prototype.getTouchAction.call(this)},attrTest:function(h){var p=this.options.direction,b;return p&(Et|_e)?b=h.overallVelocity:p&Et?b=h.overallVelocityX:p&_e&&(b=h.overallVelocityY),this._super.attrTest.call(this,h)&&p&h.offsetDirection&&h.distance>this.options.threshold&&h.maxPointers==this.options.pointers&&c(b)>this.options.velocity&&h.eventType&X},emit:function(h){var p=Yo(h.offsetDirection);p&&this.manager.emit(this.options.event+p,h),this.manager.emit(this.options.event,h)}});function Zn(){Wt.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}k(Zn,Wt,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Yi]},process:function(h){var p=this.options,b=h.pointers.length===p.pointers,_=h.distance<p.threshold,S=h.deltaTime<p.time;if(this.reset(),h.eventType&st&&this.count===0)return this.failTimeout();if(_&&S&&b){if(h.eventType!=X)return this.failTimeout();var M=this.pTime?h.timeStamp-this.pTime<p.interval:!0,N=!this.pCenter||$n(this.pCenter,h.center)<p.posThreshold;this.pTime=h.timeStamp,this.pCenter=h.center,!N||!M?this.count=1:this.count+=1,this._input=h;var K=this.count%p.taps;if(K===0)return this.hasRequireFailures()?(this._timer=f(function(){this.state=Bt,this.tryEmit()},p.interval,this),gt):Bt}return Ct},failTimeout:function(){return this._timer=f(function(){this.state=Ct},this.options.interval,this),Ct},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==Bt&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}});function Zt(h,p){return p=p||{},p.recognizers=T(p.recognizers,Zt.defaults.preset),new Qi(h,p)}Zt.VERSION="2.0.7",Zt.defaults={domEvents:!1,touchAction:jo,enable:!0,inputTarget:null,inputClass:null,preset:[[Ki,{enable:!1}],[qi,{enable:!1},["rotate"]],[Zi,{direction:Et}],[Kn,{direction:Et},["swipe"]],[Zn],[Zn,{event:"doubletap",taps:2},["tap"]],[Gi]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var Qc=1,Xo=2;function Qi(h,p){this.options=x({},Zt.defaults,p||{}),this.options.inputTarget=this.options.inputTarget||h,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=h,this.input=Cc(this),this.touchAction=new Xi(this,this.options.touchAction),qo(this,!0),m(this.options.recognizers,function(b){var _=this.add(new b[0](b[1]));b[2]&&_.recognizeWith(b[2]),b[3]&&_.requireFailure(b[3])},this)}Qi.prototype={set:function(h){return x(this.options,h),h.touchAction&&this.touchAction.update(),h.inputTarget&&(this.input.destroy(),this.input.target=h.inputTarget,this.input.init()),this},stop:function(h){this.session.stopped=h?Xo:Qc},recognize:function(h){var p=this.session;if(!p.stopped){this.touchAction.preventDefaults(h);var b,_=this.recognizers,S=p.curRecognizer;(!S||S&&S.state&Bt)&&(S=p.curRecognizer=null);for(var M=0;M<_.length;)b=_[M],p.stopped!==Xo&&(!S||b==S||b.canRecognizeWith(S))?b.recognize(h):b.reset(),!S&&b.state&(gt|$e|Kt)&&(S=p.curRecognizer=b),M++}},get:function(h){if(h instanceof Wt)return h;for(var p=this.recognizers,b=0;b<p.length;b++)if(p[b].options.event==h)return p[b];return null},add:function(h){if(d(h,"add",this))return this;var p=this.get(h.options.event);return p&&this.remove(p),this.recognizers.push(h),h.manager=this,this.touchAction.update(),h},remove:function(h){if(d(h,"remove",this))return this;if(h=this.get(h),h){var p=this.recognizers,b=L(p,h);b!==-1&&(p.splice(b,1),this.touchAction.update())}return this},on:function(h,p){if(h!==s&&p!==s){var b=this.handlers;return m(z(h),function(_){b[_]=b[_]||[],b[_].push(p)}),this}},off:function(h,p){if(h!==s){var b=this.handlers;return m(z(h),function(_){p?b[_]&&b[_].splice(L(b[_],p),1):delete b[_]}),this}},emit:function(h,p){this.options.domEvents&&Jc(h,p);var b=this.handlers[h]&&this.handlers[h].slice();if(!(!b||!b.length)){p.type=h,p.preventDefault=function(){p.srcEvent.preventDefault()};for(var _=0;_<b.length;)b[_](p),_++}},destroy:function(){this.element&&qo(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}};function qo(h,p){var b=h.element;if(b.style){var _;m(h.options.cssProps,function(S,M){_=nt(b.style,M),p?(h.oldCssProps[_]=b.style[_],b.style[_]=S):b.style[_]=h.oldCssProps[_]||""}),p||(h.oldCssProps={})}}function Jc(h,p){var b=n.createEvent("Event");b.initEvent(h,!0,!0),b.gesture=p,p.target.dispatchEvent(b)}x(Zt,{INPUT_START:st,INPUT_MOVE:ve,INPUT_END:X,INPUT_CANCEL:at,STATE_POSSIBLE:qn,STATE_BEGAN:gt,STATE_CHANGED:$e,STATE_ENDED:Kt,STATE_RECOGNIZED:Bt,STATE_CANCELLED:pn,STATE_FAILED:Ct,DIRECTION_NONE:Wn,DIRECTION_LEFT:ln,DIRECTION_RIGHT:cn,DIRECTION_UP:un,DIRECTION_DOWN:hn,DIRECTION_HORIZONTAL:Et,DIRECTION_VERTICAL:_e,DIRECTION_ALL:Po,Manager:Qi,Input:pt,TouchAction:Xi,TouchInput:Yn,MouseInput:Un,PointerEventInput:$i,TouchMouseInput:Ui,SingleTouchInput:zo,Recognizer:Wt,AttrRecognizer:St,Tap:Zn,Pan:Kn,Swipe:Zi,Pinch:qi,Rotate:Ki,Press:Gi,on:D,off:P,each:m,merge:w,extend:v,assign:x,inherit:k,bindFn:E,prefixed:nt});var tu=typeof t<"u"?t:typeof self<"u"?self:{};tu.Hammer=Zt,e.exports?e.exports=Zt:t[i]=Zt})(window,document,"Hammer")})(us)),us.exports}var cm=lm();const Pn=am(cm);/*!
9301
+ \`;return function(){var S=new Error("get-stack-trace"),M=S&&S.stack?S.stack.replace(/^[^\\(]+?[\\n$]/gm,"").replace(/^\\s+at\\s+/gm,"").replace(/^Object.<anonymous>\\s*\\(/gm,"{anonymous}()@"):"Unknown Stack Trace",N=t.console&&(t.console.warn||t.console.log);return N&&N.call(t.console,_,M),h.apply(this,arguments)}}var x;typeof Object.assign!="function"?x=function(p){if(p===s||p===null)throw new TypeError("Cannot convert undefined or null to object");for(var b=Object(p),_=1;_<arguments.length;_++){var S=arguments[_];if(S!==s&&S!==null)for(var M in S)S.hasOwnProperty(M)&&(b[M]=S[M])}return b}:x=Object.assign;var v=y(function(p,b,_){for(var S=Object.keys(b),M=0;M<S.length;)(!_||_&&p[S[M]]===s)&&(p[S[M]]=b[S[M]]),M++;return p},"extend","Use \`assign\`."),w=y(function(p,b){return v(p,b,!0)},"merge","Use \`assign\`.");function k(h,p,b){var _=p.prototype,S;S=h.prototype=Object.create(_),S.constructor=h,S._super=_,b&&x(S,b)}function E(h,p){return function(){return h.apply(p,arguments)}}function C(h,p){return typeof h==a?h.apply(p&&p[0]||s,p):h}function T(h,p){return h===s?p:h}function D(h,p,b){m(z(p),function(_){h.addEventListener(_,b,!1)})}function P(h,p,b){m(z(p),function(_){h.removeEventListener(_,b,!1)})}function O(h,p){for(;h;){if(h==p)return!0;h=h.parentNode}return!1}function A(h,p){return h.indexOf(p)>-1}function z(h){return h.trim().split(/\\s+/g)}function L(h,p,b){if(h.indexOf&&!b)return h.indexOf(p);for(var _=0;_<h.length;){if(b&&h[_][b]==p||!b&&h[_]===p)return _;_++}return-1}function H(h){return Array.prototype.slice.call(h,0)}function Z(h,p,b){for(var _=[],S=[],M=0;M<h.length;){var N=h[M][p];L(S,N)<0&&_.push(h[M]),S[M]=N,M++}return _=_.sort(function(Q,ot){return Q[p]>ot[p]}),_}function nt(h,p){for(var b,_,S=p[0].toUpperCase()+p.slice(1),M=0;M<o.length;){if(b=o[M],_=b?b+S:p,_ in h)return _;M++}return s}var j=1;function q(){return j++}function it(h){var p=h.ownerDocument||h;return p.defaultView||p.parentWindow||t}var We=/mobile|tablet|ip(ad|hone|od)|android/i,be="ontouchstart"in t,Gt=nt(t,"PointerEvent")!==s,je=be&&We.test(navigator.userAgent),dt="touch",xe="pen",wt="mouse",ye="kinect",Vt=25,st=1,ve=2,X=4,at=8,Bn=1,ln=2,cn=4,un=8,hn=16,Et=ln|cn,_e=un|hn,Po=Et|_e,Do=["x","y"],Wn=["clientX","clientY"];function pt(h,p){var b=this;this.manager=h,this.callback=p,this.element=h.element,this.target=h.options.inputTarget,this.domHandler=function(_){C(h.options.enable,[h])&&b.handler(_)},this.init()}pt.prototype={handler:function(){},init:function(){this.evEl&&D(this.element,this.evEl,this.domHandler),this.evTarget&&D(this.target,this.evTarget,this.domHandler),this.evWin&&D(it(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&P(this.element,this.evEl,this.domHandler),this.evTarget&&P(this.target,this.evTarget,this.domHandler),this.evWin&&P(it(this.element),this.evWin,this.domHandler)}};function Pc(h){var p,b=h.options.inputClass;return b?p=b:Gt?p=$i:je?p=Un:be?p=Ui:p=$n,new p(h,Dc)}function Dc(h,p,b){var _=b.pointers.length,S=b.changedPointers.length,M=p&st&&_-S===0,N=p&(X|at)&&_-S===0;b.isFirst=!!M,b.isFinal=!!N,M&&(h.session={}),b.eventType=p,Ac(h,b),h.emit("hammer.input",b),h.recognize(b),h.session.prevInput=b}function Ac(h,p){var b=h.session,_=p.pointers,S=_.length;b.firstInput||(b.firstInput=Ao(p)),S>1&&!b.firstMultiple?b.firstMultiple=Ao(p):S===1&&(b.firstMultiple=!1);var M=b.firstInput,N=b.firstMultiple,K=N?N.center:M.center,Q=p.center=Io(_);p.timeStamp=u(),p.deltaTime=p.timeStamp-M.timeStamp,p.angle=ji(K,Q),p.distance=jn(K,Q),Ic(b,p),p.offsetDirection=Ro(p.deltaX,p.deltaY);var ot=Lo(p.deltaTime,p.deltaX,p.deltaY);p.overallVelocityX=ot.x,p.overallVelocityY=ot.y,p.overallVelocity=c(ot.x)>c(ot.y)?ot.x:ot.y,p.scale=N?Nc(N.pointers,_):1,p.rotation=N?Rc(N.pointers,_):0,p.maxPointers=b.prevInput?p.pointers.length>b.prevInput.maxPointers?p.pointers.length:b.prevInput.maxPointers:p.pointers.length,Lc(b,p);var Ot=h.element;O(p.srcEvent.target,Ot)&&(Ot=p.srcEvent.target),p.target=Ot}function Ic(h,p){var b=p.center,_=h.offsetDelta||{},S=h.prevDelta||{},M=h.prevInput||{};(p.eventType===st||M.eventType===X)&&(S=h.prevDelta={x:M.deltaX||0,y:M.deltaY||0},_=h.offsetDelta={x:b.x,y:b.y}),p.deltaX=S.x+(b.x-_.x),p.deltaY=S.y+(b.y-_.y)}function Lc(h,p){var b=h.lastInterval||p,_=p.timeStamp-b.timeStamp,S,M,N,K;if(p.eventType!=at&&(_>Vt||b.velocity===s)){var Q=p.deltaX-b.deltaX,ot=p.deltaY-b.deltaY,Ot=Lo(_,Q,ot);M=Ot.x,N=Ot.y,S=c(Ot.x)>c(Ot.y)?Ot.x:Ot.y,K=Ro(Q,ot),h.lastInterval=p}else S=b.velocity,M=b.velocityX,N=b.velocityY,K=b.direction;p.velocity=S,p.velocityX=M,p.velocityY=N,p.direction=K}function Ao(h){for(var p=[],b=0;b<h.pointers.length;)p[b]={clientX:l(h.pointers[b].clientX),clientY:l(h.pointers[b].clientY)},b++;return{timeStamp:u(),pointers:p,center:Io(p),deltaX:h.deltaX,deltaY:h.deltaY}}function Io(h){var p=h.length;if(p===1)return{x:l(h[0].clientX),y:l(h[0].clientY)};for(var b=0,_=0,S=0;S<p;)b+=h[S].clientX,_+=h[S].clientY,S++;return{x:l(b/p),y:l(_/p)}}function Lo(h,p,b){return{x:p/h||0,y:b/h||0}}function Ro(h,p){return h===p?Bn:c(h)>=c(p)?h<0?ln:cn:p<0?un:hn}function jn(h,p,b){b||(b=Do);var _=p[b[0]]-h[b[0]],S=p[b[1]]-h[b[1]];return Math.sqrt(_*_+S*S)}function ji(h,p,b){b||(b=Do);var _=p[b[0]]-h[b[0]],S=p[b[1]]-h[b[1]];return Math.atan2(S,_)*180/Math.PI}function Rc(h,p){return ji(p[1],p[0],Wn)+ji(h[1],h[0],Wn)}function Nc(h,p){return jn(p[0],p[1],Wn)/jn(h[0],h[1],Wn)}var Fc={mousedown:st,mousemove:ve,mouseup:X},zc="mousedown",Hc="mousemove mouseup";function $n(){this.evEl=zc,this.evWin=Hc,this.pressed=!1,pt.apply(this,arguments)}k($n,pt,{handler:function(p){var b=Fc[p.type];b&st&&p.button===0&&(this.pressed=!0),b&ve&&p.which!==1&&(b=X),this.pressed&&(b&X&&(this.pressed=!1),this.callback(this.manager,b,{pointers:[p],changedPointers:[p],pointerType:wt,srcEvent:p}))}});var Vc={pointerdown:st,pointermove:ve,pointerup:X,pointercancel:at,pointerout:at},Bc={2:dt,3:xe,4:wt,5:ye},No="pointerdown",Fo="pointermove pointerup pointercancel";t.MSPointerEvent&&!t.PointerEvent&&(No="MSPointerDown",Fo="MSPointerMove MSPointerUp MSPointerCancel");function $i(){this.evEl=No,this.evWin=Fo,pt.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}k($i,pt,{handler:function(p){var b=this.store,_=!1,S=p.type.toLowerCase().replace("ms",""),M=Vc[S],N=Bc[p.pointerType]||p.pointerType,K=N==dt,Q=L(b,p.pointerId,"pointerId");M&st&&(p.button===0||K)?Q<0&&(b.push(p),Q=b.length-1):M&(X|at)&&(_=!0),!(Q<0)&&(b[Q]=p,this.callback(this.manager,M,{pointers:b,changedPointers:[p],pointerType:N,srcEvent:p}),_&&b.splice(Q,1))}});var Wc={touchstart:st,touchmove:ve,touchend:X,touchcancel:at},jc="touchstart",$c="touchstart touchmove touchend touchcancel";function zo(){this.evTarget=jc,this.evWin=$c,this.started=!1,pt.apply(this,arguments)}k(zo,pt,{handler:function(p){var b=Wc[p.type];if(b===st&&(this.started=!0),!!this.started){var _=Uc.call(this,p,b);b&(X|at)&&_[0].length-_[1].length===0&&(this.started=!1),this.callback(this.manager,b,{pointers:_[0],changedPointers:_[1],pointerType:dt,srcEvent:p})}}});function Uc(h,p){var b=H(h.touches),_=H(h.changedTouches);return p&(X|at)&&(b=Z(b.concat(_),"identifier")),[b,_]}var Yc={touchstart:st,touchmove:ve,touchend:X,touchcancel:at},Xc="touchstart touchmove touchend touchcancel";function Un(){this.evTarget=Xc,this.targetIds={},pt.apply(this,arguments)}k(Un,pt,{handler:function(p){var b=Yc[p.type],_=qc.call(this,p,b);_&&this.callback(this.manager,b,{pointers:_[0],changedPointers:_[1],pointerType:dt,srcEvent:p})}});function qc(h,p){var b=H(h.touches),_=this.targetIds;if(p&(st|ve)&&b.length===1)return _[b[0].identifier]=!0,[b,b];var S,M,N=H(h.changedTouches),K=[],Q=this.target;if(M=b.filter(function(ot){return O(ot.target,Q)}),p===st)for(S=0;S<M.length;)_[M[S].identifier]=!0,S++;for(S=0;S<N.length;)_[N[S].identifier]&&K.push(N[S]),p&(X|at)&&delete _[N[S].identifier],S++;if(K.length)return[Z(M.concat(K),"identifier"),K]}var Gc=2500,Ho=25;function Ui(){pt.apply(this,arguments);var h=E(this.handler,this);this.touch=new Un(this.manager,h),this.mouse=new $n(this.manager,h),this.primaryTouch=null,this.lastTouches=[]}k(Ui,pt,{handler:function(p,b,_){var S=_.pointerType==dt,M=_.pointerType==wt;if(!(M&&_.sourceCapabilities&&_.sourceCapabilities.firesTouchEvents)){if(S)Kc.call(this,b,_);else if(M&&Zc.call(this,_))return;this.callback(p,b,_)}},destroy:function(){this.touch.destroy(),this.mouse.destroy()}});function Kc(h,p){h&st?(this.primaryTouch=p.changedPointers[0].identifier,Vo.call(this,p)):h&(X|at)&&Vo.call(this,p)}function Vo(h){var p=h.changedPointers[0];if(p.identifier===this.primaryTouch){var b={x:p.clientX,y:p.clientY};this.lastTouches.push(b);var _=this.lastTouches,S=function(){var M=_.indexOf(b);M>-1&&_.splice(M,1)};setTimeout(S,Gc)}}function Zc(h){for(var p=h.srcEvent.clientX,b=h.srcEvent.clientY,_=0;_<this.lastTouches.length;_++){var S=this.lastTouches[_],M=Math.abs(p-S.x),N=Math.abs(b-S.y);if(M<=Ho&&N<=Ho)return!0}return!1}var Bo=nt(r.style,"touchAction"),Wo=Bo!==s,jo="compute",$o="auto",Yi="manipulation",we="none",fn="pan-x",dn="pan-y",Yn=Jc();function Xi(h,p){this.manager=h,this.set(p)}Xi.prototype={set:function(h){h==jo&&(h=this.compute()),Wo&&this.manager.element.style&&Yn[h]&&(this.manager.element.style[Bo]=h),this.actions=h.toLowerCase().trim()},update:function(){this.set(this.manager.options.touchAction)},compute:function(){var h=[];return m(this.manager.recognizers,function(p){C(p.options.enable,[p])&&(h=h.concat(p.getTouchAction()))}),Qc(h.join(" "))},preventDefaults:function(h){var p=h.srcEvent,b=h.offsetDirection;if(this.manager.session.prevented){p.preventDefault();return}var _=this.actions,S=A(_,we)&&!Yn[we],M=A(_,dn)&&!Yn[dn],N=A(_,fn)&&!Yn[fn];if(S){var K=h.pointers.length===1,Q=h.distance<2,ot=h.deltaTime<250;if(K&&Q&&ot)return}if(!(N&&M)&&(S||M&&b&Et||N&&b&_e))return this.preventSrc(p)},preventSrc:function(h){this.manager.session.prevented=!0,h.preventDefault()}};function Qc(h){if(A(h,we))return we;var p=A(h,fn),b=A(h,dn);return p&&b?we:p||b?p?fn:dn:A(h,Yi)?Yi:$o}function Jc(){if(!Wo)return!1;var h={},p=t.CSS&&t.CSS.supports;return["auto","manipulation","pan-y","pan-x","pan-x pan-y","none"].forEach(function(b){h[b]=p?t.CSS.supports("touch-action",b):!0}),h}var Xn=1,gt=2,$e=4,Kt=8,Bt=Kt,pn=16,Ct=32;function Wt(h){this.options=x({},this.defaults,h||{}),this.id=q(),this.manager=null,this.options.enable=T(this.options.enable,!0),this.state=Xn,this.simultaneous={},this.requireFail=[]}Wt.prototype={defaults:{},set:function(h){return x(this.options,h),this.manager&&this.manager.touchAction.update(),this},recognizeWith:function(h){if(d(h,"recognizeWith",this))return this;var p=this.simultaneous;return h=qn(h,this),p[h.id]||(p[h.id]=h,h.recognizeWith(this)),this},dropRecognizeWith:function(h){return d(h,"dropRecognizeWith",this)?this:(h=qn(h,this),delete this.simultaneous[h.id],this)},requireFailure:function(h){if(d(h,"requireFailure",this))return this;var p=this.requireFail;return h=qn(h,this),L(p,h)===-1&&(p.push(h),h.requireFailure(this)),this},dropRequireFailure:function(h){if(d(h,"dropRequireFailure",this))return this;h=qn(h,this);var p=L(this.requireFail,h);return p>-1&&this.requireFail.splice(p,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(h){return!!this.simultaneous[h.id]},emit:function(h){var p=this,b=this.state;function _(S){p.manager.emit(S,h)}b<Kt&&_(p.options.event+Uo(b)),_(p.options.event),h.additionalEvent&&_(h.additionalEvent),b>=Kt&&_(p.options.event+Uo(b))},tryEmit:function(h){if(this.canEmit())return this.emit(h);this.state=Ct},canEmit:function(){for(var h=0;h<this.requireFail.length;){if(!(this.requireFail[h].state&(Ct|Xn)))return!1;h++}return!0},recognize:function(h){var p=x({},h);if(!C(this.options.enable,[this,p])){this.reset(),this.state=Ct;return}this.state&(Bt|pn|Ct)&&(this.state=Xn),this.state=this.process(p),this.state&(gt|$e|Kt|pn)&&this.tryEmit(p)},process:function(h){},getTouchAction:function(){},reset:function(){}};function Uo(h){return h&pn?"cancel":h&Kt?"end":h&$e?"move":h&gt?"start":""}function Yo(h){return h==hn?"down":h==un?"up":h==ln?"left":h==cn?"right":""}function qn(h,p){var b=p.manager;return b?b.get(h):h}function St(){Wt.apply(this,arguments)}k(St,Wt,{defaults:{pointers:1},attrTest:function(h){var p=this.options.pointers;return p===0||h.pointers.length===p},process:function(h){var p=this.state,b=h.eventType,_=p&(gt|$e),S=this.attrTest(h);return _&&(b&at||!S)?p|pn:_||S?b&X?p|Kt:p&gt?p|$e:gt:Ct}});function Gn(){St.apply(this,arguments),this.pX=null,this.pY=null}k(Gn,St,{defaults:{event:"pan",threshold:10,pointers:1,direction:Po},getTouchAction:function(){var h=this.options.direction,p=[];return h&Et&&p.push(dn),h&_e&&p.push(fn),p},directionTest:function(h){var p=this.options,b=!0,_=h.distance,S=h.direction,M=h.deltaX,N=h.deltaY;return S&p.direction||(p.direction&Et?(S=M===0?Bn:M<0?ln:cn,b=M!=this.pX,_=Math.abs(h.deltaX)):(S=N===0?Bn:N<0?un:hn,b=N!=this.pY,_=Math.abs(h.deltaY))),h.direction=S,b&&_>p.threshold&&S&p.direction},attrTest:function(h){return St.prototype.attrTest.call(this,h)&&(this.state&gt||!(this.state&gt)&&this.directionTest(h))},emit:function(h){this.pX=h.deltaX,this.pY=h.deltaY;var p=Yo(h.direction);p&&(h.additionalEvent=this.options.event+p),this._super.emit.call(this,h)}});function qi(){St.apply(this,arguments)}k(qi,St,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[we]},attrTest:function(h){return this._super.attrTest.call(this,h)&&(Math.abs(h.scale-1)>this.options.threshold||this.state&gt)},emit:function(h){if(h.scale!==1){var p=h.scale<1?"in":"out";h.additionalEvent=this.options.event+p}this._super.emit.call(this,h)}});function Gi(){Wt.apply(this,arguments),this._timer=null,this._input=null}k(Gi,Wt,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[$o]},process:function(h){var p=this.options,b=h.pointers.length===p.pointers,_=h.distance<p.threshold,S=h.deltaTime>p.time;if(this._input=h,!_||!b||h.eventType&(X|at)&&!S)this.reset();else if(h.eventType&st)this.reset(),this._timer=f(function(){this.state=Bt,this.tryEmit()},p.time,this);else if(h.eventType&X)return Bt;return Ct},reset:function(){clearTimeout(this._timer)},emit:function(h){this.state===Bt&&(h&&h.eventType&X?this.manager.emit(this.options.event+"up",h):(this._input.timeStamp=u(),this.manager.emit(this.options.event,this._input)))}});function Ki(){St.apply(this,arguments)}k(Ki,St,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[we]},attrTest:function(h){return this._super.attrTest.call(this,h)&&(Math.abs(h.rotation)>this.options.threshold||this.state&gt)}});function Zi(){St.apply(this,arguments)}k(Zi,St,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:Et|_e,pointers:1},getTouchAction:function(){return Gn.prototype.getTouchAction.call(this)},attrTest:function(h){var p=this.options.direction,b;return p&(Et|_e)?b=h.overallVelocity:p&Et?b=h.overallVelocityX:p&_e&&(b=h.overallVelocityY),this._super.attrTest.call(this,h)&&p&h.offsetDirection&&h.distance>this.options.threshold&&h.maxPointers==this.options.pointers&&c(b)>this.options.velocity&&h.eventType&X},emit:function(h){var p=Yo(h.offsetDirection);p&&this.manager.emit(this.options.event+p,h),this.manager.emit(this.options.event,h)}});function Kn(){Wt.apply(this,arguments),this.pTime=!1,this.pCenter=!1,this._timer=null,this._input=null,this.count=0}k(Kn,Wt,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[Yi]},process:function(h){var p=this.options,b=h.pointers.length===p.pointers,_=h.distance<p.threshold,S=h.deltaTime<p.time;if(this.reset(),h.eventType&st&&this.count===0)return this.failTimeout();if(_&&S&&b){if(h.eventType!=X)return this.failTimeout();var M=this.pTime?h.timeStamp-this.pTime<p.interval:!0,N=!this.pCenter||jn(this.pCenter,h.center)<p.posThreshold;this.pTime=h.timeStamp,this.pCenter=h.center,!N||!M?this.count=1:this.count+=1,this._input=h;var K=this.count%p.taps;if(K===0)return this.hasRequireFailures()?(this._timer=f(function(){this.state=Bt,this.tryEmit()},p.interval,this),gt):Bt}return Ct},failTimeout:function(){return this._timer=f(function(){this.state=Ct},this.options.interval,this),Ct},reset:function(){clearTimeout(this._timer)},emit:function(){this.state==Bt&&(this._input.tapCount=this.count,this.manager.emit(this.options.event,this._input))}});function Zt(h,p){return p=p||{},p.recognizers=T(p.recognizers,Zt.defaults.preset),new Qi(h,p)}Zt.VERSION="2.0.7",Zt.defaults={domEvents:!1,touchAction:jo,enable:!0,inputTarget:null,inputClass:null,preset:[[Ki,{enable:!1}],[qi,{enable:!1},["rotate"]],[Zi,{direction:Et}],[Gn,{direction:Et},["swipe"]],[Kn],[Kn,{event:"doubletap",taps:2},["tap"]],[Gi]],cssProps:{userSelect:"none",touchSelect:"none",touchCallout:"none",contentZooming:"none",userDrag:"none",tapHighlightColor:"rgba(0,0,0,0)"}};var tu=1,Xo=2;function Qi(h,p){this.options=x({},Zt.defaults,p||{}),this.options.inputTarget=this.options.inputTarget||h,this.handlers={},this.session={},this.recognizers=[],this.oldCssProps={},this.element=h,this.input=Pc(this),this.touchAction=new Xi(this,this.options.touchAction),qo(this,!0),m(this.options.recognizers,function(b){var _=this.add(new b[0](b[1]));b[2]&&_.recognizeWith(b[2]),b[3]&&_.requireFailure(b[3])},this)}Qi.prototype={set:function(h){return x(this.options,h),h.touchAction&&this.touchAction.update(),h.inputTarget&&(this.input.destroy(),this.input.target=h.inputTarget,this.input.init()),this},stop:function(h){this.session.stopped=h?Xo:tu},recognize:function(h){var p=this.session;if(!p.stopped){this.touchAction.preventDefaults(h);var b,_=this.recognizers,S=p.curRecognizer;(!S||S&&S.state&Bt)&&(S=p.curRecognizer=null);for(var M=0;M<_.length;)b=_[M],p.stopped!==Xo&&(!S||b==S||b.canRecognizeWith(S))?b.recognize(h):b.reset(),!S&&b.state&(gt|$e|Kt)&&(S=p.curRecognizer=b),M++}},get:function(h){if(h instanceof Wt)return h;for(var p=this.recognizers,b=0;b<p.length;b++)if(p[b].options.event==h)return p[b];return null},add:function(h){if(d(h,"add",this))return this;var p=this.get(h.options.event);return p&&this.remove(p),this.recognizers.push(h),h.manager=this,this.touchAction.update(),h},remove:function(h){if(d(h,"remove",this))return this;if(h=this.get(h),h){var p=this.recognizers,b=L(p,h);b!==-1&&(p.splice(b,1),this.touchAction.update())}return this},on:function(h,p){if(h!==s&&p!==s){var b=this.handlers;return m(z(h),function(_){b[_]=b[_]||[],b[_].push(p)}),this}},off:function(h,p){if(h!==s){var b=this.handlers;return m(z(h),function(_){p?b[_]&&b[_].splice(L(b[_],p),1):delete b[_]}),this}},emit:function(h,p){this.options.domEvents&&eu(h,p);var b=this.handlers[h]&&this.handlers[h].slice();if(!(!b||!b.length)){p.type=h,p.preventDefault=function(){p.srcEvent.preventDefault()};for(var _=0;_<b.length;)b[_](p),_++}},destroy:function(){this.element&&qo(this,!1),this.handlers={},this.session={},this.input.destroy(),this.element=null}};function qo(h,p){var b=h.element;if(b.style){var _;m(h.options.cssProps,function(S,M){_=nt(b.style,M),p?(h.oldCssProps[_]=b.style[_],b.style[_]=S):b.style[_]=h.oldCssProps[_]||""}),p||(h.oldCssProps={})}}function eu(h,p){var b=n.createEvent("Event");b.initEvent(h,!0,!0),b.gesture=p,p.target.dispatchEvent(b)}x(Zt,{INPUT_START:st,INPUT_MOVE:ve,INPUT_END:X,INPUT_CANCEL:at,STATE_POSSIBLE:Xn,STATE_BEGAN:gt,STATE_CHANGED:$e,STATE_ENDED:Kt,STATE_RECOGNIZED:Bt,STATE_CANCELLED:pn,STATE_FAILED:Ct,DIRECTION_NONE:Bn,DIRECTION_LEFT:ln,DIRECTION_RIGHT:cn,DIRECTION_UP:un,DIRECTION_DOWN:hn,DIRECTION_HORIZONTAL:Et,DIRECTION_VERTICAL:_e,DIRECTION_ALL:Po,Manager:Qi,Input:pt,TouchAction:Xi,TouchInput:Un,MouseInput:$n,PointerEventInput:$i,TouchMouseInput:Ui,SingleTouchInput:zo,Recognizer:Wt,AttrRecognizer:St,Tap:Kn,Pan:Gn,Swipe:Zi,Pinch:qi,Rotate:Ki,Press:Gi,on:D,off:P,each:m,merge:w,extend:v,assign:x,inherit:k,bindFn:E,prefixed:nt});var nu=typeof t<"u"?t:typeof self<"u"?self:{};nu.Hammer=Zt,e.exports?e.exports=Zt:t[i]=Zt})(window,document,"Hammer")})(us)),us.exports}var um=cm();const Pn=lm(um);/*!
9149
9302
  * chartjs-plugin-zoom v2.2.0
9150
9303
  * https://www.chartjs.org/chartjs-plugin-zoom/2.2.0/
9151
9304
  * (c) 2016-2024 chartjs-plugin-zoom Contributors
9152
9305
  * Released under the MIT License
9153
- */const Fn=e=>e&&e.enabled&&e.modifierKey,hc=(e,t)=>e&&t[e+"Key"],Co=(e,t)=>e&&!t[e+"Key"];function fe(e,t,n){return e===void 0?!0:typeof e=="string"?e.indexOf(t)!==-1:typeof e=="function"?e({chart:n}).indexOf(t)!==-1:!1}function hs(e,t){return typeof e=="function"&&(e=e({chart:t})),typeof e=="string"?{x:e.indexOf("x")!==-1,y:e.indexOf("y")!==-1}:{x:!1,y:!1}}function um(e,t){let n;return function(){return clearTimeout(n),n=setTimeout(e,t),t}}function hm({x:e,y:t},n){const i=n.scales,s=Object.keys(i);for(let o=0;o<s.length;o++){const r=i[s[o]];if(t>=r.top&&t<=r.bottom&&e>=r.left&&e<=r.right)return r}return null}function fc(e,t,n){const{mode:i="xy",scaleMode:s,overScaleMode:o}=e||{},r=hm(t,n),a=hs(i,n),l=hs(s,n);if(o){const u=hs(o,n);for(const f of["x","y"])u[f]&&(l[f]=a[f],a[f]=!1)}if(r&&l[r.axis])return[r];const c=[];return F(n.scales,function(u){a[u.axis]&&c.push(u)}),c}const Ys=new WeakMap;function $(e){let t=Ys.get(e);return t||(t={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{},dragging:!1,panning:!1},Ys.set(e,t)),t}function fm(e){Ys.delete(e)}function dc(e,t,n,i){const s=Math.max(0,Math.min(1,(e-t)/n||0)),o=1-s;return{min:i*s,max:i*o}}function pc(e,t){const n=e.isHorizontal()?t.x:t.y;return e.getValueForPixel(n)}function gc(e,t,n){const i=e.max-e.min,s=i*(t-1),o=pc(e,n);return dc(o,e.min,i,s)}function dm(e,t,n){const i=pc(e,n);if(i===void 0)return{min:e.min,max:e.max};const s=Math.log10(e.min),o=Math.log10(e.max),r=Math.log10(i),a=o-s,l=a*(t-1),c=dc(r,s,a,l);return{min:Math.pow(10,s+c.min),max:Math.pow(10,o-c.max)}}function pm(e,t){return t&&(t[e.id]||t[e.axis])||{}}function va(e,t,n,i,s){let o=n[i];if(o==="original"){const r=e.originalScaleLimits[t.id][i];o=R(r.options,r.scale)}return R(o,s)}function gm(e,t,n){const i=e.getValueForPixel(t),s=e.getValueForPixel(n);return{min:Math.min(i,s),max:Math.max(i,s)}}function mm(e,{min:t,max:n,minLimit:i,maxLimit:s},o){const r=(e-n+t)/2;t-=r,n+=r;const a=o.min.options??o.min.scale,l=o.max.options??o.max.scale,c=e/1e6;return Ie(t,a,c)&&(t=a),Ie(n,l,c)&&(n=l),t<i?(t=i,n=Math.min(i+e,s)):n>s&&(n=s,t=Math.max(s-e,i)),{min:t,max:n}}function Be(e,{min:t,max:n},i,s=!1){const o=$(e.chart),{options:r}=e,a=pm(e,i),{minRange:l=0}=a,c=va(o,e,a,"min",-1/0),u=va(o,e,a,"max",1/0);if(s==="pan"&&(t<c||n>u))return!0;const f=e.max-e.min,d=s?Math.max(n-t,l):f;if(s&&d===l&&f<=l)return!0;const m=mm(d,{min:t,max:n,minLimit:c,maxLimit:u},o.originalScaleLimits[e.id]);return r.min=m.min,r.max=m.max,o.updatedScaleLimits[e.id]=m,e.parse(m.min)!==e.min||e.parse(m.max)!==e.max}function bm(e,t,n,i){const s=gc(e,t,n),o={min:e.min+s.min,max:e.max-s.max};return Be(e,o,i,!0)}function xm(e,t,n,i){const s=dm(e,t,n);return Be(e,s,i,!0)}function ym(e,t,n,i){Be(e,gm(e,t,n),i,!0)}const _a=e=>e===0||isNaN(e)?0:e<0?Math.min(Math.round(e),-1):Math.max(Math.round(e),1);function vm(e){const n=e.getLabels().length-1;e.min>0&&(e.min-=1),e.max<n&&(e.max+=1)}function _m(e,t,n,i){const s=gc(e,t,n);e.min===e.max&&t<1&&vm(e);const o={min:e.min+_a(s.min),max:e.max-_a(s.max)};return Be(e,o,i,!0)}function wm(e){return e.isHorizontal()?e.width:e.height}function Sm(e,t,n){const s=e.getLabels().length-1;let{min:o,max:r}=e;const a=Math.max(r-o,1),l=Math.round(wm(e)/Math.max(a,10)),c=Math.round(Math.abs(t/l));let u;return t<-l?(r=Math.min(r+c,s),o=a===1?r:r-a,u=r===s):t>l&&(o=Math.max(0,o-c),r=a===1?o:o+a,u=o===0),Be(e,{min:o,max:r},n)||u}const km={second:500,minute:30*1e3,hour:1800*1e3,day:720*60*1e3,week:3.5*24*60*60*1e3,month:360*60*60*1e3,quarter:1440*60*60*1e3,year:4368*60*60*1e3};function mc(e,t,n,i=!1){const{min:s,max:o,options:r}=e,a=r.time&&r.time.round,l=km[a]||0,c=e.getValueForPixel(e.getPixelForValue(s+l)-t),u=e.getValueForPixel(e.getPixelForValue(o+l)-t);return isNaN(c)||isNaN(u)?!0:Be(e,{min:c,max:u},n,i?"pan":!1)}function wa(e,t,n){return mc(e,t,n,!0)}const Xs={category:_m,default:bm,logarithmic:xm},qs={default:ym},Gs={category:Sm,default:mc,logarithmic:wa,timeseries:wa};function Tm(e,t,n){const{id:i,options:{min:s,max:o}}=e;if(!t[i]||!n[i])return!0;const r=n[i];return r.min!==s||r.max!==o}function Sa(e,t){F(e,(n,i)=>{t[i]||delete e[i]})}function an(e,t){const{scales:n}=e,{originalScaleLimits:i,updatedScaleLimits:s}=t;return F(n,function(o){Tm(o,i,s)&&(i[o.id]={min:{scale:o.min,options:o.options.min},max:{scale:o.max,options:o.options.max}})}),Sa(i,n),Sa(s,n),i}function ka(e,t,n,i){const s=Xs[e.type]||Xs.default;I(s,[e,t,n,i])}function Ta(e,t,n,i){const s=qs[e.type]||qs.default;I(s,[e,t,n,i])}function Mm(e){const t=e.chartArea;return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}}function Oo(e,t,n="none",i="api"){const{x:s=1,y:o=1,focalPoint:r=Mm(e)}=typeof t=="number"?{x:t,y:t}:t,a=$(e),{options:{limits:l,zoom:c}}=a;an(e,a);const u=s!==1,f=o!==1,d=fc(c,r,e);F(d||e.scales,function(m){m.isHorizontal()&&u?ka(m,s,r,l):!m.isHorizontal()&&f&&ka(m,o,r,l)}),e.update(n),I(c.onZoom,[{chart:e,trigger:i}])}function bc(e,t,n,i="none",s="api"){const o=$(e),{options:{limits:r,zoom:a}}=o,{mode:l="xy"}=a;an(e,o);const c=fe(l,"x",e),u=fe(l,"y",e);F(e.scales,function(f){f.isHorizontal()&&c?Ta(f,t.x,n.x,r):!f.isHorizontal()&&u&&Ta(f,t.y,n.y,r)}),e.update(i),I(a.onZoom,[{chart:e,trigger:s}])}function Em(e,t,n,i="none",s="api"){const o=$(e);an(e,o);const r=e.scales[t];Be(r,n,void 0,!0),e.update(i),I(o.options.zoom?.onZoom,[{chart:e,trigger:s}])}function Cm(e,t="default"){const n=$(e),i=an(e,n);F(e.scales,function(s){const o=s.options;i[s.id]?(o.min=i[s.id].min.options,o.max=i[s.id].max.options):(delete o.min,delete o.max),delete n.updatedScaleLimits[s.id]}),e.update(t),I(n.options.zoom.onZoomComplete,[{chart:e}])}function Om(e,t){const n=e.originalScaleLimits[t];if(!n)return;const{min:i,max:s}=n;return R(s.options,s.scale)-R(i.options,i.scale)}function Pm(e){const t=$(e);let n=1,i=1;return F(e.scales,function(s){const o=Om(t,s.id);if(o){const r=Math.round(o/(s.max-s.min)*100)/100;n=Math.min(n,r),i=Math.max(i,r)}}),n<1?n:i}function Ma(e,t,n,i){const{panDelta:s}=i,o=s[e.id]||0;he(o)===he(t)&&(t+=o);const r=Gs[e.type]||Gs.default;I(r,[e,t,n])?s[e.id]=0:s[e.id]=t}function xc(e,t,n,i="none"){const{x:s=0,y:o=0}=typeof t=="number"?{x:t,y:t}:t,r=$(e),{options:{pan:a,limits:l}}=r,{onPan:c}=a||{};an(e,r);const u=s!==0,f=o!==0;F(n||e.scales,function(d){d.isHorizontal()&&u?Ma(d,s,l,r):!d.isHorizontal()&&f&&Ma(d,o,l,r)}),e.update(i),I(c,[{chart:e}])}function yc(e){const t=$(e);an(e,t);const n={};for(const i of Object.keys(e.scales)){const{min:s,max:o}=t.originalScaleLimits[i]||{min:{},max:{}};n[i]={min:s.scale,max:o.scale}}return n}function Dm(e){const t=$(e),n={};for(const i of Object.keys(e.scales))n[i]=t.updatedScaleLimits[i];return n}function Am(e){const t=yc(e);for(const n of Object.keys(e.scales)){const{min:i,max:s}=t[n];if(i!==void 0&&e.scales[n].min!==i||s!==void 0&&e.scales[n].max!==s)return!0}return!1}function Ea(e){const t=$(e);return t.panning||t.dragging}const Ca=(e,t,n)=>Math.min(n,Math.max(t,e));function ct(e,t){const{handlers:n}=$(e),i=n[t];i&&i.target&&(i.target.removeEventListener(t,i),delete n[t])}function Dn(e,t,n,i){const{handlers:s,options:o}=$(e),r=s[n];if(r&&r.target===t)return;ct(e,n),s[n]=l=>i(e,l,o),s[n].target=t;const a=n==="wheel"?!1:void 0;t.addEventListener(n,s[n],{passive:a})}function Im(e,t){const n=$(e);n.dragStart&&(n.dragging=!0,n.dragEnd=t,e.update("none"))}function Lm(e,t){const n=$(e);!n.dragStart||t.key!=="Escape"||(ct(e,"keydown"),n.dragging=!1,n.dragStart=n.dragEnd=null,e.update("none"))}function Ks(e,t){if(e.target!==t.canvas){const n=t.canvas.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}return It(e,t)}function vc(e,t,n){const{onZoomStart:i,onZoomRejected:s}=n;if(i){const o=Ks(t,e);if(I(i,[{chart:e,event:t,point:o}])===!1)return I(s,[{chart:e,event:t}]),!1}}function Rm(e,t){if(e.legend){const o=It(t,e);if(en(o,e.legend))return}const n=$(e),{pan:i,zoom:s={}}=n.options;if(t.button!==0||hc(Fn(i),t)||Co(Fn(s.drag),t))return I(s.onZoomRejected,[{chart:e,event:t}]);vc(e,t,s)!==!1&&(n.dragStart=t,Dn(e,e.canvas.ownerDocument,"mousemove",Im),Dn(e,window.document,"keydown",Lm))}function Nm({begin:e,end:t},n){let i=t.x-e.x,s=t.y-e.y;const o=Math.abs(i/s);o>n?i=Math.sign(i)*Math.abs(s*n):o<n&&(s=Math.sign(s)*Math.abs(i/n)),t.x=e.x+i,t.y=e.y+s}function Oa(e,t,n,{min:i,max:s,prop:o}){e[i]=Ca(Math.min(n.begin[o],n.end[o]),t[i],t[s]),e[s]=Ca(Math.max(n.begin[o],n.end[o]),t[i],t[s])}function Fm(e,t,n){const i={begin:Ks(t.dragStart,e),end:Ks(t.dragEnd,e)};if(n){const s=e.chartArea.width/e.chartArea.height;Nm(i,s)}return i}function _c(e,t,n,i){const s=fe(t,"x",e),o=fe(t,"y",e),{top:r,left:a,right:l,bottom:c,width:u,height:f}=e.chartArea,d={top:r,left:a,right:l,bottom:c},m=Fm(e,n,i&&s&&o);s&&Oa(d,e.chartArea,m,{min:"left",max:"right",prop:"x"}),o&&Oa(d,e.chartArea,m,{min:"top",max:"bottom",prop:"y"});const y=d.right-d.left,x=d.bottom-d.top;return{...d,width:y,height:x,zoomX:s&&y?1+(u-y)/u:1,zoomY:o&&x?1+(f-x)/f:1}}function zm(e,t){const n=$(e);if(!n.dragStart)return;ct(e,"mousemove");const{mode:i,onZoomComplete:s,drag:{threshold:o=0,maintainAspectRatio:r}}=n.options.zoom,a=_c(e,i,{dragStart:n.dragStart,dragEnd:t},r),l=fe(i,"x",e)?a.width:0,c=fe(i,"y",e)?a.height:0,u=Math.sqrt(l*l+c*c);if(n.dragStart=n.dragEnd=null,u<=o){n.dragging=!1,e.update("none");return}bc(e,{x:a.left,y:a.top},{x:a.right,y:a.bottom},"zoom","drag"),n.dragging=!1,n.filterNextClick=!0,I(s,[{chart:e}])}function Hm(e,t,n){if(Co(Fn(n.wheel),t)){I(n.onZoomRejected,[{chart:e,event:t}]);return}if(vc(e,t,n)!==!1&&(t.cancelable&&t.preventDefault(),t.deltaY!==void 0))return!0}function Vm(e,t){const{handlers:{onZoomComplete:n},options:{zoom:i}}=$(e);if(!Hm(e,t,i))return;const s=t.target.getBoundingClientRect(),o=i.wheel.speed,r=t.deltaY>=0?2-1/(1-o):1+o,a={x:r,y:r,focalPoint:{x:t.clientX-s.left,y:t.clientY-s.top}};Oo(e,a,"zoom","wheel"),I(n,[{chart:e}])}function Bm(e,t,n,i){n&&($(e).handlers[t]=um(()=>I(n,[{chart:e}]),i))}function Wm(e,t){const n=e.canvas,{wheel:i,drag:s,onZoomComplete:o}=t.zoom;i.enabled?(Dn(e,n,"wheel",Vm),Bm(e,"onZoomComplete",o,250)):ct(e,"wheel"),s.enabled?(Dn(e,n,"mousedown",Rm),Dn(e,n.ownerDocument,"mouseup",zm)):(ct(e,"mousedown"),ct(e,"mousemove"),ct(e,"mouseup"),ct(e,"keydown"))}function jm(e){ct(e,"mousedown"),ct(e,"mousemove"),ct(e,"mouseup"),ct(e,"wheel"),ct(e,"click"),ct(e,"keydown")}function $m(e,t){return function(n,i){const{pan:s,zoom:o={}}=t.options;if(!s||!s.enabled)return!1;const r=i&&i.srcEvent;return r&&!t.panning&&i.pointerType==="mouse"&&(Co(Fn(s),r)||hc(Fn(o.drag),r))?(I(s.onPanRejected,[{chart:e,event:i}]),!1):!0}}function Um(e,t){const n=Math.abs(e.clientX-t.clientX),i=Math.abs(e.clientY-t.clientY),s=n/i;let o,r;return s>.3&&s<1.7?o=r=!0:n>i?o=!0:r=!0,{x:o,y:r}}function wc(e,t,n){if(t.scale){const{center:i,pointers:s}=n,o=1/t.scale*n.scale,r=n.target.getBoundingClientRect(),a=Um(s[0],s[1]),l=t.options.zoom.mode,c={x:a.x&&fe(l,"x",e)?o:1,y:a.y&&fe(l,"y",e)?o:1,focalPoint:{x:i.x-r.left,y:i.y-r.top}};Oo(e,c,"zoom","pinch"),t.scale=n.scale}}function Ym(e,t,n){if(t.options.zoom.pinch.enabled){const i=It(n,e);I(t.options.zoom.onZoomStart,[{chart:e,event:n,point:i}])===!1?(t.scale=null,I(t.options.zoom.onZoomRejected,[{chart:e,event:n}])):t.scale=1}}function Xm(e,t,n){t.scale&&(wc(e,t,n),t.scale=null,I(t.options.zoom.onZoomComplete,[{chart:e}]))}function Sc(e,t,n){const i=t.delta;i&&(t.panning=!0,xc(e,{x:n.deltaX-i.x,y:n.deltaY-i.y},t.panScales),t.delta={x:n.deltaX,y:n.deltaY})}function qm(e,t,n){const{enabled:i,onPanStart:s,onPanRejected:o}=t.options.pan;if(!i)return;const r=n.target.getBoundingClientRect(),a={x:n.center.x-r.left,y:n.center.y-r.top};if(I(s,[{chart:e,event:n,point:a}])===!1)return I(o,[{chart:e,event:n}]);t.panScales=fc(t.options.pan,a,e),t.delta={x:0,y:0},Sc(e,t,n)}function Gm(e,t){t.delta=null,t.panning&&(t.panning=!1,t.filterNextClick=!0,I(t.options.pan.onPanComplete,[{chart:e}]))}const Zs=new WeakMap;function Pa(e,t){const n=$(e),i=e.canvas,{pan:s,zoom:o}=t,r=new Pn.Manager(i);o&&o.pinch.enabled&&(r.add(new Pn.Pinch),r.on("pinchstart",a=>Ym(e,n,a)),r.on("pinch",a=>wc(e,n,a)),r.on("pinchend",a=>Xm(e,n,a))),s&&s.enabled&&(r.add(new Pn.Pan({threshold:s.threshold,enable:$m(e,n)})),r.on("panstart",a=>qm(e,n,a)),r.on("panmove",a=>Sc(e,n,a)),r.on("panend",()=>Gm(e,n))),Zs.set(e,r)}function Da(e){const t=Zs.get(e);t&&(t.remove("pinchstart"),t.remove("pinch"),t.remove("pinchend"),t.remove("panstart"),t.remove("pan"),t.remove("panend"),t.destroy(),Zs.delete(e))}function Km(e,t){const{pan:n,zoom:i}=e,{pan:s,zoom:o}=t;return i?.zoom?.pinch?.enabled!==o?.zoom?.pinch?.enabled||n?.enabled!==s?.enabled||n?.threshold!==s?.threshold}var Zm="2.2.0";function pi(e,t,n){const i=n.zoom.drag,{dragStart:s,dragEnd:o}=$(e);if(i.drawTime!==t||!o)return;const{left:r,top:a,width:l,height:c}=_c(e,n.zoom.mode,{dragStart:s,dragEnd:o},i.maintainAspectRatio),u=e.ctx;u.save(),u.beginPath(),u.fillStyle=i.backgroundColor||"rgba(225,225,225,0.3)",u.fillRect(r,a,l,c),i.borderWidth>0&&(u.lineWidth=i.borderWidth,u.strokeStyle=i.borderColor||"rgba(225,225,225)",u.strokeRect(r,a,l,c)),u.restore()}var Qm={id:"zoom",version:Zm,defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(e,t,n){const i=$(e);i.options=n,Object.prototype.hasOwnProperty.call(n.zoom,"enabled")&&console.warn("The option \`zoom.enabled\` is no longer supported. Please use \`zoom.wheel.enabled\`, \`zoom.drag.enabled\`, or \`zoom.pinch.enabled\`."),(Object.prototype.hasOwnProperty.call(n.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(n.pan,"overScaleMode"))&&console.warn("The option \`overScaleMode\` is deprecated. Please use \`scaleMode\` instead (and update \`mode\` as desired)."),Pn&&Pa(e,n),e.pan=(s,o,r)=>xc(e,s,o,r),e.zoom=(s,o)=>Oo(e,s,o),e.zoomRect=(s,o,r)=>bc(e,s,o,r),e.zoomScale=(s,o,r)=>Em(e,s,o,r),e.resetZoom=s=>Cm(e,s),e.getZoomLevel=()=>Pm(e),e.getInitialScaleBounds=()=>yc(e),e.getZoomedScaleBounds=()=>Dm(e),e.isZoomedOrPanned=()=>Am(e),e.isZoomingOrPanning=()=>Ea(e)},beforeEvent(e,{event:t}){if(Ea(e))return!1;if(t.type==="click"||t.type==="mouseup"){const n=$(e);if(n.filterNextClick)return n.filterNextClick=!1,!1}},beforeUpdate:function(e,t,n){const i=$(e),s=i.options;i.options=n,Km(s,n)&&(Da(e),Pa(e,n)),Wm(e,n)},beforeDatasetsDraw(e,t,n){pi(e,"beforeDatasetsDraw",n)},afterDatasetsDraw(e,t,n){pi(e,"afterDatasetsDraw",n)},beforeDraw(e,t,n){pi(e,"beforeDraw",n)},afterDraw(e,t,n){pi(e,"afterDraw",n)},stop:function(e){jm(e),Pn&&Da(e),fm(e)},panFunctions:Gs,zoomFunctions:Xs,zoomRectFunctions:qs};function Jm({data:e,...t}){const n=Ne(null),i=Ne(null);return rt(()=>{$s.register(Qm,im,mp,tm,Ng,Rg,Wg,Kg);const s=i.current,o=n.current=new $s(s,{type:"line",data:e.peek(),options:{scales:{y:{min:0}},animation:!1,responsive:!0,plugins:{zoom:{pan:{enabled:!0,mode:"x"},zoom:{wheel:{enabled:!0},mode:"x"}},legend:{position:"top"},title:{display:!1}}}}),r=e.subscribe(a=>{o.data=a,o.update()});return()=>{o.destroy(),r()}},[]),g("canvas",{ref:i,...t})}function tb(){const e=pe();rt(()=>{const n=i=>{An(i)||e()};return U?.on("mount",n),U?.on("unmount",n),()=>{U?.off("mount",n),U?.off("unmount",n)}},[]);const t=U?.profilingContext;return g("div",{className:"flex flex-col gap-2"},gl(t.appStats).filter(([n])=>!An(n)).map(([n])=>g(eb,{key:n.id,app:n})))}const Aa=100,Ia=e=>Object.entries(e).map(([t,{values:n,color:i}])=>({label:t,data:n,fill:!1,borderColor:i,tension:.1}));function eb({app:e}){const t=pe(),n=Ne({update:{values:[0],color:"#ad981f"},updateDirtied:{values:[0],color:"#b21f3a"},createNode:{values:[0],color:"#198019"},removeNode:{values:[0],color:"#5F3691"},updateNode:{values:[0],color:"#2f2f9d"},signalAttrUpdate:{values:[0],color:"#28888f"},signalTextUpdate:{values:[0],color:"#9b3b98"}}),i=J({labels:[(performance.now()/1e3).toFixed(2)],datasets:Ia(n.current)}),s=J(!1),o=U?.profilingContext;return rt(()=>{const r=a=>{a.id===e.id&&t()};return U?.on("update",r),()=>U?.off("update",r)},[]),rt(()=>{const r=[];Object.entries(n.current).forEach(([l,{values:c}])=>{const u=d=>{d.id===e.id&&s.peek()!==!0&&c[c.length-1]++},f=l;o.addEventListener(f,u),r.push(()=>o.removeEventListener(f,u))});const a=setInterval(()=>{if(s.peek()===!0)return;const l=[...i.value.labels];Object.values(n.current).forEach(c=>{c.values.push(0),c.values.length>Aa&&c.values.shift()}),l.push((performance.now()/1e3).toFixed(2)),l.length>Aa&&l.shift(),i.value={labels:l,datasets:Ia(n.current)}},100);return()=>{r.forEach(l=>l()),clearInterval(a)}},[]),g("div",{className:"flex flex-col gap-2 border border-white border-opacity-10 rounded bg-neutral-400 bg-opacity-5 text-neutral-400 p-2"},g("div",{className:"grid items-start gap-2",style:"grid-template-columns: 1fr max-content;"},g("div",{className:"flex flex-col gap-2"},g("span",null,e.name),g(Jm,{data:i,className:"w-full max-w-full min-h-20 bg-black bg-opacity-30",onmouseenter:()=>s.value=!0,onmouseleave:()=>s.value=!1})),g("div",{className:"text-xs grid grid-cols-2 gap-x-4",style:"grid-template-columns: auto auto;"},g("span",{className:"text-right"},"Mount duration:"),o.mountDuration(e).toFixed(2)," ms",g("span",{className:"text-right"},"Total updates:"),g("span",null,o.totalTicks(e).toLocaleString()),g("span",{className:"text-right"},"Avg. update duration:"),o.averageTickDuration(e).toFixed(2)," ms",g("span",{className:"text-right"},"Latest update:"),g("span",null,o.lastTickDuration(e).toFixed(2)," ms"))))}const _n=G([]),kc=G(""),nb=Vn(()=>kc.value.toLowerCase().split(" ").filter(e=>e.length>0));function ib(e){return nb.value.every(t=>e.toLowerCase().includes(t))}function sb(){const e=pe();rt(()=>{const n=i=>{An(i)||e()};return U?.on("update",n),()=>U?.off("update",n)},[]);const t=U?.SWRGlobalCache??new Map;return t.size===0?g("div",{className:"flex flex-col items-center justify-center h-full text-neutral-400"},g(lo,null),g("h2",{className:"text-lg italic"},"No SWR detected")):g("div",{className:"flex flex-col gap-2 items-start"},g(ho,{value:kc,className:"sticky top-0"}),g("div",{className:"flex flex-col gap-2 w-full"},gl(t).filter(([n])=>ib(n)).map(([n,i])=>g(ob,{key:n,entry:i}))))}function ob({key:e,entry:t}){const n=_n.value.includes(e),i=pe();rt(()=>{const{resource:o,isValidating:r,isMutating:a}=t,l=[o.subscribe(i),r.subscribe(i),a.subscribe(i)];return()=>l.forEach(c=>c())},[]);const s=Xe(()=>{n?_n.value=_n.value.filter(o=>o!==e):_n.value=[..._n.value,e]},[n]);return g("div",{className:"flex flex-col"},g("button",{onclick:s,className:"flex items-center gap-2 justify-between p-2 border border-white border-opacity-10 cursor-pointer"+(n?" bg-white bg-opacity-5 text-neutral-100 rounded-t":" hover:bg-white hover:bg-opacity-10 text-neutral-400 rounded")},e,g(ce,{className:"transition-all"+(n?" rotate-90":"")})),n&&g("div",{className:"flex flex-col gap-2 p-2 border border-white border-opacity-10"},g(me,{data:{resource:t.resource.peek(),isMutating:t.isMutating.peek(),isValidating:t.isValidating.peek()},mutable:!1,objectRefAcc:[],keys:[],onChange:()=>{}})))}const qt=U.fileRouterInstance?.current?.devtools,yi=G({}),fs=G(null),La=G({});function rb(e){const t=new Map,n=new Map,i=[];function s(a){return a.filter(l=>!(l.startsWith("(")&&l.endsWith(")")))}function o(a){return"/"+s(a).join("/")}for(const[a,l]of Object.entries(e)){const c=l.route,u=s(l.segments),f=o(u),d={routeKey:a,route:c,entry:l,children:[]};t.set(c,d),n.set(f,d)}for(const[,a]of Object.entries(e)){const l=a.route,c=a.segments,u=t.get(l),f=s(c);if(f.length>1){const d=f.slice(0,-1),m=o(d),y=n.get(m);y?y.children.push(u):i.push(u)}else i.push(u)}function r(a){return a.sort((l,c)=>l.route.localeCompare(c.route)).map(l=>({...l,children:r(l.children)}))}return r(i)}const ab=Vn(()=>rb(yi.value)),Qs=G(null),Tc=G(""),Ra=Vn(()=>Tc.value.toLowerCase().split(" ").filter(e=>e.length>0));function lb(e,t){if(Ra.value.length===0)return!0;const n=(e+" "+t.filePath).toLowerCase();return Ra.value.every(i=>n.includes(i))}function Mc(e){return e.map(t=>{const n=Mc(t.children);return lb(t.route,t.entry)||n.length>0?{...t,children:n}:null}).filter(t=>t!==null)}const cb=Vn(()=>Mc(ab.value));function ub(){return rt(()=>{if(!qt){yi.value={},fs.value=null,La.value={};return}yi.value=qt.getPages(),console.log(yi.value);const e=qt.subscribe((t,n)=>{fs.value=t,La.value=n});return()=>e()},[qt]),qt?g(Tt,null,g(kl,null,g("div",{className:"flex-grow sticky pr-2 top-0 flex flex-col gap-2"},g(ho,{value:Tc,className:"sticky top-0"}),g("div",{className:"flex-grow flex flex-col gap-1 items-start"},g(Ps,{from:{filteredRouteTree:cb,selectedRoute:Qs,currentPage:fs}},({filteredRouteTree:e,selectedRoute:t,currentPage:n})=>g(Ec,{nodes:e,selected:t,currentPage:n,depth:0})))),g("div",{className:"flex-grow p-2 sticky top-0"},g(Ps,{from:Qs},e=>e&&g(hb,{page:e}))))):g("div",{className:"flex flex-col items-center justify-center h-full text-neutral-400"},g(lo,null),g("h2",{className:"text-lg italic"},"No file router detected"))}function Ec({nodes:e,selected:t,currentPage:n,depth:i}){return g(Tt,null,e.map(s=>{const o=s.routeKey,r=s.route,a=s.entry,l=o===t,c=n?.route===r,u=s.children.length>0;let f=a.route;if(i>0){const d=a.route.split("/").filter(Boolean);d.length>0&&(f="/"+d[d.length-1])}return g("div",{key:o,className:_i("flex-grow",i>0?"ml-4":"w-full")},g("button",{onclick:()=>Qs.value=o,className:_i("flex items-center gap-2 justify-between px-2 py-1 w-full cursor-pointer rounded","border border-white border-opacity-10 group",l?" bg-white bg-opacity-5 text-neutral-100":" hover:[&:not(:group-hover)]:bg-white/10 hover:[&:not(:group-hover)]:text-neutral-100 text-neutral-400")},g("span",{className:"text-sm"},f),c?g("div",{className:"flex items-center gap-2 relative"},g("span",{className:"text-xs text-neutral-300 bg-white/15 rounded px-1 py-0.5 font-medium"},"Current"),g("button",{className:"flex items-center gap-2 text-neutral-400 hover:text-neutral-100 hover:bg-white/10 rounded p-1",onclick:d=>{d.stopPropagation(),qt.reload()}},g(ml,{className:"w-4 h-4"})),a.params.length>0&&g(Na,{entry:a,route:a.route})):g("div",{className:"flex invisible items-center gap-2 relative group-hover:visible"},g(Na,{entry:a,route:a.route}))),u&&g("div",{className:"mt-1 flex flex-col gap-1"},g(Ec,{nodes:s.children,selected:t,currentPage:n,depth:i+1})))}))}function Na({route:e,entry:t}){return g("button",{className:"flex items-center gap-2 text-neutral-400 hover:text-neutral-100 hover:bg-white/10 rounded p-1",onclick:n=>{if(n.stopPropagation(),!t.params.length)return qt.navigate(e);let i={};for(let o=0;o<t.params.length;o++){const r=t.params[o],a=prompt(\`Enter value for "\${r}"\`);if(!a){alert("Navigation cancelled");return}i[r]=a}const s=t.route.split("/").filter(o=>!o.startsWith("(")&&!o.endsWith(")")).map(o=>o.startsWith("[...")&&o.endsWith("]")?i[o.slice(4,-1)]:o.startsWith("[")&&o.endsWith("]")?i[o.slice(1,-1)]:o).filter(Boolean).join("/");qt.navigate(\`/\${s}\`)}},g(Th,{className:"w-4 h-4"}))}function hb({page:e}){const n=qt.getPages()[e],i=dh(async()=>(await new Promise(s=>setTimeout(s,150)),await n.load()),[e]);return g(Ps,{from:i,fallback:g("div",null,"Loading...")},(s,o)=>{const{default:r,config:a}=s;return g("div",{className:\`transition-opacity \${o?"opacity-75":""}\`},g("h2",{className:"flex justify-between items-center font-bold mb-2 pb-2 border-b-2 border-neutral-800"},g("div",{className:"flex gap-2 items-center"},\`<\${ao({type:r})}>\`,g(Hi,{fn:r}))),a?g("div",{className:"flex items-center gap-2"},g("span",{className:"text-sm text-neutral-400"},"Config:"),g(me,{data:a,mutable:!1,objectRefAcc:[],keys:[],onChange:()=>{}})):g("i",{className:"text-sm text-neutral-400"},"No config"))})}const fb=e=>e.active?g("main",{className:"flex flex-col flex-1 max-h-[calc(100vh-1rem)] overflow-y-auto"},e.children):null,Js={Apps:{Icon:xh,View:Zh},FileRouter:{Icon:_h,View:ub},Stores:{Icon:kh,View:tf},SWR:{Icon:Sh,View:sb},Profiling:{Icon:wh,View:tb},Settings:{Icon:yh,View:Eh}},Li=G("Apps");let Fa=oe.peek();oe.subscribe(e=>{e!==Fa&&e!==null&&(Li.value="Apps"),Fa=e});function db(){return g(Mh,null,g("nav",{className:"flex flex-col gap-2 justify-between p-2 bg-neutral-400 bg-opacity-5 border border-white border-opacity-10 rounded"},g("div",{className:"flex flex-col gap-2"},Object.keys(Js).map(e=>g(pb,{key:e,title:e})))),Object.entries(Js).map(([e,{View:t}])=>g(fb,{key:e,active:Li.value===e},g(t,null))))}function pb({title:e}){const{Icon:t}=Js[e];return g("button",{key:e,onclick:()=>{Li.value=e},className:"flex items-center px-2 py-1 gap-2 rounded border text-xs border-white border-opacity-10"+(Li.value===e?" bg-white bg-opacity-5 text-neutral-100":" hover:bg-white hover:bg-opacity-10 text-neutral-400"),title:e},g(t,{className:"text-primary"}),g("span",{className:"hidden sm:inline"},e))}rh(g(db,null),document.getElementById("app"));Fe.send({type:"ready"});setInterval(()=>{window.opener||window.close()},250);</script>
9306
+ */const Fn=e=>e&&e.enabled&&e.modifierKey,dc=(e,t)=>e&&t[e+"Key"],Co=(e,t)=>e&&!t[e+"Key"];function fe(e,t,n){return e===void 0?!0:typeof e=="string"?e.indexOf(t)!==-1:typeof e=="function"?e({chart:n}).indexOf(t)!==-1:!1}function hs(e,t){return typeof e=="function"&&(e=e({chart:t})),typeof e=="string"?{x:e.indexOf("x")!==-1,y:e.indexOf("y")!==-1}:{x:!1,y:!1}}function hm(e,t){let n;return function(){return clearTimeout(n),n=setTimeout(e,t),t}}function fm({x:e,y:t},n){const i=n.scales,s=Object.keys(i);for(let o=0;o<s.length;o++){const r=i[s[o]];if(t>=r.top&&t<=r.bottom&&e>=r.left&&e<=r.right)return r}return null}function pc(e,t,n){const{mode:i="xy",scaleMode:s,overScaleMode:o}=e||{},r=fm(t,n),a=hs(i,n),l=hs(s,n);if(o){const u=hs(o,n);for(const f of["x","y"])u[f]&&(l[f]=a[f],a[f]=!1)}if(r&&l[r.axis])return[r];const c=[];return F(n.scales,function(u){a[u.axis]&&c.push(u)}),c}const Ys=new WeakMap;function $(e){let t=Ys.get(e);return t||(t={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{},dragging:!1,panning:!1},Ys.set(e,t)),t}function dm(e){Ys.delete(e)}function gc(e,t,n,i){const s=Math.max(0,Math.min(1,(e-t)/n||0)),o=1-s;return{min:i*s,max:i*o}}function mc(e,t){const n=e.isHorizontal()?t.x:t.y;return e.getValueForPixel(n)}function bc(e,t,n){const i=e.max-e.min,s=i*(t-1),o=mc(e,n);return gc(o,e.min,i,s)}function pm(e,t,n){const i=mc(e,n);if(i===void 0)return{min:e.min,max:e.max};const s=Math.log10(e.min),o=Math.log10(e.max),r=Math.log10(i),a=o-s,l=a*(t-1),c=gc(r,s,a,l);return{min:Math.pow(10,s+c.min),max:Math.pow(10,o-c.max)}}function gm(e,t){return t&&(t[e.id]||t[e.axis])||{}}function _a(e,t,n,i,s){let o=n[i];if(o==="original"){const r=e.originalScaleLimits[t.id][i];o=R(r.options,r.scale)}return R(o,s)}function mm(e,t,n){const i=e.getValueForPixel(t),s=e.getValueForPixel(n);return{min:Math.min(i,s),max:Math.max(i,s)}}function bm(e,{min:t,max:n,minLimit:i,maxLimit:s},o){const r=(e-n+t)/2;t-=r,n+=r;const a=o.min.options??o.min.scale,l=o.max.options??o.max.scale,c=e/1e6;return Ie(t,a,c)&&(t=a),Ie(n,l,c)&&(n=l),t<i?(t=i,n=Math.min(i+e,s)):n>s&&(n=s,t=Math.max(s-e,i)),{min:t,max:n}}function Be(e,{min:t,max:n},i,s=!1){const o=$(e.chart),{options:r}=e,a=gm(e,i),{minRange:l=0}=a,c=_a(o,e,a,"min",-1/0),u=_a(o,e,a,"max",1/0);if(s==="pan"&&(t<c||n>u))return!0;const f=e.max-e.min,d=s?Math.max(n-t,l):f;if(s&&d===l&&f<=l)return!0;const m=bm(d,{min:t,max:n,minLimit:c,maxLimit:u},o.originalScaleLimits[e.id]);return r.min=m.min,r.max=m.max,o.updatedScaleLimits[e.id]=m,e.parse(m.min)!==e.min||e.parse(m.max)!==e.max}function xm(e,t,n,i){const s=bc(e,t,n),o={min:e.min+s.min,max:e.max-s.max};return Be(e,o,i,!0)}function ym(e,t,n,i){const s=pm(e,t,n);return Be(e,s,i,!0)}function vm(e,t,n,i){Be(e,mm(e,t,n),i,!0)}const wa=e=>e===0||isNaN(e)?0:e<0?Math.min(Math.round(e),-1):Math.max(Math.round(e),1);function _m(e){const n=e.getLabels().length-1;e.min>0&&(e.min-=1),e.max<n&&(e.max+=1)}function wm(e,t,n,i){const s=bc(e,t,n);e.min===e.max&&t<1&&_m(e);const o={min:e.min+wa(s.min),max:e.max-wa(s.max)};return Be(e,o,i,!0)}function Sm(e){return e.isHorizontal()?e.width:e.height}function km(e,t,n){const s=e.getLabels().length-1;let{min:o,max:r}=e;const a=Math.max(r-o,1),l=Math.round(Sm(e)/Math.max(a,10)),c=Math.round(Math.abs(t/l));let u;return t<-l?(r=Math.min(r+c,s),o=a===1?r:r-a,u=r===s):t>l&&(o=Math.max(0,o-c),r=a===1?o:o+a,u=o===0),Be(e,{min:o,max:r},n)||u}const Tm={second:500,minute:30*1e3,hour:1800*1e3,day:720*60*1e3,week:3.5*24*60*60*1e3,month:360*60*60*1e3,quarter:1440*60*60*1e3,year:4368*60*60*1e3};function xc(e,t,n,i=!1){const{min:s,max:o,options:r}=e,a=r.time&&r.time.round,l=Tm[a]||0,c=e.getValueForPixel(e.getPixelForValue(s+l)-t),u=e.getValueForPixel(e.getPixelForValue(o+l)-t);return isNaN(c)||isNaN(u)?!0:Be(e,{min:c,max:u},n,i?"pan":!1)}function Sa(e,t,n){return xc(e,t,n,!0)}const Xs={category:wm,default:xm,logarithmic:ym},qs={default:vm},Gs={category:km,default:xc,logarithmic:Sa,timeseries:Sa};function Mm(e,t,n){const{id:i,options:{min:s,max:o}}=e;if(!t[i]||!n[i])return!0;const r=n[i];return r.min!==s||r.max!==o}function ka(e,t){F(e,(n,i)=>{t[i]||delete e[i]})}function an(e,t){const{scales:n}=e,{originalScaleLimits:i,updatedScaleLimits:s}=t;return F(n,function(o){Mm(o,i,s)&&(i[o.id]={min:{scale:o.min,options:o.options.min},max:{scale:o.max,options:o.options.max}})}),ka(i,n),ka(s,n),i}function Ta(e,t,n,i){const s=Xs[e.type]||Xs.default;I(s,[e,t,n,i])}function Ma(e,t,n,i){const s=qs[e.type]||qs.default;I(s,[e,t,n,i])}function Em(e){const t=e.chartArea;return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}}function Oo(e,t,n="none",i="api"){const{x:s=1,y:o=1,focalPoint:r=Em(e)}=typeof t=="number"?{x:t,y:t}:t,a=$(e),{options:{limits:l,zoom:c}}=a;an(e,a);const u=s!==1,f=o!==1,d=pc(c,r,e);F(d||e.scales,function(m){m.isHorizontal()&&u?Ta(m,s,r,l):!m.isHorizontal()&&f&&Ta(m,o,r,l)}),e.update(n),I(c.onZoom,[{chart:e,trigger:i}])}function yc(e,t,n,i="none",s="api"){const o=$(e),{options:{limits:r,zoom:a}}=o,{mode:l="xy"}=a;an(e,o);const c=fe(l,"x",e),u=fe(l,"y",e);F(e.scales,function(f){f.isHorizontal()&&c?Ma(f,t.x,n.x,r):!f.isHorizontal()&&u&&Ma(f,t.y,n.y,r)}),e.update(i),I(a.onZoom,[{chart:e,trigger:s}])}function Cm(e,t,n,i="none",s="api"){const o=$(e);an(e,o);const r=e.scales[t];Be(r,n,void 0,!0),e.update(i),I(o.options.zoom?.onZoom,[{chart:e,trigger:s}])}function Om(e,t="default"){const n=$(e),i=an(e,n);F(e.scales,function(s){const o=s.options;i[s.id]?(o.min=i[s.id].min.options,o.max=i[s.id].max.options):(delete o.min,delete o.max),delete n.updatedScaleLimits[s.id]}),e.update(t),I(n.options.zoom.onZoomComplete,[{chart:e}])}function Pm(e,t){const n=e.originalScaleLimits[t];if(!n)return;const{min:i,max:s}=n;return R(s.options,s.scale)-R(i.options,i.scale)}function Dm(e){const t=$(e);let n=1,i=1;return F(e.scales,function(s){const o=Pm(t,s.id);if(o){const r=Math.round(o/(s.max-s.min)*100)/100;n=Math.min(n,r),i=Math.max(i,r)}}),n<1?n:i}function Ea(e,t,n,i){const{panDelta:s}=i,o=s[e.id]||0;he(o)===he(t)&&(t+=o);const r=Gs[e.type]||Gs.default;I(r,[e,t,n])?s[e.id]=0:s[e.id]=t}function vc(e,t,n,i="none"){const{x:s=0,y:o=0}=typeof t=="number"?{x:t,y:t}:t,r=$(e),{options:{pan:a,limits:l}}=r,{onPan:c}=a||{};an(e,r);const u=s!==0,f=o!==0;F(n||e.scales,function(d){d.isHorizontal()&&u?Ea(d,s,l,r):!d.isHorizontal()&&f&&Ea(d,o,l,r)}),e.update(i),I(c,[{chart:e}])}function _c(e){const t=$(e);an(e,t);const n={};for(const i of Object.keys(e.scales)){const{min:s,max:o}=t.originalScaleLimits[i]||{min:{},max:{}};n[i]={min:s.scale,max:o.scale}}return n}function Am(e){const t=$(e),n={};for(const i of Object.keys(e.scales))n[i]=t.updatedScaleLimits[i];return n}function Im(e){const t=_c(e);for(const n of Object.keys(e.scales)){const{min:i,max:s}=t[n];if(i!==void 0&&e.scales[n].min!==i||s!==void 0&&e.scales[n].max!==s)return!0}return!1}function Ca(e){const t=$(e);return t.panning||t.dragging}const Oa=(e,t,n)=>Math.min(n,Math.max(t,e));function ct(e,t){const{handlers:n}=$(e),i=n[t];i&&i.target&&(i.target.removeEventListener(t,i),delete n[t])}function Dn(e,t,n,i){const{handlers:s,options:o}=$(e),r=s[n];if(r&&r.target===t)return;ct(e,n),s[n]=l=>i(e,l,o),s[n].target=t;const a=n==="wheel"?!1:void 0;t.addEventListener(n,s[n],{passive:a})}function Lm(e,t){const n=$(e);n.dragStart&&(n.dragging=!0,n.dragEnd=t,e.update("none"))}function Rm(e,t){const n=$(e);!n.dragStart||t.key!=="Escape"||(ct(e,"keydown"),n.dragging=!1,n.dragStart=n.dragEnd=null,e.update("none"))}function Ks(e,t){if(e.target!==t.canvas){const n=t.canvas.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}return It(e,t)}function wc(e,t,n){const{onZoomStart:i,onZoomRejected:s}=n;if(i){const o=Ks(t,e);if(I(i,[{chart:e,event:t,point:o}])===!1)return I(s,[{chart:e,event:t}]),!1}}function Nm(e,t){if(e.legend){const o=It(t,e);if(en(o,e.legend))return}const n=$(e),{pan:i,zoom:s={}}=n.options;if(t.button!==0||dc(Fn(i),t)||Co(Fn(s.drag),t))return I(s.onZoomRejected,[{chart:e,event:t}]);wc(e,t,s)!==!1&&(n.dragStart=t,Dn(e,e.canvas.ownerDocument,"mousemove",Lm),Dn(e,window.document,"keydown",Rm))}function Fm({begin:e,end:t},n){let i=t.x-e.x,s=t.y-e.y;const o=Math.abs(i/s);o>n?i=Math.sign(i)*Math.abs(s*n):o<n&&(s=Math.sign(s)*Math.abs(i/n)),t.x=e.x+i,t.y=e.y+s}function Pa(e,t,n,{min:i,max:s,prop:o}){e[i]=Oa(Math.min(n.begin[o],n.end[o]),t[i],t[s]),e[s]=Oa(Math.max(n.begin[o],n.end[o]),t[i],t[s])}function zm(e,t,n){const i={begin:Ks(t.dragStart,e),end:Ks(t.dragEnd,e)};if(n){const s=e.chartArea.width/e.chartArea.height;Fm(i,s)}return i}function Sc(e,t,n,i){const s=fe(t,"x",e),o=fe(t,"y",e),{top:r,left:a,right:l,bottom:c,width:u,height:f}=e.chartArea,d={top:r,left:a,right:l,bottom:c},m=zm(e,n,i&&s&&o);s&&Pa(d,e.chartArea,m,{min:"left",max:"right",prop:"x"}),o&&Pa(d,e.chartArea,m,{min:"top",max:"bottom",prop:"y"});const y=d.right-d.left,x=d.bottom-d.top;return{...d,width:y,height:x,zoomX:s&&y?1+(u-y)/u:1,zoomY:o&&x?1+(f-x)/f:1}}function Hm(e,t){const n=$(e);if(!n.dragStart)return;ct(e,"mousemove");const{mode:i,onZoomComplete:s,drag:{threshold:o=0,maintainAspectRatio:r}}=n.options.zoom,a=Sc(e,i,{dragStart:n.dragStart,dragEnd:t},r),l=fe(i,"x",e)?a.width:0,c=fe(i,"y",e)?a.height:0,u=Math.sqrt(l*l+c*c);if(n.dragStart=n.dragEnd=null,u<=o){n.dragging=!1,e.update("none");return}yc(e,{x:a.left,y:a.top},{x:a.right,y:a.bottom},"zoom","drag"),n.dragging=!1,n.filterNextClick=!0,I(s,[{chart:e}])}function Vm(e,t,n){if(Co(Fn(n.wheel),t)){I(n.onZoomRejected,[{chart:e,event:t}]);return}if(wc(e,t,n)!==!1&&(t.cancelable&&t.preventDefault(),t.deltaY!==void 0))return!0}function Bm(e,t){const{handlers:{onZoomComplete:n},options:{zoom:i}}=$(e);if(!Vm(e,t,i))return;const s=t.target.getBoundingClientRect(),o=i.wheel.speed,r=t.deltaY>=0?2-1/(1-o):1+o,a={x:r,y:r,focalPoint:{x:t.clientX-s.left,y:t.clientY-s.top}};Oo(e,a,"zoom","wheel"),I(n,[{chart:e}])}function Wm(e,t,n,i){n&&($(e).handlers[t]=hm(()=>I(n,[{chart:e}]),i))}function jm(e,t){const n=e.canvas,{wheel:i,drag:s,onZoomComplete:o}=t.zoom;i.enabled?(Dn(e,n,"wheel",Bm),Wm(e,"onZoomComplete",o,250)):ct(e,"wheel"),s.enabled?(Dn(e,n,"mousedown",Nm),Dn(e,n.ownerDocument,"mouseup",Hm)):(ct(e,"mousedown"),ct(e,"mousemove"),ct(e,"mouseup"),ct(e,"keydown"))}function $m(e){ct(e,"mousedown"),ct(e,"mousemove"),ct(e,"mouseup"),ct(e,"wheel"),ct(e,"click"),ct(e,"keydown")}function Um(e,t){return function(n,i){const{pan:s,zoom:o={}}=t.options;if(!s||!s.enabled)return!1;const r=i&&i.srcEvent;return r&&!t.panning&&i.pointerType==="mouse"&&(Co(Fn(s),r)||dc(Fn(o.drag),r))?(I(s.onPanRejected,[{chart:e,event:i}]),!1):!0}}function Ym(e,t){const n=Math.abs(e.clientX-t.clientX),i=Math.abs(e.clientY-t.clientY),s=n/i;let o,r;return s>.3&&s<1.7?o=r=!0:n>i?o=!0:r=!0,{x:o,y:r}}function kc(e,t,n){if(t.scale){const{center:i,pointers:s}=n,o=1/t.scale*n.scale,r=n.target.getBoundingClientRect(),a=Ym(s[0],s[1]),l=t.options.zoom.mode,c={x:a.x&&fe(l,"x",e)?o:1,y:a.y&&fe(l,"y",e)?o:1,focalPoint:{x:i.x-r.left,y:i.y-r.top}};Oo(e,c,"zoom","pinch"),t.scale=n.scale}}function Xm(e,t,n){if(t.options.zoom.pinch.enabled){const i=It(n,e);I(t.options.zoom.onZoomStart,[{chart:e,event:n,point:i}])===!1?(t.scale=null,I(t.options.zoom.onZoomRejected,[{chart:e,event:n}])):t.scale=1}}function qm(e,t,n){t.scale&&(kc(e,t,n),t.scale=null,I(t.options.zoom.onZoomComplete,[{chart:e}]))}function Tc(e,t,n){const i=t.delta;i&&(t.panning=!0,vc(e,{x:n.deltaX-i.x,y:n.deltaY-i.y},t.panScales),t.delta={x:n.deltaX,y:n.deltaY})}function Gm(e,t,n){const{enabled:i,onPanStart:s,onPanRejected:o}=t.options.pan;if(!i)return;const r=n.target.getBoundingClientRect(),a={x:n.center.x-r.left,y:n.center.y-r.top};if(I(s,[{chart:e,event:n,point:a}])===!1)return I(o,[{chart:e,event:n}]);t.panScales=pc(t.options.pan,a,e),t.delta={x:0,y:0},Tc(e,t,n)}function Km(e,t){t.delta=null,t.panning&&(t.panning=!1,t.filterNextClick=!0,I(t.options.pan.onPanComplete,[{chart:e}]))}const Zs=new WeakMap;function Da(e,t){const n=$(e),i=e.canvas,{pan:s,zoom:o}=t,r=new Pn.Manager(i);o&&o.pinch.enabled&&(r.add(new Pn.Pinch),r.on("pinchstart",a=>Xm(e,n,a)),r.on("pinch",a=>kc(e,n,a)),r.on("pinchend",a=>qm(e,n,a))),s&&s.enabled&&(r.add(new Pn.Pan({threshold:s.threshold,enable:Um(e,n)})),r.on("panstart",a=>Gm(e,n,a)),r.on("panmove",a=>Tc(e,n,a)),r.on("panend",()=>Km(e,n))),Zs.set(e,r)}function Aa(e){const t=Zs.get(e);t&&(t.remove("pinchstart"),t.remove("pinch"),t.remove("pinchend"),t.remove("panstart"),t.remove("pan"),t.remove("panend"),t.destroy(),Zs.delete(e))}function Zm(e,t){const{pan:n,zoom:i}=e,{pan:s,zoom:o}=t;return i?.zoom?.pinch?.enabled!==o?.zoom?.pinch?.enabled||n?.enabled!==s?.enabled||n?.threshold!==s?.threshold}var Qm="2.2.0";function di(e,t,n){const i=n.zoom.drag,{dragStart:s,dragEnd:o}=$(e);if(i.drawTime!==t||!o)return;const{left:r,top:a,width:l,height:c}=Sc(e,n.zoom.mode,{dragStart:s,dragEnd:o},i.maintainAspectRatio),u=e.ctx;u.save(),u.beginPath(),u.fillStyle=i.backgroundColor||"rgba(225,225,225,0.3)",u.fillRect(r,a,l,c),i.borderWidth>0&&(u.lineWidth=i.borderWidth,u.strokeStyle=i.borderColor||"rgba(225,225,225)",u.strokeRect(r,a,l,c)),u.restore()}var Jm={id:"zoom",version:Qm,defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(e,t,n){const i=$(e);i.options=n,Object.prototype.hasOwnProperty.call(n.zoom,"enabled")&&console.warn("The option \`zoom.enabled\` is no longer supported. Please use \`zoom.wheel.enabled\`, \`zoom.drag.enabled\`, or \`zoom.pinch.enabled\`."),(Object.prototype.hasOwnProperty.call(n.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(n.pan,"overScaleMode"))&&console.warn("The option \`overScaleMode\` is deprecated. Please use \`scaleMode\` instead (and update \`mode\` as desired)."),Pn&&Da(e,n),e.pan=(s,o,r)=>vc(e,s,o,r),e.zoom=(s,o)=>Oo(e,s,o),e.zoomRect=(s,o,r)=>yc(e,s,o,r),e.zoomScale=(s,o,r)=>Cm(e,s,o,r),e.resetZoom=s=>Om(e,s),e.getZoomLevel=()=>Dm(e),e.getInitialScaleBounds=()=>_c(e),e.getZoomedScaleBounds=()=>Am(e),e.isZoomedOrPanned=()=>Im(e),e.isZoomingOrPanning=()=>Ca(e)},beforeEvent(e,{event:t}){if(Ca(e))return!1;if(t.type==="click"||t.type==="mouseup"){const n=$(e);if(n.filterNextClick)return n.filterNextClick=!1,!1}},beforeUpdate:function(e,t,n){const i=$(e),s=i.options;i.options=n,Zm(s,n)&&(Aa(e),Da(e,n)),jm(e,n)},beforeDatasetsDraw(e,t,n){di(e,"beforeDatasetsDraw",n)},afterDatasetsDraw(e,t,n){di(e,"afterDatasetsDraw",n)},beforeDraw(e,t,n){di(e,"beforeDraw",n)},afterDraw(e,t,n){di(e,"afterDraw",n)},stop:function(e){$m(e),Pn&&Aa(e),dm(e)},panFunctions:Gs,zoomFunctions:Xs,zoomRectFunctions:qs};function tb({data:e,...t}){const n=Ne(null),i=Ne(null);return rt(()=>{$s.register(Jm,sm,bp,em,Fg,Ng,jg,Zg);const s=i.current,o=n.current=new $s(s,{type:"line",data:e.peek(),options:{scales:{y:{min:0}},animation:!1,responsive:!0,plugins:{zoom:{pan:{enabled:!0,mode:"x"},zoom:{wheel:{enabled:!0},mode:"x"}},legend:{position:"top"},title:{display:!1}}}}),r=e.subscribe(a=>{o.data=a,o.update()});return()=>{o.destroy(),r()}},[]),g("canvas",{ref:i,...t})}function eb(){const e=pe();rt(()=>{const n=i=>{An(i)||e()};return U?.on("mount",n),U?.on("unmount",n),()=>{U?.off("mount",n),U?.off("unmount",n)}},[]);const t=U?.profilingContext;return g("div",{className:"flex flex-col gap-2"},bl(t.appStats).filter(([n])=>!An(n)).map(([n])=>g(nb,{key:n.id,app:n})))}const Ia=100,La=e=>Object.entries(e).map(([t,{values:n,color:i}])=>({label:t,data:n,fill:!1,borderColor:i,tension:.1}));function nb({app:e}){const t=pe(),n=Ne({update:{values:[0],color:"#ad981f"},updateDirtied:{values:[0],color:"#b21f3a"},createNode:{values:[0],color:"#198019"},removeNode:{values:[0],color:"#5F3691"},updateNode:{values:[0],color:"#2f2f9d"},signalAttrUpdate:{values:[0],color:"#28888f"},signalTextUpdate:{values:[0],color:"#9b3b98"}}),i=J({labels:[(performance.now()/1e3).toFixed(2)],datasets:La(n.current)}),s=J(!1),o=U?.profilingContext;return rt(()=>{const r=a=>{a.id===e.id&&t()};return U?.on("update",r),()=>U?.off("update",r)},[]),rt(()=>{const r=[];Object.entries(n.current).forEach(([l,{values:c}])=>{const u=d=>{d.id===e.id&&s.peek()!==!0&&c[c.length-1]++},f=l;o.addEventListener(f,u),r.push(()=>o.removeEventListener(f,u))});const a=setInterval(()=>{if(s.peek()===!0)return;const l=[...i.value.labels];Object.values(n.current).forEach(c=>{c.values.push(0),c.values.length>Ia&&c.values.shift()}),l.push((performance.now()/1e3).toFixed(2)),l.length>Ia&&l.shift(),i.value={labels:l,datasets:La(n.current)}},100);return()=>{r.forEach(l=>l()),clearInterval(a)}},[]),g("div",{className:"flex flex-col gap-2 border border-white border-opacity-10 rounded bg-neutral-400 bg-opacity-5 text-neutral-400 p-2"},g("div",{className:"grid items-start gap-2",style:"grid-template-columns: 1fr max-content;"},g("div",{className:"flex flex-col gap-2"},g("span",null,e.name),g(tb,{data:i,className:"w-full max-w-full min-h-20 bg-black bg-opacity-30",onmouseenter:()=>s.value=!0,onmouseleave:()=>s.value=!1})),g("div",{className:"text-xs grid grid-cols-2 gap-x-4",style:"grid-template-columns: auto auto;"},g("span",{className:"text-right"},"Mount duration:"),o.mountDuration(e).toFixed(2)," ms",g("span",{className:"text-right"},"Total updates:"),g("span",null,o.totalTicks(e).toLocaleString()),g("span",{className:"text-right"},"Avg. update duration:"),o.averageTickDuration(e).toFixed(2)," ms",g("span",{className:"text-right"},"Latest update:"),g("span",null,o.lastTickDuration(e).toFixed(2)," ms"))))}const _n=G([]),Mc=G(""),ib=Hn(()=>Mc.value.toLowerCase().split(" ").filter(e=>e.length>0));function sb(e){return ib.value.every(t=>e.toLowerCase().includes(t))}function ob(){const e=pe();rt(()=>{const n=i=>{An(i)||e()};return U?.on("update",n),()=>U?.off("update",n)},[]);const t=U?.SWRGlobalCache??new Map;return t.size===0?g("div",{className:"flex flex-col items-center justify-center h-full text-neutral-400"},g(lo,null),g("h2",{className:"text-lg italic"},"No SWR detected")):g("div",{className:"flex flex-col gap-2 items-start"},g(ho,{value:Mc,className:"sticky top-0"}),g("div",{className:"flex flex-col gap-2 w-full"},bl(t).filter(([n])=>sb(n)).map(([n,i])=>g(rb,{key:n,entry:i}))))}function rb({key:e,entry:t}){const n=_n.value.includes(e),i=pe();rt(()=>{const{resource:o,isValidating:r,isMutating:a}=t,l=[o.subscribe(i),r.subscribe(i),a.subscribe(i)];return()=>l.forEach(c=>c())},[]);const s=Xe(()=>{n?_n.value=_n.value.filter(o=>o!==e):_n.value=[..._n.value,e]},[n]);return g("div",{className:"flex flex-col"},g("button",{onclick:s,className:"flex items-center gap-2 justify-between p-2 border border-white border-opacity-10 cursor-pointer"+(n?" bg-white bg-opacity-5 text-neutral-100 rounded-t":" hover:bg-white hover:bg-opacity-10 text-neutral-400 rounded")},e,g(ce,{className:"transition-all"+(n?" rotate-90":"")})),n&&g("div",{className:"flex flex-col gap-2 p-2 border border-white border-opacity-10"},g(me,{data:{resource:t.resource.peek(),isMutating:t.isMutating.peek(),isValidating:t.isValidating.peek()},mutable:!1,objectRefAcc:[],keys:[],onChange:()=>{}})))}const qt=U.fileRouterInstance?.current?.devtools,xi=G({}),fs=G(null),Ra=G({});function ab(e){const t=new Map,n=new Map,i=[];function s(a){return a.filter(l=>!(l.startsWith("(")&&l.endsWith(")")))}function o(a){return"/"+s(a).join("/")}for(const[a,l]of Object.entries(e)){const c=l.route,u=s(l.segments),f=o(u),d={routeKey:a,route:c,entry:l,children:[]};t.set(c,d),n.set(f,d)}for(const[,a]of Object.entries(e)){const l=a.route,c=a.segments,u=t.get(l),f=s(c);if(f.length>1){const d=f.slice(0,-1),m=o(d),y=n.get(m);y?y.children.push(u):i.push(u)}else i.push(u)}function r(a){return a.sort((l,c)=>l.route.localeCompare(c.route)).map(l=>({...l,children:r(l.children)}))}return r(i)}const lb=Hn(()=>ab(xi.value)),Qs=G(null),Ec=G(""),Na=Hn(()=>Ec.value.toLowerCase().split(" ").filter(e=>e.length>0));function cb(e,t){if(Na.value.length===0)return!0;const n=(e+" "+t.filePath).toLowerCase();return Na.value.every(i=>n.includes(i))}function Cc(e){return e.map(t=>{const n=Cc(t.children);return cb(t.route,t.entry)||n.length>0?{...t,children:n}:null}).filter(t=>t!==null)}const ub=Hn(()=>Cc(lb.value));function hb(){return rt(()=>{if(!qt){xi.value={},fs.value=null,Ra.value={};return}xi.value=qt.getPages(),console.log(xi.value);const e=qt.subscribe((t,n)=>{fs.value=t,Ra.value=n});return()=>e()},[qt]),qt?g(Tt,null,g(Ml,null,g("div",{className:"flex-grow sticky pr-2 top-0 flex flex-col gap-2"},g(ho,{value:Ec,className:"sticky top-0"}),g("div",{className:"flex-grow flex flex-col gap-1 items-start"},g(Ps,{from:{filteredRouteTree:ub,selectedRoute:Qs,currentPage:fs}},({filteredRouteTree:e,selectedRoute:t,currentPage:n})=>g(Oc,{nodes:e,selected:t,currentPage:n,depth:0})))),g("div",{className:"flex-grow p-2 sticky top-0"},g(Ps,{from:Qs},e=>e&&g(fb,{page:e}))))):g("div",{className:"flex flex-col items-center justify-center h-full text-neutral-400"},g(lo,null),g("h2",{className:"text-lg italic"},"No file router detected"))}function Oc({nodes:e,selected:t,currentPage:n,depth:i}){return g(Tt,null,e.map(s=>{const o=s.routeKey,r=s.route,a=s.entry,l=o===t,c=n?.route===r,u=s.children.length>0;let f=a.route;if(i>0){const d=a.route.split("/").filter(Boolean);d.length>0&&(f="/"+d[d.length-1])}return g("div",{key:o,className:vi("flex-grow",i>0?"ml-4":"w-full")},g("button",{onclick:()=>Qs.value=o,className:vi("flex items-center gap-2 justify-between px-2 py-1 w-full cursor-pointer rounded","border border-white border-opacity-10 group",l?" bg-white bg-opacity-5 text-neutral-100":" hover:[&:not(:group-hover)]:bg-white/10 hover:[&:not(:group-hover)]:text-neutral-100 text-neutral-400")},g("span",{className:"text-sm"},f),c?g("div",{className:"flex items-center gap-2 relative"},g("span",{className:"text-xs text-neutral-300 bg-white/15 rounded px-1 py-0.5 font-medium"},"Current"),g("button",{className:"flex items-center gap-2 text-neutral-400 hover:text-neutral-100 hover:bg-white/10 rounded p-1",onclick:d=>{d.stopPropagation(),qt.reload()}},g(xl,{className:"w-4 h-4"})),a.params.length>0&&g(Fa,{entry:a,route:a.route})):g("div",{className:"flex invisible items-center gap-2 relative group-hover:visible"},g(Fa,{entry:a,route:a.route}))),u&&g("div",{className:"mt-1 flex flex-col gap-1"},g(Oc,{nodes:s.children,selected:t,currentPage:n,depth:i+1})))}))}function Fa({route:e,entry:t}){return g("button",{className:"flex items-center gap-2 text-neutral-400 hover:text-neutral-100 hover:bg-white/10 rounded p-1",onclick:n=>{if(n.stopPropagation(),!t.params.length)return qt.navigate(e);let i={};for(let o=0;o<t.params.length;o++){const r=t.params[o],a=prompt(\`Enter value for "\${r}"\`);if(!a){alert("Navigation cancelled");return}i[r]=a}const s=t.route.split("/").filter(o=>!o.startsWith("(")&&!o.endsWith(")")).map(o=>o.startsWith("[...")&&o.endsWith("]")?i[o.slice(4,-1)]:o.startsWith("[")&&o.endsWith("]")?i[o.slice(1,-1)]:o).filter(Boolean).join("/");qt.navigate(\`/\${s}\`)}},g(Mh,{className:"w-4 h-4"}))}function fb({page:e}){const n=qt.getPages()[e],i=gh(async()=>(await new Promise(s=>setTimeout(s,150)),await n.load()),[e]);return g(Ps,{from:i,fallback:g("div",null,"Loading...")},(s,o)=>{const{default:r,config:a}=s;return g("div",{className:\`transition-opacity \${o?"opacity-75":""}\`},g("h2",{className:"flex justify-between items-center font-bold mb-2 pb-2 border-b-2 border-neutral-800"},g("div",{className:"flex gap-2 items-center"},\`<\${ao({type:r})}>\`,g(Hi,{fn:r}))),a?g("div",{className:"flex items-center gap-2"},g("span",{className:"text-sm text-neutral-400"},"Config:"),g(me,{data:a,mutable:!1,objectRefAcc:[],keys:[],onChange:()=>{}})):g("i",{className:"text-sm text-neutral-400"},"No config"))})}const db=e=>e.active?g("main",{className:"flex flex-col flex-1 max-h-[calc(100vh-1rem)] overflow-y-auto"},e.children):null,Js={Apps:{Icon:yh,View:Qh},FileRouter:{Icon:wh,View:hb},Stores:{Icon:Th,View:ef},SWR:{Icon:kh,View:ob},Profiling:{Icon:Sh,View:eb},Settings:{Icon:vh,View:Ch}},Ii=G("Apps");let za=oe.peek();oe.subscribe(e=>{e!==za&&e!==null&&(Ii.value="Apps"),za=e});function pb(){return g(Eh,null,g("nav",{className:"flex flex-col gap-2 justify-between p-2 bg-neutral-400 bg-opacity-5 border border-white border-opacity-10 rounded"},g("div",{className:"flex flex-col gap-2"},Object.keys(Js).map(e=>g(gb,{key:e,title:e})))),Object.entries(Js).map(([e,{View:t}])=>g(db,{key:e,active:Ii.value===e},g(t,null))))}function gb({title:e}){const{Icon:t}=Js[e];return g("button",{key:e,onclick:()=>{Ii.value=e},className:"flex items-center px-2 py-1 gap-2 rounded border text-xs border-white border-opacity-10"+(Ii.value===e?" bg-white bg-opacity-5 text-neutral-100":" hover:bg-white hover:bg-opacity-10 text-neutral-400"),title:e},g(t,{className:"text-primary"}),g("span",{className:"hidden sm:inline"},e))}ah(g(pb,null),document.getElementById("app"));Fe.send({type:"ready"});setInterval(()=>{window.opener||window.close()},250);</script>
9154
9307
  <style rel="stylesheet" crossorigin>*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.invisible{visibility:hidden}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.top-0{top:0}.z-10{z-index:10}.z-\\[9999\\]{z-index:9999}.mb-1{margin-bottom:.25rem}.mb-2{margin-bottom:.5rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.mt-1{margin-top:.25rem}.flex{display:flex}.grid{display:grid}.hidden{display:none}.h-4{height:1rem}.h-5{height:1.25rem}.h-full{height:100%}.max-h-\\[calc\\(100vh-1rem\\)\\]{max-height:calc(100vh - 1rem)}.min-h-20{min-height:5rem}.min-h-screen{min-height:100vh}.w-4{width:1rem}.w-5{width:1.25rem}.w-8{width:2rem}.w-\\[5px\\]{width:5px}.w-full{width:100%}.max-w-full{max-width:100%}.flex-1{flex:1 1 0%}.flex-grow{flex-grow:1}.-translate-x-1\\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-col-resize{cursor:col-resize}.cursor-default{cursor:default}.cursor-pointer{cursor:pointer}.resize{resize:both}.scroll-m-12{scroll-margin:3rem}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.flex-col{flex-direction:column}.items-start{align-items:flex-start}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-2{gap:.5rem}.gap-4{gap:1rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.overflow-hidden{overflow:hidden}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.rounded{border-radius:.25rem}.rounded-b{border-bottom-right-radius:.25rem;border-bottom-left-radius:.25rem}.rounded-t{border-top-left-radius:.25rem;border-top-right-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-\\[\\#fff1\\]{border-color:#fff1}.border-neutral-700{--tw-border-opacity: 1;border-color:rgb(64 64 64 / var(--tw-border-opacity, 1))}.border-neutral-800{--tw-border-opacity: 1;border-color:rgb(38 38 38 / var(--tw-border-opacity, 1))}.border-white{--tw-border-opacity: 1;border-color:rgb(255 255 255 / var(--tw-border-opacity, 1))}.border-opacity-10{--tw-border-opacity: .1}.bg-\\[\\#171616\\]{--tw-bg-opacity: 1;background-color:rgb(23 22 22 / var(--tw-bg-opacity, 1))}.bg-\\[\\#1a1a1a\\]{--tw-bg-opacity: 1;background-color:rgb(26 26 26 / var(--tw-bg-opacity, 1))}.bg-\\[\\#1d1d1d\\]{--tw-bg-opacity: 1;background-color:rgb(29 29 29 / var(--tw-bg-opacity, 1))}.bg-\\[\\#212121\\]{--tw-bg-opacity: 1;background-color:rgb(33 33 33 / var(--tw-bg-opacity, 1))}.bg-\\[\\#ffffff04\\]{background-color:#ffffff04}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity, 1))}.bg-neutral-400{--tw-bg-opacity: 1;background-color:rgb(163 163 163 / var(--tw-bg-opacity, 1))}.bg-neutral-800{--tw-bg-opacity: 1;background-color:rgb(38 38 38 / var(--tw-bg-opacity, 1))}.bg-neutral-900{--tw-bg-opacity: 1;background-color:rgb(23 23 23 / var(--tw-bg-opacity, 1))}.bg-primary{--tw-bg-opacity: 1;background-color:rgb(220 20 60 / var(--tw-bg-opacity, 1))}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-white\\/15{background-color:#ffffff26}.bg-opacity-30{--tw-bg-opacity: .3}.bg-opacity-5{--tw-bg-opacity: .05}.p-1{padding:.25rem}.p-2{padding:.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-2{padding-left:.5rem;padding-right:.5rem}.py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.pb-2{padding-bottom:.5rem}.pl-2{padding-left:.5rem}.pl-4{padding-left:1rem}.pl-6{padding-left:1.5rem}.pl-8{padding-left:2rem}.pr-1{padding-right:.25rem}.pr-2{padding-right:.5rem}.text-right{text-align:right}.text-\\[10px\\]{font-size:10px}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.italic{font-style:italic}.text-neutral-100{--tw-text-opacity: 1;color:rgb(245 245 245 / var(--tw-text-opacity, 1))}.text-neutral-300{--tw-text-opacity: 1;color:rgb(212 212 212 / var(--tw-text-opacity, 1))}.text-neutral-400{--tw-text-opacity: 1;color:rgb(163 163 163 / var(--tw-text-opacity, 1))}.text-primary{--tw-text-opacity: 1;color:rgb(220 20 60 / var(--tw-text-opacity, 1))}.accent-red-500{accent-color:#ef4444}.opacity-50{opacity:.5}.opacity-75{opacity:.75}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}:root{color-scheme:dark}#app{min-width:-moz-fit-content;min-width:fit-content;background-image:linear-gradient(#171616,#0e0e0e);color:#fff;min-height:100vh;width:100%;display:flex;flex-direction:row;padding:.5rem;gap:.5rem}select{background:url("data:image/svg+xml,<svg height='10px' width='10px' viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'><path d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/></svg>") no-repeat;background-position:calc(100% - .75rem) center!important;-moz-appearance:none!important;-webkit-appearance:none!important;appearance:none!important;padding-right:2rem!important}select:not([disabled]){cursor:pointer}.last\\:border-b-0:last-child{border-bottom-width:0px}.hover\\:bg-neutral-700:hover{--tw-bg-opacity: 1;background-color:rgb(64 64 64 / var(--tw-bg-opacity, 1))}.hover\\:bg-white:hover{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.hover\\:bg-white\\/10:hover{background-color:#ffffff1a}.hover\\:bg-opacity-10:hover{--tw-bg-opacity: .1}.hover\\:text-neutral-100:hover{--tw-text-opacity: 1;color:rgb(245 245 245 / var(--tw-text-opacity, 1))}.hover\\:opacity-100:hover{opacity:1}.focus\\:outline:focus{outline-style:solid}.focus\\:outline-primary:focus{outline-color:#dc143c}.group:hover .group-hover\\:visible{visibility:visible}@media (min-width: 640px){.sm\\:inline{display:inline}}.hover\\:\\[\\&\\:not\\(\\:group-hover\\)\\]\\:bg-white\\/10:not(:group-hover):hover{background-color:#ffffff1a}.hover\\:\\[\\&\\:not\\(\\:group-hover\\)\\]\\:text-neutral-100:not(:group-hover):hover{--tw-text-opacity: 1;color:rgb(245 245 245 / var(--tw-text-opacity, 1))}</style>
9155
9308
  </head>
9156
9309
  <body class="w-full min-h-screen">
@@ -9161,11 +9314,11 @@ var dist_default = `<!DOCTYPE html>
9161
9314
  `;
9162
9315
 
9163
9316
  // ../devtools-host/dist/index.js
9164
- var dist_default2 = `var qe="production";if(qe!=="development"&&qe!=="production")throw new Error("NODE_ENV must either be set to development or production.");var l=qe==="development";var Xe=Symbol.for("kiru.signal"),Dt=Symbol.for("kiru.context"),ie=Symbol.for("kiru.contextProvider"),T=Symbol.for("kiru.fragment"),Ye=Symbol.for("kiru.error"),Y=Symbol.for("kiru.hmrAccept"),_e=Symbol.for("kiru.memo"),se=Symbol.for("kiru.errorBoundary"),Ze=Symbol.for("kiru.streamData"),Ot=Symbol.for("kiru.devFileLink"),Je=50;var P=2,L=4,fe=8,I=16,Ce=32,we=64,ae=128,Pt=/^on:?/;var Qe=new Set(["animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","path","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","title","tspan","use"]),et=new Set(["allowfullscreen","autofocus","autoplay","async","checked","compact","controls","contenteditable","declare","default","defer","disabled","download","hidden","inert","ismap","multiple","nohref","noresize","noshade","novalidate","nowrap","open","popover","readonly","required","sandbox","scoped","selected","sortable","spellcheck","translate","wrap"]),Lt=new Map([["acceptCharset","accept-charset"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["httpEquiv","http-equiv"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]);var C={current:null},Z={current:0},M={current:"window"in globalThis?"dom":"string"};var Vt,k=class extends Error{constructor(t){let r=typeof t=="string"?t:t.message;super(r),this[Vt]=!0,typeof t!="string"&&(l&&t?.vNode&&(this.customNodeStack=Ur(t.vNode)),this.fatal=t?.fatal)}static isKiruError(t){return t instanceof Error&&t[Ye]===!0}};Vt=Ye;function Ur(e){let t=e,r=[];for(;t&&t.parent;)typeof t.type=="function"?r.push(Br(t.type)):typeof t.type=="string"&&r.push(t.type),t=t.parent;let n=typeof e.type=="function"?e:tt(e,o=>typeof o.type=="function");return\`The above error occurred in the <\${$t(n?.type||B)}> component:
9317
+ var dist_default2 = `var Xe="production";if(Xe!=="development"&&Xe!=="production")throw new Error("NODE_ENV must either be set to development or production.");var l=Xe==="development";var Ye=Symbol.for("kiru.signal"),Dt=Symbol.for("kiru.context"),ie=Symbol.for("kiru.contextProvider"),T=Symbol.for("kiru.fragment"),Ze=Symbol.for("kiru.error"),Y=Symbol.for("kiru.hmrAccept"),_e=Symbol.for("kiru.memo"),se=Symbol.for("kiru.errorBoundary"),Je=Symbol.for("kiru.streamData"),Ot=Symbol.for("kiru.devFileLink"),Qe=50;var P=2,L=4,fe=8,I=16,Ce=32,we=64,ae=128,Pt=/^on:?/;var et=new Set(["animateTransform","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","filter","foreignObject","g","image","line","linearGradient","marker","path","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","title","tspan","use"]),tt=new Set(["allowfullscreen","autofocus","autoplay","async","checked","compact","controls","contenteditable","declare","default","defer","disabled","download","hidden","inert","ismap","multiple","nohref","noresize","noshade","novalidate","nowrap","open","popover","readonly","required","sandbox","scoped","selected","sortable","spellcheck","translate","wrap"]),Lt=new Map([["acceptCharset","accept-charset"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["httpEquiv","http-equiv"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]);var C={current:null},Z={current:0},M={current:"window"in globalThis?"dom":"string"};var Vt,k=class extends Error{constructor(t){let r=typeof t=="string"?t:t.message;super(r),this[Vt]=!0,typeof t!="string"&&(l&&t?.vNode&&(this.customNodeStack=Ur(t.vNode)),this.fatal=t?.fatal)}static isKiruError(t){return t instanceof Error&&t[Ze]===!0}};Vt=Ze;function Ur(e){let t=e,r=[];for(;t&&t.parent;)typeof t.type=="function"?r.push(Br(t.type)):typeof t.type=="string"&&r.push(t.type),t=t.parent;let n=typeof e.type=="function"?e:rt(e,o=>typeof o.type=="function");return\`The above error occurred in the <\${$t(n?.type||U)}> component:
9165
9318
 
9166
9319
  \${r.map(o=>\` at \${o}\`).join(\`
9167
9320
  \`)}
9168
- \`}function Br(e){let t=$t(e);if(l){let r=Wr(e);r&&(t=\`\${t} (\${r})\`)}return t}function $t(e){return e.displayName??(e.name||"Anonymous Function")}function Wr(e){return e.toString().match(/\\/\\/ \\[kiru_devtools\\]:(.*)/)?.[1]??null}var te={parentStack:[],childIdxStack:[],eventDeferrals:new Map,parent:function(){return this.parentStack[this.parentStack.length-1]},clear:function(){this.parentStack.length=0,this.childIdxStack.length=0},pop:function(){this.parentStack.pop(),this.childIdxStack.pop()},push:function(e){this.parentStack.push(e),this.childIdxStack.push(0)},currentChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]]},nextChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]++]},bumpChildIndex:function(){this.childIdxStack[this.childIdxStack.length-1]++},captureEvents:function(e){It(e,!0),this.eventDeferrals.set(e,[])},resetEvents:function(e){this.eventDeferrals.delete(e)},releaseEvents:function(e){It(e,!1);let t=this.eventDeferrals.get(e);for(;t?.length;)t.shift()()}},Gr=e=>{let t=e.target;!e.isTrusted||!t||te.eventDeferrals.get(t)?.push(()=>t.dispatchEvent(e))},It=(e,t)=>{for(let r in e)if(r.startsWith("on")){let n=r.substring(2);e[t?"addEventListener":"removeEventListener"](n,Gr,{passive:!0})}};var st=!1,rt=!1,Nt=e=>{e.preventDefault(),e.stopPropagation(),rt=!0},le=null;function Ht(){st=!0,le=document.activeElement,le&&le!==document.body&&le.addEventListener("blur",Nt)}function Ft(){rt&&(le.removeEventListener("blur",Nt),le.isConnected&&le.focus(),rt=!1),st=!1}function zt(e){let t=e.type;return t=="#text"?jt(e):Qe.has(t)?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)}function jt(e){let{nodeValue:t}=e.props;if(!b.isSignal(t))return document.createTextNode(t);let r=t.peek()??"",n=document.createTextNode(r);return ot(e,n,t),n}function qr(e,t,r){let n=nt.get(e)??{},o=n[t]=i=>{if(st){i.preventDefault(),i.stopPropagation();return}r(i)};return nt.set(e,n),o}var nt=new WeakMap;function Kt(e){let{dom:t,prev:r,props:n,cleanups:o}=e,i=r?.props??{},s=n??{},a=M.current==="hydrate";if(t instanceof Text){let p=s.nodeValue;!b.isSignal(p)&&t.nodeValue!==p&&(t.nodeValue=p);return}let u=[];for(let p in i)u.push(p);for(let p in s)p in i||u.push(p);for(let p=0;p<u.length;p++){let v=u[p],f=i[v],y=s[v];if(Te.isEvent(v)){if(f!==y||a){let E=v.replace(Pt,""),U=E==="focus"||E==="blur",S=nt.get(e);v in i&&t.removeEventListener(E,U?S?.[E]:f),v in s&&t.addEventListener(E,U?qr(e,E,y):y)}continue}if(!(Te.isInternalProp(v)&&v!=="innerHTML")&&f!==y){if(b.isSignal(f)&&o){let E=o[v];E&&(E(),delete o[v])}if(b.isSignal(y)){Jr(e,t,v,y,f);continue}Ae(t,v,y,f)}}let c=i.ref,d=s.ref;c!==d&&(c&&Me(c,null),d&&Me(d,t))}function Xr(e){return e.multiple?Array.from(e.selectedOptions).map(t=>t.value):e.value}function Ut(e,t){if(!e.multiple||t===void 0||t===null||t===""){e.value=t;return}Array.from(e.options).forEach(r=>{r.selected=t.indexOf(r.value)>-1})}var Yr={value:"input",checked:"change",open:"toggle",volume:"volumechange",playbackRate:"ratechange",currentTime:"timeupdate"},Zr=["progress","meter","number","range"];function Jr(e,t,r,n,o){let i=e.cleanups??(e.cleanups={}),[s,a]=r.split(":");if(s!=="bind"){i[r]=n.subscribe((he,Ge)=>{he!==Ge&&(Ae(t,r,he,Ge),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",N(e)))});let S=n.peek(),D=J(o);if(S===D)return;Ae(t,r,S,D);return}let u=Yr[a];if(!u){l&&console.error(\`[kiru]: \${a} is not a valid element binding attribute.\`);return}let c=t instanceof HTMLSelectElement,d=c?S=>Ut(t,S):S=>t[a]=S,p=S=>{d(S),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",N(e))},v=S=>{n.sneak(S),n.notify(D=>D!==p)},f;if(a==="value"){let S=Zr.indexOf(t.type)!==-1;f=()=>{let D=t.value;c?D=Xr(t):typeof n.peek()=="number"&&S&&(D=t.valueAsNumber),v(D)}}else f=S=>{let D=S.target[a];a==="currentTime"&&n.peek()===D||v(D)};t.addEventListener(u,f);let y=n.subscribe(p);i[r]=()=>{t.removeEventListener(u,f),y()};let E=n.peek(),U=J(o);E!==U&&Ae(t,a,E,U)}function ot(e,t,r){(e.cleanups??(e.cleanups={})).nodeValue=r.subscribe((n,o)=>{n!==o&&(t.nodeValue=n,l&&window.__kiru.profilingContext?.emit("signalTextUpdate",N(e)))})}function Qr(e){if(e.type!=="#text"||!b.isSignal(e.props.nodeValue))return;let t=J(e.props.nodeValue);if(t!=null)return;let r=jt(e);return te.parent().appendChild(r),r}function Bt(e){let t=te.nextChild()??Qr(e);if(!t)throw new k({message:"Hydration mismatch - no node found",vNode:e});let r=t.nodeName;if(Qe.has(r)||(r=r.toLowerCase()),e.type!==r)throw new k({message:\`Hydration mismatch - expected node of type \${e.type.toString()} but received \${r}\`,vNode:e});if(e.dom=t,e.type!=="#text"&&!(e.flags&I)){Kt(e);return}b.isSignal(e.props.nodeValue)&&ot(e,t,e.props.nodeValue);let n=e,o=e.sibling;for(;o&&o.type==="#text";){let i=o;te.bumpChildIndex();let s=String(J(n.props.nodeValue)??""),a=n.dom.splitText(s.length);i.dom=a,b.isSignal(i.props.nodeValue)&&ot(i,a,i.props.nodeValue),n=o,o=o.sibling}}function Wt(e,t,r,n=!1){if(r===null)return e.removeAttribute(t),!0;switch(typeof r){case"undefined":case"function":case"symbol":return e.removeAttribute(t),!0;case"boolean":if(n&&!r)return e.removeAttribute(t),!0}return!1}function en(e,t,r){let n=et.has(t);Wt(e,t,r,n)||e.setAttribute(t,n&&typeof r=="boolean"?"":String(r))}var tn=["INPUT","TEXTAREA"],rn=e=>tn.indexOf(e.nodeName)>-1;function Ae(e,t,r,n){switch(t){case"style":return sn(e,r,n);case"className":return on(e,r);case"innerHTML":return nn(e,r);case"muted":e.muted=!!r;return;case"value":if(e.nodeName==="SELECT")return Ut(e,r);let o=r==null?"":String(r);if(rn(e)){e.value=o;return}e.setAttribute("value",o);return;case"checked":if(e.nodeName==="INPUT"){e.checked=!!r;return}e.setAttribute("checked",String(r));return;default:return en(e,Jt(t),r)}}function nn(e,t){if(t==null||typeof t=="boolean"){e.innerHTML="";return}e.innerHTML=String(t)}function on(e,t){let r=J(t);if(!r)return e.removeAttribute("class");e.setAttribute("class",r)}function sn(e,t,r){if(Wt(e,"style",t))return;if(typeof t=="string"){e.setAttribute("style",t);return}let n={};typeof r=="string"?e.setAttribute("style",""):typeof r=="object"&&r&&(n=r);let o=t;new Set([...Object.keys(n),...Object.keys(o)]).forEach(s=>{let a=n[s],u=o[s];if(a!==u){if(u===void 0){e.style[s]="";return}e.style[s]=u}})}function an(e){let t=e.parent,r=t?.dom;for(;t&&!r;)t=t.parent,r=t?.dom;if(!r||!t){if(!e.parent&&e.dom)return e;throw new k({message:"No DOM parent found while attempting to place node.",vNode:e})}return t}function ln(e,t){let{node:r,lastChild:n}=t,o=e.dom;if(n){n.after(o);return}let i=Gt(e,r);if(i){r.dom.insertBefore(o,i);return}r.dom.appendChild(o)}function Gt(e,t){let r=e;for(;r;){let n=r.sibling;for(;n;){if(!(n.flags&(L|I))){let o=un(n);if(o?.isConnected)return o}n=n.sibling}if(r=r.parent,!r||r.flags&I||r===t)return}}function un(e){let t=e;for(;t;){if(t.dom)return t.dom;if(t.flags&I)return;t=t.child}}function qt(e){if(M.current==="hydrate")return Q(e,be);let t={node:e.dom?e:an(e)};it(e,t,(e.flags&L)>0),e.dom&&!(e.flags&I)&&Xt(e,t,!1),be(e)}function it(e,t,r){let n=e.child;for(;n;){if(n.flags&we){n.flags&L&&cn(n,t),be(n),n=n.sibling;continue}n.dom?(it(n,{node:n},!1),n.flags&I||Xt(n,t,r)):it(n,t,(n.flags&L)>0||r),be(n),n=n.sibling}}function Xt(e,t,r){(r||!e.dom.isConnected||e.flags&L)&&ln(e,t),(!e.prev||e.flags&P)&&Kt(e),t.lastChild=e.dom}function Yt(e){e===e.parent?.child&&(e.parent.child=e.sibling);let t;l&&(t=N(e)),Q(e,r=>{let{hooks:n,subs:o,cleanups:i,dom:s,props:{ref:a}}=r;for(o?.forEach(u=>u()),i&&Object.values(i).forEach(u=>u());n?.length;)n.pop().cleanup?.();l&&(window.__kiru.profilingContext?.emit("removeNode",t),s instanceof Element&&delete s.__kiruNode),s&&(s.isConnected&&!(r.flags&I)&&s.remove(),a&&Me(a,null),delete r.dom)}),e.parent=null}function cn(e,t){if(!e.child)return;let r=[];if(Zt(e.child,r),r.length===0)return;let{node:n,lastChild:o}=t;if(o)o.after(...r);else{let i=Gt(e,n),s=n.dom;i?i.before(...r):s.append(...r)}t.lastChild=r[r.length-1]}function Zt(e,t){let r=e;for(;r;)r.dom?t.push(r.dom):r.child&&Zt(r.child,t),r=r.sibling}function m(e,t=null,...r){e===ue&&(e=T);let n=t===null?{}:t,o=at(n.key),i=r.length;return i===1?n.children=r[0]:i>1&&(n.children=r),{type:e,key:o,props:n}}function ue({children:e,key:t}){return{type:T,key:at(t),props:{children:e}}}function lt(e){return typeof e=="function"&&typeof e[_e]?.arePropsEqual=="function"}function Re(e,t=null,r={},n=null,o=0){e===ue&&(e=T);let i=t?t.depth+1:0;return{type:e,key:n,props:r,parent:t,index:o,depth:i,flags:0,child:null,sibling:null,prev:null,deletions:null}}var ft;function Pe(e,t){return l&&(ft=N(e)),Array.isArray(t)?(l&&(ir in t&&gn(e,t),mn(e,t)),pn(e,t)):fn(e,t)}function fn(e,t){let r=e.child;if(r===null)return rr(e,t);let n=r.sibling,o=er(e,r,t);if(o!==null)return r&&r!==o&&!o.prev?ct(e,r):n&&ct(e,n),o;{let i=sr(r),s=nr(i,e,0,t);if(s!==null){let a=s.prev;if(a!==null){let u=a.key;i.delete(u===null?a.index:u)}De(s,0,0)}return i.forEach(a=>Oe(e,a)),s}}function pn(e,t){let r=null,n=null,o=e.child,i=null,s=0,a=0;for(;o!==null&&a<t.length;a++){o.index>a?(i=o,o=null):i=o.sibling;let c=er(e,o,t[a]);if(c===null){o===null&&(o=i);break}o&&!c.prev&&Oe(e,o),s=De(c,s,a),n===null?r=c:n.sibling=c,n=c,o=i}if(a===t.length)return ct(e,o),r;if(o===null){for(;a<t.length;a++){let c=rr(e,t[a]);c!==null&&(s=De(c,s,a),n===null?r=c:n.sibling=c,n=c)}return r}let u=sr(o);for(;a<t.length;a++){let c=nr(u,e,a,t[a]);if(c!==null){let d=c.prev;if(d!==null){let p=d.key;u.delete(p===null?d.index:p)}s=De(c,s,a),n===null?r=c:n.sibling=c,n=c}}return u.forEach(c=>Oe(e,c)),r}function er(e,t,r){let n=t===null?null:t.key;return Le(r)?n!==null||t?.type==="#text"&&b.isSignal(t.props.nodeValue)?null:Qt(e,t,""+r):b.isSignal(r)?t&&t.props.nodeValue!==r?null:Qt(e,t,r):pe(r)?r.key!==n?null:dn(e,t,r):Array.isArray(r)?n!==null?null:(l&&pt(r),tr(e,t,r)):null}function Qt(e,t,r){return t===null||t.type!=="#text"?W(e,"#text",{nodeValue:r}):(l&&ye(),t.props.nodeValue!==r&&(t.props.nodeValue=r,t.flags|=P),t.sibling=null,t)}function dn(e,t,r){let{type:n,props:o,key:i}=r;return l&&typeof n=="function"&&(n=_(n)),n===T?tr(e,t,o.children||[],o):t?.type===n?(l&&ye(),t.index=0,t.sibling=null,typeof n=="string"?or(t.props,o)&&(t.flags|=P):t.flags|=P,t.props=o,t):W(e,n,o,i)}function tr(e,t,r,n={}){return t===null||t.type!==T?W(e,T,{children:r,...n}):(l&&ye(),t.props={...t.props,...n,children:r},t.flags|=P,t.sibling=null,t)}function rr(e,t){return Le(t)?W(e,"#text",{nodeValue:""+t}):b.isSignal(t)?W(e,"#text",{nodeValue:t}):pe(t)?W(e,t.type,t.props,t.key):Array.isArray(t)?(l&&pt(t),W(e,T,{children:t})):null}function De(e,t,r){e.index=r;let n=e.prev;if(n!==null){let o=n.index;return o<t?(e.flags|=L,t):o}else return e.flags|=L,t}function nr(e,t,r,n){if(b.isSignal(n)||Le(n)){let i=e.get(r);if(i){if(i.props.nodeValue===n)return i;i.type==="#text"&&b.isSignal(i.props.nodeValue)&&i.cleanups?.nodeValue?.()}return W(t,"#text",{nodeValue:n},null,r)}if(pe(n)){let{type:i,props:s,key:a}=n,u=e.get(a===null?r:a);return u?.type===i?(l&&ye(),typeof i=="string"?or(u.props,s)&&(u.flags|=P):u.flags|=P,u.props=s,u.sibling=null,u.index=r,u):W(t,i,s,a,r)}if(Array.isArray(n)){let i=e.get(r);return l&&pt(n),i?(l&&ye(),i.flags|=P,i.props.children=n,i):W(t,T,{children:n},null,r)}return null}function or(e,t){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!0;for(let o of r)if(!(o==="children"||o==="key")&&e[o]!==t[o])return!0;return!1}function ye(){"window"in globalThis&&window.__kiru.profilingContext?.emit("updateNode",ft)}var ir=Symbol("kiru:marked-list-child");function pt(e){Object.assign(e,{[ir]:!0})}function sr(e){let t=new Map;for(;e;){let r=e.key;t.set(r===null?e.index:r,e),e=e.sibling}return t}function Oe(e,t){e.deletions===null?e.deletions=[t]:e.deletions.push(t)}function ct(e,t){for(;t;)Oe(e,t),t=t.sibling}function mn(e,t){let r=new Set,n=!1;for(let o of t){if(!pe(o))continue;let i=o.key;if(typeof i=="string"){if(!n&&r.has(i)){let s=lr(e);ar(\`\${s} component produced a child in a list with a duplicate key prop: "\${i}". Keys should be unique so that components maintain their identity across updates\`),n=!0}r.add(i)}}}function gn(e,t){let r=!1,n=!1;for(let o of t)pe(o)&&(typeof o.key=="string"?r=!0:n=!0);if(n&&r){let o=lr(e);ar(\`\${o} component produced a child in a list without a valid key prop\`)}}function ar(e){let t=\`[kiru]: \${e}. See https://kirujs.dev/keys-warning for more information.\`;console.error(t)}var ut=new WeakMap;function lr(e){if(ut.has(e))return ut.get(e);let t=e.parent,r;for(;!r&&t;)typeof t.type=="function"&&(r=t.type),t=t.parent;let n=\`<\${r?.displayName||r?.name||"Anonymous Function"} />\`;return ut.set(e,n),n}function W(e,t,r,n=null,o=0){let i=Re(t,e,r,n,o);return i.flags|=L,typeof t=="function"&&lt(t)&&(i.flags|=Ce,i.arePropsEqual=t[_e].arePropsEqual),l&&"window"in globalThis&&window.__kiru.profilingContext?.emit("createNode",ft),i}var G,q=[],de=!1,mt=[],Ve=[],gt=!1,ht=!1,wt=!1,bt=0,ur=[],yt=[],cr=-1;function xt(e){if(de){mt.push(e);return}e()}function $e(){de&&(window.cancelAnimationFrame(cr),fr())}function Et(e){e.flags|=ae,q.push(e),de=!0,$e()}function O(e){if(M.current==="hydrate")return xt(()=>vt(e));vt(e)}function hn(){de||(de=!0,cr=window.requestAnimationFrame(fr))}function wn(){for(de=!1;mt.length;)mt.shift()()}function vt(e){if(gt&&(ht=!0),C.current===e){l&&window.__kiru.profilingContext?.emit("updateDirtied",G),wt=!0;return}if(!(e.flags&(ae|fe))){if(e.flags|=ae,!q.length)return q.push(e),hn();q.push(e)}}function bn(e){Q(e,t=>t.flags|=fe),Ve.push(e)}var yn=(e,t)=>t.depth-e.depth,re=null;function fr(){if(l){let t=Ve[0]??q[0];t?(G=N(t),window.__kiru.profilingContext?.beginTick(G)):G=null}let e=1;for(Ht();q.length;){q.length>e&&q.sort(yn),re=q.shift(),e=q.length;let t=re.flags;if(!(t&fe)&&t&ae){let r=re;for(;r=vn(r););for(;Ve.length;)Yt(Ve.pop());qt(re),re.flags&=~ae}}if(Ft(),gt=!0,dt(ur),gt=!1,ht)return kn(),dt(yt),ht=!1,bt++,l&&(window.__kiru.profilingContext?.endTick(G),window.__kiru.profilingContext?.emit("updateDirtied",G)),$e();bt=0,wn(),dt(yt),l&&(window.__kiru.emit("update",G),window.__kiru.profilingContext?.emit("update",G),window.__kiru.profilingContext?.endTick(G))}function vn(e){let t=!0;try{typeof e.type=="string"?Sn(e):St(e.type)?xn(e):t=En(e)}catch(n){l&&window.__kiru.emit("error",G,n instanceof Error?n:new Error(String(n)));let o=pr(e);if(o){let i=o.error=n instanceof Error?n:new Error(String(n));return o.props.onError?.(i),o.depth<re.depth&&(re=o),o}if(k.isKiruError(n)){if(n.customNodeStack&&setTimeout(()=>{throw new Error(n.customNodeStack)}),n.fatal)throw n;console.error(n);return}setTimeout(()=>{throw n})}if(e.deletions!==null&&(e.deletions.forEach(bn),e.deletions=null),t&&e.child)return e.child;let r=e;for(;r;){if(r.immediateEffects&&(ur.push(...r.immediateEffects),r.immediateEffects=void 0),r.effects&&(yt.push(...r.effects),r.effects=void 0),r===re)return;if(r.sibling)return r.sibling;r=r.parent,M.current==="hydrate"&&r?.dom&&te.pop()}}function xn(e){let{props:t,type:r}=e,n=t.children;if(r===ie){let{props:{dependents:o,value:i},prev:s}=e;o.size&&s&&s.props.value!==i&&o.forEach(vt)}else if(r===se){let o=e,{error:i}=o;i&&(n=typeof t.fallback=="function"?t.fallback(i):t.fallback,delete o.error)}e.child=Pe(e,n)}function En(e){let{type:t,props:r,subs:n,prev:o,flags:i}=e;if(i&Ce){if(e.memoizedProps=r,o?.memoizedProps&&e.arePropsEqual(o.memoizedProps,r)&&!e.hmrUpdated)return e.flags|=we,!1;e.flags&=~we}try{C.current=e;let s,a=0;do{if(e.flags&=~ae,wt=!1,Z.current=0,n&&(n.forEach(u=>u()),n.clear()),l){if(s=_(t)(r),e.hmrUpdated&&e.hooks&&e.hookSig){let u=e.hooks.length;if(Z.current<u){for(let c=Z.current;c<u;c++)e.hooks[c].cleanup?.();e.hooks.length=Z.current,e.hookSig.length=Z.current}}if(delete e.hmrUpdated,++a>Je)throw new k({message:"Too many re-renders. Kiru limits the number of renders to prevent an infinite loop.",fatal:!0,vNode:e});continue}s=t(r)}while(wt);return e.child=Pe(e,s),!0}finally{C.current=null}}function Sn(e){let{props:t,type:r}=e;l&&kt(e),e.dom||(M.current==="hydrate"?Bt(e):e.dom=zt(e),l&&e.dom instanceof Element&&(e.dom.__kiruNode=e)),r!=="#text"&&(e.child=Pe(e,t.children),e.child&&M.current==="hydrate"&&te.push(e.dom))}function kn(){if(bt>Je)throw new k("Maximum update depth exceeded. This can happen when a component repeatedly calls setState during render or in useLayoutEffect. Kiru limits the number of nested updates to prevent infinite loops.")}function dt(e){for(let t=0;t<e.length;t++)e[t]();e.length=0}var dr;(function(e){e.Start="start",e.End="end"})(dr||(dr={}));var me=null,mr=new Set;function h(e,t,r){let n=_n(e);if(l&&me!==null&&!mr.has(e+me))throw mr.add(e+me),new k({message:\`Nested primitive "useHook" calls are not supported. "\${e}" was called inside "\${me}". Strange will most certainly happen.\`,vNode:n});let o=(a,u)=>{if(u?.immediate){(n.immediateEffects??(n.immediateEffects=[])).push(a);return}(n.effects??(n.effects=[])).push(a)},i=Z.current++,s=n.hooks?.at(i);if(l){me=e,n.hooks??(n.hooks=[]),n.hookSig??(n.hookSig=[]),n.hookSig[i]?n.hookSig[i]!==e&&(console.warn(\`[kiru]: hooks must be called in the same order. Hook "\${e}" was called in place of "\${n.hookSig[i]}". Strange things may happen.\`),s?.cleanup?.(),n.hooks.length=i,n.hookSig.length=i,s=void 0):n.hookSig[i]=e;let a;s?a=s:(a=typeof t=="function"?t():{...t},a.name=e),n.hooks[i]=a;try{return r({hook:a,isInit:!s,isHMR:n.hmrUpdated,update:()=>O(n),queueEffect:o,vNode:n,index:i})}catch(u){throw u}finally{me=null}}try{let a=s??(typeof t=="function"?t():{...t});return n.hooks??(n.hooks=[]),n.hooks[i]=a,r({hook:a,isInit:!s,update:()=>O(n),queueEffect:o,vNode:n,index:i})}catch(a){throw a}}function _n(e){let t=C.current;if(!t)throw new k(\`Hook "\${e}" must be used at the top level of a component or inside another composite hook.\`);return t}function H(e){e.cleanup&&(e.cleanup(),e.cleanup=void 0)}function A(e,t){return e===void 0||t===void 0||e.length!==t.length||e.length>0&&t.some((r,n)=>!Object.is(r,e[n]))}var ve={stack:new Array,current:function(){return this.stack[this.stack.length-1]}},F=new Map,z=new Map;var gr,b=class e{constructor(t,r){this[gr]=!0,this.$id=Ne(),this.$value=t,r&&(this.displayName=r),l?(z.set(this.$id,new Set),this.$initialValue=_t(t),this[Y]={provide:()=>this,inject:n=>{z.get(this.$id)?.clear?.(),z.delete(this.$id),this.$id=n.$id,n.__next=this,this.$initialValue===n.$initialValue?this.$value=n.$value:this.notify()},destroy:()=>{}}):this.$subs=new Set}get value(){if(this.onBeforeRead?.(),l){let t=_(this);return e.entangle(t),t.$value}return e.entangle(this),this.$value}set value(t){if(l){let r=_(this);if(Object.is(r.$value,t))return;r.$prevValue=r.$value,r.$value=t,r.notify();return}Object.is(this.$value,t)||(this.$prevValue=this.$value,this.$value=t,this.notify())}peek(){return this.onBeforeRead?.(),l?_(this).$value:this.$value}sneak(t){if(l){let r=_(this);r.$prevValue=r.$value,r.$value=t;return}this.$prevValue=this.$value,this.$value=t}toString(){if(this.onBeforeRead?.(),l){let t=_(this);return e.entangle(t),\`\${t.$value}\`}return e.entangle(this),\`\${this.$value}\`}subscribe(t){return l?(z.get(this.$id).add(t),()=>z.get(this.$id)?.delete(t)):(this.$subs.add(t),()=>this.$subs.delete(t))}notify(t){if(l)return z.get(this.$id)?.forEach(r=>{if(t&&!t(r))return;let{$value:n,$prevValue:o}=_(this);return r(n,o)});this.$subs.forEach(r=>{if(!(t&&!t(r)))return r(this.$value,this.$prevValue)})}static isSignal(t){return typeof t=="object"&&!!t&&Xe in t}static subscribers(t){return l?z.get(t.$id):t.$subs}static makeReadonly(t){let r=Object.getOwnPropertyDescriptor(t,"value");return r&&!r.writable?t:Object.defineProperty(t,"value",{get:function(){return e.entangle(this),this.$value},configurable:!0})}static makeWritable(t){let r=Object.getOwnPropertyDescriptor(t,"value");return r&&r.writable?t:Object.defineProperty(t,"value",{get:function(){return e.entangle(this),this.$value},set:function(n){this.$value=n,this.notify()},configurable:!0})}static entangle(t){let r=C.current,n=ve.current();if(n){(!r||r&&g())&&n.set(t.$id,t);return}if(!r||!g())return;let o=t.subscribe(()=>O(r));(r.subs??(r.subs=new Set)).add(o)}static configure(t,r){t.onBeforeRead=r}static dispose(t){if(t.$isDisposed=!0,l){z.delete(t.$id);return}t.$subs.clear()}};gr=Xe;var Ie=(e,t)=>new b(e,t),x=(e,t)=>h("useSignal",{signal:null},({hook:r,isInit:n,isHMR:o})=>{if(l&&(n&&(r.dev={devtools:{get:()=>({displayName:r.signal.displayName,value:r.signal.peek()}),set:({value:i})=>{r.signal.value=i}},initialArgs:[e,t]}),o)){let[i,s]=r.dev.initialArgs;(i!==e||s!==t)&&(r.cleanup?.(),n=!0,r.dev.initialArgs=[e,t])}return n&&(r.cleanup=()=>b.dispose(r.signal),r.signal=new b(e,t)),r.signal});function J(e,t=!1){return b.isSignal(e)?t?e.value:e.peek():e}var Ct=()=>{F.forEach(e=>e()),F.clear()};var hr=new Set(["children","ref","key","innerHTML"]),Te={isInternalProp:e=>hr.has(e),isEvent:e=>e.startsWith("on"),isStringRenderableProperty:e=>!hr.has(e)&&!Te.isEvent(e)};function Jt(e){switch(e){case"className":return"class";case"htmlFor":return"for";case"tabIndex":case"formAction":case"formMethod":case"formEncType":case"contentEditable":case"spellCheck":case"allowFullScreen":case"autoPlay":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"noModule":case"noValidate":case"popoverTarget":case"popoverTargetAction":case"playsInline":case"readOnly":case"itemscope":case"rowSpan":case"crossOrigin":return e.toLowerCase();default:return e.indexOf("-")>-1?e:e.startsWith("aria")?"aria-"+e.substring(4).toLowerCase():Lt.get(e)||e}}function _t(e,t={functions:!0}){let r=new WeakSet;return JSON.stringify(e,(n,o)=>{if(typeof o=="object"&&o!==null){if(r.has(o))return"[CIRCULAR]";r.add(o)}return typeof o=="function"?t.functions?o.toString():\`[FUNCTION (\${o.name||"anonymous"})]\`:o})}var B=Object.freeze(()=>{});function _(e){let t=e;if(l)for(;"__next"in t;)t=t.__next;return t}function Me(e,t){if(typeof e=="function"){e(t);return}if(b.isSignal(e)){e.value=t;return}e.current=t}function g(){return M.current==="dom"||M.current==="hydrate"}function pe(e){return typeof e=="object"&&e!==null&&"type"in e}function Le(e){return typeof e=="string"&&e!==""||typeof e=="number"||typeof e=="bigint"}function St(e){return e===T||e===ie||e===se}function wr(e){return e.type===T}function N(e){let t=e;for(;t;){if(t.app)return e.app=t.app;t=t.parent}return null}function be(e){let{props:{children:t,...r},key:n,memoizedProps:o,index:i}=e;e.prev={props:r,key:n,memoizedProps:o,index:i},e.flags&=~(P|L|fe)}function br(e,t){if(t.depth<e.depth)return!1;if(e===t)return!0;let r=!1,n=[e];for(;n.length;){let o=n.pop();if(o===t)return!0;o.child&&n.push(o.child),r&&o.sibling&&n.push(o.sibling),r=!0}return!1}function Q(e,t){t(e);let r=e.child;for(;r;)t(r),r.child&&Q(r,t),r=r.sibling}function tt(e,t){let r=e.parent;for(;r;){if(t(r))return r;r=r.parent}return null}function pr(e){return tt(e,t=>t.type===se)}function kt(e){if("children"in e.props&&e.props.innerHTML)throw new k({message:"Cannot use both children and innerHTML on an element",vNode:e});for(let t in e.props)if("bind:"+t in e.props)throw new k({message:\`Cannot use both bind:\${t} and \${t} on an element\`,vNode:e})}function at(e){return e===void 0?null:typeof e=="string"||typeof e=="number"?e:null}var Cn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-";function Ne(e=10,t=Cn){let r="";for(let n=0;n<e;n++)r+=t[Math.random()*t.length|0];return r}function He(e){let{id:t,subs:r,fn:n,deps:o=[],onDepChanged:i}=e,s;F.delete(t);let a=!!C.current&&!g();a||(s=new Map,ve.stack.push(s));let u=n(...o.map(c=>c.value));if(!a){for(let[d,p]of r)s.has(d)||(p(),r.delete(d));let c=()=>{F.size||queueMicrotask(Ct),F.set(t,i)};for(let[d,p]of s){if(r.has(d))continue;let v=p.subscribe(c);r.set(d,v)}ve.stack.pop()}return u}var ge=class e extends b{constructor(t,r){if(super(void 0,r),this.$getter=t,this.$unsubs=new Map,this.$isDirty=!0,l){let n=this[Y].inject;this[Y]={provide:()=>this,inject:o=>{n(o),e.stop(o),this.$isDirty=o.$isDirty},destroy:()=>{}}}b.configure(this,()=>{this.$isDirty&&(l&&this.$isDisposed||e.run(this))})}get value(){return super.value}set value(t){}subscribe(t){return this.$isDirty&&e.run(this),super.subscribe(t)}static dispose(t){e.stop(t),b.dispose(t)}static updateGetter(t,r){let n=_(t);n.$getter=r,n.$isDirty=!0,e.run(n),!Object.is(n.$value,n.$prevValue)&&n.notify()}static stop(t){let{$id:r,$unsubs:n}=_(t);F.delete(r),n.forEach(o=>o()),n.clear(),t.$isDirty=!0}static run(t){let r=_(t),{$id:n,$getter:o,$unsubs:i}=r,s=He({id:n,subs:i,fn:()=>o(r.$value),onDepChanged:()=>{if(r.$isDirty=!0,l){if(!z?.get(n)?.size)return}else if(!t.$subs.size)return;e.run(r),!Object.is(r.$value,r.$prevValue)&&r.notify()}});r.sneak(s),r.$isDirty=!1}};function yr(e,t){return new ge(e,t)}function At(e,t,r){return h("useComputedSignal",{signal:null,deps:void 0},({hook:n,isInit:o,isHMR:i})=>(l&&(n.dev={devtools:{get:()=>({displayName:n.signal.displayName,value:n.signal.peek()})}},i&&(n.cleanup?.(),o=!0)),o?(typeof t=="string"&&(r=t,t=void 0),n.deps=t,n.cleanup=()=>ge.dispose(n.signal),n.signal=yr(e,r)):n.deps&&typeof t!="string"&&A(n.deps,t)&&(n.deps=t,ge.updateGetter(n.signal,e)),n.signal))}var xe=class e{constructor(t,r){if(this.id=Ne(),this.getter=t,this.deps=r,this.unsubs=new Map,this.isRunning=!1,this.cleanup=null,l&&"window"in globalThis){let n=window.__kiru.HMRContext.signals;n.isWaitingForNextWatchCall()&&n.pushWatch(this)}this.start()}start(){if(!this.isRunning){if(this.isRunning=!0,l&&"window"in globalThis&&window.__kiru.HMRContext?.isReplacement())return queueMicrotask(()=>{this.isRunning&&e.run(this)});e.run(this)}}stop(){F.delete(this.id),this.unsubs.forEach(t=>t()),this.unsubs.clear(),this.cleanup?.(),this.cleanup=null,this.isRunning=!1}static run(t){let r=_(t),{id:n,getter:o,unsubs:i,deps:s}=r;r.cleanup=He({id:n,subs:i,fn:o,deps:s,onDepChanged:()=>{r.cleanup?.(),e.run(r)}})??null}};function vr(e,t){if(typeof e=="function")return new xe(e);let r=e,n=t;return new xe(n,r)}function Ee(e,t){if(g())return h("useWatch",{watcher:null},({hook:r,isInit:n,isHMR:o})=>{if(l&&o&&(r.cleanup?.(),n=!0),n){let i=r.watcher=vr(e,t);r.cleanup=()=>i.stop()}return r.watcher})}var An=0;function xr(e,t,r){if(l&&t.__kiruNode)throw new Error("[kiru]: container in use - call unmount on the previous app first.");let n=Tn(t),o=An++,i={id:o,name:r?.name??\`App-\${o}\`,rootNode:n,render:s,unmount:a};function s(u){n.props.children=u,Et(n)}function a(){n.props.children=null,Et(n),l&&(delete t.__kiruNode,delete n.app),window.__kiru.emit("unmount",i)}return l&&(n.app=i),s(e),window.__kiru.emit("mount",i,O),l&&queueMicrotask(()=>{window.dispatchEvent(new Event("kiru:ready"))}),i}function Tn(e){let t=Re(e.nodeName.toLowerCase());return t.flags|=I,t.dom=e,l&&(e.__kiruNode=t),t}function ce(e){return g()?h("useState",{state:void 0,dispatch:B},({hook:t,isInit:r,update:n,isHMR:o})=>{if(l&&(r&&(t.dev={devtools:{get:()=>({value:t.state}),set:({value:i})=>t.state=i},initialArgs:[e]}),o)){let[i]=t.dev.initialArgs;i!==e&&(r=!0,t.dev.initialArgs=[e])}return r&&(t.state=typeof e=="function"?e():e,t.dispatch=i=>{let s=typeof i=="function"?i(t.state):i;Object.is(t.state,s)||(t.state=s,n())}),[t.state,t.dispatch]}):[typeof e=="function"?e():e,B]}function Er(e){let t={[Dt]:!0,Provider:({value:r,children:n})=>{let[o]=ce(()=>new Set);return m(ie,{value:r,ctx:t,dependents:o},typeof n=="function"?n(r):n)},default:()=>e,set displayName(r){this.Provider.displayName=r},get displayName(){return this.Provider.displayName||"Anonymous Context"}};if(l){let r=t;r[Y]={inject:n=>{let o=t.Provider;window.__kiru.apps.forEach(i=>{Q(i.rootNode,s=>{s.type===n.Provider&&(s.type=o,s.hmrUpdated=!0,O(s))})})},destroy:()=>{},provide:()=>t}}return t}function ee(e,t){return g()?h("useCallback",{callback:e,deps:t},({hook:r,isHMR:n})=>(l&&(r.dev={devtools:{get:()=>({callback:r.callback,dependencies:r.deps})}},n&&(r.deps=[])),A(t,r.deps)&&(r.deps=t,r.callback=e),r.callback)):e}function j(e,t){if(g())return h("useEffect",{deps:t},({hook:r,isInit:n,isHMR:o,queueEffect:i})=>{l&&(r.dev={devtools:{get:()=>({callback:e,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,H(r),i(()=>{let s=e();typeof s=="function"&&(r.cleanup=s)}))})}function ne(e,t){if(g())return h("useLayoutEffect",{deps:t},({hook:r,isInit:n,isHMR:o,queueEffect:i})=>{l&&(r.dev={devtools:{get:()=>({callback:e,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,H(r),i(()=>{let s=e();typeof s=="function"&&(r.cleanup=s)},{immediate:!0}))})}function Se(e,t){return g()?h("useMemo",{deps:t,value:void 0},({hook:r,isInit:n,isHMR:o})=>(l&&(r.dev={devtools:{get:()=>({value:r.value,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,r.value=e()),r.value)):e()}function V(e){return g()?h("useRef",{ref:{current:e}},({hook:t,isInit:r,isHMR:n})=>{if(l&&(r&&(t.dev={devtools:{get:()=>({value:t.ref.current}),set:({value:o})=>t.ref.current=o},initialArgs:[t.ref.current]}),n)){let[o]=t.dev.initialArgs;o!==e&&(t.ref={current:e},t.dev.initialArgs=[e])}return t.ref}):{current:e}}var sl="window"in globalThis?window.__KIRU_LAZY_CACHE??(window.__KIRU_LAZY_CACHE=new Map):new Map;function _r(e){let[t,r]=ce(e.initialState||"exited"),n=V(null);ne(()=>{e.in&&t!=="entered"&&t!=="entering"?(o("entering"),i("entered")):!e.in&&t!=="exited"&&t!=="exiting"&&(o("exiting"),i("exited"))},[e.in,t]),j(()=>()=>kr(n.current),[]);let o=ee(s=>{kr(n.current),r(s),(s==="entered"||s==="exited")&&e.onTransitionEnd&&e.onTransitionEnd(s)},[]),i=ee(s=>{n.current=window.setTimeout(()=>o(s),Dn(s,e.duration))},[e.duration]);return e.element(t)}var Sr=150;function Dn(e,t){if(typeof t=="number")return t;switch(e){case"entered":return t?.in??Sr;case"exited":return t?.out??Sr}}function kr(e){e!=null&&window.clearTimeout(e)}"window"in globalThis;var Cr=()=>m("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},m("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"}));var Fe="kiru.devtools.anchorPosition",Ar={x:-16,y:-16};var Tt=(e,t,r)=>{if(!t.current)return{...Ar};let n=window.innerWidth/e.width,o=window.innerHeight/e.height,i=null,s=null;return e.snapSide==="left"?i=(t.current.offsetWidth-r.width.value)*-1+16:e.snapSide==="right"?i=-16:e.snapSide==="bottom"?s=-16:e.snapSide==="top"&&(s=(window.innerHeight-r.height.value)*-1+16),{x:i??e.x*n,y:s??e.y*o}},Tr=e=>{if(e==null)return null;let t=null,r=e?.__kiruNode?.parent;for(;r;){if(typeof r.type=="function"&&!wr(r)){t=r;break}r=r.parent}return t},Mr=(e,t)=>{let r=[],n=[t.__kiruNode];for(;n.length;){let i=n.pop();if(i===e)break;i?.dom&&r.push(i),i?.parent&&n.push(i.parent)}if(r.length===0)return;let o=r[r.length-1].dom;return o instanceof Element?o:void 0};function ze(e,t){if(!e)throw new Error(t)}var Dr={arrayChunkSize:10,objectKeysChunkSize:100};function Or(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let n in r)if(typeof t[n]!=typeof e[n]||typeof e[n]=="object"&&!Or(e[n],t[n]))return!1;return!0}var Ln={...Dr},Rr=localStorage.getItem("kiru.devtools.userSettings");if(Rr)try{let e=JSON.parse(Rr);Or(Dr,e)&&(Ln=e)}catch(e){console.error("kiru.devtools.userSettings error",e)}var ec=Er({userSettings:null,saveUserSettings:()=>{}});var lc=Object.freeze(()=>{});var In="kiru-devtools";"window"in globalThis&&(window.__devtoolsSelection??(window.__devtoolsSelection=null),window.__devtoolsNodeUpdatePtr??(window.__devtoolsNodeUpdatePtr=null));var Mt=class extends BroadcastChannel{send(t){super.postMessage(t)}removeEventListener(t){return super.removeEventListener("message",t)}addEventListener(t){return super.addEventListener("message",t)}},R=new Mt(In);var Oc=Symbol.for("devtools.hookGroup");var $=(e,t,r={})=>{j(()=>{let n=window,o=r?.ref?.();return o?n=o:r.ref&&console.warn("useEventListener ref failed, using window"),n.addEventListener(e,t,r),()=>{n.removeEventListener(e,t,r)}},[t])};var je=()=>{let e=x({x:0,y:0}),t=x({x:0,y:0}),r=x({x:0,y:0});return $("mousemove",n=>{e.value={x:n.x,y:n.y},t.value={x:n.movementX,y:n.movementY},r.value={x:n.clientX,y:n.clientY}}),{mouse:e,delta:t,client:r}};var Ke="window"in globalThis&&"ResizeObserver"in globalThis.window,Pr=(e,t,r=void 0)=>g()?Ke?h("useResizeObserver",{resizeObserver:null,deps:[e.current]},({isInit:n,hook:o,queueEffect:i})=>(n&&(o.resizeObserver=new ResizeObserver(t),o.cleanup=()=>{o.resizeObserver?.disconnect?.(),o.resizeObserver=null}),i(()=>{A([e.current],o.deps)&&(o.deps=[e.current],o.resizeObserver?.disconnect?.(),e.current&&o.resizeObserver?.observe(e.current,r))}),{isSupported:Ke,start:()=>{o.resizeObserver==null&&(o.resizeObserver=new ResizeObserver(t),e.current&&o.resizeObserver.observe(e.current,r),o.cleanup=()=>{o.resizeObserver?.disconnect?.(),o.resizeObserver=null})},stop:()=>{H(o)}})):{isSupported:Ke,start:()=>{},stop:()=>{}}:{isSupported:Ke,start:()=>{},stop:()=>{}};var Ue="window"in globalThis&&"MutationObserver"in globalThis.window,Lr=(e,t,r=void 0)=>g()?Ue?h("useMutationObserver",{mutationObserver:null,deps:[e.current]},({isInit:n,hook:o,queueEffect:i})=>(n?(i(()=>{o.deps=[e.current],o.mutationObserver=new MutationObserver(t),e.current&&o.mutationObserver.observe(e.current,r)}),o.cleanup=()=>{o.mutationObserver?.disconnect?.(),o.mutationObserver=null}):A([e.current],o.deps)&&(o.deps=[e.current],o.mutationObserver?.disconnect?.(),e.current&&o.mutationObserver?.observe(e.current,r)),{isSupported:Ue,start:()=>{o.mutationObserver==null&&(o.mutationObserver=new MutationObserver(t),e.current&&o.mutationObserver.observe(e.current,r),o.cleanup=()=>{o.mutationObserver?.disconnect?.(),o.mutationObserver=null})},stop:()=>{H(o)}})):{isSupported:Ue,start:()=>{},stop:()=>{}}:{isSupported:Ue,start:()=>{},stop:()=>{}};var Be=(e,t={windowScroll:!0,windowResize:!0})=>{let r=t?.windowScroll??!0,n=t?.windowResize??!0,o=t.immediate??!0,i=x(0),s=x(0),a=x(0),u=x(0),c=x(0),d=x(0),p=x(0),v=x(0),f=()=>{let y=e.current;if(!y){i.value=0,s.value=0,a.value=0,u.value=0,c.value=0,d.value=0,p.value=0,v.value=0;return}let E=y.getBoundingClientRect();i.value=E.width,s.value=E.height,a.value=E.top,u.value=E.right,c.value=E.bottom,d.value=E.left,p.value=E.x,v.value=E.y};return Pr(e,f),Lr(e,f,{attributeFilter:["style","class"]}),$("scroll",()=>{r&&f()},{capture:!0,passive:!0}),$("resize",()=>{n&&f()},{passive:!0}),ne(()=>{o&&f()},[]),{width:i,height:s,top:a,right:u,bottom:c,left:d,x:p,y:v,update:f}};var Vr=(e,t)=>{if(!g())return{isActive:t?.immediate??!1,start:()=>null,stop:()=>null};let r=t?.fpsLimit?1e3/t.fpsLimit:null;return h("useRafFn",()=>({callback:e,refId:null,previousFrameTimestamp:0,isActive:t?.immediate??!1,rafLoop:()=>{}}),({isInit:n,hook:o,update:i})=>(o.callback=e,n&&(o.rafLoop=s=>{if(o.isActive===!1)return;o.previousFrameTimestamp||(o.previousFrameTimestamp=s);let a=s-o.previousFrameTimestamp;if(r&&a<r){o.refId=window.requestAnimationFrame(o.rafLoop);return}o.previousFrameTimestamp=s,o.callback({delta:a,timestamp:s}),o.refId=window.requestAnimationFrame(o.rafLoop)}),n&&t?.immediate&&(o.isActive=!0,o.refId=window.requestAnimationFrame(o.rafLoop),o.cleanup=()=>{o.refId!=null&&window.cancelAnimationFrame(o.refId),o.isActive=!1},i()),{isActive:o.isActive,start:()=>{o.isActive!==!0&&(o.isActive=!0,o.refId=window.requestAnimationFrame(o.rafLoop),o.cleanup=()=>{o.refId!=null&&window.cancelAnimationFrame(o.refId),o.isActive=!1},i())},stop:()=>{H(o),i()}}))};var $r=e=>{let{x:t,y:r,multiple:n,immediate:o=!0}=e,i=x(null),a=Vr(()=>{i.value=n?document.elementsFromPoint(t,r)??[]:document.elementFromPoint(t,r)??null},{immediate:o});return{element:i,...a}};var Ir=()=>{let{mouse:e}=je(),t=x(null),r=V(null),n=V(null),o=Be(r),i=x({x:-16,y:-16}),s=x({x:-16,y:-16}),a=x({width:window.innerWidth,height:window.innerHeight}),u=x("bottom"),c=V(null);ne(()=>{let f=localStorage.getItem(Fe);if(f==null)return;let y=JSON.parse(f);a.value.width=window.innerWidth,a.value.height=window.innerHeight,u.value=y.snapSide,s.value=Tt(y,n,o)},[]);let d=At(()=>{let{x:f,y}=e.value;if(t.value===null)return null;let{x:E,y:U}=t.value;return{x:f-E,y:y-U}});$("dragstart",f=>{f.preventDefault(),t.value={x:f.x,y:f.y},i.value=s.value},{ref:()=>r.current}),$("mouseup",()=>{c.current&&(clearTimeout(c.current),c.current=null),t.peek()&&(t.value=null,localStorage.setItem(Fe,JSON.stringify({...s.value,...a.value,snapSide:u.value})))});let p=ee(()=>{if(n.current==null)return;let f=n.current.offsetWidth;if(u.value==="right"){let y=Math.min(-16,s.value.y);s.value={x:-16,y:Math.max(y,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="left"){let y=Math.min(0,s.value.y);s.value={x:(f-o.width.value)*-1+16,y:Math.max(y,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="top"){let y=Math.min(-16,s.value.x);s.value={x:Math.max(y,(f-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}else{let y=Math.min(-16,s.value.x);s.value={x:Math.max(y,(f-o.width.value)*-1+16),y:-16}}},[]);Ee([d,e],(f,y)=>{if(f===null||!n.current)return;let{x:E,y:U}=y,S=n.current.offsetWidth,D=U>=window.innerHeight-100,he=U<=100;if(!he&&!D){let oe=E>window.innerWidth/2;u.value=oe?"right":"left"}else u.value=he?"top":"bottom";if(u.value==="right"){let oe=Math.min(-16,i.value.y+f.y);s.value={x:-16,y:Math.max(oe,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="left"){let oe=Math.min(0,i.value.y+f.y);s.value={x:(S-o.width.value)*-1+16,y:Math.max(oe,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="top"){let oe=Math.min(-16,i.value.x+f.x);s.value={x:Math.max(oe,(S-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}let Kr=Math.min(-16,i.value.x+f.x);s.value={y:-16,x:Math.max(Kr,(S-o.width.value)*-1+16)}});let v=ee(()=>{n.current!==null&&(s.value=Tt({width:a.value.width,height:a.value.height,x:s.value.x,y:s.value.y,snapSide:u.value},n,o),a.value.width=window.innerWidth,a.value.height=window.innerHeight,localStorage.setItem(Fe,JSON.stringify({...s.value,...a.value,snapSide:u.value})))},[Math.round(o.width.value),Math.round(o.height.value)]);return $("resize",v),{anchorRef:r,anchorCoords:s,viewPortRef:n,startMouse:t,elementBound:o,snapSide:u,updateAnchorPos:p}};var K=Ie(!1);"window"in globalThis&&R.addEventListener(e=>{e.data.type==="set-inspect-enabled"&&(K.value=e.data.value)});var X=Ie(null);var Nr="kiru-devtools-popup-size",We=()=>{let e=X.value;return ee(()=>new Promise((r,n)=>{if(e)if(e.closed)X.value=null;else return e.focus(),r(e);let o=sessionStorage.getItem(Nr),i=o?JSON.parse(o):{width:Math.floor(Math.min(1920,window.screen.width)/2),height:Math.floor(Math.min(1080,window.screen.height)/2)},s=\`popup,width=\${i.width},height=\${i.height};\`,a=window.open(window.__KIRU_DEVTOOLS_PATHNAME__,"_blank",s);if(!a)return console.error("[kiru]: Unable to open devtools window"),n();let u=c=>{c.data.type==="ready"&&(R.removeEventListener(u),console.debug("[kiru]: devtools window opened"),r(a),X.value=a,a.onbeforeunload=()=>{console.debug("[kiru]: devtools window closed"),X.value=null})};R.addEventListener(u),a.onresize=()=>{sessionStorage.setItem(Nr,JSON.stringify({width:a.innerWidth,height:a.innerHeight}))}}),[e])};var Hr=()=>{let e=We(),{mouse:t}=je(),r=$r({x:t.value.x,y:t.value.y,immediate:!1}),n=r.element.value,o=K.value?n:null,i=Se(()=>{if(o&&window.__kiru){let c=window.__kiru.apps.find(d=>d.rootNode==null||o.__kiruNode==null?!1:br(d.rootNode,o.__kiruNode));return c?.rootNode==null?null:c}return null},[o]),s=Se(()=>o?Tr(o):null,[o]),a=V(null),u=Be(a);return j(()=>K.subscribe(d=>{r[d?"start":"stop"]()}),[]),j(()=>{s&&o?a.current=Mr(s,o)??null:a.current=null},[s,o]),$("click",c=>{if(K.value===!0&&s&&i){c.preventDefault();let d=p=>{p.__devtoolsSelection={node:s,app:i},R.send({type:"select-node"}),R.send({type:"set-inspect-enabled",value:!1}),K.value=!1,a.current=null,p.focus()};X.value?d(X.value):e().then(p=>d(p))}}),s&&m("div",{className:"bg-[crimson]/80 fixed grid place-content-center pointer-events-none z-10 top-0 left-0",style:{width:\`\${u?.width}px\`,height:\`\${u?.height}px\`,transform:\`translate(\${u.x}px, \${u.y}px)\`}},m("p",null,s.type.name))};function Fr(e){return m("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 -960 960 960",fill:"currentColor",...e},m("path",{d:"M710-150q-63 0-106.5-43.5T560-300q0-63 43.5-106.5T710-450q63 0 106.5 43.5T860-300q0 63-43.5 106.5T710-150Zm0-80q29 0 49.5-20.5T780-300q0-29-20.5-49.5T710-370q-29 0-49.5 20.5T640-300q0 29 20.5 49.5T710-230Zm-270-30H200q-17 0-28.5-11.5T160-300q0-17 11.5-28.5T200-340h240q17 0 28.5 11.5T480-300q0 17-11.5 28.5T440-260ZM250-510q-63 0-106.5-43.5T100-660q0-63 43.5-106.5T250-810q63 0 106.5 43.5T400-660q0 63-43.5 106.5T250-510Zm0-80q29 0 49.5-20.5T320-660q0-29-20.5-49.5T250-730q-29 0-49.5 20.5T180-660q0 29 20.5 49.5T250-590Zm510-30H520q-17 0-28.5-11.5T480-660q0-17 11.5-28.5T520-700h240q17 0 28.5 11.5T800-660q0 17-11.5 28.5T760-620Zm-50 320ZM250-660Z"}))}function zr(e){return m("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-square-mouse-pointer",...e},m("path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"}),m("path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"}))}var Nn=()=>{K.value=!K.value,R.send({type:"set-inspect-enabled",value:K.value})};function Hn(e,t){let{damping:r}=t,n=x(e),o=V(e);return j(()=>{let i=null,s=()=>{if(Math.sqrt(Math.pow(o.current.x-n.value.x,2)+Math.pow(o.current.y-n.value.y,2))<5)return;let u=n.value.x+(o.current.x-n.value.x)*r,c=n.value.y+(o.current.y-n.value.y)*r;n.value={x:u,y:c},i=window.requestAnimationFrame(s)};return i=window.requestAnimationFrame(s),()=>{i!=null&&window.cancelAnimationFrame(i)}},[e.x,e.y]),Object.assign(n,{set:(i,s)=>{o.current=i,s?.hard&&(n.value=i)}})}function Rt(){let e=x(!1),t=We(),{anchorCoords:r,anchorRef:n,viewPortRef:o,startMouse:i,snapSide:s}=Ir(),a=s.value==="left"||s.value==="right",u=V(!1),c=Hn(r.value,{damping:.4});return Ee([r],c.set),ne(()=>{u.current===!1&&c.set(r.value,{hard:!0}),u.current=!0},[]),m(ue,null,m("div",{ref:o,className:"w-full h-0 fixed top-0 left-0 z-[-9999] overflow-scroll pointer-events-none"}),m("div",{ref:n,draggable:!0,className:\`flex \${a?"flex-col":""} \${e.value?"rounded-3xl":"rounded-full"} p-1 gap-1 items-center will-change-transform bg-crimson\`,style:{transform:\`translate3d(\${Math.round(c.value.x)}px, \${Math.round(c.value.y)}px, 0)\`}},m(_r,{in:e.value,duration:{in:40,out:150},element:d=>{if(d==="exited")return null;let p=d==="entered"?"1":"0.5",v=d==="entered"?"1":"0";return m(ue,null,m("button",{title:"Open Devtools",onclick:t,style:{transform:\`scale(\${p})\`,opacity:v},className:"transition text-white rounded-full p-1 hover:bg-[#0003]"},m(Fr,{width:16,height:16})),m("button",{title:"Toggle Component Inspection",onclick:Nn,style:{transform:\`scale(\${p})\`,opacity:v},className:\`transition text-white rounded-full p-1 hover:bg-[#0003] \${K.value?"bg-[#0003]":""}\`},m(zr,{width:16,height:16})))}}),m("button",{className:"bg-crimson rounded-full p-1"+(i.value?" pointer-events-none":""),onclick:()=>e.value=!e.value,tabIndex:-1},m(Cr,null))),m(Hr,null))}var jr=\`*, ::before, ::after {
9321
+ \`}function Br(e){let t=$t(e);if(l){let r=Wr(e);r&&(t=\`\${t} (\${r})\`)}return t}function $t(e){return e.displayName??(e.name||"Anonymous Function")}function Wr(e){return e.toString().match(/\\/\\/ \\[kiru_devtools\\]:(.*)/)?.[1]??null}var te={parentStack:[],childIdxStack:[],eventDeferrals:new Map,parent:function(){return this.parentStack[this.parentStack.length-1]},clear:function(){this.parentStack.length=0,this.childIdxStack.length=0},pop:function(){this.parentStack.pop(),this.childIdxStack.pop()},push:function(e){this.parentStack.push(e),this.childIdxStack.push(0)},currentChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]]},nextChild:function(){return this.parentStack[this.parentStack.length-1].childNodes[this.childIdxStack[this.childIdxStack.length-1]++]},bumpChildIndex:function(){this.childIdxStack[this.childIdxStack.length-1]++},captureEvents:function(e){It(e,!0),this.eventDeferrals.set(e,[])},resetEvents:function(e){this.eventDeferrals.delete(e)},releaseEvents:function(e){It(e,!1);let t=this.eventDeferrals.get(e);for(;t?.length;)t.shift()()}},Gr=e=>{let t=e.target;!e.isTrusted||!t||te.eventDeferrals.get(t)?.push(()=>t.dispatchEvent(e))},It=(e,t)=>{for(let r in e)if(r.startsWith("on")){let n=r.substring(2);e[t?"addEventListener":"removeEventListener"](n,Gr,{passive:!0})}};var at=!1,nt=!1,Nt=e=>{e.preventDefault(),e.stopPropagation(),nt=!0},le=null;function Ht(){at=!0,le=document.activeElement,le&&le!==document.body&&le.addEventListener("blur",Nt)}function Ft(){nt&&(le.removeEventListener("blur",Nt),le.isConnected&&le.focus(),nt=!1),at=!1}function zt(e){let t=e.type;return t=="#text"?jt(e):et.has(t)?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)}function jt(e){let{nodeValue:t}=e.props;if(!b.isSignal(t))return document.createTextNode(t);let r=t.peek()??"",n=document.createTextNode(r);return it(e,n,t),n}function qr(e,t,r){let n=ot.get(e)??{},o=n[t]=i=>{if(at){i.preventDefault(),i.stopPropagation();return}r(i)};return ot.set(e,n),o}var ot=new WeakMap;function Kt(e){let{dom:t,prev:r,props:n,cleanups:o}=e,i=r?.props??{},s=n??{},a=M.current==="hydrate";if(t instanceof Text){let p=s.nodeValue;!b.isSignal(p)&&t.nodeValue!==p&&(t.nodeValue=p);return}let u=[];for(let p in i)u.push(p);for(let p in s)p in i||u.push(p);for(let p=0;p<u.length;p++){let v=u[p],f=i[v],y=s[v];if(Te.isEvent(v)){if(f!==y||a){let E=v.replace(Pt,""),K=E==="focus"||E==="blur",S=ot.get(e);v in i&&t.removeEventListener(E,K?S?.[E]:f),v in s&&t.addEventListener(E,K?qr(e,E,y):y)}continue}if(!(Te.isInternalProp(v)&&v!=="innerHTML")&&f!==y){if(b.isSignal(f)&&o){let E=o[v];E&&(E(),delete o[v])}if(b.isSignal(y)){Jr(e,t,v,y,f);continue}Ae(t,v,y,f)}}let c=i.ref,d=s.ref;c!==d&&(c&&Me(c,null),d&&Me(d,t))}function Xr(e){return e.multiple?Array.from(e.selectedOptions).map(t=>t.value):e.value}function Ut(e,t){if(!e.multiple||t===void 0||t===null||t===""){e.value=t;return}Array.from(e.options).forEach(r=>{r.selected=t.indexOf(r.value)>-1})}var Yr={value:"input",checked:"change",open:"toggle",volume:"volumechange",playbackRate:"ratechange",currentTime:"timeupdate"},Zr=["progress","meter","number","range"];function Jr(e,t,r,n,o){let i=e.cleanups??(e.cleanups={}),[s,a]=r.split(":");if(s!=="bind"){i[r]=n.subscribe((he,qe)=>{he!==qe&&(Ae(t,r,he,qe),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",N(e)))});let S=n.peek(),D=J(o);if(S===D)return;Ae(t,r,S,D);return}let u=Yr[a];if(!u){l&&console.error(\`[kiru]: \${a} is not a valid element binding attribute.\`);return}let c=t instanceof HTMLSelectElement,d=c?S=>Ut(t,S):S=>t[a]=S,p=S=>{d(S),l&&window.__kiru.profilingContext?.emit("signalAttrUpdate",N(e))},v=S=>{n.sneak(S),n.notify(D=>D!==p)},f;if(a==="value"){let S=Zr.indexOf(t.type)!==-1;f=()=>{let D=t.value;c?D=Xr(t):typeof n.peek()=="number"&&S&&(D=t.valueAsNumber),v(D)}}else f=S=>{let D=S.target[a];a==="currentTime"&&n.peek()===D||v(D)};t.addEventListener(u,f);let y=n.subscribe(p);i[r]=()=>{t.removeEventListener(u,f),y()};let E=n.peek(),K=J(o);E!==K&&Ae(t,a,E,K)}function it(e,t,r){(e.cleanups??(e.cleanups={})).nodeValue=r.subscribe((n,o)=>{n!==o&&(t.nodeValue=n,l&&window.__kiru.profilingContext?.emit("signalTextUpdate",N(e)))})}function Qr(e){if(e.type!=="#text"||!b.isSignal(e.props.nodeValue))return;let t=J(e.props.nodeValue);if(t!=null)return;let r=jt(e);return te.parent().appendChild(r),r}function Bt(e){let t=te.nextChild()??Qr(e);if(!t)throw new k({message:"Hydration mismatch - no node found",vNode:e});let r=t.nodeName;if(et.has(r)||(r=r.toLowerCase()),e.type!==r)throw new k({message:\`Hydration mismatch - expected node of type \${e.type.toString()} but received \${r}\`,vNode:e});if(e.dom=t,e.type!=="#text"&&!(e.flags&I)){Kt(e);return}b.isSignal(e.props.nodeValue)&&it(e,t,e.props.nodeValue);let n=e,o=e.sibling;for(;o&&o.type==="#text";){let i=o;te.bumpChildIndex();let s=String(J(n.props.nodeValue)??""),a=n.dom.splitText(s.length);i.dom=a,b.isSignal(i.props.nodeValue)&&it(i,a,i.props.nodeValue),n=o,o=o.sibling}}function Wt(e,t,r,n=!1){if(r===null)return e.removeAttribute(t),!0;switch(typeof r){case"undefined":case"function":case"symbol":return e.removeAttribute(t),!0;case"boolean":if(n&&!r)return e.removeAttribute(t),!0}return!1}function en(e,t,r){let n=tt.has(t);Wt(e,t,r,n)||e.setAttribute(t,n&&typeof r=="boolean"?"":String(r))}var tn=["INPUT","TEXTAREA"],rn=e=>tn.indexOf(e.nodeName)>-1;function Ae(e,t,r,n){switch(t){case"style":return sn(e,r,n);case"className":return on(e,r);case"innerHTML":return nn(e,r);case"muted":e.muted=!!r;return;case"value":if(e.nodeName==="SELECT")return Ut(e,r);let o=r==null?"":String(r);if(rn(e)){e.value=o;return}e.setAttribute("value",o);return;case"checked":if(e.nodeName==="INPUT"){e.checked=!!r;return}e.setAttribute("checked",String(r));return;default:return en(e,Jt(t),r)}}function nn(e,t){if(t==null||typeof t=="boolean"){e.innerHTML="";return}e.innerHTML=String(t)}function on(e,t){let r=J(t);if(!r)return e.removeAttribute("class");e.setAttribute("class",r)}function sn(e,t,r){if(Wt(e,"style",t))return;if(typeof t=="string"){e.setAttribute("style",t);return}let n={};typeof r=="string"?e.setAttribute("style",""):typeof r=="object"&&r&&(n=r);let o=t;new Set([...Object.keys(n),...Object.keys(o)]).forEach(s=>{let a=n[s],u=o[s];if(a!==u){if(u===void 0){e.style[s]="";return}e.style[s]=u}})}function an(e){let t=e.parent,r=t?.dom;for(;t&&!r;)t=t.parent,r=t?.dom;if(!r||!t){if(!e.parent&&e.dom)return e;throw new k({message:"No DOM parent found while attempting to place node.",vNode:e})}return t}function ln(e,t){let{node:r,lastChild:n}=t,o=e.dom;if(n){n.after(o);return}let i=Gt(e,r);if(i){r.dom.insertBefore(o,i);return}r.dom.appendChild(o)}function Gt(e,t){let r=e;for(;r;){let n=r.sibling;for(;n;){if(!(n.flags&(L|I))){let o=un(n);if(o?.isConnected)return o}n=n.sibling}if(r=r.parent,!r||r.flags&I||r===t)return}}function un(e){let t=e;for(;t;){if(t.dom)return t.dom;if(t.flags&I)return;t=t.child}}function qt(e){if(M.current==="hydrate")return Q(e,be);let t={node:e.dom?e:an(e)};st(e,t,(e.flags&L)>0),e.dom&&!(e.flags&I)&&Xt(e,t,!1),be(e)}function st(e,t,r){let n=e.child;for(;n;){if(n.flags&we){n.flags&L&&cn(n,t),be(n),n=n.sibling;continue}n.dom?(st(n,{node:n},!1),n.flags&I||Xt(n,t,r)):st(n,t,(n.flags&L)>0||r),be(n),n=n.sibling}}function Xt(e,t,r){(r||!e.dom.isConnected||e.flags&L)&&ln(e,t),(!e.prev||e.flags&P)&&Kt(e),t.lastChild=e.dom}function Yt(e){e===e.parent?.child&&(e.parent.child=e.sibling);let t;l&&(t=N(e)),Q(e,r=>{let{hooks:n,subs:o,cleanups:i,dom:s,props:{ref:a}}=r;for(o?.forEach(u=>u()),i&&Object.values(i).forEach(u=>u());n?.length;)try{n.pop().cleanup?.()}catch{}l&&(window.__kiru.profilingContext?.emit("removeNode",t),s instanceof Element&&delete s.__kiruNode),s&&(s.isConnected&&!(r.flags&I)&&s.remove(),a&&Me(a,null),delete r.dom)}),e.parent=null}function cn(e,t){if(!e.child)return;let r=[];if(Zt(e.child,r),r.length===0)return;let{node:n,lastChild:o}=t;if(o)o.after(...r);else{let i=Gt(e,n),s=n.dom;i?i.before(...r):s.append(...r)}t.lastChild=r[r.length-1]}function Zt(e,t){let r=e;for(;r;)r.dom?t.push(r.dom):r.child&&Zt(r.child,t),r=r.sibling}function m(e,t=null,...r){e===ue&&(e=T);let n=t===null?{}:t,o=lt(n.key),i=r.length;return i===1?n.children=r[0]:i>1&&(n.children=r),{type:e,key:o,props:n}}function ue({children:e,key:t}){return{type:T,key:lt(t),props:{children:e}}}function ut(e){return typeof e=="function"&&typeof e[_e]?.arePropsEqual=="function"}function Re(e,t=null,r={},n=null,o=0){e===ue&&(e=T);let i=t?t.depth+1:0;return{type:e,key:n,props:r,parent:t,index:o,depth:i,flags:0,child:null,sibling:null,prev:null,deletions:null}}var pt;function Pe(e,t){return l&&(pt=N(e)),Array.isArray(t)?(l&&(ir in t&&gn(e,t),mn(e,t)),pn(e,t)):fn(e,t)}function fn(e,t){let r=e.child;if(r===null)return rr(e,t);let n=r.sibling,o=er(e,r,t);if(o!==null)return r&&r!==o&&!o.prev?ft(e,r):n&&ft(e,n),o;{let i=sr(r),s=nr(i,e,0,t);if(s!==null){let a=s.prev;if(a!==null){let u=a.key;i.delete(u===null?a.index:u)}De(s,0,0)}return i.forEach(a=>Oe(e,a)),s}}function pn(e,t){let r=null,n=null,o=e.child,i=null,s=0,a=0;for(;o!==null&&a<t.length;a++){o.index>a?(i=o,o=null):i=o.sibling;let c=er(e,o,t[a]);if(c===null){o===null&&(o=i);break}o&&!c.prev&&Oe(e,o),s=De(c,s,a),n===null?r=c:n.sibling=c,n=c,o=i}if(a===t.length)return ft(e,o),r;if(o===null){for(;a<t.length;a++){let c=rr(e,t[a]);c!==null&&(s=De(c,s,a),n===null?r=c:n.sibling=c,n=c)}return r}let u=sr(o);for(;a<t.length;a++){let c=nr(u,e,a,t[a]);if(c!==null){let d=c.prev;if(d!==null){let p=d.key;u.delete(p===null?d.index:p)}s=De(c,s,a),n===null?r=c:n.sibling=c,n=c}}return u.forEach(c=>Oe(e,c)),r}function er(e,t,r){let n=t===null?null:t.key;return Le(r)?n!==null||t?.type==="#text"&&b.isSignal(t.props.nodeValue)?null:Qt(e,t,""+r):b.isSignal(r)?t&&t.props.nodeValue!==r?null:Qt(e,t,r):pe(r)?r.key!==n?null:dn(e,t,r):Array.isArray(r)?n!==null?null:(l&&dt(r),tr(e,t,r)):null}function Qt(e,t,r){return t===null||t.type!=="#text"?B(e,"#text",{nodeValue:r}):(l&&ye(),t.props.nodeValue!==r&&(t.props.nodeValue=r,t.flags|=P),t.sibling=null,t)}function dn(e,t,r){let{type:n,props:o,key:i}=r;return l&&typeof n=="function"&&(n=_(n)),n===T?tr(e,t,o.children||[],o):t?.type===n?(l&&ye(),t.index=0,t.sibling=null,typeof n=="string"?or(t.props,o)&&(t.flags|=P):t.flags|=P,t.props=o,t):B(e,n,o,i)}function tr(e,t,r,n={}){return t===null||t.type!==T?B(e,T,{children:r,...n}):(l&&ye(),t.props={...t.props,...n,children:r},t.flags|=P,t.sibling=null,t)}function rr(e,t){return Le(t)?B(e,"#text",{nodeValue:""+t}):b.isSignal(t)?B(e,"#text",{nodeValue:t}):pe(t)?B(e,t.type,t.props,t.key):Array.isArray(t)?(l&&dt(t),B(e,T,{children:t})):null}function De(e,t,r){e.index=r;let n=e.prev;if(n!==null){let o=n.index;return o<t?(e.flags|=L,t):o}else return e.flags|=L,t}function nr(e,t,r,n){if(b.isSignal(n)||Le(n)){let i=e.get(r);if(i){if(i.props.nodeValue===n)return i;i.type==="#text"&&b.isSignal(i.props.nodeValue)&&i.cleanups?.nodeValue?.()}return B(t,"#text",{nodeValue:n},null,r)}if(pe(n)){let{type:i,props:s,key:a}=n,u=e.get(a===null?r:a);return u?.type===i?(l&&ye(),typeof i=="string"?or(u.props,s)&&(u.flags|=P):u.flags|=P,u.props=s,u.sibling=null,u.index=r,u):B(t,i,s,a,r)}if(Array.isArray(n)){let i=e.get(r);return l&&dt(n),i?(l&&ye(),i.flags|=P,i.props.children=n,i):B(t,T,{children:n},null,r)}return null}function or(e,t){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!0;for(let o of r)if(!(o==="children"||o==="key")&&e[o]!==t[o])return!0;return!1}function ye(){"window"in globalThis&&window.__kiru.profilingContext?.emit("updateNode",pt)}var ir=Symbol("kiru:marked-list-child");function dt(e){Object.assign(e,{[ir]:!0})}function sr(e){let t=new Map;for(;e;){let r=e.key;t.set(r===null?e.index:r,e),e=e.sibling}return t}function Oe(e,t){e.deletions===null?e.deletions=[t]:e.deletions.push(t)}function ft(e,t){for(;t;)Oe(e,t),t=t.sibling}function mn(e,t){let r=new Set,n=!1;for(let o of t){if(!pe(o))continue;let i=o.key;if(typeof i=="string"){if(!n&&r.has(i)){let s=lr(e);ar(\`\${s} component produced a child in a list with a duplicate key prop: "\${i}". Keys should be unique so that components maintain their identity across updates\`),n=!0}r.add(i)}}}function gn(e,t){let r=!1,n=!1;for(let o of t)pe(o)&&(typeof o.key=="string"?r=!0:n=!0);if(n&&r){let o=lr(e);ar(\`\${o} component produced a child in a list without a valid key prop\`)}}function ar(e){let t=\`[kiru]: \${e}. See https://kirujs.dev/keys-warning for more information.\`;console.error(t)}var ct=new WeakMap;function lr(e){if(ct.has(e))return ct.get(e);let t=e.parent,r;for(;!r&&t;)typeof t.type=="function"&&(r=t.type),t=t.parent;let n=\`<\${r?.displayName||r?.name||"Anonymous Function"} />\`;return ct.set(e,n),n}function B(e,t,r,n=null,o=0){let i=Re(t,e,r,n,o);return i.flags|=L,typeof t=="function"&&ut(t)&&(i.flags|=Ce,i.arePropsEqual=t[_e].arePropsEqual),l&&"window"in globalThis&&window.__kiru.profilingContext?.emit("createNode",pt),i}var W,G=[],de=!1,gt=[],Ve=[],ht=!1,wt=!1,bt=!1,yt=0,ur=[],vt=[],cr=-1;function $e(e){if(!e)return new Promise($e);if(de){gt.push(e);return}e()}function Ie(){de&&(window.cancelAnimationFrame(cr),fr())}function Et(e){e.flags|=ae,G.push(e),de=!0,Ie()}function O(e){if(M.current==="hydrate")return $e(()=>xt(e));xt(e)}function hn(){de||(de=!0,cr=window.requestAnimationFrame(fr))}function wn(){for(de=!1;gt.length;)gt.shift()()}function xt(e){if(ht&&(wt=!0),C.current===e){l&&window.__kiru.profilingContext?.emit("updateDirtied",W),bt=!0;return}if(!(e.flags&(ae|fe))){if(e.flags|=ae,!G.length)return G.push(e),hn();G.push(e)}}function bn(e){Q(e,t=>t.flags|=fe),Ve.push(e)}var yn=(e,t)=>t.depth-e.depth,re=null;function fr(){if(l){let t=Ve[0]??G[0];t?(W=N(t),window.__kiru.profilingContext?.beginTick(W)):W=null}let e=1;for(Ht();G.length;){G.length>e&&G.sort(yn),re=G.shift(),e=G.length;let t=re.flags;if(!(t&fe)&&t&ae){let r=re;for(;r=vn(r););for(;Ve.length;)Yt(Ve.pop());qt(re),re.flags&=~ae}}if(Ft(),ht=!0,mt(ur),ht=!1,wt)return kn(),mt(vt),wt=!1,yt++,l&&(window.__kiru.profilingContext?.endTick(W),window.__kiru.profilingContext?.emit("updateDirtied",W)),Ie();yt=0,wn(),mt(vt),l&&(window.__kiru.emit("update",W),window.__kiru.profilingContext?.emit("update",W),window.__kiru.profilingContext?.endTick(W))}function vn(e){let t=!0;try{typeof e.type=="string"?Sn(e):St(e.type)?xn(e):t=En(e)}catch(n){l&&window.__kiru.emit("error",W,n instanceof Error?n:new Error(String(n)));let o=pr(e);if(o){let i=o.error=n instanceof Error?n:new Error(String(n));return o.props.onError?.(i),o.depth<re.depth&&(re=o),o}if(k.isKiruError(n)){if(n.customNodeStack&&setTimeout(()=>{throw new Error(n.customNodeStack)}),n.fatal)throw n;console.error(n);return}setTimeout(()=>{throw n})}if(e.deletions!==null&&(e.deletions.forEach(bn),e.deletions=null),t&&e.child)return e.child;let r=e;for(;r;){if(r.immediateEffects&&(ur.push(...r.immediateEffects),r.immediateEffects=void 0),r.effects&&(vt.push(...r.effects),r.effects=void 0),r===re)return;if(r.sibling)return r.sibling;r=r.parent,M.current==="hydrate"&&r?.dom&&te.pop()}}function xn(e){let{props:t,type:r}=e,n=t.children;if(r===ie){let{props:{dependents:o,value:i},prev:s}=e;o.size&&s&&s.props.value!==i&&o.forEach(xt)}else if(r===se){let o=e,{error:i}=o;i&&(n=typeof t.fallback=="function"?t.fallback(i):t.fallback,delete o.error)}e.child=Pe(e,n)}function En(e){let{type:t,props:r,subs:n,prev:o,flags:i}=e;if(i&Ce){if(e.memoizedProps=r,o?.memoizedProps&&e.arePropsEqual(o.memoizedProps,r)&&!e.hmrUpdated)return e.flags|=we,!1;e.flags&=~we}try{C.current=e;let s,a=0;do{if(e.flags&=~ae,bt=!1,Z.current=0,n&&(n.forEach(u=>u()),n.clear()),l){if(s=_(t)(r),e.hmrUpdated&&e.hooks&&e.hookSig){let u=e.hooks.length;if(Z.current<u){for(let c=Z.current;c<u;c++)e.hooks[c].cleanup?.();e.hooks.length=Z.current,e.hookSig.length=Z.current}}if(delete e.hmrUpdated,++a>Qe)throw new k({message:"Too many re-renders. Kiru limits the number of renders to prevent an infinite loop.",fatal:!0,vNode:e});continue}s=t(r)}while(bt);return e.child=Pe(e,s),!0}finally{C.current=null}}function Sn(e){let{props:t,type:r}=e;l&&kt(e),e.dom||(M.current==="hydrate"?Bt(e):e.dom=zt(e),l&&e.dom instanceof Element&&(e.dom.__kiruNode=e)),r!=="#text"&&(e.child=Pe(e,t.children),e.child&&M.current==="hydrate"&&te.push(e.dom))}function kn(){if(yt>Qe)throw new k("Maximum update depth exceeded. This can happen when a component repeatedly calls setState during render or in useLayoutEffect. Kiru limits the number of nested updates to prevent infinite loops.")}function mt(e){for(let t=0;t<e.length;t++)e[t]();e.length=0}var dr;(function(e){e.Start="start",e.End="end"})(dr||(dr={}));var me=null,mr=new Set;function h(e,t,r){let n=_n(e);if(l&&me!==null&&!mr.has(e+me))throw mr.add(e+me),new k({message:\`Nested primitive "useHook" calls are not supported. "\${e}" was called inside "\${me}". Strange will most certainly happen.\`,vNode:n});let o=(a,u)=>{if(u?.immediate){(n.immediateEffects??(n.immediateEffects=[])).push(a);return}(n.effects??(n.effects=[])).push(a)},i=Z.current++,s=n.hooks?.at(i);if(l){me=e,n.hooks??(n.hooks=[]),n.hookSig??(n.hookSig=[]),n.hookSig[i]?n.hookSig[i]!==e&&(console.warn(\`[kiru]: hooks must be called in the same order. Hook "\${e}" was called in place of "\${n.hookSig[i]}". Strange things may happen.\`),s?.cleanup?.(),n.hooks.length=i,n.hookSig.length=i,s=void 0):n.hookSig[i]=e;let a;s?a=s:(a=typeof t=="function"?t():{...t},a.name=e),n.hooks[i]=a;try{return r({hook:a,isInit:!s,isHMR:n.hmrUpdated,update:()=>O(n),queueEffect:o,vNode:n,index:i})}catch(u){throw u}finally{me=null}}try{let a=s??(typeof t=="function"?t():{...t});return n.hooks??(n.hooks=[]),n.hooks[i]=a,r({hook:a,isInit:!s,update:()=>O(n),queueEffect:o,vNode:n,index:i})}catch(a){throw a}}function _n(e){let t=C.current;if(!t)throw new k(\`Hook "\${e}" must be used at the top level of a component or inside another composite hook.\`);return t}function q(e){e.cleanup&&(e.cleanup(),e.cleanup=void 0)}function A(e,t){return e===void 0||t===void 0||e.length!==t.length||e.length>0&&t.some((r,n)=>!Object.is(r,e[n]))}var ve={stack:new Array,current:function(){return this.stack[this.stack.length-1]}},H=new Map,F=new Map;var gr,b=class e{constructor(t,r){this[gr]=!0,this.$id=He(),this.$value=t,r&&(this.displayName=r),l?(F.set(this.$id,new Set),this.$initialValue=_t(t),this[Y]={provide:()=>this,inject:n=>{F.get(this.$id)?.clear?.(),F.delete(this.$id),this.$id=n.$id,n.__next=this,this.$initialValue===n.$initialValue?this.$value=n.$value:this.notify()},destroy:()=>{}}):this.$subs=new Set}get value(){if(this.onBeforeRead?.(),l){let t=_(this);return e.entangle(t),t.$value}return e.entangle(this),this.$value}set value(t){if(l){let r=_(this);if(Object.is(r.$value,t))return;r.$prevValue=r.$value,r.$value=t,r.notify();return}Object.is(this.$value,t)||(this.$prevValue=this.$value,this.$value=t,this.notify())}peek(){return this.onBeforeRead?.(),l?_(this).$value:this.$value}sneak(t){if(l){let r=_(this);r.$prevValue=r.$value,r.$value=t;return}this.$prevValue=this.$value,this.$value=t}toString(){if(this.onBeforeRead?.(),l){let t=_(this);return e.entangle(t),\`\${t.$value}\`}return e.entangle(this),\`\${this.$value}\`}subscribe(t){return l?(F.get(this.$id).add(t),()=>F.get(this.$id)?.delete(t)):(this.$subs.add(t),()=>this.$subs.delete(t))}notify(t){if(l)return F.get(this.$id)?.forEach(r=>{if(t&&!t(r))return;let{$value:n,$prevValue:o}=_(this);return r(n,o)});this.$subs.forEach(r=>{if(!(t&&!t(r)))return r(this.$value,this.$prevValue)})}static isSignal(t){return typeof t=="object"&&!!t&&Ye in t}static subscribers(t){return l?F.get(t.$id):t.$subs}static makeReadonly(t){let r=Object.getOwnPropertyDescriptor(t,"value");return r&&!r.writable?t:Object.defineProperty(t,"value",{get:function(){return e.entangle(this),this.$value},configurable:!0})}static makeWritable(t){let r=Object.getOwnPropertyDescriptor(t,"value");return r&&r.writable?t:Object.defineProperty(t,"value",{get:function(){return e.entangle(this),this.$value},set:function(n){this.$value=n,this.notify()},configurable:!0})}static entangle(t){let r=C.current,n=ve.current();if(n){(!r||r&&g())&&n.set(t.$id,t);return}if(!r||!g())return;let o=t.subscribe(()=>O(r));(r.subs??(r.subs=new Set)).add(o)}static configure(t,r){t.onBeforeRead=r}static dispose(t){if(t.$isDisposed=!0,l){F.delete(t.$id);return}t.$subs.clear()}};gr=Ye;var Ne=(e,t)=>new b(e,t),x=(e,t)=>h("useSignal",{signal:null},({hook:r,isInit:n,isHMR:o})=>{if(l&&(n&&(r.dev={devtools:{get:()=>({displayName:r.signal.displayName,value:r.signal.peek()}),set:({value:i})=>{r.signal.value=i}},initialArgs:[e,t]}),o)){let[i,s]=r.dev.initialArgs;(i!==e||s!==t)&&(r.cleanup?.(),n=!0,r.dev.initialArgs=[e,t])}return n&&(r.cleanup=()=>b.dispose(r.signal),r.signal=new b(e,t)),r.signal});function J(e,t=!1){return b.isSignal(e)?t?e.value:e.peek():e}var Ct=()=>{H.forEach(e=>e()),H.clear()};var hr=new Set(["children","ref","key","innerHTML"]),Te={isInternalProp:e=>hr.has(e),isEvent:e=>e.startsWith("on"),isStringRenderableProperty:e=>!hr.has(e)&&!Te.isEvent(e)};function Jt(e){switch(e){case"className":return"class";case"htmlFor":return"for";case"tabIndex":case"formAction":case"formMethod":case"formEncType":case"contentEditable":case"spellCheck":case"allowFullScreen":case"autoPlay":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"noModule":case"noValidate":case"popoverTarget":case"popoverTargetAction":case"playsInline":case"readOnly":case"itemscope":case"rowSpan":case"crossOrigin":return e.toLowerCase();default:return e.indexOf("-")>-1?e:e.startsWith("aria")?"aria-"+e.substring(4).toLowerCase():Lt.get(e)||e}}function _t(e,t={functions:!0}){let r=new WeakSet;return JSON.stringify(e,(n,o)=>{if(typeof o=="object"&&o!==null){if(r.has(o))return"[CIRCULAR]";r.add(o)}return typeof o=="function"?t.functions?o.toString():\`[FUNCTION (\${o.name||"anonymous"})]\`:o})}var Cn="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-";function He(e=10,t=Cn){let r="";for(let n=0;n<e;n++)r+=t[Math.random()*t.length|0];return r}var U=Object.freeze(()=>{});function _(e){let t=e;if(l)for(;"__next"in t;)t=t.__next;return t}function Me(e,t){if(typeof e=="function"){e(t);return}if(b.isSignal(e)){e.value=t;return}e.current=t}function g(){return M.current==="dom"||M.current==="hydrate"}function pe(e){return typeof e=="object"&&e!==null&&"type"in e}function Le(e){return typeof e=="string"&&e!==""||typeof e=="number"||typeof e=="bigint"}function St(e){return e===T||e===ie||e===se}function wr(e){return e.type===T}function N(e){let t=e;for(;t;){if(t.app)return e.app=t.app;t=t.parent}return null}function be(e){let{props:{children:t,...r},key:n,memoizedProps:o,index:i}=e;e.prev={props:r,key:n,memoizedProps:o,index:i},e.flags&=~(P|L|fe)}function br(e,t){if(t.depth<e.depth)return!1;if(e===t)return!0;let r=!1,n=[e];for(;n.length;){let o=n.pop();if(o===t)return!0;o.child&&n.push(o.child),r&&o.sibling&&n.push(o.sibling),r=!0}return!1}function Q(e,t){t(e);let r=e.child;for(;r;)t(r),r.child&&Q(r,t),r=r.sibling}function rt(e,t){let r=e.parent;for(;r;){if(t(r))return r;r=r.parent}return null}function pr(e){return rt(e,t=>t.type===se)}function kt(e){if("children"in e.props&&e.props.innerHTML)throw new k({message:"Cannot use both children and innerHTML on an element",vNode:e});for(let t in e.props)if("bind:"+t in e.props)throw new k({message:\`Cannot use both bind:\${t} and \${t} on an element\`,vNode:e})}function lt(e){return e===void 0?null:typeof e=="string"||typeof e=="number"?e:null}function Fe(e){let{id:t,subs:r,fn:n,deps:o=[],onDepChanged:i}=e,s;H.delete(t);let a=!!C.current&&!g();a||(s=new Map,ve.stack.push(s));let u=n(...o.map(c=>c.value));if(!a){for(let[d,p]of r)s.has(d)||(p(),r.delete(d));let c=()=>{H.size||queueMicrotask(Ct),H.set(t,i)};for(let[d,p]of s){if(r.has(d))continue;let v=p.subscribe(c);r.set(d,v)}ve.stack.pop()}return u}var ge=class e extends b{constructor(t,r){if(super(void 0,r),this.$getter=t,this.$unsubs=new Map,this.$isDirty=!0,l){let n=this[Y].inject;this[Y]={provide:()=>this,inject:o=>{n(o),e.stop(o),this.$isDirty=o.$isDirty},destroy:()=>{}}}b.configure(this,()=>{this.$isDirty&&(l&&this.$isDisposed||e.run(this))})}get value(){return super.value}set value(t){}subscribe(t){return this.$isDirty&&e.run(this),super.subscribe(t)}static dispose(t){e.stop(t),b.dispose(t)}static updateGetter(t,r){let n=_(t);n.$getter=r,n.$isDirty=!0,e.run(n),!Object.is(n.$value,n.$prevValue)&&n.notify()}static stop(t){let{$id:r,$unsubs:n}=_(t);H.delete(r),n.forEach(o=>o()),n.clear(),t.$isDirty=!0}static run(t){let r=_(t),{$id:n,$getter:o,$unsubs:i}=r,s=Fe({id:n,subs:i,fn:()=>o(r.$value),onDepChanged:()=>{if(r.$isDirty=!0,l){if(!F?.get(n)?.size)return}else if(!t.$subs.size)return;e.run(r),!Object.is(r.$value,r.$prevValue)&&r.notify()}});r.sneak(s),r.$isDirty=!1}};function yr(e,t){return new ge(e,t)}function At(e,t,r){return h("useComputedSignal",{signal:null,deps:void 0},({hook:n,isInit:o,isHMR:i})=>(l&&(n.dev={devtools:{get:()=>({displayName:n.signal.displayName,value:n.signal.peek()})}},i&&(n.cleanup?.(),o=!0)),o?(typeof t=="string"&&(r=t,t=void 0),n.deps=t,n.cleanup=()=>ge.dispose(n.signal),n.signal=yr(e,r)):n.deps&&typeof t!="string"&&A(n.deps,t)&&(n.deps=t,ge.updateGetter(n.signal,e)),n.signal))}var xe=class e{constructor(t,r){if(this.id=He(),this.getter=t,this.deps=r,this.unsubs=new Map,this.isRunning=!1,this.cleanup=null,l&&"window"in globalThis){let n=window.__kiru.HMRContext.signals;n.isWaitingForNextWatchCall()&&n.pushWatch(this)}this.start()}start(){if(!this.isRunning){if(this.isRunning=!0,l&&"window"in globalThis&&window.__kiru.HMRContext?.isReplacement())return queueMicrotask(()=>{this.isRunning&&e.run(this)});e.run(this)}}stop(){H.delete(this.id),this.unsubs.forEach(t=>t()),this.unsubs.clear(),this.cleanup?.(),this.cleanup=null,this.isRunning=!1}static run(t){let r=_(t),{id:n,getter:o,unsubs:i,deps:s}=r;r.cleanup=Fe({id:n,subs:i,fn:o,deps:s,onDepChanged:()=>{r.cleanup?.(),e.run(r)}})??null}};function vr(e,t){if(typeof e=="function")return new xe(e);let r=e,n=t;return new xe(n,r)}function Ee(e,t){if(g())return h("useWatch",{watcher:null},({hook:r,isInit:n,isHMR:o})=>{if(l&&o&&(r.cleanup?.(),n=!0),n){let i=r.watcher=vr(e,t);r.cleanup=()=>i.stop()}return r.watcher})}var An=0;function xr(e,t,r){if(l&&t.__kiruNode)throw new Error("[kiru]: container in use - call unmount on the previous app first.");let n=Tn(t),o=An++,i={id:o,name:r?.name??\`App-\${o}\`,rootNode:n,render:s,unmount:a};function s(u){n.props.children=u,Et(n)}function a(){n.props.children=null,Et(n),l&&(delete t.__kiruNode,delete n.app),window.__kiru.emit("unmount",i)}return l&&(n.app=i),s(e),window.__kiru.emit("mount",i,O),l&&queueMicrotask(()=>{window.dispatchEvent(new Event("kiru:ready"))}),i}function Tn(e){let t=Re(e.nodeName.toLowerCase());return t.flags|=I,t.dom=e,l&&(e.__kiruNode=t),t}function ce(e){return g()?h("useState",{state:void 0,dispatch:U},({hook:t,isInit:r,update:n,isHMR:o})=>{if(l&&(r&&(t.dev={devtools:{get:()=>({value:t.state}),set:({value:i})=>t.state=i},initialArgs:[e]}),o)){let[i]=t.dev.initialArgs;i!==e&&(r=!0,t.dev.initialArgs=[e])}return r&&(t.state=typeof e=="function"?e():e,t.dispatch=i=>{let s=typeof i=="function"?i(t.state):i;Object.is(t.state,s)||(t.state=s,n())}),[t.state,t.dispatch]}):[typeof e=="function"?e():e,U]}function Er(e){let t={[Dt]:!0,Provider:({value:r,children:n})=>{let[o]=ce(()=>new Set);return m(ie,{value:r,ctx:t,dependents:o},typeof n=="function"?n(r):n)},default:()=>e,set displayName(r){this.Provider.displayName=r},get displayName(){return this.Provider.displayName||"Anonymous Context"}};if(l){let r=t;r[Y]={inject:n=>{let o=t.Provider;window.__kiru.apps.forEach(i=>{Q(i.rootNode,s=>{s.type===n.Provider&&(s.type=o,s.hmrUpdated=!0,O(s))})})},destroy:()=>{},provide:()=>t}}return t}function ee(e,t){return g()?h("useCallback",{callback:e,deps:t},({hook:r,isHMR:n})=>(l&&(r.dev={devtools:{get:()=>({callback:r.callback,dependencies:r.deps})}},n&&(r.deps=[])),A(t,r.deps)&&(r.deps=t,r.callback=e),r.callback)):e}function z(e,t){if(g())return h("useEffect",{deps:t},({hook:r,isInit:n,isHMR:o,queueEffect:i})=>{l&&(r.dev={devtools:{get:()=>({callback:e,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,q(r),i(()=>{let s=e();typeof s=="function"&&(r.cleanup=s)}))})}function ne(e,t){if(g())return h("useLayoutEffect",{deps:t},({hook:r,isInit:n,isHMR:o,queueEffect:i})=>{l&&(r.dev={devtools:{get:()=>({callback:e,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,q(r),i(()=>{let s=e();typeof s=="function"&&(r.cleanup=s)},{immediate:!0}))})}function Se(e,t){return g()?h("useMemo",{deps:t,value:void 0},({hook:r,isInit:n,isHMR:o})=>(l&&(r.dev={devtools:{get:()=>({value:r.value,dependencies:r.deps})}},o&&(n=!0)),(n||A(t,r.deps))&&(r.deps=t,r.value=e()),r.value)):e()}function V(e){return g()?h("useRef",{ref:{current:e}},({hook:t,isInit:r,isHMR:n})=>{if(l&&(r&&(t.dev={devtools:{get:()=>({value:t.ref.current}),set:({value:o})=>t.ref.current=o},initialArgs:[t.ref.current]}),n)){let[o]=t.dev.initialArgs;o!==e&&(t.ref={current:e},t.dev.initialArgs=[e])}return t.ref}):{current:e}}var nl=Symbol("no value");var ul="window"in globalThis?window.__KIRU_LAZY_CACHE??(window.__KIRU_LAZY_CACHE=new Map):new Map;function _r(e){let[t,r]=ce(e.initialState||"exited"),n=V(null);ne(()=>{e.in&&t!=="entered"&&t!=="entering"?(o("entering"),i("entered")):!e.in&&t!=="exited"&&t!=="exiting"&&(o("exiting"),i("exited"))},[e.in,t]),z(()=>()=>kr(n.current),[]);let o=ee(s=>{kr(n.current),r(s),(s==="entered"||s==="exited")&&e.onTransitionEnd&&e.onTransitionEnd(s)},[]),i=ee(s=>{n.current=window.setTimeout(()=>o(s),Dn(s,e.duration))},[e.duration]);return e.element(t)}var Sr=150;function Dn(e,t){if(typeof t=="number")return t;switch(e){case"entered":return t?.in??Sr;case"exited":return t?.out??Sr}}function kr(e){e!=null&&window.clearTimeout(e)}"window"in globalThis;var Cr=()=>m("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},m("path",{d:"M8.5 14.5A2.5 2.5 0 0 0 11 12c0-1.38-.5-2-1-3-1.072-2.143-.224-4.054 2-6 .5 2.5 2 4.9 4 6.5 2 1.6 3 3.5 3 5.5a7 7 0 1 1-14 0c0-1.153.433-2.294 1-3a2.5 2.5 0 0 0 2.5 2.5z"}));var ze="kiru.devtools.anchorPosition",Ar={x:-16,y:-16};var Tt=(e,t,r)=>{if(!t.current)return{...Ar};let n=window.innerWidth/e.width,o=window.innerHeight/e.height,i=null,s=null;return e.snapSide==="left"?i=(t.current.offsetWidth-r.width.value)*-1+16:e.snapSide==="right"?i=-16:e.snapSide==="bottom"?s=-16:e.snapSide==="top"&&(s=(window.innerHeight-r.height.value)*-1+16),{x:i??e.x*n,y:s??e.y*o}},Tr=e=>{if(e==null)return null;let t=null,r=e?.__kiruNode?.parent;for(;r;){if(typeof r.type=="function"&&!wr(r)){t=r;break}r=r.parent}return t},Mr=(e,t)=>{let r=[],n=[t.__kiruNode];for(;n.length;){let i=n.pop();if(i===e)break;i?.dom&&r.push(i),i?.parent&&n.push(i.parent)}if(r.length===0)return;let o=r[r.length-1].dom;return o instanceof Element?o:void 0};function je(e,t){if(!e)throw new Error(t)}var Dr={arrayChunkSize:10,objectKeysChunkSize:100};function Or(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let n in r)if(typeof t[n]!=typeof e[n]||typeof e[n]=="object"&&!Or(e[n],t[n]))return!1;return!0}var Ln={...Dr},Rr=localStorage.getItem("kiru.devtools.userSettings");if(Rr)try{let e=JSON.parse(Rr);Or(Dr,e)&&(Ln=e)}catch(e){console.error("kiru.devtools.userSettings error",e)}var nc=Er({userSettings:null,saveUserSettings:()=>{}});var fc=Object.freeze(()=>{});var In="kiru-devtools";"window"in globalThis&&(window.__devtoolsSelection??(window.__devtoolsSelection=null),window.__devtoolsNodeUpdatePtr??(window.__devtoolsNodeUpdatePtr=null));var Mt=class extends BroadcastChannel{send(t){super.postMessage(t)}removeEventListener(t){return super.removeEventListener("message",t)}addEventListener(t){return super.addEventListener("message",t)}},R=new Mt(In);var Vc=Symbol.for("devtools.hookGroup");var $=(e,t,r={})=>{z(()=>{let n=window,o=r?.ref?.();return o?n=o:r.ref&&console.warn("useEventListener ref failed, using window"),n.addEventListener(e,t,r),()=>{n.removeEventListener(e,t,r)}},[t])};var Ke=()=>{let e=x({x:0,y:0}),t=x({x:0,y:0}),r=x({x:0,y:0});return $("mousemove",n=>{e.value={x:n.x,y:n.y},t.value={x:n.movementX,y:n.movementY},r.value={x:n.clientX,y:n.clientY}}),{mouse:e,delta:t,client:r}};var Ue="window"in globalThis&&"ResizeObserver"in globalThis.window,Pr=(e,t,r=void 0)=>g()?Ue?h("useResizeObserver",{resizeObserver:null,deps:[e.current]},({isInit:n,hook:o,queueEffect:i})=>(n&&(o.resizeObserver=new ResizeObserver(t),o.cleanup=()=>{o.resizeObserver?.disconnect?.(),o.resizeObserver=null}),i(()=>{A([e.current],o.deps)&&(o.deps=[e.current],o.resizeObserver?.disconnect?.(),e.current&&o.resizeObserver?.observe(e.current,r))}),{isSupported:Ue,start:()=>{o.resizeObserver==null&&(o.resizeObserver=new ResizeObserver(t),e.current&&o.resizeObserver.observe(e.current,r),o.cleanup=()=>{o.resizeObserver?.disconnect?.(),o.resizeObserver=null})},stop:()=>{q(o)}})):{isSupported:Ue,start:()=>{},stop:()=>{}}:{isSupported:Ue,start:()=>{},stop:()=>{}};var Be="window"in globalThis&&"MutationObserver"in globalThis.window,Lr=(e,t,r=void 0)=>g()?Be?h("useMutationObserver",{mutationObserver:null,deps:[e.current]},({isInit:n,hook:o,queueEffect:i})=>(n?(i(()=>{o.deps=[e.current],o.mutationObserver=new MutationObserver(t),e.current&&o.mutationObserver.observe(e.current,r)}),o.cleanup=()=>{o.mutationObserver?.disconnect?.(),o.mutationObserver=null}):A([e.current],o.deps)&&(o.deps=[e.current],o.mutationObserver?.disconnect?.(),e.current&&o.mutationObserver?.observe(e.current,r)),{isSupported:Be,start:()=>{o.mutationObserver==null&&(o.mutationObserver=new MutationObserver(t),e.current&&o.mutationObserver.observe(e.current,r),o.cleanup=()=>{o.mutationObserver?.disconnect?.(),o.mutationObserver=null})},stop:()=>{q(o)}})):{isSupported:Be,start:()=>{},stop:()=>{}}:{isSupported:Be,start:()=>{},stop:()=>{}};var We=(e,t={windowScroll:!0,windowResize:!0})=>{let r=t?.windowScroll??!0,n=t?.windowResize??!0,o=t.immediate??!0,i=x(0),s=x(0),a=x(0),u=x(0),c=x(0),d=x(0),p=x(0),v=x(0),f=()=>{let y=e.current;if(!y){i.value=0,s.value=0,a.value=0,u.value=0,c.value=0,d.value=0,p.value=0,v.value=0;return}let E=y.getBoundingClientRect();i.value=E.width,s.value=E.height,a.value=E.top,u.value=E.right,c.value=E.bottom,d.value=E.left,p.value=E.x,v.value=E.y};return Pr(e,f),Lr(e,f,{attributeFilter:["style","class"]}),$("scroll",()=>{r&&f()},{capture:!0,passive:!0}),$("resize",()=>{n&&f()},{passive:!0}),ne(()=>{o&&f()},[]),{width:i,height:s,top:a,right:u,bottom:c,left:d,x:p,y:v,update:f}};var Vr=(e,t)=>{if(!g())return{isActive:t?.immediate??!1,start:()=>null,stop:()=>null};let r=t?.fpsLimit?1e3/t.fpsLimit:null;return h("useRafFn",()=>({callback:e,refId:null,previousFrameTimestamp:0,isActive:t?.immediate??!1,rafLoop:()=>{}}),({isInit:n,hook:o,update:i})=>(o.callback=e,n&&(o.rafLoop=s=>{if(o.isActive===!1)return;o.previousFrameTimestamp||(o.previousFrameTimestamp=s);let a=s-o.previousFrameTimestamp;if(r&&a<r){o.refId=window.requestAnimationFrame(o.rafLoop);return}o.previousFrameTimestamp=s,o.callback({delta:a,timestamp:s}),o.refId=window.requestAnimationFrame(o.rafLoop)}),n&&t?.immediate&&(o.isActive=!0,o.refId=window.requestAnimationFrame(o.rafLoop),o.cleanup=()=>{o.refId!=null&&window.cancelAnimationFrame(o.refId),o.isActive=!1},i()),{isActive:o.isActive,start:()=>{o.isActive!==!0&&(o.isActive=!0,o.refId=window.requestAnimationFrame(o.rafLoop),o.cleanup=()=>{o.refId!=null&&window.cancelAnimationFrame(o.refId),o.isActive=!1},i())},stop:()=>{q(o),i()}}))};var $r=e=>{let{x:t,y:r,multiple:n,immediate:o=!0}=e,i=x(null),a=Vr(()=>{i.value=n?document.elementsFromPoint(t,r)??[]:document.elementFromPoint(t,r)??null},{immediate:o});return{element:i,...a}};var Ir=()=>{let{mouse:e}=Ke(),t=x(null),r=V(null),n=V(null),o=We(r),i=x({x:-16,y:-16}),s=x({x:-16,y:-16}),a=x({width:window.innerWidth,height:window.innerHeight}),u=x("bottom"),c=V(null);ne(()=>{let f=localStorage.getItem(ze);if(f==null)return;let y=JSON.parse(f);a.value.width=window.innerWidth,a.value.height=window.innerHeight,u.value=y.snapSide,s.value=Tt(y,n,o)},[]);let d=At(()=>{let{x:f,y}=e.value;if(t.value===null)return null;let{x:E,y:K}=t.value;return{x:f-E,y:y-K}});$("dragstart",f=>{f.preventDefault(),t.value={x:f.x,y:f.y},i.value=s.value},{ref:()=>r.current}),$("mouseup",()=>{c.current&&(clearTimeout(c.current),c.current=null),t.peek()&&(t.value=null,localStorage.setItem(ze,JSON.stringify({...s.value,...a.value,snapSide:u.value})))});let p=ee(()=>{if(n.current==null)return;let f=n.current.offsetWidth;if(u.value==="right"){let y=Math.min(-16,s.value.y);s.value={x:-16,y:Math.max(y,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="left"){let y=Math.min(0,s.value.y);s.value={x:(f-o.width.value)*-1+16,y:Math.max(y,(window.innerHeight-o.height.value)*-1+16)}}else if(u.value==="top"){let y=Math.min(-16,s.value.x);s.value={x:Math.max(y,(f-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}else{let y=Math.min(-16,s.value.x);s.value={x:Math.max(y,(f-o.width.value)*-1+16),y:-16}}},[]);Ee([d,e],(f,y)=>{if(f===null||!n.current)return;let{x:E,y:K}=y,S=n.current.offsetWidth,D=K>=window.innerHeight-100,he=K<=100;if(!he&&!D){let oe=E>window.innerWidth/2;u.value=oe?"right":"left"}else u.value=he?"top":"bottom";if(u.value==="right"){let oe=Math.min(-16,i.value.y+f.y);s.value={x:-16,y:Math.max(oe,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="left"){let oe=Math.min(0,i.value.y+f.y);s.value={x:(S-o.width.value)*-1+16,y:Math.max(oe,(window.innerHeight-o.height.value)*-1+16)};return}else if(u.value==="top"){let oe=Math.min(-16,i.value.x+f.x);s.value={x:Math.max(oe,(S-o.width.value)*-1+16),y:(window.innerHeight-o.height.value)*-1+16};return}let Kr=Math.min(-16,i.value.x+f.x);s.value={y:-16,x:Math.max(Kr,(S-o.width.value)*-1+16)}});let v=ee(()=>{n.current!==null&&(s.value=Tt({width:a.value.width,height:a.value.height,x:s.value.x,y:s.value.y,snapSide:u.value},n,o),a.value.width=window.innerWidth,a.value.height=window.innerHeight,localStorage.setItem(ze,JSON.stringify({...s.value,...a.value,snapSide:u.value})))},[Math.round(o.width.value),Math.round(o.height.value)]);return $("resize",v),{anchorRef:r,anchorCoords:s,viewPortRef:n,startMouse:t,elementBound:o,snapSide:u,updateAnchorPos:p}};var j=Ne(!1);"window"in globalThis&&R.addEventListener(e=>{e.data.type==="set-inspect-enabled"&&(j.value=e.data.value)});var X=Ne(null);var Nr="kiru-devtools-popup-size",Ge=()=>{let e=X.value;return ee(()=>new Promise((r,n)=>{if(e)if(e.closed)X.value=null;else return e.focus(),r(e);let o=sessionStorage.getItem(Nr),i=o?JSON.parse(o):{width:Math.floor(Math.min(1920,window.screen.width)/2),height:Math.floor(Math.min(1080,window.screen.height)/2)},s=\`popup,width=\${i.width},height=\${i.height};\`,a=window.open(window.__KIRU_DEVTOOLS_PATHNAME__,"_blank",s);if(!a)return console.error("[kiru]: Unable to open devtools window"),n();let u=c=>{c.data.type==="ready"&&(R.removeEventListener(u),console.debug("[kiru]: devtools window opened"),r(a),X.value=a,a.onbeforeunload=()=>{console.debug("[kiru]: devtools window closed"),X.value=null})};R.addEventListener(u),a.onresize=()=>{sessionStorage.setItem(Nr,JSON.stringify({width:a.innerWidth,height:a.innerHeight}))}}),[e])};var Hr=()=>{let e=Ge(),{mouse:t}=Ke(),r=$r({x:t.value.x,y:t.value.y,immediate:!1}),n=r.element.value,o=j.value?n:null,i=Se(()=>{if(o&&window.__kiru){let c=window.__kiru.apps.find(d=>d.rootNode==null||o.__kiruNode==null?!1:br(d.rootNode,o.__kiruNode));return c?.rootNode==null?null:c}return null},[o]),s=Se(()=>o?Tr(o):null,[o]),a=V(null),u=We(a);return z(()=>j.subscribe(d=>{r[d?"start":"stop"]()}),[]),z(()=>{s&&o?a.current=Mr(s,o)??null:a.current=null},[s,o]),$("click",c=>{if(j.value===!0&&s&&i){c.preventDefault();let d=p=>{p.__devtoolsSelection={node:s,app:i},R.send({type:"select-node"}),R.send({type:"set-inspect-enabled",value:!1}),j.value=!1,a.current=null,p.focus()};X.value?d(X.value):e().then(p=>d(p))}}),s&&m("div",{className:"bg-[crimson]/80 fixed grid place-content-center pointer-events-none z-10 top-0 left-0",style:{width:\`\${u?.width}px\`,height:\`\${u?.height}px\`,transform:\`translate(\${u.x}px, \${u.y}px)\`}},m("p",null,s.type.name))};function Fr(e){return m("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 -960 960 960",fill:"currentColor",...e},m("path",{d:"M710-150q-63 0-106.5-43.5T560-300q0-63 43.5-106.5T710-450q63 0 106.5 43.5T860-300q0 63-43.5 106.5T710-150Zm0-80q29 0 49.5-20.5T780-300q0-29-20.5-49.5T710-370q-29 0-49.5 20.5T640-300q0 29 20.5 49.5T710-230Zm-270-30H200q-17 0-28.5-11.5T160-300q0-17 11.5-28.5T200-340h240q17 0 28.5 11.5T480-300q0 17-11.5 28.5T440-260ZM250-510q-63 0-106.5-43.5T100-660q0-63 43.5-106.5T250-810q63 0 106.5 43.5T400-660q0 63-43.5 106.5T250-510Zm0-80q29 0 49.5-20.5T320-660q0-29-20.5-49.5T250-730q-29 0-49.5 20.5T180-660q0 29 20.5 49.5T250-590Zm510-30H520q-17 0-28.5-11.5T480-660q0-17 11.5-28.5T520-700h240q17 0 28.5 11.5T800-660q0 17-11.5 28.5T760-620Zm-50 320ZM250-660Z"}))}function zr(e){return m("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"lucide lucide-square-mouse-pointer",...e},m("path",{d:"M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"}),m("path",{d:"M21 11V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h6"}))}var Nn=()=>{j.value=!j.value,R.send({type:"set-inspect-enabled",value:j.value})};function Hn(e,t){let{damping:r}=t,n=x(e),o=V(e);return z(()=>{let i=null,s=()=>{if(Math.sqrt(Math.pow(o.current.x-n.value.x,2)+Math.pow(o.current.y-n.value.y,2))<5)return;let u=n.value.x+(o.current.x-n.value.x)*r,c=n.value.y+(o.current.y-n.value.y)*r;n.value={x:u,y:c},i=window.requestAnimationFrame(s)};return i=window.requestAnimationFrame(s),()=>{i!=null&&window.cancelAnimationFrame(i)}},[e.x,e.y]),Object.assign(n,{set:(i,s)=>{o.current=i,s?.hard&&(n.value=i)}})}function Rt(){let e=x(!1),t=Ge(),{anchorCoords:r,anchorRef:n,viewPortRef:o,startMouse:i,snapSide:s}=Ir(),a=s.value==="left"||s.value==="right",u=V(!1),c=Hn(r.value,{damping:.4});return Ee([r],c.set),ne(()=>{u.current===!1&&c.set(r.value,{hard:!0}),u.current=!0},[]),m(ue,null,m("div",{ref:o,className:"w-full h-0 fixed top-0 left-0 z-[-9999] overflow-scroll pointer-events-none"}),m("div",{ref:n,draggable:!0,className:\`flex \${a?"flex-col":""} \${e.value?"rounded-3xl":"rounded-full"} p-1 gap-1 items-center will-change-transform bg-crimson\`,style:{transform:\`translate3d(\${Math.round(c.value.x)}px, \${Math.round(c.value.y)}px, 0)\`}},m(_r,{in:e.value,duration:{in:40,out:150},element:d=>{if(d==="exited")return null;let p=d==="entered"?"1":"0.5",v=d==="entered"?"1":"0";return m(ue,null,m("button",{title:"Open Devtools",onclick:t,style:{transform:\`scale(\${p})\`,opacity:v},className:"transition text-white rounded-full p-1 hover:bg-[#0003]"},m(Fr,{width:16,height:16})),m("button",{title:"Toggle Component Inspection",onclick:Nn,style:{transform:\`scale(\${p})\`,opacity:v},className:\`transition text-white rounded-full p-1 hover:bg-[#0003] \${j.value?"bg-[#0003]":""}\`},m(zr,{width:16,height:16})))}}),m("button",{className:"bg-crimson rounded-full p-1"+(i.value?" pointer-events-none":""),onclick:()=>e.value=!e.value,tabIndex:-1},m(Cr,null))),m(Hr,null))}var jr=\`*, ::before, ::after {
9169
9322
  --tw-border-spacing-x: 0;
9170
9323
  --tw-border-spacing-y: 0;
9171
9324
  --tw-translate-x: 0;
@@ -9932,7 +10085,7 @@ video {
9932
10085
  .focus\\\\:outline:focus {
9933
10086
  outline-style: solid;
9934
10087
  }
9935
- \`;if("window"in globalThis){let e=function(){let t=document.createElement("kiru-devtools");t.setAttribute("style","display: contents"),document.body.appendChild(t);let r=t.attachShadow({mode:"open"}),n=new CSSStyleSheet;n.replaceSync(jr),r.adoptedStyleSheets=[n];let o=Object.assign(document.createElement("div"),{id:"devtools-root",className:"fixed flex bottom-0 right-0 z-[9999999]"});r.appendChild(o),xr(m(Rt,{}),o,{name:"kiru.devtools"});let i=()=>X.value?.close();window.addEventListener("close",i),window.addEventListener("beforeunload",i),R.addEventListener(s=>{switch(s.data.type){case"update-node":{let a=window.__devtoolsNodeUpdatePtr;ze(a,"failed to get node ptr");let u=N(a);ze(u,"failed to get app context");let c=window.__kiru.getSchedulerInterface(u);ze(c,"failed to get scheduler interface"),c.requestUpdate(a),window.__devtoolsNodeUpdatePtr=null;break}case"open-editor":{window.open(s.data.fileLink);break}}})};zn=e,window.addEventListener("kiru:ready",e,{once:!0})}var zn;
10088
+ \`;if("window"in globalThis){let e=function(){let t=document.createElement("kiru-devtools");t.setAttribute("style","display: contents"),document.body.appendChild(t);let r=t.attachShadow({mode:"open"}),n=new CSSStyleSheet;n.replaceSync(jr),r.adoptedStyleSheets=[n];let o=Object.assign(document.createElement("div"),{id:"devtools-root",className:"fixed flex bottom-0 right-0 z-[9999999]"});r.appendChild(o),xr(m(Rt,{}),o,{name:"kiru.devtools"});let i=()=>X.value?.close();window.addEventListener("close",i),window.addEventListener("beforeunload",i),R.addEventListener(s=>{switch(s.data.type){case"update-node":{let a=window.__devtoolsNodeUpdatePtr;je(a,"failed to get node ptr");let u=N(a);je(u,"failed to get app context");let c=window.__kiru.getSchedulerInterface(u);je(c,"failed to get scheduler interface"),c.requestUpdate(a),window.__devtoolsNodeUpdatePtr=null;break}case"open-editor":{window.open(s.data.fileLink);break}}})};zn=e,window.addEventListener("kiru:ready",e,{once:!0})}var zn;
9936
10089
 
9937
10090
  `;
9938
10091
 
@@ -9969,7 +10122,7 @@ function createDevtoolsHtmlTransform(dtClientPathname, dtHostScriptPath) {
9969
10122
  }
9970
10123
 
9971
10124
  // src/dev-server.ts
9972
- import path4 from "node:path";
10125
+ import path5 from "node:path";
9973
10126
  function injectClientScript(html) {
9974
10127
  const scriptTag = `<script type="module" src="/@id/${VIRTUAL_ENTRY_CLIENT_ID}"></script>`;
9975
10128
  if (html.includes("</body>")) {
@@ -9977,12 +10130,12 @@ function injectClientScript(html) {
9977
10130
  }
9978
10131
  return html + scriptTag;
9979
10132
  }
9980
- async function handleSSR(server, url, projectRoot, resolveUserDocument2) {
10133
+ async function handleSSR(server, url, projectRoot2, resolveUserDocument2) {
9981
10134
  const mod = await server.ssrLoadModule(
9982
10135
  VIRTUAL_ENTRY_SERVER_ID
9983
10136
  );
9984
10137
  const moduleIds = [];
9985
- const documentModule = resolveUserDocument2().substring(projectRoot.length);
10138
+ const documentModule = resolveUserDocument2().substring(projectRoot2.length);
9986
10139
  moduleIds.push(documentModule);
9987
10140
  const ctx = {
9988
10141
  registerModule: (moduleId) => {
@@ -10005,7 +10158,7 @@ async function handleSSR(server, url, projectRoot, resolveUserDocument2) {
10005
10158
  }
10006
10159
  };
10007
10160
  for (const id of moduleIds) {
10008
- const p = path4.join(projectRoot, id).replace(/\\/g, "/");
10161
+ const p = path5.join(projectRoot2, id).replace(/\\/g, "/");
10009
10162
  const mod2 = server.moduleGraph.getModuleById(p);
10010
10163
  if (!mod2) {
10011
10164
  console.error(`Module not found: ${p}`);
@@ -10014,7 +10167,7 @@ async function handleSSR(server, url, projectRoot, resolveUserDocument2) {
10014
10167
  scan(mod2);
10015
10168
  }
10016
10169
  const localModules = Array.from(importedModules).filter(
10017
- (m) => m.id?.startsWith(projectRoot)
10170
+ (m) => m.id?.startsWith(projectRoot2)
10018
10171
  );
10019
10172
  const cssModules = localModules.filter((m) => m.id?.endsWith(".css"));
10020
10173
  html = await server.transformIndexHtml(
@@ -10024,7 +10177,7 @@ async function handleSSR(server, url, projectRoot, resolveUserDocument2) {
10024
10177
  );
10025
10178
  if (cssModules.length) {
10026
10179
  const stylesheets = cssModules.map((mod2) => {
10027
- const p = mod2.id?.replace(projectRoot, "");
10180
+ const p = mod2.id?.replace(projectRoot2, "");
10028
10181
  return `<link rel="stylesheet" type="text/css" href="${p}?temp">`;
10029
10182
  });
10030
10183
  html = html.replace("<head>", "<head>" + stylesheets.join("\n"));
@@ -10035,7 +10188,7 @@ async function handleSSR(server, url, projectRoot, resolveUserDocument2) {
10035
10188
  // src/preview-server.ts
10036
10189
  import { resolve } from "node:path";
10037
10190
  import fs2 from "node:fs";
10038
- import path5 from "node:path";
10191
+ import path6 from "node:path";
10039
10192
 
10040
10193
  // ../../node_modules/.pnpm/mime@4.1.0/node_modules/mime/dist/types/other.js
10041
10194
  var types2 = {
@@ -11172,12 +11325,12 @@ var Mime = class {
11172
11325
  }
11173
11326
  return this;
11174
11327
  }
11175
- getType(path8) {
11176
- if (typeof path8 !== "string")
11328
+ getType(path9) {
11329
+ if (typeof path9 !== "string")
11177
11330
  return null;
11178
- const last = path8.replace(/^.*[/\\]/s, "").toLowerCase();
11331
+ const last = path9.replace(/^.*[/\\]/s, "").toLowerCase();
11179
11332
  const ext2 = last.replace(/^.*\./s, "").toLowerCase();
11180
- const hasPath = last.length < path8.length;
11333
+ const hasPath = last.length < path9.length;
11181
11334
  const hasDot = ext2.length < last.length - 1;
11182
11335
  if (!hasDot && hasPath)
11183
11336
  return null;
@@ -11218,20 +11371,20 @@ var Mime_default = Mime;
11218
11371
  var src_default = new Mime_default(standard_default, other_default)._freeze();
11219
11372
 
11220
11373
  // src/preview-server.ts
11221
- function createPreviewMiddleware(projectRoot, baseOutDir) {
11222
- const clientOutDir = resolve(projectRoot, `${baseOutDir}/client`);
11374
+ function createPreviewMiddleware(projectRoot2, baseOutDir) {
11375
+ const clientOutDir = resolve(projectRoot2, `${baseOutDir}/client`);
11223
11376
  return async (req, res, next) => {
11224
11377
  try {
11225
11378
  let url = req.url || "/";
11226
- let filePath = path5.join(clientOutDir, url);
11227
- const extName = path5.extname(filePath);
11379
+ let filePath = path6.join(clientOutDir, url);
11380
+ const extName = path6.extname(filePath);
11228
11381
  if (extName && extName !== ".html") {
11229
11382
  return next();
11230
11383
  }
11231
11384
  if (url.endsWith("/")) {
11232
- filePath = path5.join(filePath, "index.html");
11385
+ filePath = path6.join(filePath, "index.html");
11233
11386
  }
11234
- if (!path5.extname(filePath) && !url.endsWith("/")) {
11387
+ if (!path6.extname(filePath) && !url.endsWith("/")) {
11235
11388
  const htmlCandidate = filePath + ".html";
11236
11389
  if (fs2.existsSync(htmlCandidate)) {
11237
11390
  filePath = htmlCandidate;
@@ -11244,7 +11397,7 @@ function createPreviewMiddleware(projectRoot, baseOutDir) {
11244
11397
  for (let i = urlSegments.length; i >= 0; i--) {
11245
11398
  const parentSegments = urlSegments.slice(0, i);
11246
11399
  const fourOhFourPath = "/" + [...parentSegments, "404"].join("/");
11247
- const fourOhFourFilePath = path5.join(
11400
+ const fourOhFourFilePath = path6.join(
11248
11401
  clientOutDir,
11249
11402
  fourOhFourPath + ".html"
11250
11403
  );
@@ -11273,23 +11426,23 @@ function createPreviewMiddleware(projectRoot, baseOutDir) {
11273
11426
  }
11274
11427
 
11275
11428
  // src/ssg.ts
11276
- import path6 from "node:path";
11429
+ import path7 from "node:path";
11277
11430
  import fs3 from "node:fs";
11278
11431
  import { pathToFileURL } from "node:url";
11279
11432
  async function generateStaticSite(state, outputOptions, bundle, log) {
11280
- const { projectRoot, baseOutDir, manifestPath, ssgOptions } = state;
11281
- const outDirAbs = path6.resolve(projectRoot, outputOptions?.dir ?? "dist");
11433
+ const { projectRoot: projectRoot2, baseOutDir, manifestPath: manifestPath2, ssgOptions } = state;
11434
+ const outDirAbs = path7.resolve(projectRoot2, outputOptions?.dir ?? "dist");
11282
11435
  const ssrEntry = Object.values(bundle).find(
11283
11436
  (c) => c.type === "chunk" && c.isEntry
11284
11437
  );
11285
11438
  if (!ssrEntry) return;
11286
- const ssrEntryAbs = path6.resolve(outDirAbs, ssrEntry.fileName);
11439
+ const ssrEntryAbs = path7.resolve(outDirAbs, ssrEntry.fileName);
11287
11440
  const mod = await import(pathToFileURL(ssrEntryAbs).href);
11288
11441
  const paths = await mod.generateStaticPaths();
11289
- const clientOutDirAbs = path6.resolve(projectRoot, `${baseOutDir}/client`);
11290
- const { clientEntry } = await getClientAssets(clientOutDirAbs, manifestPath);
11442
+ const clientOutDirAbs = path7.resolve(projectRoot2, `${baseOutDir}/client`);
11443
+ const { clientEntry } = await getClientAssets(clientOutDirAbs, manifestPath2);
11291
11444
  let manifest = null;
11292
- const clientManifestPath = path6.resolve(clientOutDirAbs, manifestPath);
11445
+ const clientManifestPath = path7.resolve(clientOutDirAbs, manifestPath2);
11293
11446
  if (fs3.existsSync(clientManifestPath)) {
11294
11447
  try {
11295
11448
  manifest = JSON.parse(fs3.readFileSync(clientManifestPath, "utf-8"));
@@ -11322,7 +11475,7 @@ async function generateStaticSite(state, outputOptions, bundle, log) {
11322
11475
  );
11323
11476
  const filePath = getOutputPath(clientOutDirAbs, route);
11324
11477
  log(ANSI.cyan("[SSG]"), "write:", ANSI.black(filePath));
11325
- fs3.mkdirSync(path6.dirname(filePath), { recursive: true });
11478
+ fs3.mkdirSync(path7.dirname(filePath), { recursive: true });
11326
11479
  fs3.writeFileSync(filePath, html, "utf-8");
11327
11480
  })
11328
11481
  );
@@ -11332,10 +11485,10 @@ async function generateStaticSite(state, outputOptions, bundle, log) {
11332
11485
  await generateSitemap(state, routes, clientOutDirAbs, log);
11333
11486
  }
11334
11487
  }
11335
- async function getClientAssets(clientOutDirAbs, manifestPath) {
11488
+ async function getClientAssets(clientOutDirAbs, manifestPath2) {
11336
11489
  let clientEntry = null;
11337
11490
  try {
11338
- const clientManifestPath = path6.resolve(clientOutDirAbs, manifestPath);
11491
+ const clientManifestPath = path7.resolve(clientOutDirAbs, manifestPath2);
11339
11492
  if (fs3.existsSync(clientManifestPath)) {
11340
11493
  const manifest = JSON.parse(fs3.readFileSync(clientManifestPath, "utf-8"));
11341
11494
  const clientEntryKey = VIRTUAL_ENTRY_CLIENT_ID;
@@ -11350,7 +11503,7 @@ async function getClientAssets(clientOutDirAbs, manifestPath) {
11350
11503
  }
11351
11504
  return { clientEntry };
11352
11505
  }
11353
- function collectCssForModules(manifest, moduleIds, projectRoot) {
11506
+ function collectCssForModules(manifest, moduleIds, projectRoot2) {
11354
11507
  const seen = /* @__PURE__ */ new Set();
11355
11508
  const cssFiles = /* @__PURE__ */ new Set();
11356
11509
  const collectCss = (key) => {
@@ -11370,8 +11523,8 @@ function collectCssForModules(manifest, moduleIds, projectRoot) {
11370
11523
  }
11371
11524
  for (const moduleId of moduleIds) {
11372
11525
  let normalizedId = moduleId.replace(/\\/g, "/");
11373
- if (normalizedId.startsWith(projectRoot)) {
11374
- normalizedId = normalizedId.substring(projectRoot.length);
11526
+ if (normalizedId.startsWith(projectRoot2)) {
11527
+ normalizedId = normalizedId.substring(projectRoot2.length);
11375
11528
  }
11376
11529
  if (normalizedId.startsWith("/")) {
11377
11530
  normalizedId = normalizedId.substring(1);
@@ -11390,8 +11543,8 @@ function collectCssForModules(manifest, moduleIds, projectRoot) {
11390
11543
  }
11391
11544
  for (const key in manifest) {
11392
11545
  const keyNormalized = key.replace(/\\/g, "/");
11393
- const moduleBaseName = path6.basename(normalizedId);
11394
- const keyBaseName = path6.basename(keyNormalized);
11546
+ const moduleBaseName = path7.basename(normalizedId);
11547
+ const keyBaseName = path7.basename(keyNormalized);
11395
11548
  if ((keyNormalized.endsWith(normalizedId) || normalizedId.endsWith(keyNormalized)) && moduleBaseName === keyBaseName) {
11396
11549
  collectCss(key);
11397
11550
  break;
@@ -11409,7 +11562,7 @@ function findClientEntry(dir) {
11409
11562
  const top = fs3.readdirSync(dir);
11410
11563
  const topJs = top.find((f) => f.endsWith(".js"));
11411
11564
  if (topJs) return topJs;
11412
- const assetsDir = path6.join(dir, "assets");
11565
+ const assetsDir = path7.join(dir, "assets");
11413
11566
  if (fs3.existsSync(assetsDir)) {
11414
11567
  const assetJs = fs3.readdirSync(assetsDir).find((f) => f.endsWith(".js"));
11415
11568
  return assetJs ? `assets/${assetJs}` : null;
@@ -11418,9 +11571,9 @@ function findClientEntry(dir) {
11418
11571
  }
11419
11572
  async function renderRoute(state, mod, route, srcFilePath, clientEntry, manifest) {
11420
11573
  const moduleIds = [];
11421
- const { projectRoot, ssgOptions } = state;
11422
- const documentPath = path6.resolve(
11423
- projectRoot,
11574
+ const { projectRoot: projectRoot2, ssgOptions } = state;
11575
+ const documentPath = path7.resolve(
11576
+ projectRoot2,
11424
11577
  ssgOptions.dir,
11425
11578
  ssgOptions.document
11426
11579
  );
@@ -11439,7 +11592,7 @@ async function renderRoute(state, mod, route, srcFilePath, clientEntry, manifest
11439
11592
  let html = result.body;
11440
11593
  let cssLinks = "";
11441
11594
  if (manifest) {
11442
- cssLinks = collectCssForModules(manifest, moduleIds, projectRoot);
11595
+ cssLinks = collectCssForModules(manifest, moduleIds, projectRoot2);
11443
11596
  }
11444
11597
  if (clientEntry) {
11445
11598
  const scriptTag = `<script type="module" src="/${clientEntry}"></script>`;
@@ -11450,18 +11603,18 @@ async function renderRoute(state, mod, route, srcFilePath, clientEntry, manifest
11450
11603
  }
11451
11604
  function getOutputPath(clientOutDirAbs, route) {
11452
11605
  if (route === "/") {
11453
- return path6.resolve(clientOutDirAbs, "index.html");
11606
+ return path7.resolve(clientOutDirAbs, "index.html");
11454
11607
  }
11455
11608
  const parts = route.replace(/^\//, "").split("/").filter(Boolean);
11456
11609
  if (parts.length === 1) {
11457
- return path6.resolve(clientOutDirAbs, `${parts[0]}.html`);
11610
+ return path7.resolve(clientOutDirAbs, `${parts[0]}.html`);
11458
11611
  }
11459
- const dirPath = path6.resolve(clientOutDirAbs, parts.slice(0, -1).join("/"));
11612
+ const dirPath = path7.resolve(clientOutDirAbs, parts.slice(0, -1).join("/"));
11460
11613
  let last = parts[parts.length - 1];
11461
11614
  if (last.endsWith("*")) {
11462
11615
  last = last.slice(0, -1);
11463
11616
  }
11464
- return path6.resolve(dirPath, `${last}.html`);
11617
+ return path7.resolve(dirPath, `${last}.html`);
11465
11618
  }
11466
11619
  async function generateSitemap(state, routes, clientOutDirAbs, log) {
11467
11620
  const sitemapConfig = state.ssgOptions.sitemap;
@@ -11551,7 +11704,7 @@ async function generateSitemap(state, routes, clientOutDirAbs, log) {
11551
11704
  <urlset ${namespaces}>
11552
11705
  ${urls}
11553
11706
  </urlset>`;
11554
- const sitemapPath = path6.resolve(clientOutDirAbs, "sitemap.xml");
11707
+ const sitemapPath = path7.resolve(clientOutDirAbs, "sitemap.xml");
11555
11708
  fs3.writeFileSync(sitemapPath, sitemapXml, "utf-8");
11556
11709
  log(ANSI.cyan("[SSG]"), "Generated sitemap:", ANSI.black(sitemapPath));
11557
11710
  }
@@ -11559,10 +11712,10 @@ function escapeXml(unsafe) {
11559
11712
  return unsafe.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
11560
11713
  }
11561
11714
  async function appendStaticPropsToClientModules(state, clientOutDirAbs, log) {
11562
- const { projectRoot, manifestPath, ssgOptions } = state;
11715
+ const { projectRoot: projectRoot2, manifestPath: manifestPath2, ssgOptions } = state;
11563
11716
  try {
11564
11717
  log(ANSI.cyan("[SSG]"), "Starting static props collection...");
11565
- const clientManifestPath = path6.resolve(clientOutDirAbs, manifestPath);
11718
+ const clientManifestPath = path7.resolve(clientOutDirAbs, manifestPath2);
11566
11719
  if (!fs3.existsSync(clientManifestPath)) {
11567
11720
  log(
11568
11721
  ANSI.yellow("[SSG]"),
@@ -11572,7 +11725,7 @@ async function appendStaticPropsToClientModules(state, clientOutDirAbs, log) {
11572
11725
  }
11573
11726
  log(ANSI.cyan("[SSG]"), "Found client manifest at:", clientManifestPath);
11574
11727
  const srcPages = globSync(`${ssgOptions.dir}/**/${ssgOptions.page}`, {
11575
- cwd: projectRoot
11728
+ cwd: projectRoot2
11576
11729
  }).map((s) => s.replace(/\\/g, "/"));
11577
11730
  const manifest = JSON.parse(
11578
11731
  fs3.readFileSync(clientManifestPath, "utf-8")
@@ -11596,7 +11749,7 @@ async function appendStaticPropsToClientModules(state, clientOutDirAbs, log) {
11596
11749
  log(ANSI.red(`failed to get manifest chunk for module "${moduleId}"`));
11597
11750
  return;
11598
11751
  }
11599
- const filePath = path6.resolve(clientOutDirAbs, chunk.file);
11752
+ const filePath = path7.resolve(clientOutDirAbs, chunk.file);
11600
11753
  const code = `export const __KIRU_STATIC_PROPS__ = ${JSON.stringify(
11601
11754
  staticProps
11602
11755
  )};`;
@@ -11612,21 +11765,6 @@ ${code}`, "utf-8");
11612
11765
 
11613
11766
  // src/index.ts
11614
11767
  import { build } from "vite";
11615
-
11616
- // src/globals.ts
11617
- var VITE_DEV_SERVER_INSTANCE = {
11618
- get current() {
11619
- return (
11620
- // @ts-ignore
11621
- globalThis.KIRU_VITE_DEV_SERVER_INSTANCE ?? null
11622
- );
11623
- },
11624
- set current(server) {
11625
- globalThis.KIRU_VITE_DEV_SERVER_INSTANCE = server;
11626
- }
11627
- };
11628
-
11629
- // src/index.ts
11630
11768
  function kiru(opts = {}) {
11631
11769
  let state;
11632
11770
  let log;
@@ -11643,16 +11781,14 @@ function kiru(opts = {}) {
11643
11781
  state = updatePluginState(initialState, config, opts);
11644
11782
  log = createLogger(state);
11645
11783
  if (state.ssrOptions) {
11646
- virtualModules = await createVirtualModules(
11784
+ virtualModules = createVirtualModules_SSR(
11647
11785
  state.projectRoot,
11648
- state.ssrOptions,
11649
- "ssr"
11786
+ state.ssrOptions
11650
11787
  );
11651
11788
  } else if (state.ssgOptions) {
11652
- virtualModules = await createVirtualModules(
11789
+ virtualModules = createVirtualModules_SSG(
11653
11790
  state.projectRoot,
11654
- state.ssgOptions,
11655
- "ssg"
11791
+ state.ssgOptions
11656
11792
  );
11657
11793
  }
11658
11794
  },
@@ -11669,16 +11805,17 @@ function kiru(opts = {}) {
11669
11805
  createPreviewMiddleware(state.projectRoot, state.baseOutDir)
11670
11806
  );
11671
11807
  },
11672
- configureServer(server) {
11673
- VITE_DEV_SERVER_INSTANCE.current = server;
11808
+ async configureServer(server) {
11809
+ global.viteDevServer = server;
11674
11810
  if (state.isProduction || state.isBuild) return;
11675
11811
  const {
11676
11812
  ssgOptions,
11813
+ ssrOptions,
11677
11814
  devtoolsEnabled,
11678
11815
  dtClientPathname,
11679
11816
  dtHostScriptPath,
11680
11817
  fileLinkFormatter,
11681
- projectRoot
11818
+ projectRoot: projectRoot2
11682
11819
  } = state;
11683
11820
  if (devtoolsEnabled) {
11684
11821
  setupDevtools(
@@ -11692,8 +11829,8 @@ function kiru(opts = {}) {
11692
11829
  server.middlewares.use(async (req, res, next) => {
11693
11830
  try {
11694
11831
  const url = req.originalUrl || req.url || "/";
11695
- const filePath = path7.join(state.baseOutDir, "client", url);
11696
- const extName = path7.extname(filePath);
11832
+ const filePath = path8.join(state.baseOutDir, "client", url);
11833
+ const extName = path8.extname(filePath);
11697
11834
  const accept = req.headers["accept"] || "";
11698
11835
  const shouldHandle = typeof accept === "string" && accept.includes("text/html") && !url.startsWith("/node_modules/") && !url.startsWith("/@") && !url.startsWith(dtHostScriptPath) && !url.startsWith(dtClientPathname) && (extName === ".html" || !extName);
11699
11836
  if (!shouldHandle) {
@@ -11703,7 +11840,7 @@ function kiru(opts = {}) {
11703
11840
  server,
11704
11841
  url,
11705
11842
  state.projectRoot,
11706
- () => resolveUserDocument(projectRoot, ssgOptions)
11843
+ () => resolveUserDocument(projectRoot2, ssgOptions)
11707
11844
  );
11708
11845
  res.statusCode = status;
11709
11846
  res.setHeader("Content-Type", "text/html");
@@ -11723,6 +11860,10 @@ ${ANSI.yellow("Error:")} ${error.message}`
11723
11860
  next(e);
11724
11861
  }
11725
11862
  });
11863
+ } else if (ssrOptions) {
11864
+ queueMicrotask(() => {
11865
+ server.ssrLoadModule(VIRTUAL_ENTRY_SERVER_ID).then(setServerEntryModule);
11866
+ });
11726
11867
  }
11727
11868
  },
11728
11869
  resolveId(id) {
@@ -11758,18 +11899,34 @@ ${ANSI.yellow("Error:")} ${error.message}`
11758
11899
  }
11759
11900
  return { code: src };
11760
11901
  }
11761
- log(`Processing ${ANSI.black(id)}`);
11902
+ const filePath = id.replace(state.projectRoot, "");
11903
+ log(`Processing ${ANSI.black(filePath)}`);
11762
11904
  const ast = this.parse(src);
11763
11905
  const code = new import_magic_string.default(src);
11764
11906
  const ctx = {
11765
11907
  code,
11766
11908
  ast,
11767
11909
  isBuild: state.isBuild,
11910
+ isServer: this.environment.name === "ssr",
11768
11911
  fileLinkFormatter: state.fileLinkFormatter,
11769
- filePath: id,
11912
+ id,
11913
+ filePath,
11770
11914
  log
11771
11915
  };
11772
11916
  prepareDevOnlyHooks(ctx);
11917
+ if (state.ssrOptions) {
11918
+ const {
11919
+ projectRoot: projectRoot2,
11920
+ ssrOptions: { dir, remote }
11921
+ } = state;
11922
+ const actionsMatchPattern = path8.join(projectRoot2, dir, "**", remote).replace(/\\/g, "/");
11923
+ if (minimatch(id, actionsMatchPattern)) {
11924
+ const route = getRouteFromFilePath(id, projectRoot2, dir);
11925
+ global.route = route;
11926
+ prepareRemoteFunctions(ctx);
11927
+ global.route = null;
11928
+ }
11929
+ }
11773
11930
  if (!state.isProduction && !state.isBuild) {
11774
11931
  prepareHMR(ctx);
11775
11932
  }
@@ -11827,10 +11984,10 @@ ${ANSI.yellow("Error:")} ${error.message}`
11827
11984
  ...inlineConfig?.build,
11828
11985
  ssr: true,
11829
11986
  rollupOptions: {
11830
- input: path7.resolve(
11831
- state.projectRoot,
11832
- state.ssrOptions.runtimeEntry
11833
- )
11987
+ input: [
11988
+ path8.resolve(state.projectRoot, state.ssrOptions.runtimeEntry),
11989
+ VIRTUAL_ENTRY_SERVER_ID
11990
+ ]
11834
11991
  }
11835
11992
  }
11836
11993
  });
@@ -11842,6 +11999,11 @@ ${ANSI.yellow("Error:")} ${error.message}`
11842
11999
  }
11843
12000
  function onHMR(callback) {
11844
12001
  }
12002
+ function getRouteFromFilePath(filePath, projectRoot2, dir) {
12003
+ const pref = path8.join(projectRoot2, dir).replace(/\\/g, "/");
12004
+ const lastSlash = filePath.lastIndexOf("/");
12005
+ return filePath.slice(pref.length, lastSlash);
12006
+ }
11845
12007
  export {
11846
12008
  kiru as default,
11847
12009
  defaultEsBuildOptions,