import { Inject, Injectable } from '@angular/core';
import { ReplaySubject } from 'rxjs';
import { share } from 'rxjs/operators';
import { R_THEME_OPTIONS } from './theme.options';
export class RThemeService {
    constructor(options) {
        this.options = options;
        this.themeChanges$ = new ReplaySubject(1);
        this.changeTheme(localStorage.getItem('r_theme') || (options === null || options === void 0 ? void 0 : options.name));
    }
    changeTheme(name) {
        this.themeChanges$.next({ name, previous: this.currentTheme });
        if (this.options.persistTheme) {
            localStorage.setItem('r_theme', name);
        }
        this.currentTheme = name;
    }
    onThemeChange() {
        return this.themeChanges$.pipe(share());
    }
}
RThemeService.decorators = [
    { type: Injectable }
];
RThemeService.ctorParameters = () => [
    { type: undefined, decorators: [{ type: Inject, args: [R_THEME_OPTIONS,] }] }
];
//# sourceMappingURL=theme.service.js.map