import { EntityDefinition, EntityActionHandlerComponent, EntityDescriberComponent, InlineEntityEncoderComponent, ioc, ReactorEntityCategories, SimpleEntitySearchEngineComponent } from '@journeyapps-labs/reactor-mod';
import { ChangeEditorThemeAction } from '../actions/ChangeEditorThemeAction';
import { MonacoThemeStore } from '../stores/MonacoThemeStore';
import { EditorEntities } from './EditorEntities';
export class EditorThemeEntityDefinition extends EntityDefinition {
    constructor() {
        super({
            type: EditorThemeEntityDefinition.TYPE,
            category: ReactorEntityCategories.CORE,
            label: 'Editor theme',
            icon: 'paint-brush',
            iconColor: 'orange'
        });
        this.registerComponent(new EntityDescriberComponent({
            label: 'Simple',
            describe: (entity) => {
                return {
                    simpleName: entity.label
                };
            }
        }));
        this.registerComponent(new InlineEntityEncoderComponent({
            version: 1,
            encode: (entity) => {
                return {
                    themeID: entity.key
                };
            },
            decode: async (entity) => {
                return ioc.get(MonacoThemeStore).getTheme(entity.themeID);
            }
        }));
        this.registerComponent(new SimpleEntitySearchEngineComponent({
            label: 'Editor themes',
            getEntities: async () => {
                return Object.values(ioc.get(MonacoThemeStore).getThemes());
            }
        }));
        this.registerComponent(new EntityActionHandlerComponent(ChangeEditorThemeAction.ID));
    }
    getEntityUID(t) {
        return t.key;
    }
    matchEntity(t) {
        return !!t && typeof t.key === 'string' && typeof t.label === 'string' && !!t.theme;
    }
}
EditorThemeEntityDefinition.TYPE = EditorEntities.THEME;
//# sourceMappingURL=EditorThemeEntityDefinition.js.map