<commit_before>module Fayde {
    interface IThemesHash {
        [name: string]: Theme;
    }

    export class ThemedLibrary extends nullstone.Library {
        private $$themes: IThemesHash = {};
        private $$activeTheme: Theme = null;
        private $$activeThemeName: string = null;

        get activeTheme(): Theme {
            return this.$$activeTheme;
        }

        loadAsync(): Promise<nullstone.Library> {
            return super.loadAsync()
                .tap(() => this.ensureThemeLoaded());
        }

        protected ensureThemeLoaded(): Promise<Theme> {
            if (this.$$activeTheme)
                return Promise.resolve(this.$$activeTheme);
            if (!this.$$activeThemeName)<commit_msg>Ensuring ThemedLibrary doesn't get stuck on first theme loaded if theme name is changed later.<commit_after>module Fayde {
    interface IThemesHash {
        [name: string]: Theme;
    }

    export class ThemedLibrary extends nullstone.Library {
        private $$themes: IThemesHash = {};
        private $$activeTheme: Theme = null;
        private $$activeThemeName: string = null;

        get activeTheme(): Theme {
            return this.$$activeTheme;
        }

        get isActiveThemeInvalid(): boolean {
            return !this.$$activeTheme || this.$$activeTheme.Name !== this.$$activeThemeName;
        }

        loadAsync(): Promise<nullstone.Library> {
            return super.loadAsync()
                .tap(() => this.ensureThemeLoaded());
        }

        protected ensureThemeLoaded(): Promise<Theme> {
            if (!this.isActiveThemeInvalid)
                return Promise.resolve(this.$$activeTheme);
            if (!this.$$activeThemeName)
{'fraction_non_alphanumeric': 0.11273364485981309, 'fraction_numerical': 0.0, 'mean_word_length': 2.2443181818181817, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3683515', 'n_tokens_mistral': 443, 'n_tokens_neox': 413, 'n_words': 106}