import { Iconset } from './iconset.js' ; export interface IconsetAddedDetail { name : string ; iconset : Iconset ; } export interface IconsetRemovedDetail { name : string ; } export class IconsetRegistry { public static getInstance ( ) { if ( ! IconsetRegistry . instance ) { IconsetRegistry . instance = new IconsetRegistry ( ) ; } return IconsetRegistry . instance ; } private static instance : IconsetRegistry ; private iconsetMap = new Map < string , Iconset > ( ) ; public addIconset ( name , iconset ) { this . iconsetMap . set ( name , iconset ) ; const event = new CustomEvent ( 'sp-iconset-added' , { bubbles : true , composed : true , detail : { name , iconset } , } ) ; setTimeout ( ( ) => window . dispatchEvent ( event ) , 0 ) ; } public removeIconset ( name ) { this . iconsetMap . delete ( name ) ; const event = new CustomEvent ( 'sp-iconset-removed' , { bubbles : true , composed : true , detail : { name } , } ) ; setTimeout ( ( ) => window . dispatchEvent ( event ) , 0 ) ; } public getIconset ( name ) { return this . iconsetMap . get ( name ) ; } } declare global { interface GlobalEventHandlersEventMap { 'sp-iconset-added' : CustomEvent < IconsetAddedDetail > ; 'sp-iconset-removed' : CustomEvent < IconsetRemovedDetail > ; } }