@ignite-ember/ui-react 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +217 -2
  4. package/dist/CopySource.d.ts +4 -0
  5. package/dist/CopySource.d.ts.map +1 -0
  6. package/dist/CopySource.js +36 -0
  7. package/dist/CopySource.js.map +1 -0
  8. package/dist/DataTable.d.ts +61 -0
  9. package/dist/DataTable.d.ts.map +1 -0
  10. package/dist/DataTable.js +29 -0
  11. package/dist/DataTable.js.map +1 -0
  12. package/dist/ErrorBoundary.d.ts +68 -0
  13. package/dist/ErrorBoundary.d.ts.map +1 -0
  14. package/dist/ErrorBoundary.js +63 -0
  15. package/dist/ErrorBoundary.js.map +1 -0
  16. package/dist/LiveRegion.d.ts +35 -0
  17. package/dist/LiveRegion.d.ts.map +1 -0
  18. package/dist/LiveRegion.js +70 -0
  19. package/dist/LiveRegion.js.map +1 -0
  20. package/dist/Markdown.d.ts +18 -0
  21. package/dist/Markdown.d.ts.map +1 -0
  22. package/dist/Markdown.js +52 -0
  23. package/dist/Markdown.js.map +1 -0
  24. package/dist/MarkdownInline.d.ts +44 -0
  25. package/dist/MarkdownInline.d.ts.map +1 -0
  26. package/dist/MarkdownInline.js +144 -0
  27. package/dist/MarkdownInline.js.map +1 -0
  28. package/dist/MenuIcon.d.ts +54 -0
  29. package/dist/MenuIcon.d.ts.map +1 -0
  30. package/dist/MenuIcon.js +96 -0
  31. package/dist/MenuIcon.js.map +1 -0
  32. package/dist/Mermaid.d.ts +38 -0
  33. package/dist/Mermaid.d.ts.map +1 -0
  34. package/dist/Mermaid.js +119 -0
  35. package/dist/Mermaid.js.map +1 -0
  36. package/dist/Monogram.d.ts +42 -0
  37. package/dist/Monogram.d.ts.map +1 -0
  38. package/dist/Monogram.js +88 -0
  39. package/dist/Monogram.js.map +1 -0
  40. package/dist/OverflowMenu.d.ts +55 -0
  41. package/dist/OverflowMenu.d.ts.map +1 -0
  42. package/dist/OverflowMenu.js +141 -0
  43. package/dist/OverflowMenu.js.map +1 -0
  44. package/dist/Shell.d.ts +54 -0
  45. package/dist/Shell.d.ts.map +1 -0
  46. package/dist/Shell.js +31 -0
  47. package/dist/Shell.js.map +1 -0
  48. package/dist/Skeleton.d.ts +32 -0
  49. package/dist/Skeleton.d.ts.map +1 -0
  50. package/dist/Skeleton.js +26 -0
  51. package/dist/Skeleton.js.map +1 -0
  52. package/dist/Split.d.ts +66 -0
  53. package/dist/Split.d.ts.map +1 -0
  54. package/dist/Split.js +133 -0
  55. package/dist/Split.js.map +1 -0
  56. package/dist/Toast.d.ts +87 -0
  57. package/dist/Toast.d.ts.map +1 -0
  58. package/dist/Toast.js +118 -0
  59. package/dist/Toast.js.map +1 -0
  60. package/dist/Tooltip.d.ts +15 -0
  61. package/dist/Tooltip.d.ts.map +1 -0
  62. package/dist/Tooltip.js +144 -0
  63. package/dist/Tooltip.js.map +1 -0
  64. package/dist/cx.d.ts +3 -0
  65. package/dist/cx.d.ts.map +1 -0
  66. package/dist/cx.js +5 -0
  67. package/dist/cx.js.map +1 -0
  68. package/dist/fenceInfo.d.ts +23 -0
  69. package/dist/fenceInfo.d.ts.map +1 -0
  70. package/dist/fenceInfo.js +19 -0
  71. package/dist/fenceInfo.js.map +1 -0
  72. package/dist/index.d.ts +82 -0
  73. package/dist/index.d.ts.map +1 -0
  74. package/dist/index.js +82 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/primitives.d.ts +383 -0
  77. package/dist/primitives.d.ts.map +1 -0
  78. package/dist/primitives.js +340 -0
  79. package/dist/primitives.js.map +1 -0
  80. package/package.json +56 -4
  81. package/src/CopySource.tsx +52 -0
  82. package/src/DataTable.tsx +104 -0
  83. package/src/ErrorBoundary.tsx +102 -0
  84. package/src/LiveRegion.tsx +121 -0
  85. package/src/Markdown.tsx +71 -0
  86. package/src/MarkdownInline.tsx +164 -0
  87. package/src/MenuIcon.tsx +203 -0
  88. package/src/Mermaid.tsx +142 -0
  89. package/src/Monogram.tsx +103 -0
  90. package/src/OverflowMenu.tsx +352 -0
  91. package/src/Shell.tsx +86 -0
  92. package/src/Skeleton.tsx +68 -0
  93. package/src/Split.tsx +242 -0
  94. package/src/Toast.tsx +258 -0
  95. package/src/Tooltip.tsx +188 -0
  96. package/src/cx.ts +4 -0
  97. package/src/fenceInfo.ts +33 -0
  98. package/src/index.ts +153 -0
  99. package/src/primitives.tsx +887 -0
@@ -0,0 +1,38 @@
1
+ type MermaidTheme = "default" | "dark";
2
+ interface MermaidConfig {
3
+ startOnLoad: boolean;
4
+ securityLevel: "strict";
5
+ theme: MermaidTheme;
6
+ themeVariables: {
7
+ fontFamily: string;
8
+ background: string;
9
+ };
10
+ }
11
+ interface MermaidLib {
12
+ initialize: (config: MermaidConfig) => void;
13
+ render: (id: string, src: string) => Promise<{
14
+ svg: string;
15
+ }>;
16
+ }
17
+ /**
18
+ * Mermaid, configured for the theme in force right now.
19
+ *
20
+ * Mermaid is about 700KB, so it arrives only if a document has one;
21
+ * the bundler caches the module, so asking again costs nothing.
22
+ * Configured on every call rather than once, because the theme is
23
+ * read when it is configured — a diagram drawn after a switch to
24
+ * dark has to be drawn in dark.
25
+ */
26
+ export declare function loadMermaid(): Promise<MermaidLib>;
27
+ /**
28
+ * A mermaid diagram.
29
+ *
30
+ * `source` is the text inside the fence. A diagram that does not
31
+ * parse is shown as its own source rather than as a blank box: it is
32
+ * usually a diagram somebody is halfway through writing.
33
+ */
34
+ export declare function MermaidBlock({ source }: {
35
+ source: string;
36
+ }): import("react").JSX.Element;
37
+ export {};
38
+ //# sourceMappingURL=Mermaid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mermaid.d.ts","sourceRoot":"","sources":["../src/Mermaid.tsx"],"names":[],"mappings":"AAgCA,KAAK,YAAY,GAAG,SAAS,GAAG,MAAM,CAAC;AAEvC,UAAU,aAAa;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,QAAQ,CAAC;IACxB,KAAK,EAAE,YAAY,CAAC;IACpB,cAAc,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CAC5D;AAED,UAAU,UAAU;IAClB,UAAU,EAAE,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,CAAC;IAC5C,MAAM,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC/D;AA4BD;;;;;;;;GAQG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,UAAU,CAAC,CAavD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,+BAsC1D"}
@@ -0,0 +1,119 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Mermaid diagrams.
4
+ *
5
+ * ```mermaid``` becomes a diagram, in a document exactly as it
6
+ * already does in chat.
7
+ *
8
+ * **A fence, deliberately.** This is what lets a document carry a
9
+ * diagram while staying markdown: the source is a code block, so it
10
+ * diffs a line at a time, chunks for search, survives the editor's
11
+ * round trip untouched, and reads as its own source in any other
12
+ * markdown tool. The alternative — embedding HTML, or a bespoke
13
+ * node type — would cost every one of those. ``fenceInfo`` is the
14
+ * helper that spots one.
15
+ *
16
+ * Shared by the chat and the document view rather than copied.
17
+ * There was one mermaid renderer living inside ``ChatItems`` and a
18
+ * document could not reach it, which is the usual way two renderers
19
+ * of the same thing start disagreeing about what it looks like.
20
+ *
21
+ * **`mermaid` is a peer dependency**, loaded on demand. An
22
+ * extension that never renders a diagram never downloads it; one
23
+ * that does must have it installed. This is the only export under
24
+ * the floor that asks anything of your package.json.
25
+ *
26
+ * ``SpecBlock`` used to live here and does not any more: it reaches
27
+ * into the app for the ``json-render`` renderer, so it could not be
28
+ * published without publishing that too. It is app code now.
29
+ */
30
+ import { useEffect, useRef, useState } from "react";
31
+ import { CopySource } from "./CopySource.js";
32
+ // Mermaid draws into a scratch element by id, and the id becomes the
33
+ // SVG's own and scopes the <style> it injects. One counter for the
34
+ // page, so no two renders anywhere on it share one — not across
35
+ // blocks, not across React roots, not across an edit in flight.
36
+ let mermaidId = 0;
37
+ /**
38
+ * A mermaid theme matching igni's.
39
+ *
40
+ * ``default`` is the colourful light palette and ``dark`` its dark
41
+ * counterpart. Both run in colour — ``neutral``, which reads like
42
+ * the safe choice, is what made every diagram grey.
43
+ */
44
+ function mermaidTheme() {
45
+ if (typeof document === "undefined")
46
+ return "default";
47
+ const explicit = document.documentElement.dataset.theme;
48
+ if (explicit === "dark")
49
+ return "dark";
50
+ if (explicit === "light")
51
+ return "default";
52
+ if (typeof window !== "undefined" && window.matchMedia) {
53
+ return window.matchMedia("(prefers-color-scheme: dark)").matches
54
+ ? "dark"
55
+ : "default";
56
+ }
57
+ return "default";
58
+ }
59
+ /**
60
+ * Mermaid, configured for the theme in force right now.
61
+ *
62
+ * Mermaid is about 700KB, so it arrives only if a document has one;
63
+ * the bundler caches the module, so asking again costs nothing.
64
+ * Configured on every call rather than once, because the theme is
65
+ * read when it is configured — a diagram drawn after a switch to
66
+ * dark has to be drawn in dark.
67
+ */
68
+ export async function loadMermaid() {
69
+ // Inline on purpose: `mermaid` is an optional peer dependency.
70
+ const lib = (await import("mermaid")).default;
71
+ lib.initialize({
72
+ startOnLoad: false,
73
+ securityLevel: "strict",
74
+ theme: mermaidTheme(),
75
+ themeVariables: {
76
+ fontFamily: "var(--font-ui)",
77
+ background: "transparent",
78
+ },
79
+ });
80
+ return lib;
81
+ }
82
+ /**
83
+ * A mermaid diagram.
84
+ *
85
+ * `source` is the text inside the fence. A diagram that does not
86
+ * parse is shown as its own source rather than as a blank box: it is
87
+ * usually a diagram somebody is halfway through writing.
88
+ */
89
+ export function MermaidBlock({ source }) {
90
+ const frame = useRef(null);
91
+ const [error, setError] = useState(null);
92
+ useEffect(() => {
93
+ let cancelled = false;
94
+ setError(null);
95
+ void loadMermaid()
96
+ .then((lib) => lib.render(`mermaid-${++mermaidId}`, source))
97
+ .then(({ svg }) => {
98
+ if (cancelled || !frame.current)
99
+ return;
100
+ frame.current.innerHTML = svg;
101
+ })
102
+ .catch((e) => {
103
+ if (cancelled)
104
+ return;
105
+ setError(e instanceof Error ? e.message : String(e));
106
+ });
107
+ return () => {
108
+ cancelled = true;
109
+ };
110
+ }, [source]);
111
+ if (error) {
112
+ // The source, not a blank box. A diagram that does not parse is
113
+ // usually a diagram somebody is halfway through writing, and
114
+ // hiding what they wrote is the least helpful response to that.
115
+ return (_jsx("pre", { className: "mermaid-error", title: `Mermaid render failed: ${error}`, children: source }));
116
+ }
117
+ return (_jsxs("div", { className: "mermaid-diagram", children: [_jsx(CopySource, { source: source }), _jsx("div", { ref: frame })] }));
118
+ }
119
+ //# sourceMappingURL=Mermaid.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mermaid.js","sourceRoot":"","sources":["../src/Mermaid.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAgB7C,qEAAqE;AACrE,mEAAmE;AACnE,gEAAgE;AAChE,gEAAgE;AAChE,IAAI,SAAS,GAAG,CAAC,CAAC;AAElB;;;;;;GAMG;AACH,SAAS,YAAY;IACnB,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO,SAAS,CAAC;IACtD,MAAM,QAAQ,GAAG,QAAQ,CAAC,eAAe,CAAC,OAAO,CAAC,KAAK,CAAC;IACxD,IAAI,QAAQ,KAAK,MAAM;QAAE,OAAO,MAAM,CA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OAAO;gBAAE,OAAO;YACxC,KAAK,CAAC,OAAO,CAAC,SAAS,GAAG,GAAG,CAAC;QAChC,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,CAAU,EAAE,EAAE;YACpB,IAAI,SAAS;gBAAE,OAAO;YACtB,QAAQ,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;QACL,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;QACnB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,IAAI,KAAK,EAAE,CAAC;QACV,gEAAgE;QAChE,6DAA6D;QAC7D,gEAAgE;QAChE,OAAO,CACL,cAAK,SAAS,EAAC,eAAe,EAAC,KAAK,EAAE,0BAA0B,KAAK,EAAE,YACpE,MAAM,GACH,CACP,CAAC;IACJ,CAAC;IACD,OAAO,CACL,eAAK,SAAS,EAAC,iBAAiB,aAC9B,KAAC,UAAU,IAAC,MAAM,EAAE,MAAM,GAAI,EAC9B,cAAK,GAAG,EAAE,KAAK,GAAI,IACf,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Two letters standing in for a face.
3
+ *
4
+ * Not an avatar. Nothing in the product stores an uploaded picture —
5
+ * there is no `avatar_url` on a user anywhere in the server — and a
6
+ * generic silhouette for everybody says strictly less than two
7
+ * letters of somebody's own name. The portal draws the same thing
8
+ * from the same source, so the two surfaces agree about what a person
9
+ * looks like.
10
+ *
11
+ * The colour is derived from the name rather than chosen, so the same
12
+ * person is the same colour on every machine and across restarts.
13
+ * That is the whole point: the monogram is a recognition aid, and one
14
+ * that changed colour per session would be decoration.
15
+ */
16
+ export declare function initialsOf(name: string): string;
17
+ /** A stable hue for a name. Same person, same colour, every time. */
18
+ export declare function hueOf(name: string): number;
19
+ /**
20
+ * The same colour, written as ``#rrggbb``.
21
+ *
22
+ * For the places that cannot take ``hsl()``. The collaborative
23
+ * caret is one: it validates against ``/^#[0-9a-fA-F]{6}$/`` and
24
+ * quietly renders anything else transparent — a cursor that is
25
+ * there, labelled with the right name, and invisible.
26
+ *
27
+ * Derived from the same hue as the monogram, so somebody's caret and
28
+ * their initials are the same colour.
29
+ */
30
+ export declare function hexOf(name: string, saturation?: number, lightness?: number): string;
31
+ /**
32
+ * Two letters standing in for a face.
33
+ *
34
+ * See the note at the top of this file. The colour comes from the
35
+ * name, so the same person is the same colour on every machine and
36
+ * across restarts.
37
+ */
38
+ export declare function Monogram({ name, size }: {
39
+ name: string;
40
+ size?: number;
41
+ }): import("react").JSX.Element;
42
+ //# sourceMappingURL=Monogram.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Monogram.d.ts","sourceRoot":"","sources":["../src/Monogram.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAW/C;AAED,qEAAqE;AACrE,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM1C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,MAAM,EACZ,UAAU,SAAO,EACjB,SAAS,SAAO,GACf,MAAM,CAqBR;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAS,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,+BAmB5E"}
@@ -0,0 +1,88 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Two letters standing in for a face.
4
+ *
5
+ * Not an avatar. Nothing in the product stores an uploaded picture —
6
+ * there is no `avatar_url` on a user anywhere in the server — and a
7
+ * generic silhouette for everybody says strictly less than two
8
+ * letters of somebody's own name. The portal draws the same thing
9
+ * from the same source, so the two surfaces agree about what a person
10
+ * looks like.
11
+ *
12
+ * The colour is derived from the name rather than chosen, so the same
13
+ * person is the same colour on every machine and across restarts.
14
+ * That is the whole point: the monogram is a recognition aid, and one
15
+ * that changed colour per session would be decoration.
16
+ */
17
+ export function initialsOf(name) {
18
+ const cleaned = (name || "").trim();
19
+ if (!cleaned)
20
+ return "?";
21
+ // An address is not a name: "maya@acme.test" should read as M, not
22
+ // as MA from "maya" and "acme".
23
+ const local = cleaned.includes("@") ? cleaned.split("@")[0] : cleaned;
24
+ const words = local.split(/[\s._-]+/).filter(Boolean);
25
+ if (words.length === 0)
26
+ return "?";
27
+ if (words.length === 1)
28
+ return words[0].slice(0, 2).toUpperCase();
29
+ return (words[0][0] + words[words.length - 1][0]).toUpperCase();
30
+ }
31
+ /** A stable hue for a name. Same person, same colour, every time. */
32
+ export function hueOf(name) {
33
+ let hash = 0;
34
+ for (const ch of name || "") {
35
+ hash = (hash * 31 + ch.charCodeAt(0)) % 360;
36
+ }
37
+ return hash;
38
+ }
39
+ /**
40
+ * The same colour, written as ``#rrggbb``.
41
+ *
42
+ * For the places that cannot take ``hsl()``. The collaborative
43
+ * caret is one: it validates against ``/^#[0-9a-fA-F]{6}$/`` and
44
+ * quietly renders anything else transparent — a cursor that is
45
+ * there, labelled with the right name, and invisible.
46
+ *
47
+ * Derived from the same hue as the monogram, so somebody's caret and
48
+ * their initials are the same colour.
49
+ */
50
+ export function hexOf(name, saturation = 0.62, lightness = 0.52) {
51
+ const hue = hueOf(name) / 360;
52
+ const chroma = (1 - Math.abs(2 * lightness - 1)) * saturation;
53
+ const second = chroma * (1 - Math.abs(((hue * 6) % 2) - 1));
54
+ const base = lightness - chroma / 2;
55
+ const sixth = Math.floor(hue * 6) % 6;
56
+ const [r, g, b] = [
57
+ [chroma, second, 0],
58
+ [second, chroma, 0],
59
+ [0, chroma, second],
60
+ [0, second, chroma],
61
+ [second, 0, chroma],
62
+ [chroma, 0, second],
63
+ ][sixth];
64
+ const byte = (value) => Math.round((value + base) * 255)
65
+ .toString(16)
66
+ .padStart(2, "0");
67
+ return `#${byte(r)}${byte(g)}${byte(b)}`;
68
+ }
69
+ /**
70
+ * Two letters standing in for a face.
71
+ *
72
+ * See the note at the top of this file. The colour comes from the
73
+ * name, so the same person is the same colour on every machine and
74
+ * across restarts.
75
+ */
76
+ export function Monogram({ name, size = 18 }) {
77
+ const hue = hueOf(name);
78
+ return (_jsx("span", { className: "monogram", "aria-hidden": "true", style: {
79
+ width: size,
80
+ height: size,
81
+ fontSize: Math.round(size * 0.46),
82
+ // Fixed saturation and lightness so every generated colour
83
+ // clears contrast against white text, rather than hoping the
84
+ // hash lands somewhere readable.
85
+ background: `hsl(${hue} 42% 42%)`,
86
+ }, children: initialsOf(name) }));
87
+ }
88
+ //# sourceMappingURL=Monogram.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Monogram.js","sourceRoot":"","sources":["../src/Monogram.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,OAAO,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACpC,IAAI,CAAC,OAAO;QAAE,OAAO,GAAG,CAAC;IAEzB,mEAAmE;IACnE,gCAAgC;IAChC,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IACtE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,CA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AC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACnB,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;QACnB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC;QACnB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC;QACnB,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC;QACnB,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,CAAC;KAEtB,CAAC,KAAK,CAAC,CAAC;IACT,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAC7B,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC;SAC7B,QAAQ,CAAC,EAAE,CAAC;SACZ,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACtB,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,EAAE,EAAmC;IAC3E,MAAM,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IACxB,OAAO,CACL,eACE,SAAS,EAAC,UAAU,iBACR,MAAM,EAClB,KAAK,EAAE;YACL,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,IAAI;YACZ,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;YACjC,2DAA2D;YAC3D,6DAA6D;YAC7D,iCAAiC;YACjC,UAAU,EAAE,OAAO,GAAG,WAAW;SAClC,YAEA,UAAU,CAAC,IAAI,CAAC,GACZ,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { type MenuIconName } from "./MenuIcon.js";
2
+ /**
3
+ * A row of actions collapsed behind one button.
4
+ *
5
+ * For the case where the actions are real but secondary: four buttons
6
+ * across a header give each of them the same weight as the page
7
+ * title, and the one that deletes the thing ends up the same size as
8
+ * the one that exports it.
9
+ *
10
+ * Hiding them costs discoverability, so everything that made them
11
+ * usable as buttons has to survive the move — focus, the keyboard,
12
+ * and the names screen readers announce. That is most of what is
13
+ * below.
14
+ */
15
+ /** One action in an {@link OverflowMenu}. */
16
+ export interface OverflowAction {
17
+ /** Stable across renders; the label changes on toggles. */
18
+ key: string;
19
+ /** What it is called. */
20
+ label: string;
21
+ /** What picking it does. Omitted when `items` makes it a submenu. */
22
+ onSelect?: () => void;
23
+ /** Variants of this action, opened as a submenu rather than run.
24
+ * Use it when one verb has several objects — export as HTML, as
25
+ * Markdown, as PDF — so the menu stays a list of things you can
26
+ * do rather than a list of every combination of them. */
27
+ items?: OverflowAction[];
28
+ /** Destructive — rendered apart from the rest and in the danger colour. */
29
+ danger?: boolean;
30
+ /** A toggle that is currently on. Announced as such, not just coloured. */
31
+ active?: boolean;
32
+ /** Whether it can be picked. Shown as it is, and kept out of the tab order. */
33
+ disabled?: boolean;
34
+ /** Why you would pick this. Shown on hover, same as the buttons had. */
35
+ title?: string;
36
+ /** The glyph beside the label.
37
+ *
38
+ * Optional. A menu of five verbs reads as five equal options, and
39
+ * picking the wrong one of Archive and Remove costs quite
40
+ * differently — the shape is recognised before the word is read. */
41
+ icon?: MenuIconName;
42
+ }
43
+ /**
44
+ * A row of actions collapsed behind one button.
45
+ *
46
+ * See the note at the top of this file. Everything that made the
47
+ * buttons usable as buttons survives the move: focus, the keyboard,
48
+ * and the names screen readers announce.
49
+ */
50
+ export declare function OverflowMenu({ actions, label, }: {
51
+ actions: OverflowAction[];
52
+ /** What the trigger is called, for anyone who cannot see three dots. */
53
+ label?: string;
54
+ }): import("react").JSX.Element | null;
55
+ //# sourceMappingURL=OverflowMenu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverflowMenu.d.ts","sourceRoot":"","sources":["../src/OverflowMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAE5D;;;;;;;;;;;;GAYG;AAEH,6CAA6C;AAC7C,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,GAAG,EAAE,MAAM,CAAC;IACZ,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB;;;8DAG0D;IAC1D,KAAK,CAAC,EAAE,cAAc,EAAE,CAAC;IACzB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;yEAIqE;IACrE,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB;AAyBD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,EAC3B,OAAO,EACP,KAAsB,GACvB,EAAE;IACD,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,sCA2FA"}
@@ -0,0 +1,141 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useId, useRef, useState } from "react";
3
+ import { MenuIcon } from "./MenuIcon.js";
4
+ /** Direct children only — a submenu's own items belong to its list. */
5
+ const OWN_ITEMS = ":scope > [role='menuitem'], :scope > .overflow-sub-wrap > [role='menuitem']";
6
+ function enabledItems(root) {
7
+ return Array.from(root?.querySelectorAll(OWN_ITEMS) ?? []).filter((el) => !el.disabled);
8
+ }
9
+ /** Up/down within one list, wrapping. Returns whether it handled the key. */
10
+ function moveFocus(root, key) {
11
+ if (key !== "ArrowDown" && key !== "ArrowUp")
12
+ return false;
13
+ const all = enabledItems(root);
14
+ if (!all.length)
15
+ return false;
16
+ const at = all.indexOf(document.activeElement);
17
+ const step = key === "ArrowDown" ? 1 : -1;
18
+ // Wrapping, because a menu this short has no scroll to tell you
19
+ // that you have reached the end of it.
20
+ all[(at + step + all.length) % all.length]?.focus();
21
+ return true;
22
+ }
23
+ /**
24
+ * A row of actions collapsed behind one button.
25
+ *
26
+ * See the note at the top of this file. Everything that made the
27
+ * buttons usable as buttons survives the move: focus, the keyboard,
28
+ * and the names screen readers announce.
29
+ */
30
+ export function OverflowMenu({ actions, label = "More actions", }) {
31
+ const [open, setOpen] = useState(false);
32
+ const trigger = useRef(null);
33
+ const list = useRef(null);
34
+ const menuId = useId();
35
+ // Closing returns focus to the trigger. Without it a keyboard user
36
+ // who opens the menu and changes their mind is dropped at the top
37
+ // of the document with no way back to where they were.
38
+ const close = useCallback((restoreFocus = true) => {
39
+ setOpen(false);
40
+ if (restoreFocus)
41
+ trigger.current?.focus();
42
+ }, []);
43
+ // Opening moves focus into the menu, which is what makes it a menu
44
+ // rather than a panel that happens to be visible: the next Tab or
45
+ // arrow key lands on an action instead of on whatever follows the
46
+ // trigger in the document.
47
+ useEffect(() => {
48
+ if (open)
49
+ enabledItems(list.current)[0]?.focus();
50
+ }, [open]);
51
+ const onKeyDown = (e) => {
52
+ if (e.key === "Escape") {
53
+ // Only if no submenu is open — that one owns Escape first, and
54
+ // closes back to here rather than out of the menu entirely.
55
+ if (list.current?.querySelector(".overflow-sub"))
56
+ return;
57
+ e.stopPropagation();
58
+ close();
59
+ return;
60
+ }
61
+ if (moveFocus(list.current, e.key))
62
+ e.preventDefault();
63
+ };
64
+ if (!actions.length)
65
+ return null;
66
+ const safe = actions.filter((a) => !a.danger);
67
+ const destructive = actions.filter((a) => a.danger);
68
+ const dismiss = () => close(false);
69
+ return (_jsxs("div", { className: "overflow-menu", children: [_jsx("button", { ref: trigger, type: "button", className: "kb-icon-btn", "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": open ? menuId : undefined, "aria-label": label, title: label, onClick: () => (open ? close() : setOpen(true)), children: _jsxs("svg", { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": "true", children: [_jsx("circle", { cx: "3", cy: "8", r: "1.4", fill: "currentColor" }), _jsx("circle", { cx: "8", cy: "8", r: "1.4", fill: "currentColor" }), _jsx("circle", { cx: "13", cy: "8", r: "1.4", fill: "currentColor" })] }) }), open && (_jsxs(_Fragment, { children: [_jsx("div", { className: "overflow-backdrop", onClick: dismiss }), _jsxs("div", { ref: list, id: menuId, className: "overflow-list", role: "menu", "aria-label": label, onKeyDown: onKeyDown, children: [safe.map((a) => (_jsx(Entry, { action: a, onDone: dismiss }, a.key))), destructive.length > 0 && safe.length > 0 && (_jsx("div", { className: "overflow-sep", role: "separator" })), destructive.map((a) => (_jsx(Entry, { action: a, onDone: dismiss }, a.key)))] })] }))] }));
70
+ }
71
+ function Entry({ action, onDone, }) {
72
+ return action.items?.length ? (_jsx(Submenu, { action: action, onDone: onDone })) : (_jsx(Item, { action: action, onDone: onDone }));
73
+ }
74
+ /**
75
+ * An item that opens its own list beside it.
76
+ *
77
+ * Opens to the *left*. The parent menu is already pinned to the right
78
+ * edge of what it hangs off, so a submenu flying out to the right —
79
+ * the desktop default — would open past the window.
80
+ */
81
+ function Submenu({ action, onDone, }) {
82
+ const [open, setOpen] = useState(false);
83
+ const item = useRef(null);
84
+ const list = useRef(null);
85
+ const menuId = useId();
86
+ useEffect(() => {
87
+ if (open)
88
+ enabledItems(list.current)[0]?.focus();
89
+ }, [open]);
90
+ const back = () => {
91
+ setOpen(false);
92
+ item.current?.focus();
93
+ };
94
+ return (_jsxs("div", { className: "overflow-sub-wrap",
95
+ // Hover opens it, the way a desktop menu does. `onMouseLeave`
96
+ // rather than a timer: a submenu that lingers after the pointer
97
+ // has gone covers the items below the one that opened it.
98
+ onMouseEnter: () => setOpen(true), onMouseLeave: () => setOpen(false), children: [_jsxs("button", { ref: item, type: "button", role: "menuitem", className: "popup-item overflow-item overflow-item-parent", "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": open ? menuId : undefined, disabled: action.disabled, title: action.title, onClick: () => setOpen((on) => !on), onKeyDown: (e) => {
99
+ // Right opens and steps in, matching every other menu on
100
+ // the desktop. Enter and Space come free from `button`.
101
+ if (e.key === "ArrowRight" || e.key === "Enter" || e.key === " ") {
102
+ e.preventDefault();
103
+ e.stopPropagation();
104
+ setOpen(true);
105
+ }
106
+ }, children: [action.icon && _jsx(MenuIcon, { name: action.icon }), action.label, _jsx("svg", { className: "overflow-chevron", viewBox: "0 0 16 16", width: "11", height: "11", "aria-hidden": "true", children: _jsx("path", { d: "M6 3.5 10.5 8 6 12.5", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round", strokeLinejoin: "round" }) })] }), open && (_jsx("div", { ref: list, id: menuId, className: "overflow-list overflow-sub", role: "menu", "aria-label": action.label, onKeyDown: (e) => {
107
+ // Escape and Left close *this* list and go back to the
108
+ // item that opened it, rather than dropping the whole
109
+ // menu — one level per keypress, like the trail does.
110
+ if (e.key === "Escape" || e.key === "ArrowLeft") {
111
+ e.preventDefault();
112
+ e.stopPropagation();
113
+ back();
114
+ return;
115
+ }
116
+ if (moveFocus(list.current, e.key)) {
117
+ e.preventDefault();
118
+ e.stopPropagation();
119
+ }
120
+ }, children: action.items?.map((child) => (_jsx(Item, { action: child, onDone: onDone, parent: action.label }, child.key))) }))] }));
121
+ }
122
+ function Item({ action, onDone, parent, }) {
123
+ return (_jsxs("button", { type: "button", role: "menuitem", "aria-current": action.active ? true : undefined, "aria-label": parent ? `${parent} ${action.label}` : undefined, className: [
124
+ "popup-item",
125
+ "overflow-item",
126
+ action.active ? "active" : "",
127
+ action.danger ? "overflow-item-danger" : "",
128
+ ]
129
+ .filter(Boolean)
130
+ .join(" "), disabled: action.disabled, title: action.title,
131
+ // Closed without pulling focus back to the trigger, because most
132
+ // of these actions replace the header the trigger lives in —
133
+ // restoring focus to an element that is about to unmount loses
134
+ // it on `document.body`. Where focus goes next belongs to the
135
+ // action. Dismissing without choosing still restores it.
136
+ onClick: () => {
137
+ onDone();
138
+ action.onSelect?.();
139
+ }, children: [action.icon && _jsx(MenuIcon, { name: action.icon }), action.label] }));
140
+ }
141
+ //# sourceMappingURL=OverflowMenu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverflowMenu.js","sourceRoot":"","sources":["../src/OverflowMenu.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACxE,OAAO,EAAE,QAAQ,EAAqB,MAAM,eAAe,CAAC;AA6C5D,uEAAuE;AACvE,MAAM,SAAS,GACb,6EAA6E,CAAC;AAEhF,SAAS,YAAY,CAAC,IAAwB;IAC5C,OAAO,KAAK,CAAC,IAAI,CACf,IAAI,EAAE,gBAAgB,CAAoB,SAAS,CAAC,IAAI,EAAE,CAC3D,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC;AAED,6EAA6E;AAC7E,SAAS,SAAS,CAAC,IAAwB,EAAE,GAAW;IACtD,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC3D,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,GAAG,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC9B,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAkC,CAAC,CAAC;IACpE,MAAM,IAAI,GAAG,GAAG,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,gEAAgE;IAChE,uCAAuC;IACvC,GAAG,CAAC,CAAC,EAAE,GAAG,IAAI,GAAG,GAAG,CAAC,MAAM,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no height, no `box-sizing`, nothing on `html`. So every
6
+ * full-frame extension opened by writing the same six lines of CSS,
7
+ * and wrote them differently. Two panels in one product then scroll
8
+ * differently, which is the kind of difference nobody can name and
9
+ * everybody notices.
10
+ *
11
+ * `min-height: 0` is the reason this is a published component rather
12
+ * than a recipe in a README. A flex child defaults to
13
+ * `min-height: auto`, which refuses to shrink below its content, so
14
+ * a scroll container nested in a flex column grows the page instead
15
+ * of scrolling. It is invisible until the content is long, it is the
16
+ * most-reported layout bug in flexbox, and the fix is one line that
17
+ * reads like it does nothing.
18
+ */
19
+ import type { HTMLAttributes, ReactNode } from "react";
20
+ /** What an {@link AppShell} takes. */
21
+ export interface AppShellProps extends HTMLAttributes<HTMLDivElement> {
22
+ /** Fixed at the top. A `Toolbar`, usually. */
23
+ header?: ReactNode;
24
+ /** Fixed at the bottom. Status, or a form's actions. */
25
+ footer?: ReactNode;
26
+ }
27
+ /**
28
+ * Header, body, footer — with exactly one part allowed to grow.
29
+ *
30
+ * The body is a flex column itself, so a `Scroll` placed directly
31
+ * inside it fills what is left over rather than the whole frame.
32
+ */
33
+ export declare function AppShell({ header, footer, children, className, ...rest }: AppShellProps): import("react").JSX.Element;
34
+ /** What a {@link Scroll} takes. */
35
+ export interface ScrollProps extends HTMLAttributes<HTMLDivElement> {
36
+ /** Scroll sideways instead. A wide table, not a long list. */
37
+ axis?: "y" | "x";
38
+ }
39
+ /**
40
+ * The part that scrolls.
41
+ *
42
+ * `overscroll-behavior: contain`, so reaching the end does not chain
43
+ * the scroll to the host page behind the frame — an extension that
44
+ * scrolls igni when its own list bottoms out feels like a bug in
45
+ * igni.
46
+ *
47
+ * Not focusable by default. A scrollable region that holds no
48
+ * focusable children is unreachable by keyboard, so pass
49
+ * `tabIndex={0}` when that is the case; doing it unconditionally
50
+ * would put a stop in the tab order of every list that already has
51
+ * buttons in it.
52
+ */
53
+ export declare function Scroll({ axis, className, ...rest }: ScrollProps): import("react").JSX.Element;
54
+ //# sourceMappingURL=Shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Shell.d.ts","sourceRoot":"","sources":["../src/Shell.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvD,sCAAsC;AACtC,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,cAAc,CAAC;IACnE,8CAA8C;IAC9C,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,wDAAwD;IACxD,MAAM,CAAC,EAAE,SAAS,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EACvB,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACR,EAAE,aAAa,+BAYf;AAED,mCAAmC;AACnC,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,cAAc,CAAC;IACjE,8DAA8D;IAC9D,IAAI,CAAC,EAAE,GAAG,GAAG,GAAG,CAAC;CAClB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,MAAM,CAAC,EAAE,IAAU,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,WAAW,+BAOrE"}
package/dist/Shell.js ADDED
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ function cx(...parts) {
3
+ return parts.filter(Boolean).join(" ");
4
+ }
5
+ /**
6
+ * Header, body, footer — with exactly one part allowed to grow.
7
+ *
8
+ * The body is a flex column itself, so a `Scroll` placed directly
9
+ * inside it fills what is left over rather than the whole frame.
10
+ */
11
+ export function AppShell({ header, footer, children, className, ...rest }) {
12
+ return (_jsxs("div", { ...rest, className: cx("ui-shell", className), children: [header === undefined ? null : (_jsx("div", { className: "ui-shell-header", children: header })), _jsx("div", { className: "ui-shell-body", children: children }), footer === undefined ? null : (_jsx("div", { className: "ui-shell-footer", children: footer }))] }));
13
+ }
14
+ /**
15
+ * The part that scrolls.
16
+ *
17
+ * `overscroll-behavior: contain`, so reaching the end does not chain
18
+ * the scroll to the host page behind the frame — an extension that
19
+ * scrolls igni when its own list bottoms out feels like a bug in
20
+ * igni.
21
+ *
22
+ * Not focusable by default. A scrollable region that holds no
23
+ * focusable children is unreachable by keyboard, so pass
24
+ * `tabIndex={0}` when that is the case; doing it unconditionally
25
+ * would put a stop in the tab order of every list that already has
26
+ * buttons in it.
27
+ */
28
+ export function Scroll({ axis = "y", className, ...rest }) {
29
+ return (_jsx("div", { ...rest, className: cx(axis === "x" ? "ui-scroll-x" : "ui-scroll", className) }));
30
+ }
31
+ //# sourceMappingURL=Shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Shell.js","sourceRoot":"","sources":["../src/Shell.tsx"],"names":[],"mappings":";AAoBA,SAAS,EAAE,CAAC,GAAG,KAA4C;IACzD,OAAO,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzC,CAAC;AAUD;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CAAC,EACvB,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,EACT,GAAG,IAAI,EACO;IACd,OAAO,CACL,kBAAS,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,aAChD,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC7B,cAAK,SAAS,EAAC,iBAAiB,YAAE,MAAM,GAAO,CAChD,EACD,cAAK,SAAS,EAAC,eAAe,YAAE,QAAQ,GAAO,EAC9C,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC7B,cAAK,SAAS,EAAC,iBAAiB,YAAE,MAAM,GAAO,CAChD,IACG,CACP,CAAC;AACJ,CAAC;AAQD;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,MAAM,CAAC,EAAE,IAAI,GAAG,GAAG,EAAE,SAAS,EAAE,GAAG,IAAI,EAAe;IACpE,OAAO,CACL,iBACM,IAAI,EACR,SAAS,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,WAAW,EAAE,SAAS,CAAC,GACpE,CACH,CAAC;AACJ,CAAC"}