/** * Country selector with flags. * * Upgrades any ` stays in the DOM as * the value holder. The widget writes the chosen ISO code back to it and fires a * `change` event, so form submission, required-field validation and any existing * listener keep working exactly as before. If this script fails to load — or the * browser is very old — the untouched native select is still fully usable. * * Reads flag URLs from the field's own `data-flag-base`, matching the phone * widget, so there is a single place that knows where the SVGs live. */ (function () { "use strict"; var DATA = window.yatraCountrySelectData || {}; var I18N = DATA.i18n || {}; var SEARCH_PLACEHOLDER = I18N.search || "Search country"; var NO_RESULTS = I18N.noResults || "No matches"; /** Native pickers are better on touch devices, so leave those alone. */ function prefersNativePicker() { return ( window.matchMedia && window.matchMedia("(max-width: 640px), (pointer: coarse)").matches ); } function flagUrl(base, iso) { if (!base || !iso) return ""; return base + String(iso).toLowerCase() + ".svg"; } function closeAll(except) { document .querySelectorAll(".yatra-country-field.is-open") .forEach(function (f) { if (f === except) return; f.classList.remove("is-open"); var btn = f.querySelector(".yatra-country-trigger"); if (btn) btn.setAttribute("aria-expanded", "false"); }); } function enhance(select) { if (!select || select.dataset.yatraCountryReady === "1") return; // A disabled or readonly field gains nothing from the widget. if (select.disabled) return; select.dataset.yatraCountryReady = "1"; var flagBase = select.getAttribute("data-flag-base") || ""; // Build the option model straight from the existing