import { IconsetRegistry } from './iconset-registry.js' ; import { LitElement } from '@spectrum-web-components/base' ; import { property } from '@spectrum-web-components/base/src/decorators.js' ; export abstract class Iconset extends LitElement { protected registered = false ; private _name ! : string ; protected firstUpdated ( ) { this . style . display = 'none' ; } /**
     * Name of the iconset, used by the IconsetRegistry to serve this icon set
     * to consuming icons.
     */ @ property ( ) public set name ( value ) { if ( this . registered ) { if ( this . _name ) { IconsetRegistry . getInstance ( ) . removeIconset ( this . _name ) ; } if ( value ) { IconsetRegistry . getInstance ( ) . addIconset ( value , this ) ; } } this . _name = value ; } public get name ( ) : string { return this . _name ; } /**
     * Applies an icon to the given element
     */ public abstract applyIconToElement ( el , icon , size , label ) ; /**
     * Returns a list of all icons in this iconset.
     */ public abstract getIconList ( ) ; private handleRemoved = ( { detail , } ) : void => { if ( detail . name === this . name ) { this . registered = false ; this . addIconset ( ) ; } } ; /**
     * On updated we register the iconset if we're not already registered
     */ public connectedCallback ( ) { super . connectedCallback ( ) ; this . addIconset ( ) ; window . addEventListener ( 'sp-iconset-removed' , this . handleRemoved ) ; } /**
     * On disconnected we remove the iconset
     */ public disconnectedCallback ( ) { super . disconnectedCallback ( ) ; window . removeEventListener ( 'sp-iconset-removed' , this . handleRemoved ) ; this . removeIconset ( ) ; } private addIconset ( ) { if ( ! this . name || this . registered ) { return ; } IconsetRegistry . getInstance ( ) . addIconset ( this . name , this ) ; this . registered = true ; } private removeIconset ( ) { if ( ! this . name ) { return ; } IconsetRegistry . getInstance ( ) . removeIconset ( this . name ) ; this . registered = false ; } }