import { _t } from '../i18n/i18n';
export class BasemapSwitcher {
    getBasemapStyles() {
        return Array.from(document.querySelectorAll('gl-style'))
            .filter((style) => style.basemap);
    }
    setBasemap(url) {
        this.getBasemapStyles()
            .forEach((style) => style.enabled = style.url === url);
    }
    render() {
        const header = _t('webmapgl.basemap-switcher.header');
        let items = this.getBasemapStyles()
            .map((style) => (h("ion-item", null,
            (style.thumbnail) ?
                h("ion-thumbnail", { slot: "start" },
                    h("img", { src: style.thumbnail, alt: style.name })) : null,
            h("ion-label", { "text-wrap": true }, style.name),
            h("ion-radio", { checked: style.enabled, value: style.url }))));
        return (h("ion-content", null,
            h("ion-list", null,
                h("ion-radio-group", { onIonChange: (e) => this.setBasemap(e.detail.value) },
                    h("ion-list-header", null, header),
                    items))));
    }
    static get is() { return "gl-basemap-switcher"; }
}
