'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const core = require('./core-b7b9d752.js');
const storage = require('./storage-4e7d35cd.js');

const StateStore = class {
    constructor(hostRef) {
        core.registerInstance(this, hostRef);
        /**
         * The key for what is being stored
         */
        this.storeKey = 'anjState';
        /**
         * The type of storage to use.
         * Options are `"local"` or `"sessions"` Defaults to session.
         */
        this.type = 'session';
        this.anjStateStoreDidLoad = core.createEvent(this, "anjStateStoreDidLoad", 7);
    }
    componentWillLoad() {
        this.store = this.type === 'local' ? new storage.LocalStorage() : new storage.SessionStorage();
    }
    componentDidLoad() {
        this.anjStateStoreDidLoad.emit();
    }
    async get() {
        return this.store.getItem(this.storeKey);
    }
    async set(data) {
        return this.store.setItem(this.storeKey, data);
    }
    async clear() {
        return this.store.removeItem(this.storeKey);
    }
};

exports.anj_state_store = StateStore;
