import { h } from '../webmapgl.core.js';

import { a as _t } from './chunk-cf921ba9.js';
import { a as debounceEvent } from './chunk-3488a752.js';
import { a as sanitizeDOMString } from './chunk-d01d69cb.js';
import { a as createColorClasses } from './chunk-c82b670d.js';

class AddressSearchBox {
    constructor() {
        this.hasFocus = false;
        this.hasValue = false;
        this.results = [];
        this.jobId = 'gl-address-search';
        this.limit = 10;
        this.maxZoom = 18;
        this.placeholder = _t('webmapgl.address-search.prompt');
        this.zoomPadding = 20;
    }
    async componentWillLoad() {
        this.parseBbox();
        this.geocodeCtrl = await this.lazyGeocodeCtrl.componentOnReady();
    }
    async handleGeocode(e) {
        if (e.detail.options.jobId === this.jobId)
            this.results = e.detail.response;
    }
    handleBodyClick() {
        this.hasFocus = false;
    }
    handleDown(e) {
        let nextItem;
        if (document.activeElement.tagName === 'ION-ITEM') {
            this.unsetFocus();
            nextItem = document.activeElement.nextElementSibling;
        }
        if (!nextItem)
            nextItem = this.el.querySelector('ion-item');
        if (nextItem) {
            e.preventDefault();
            this.setFocus(nextItem);
        }
    }
    handleUp(e) {
        if (document.activeElement.tagName === 'ION-ITEM') {
            e.preventDefault();
            this.unsetFocus();
            let prevItem = document.activeElement.previousElementSibling;
            if (prevItem) {
                this.setFocus(prevItem);
            }
            else if (this.input) {
                this.input.querySelector('input').focus();
            }
        }
    }
    parseBbox() {
        this.bboxArray = (typeof this.bbox === 'string') ?
            this.bbox.split(',').map((c) => parseFloat(c)) : this.bbox;
    }
    setFocus(el) {
        let button = el.shadowRoot.querySelector('button');
        button.focus();
        button.style.color = '#3880ff';
    }
    unsetFocus() {
        let button = document.activeElement.shadowRoot.querySelector('button');
        button.style.color = null;
    }
    formatAddress(address) {
        let parts = [];
        if (address.name &&
            address.name != address.city)
            parts.push(address.name);
        if (address.street) {
            let part = address.street;
            if (address.housenumber)
                part = address.housenumber + ' ' + part;
            parts.push(part);
        }
        if (address.city)
            parts.push(address.city);
        if (!parts.length && address.county)
            parts.push(address.county);
        if (parts.length)
            return parts.join(', ');
        return address.display;
    }
    async selectResult(result) {
        let mapEl = this.el.closest('gl-map');
        mapEl.map.fitBounds(result.bbox, {
            maxZoom: this.maxZoom,
            padding: this.zoomPadding
        });
        this.hasFocus = false;
    }
    async geocode() {
        this.geocodeCtrl.forward({
            address: this.input.value,
            url: this.url,
            bbox: this.bboxArray,
            bounded: true,
            jobId: this.jobId,
            limit: this.limit
        });
    }
    renderResults() {
        if (!this.results.length || !this.hasValue || !this.hasFocus)
            return null;
        let items = this.results.map((result) => (h("ion-item", { button: true, onClick: () => this.selectResult(result) },
            h("ion-icon", { name: "pin", slot: "start" }),
            h("ion-label", null, this.formatAddress(result.address)))));
        return (h("ion-list", { lines: "full" }, items));
    }
    handleChange() {
        if (this.input && this.input.value) {
            this.hasValue = true;
            this.geocode();
        }
        else {
            this.hasValue = false;
            if (this.results.length)
                this.results = [];
        }
    }
    handleFocus() {
        this.hasFocus = true;
    }
    handleClick(e) {
        e.stopPropagation();
    }
    render() {
        return ([
            h("ion-searchbar", { ref: (r) => this.input = r, placeholder: this.placeholder, onIonChange: () => this.handleChange(), onIonFocus: () => this.handleFocus(), onClick: (e) => this.handleClick(e) }),
            this.renderResults()
        ]);
    }
    static get is() { return "gl-address-search"; }
    static get properties() { return {
        "bbox": {
            "type": String,
            "attr": "bbox",
            "watchCallbacks": ["parseBbox"]
        },
        "bboxArray": {
            "state": true
        },
        "el": {
            "elementRef": true
        },
        "hasFocus": {
            "state": true
        },
        "hasValue": {
            "state": true
        },
        "jobId": {
            "type": String,
            "attr": "job-id"
        },
        "lazyGeocodeCtrl": {
            "connect": "gl-geocode-controller"
        },
        "limit": {
            "type": Number,
            "attr": "limit"
        },
        "maxZoom": {
            "type": Number,
            "attr": "max-zoom"
        },
        "placeholder": {
            "type": String,
            "attr": "placeholder"
        },
        "results": {
            "state": true
        },
        "url": {
            "type": String,
            "attr": "url"
        },
        "zoomPadding": {
            "type": Number,
            "attr": "zoom-padding"
        }
    }; }
    static get listeners() { return [{
            "name": "body:glForwardGeocode",
            "method": "handleGeocode"
        }, {
            "name": "body:click",
            "method": "handleBodyClick"
        }, {
            "name": "keydown.down",
            "method": "handleDown"
        }, {
            "name": "keydown.up",
            "method": "handleUp"
        }]; }
    static get style() { return "gl-address-search{background-color:#fff;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;left:0;position:absolute;top:0;width:100%;z-index:1000;max-height:100%}gl-address-search ion-searchbar{-ms-flex:none;flex:none}gl-address-search ion-list.list-ios{margin-bottom:0;overflow-y:scroll}"; }
    static get styleMode() { return "ios"; }
}

class NominatimClient {
    async forward(options, clientOptions = {}) {
        let params = {
            format: 'jsonv2',
            addressdetails: clientOptions.addressdetails || '1'
        };
        if (clientOptions.countrycodes)
            params['countrycodes'] = clientOptions.countrycodes;
        if (typeof options.address === 'string') {
            params['q'] = options.address;
        }
        else {
            Object.assign(params, options.address);
        }
        if (options.bbox)
            params['viewbox'] = options.bbox.join(',');
        if (options.bounded)
            params['bounded'] = '1';
        if (options.limit)
            params['limit'] = options.limit;
        let res = await fetch(this.addParams(options.url, params), {
            mode: clientOptions.mode || 'cors'
        });
        let json = await res.json();
        if (json.error)
            return json;
        return this.formatResponse(json);
    }
    async reverse(options, clientOptions = {}) {
        let params = {
            format: 'jsonv2',
            addressdetails: clientOptions.addressdetails || '1',
            zoom: clientOptions.zoom || '18'
        };
        params['lon'] = options.location.lon.toString();
        params['lat'] = options.location.lat.toString();
        let res = await fetch(this.addParams(options.url, params), {
            mode: clientOptions.mode || 'cors'
        });
        let json = await res.json();
        if (json.error)
            return json;
        return this.formatResponseItem(json);
    }
    formatResponse(res) {
        return res.map((item) => this.formatResponseItem(item));
    }
    formatResponseItem(item) {
        let bbox = null;
        if (item.boundingbox) {
            let coords = item.boundingbox.map((coord) => parseFloat(coord));
            bbox = [coords[2], coords[0], coords[3], coords[1]];
        }
        let gr = {
            address: {
                name: item.address[item.type] || item.address[item.category] || null,
                housenumber: item.address.house_number || null,
                street: item.address.road || null,
                city: item.address.city || null,
                county: item.address.county || null,
                state: item.address.state || null,
                country: item.address.country || null,
                countrycode: item.address.country_code || null,
                postalcode: item.address.postcode || null
            },
            bbox: bbox,
            client: {
                osm_id: item.osm_id || null,
                osm_type: item.osm_type || null,
                category: item.category || null,
                type: item.type || null,
                importance: item.importance || null,
                place_id: item.place_id || null,
                place_rank: item.place_rank || null
            },
            display: item.display_name || null,
            location: {
                lon: parseFloat(item.lon),
                lat: parseFloat(item.lat)
            },
            polygon: item.geojson || null
        };
        return gr;
    }
    addParams(endpoint, params) {
        let url = new URL(endpoint);
        Object.keys(params)
            .forEach(key => url.searchParams.append(key, params[key]));
        return url.toString();
    }
}

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());

class Searchbar {
    constructor() {
        this.isCancelVisible = false;
        this.shouldAlignLeft = true;
        this.focused = false;
        this.noAnimate = true;
        this.animated = false;
        this.autocomplete = "off";
        this.autocorrect = "off";
        this.cancelButtonIcon = "md-arrow-back";
        this.cancelButtonText = "Cancel";
        this.debounce = 250;
        this.disabled = false;
        this.placeholder = "Search";
        this.searchIcon = "search";
        this.showCancelButton = "never";
        this.spellcheck = false;
        this.type = "search";
        this.value = "";
        this.onClearInput = (ev) => {
            this.ionClear.emit();
            if (ev) {
                ev.preventDefault();
                ev.stopPropagation();
            }
            setTimeout(() => {
                const value = this.getValue();
                if (value !== "") {
                    this.value = "";
                    this.ionInput.emit();
                }
            }, 16 * 4);
        };
        this.onCancelSearchbar = (ev) => {
            if (ev) {
                ev.preventDefault();
                ev.stopPropagation();
            }
            this.ionCancel.emit();
            this.onClearInput();
            if (this.nativeInput) {
                this.nativeInput.blur();
            }
        };
        this.onInput = (ev) => {
            const input = ev.target;
            if (input) {
                this.value = input.value;
            }
            this.ionInput.emit(ev);
        };
        this.onBlur = () => {
            this.focused = false;
            this.ionBlur.emit();
            this.positionElements();
        };
        this.onFocus = () => {
            this.focused = true;
            this.ionFocus.emit();
            this.positionElements();
        };
    }
    debounceChanged() {
        this.ionChange = debounceEvent(this.ionChange, this.debounce);
    }
    valueChanged() {
        const inputEl = this.nativeInput;
        const value = this.getValue();
        if (inputEl && inputEl.value !== value) {
            inputEl.value = value;
        }
        this.ionChange.emit({ value });
    }
    showCancelButtonChanged() {
        requestAnimationFrame(() => {
            this.positionElements();
            this.el.forceUpdate();
        });
    }
    componentDidLoad() {
        this.positionElements();
        this.debounceChanged();
        setTimeout(() => {
            this.noAnimate = false;
        }, 300);
    }
    setFocus() {
        if (this.nativeInput) {
            this.nativeInput.focus();
        }
    }
    getInputElement() {
        return Promise.resolve(this.nativeInput);
    }
    positionElements() {
        const value = this.getValue();
        const prevAlignLeft = this.shouldAlignLeft;
        const shouldAlignLeft = (!this.animated || value.trim() !== "" || !!this.focused);
        this.shouldAlignLeft = shouldAlignLeft;
        if (this.mode !== "ios") {
            return;
        }
        if (prevAlignLeft !== shouldAlignLeft) {
            this.positionPlaceholder();
        }
        if (this.animated) {
            this.positionCancelButton();
        }
    }
    positionPlaceholder() {
        const inputEl = this.nativeInput;
        if (!inputEl) {
            return;
        }
        const isRTL = this.doc.dir === "rtl";
        const iconEl = (this.el.shadowRoot || this.el).querySelector(".searchbar-search-icon");
        if (this.shouldAlignLeft) {
            inputEl.removeAttribute("style");
            iconEl.removeAttribute("style");
        }
        else {
            const doc = this.doc;
            const tempSpan = doc.createElement("span");
            tempSpan.innerHTML = sanitizeDOMString(this.placeholder) || "";
            doc.body.appendChild(tempSpan);
            const textWidth = tempSpan.offsetWidth;
            tempSpan.remove();
            const inputLeft = "calc(50% - " + (textWidth / 2) + "px)";
            const iconLeft = "calc(50% - " + ((textWidth / 2) + 30) + "px)";
            if (isRTL) {
                inputEl.style.paddingRight = inputLeft;
                iconEl.style.marginRight = iconLeft;
            }
            else {
                inputEl.style.paddingLeft = inputLeft;
                iconEl.style.marginLeft = iconLeft;
            }
        }
    }
    positionCancelButton() {
        const isRTL = this.doc.dir === "rtl";
        const cancelButton = (this.el.shadowRoot || this.el).querySelector(".searchbar-cancel-button");
        const shouldShowCancel = this.shouldShowCancelButton();
        if (cancelButton && shouldShowCancel !== this.isCancelVisible) {
            const cancelStyle = cancelButton.style;
            this.isCancelVisible = shouldShowCancel;
            if (shouldShowCancel) {
                if (isRTL) {
                    cancelStyle.marginLeft = "0";
                }
                else {
                    cancelStyle.marginRight = "0";
                }
            }
            else {
                const offset = cancelButton.offsetWidth;
                if (offset > 0) {
                    if (isRTL) {
                        cancelStyle.marginLeft = -offset + "px";
                    }
                    else {
                        cancelStyle.marginRight = -offset + "px";
                    }
                }
            }
        }
    }
    getValue() {
        return this.value || "";
    }
    hasValue() {
        return this.getValue() !== "";
    }
    shouldShowCancelButton() {
        if (isCancelButtonSetToNever(this.showCancelButton) ||
            (isCancelButtonSetToFocus(this.showCancelButton) && !this.focused)) {
            return false;
        }
        return true;
    }
    hostData() {
        const animated = this.animated && this.config.getBoolean("animated", true);
        return {
            "aria-disabled": this.disabled ? "true" : null,
            class: Object.assign({}, createColorClasses(this.color), { [`${this.mode}`]: true, "searchbar-animated": animated, "searchbar-disabled": this.disabled, "searchbar-no-animate": animated && this.noAnimate, "searchbar-has-value": this.hasValue(), "searchbar-left-aligned": this.shouldAlignLeft, "searchbar-has-focus": this.focused, "searchbar-should-show-cancel": this.shouldShowCancelButton() })
        };
    }
    render() {
        const clearIcon = this.clearIcon || (this.mode === "ios" ? "ios-close-circle" : "md-close");
        const searchIcon = this.searchIcon;
        const cancelButton = !isCancelButtonSetToNever(this.showCancelButton) && (h("button", { type: "button", tabIndex: this.mode === "ios" && !this.shouldShowCancelButton() ? -1 : undefined, onMouseDown: this.onCancelSearchbar, onTouchStart: this.onCancelSearchbar, class: "searchbar-cancel-button" }, h("div", null, this.mode === "md"
            ? h("ion-icon", { mode: this.mode, icon: this.cancelButtonIcon, lazy: false })
            : this.cancelButtonText)));
        return [
            h("div", { class: "searchbar-input-container" }, h("input", { disabled: this.disabled, ref: el => this.nativeInput = el, class: "searchbar-input", onInput: this.onInput, onBlur: this.onBlur, onFocus: this.onFocus, placeholder: this.placeholder, type: this.type, value: this.getValue(), autoComplete: this.autocomplete, autoCorrect: this.autocorrect, spellCheck: this.spellcheck }), this.mode === "md" && cancelButton, h("ion-icon", { mode: this.mode, icon: searchIcon, lazy: false, class: "searchbar-search-icon" }), h("button", { type: "button", "no-blur": true, class: "searchbar-clear-button", onMouseDown: this.onClearInput, onTouchStart: this.onClearInput }, h("ion-icon", { mode: this.mode, icon: clearIcon, lazy: false, class: "searchbar-clear-icon" }))),
            this.mode === "ios" && cancelButton
        ];
    }
    static get is() { return "ion-searchbar"; }
    static get encapsulation() { return "scoped"; }
    static get properties() {
        return {
            "animated": {
                "type": Boolean,
                "attr": "animated"
            },
            "autocomplete": {
                "type": String,
                "attr": "autocomplete"
            },
            "autocorrect": {
                "type": String,
                "attr": "autocorrect"
            },
            "cancelButtonIcon": {
                "type": String,
                "attr": "cancel-button-icon"
            },
            "cancelButtonText": {
                "type": String,
                "attr": "cancel-button-text"
            },
            "clearIcon": {
                "type": String,
                "attr": "clear-icon"
            },
            "color": {
                "type": String,
                "attr": "color"
            },
            "config": {
                "context": "config"
            },
            "debounce": {
                "type": Number,
                "attr": "debounce",
                "watchCallbacks": ["debounceChanged"]
            },
            "disabled": {
                "type": Boolean,
                "attr": "disabled"
            },
            "doc": {
                "context": "document"
            },
            "el": {
                "elementRef": true
            },
            "focused": {
                "state": true
            },
            "getInputElement": {
                "method": true
            },
            "mode": {
                "type": String,
                "attr": "mode"
            },
            "noAnimate": {
                "state": true
            },
            "placeholder": {
                "type": String,
                "attr": "placeholder"
            },
            "searchIcon": {
                "type": String,
                "attr": "search-icon"
            },
            "setFocus": {
                "method": true
            },
            "showCancelButton": {
                "type": "Any",
                "attr": "show-cancel-button",
                "watchCallbacks": ["showCancelButtonChanged"]
            },
            "spellcheck": {
                "type": Boolean,
                "attr": "spellcheck"
            },
            "type": {
                "type": String,
                "attr": "type"
            },
            "value": {
                "type": String,
                "attr": "value",
                "mutable": true,
                "watchCallbacks": ["valueChanged"]
            }
        };
    }
    static get events() {
        return [{
                "name": "ionInput",
                "method": "ionInput",
                "bubbles": true,
                "cancelable": true,
                "composed": true
            }, {
                "name": "ionChange",
                "method": "ionChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true
            }, {
                "name": "ionCancel",
                "method": "ionCancel",
                "bubbles": true,
                "cancelable": true,
                "composed": true
            }, {
                "name": "ionClear",
                "method": "ionClear",
                "bubbles": true,
                "cancelable": true,
                "composed": true
            }, {
                "name": "ionBlur",
                "method": "ionBlur",
                "bubbles": true,
                "cancelable": true,
                "composed": true
            }, {
                "name": "ionFocus",
                "method": "ionFocus",
                "bubbles": true,
                "cancelable": true,
                "composed": true
            }];
    }
    static get style() { return ".sc-ion-searchbar-ios-h{--placeholder-color:initial;--placeholder-font-style:initial;--placeholder-font-weight:initial;--placeholder-opacity:.5;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:-ms-flexbox;display:flex;position:relative;-ms-flex-align:center;align-items:center;width:100%;color:var(--color);font-family:var(--ion-font-family,inherit);-webkit-box-sizing:border-box;box-sizing:border-box}.ion-color.sc-ion-searchbar-ios-h{color:var(--ion-color-contrast)}.ion-color.sc-ion-searchbar-ios-h   .searchbar-input.sc-ion-searchbar-ios{background:var(--ion-color-base)}.ion-color.sc-ion-searchbar-ios-h   .searchbar-cancel-button.sc-ion-searchbar-ios, .ion-color.sc-ion-searchbar-ios-h   .searchbar-clear-button.sc-ion-searchbar-ios, .ion-color.sc-ion-searchbar-ios-h   .searchbar-search-icon.sc-ion-searchbar-ios{color:inherit}.searchbar-search-icon.sc-ion-searchbar-ios{color:var(--icon-color);pointer-events:none}.searchbar-input-container.sc-ion-searchbar-ios{display:block;position:relative;-ms-flex-negative:1;flex-shrink:1;width:100%}.searchbar-input.sc-ion-searchbar-ios{font-size:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;text-decoration:inherit;text-overflow:inherit;text-transform:inherit;text-align:inherit;white-space:inherit;color:inherit;-webkit-box-sizing:border-box;box-sizing:border-box;display:block;width:100%;border:0;outline:none;background:var(--background);font-family:inherit;-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbar-input.sc-ion-searchbar-ios::-webkit-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-ios:-ms-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-ios::-ms-input-placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-ios::placeholder{color:var(--placeholder-color);font-family:inherit;font-style:var(--placeholder-font-style);font-weight:var(--placeholder-font-weight);opacity:var(--placeholder-opacity)}.searchbar-input.sc-ion-searchbar-ios::-ms-clear, .searchbar-input.sc-ion-searchbar-ios::-webkit-search-cancel-button{display:none}.searchbar-cancel-button.sc-ion-searchbar-ios{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:none;height:100%;border:0;outline:none;color:var(--cancel-button-color);cursor:pointer;-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbar-cancel-button.sc-ion-searchbar-ios > div.sc-ion-searchbar-ios{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:100%;height:100%}.searchbar-clear-button.sc-ion-searchbar-ios{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;display:none;min-height:0;outline:none;color:var(--clear-button-color);-webkit-appearance:none;-moz-appearance:none;appearance:none}.searchbar-has-value.searchbar-has-focus.sc-ion-searchbar-ios-h   .searchbar-clear-button.sc-ion-searchbar-ios{display:block}.searchbar-disabled.sc-ion-searchbar-ios-h{cursor:default;opacity:.4;pointer-events:none}.sc-ion-searchbar-ios-h{--clear-button-color:var(--ion-color-step-600,#666);--cancel-button-color:var(--ion-color-primary,#3880ff);--color:var(--ion-text-color,#000);--icon-color:var(--ion-color-step-600,#666);--background:rgba(var(--ion-text-color-rgb,0,0,0),0.07);padding-left:12px;padding-right:12px;padding-top:12px;padding-bottom:12px;height:60px;contain:strict}\@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.sc-ion-searchbar-ios-h{padding-left:unset;padding-right:unset;-webkit-padding-start:12px;padding-inline-start:12px;-webkit-padding-end:12px;padding-inline-end:12px}}.searchbar-input-container.sc-ion-searchbar-ios{height:36px;contain:strict}.searchbar-search-icon.sc-ion-searchbar-ios{margin-left:calc(50% - 60px);left:8px;top:0;position:absolute;width:16px;height:100%;contain:strict}\@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.searchbar-search-icon.sc-ion-searchbar-ios{margin-left:unset;-webkit-margin-start:calc(50% - 60px);margin-inline-start:calc(50% - 60px)}}[dir=rtl].sc-ion-searchbar-ios-h   .searchbar-search-icon.sc-ion-searchbar-ios, [dir=rtl]   .sc-ion-searchbar-ios-h   .searchbar-search-icon.sc-ion-searchbar-ios, [dir=rtl].sc-ion-searchbar-ios   .searchbar-search-icon.sc-ion-searchbar-ios{left:unset;right:unset;right:8px}.searchbar-input.sc-ion-searchbar-ios{padding-left:28px;padding-right:28px;padding-top:0;padding-bottom:0;border-radius:10px;height:100%;font-size:14px;font-weight:400;contain:strict}\@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.searchbar-input.sc-ion-searchbar-ios{padding-left:unset;padding-right:unset;-webkit-padding-start:28px;padding-inline-start:28px;-webkit-padding-end:28px;padding-inline-end:28px}}.searchbar-clear-button.sc-ion-searchbar-ios{right:0;top:0;background-position:50%;position:absolute;width:30px;height:100%;border:0;background-color:transparent}[dir=rtl].sc-ion-searchbar-ios-h   .searchbar-clear-button.sc-ion-searchbar-ios, [dir=rtl]   .sc-ion-searchbar-ios-h   .searchbar-clear-button.sc-ion-searchbar-ios, [dir=rtl].sc-ion-searchbar-ios   .searchbar-clear-button.sc-ion-searchbar-ios{left:unset;right:unset;left:0}.searchbar-clear-icon.sc-ion-searchbar-ios{width:18px;height:100%}.searchbar-cancel-button.sc-ion-searchbar-ios{padding-left:8px;padding-right:0;padding-top:0;padding-bottom:0;-ms-flex-negative:0;flex-shrink:0;background-color:transparent;font-size:16px}\@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.searchbar-cancel-button.sc-ion-searchbar-ios{padding-left:unset;padding-right:unset;-webkit-padding-start:8px;padding-inline-start:8px;-webkit-padding-end:0;padding-inline-end:0}}.searchbar-left-aligned.sc-ion-searchbar-ios-h   .searchbar-search-icon.sc-ion-searchbar-ios{margin-left:0}\@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.searchbar-left-aligned.sc-ion-searchbar-ios-h   .searchbar-search-icon.sc-ion-searchbar-ios{margin-left:unset;-webkit-margin-start:0;margin-inline-start:0}}.searchbar-left-aligned.sc-ion-searchbar-ios-h   .searchbar-input.sc-ion-searchbar-ios{padding-left:30px}\@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.searchbar-left-aligned.sc-ion-searchbar-ios-h   .searchbar-input.sc-ion-searchbar-ios{padding-left:unset;-webkit-padding-start:30px;padding-inline-start:30px}}.searchbar-animated.sc-ion-searchbar-ios-h   .searchbar-cancel-button.sc-ion-searchbar-ios, .searchbar-has-focus.sc-ion-searchbar-ios-h   .searchbar-cancel-button.sc-ion-searchbar-ios, .searchbar-should-show-cancel.sc-ion-searchbar-ios-h   .searchbar-cancel-button.sc-ion-searchbar-ios{display:block}.searchbar-animated.sc-ion-searchbar-ios-h   .searchbar-input.sc-ion-searchbar-ios, .searchbar-animated.sc-ion-searchbar-ios-h   .searchbar-search-icon.sc-ion-searchbar-ios{-webkit-transition:all .3s ease;transition:all .3s ease}.searchbar-animated.searchbar-has-focus.sc-ion-searchbar-ios-h   .searchbar-cancel-button.sc-ion-searchbar-ios, .searchbar-animated.searchbar-should-show-cancel.sc-ion-searchbar-ios-h   .searchbar-cancel-button.sc-ion-searchbar-ios{opacity:1;pointer-events:auto}.searchbar-animated.sc-ion-searchbar-ios-h   .searchbar-cancel-button.sc-ion-searchbar-ios{margin-right:-100%;-webkit-transform:translateZ(0);transform:translateZ(0);-webkit-transition:all .3s ease;transition:all .3s ease;opacity:0;pointer-events:none}\@supports ((-webkit-margin-start:0) or (margin-inline-start:0)) or (-webkit-margin-start:0){.searchbar-animated.sc-ion-searchbar-ios-h   .searchbar-cancel-button.sc-ion-searchbar-ios{margin-right:unset;-webkit-margin-end:-100%;margin-inline-end:-100%}}.searchbar-no-animate.sc-ion-searchbar-ios-h   .searchbar-cancel-button.sc-ion-searchbar-ios, .searchbar-no-animate.sc-ion-searchbar-ios-h   .searchbar-input.sc-ion-searchbar-ios, .searchbar-no-animate.sc-ion-searchbar-ios-h   .searchbar-search-icon.sc-ion-searchbar-ios{-webkit-transition-duration:0ms;transition-duration:0ms}.ion-color.sc-ion-searchbar-ios-h   .searchbar-cancel-button.sc-ion-searchbar-ios{color:var(--ion-color-base)}\@media (any-hover:hover){.ion-color.sc-ion-searchbar-ios-h   .searchbar-cancel-button.sc-ion-searchbar-ios:hover{color:var(--ion-color-tint)}}ion-toolbar.ion-color.sc-ion-searchbar-ios-h:not(.ion-color), ion-toolbar.ion-color   .sc-ion-searchbar-ios-h:not(.ion-color){color:inherit}ion-toolbar.ion-color.sc-ion-searchbar-ios-h:not(.ion-color)   .searchbar-cancel-button.sc-ion-searchbar-ios, ion-toolbar.ion-color   .sc-ion-searchbar-ios-h:not(.ion-color)   .searchbar-cancel-button.sc-ion-searchbar-ios{color:currentColor}ion-toolbar.ion-color.sc-ion-searchbar-ios-h   .searchbar-search-icon.sc-ion-searchbar-ios, ion-toolbar.ion-color   .sc-ion-searchbar-ios-h   .searchbar-search-icon.sc-ion-searchbar-ios{color:currentColor;opacity:.5}ion-toolbar.ion-color.sc-ion-searchbar-ios-h:not(.ion-color)   .searchbar-input.sc-ion-searchbar-ios, ion-toolbar.ion-color   .sc-ion-searchbar-ios-h:not(.ion-color)   .searchbar-input.sc-ion-searchbar-ios{background:rgba(var(--ion-color-contrast-rgb),.07);color:currentColor}ion-toolbar.ion-color.sc-ion-searchbar-ios-h:not(.ion-color)   .searchbar-clear-button.sc-ion-searchbar-ios, ion-toolbar.ion-color   .sc-ion-searchbar-ios-h:not(.ion-color)   .searchbar-clear-button.sc-ion-searchbar-ios{color:currentColor;opacity:.5}"; }
    static get styleMode() { return "ios"; }
}
const isCancelButtonSetToNever = (showCancelButton) => {
    return (showCancelButton === "never" ||
        showCancelButton === "false" ||
        showCancelButton === false);
};
const isCancelButtonSetToFocus = (showCancelButton) => {
    return (showCancelButton === "focus" ||
        showCancelButton === "true" ||
        showCancelButton === true ||
        showCancelButton === "");
};

export { AddressSearchBox as GlAddressSearch, GeocodeController as GlGeocodeController, Searchbar as IonSearchbar };
