@spectrum-web-components/iconset 0.42.3 → 0.42.5

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-web-components/iconset",
3
- "version": "0.42.3",
3
+ "version": "0.42.5",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -60,7 +60,7 @@
60
60
  "lit-html"
61
61
  ],
62
62
  "dependencies": {
63
- "@spectrum-web-components/base": "^0.42.3"
63
+ "@spectrum-web-components/base": "^0.42.5"
64
64
  },
65
65
  "types": "./src/index.d.ts",
66
66
  "customElements": "custom-elements.json",
@@ -70,5 +70,5 @@
70
70
  "./stories/icons-demo.js",
71
71
  "./**/*.dev.js"
72
72
  ],
73
- "gitHead": "a03edce4f21f232f1705d8eb222e6e5436cad4c3"
73
+ "gitHead": "f29fd737947945de8cd6f5bc03fb389d386c9c3a"
74
74
  }
@@ -6,8 +6,7 @@ var __decorateClass = (decorators, target, key, kind) => {
6
6
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
7
  if (decorator = decorators[i])
8
8
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
- if (kind && result)
10
- __defProp(target, key, result);
9
+ if (kind && result) __defProp(target, key, result);
11
10
  return result;
12
11
  };
13
12
  import {
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["iconset-svg.ts"],
4
4
  "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\n\nimport {\n html,\n PropertyValues,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport { query } from '@spectrum-web-components/base/src/decorators.js';\n\nimport { Iconset } from './iconset.dev.js'\n\nexport abstract class IconsetSVG extends Iconset {\n private iconMap: Map<string, SVGSymbolElement> = new Map();\n\n @query('slot')\n private slotContainer?: HTMLSlotElement;\n\n /**\n * First updated handler just ensures we've processed any slotted symbols\n */\n public override updated(changedProperties: PropertyValues): void {\n if (!this.slotContainer) {\n return;\n }\n const currentSVGNodes = this.getSVGNodes(this.slotContainer);\n this.updateSVG(currentSVGNodes);\n super.updated(changedProperties);\n }\n /**\n * Applies the requested icon from this iconset instance to the given element.\n *\n * @param el - the element to apply the icon to\n * @param icon - the name of the icon within this set to apply.\n */\n public async applyIconToElement(\n el: HTMLElement,\n icon: string,\n _size: string,\n label: string\n ): Promise<void> {\n await this.updateComplete;\n const iconSymbol = this.iconMap.get(icon);\n if (!iconSymbol) {\n throw new Error(`Unable to find icon ${icon}`);\n }\n // we cannot share a single SVG globally across shadowroot boundaries\n // so copy the template node so we can inject it where we need it\n const clonedNode = this.prepareSvgClone(iconSymbol);\n clonedNode.setAttribute('role', 'img');\n if (label) {\n clonedNode.setAttribute('aria-label', label);\n } else {\n clonedNode.setAttribute('aria-hidden', 'true');\n }\n // append the svg to the node either in its shadowroot or directly into its dom\n if (el.shadowRoot) {\n el.shadowRoot.appendChild(clonedNode);\n } else {\n el.appendChild(clonedNode);\n }\n }\n\n /**\n * Returns a list of all icons in this iconset.\n */\n public getIconList(): string[] {\n return [...this.iconMap.keys()];\n }\n\n protected prepareSvgClone(sourceSvg: SVGSymbolElement): SVGSVGElement {\n const content = sourceSvg.cloneNode(true) as SVGSymbolElement;\n // we're going to create a new svg element that will have our symbol geometry inside\n const svg = document.createElementNS(\n 'http://www.w3.org/2000/svg',\n 'svg'\n );\n const viewBox = content.getAttribute('viewBox') || '';\n // inline style isn't ideal but will work in all cases and means our icons don't need to know\n // if they are svg or spritesheet provided\n const cssText =\n 'pointer-events: none; display: block; width: 100%; height: 100%;';\n svg.style.cssText = cssText;\n // copy the viewbox and other properties into the svg\n svg.setAttribute('viewBox', viewBox);\n svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');\n svg.setAttribute('focusable', 'false');\n // move all the child nodes over to the svg\n while (content.childNodes.length > 0) {\n svg.appendChild(content.childNodes[0]);\n }\n return svg;\n }\n protected getSVGIconName(icon: string): string {\n return icon;\n }\n protected getSanitizedIconName(icon: string): string {\n return icon;\n }\n protected renderDefaultContent(): TemplateResult {\n return html``;\n }\n\n protected override render(): TemplateResult {\n return html`\n <slot @slotchange=${this.onSlotChange}>\n ${this.renderDefaultContent()}\n </slot>\n `;\n }\n\n protected updateSVG(nodes: SVGElement[]): void {\n // iterate over the nodes that were passed in, and find all the top level symbols\n const symbols = nodes.reduce((prev, svgNode) => {\n const containedSymbols = svgNode.querySelectorAll('symbol');\n prev.push(...containedSymbols);\n return prev;\n }, [] as SVGSymbolElement[]);\n symbols.forEach((symbol) => {\n this.iconMap.set(this.getSanitizedIconName(symbol.id), symbol);\n });\n }\n\n protected getSVGNodes(slotTarget: HTMLSlotElement): SVGElement[] {\n const nodes = slotTarget.assignedNodes({ flatten: true });\n // find all the svg nodes\n const svgNodes = nodes.filter((node) => {\n return node.nodeName === 'svg';\n }) as SVGElement[];\n return svgNodes;\n }\n\n private onSlotChange(event: Event): void {\n const slotTarget = event.target as HTMLSlotElement;\n const svgNodes = this.getSVGNodes(slotTarget);\n this.updateSVG(svgNodes);\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;AAYA;AAAA,EACI;AAAA,OAGG;AACP,SAAS,aAAa;AAEtB,SAAS,eAAe;AAEjB,aAAe,mBAAmB,QAAQ;AAAA,EAA1C;AAAA;AACH,SAAQ,UAAyC,oBAAI,IAAI;AAAA;AAAA;AAAA;AAAA;AAAA,EAQzC,QAAQ,mBAAyC;AAC7D,QAAI,CAAC,KAAK,eAAe;AACrB;AAAA,IACJ;AACA,UAAM,kBAAkB,KAAK,YAAY,KAAK,aAAa;AAC3D,SAAK,UAAU,eAAe;AAC9B,UAAM,QA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AU,OAA2B;AAE3C,UAAM,UAAU,MAAM,OAAO,CAAC,MAAM,YAAY;AAC5C,YAAM,mBAAmB,QAAQ,iBAAiB,QAAQ;AAC1D,WAAK,KAAK,GAAG,gBAAgB;AAC7B,aAAO;AAAA,IACX,GAAG,CAAC,CAAuB;AAC3B,YAAQ,QAAQ,CAAC,WAAW;AACxB,WAAK,QAAQ,IAAI,KAAK,qBAAqB,OAAO,EAAE,GAAG,MAAM;AAAA,IACjE,CAAC;AAAA,EACL;AAAA,EAEU,YAAY,YAA2C;AAC7D,UAAM,QAAQ,WAAW,cAAc,EAAE,SAAS,KAAK,CAAC;AAExD,UAAM,WAAW,MAAM,OAAO,CAAC,SAAS;AACpC,aAAO,KAAK,aAAa;AAAA,IAC7B,CAAC;AACD,WAAO;AAAA,EACX;AAAA,EAEQ,aAAa,OAAoB;AACrC,UAAM,aAAa,MAAM;AACzB,UAAM,WAAW,KAAK,YAAY,UAAU;AAC5C,SAAK,UAAU,QAAQ;AAAA,EAC3B;AACJ;AAzHY;AAAA,EADP,MAAM,MAAM;AAAA,GAHK,WAIV;",
6
6
  "names": []
7
7
  }
@@ -6,8 +6,7 @@ var __decorateClass = (decorators, target, key, kind) => {
6
6
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
7
  if (decorator = decorators[i])
8
8
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
- if (kind && result)
10
- __defProp(target, key, result);
9
+ if (kind && result) __defProp(target, key, result);
11
10
  return result;
12
11
  };
13
12
  import { IconsetRegistry } from "./iconset-registry.dev.js";
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["iconset.ts"],
4
4
  "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { IconsetRegistry } from './iconset-registry.dev.js'\n\nimport { LitElement } from '@spectrum-web-components/base';\nimport { property } from '@spectrum-web-components/base/src/decorators.js';\n\nexport abstract class Iconset extends LitElement {\n protected registered = false;\n\n private _name!: string;\n\n protected override firstUpdated(): void {\n // force no display for all iconsets\n this.style.display = 'none';\n if (window.__swc.DEBUG) {\n window.__swc.warn(\n this,\n 'Iconsets have been deprecated and will be removed from the project in an upcoming version. For default Spectrum Icons, learn more about leveraging UI Icons (https://opensource.adobe.com/spectrum-web-components/components/icons-ui/) or Workflow Icons (https://opensource.adobe.com/spectrum-web-components/components/icons-workflow/) as an alternative.',\n 'https://opensource.adobe.com/spectrum-web-components/components/iconset/#deprecated',\n { level: 'deprecation' }\n );\n }\n }\n\n /**\n * Name of the iconset, used by the IconsetRegistry to serve this icon set\n * to consuming icons.\n */\n @property()\n public set name(value: string) {\n // if we're already registered in the iconset registry\n // we'll need to update our registration\n if (this.registered) {\n if (this._name) {\n // remove from the iconset map using the old name\n IconsetRegistry.getInstance().removeIconset(this._name);\n }\n\n if (value) {\n // set in the map using the new name\n IconsetRegistry.getInstance().addIconset(value, this);\n }\n }\n this._name = value;\n }\n public get name(): string {\n return this._name;\n }\n\n /**\n * Applies an icon to the given element\n */\n public abstract applyIconToElement(\n el: HTMLElement,\n icon: string,\n size: string,\n label: string\n ): void;\n\n /**\n * Returns a list of all icons in this iconset.\n */\n public abstract getIconList(): string[];\n\n private handleRemoved = ({\n detail,\n }: {\n detail: { name: string };\n }): void => {\n if (detail.name === this.name) {\n this.registered = false;\n this.addIconset();\n }\n };\n\n /**\n * On updated we register the iconset if we're not already registered\n */\n public override connectedCallback(): void {\n super.connectedCallback();\n this.addIconset();\n window.addEventListener('sp-iconset-removed', this.handleRemoved);\n }\n /**\n * On disconnected we remove the iconset\n */\n public override disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener('sp-iconset-removed', this.handleRemoved);\n this.removeIconset();\n }\n\n private addIconset(): void {\n if (!this.name || this.registered) {\n return;\n }\n IconsetRegistry.getInstance().addIconset(this.name, this);\n this.registered = true;\n }\n\n private removeIconset(): void {\n if (!this.name) {\n return;\n }\n IconsetRegistry.getInstance().removeIconset(this.name);\n this.registered = false;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;AAWA,SAAS,uBAAuB;AAEhC,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AAElB,aAAe,gBAAgB,WAAW;AAAA,EAA1C;AAAA;AACH,SAAU,aAAa;AAyDvB,SAAQ,gBAAgB,CAAC;AAAA,MACrB;AAAA,IACJ,MAEY;AACR,UAAI,OAAO,SAAS,KAAK,MAAM;AAC3B,aAAK,aAAa;AAClB,aAAK,WAAW;AAAA,MACpB;AAAA,IACJ;AAAA;AAAA,EA9DmB,eAAqB;AAEpC,SAAK,MAAM,UAAU;AACrB,QAAI,MAAoB;AACpB,aAAO,MAAM;AAAA,QACT;AAAA,QACA;AAAA,QACA;AAAA,QACA,EAAE,OAAO,cAAc;AAAA,MAC3B;AAAA,IACJ;AAAA,EACJ;AAAA,EAOA,IAAW,KAAK,OAAe;AAG3B,QAAI,KAAK,YAAY;AACjB,UAAI,KAAK,OAAO;AAEZ,wBAAgB,YAAY,EAAE,cAAc,KAAK,KAAK;AAAA,MAC1D;AAEA,UAAI,OAAO;AAEP,wBAAgB,YAAY,EAAE,WAAW,OAAO,IAAI;AAAA,MACxD;AAAA,IACJ;AACA,SAAK,QAAQ;AAAA,EACjB;AAAA,EACA,IAAW,OAAe;AACtB,WAAO,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EA+BgB,oBAA0B;AACtC,UAAM,kBAAkB;AACxB,SAAK,WAAW;AAChB,WAAO,iBAAiB,sBAAsB,KAAK,aAAa;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA,EAIgB,uBAA6B;AACzC,U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O,KAAK;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EA+BgB,oBAA0B;AACtC,UAAM,kBAAkB;AACxB,SAAK,WAAW;AAChB,WAAO,iBAAiB,sBAAsB,KAAK,aAAa;AAAA,EACpE;AAAA;AAAA;AAAA;AAAA,EAIgB,uBAA6B;AACzC,UAAM,qBAAqB;AAC3B,WAAO,oBAAoB,sBAAsB,KAAK,aAAa;AACnE,SAAK,cAAc;AAAA,EACvB;AAAA,EAEQ,aAAmB;AACvB,QAAI,CAAC,KAAK,QAAQ,KAAK,YAAY;AAC/B;AAAA,IACJ;AACA,oBAAgB,YAAY,EAAE,WAAW,KAAK,MAAM,IAAI;AACxD,SAAK,aAAa;AAAA,EACtB;AAAA,EAEQ,gBAAsB;AAC1B,QAAI,CAAC,KAAK,MAAM;AACZ;AAAA,IACJ;AACA,oBAAgB,YAAY,EAAE,cAAc,KAAK,IAAI;AACrD,SAAK,aAAa;AAAA,EACtB;AACJ;AA9Ee;AAAA,EADV,SAAS;AAAA,GAtBQ,QAuBP;",
6
6
  "names": []
7
7
  }
@@ -6,8 +6,7 @@ var __decorateClass = (decorators, target, key, kind) => {
6
6
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
7
7
  if (decorator = decorators[i])
8
8
  result = (kind ? decorator(target, key, result) : decorator(result)) || result;
9
- if (kind && result)
10
- __defProp(target, key, result);
9
+ if (kind && result) __defProp(target, key, result);
11
10
  return result;
12
11
  };
13
12
  import {
@@ -134,8 +133,7 @@ export let IconsDemo = class extends SpectrumElement {
134
133
  this.shouldCopy(tag);
135
134
  }
136
135
  shouldCopy(tag) {
137
- if (!this.package)
138
- return;
136
+ if (!this.package) return;
139
137
  const conditionedTag = tag.slice(1, tag.length - 1);
140
138
  const importURL = `import '@spectrum-web-components/${this.package}/icons/${conditionedTag}.js';`;
141
139
  this.dispatchEvent(
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["icons-demo.ts"],
4
4
  "sourcesContent": ["/*\nCopyright 2020 Adobe. All rights reserved.\nThis file is licensed to you under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License. You may obtain a copy\nof the License at http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software distributed under\nthe License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\nOF ANY KIND, either express or implied. See the License for the specific language\ngoverning permissions and limitations under the License.\n*/\nimport { IconsetAddedDetail } from '@spectrum-web-components/iconset';\nimport {\n css,\n CSSResultGroup,\n html,\n SpectrumElement,\n TemplateResult,\n} from '@spectrum-web-components/base';\nimport {\n customElement,\n property,\n} from '@spectrum-web-components/base/src/decorators.js';\nimport { ifDefined } from '@spectrum-web-components/base/src/directives.js';\nimport { Search } from '@spectrum-web-components/search';\nimport '@spectrum-web-components/search/sp-search.js';\nimport '@spectrum-web-components/field-label/sp-field-label.js';\nimport bodyStyles from '@spectrum-web-components/styles/body.js';\nimport '@spectrum-web-components/icon/sp-icon.js';\nimport '@spectrum-web-components/help-text/sp-help-text.js';\n\n@customElement('delayed-ready')\nexport class DelayedReady extends SpectrumElement {\n _delayedReady!: Promise<void>;\n _resolveDelayedReady!: () => void;\n\n protected override render(): TemplateResult {\n return html`\n <slot @slotchange=${this.handleSlotchange}></slot>\n `;\n }\n\n protected override firstUpdated(): void {\n this._delayedReady = new Promise(\n (res) => (this._resolveDelayedReady = res)\n );\n }\n\n protected override async getUpdateComplete(): Promise<boolean> {\n const complete = (await super.getUpdateComplete()) as boolean;\n await this._delayedReady;\n return complete;\n }\n\n public handleSlotchange({\n target,\n }: Event & { target: HTMLSlotElement }): void {\n if (target.assignedElements({ flatten: true }).length) {\n requestAnimationFrame(() => {\n this._resolveDelayedReady();\n });\n }\n }\n}\n\n@customElement('icons-demo')\nexport class IconsDemo extends SpectrumElement {\n @property()\n public name = 'ui';\n\n @property()\n public package = '';\n\n @property()\n public size = 'm';\n\n @property()\n public search = '';\n\n @property({ attribute: false })\n public icons: {\n name: string;\n story(size: string): TemplateResult;\n tag: string;\n }[] = [];\n\n private iconset: string[] = [];\n public constructor() {\n super();\n this.iconset = [];\n this.handleIconSetAdded = this.handleIconSetAdded.bind(this);\n }\n public override connectedCallback(): void {\n super.connectedCallback();\n window.addEventListener('sp-iconset-added', this.handleIconSetAdded);\n }\n public override disconnectedCallback(): void {\n window.removeEventListener('sp-iconset-added', this.handleIconSetAdded);\n super.disconnectedCallback();\n }\n public handleIconSetAdded(event: CustomEvent<IconsetAddedDetail>): void {\n const { iconset } = event.detail;\n this.iconset = iconset.getIconList();\n this.requestUpdate();\n }\n public static override get styles(): CSSResultGroup {\n return [\n ...bodyStyles,\n css`\n :host {\n display: grid;\n grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));\n gap: 20px;\n align-items: flex-start;\n }\n .icon {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n border-radius: var(\n --spectrum-alias-focus-ring-gap,\n var(--spectrum-global-dimension-static-size-25)\n );\n }\n :host([package]) .icon {\n cursor: pointer;\n }\n sp-icon {\n margin-bottom: 10px;\n }\n .search {\n grid-column-start: 1;\n grid-column-end: -1;\n }\n .icon[tabindex]:focus {\n outline: none;\n }\n .icon[tabindex]:focus-visible {\n outline: var(--spectrum-alias-focus-ring-size) solid\n var(--spectrum-alias-focus-ring-color);\n outline-offset: calc(\n var(\n --spectrum-alias-focus-ring-gap,\n var(--spectrum-global-dimension-static-size-25)\n ) * 2\n );\n }\n `,\n ];\n }\n private handleKeydown(event: KeyboardEvent, tag: string): void {\n const { code } = event;\n if (code !== 'Enter' && code !== 'NumpadEnter' && code !== 'Space') {\n return;\n }\n event.preventDefault();\n this.shouldCopy(tag);\n }\n\n private shouldCopy(tag: string): void {\n if (!this.package) return;\n const conditionedTag = tag.slice(1, tag.length - 1);\n const importURL = `import '@spectrum-web-components/${this.package}/icons/${conditionedTag}.js';`;\n this.dispatchEvent(\n new CustomEvent('copy-text', {\n bubbles: true,\n composed: true,\n detail: {\n message: 'Import statement copied to clipboard!',\n text: importURL,\n },\n })\n );\n }\n private updateSearch(event: Event & { target: Search }): void {\n event.stopPropagation();\n this.search = event.target.value;\n }\n private submit(event: Event & { target: Search }): void {\n event.stopPropagation();\n this.updateSearch(event);\n }\n private renderSearch(): TemplateResult {\n const matchingIcons = this.search\n ? this.icons.filter(\n (icon) => icon.name.toLowerCase().search(this.search) !== -1\n )\n : this.icons;\n return html`\n <div class=\"search\" part=\"search\">\n <sp-field-label for=\"search\">Spectrum icons:</sp-field-label>\n <sp-search\n id=\"search\"\n @keydown=${this.updateSearch}\n @input=${this.updateSearch}\n @submit=${this.submit}\n .value=${this.search}\n label=\"Search for icons\"\n autocomplete=\"off\"\n >\n <sp-help-text slot=\"help-text\">\n Showing ${matchingIcons.length} of ${this.icons.length}\n available icons.\n </sp-help-text>\n </sp-search>\n </div>\n ${matchingIcons.map((icon) => {\n return html`\n <bdo\n class=\"icon\"\n part=\"icon\"\n dir=\"ltr\"\n class=\"icon\"\n @click=${() => this.shouldCopy(icon.tag)}\n @keydown=${(event: KeyboardEvent) =>\n this.handleKeydown(event, icon.tag)}\n tabindex=${ifDefined(this.package ? '0' : undefined)}\n >\n ${icon.story(this.size)} ${icon.tag}\n </bdo>\n `;\n })}\n `;\n }\n protected override render(): TemplateResult {\n return html`\n ${this.icons.length\n ? this.renderSearch()\n : html`\n <slot></slot>\n `}\n ${this.iconset.map(\n (icon) => html`\n <bdo class=\"icon\" dir=\"ltr\">\n <sp-icon\n size=\"xl\"\n name=${`${this.name}:${icon}`}\n ></sp-icon>\n ${icon}\n </bdo>\n `\n )}\n `;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;AAYA;AAAA,EACI;AAAA,EAEA;AAAA,EACA;AAAA,OAEG;AACP;AAAA,EACI;AAAA,EACA;AAAA,OACG;AACP,SAAS,iBAAiB;AAE1B,OAAO;AACP,OAAO;AACP,OAAO,gBAAgB;AACvB,OAAO;AACP,OAAO;AAGA,WAAM,eAAN,cAA2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