import { NominatimClient } from './nominatim';
export class GeocodeController {
    constructor() {
        this.defaultClient = 'nominatim';
    }
    async forward(options, clientOptions) {
        let client = this.getClient(options.client);
        let res = await client.forward(options, clientOptions);
        this.glForwardGeocode.emit({
            options: options,
            response: res
        });
        return res;
    }
    async reverse(options, clientOptions) {
        let client = this.getClient(options.client);
        let res = await client.reverse(options, clientOptions);
        this.glReverseGeocode.emit({
            options: options,
            response: res
        });
        return res;
    }
    getClient(id) {
        return GeocodeController.clients[id || this.defaultClient];
    }
    static addClient(id, service) {
        GeocodeController.clients[id] = service;
    }
    static get is() { return "gl-geocode-controller"; }
    static get properties() { return {
        "defaultClient": {
            "type": String,
            "attr": "default-client"
        },
        "forward": {
            "method": true
        },
        "reverse": {
            "method": true
        }
    }; }
    static get events() { return [{
            "name": "glForwardGeocode",
            "method": "glForwardGeocode",
            "bubbles": true,
            "cancelable": true,
            "composed": true
        }, {
            "name": "glReverseGeocode",
            "method": "glReverseGeocode",
            "bubbles": true,
            "cancelable": true,
            "composed": true
        }]; }
}
GeocodeController.clients = {};
GeocodeController.addClient('nominatim', new NominatimClient());
