import { Inject, Injectable } from '@angular/core';
import { PERMANENT_STORAGE } from '@anglr/common';
import { Subject } from 'rxjs';
import * as i0 from "@angular/core";
const LIVE_EVENTS_STATUS = 'LIVE_EVENTS_STATUS';
/**
 * Service used for handling state of layout live events
 */
export class LiveEventService {
    //######################### public properties #########################
    /**
     * Gets current enabled value
     */
    get enabled() {
        return this.ɵenabled;
    }
    /**
     * Occurs when enabled changes
     */
    get enabledChange() {
        return this.ɵenabledChange.asObservable();
    }
    //######################### constructor #########################
    constructor(storage) {
        var _a;
        this.storage = storage;
        //######################### protected fields #########################
        /**
         * Current enabled value
         */
        this.ɵenabled = false;
        /**
         * Used for emitting enabled changes
         */
        this.ɵenabledChange = new Subject();
        this.ɵenabled = (_a = this.storage.get(LIVE_EVENTS_STATUS)) !== null && _a !== void 0 ? _a : false;
    }
    //######################### public methods #########################
    /**
     * Sets enabled new value
     * @param enabled - Value of enabled that changed
     */
    setEnabled(enabled) {
        if (this.ɵenabled == enabled) {
            return;
        }
        this.storage.set(LIVE_EVENTS_STATUS, enabled);
        this.ɵenabled = enabled;
        this.ɵenabledChange.next();
    }
}
LiveEventService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: LiveEventService, deps: [{ token: PERMANENT_STORAGE }], target: i0.ɵɵFactoryTarget.Injectable });
LiveEventService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: LiveEventService });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: LiveEventService, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: undefined, decorators: [{
                    type: Inject,
                    args: [PERMANENT_STORAGE]
                }] }] });
//# sourceMappingURL=liveEvents.service.js.map