eslint-plugin-web-components-doctor 0.3.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 (55) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +309 -0
  3. package/dist/adapters/jsx-adapter.d.ts +20 -0
  4. package/dist/adapters/jsx-adapter.d.ts.map +1 -0
  5. package/dist/adapters/jsx-adapter.js +150 -0
  6. package/dist/adapters/jsx-adapter.js.map +1 -0
  7. package/dist/adapters/lit-adapter.d.ts +19 -0
  8. package/dist/adapters/lit-adapter.d.ts.map +1 -0
  9. package/dist/adapters/lit-adapter.js +145 -0
  10. package/dist/adapters/lit-adapter.js.map +1 -0
  11. package/dist/adapters/utils.d.ts +36 -0
  12. package/dist/adapters/utils.d.ts.map +1 -0
  13. package/dist/adapters/utils.js +58 -0
  14. package/dist/adapters/utils.js.map +1 -0
  15. package/dist/core/rule-factory.d.ts +44 -0
  16. package/dist/core/rule-factory.d.ts.map +1 -0
  17. package/dist/core/rule-factory.js +443 -0
  18. package/dist/core/rule-factory.js.map +1 -0
  19. package/dist/core/types.d.ts +103 -0
  20. package/dist/core/types.d.ts.map +1 -0
  21. package/dist/core/types.js +13 -0
  22. package/dist/core/types.js.map +1 -0
  23. package/dist/descriptors/components.d.ts +21 -0
  24. package/dist/descriptors/components.d.ts.map +1 -0
  25. package/dist/descriptors/components.js +249 -0
  26. package/dist/descriptors/components.js.map +1 -0
  27. package/dist/index.d.ts +39 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +77 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/rules/accessible-component.d.ts +13 -0
  32. package/dist/rules/accessible-component.d.ts.map +1 -0
  33. package/dist/rules/accessible-component.js +15 -0
  34. package/dist/rules/accessible-component.js.map +1 -0
  35. package/dist/rules/no-deprecated.d.ts +13 -0
  36. package/dist/rules/no-deprecated.d.ts.map +1 -0
  37. package/dist/rules/no-deprecated.js +15 -0
  38. package/dist/rules/no-deprecated.js.map +1 -0
  39. package/dist/rules/required-attributes.d.ts +13 -0
  40. package/dist/rules/required-attributes.d.ts.map +1 -0
  41. package/dist/rules/required-attributes.js +15 -0
  42. package/dist/rules/required-attributes.js.map +1 -0
  43. package/dist/rules/valid-attribute-values.d.ts +13 -0
  44. package/dist/rules/valid-attribute-values.d.ts.map +1 -0
  45. package/dist/rules/valid-attribute-values.js +15 -0
  46. package/dist/rules/valid-attribute-values.js.map +1 -0
  47. package/dist/rules/valid-slot-children.d.ts +13 -0
  48. package/dist/rules/valid-slot-children.d.ts.map +1 -0
  49. package/dist/rules/valid-slot-children.js +15 -0
  50. package/dist/rules/valid-slot-children.js.map +1 -0
  51. package/dist/rules/valid-slot-names.d.ts +13 -0
  52. package/dist/rules/valid-slot-names.d.ts.map +1 -0
  53. package/dist/rules/valid-slot-names.js +15 -0
  54. package/dist/rules/valid-slot-names.js.map +1 -0
  55. package/package.json +64 -0
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import type { Rule } from 'eslint';
13
+ import type { ParsedElement } from '../core/types.js';
14
+ /**
15
+ * Extract all SWC elements from a Lit `html` tagged template expression.
16
+ * Returns an empty array if the node is not a Lit template.
17
+ */
18
+ export declare function extractElementsFromTemplate(node: Rule.Node): ParsedElement[];
19
+ //# sourceMappingURL=lit-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lit-adapter.d.ts","sourceRoot":"","sources":["../../src/adapters/lit-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAiKtE;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,aAAa,EAAE,CAa5E"}
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import { parseFragment } from 'parse5';
13
+ /** Placeholder inserted where template expressions (${...}) appear. */
14
+ const EXPR_PLACEHOLDER = '\u200B__SWC_EXPR__\u200B';
15
+ const LIT_HTML_TAGS = new Set(['html']);
16
+ /**
17
+ * Check whether an ESTree node is a Lit `html` tagged template expression.
18
+ */
19
+ function isLitHtmlTemplate(node) {
20
+ if (node.type !== 'TaggedTemplateExpression')
21
+ return false;
22
+ const te = node;
23
+ const { tag } = te;
24
+ if (tag.type === 'Identifier' && LIT_HTML_TAGS.has(tag.name ?? '')) {
25
+ return true;
26
+ }
27
+ if (tag.type === 'MemberExpression' &&
28
+ tag.property?.name &&
29
+ LIT_HTML_TAGS.has(tag.property.name)) {
30
+ return true;
31
+ }
32
+ return false;
33
+ }
34
+ /**
35
+ * Reconstruct the template text from quasis, inserting placeholders for expressions.
36
+ */
37
+ function getTemplateText(node) {
38
+ const te = node;
39
+ return te.quasi.quasis
40
+ .map((quasi, i) => {
41
+ const text = quasi.value.raw;
42
+ if (i < te.quasi.quasis.length - 1) {
43
+ return text + EXPR_PLACEHOLDER;
44
+ }
45
+ return text;
46
+ })
47
+ .join('');
48
+ }
49
+ /**
50
+ * Parse an attribute name that may have Lit binding prefixes.
51
+ */
52
+ function parseAttributeName(raw) {
53
+ if (raw.startsWith('.'))
54
+ return { name: raw.slice(1), bindingType: '.' };
55
+ if (raw.startsWith('?'))
56
+ return { name: raw.slice(1), bindingType: '?' };
57
+ if (raw.startsWith('@'))
58
+ return { name: raw.slice(1), bindingType: '@' };
59
+ return { name: raw };
60
+ }
61
+ /**
62
+ * Convert a parse5 document fragment into our normalized ParsedElement[].
63
+ * Only returns elements whose tag names start with `sp-` or are `overlay-trigger`.
64
+ */
65
+ function extractFromParse5(fragment) {
66
+ const results = [];
67
+ function walk(nodes) {
68
+ const localResults = [];
69
+ for (const node of nodes) {
70
+ if (node.nodeName === '#text')
71
+ continue;
72
+ if (node.nodeName === '#comment')
73
+ continue;
74
+ const tagName = node.tagName ?? node.nodeName;
75
+ const childElements = node.childNodes ? walk(node.childNodes) : [];
76
+ const isSwcElement = tagName.startsWith('sp-') || tagName === 'overlay-trigger';
77
+ if (!isSwcElement) {
78
+ localResults.push(...childElements);
79
+ continue;
80
+ }
81
+ const attributes = new Map();
82
+ if (node.attrs) {
83
+ for (const attr of node.attrs) {
84
+ const { name, bindingType } = parseAttributeName(attr.name);
85
+ const isDynamic = attr.value.includes(EXPR_PLACEHOLDER);
86
+ attributes.set(name, {
87
+ value: isDynamic ? null : attr.value,
88
+ isDynamic,
89
+ bindingType,
90
+ });
91
+ }
92
+ }
93
+ let hasTextContent = false;
94
+ if (node.childNodes) {
95
+ for (const child of node.childNodes) {
96
+ if (child.nodeName === '#text') {
97
+ const text = child.value ?? '';
98
+ const stripped = text.replace(/\u200B__SWC_EXPR__\u200B/g, '').trim();
99
+ if (stripped.length > 0) {
100
+ hasTextContent = true;
101
+ break;
102
+ }
103
+ }
104
+ }
105
+ }
106
+ localResults.push({
107
+ tagName,
108
+ attributes,
109
+ children: childElements,
110
+ hasTextContent,
111
+ loc: node.sourceCodeLocation
112
+ ? {
113
+ startOffset: node.sourceCodeLocation.startOffset,
114
+ endOffset: node.sourceCodeLocation.endOffset,
115
+ startLine: node.sourceCodeLocation.startLine,
116
+ startCol: node.sourceCodeLocation.startCol,
117
+ }
118
+ : undefined,
119
+ });
120
+ }
121
+ return localResults;
122
+ }
123
+ const nodes = fragment.childNodes;
124
+ results.push(...walk(nodes));
125
+ return results;
126
+ }
127
+ /**
128
+ * Extract all SWC elements from a Lit `html` tagged template expression.
129
+ * Returns an empty array if the node is not a Lit template.
130
+ */
131
+ export function extractElementsFromTemplate(node) {
132
+ if (!isLitHtmlTemplate(node))
133
+ return [];
134
+ const templateText = getTemplateText(node);
135
+ try {
136
+ const fragment = parseFragment(templateText, {
137
+ sourceCodeLocationInfo: true,
138
+ });
139
+ return extractFromParse5(fragment);
140
+ }
141
+ catch {
142
+ return [];
143
+ }
144
+ }
145
+ //# sourceMappingURL=lit-adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lit-adapter.js","sourceRoot":"","sources":["../../src/adapters/lit-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAIvC,uEAAuE;AACvE,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AAEpD,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAExC;;GAEG;AACH,SAAS,iBAAiB,CAAC,IAAe;IACxC,IAAI,IAAI,CAAC,IAAI,KAAK,0BAA0B;QAAE,OAAO,KAAK,CAAC;IAE3D,MAAM,EAAE,GAAG,IAGV,CAAC;IAEF,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;IAEnB,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAC;QACnE,OAAO,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AAe;IACzD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC;IAExC,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAE3C,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,aAAa,CAAC,YAAY,EAAE;YAC3C,sBAAsB,EAAE,IAAI;SAC7B,CAAC,CAAC;QACH,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ /**
13
+ * Convert a PascalCase SWC React wrapper name to its kebab-case tag name.
14
+ * e.g. "SpActionMenu" -> "sp-action-menu", "SpProgressBar" -> "sp-progress-bar"
15
+ */
16
+ export declare function pascalToKebab(name: string): string;
17
+ /**
18
+ * Convert a camelCase JSX prop name to its kebab-case HTML attribute equivalent.
19
+ * e.g. "ariaLabel" -> "aria-label", "isDecorative" -> "is-decorative"
20
+ */
21
+ export declare function camelToKebab(name: string): string;
22
+ /**
23
+ * Check whether a kebab-case tag name is a recognized SWC element.
24
+ */
25
+ export declare function isSwcTagName(tagName: string): boolean;
26
+ /**
27
+ * Check whether a JSX tag name looks like an SWC React wrapper (PascalCase starting with "Sp")
28
+ * or a custom element used directly in JSX (kebab-case starting with "sp-").
29
+ */
30
+ export declare function isSwcJsxTag(name: string): boolean;
31
+ /**
32
+ * Resolve a JSX tag name to its canonical kebab-case SWC tag name.
33
+ * Handles both PascalCase wrappers and direct custom element usage.
34
+ */
35
+ export declare function resolveJsxTagName(name: string): string;
36
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/adapters/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMlD;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKjD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAItD"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ /**
13
+ * Convert a PascalCase SWC React wrapper name to its kebab-case tag name.
14
+ * e.g. "SpActionMenu" -> "sp-action-menu", "SpProgressBar" -> "sp-progress-bar"
15
+ */
16
+ export function pascalToKebab(name) {
17
+ return name
18
+ .replace(/([A-Z])/g, (match, char, index) => index === 0 ? char.toLowerCase() : `-${char.toLowerCase()}`)
19
+ .replace(/^sp-/, 'sp-');
20
+ }
21
+ /**
22
+ * Convert a camelCase JSX prop name to its kebab-case HTML attribute equivalent.
23
+ * e.g. "ariaLabel" -> "aria-label", "isDecorative" -> "is-decorative"
24
+ */
25
+ export function camelToKebab(name) {
26
+ return name.replace(/([A-Z])/g, '-$1').toLowerCase();
27
+ }
28
+ /**
29
+ * Check whether a kebab-case tag name is a recognized SWC element.
30
+ */
31
+ export function isSwcTagName(tagName) {
32
+ return tagName.startsWith('sp-') || tagName === 'overlay-trigger';
33
+ }
34
+ /**
35
+ * Check whether a JSX tag name looks like an SWC React wrapper (PascalCase starting with "Sp")
36
+ * or a custom element used directly in JSX (kebab-case starting with "sp-").
37
+ */
38
+ export function isSwcJsxTag(name) {
39
+ if (name.startsWith('sp-') || name === 'overlay-trigger')
40
+ return true;
41
+ if (/^Sp[A-Z]/.test(name))
42
+ return true;
43
+ if (name === 'OverlayTrigger')
44
+ return true;
45
+ return false;
46
+ }
47
+ /**
48
+ * Resolve a JSX tag name to its canonical kebab-case SWC tag name.
49
+ * Handles both PascalCase wrappers and direct custom element usage.
50
+ */
51
+ export function resolveJsxTagName(name) {
52
+ if (name.startsWith('sp-') || name === 'overlay-trigger')
53
+ return name;
54
+ if (name === 'OverlayTrigger')
55
+ return 'overlay-trigger';
56
+ return pascalToKebab(name);
57
+ }
58
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/adapters/utils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY;IACxC,OAAO,IAAI;SACR,OAAO,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CAC1C,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAC5D;SACA,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,OAAO,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,iBAAiB,CAAC;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC;IACtE,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACvC,IAAI,IAAI,KAAK,gBAAgB;QAAE,OAAO,IAAI,CAAC;IAC3C,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,IAAI,KAAK,iBAAiB;QAAE,OAAO,IAAI,CAAC;IACtE,IAAI,IAAI,KAAK,gBAAgB;QAAE,OAAO,iBAAiB,CAAC;IACxD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Copyright 2026 Adobe. All rights reserved.
3
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License. You may obtain a copy
5
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
6
+ *
7
+ * Unless required by applicable law or agreed to in writing, software distributed under
8
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9
+ * OF ANY KIND, either express or implied. See the License for the specific language
10
+ * governing permissions and limitations under the License.
11
+ */
12
+ import type { Rule } from 'eslint';
13
+ import type { ComponentDescriptorMap } from './types.js';
14
+ type RuleModule = Rule.RuleModule;
15
+ /**
16
+ * Creates the `accessible-component` rule that checks all components
17
+ * against their accessibility descriptors.
18
+ */
19
+ export declare function createAccessibleComponentRule(descriptors: ComponentDescriptorMap): RuleModule;
20
+ /**
21
+ * Creates the `no-deprecated` rule that flags deprecated attributes
22
+ * and attribute values across all described components.
23
+ */
24
+ export declare function createNoDeprecatedRule(descriptors: ComponentDescriptorMap): RuleModule;
25
+ /**
26
+ * Creates the `required-attributes` rule.
27
+ */
28
+ export declare function createRequiredAttributesRule(descriptors: ComponentDescriptorMap): RuleModule;
29
+ /**
30
+ * Creates the `valid-attribute-values` rule.
31
+ */
32
+ export declare function createValidAttributeValuesRule(descriptors: ComponentDescriptorMap): RuleModule;
33
+ /**
34
+ * Creates the `valid-slot-names` rule that checks children aren't placed
35
+ * into non-existent slots.
36
+ */
37
+ export declare function createValidSlotNamesRule(descriptors: ComponentDescriptorMap): RuleModule;
38
+ /**
39
+ * Creates the `valid-slot-children` rule that checks a child element's tag
40
+ * is accepted in the slot it targets.
41
+ */
42
+ export declare function createValidSlotChildrenRule(descriptors: ComponentDescriptorMap): RuleModule;
43
+ export {};
44
+ //# sourceMappingURL=rule-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rule-factory.d.ts","sourceRoot":"","sources":["../../src/core/rule-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,KAAK,EAEV,sBAAsB,EAKvB,MAAM,YAAY,CAAC;AAIpB,KAAK,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;AAmClC;;;GAGG;AACH,wBAAgB,6BAA6B,CAC3C,WAAW,EAAE,sBAAsB,GAClC,UAAU,CAyGZ;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,sBAAsB,GAClC,UAAU,CAyEZ;AAED;;GAEG;AACH,wBAAgB,4BAA4B,CAC1C,WAAW,EAAE,sBAAsB,GAClC,UAAU,CA8CZ;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,WAAW,EAAE,sBAAsB,GAClC,UAAU,CAwDZ;AAYD;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,WAAW,EAAE,sBAAsB,GAClC,UAAU,CAwDZ;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,WAAW,EAAE,sBAAsB,GAClC,UAAU,CA8DZ"}