// #region Imports
// #endregion
/**
 * The `Storage` class.
 *
 * @public
 */
export class Storage {
    // #region Fields
    // #endregion
    // #region Ctor
    /**
     * Constructs a new instance of the `Storage` class.
     *
     * @public
     */
    constructor() {
    }
    // #endregion
    // #region Methods
    has(key) {
        return Object.keys(localStorage).some((x) => x === key);
    }
    get(key) {
        if (this.has(key)) {
            const storageValue = JSON.parse(localStorage.getItem(key));
            return storageValue;
        }
        return null;
    }
    set(key, value) {
        const storageValue = JSON.stringify(value);
        localStorage.setItem(key, storageValue);
    }
}
/**
 * @public
 */
export class StorageServiceLocator {
    // #region Fields
    static _current = null;
    // #endregion
    // #region Properties
    static get current() {
        if (!StorageServiceLocator.isSet()) {
            throw new Error('\'Storage\' not set.');
        }
        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
        return StorageServiceLocator._current;
    }
    // #endregion
    // #region Methods
    static isSet() {
        return StorageServiceLocator._current !== null;
    }
    static set(current) {
        StorageServiceLocator._current = current;
    }
}
StorageServiceLocator.set(new Storage());
//# sourceMappingURL=Storage.js.map