import { PlatformBindings } from './PlatformBindings.js';
import { EventTypes } from '../../events/EventTypes.js';
export const KeyPrefix = 'api-client.config.';
export const TelemetryKey = `${KeyPrefix}telemetry`;
/**
 * The base class for application settings bindings.
 */
export class ConfigurationBindings extends PlatformBindings {
    async initialize() {
        window.addEventListener(EventTypes.Config.Session.get, this.getSessionHandler.bind(this));
        window.addEventListener(EventTypes.Config.Session.set, this.setSessionHandler.bind(this));
        window.addEventListener(EventTypes.Config.Session.delete, this.deleteSessionHandler.bind(this));
        window.addEventListener(EventTypes.Config.Local.get, this.getLocalHandler.bind(this));
        window.addEventListener(EventTypes.Config.Local.set, this.setLocalHandler.bind(this));
        window.addEventListener(EventTypes.Config.Local.delete, this.deleteLocalHandler.bind(this));
        window.addEventListener(EventTypes.Config.Telemetry.read, this.telemetryReadHandler.bind(this));
        window.addEventListener(EventTypes.Config.Telemetry.set, this.telemetrySetHandler.bind(this));
    }
    getSessionHandler(input) {
        const e = input;
        e.preventDefault();
        e.detail.result = this.session.get(e.detail.key);
    }
    setSessionHandler(input) {
        const e = input;
        e.preventDefault();
        e.detail.result = this.session.set(e.detail.key, e.detail.value);
    }
    deleteSessionHandler(input) {
        const e = input;
        e.preventDefault();
        e.detail.result = this.session.delete(e.detail.key);
    }
    getLocalHandler(input) {
        const e = input;
        e.preventDefault();
        e.detail.result = this.local.get(e.detail.key);
    }
    setLocalHandler(input) {
        const e = input;
        e.preventDefault();
        e.detail.result = this.local.set(e.detail.key, e.detail.value);
    }
    deleteLocalHandler(input) {
        const e = input;
        e.preventDefault();
        e.detail.result = this.local.delete(e.detail.key);
    }
    telemetryReadHandler(input) {
        const e = input;
        e.preventDefault();
        e.detail.result = this.telemetry.read();
    }
    telemetrySetHandler(input) {
        const e = input;
        e.preventDefault();
        e.detail.result = this.telemetry.set(e.detail.config);
    }
}
//# sourceMappingURL=ConfigurationBindings.js.map