+ return;
+ } else if (_connection && _connection.getConnectionId() !== cid) {
+ if (typeof callback === "function") {
+ callback({ message: "Connection Switched", status: -1 });
+ }
+ return;
+ } else {
+ _history.merge(result.data, result.extent);
+ if (typeof callback === "function") {
+ callback(err, result);
+ }
+ return;
+ }
+ };
+ }
+ context.loadTiles = (projection2, callback) => {
+ const handle = window.requestIdleCallback(() => {
+ _deferred2.delete(handle);
+ if (_connection && context.editableDataEnabled()) {
+ const cid = _connection.getConnectionId();
+ _connection.loadTiles(projection2, afterLoad(cid, callback));
+ }
+ });
+ _deferred2.add(handle);
+ };
+ context.loadTileAtLoc = (loc, callback) => {
+ const handle = window.requestIdleCallback(() => {
+ _deferred2.delete(handle);
+ if (_connection && context.editableDataEnabled()) {
+ const cid = _connection.getConnectionId();
+ _connection.loadTileAtLoc(loc, afterLoad(cid, callback));
+ }
+ });
+ _deferred2.add(handle);
+ };
+ context.loadEntity = (entityID, callback) => {
+ if (_connection) {
+ const cid = _connection.getConnectionId();
+ _connection.loadEntity(entityID, afterLoad(cid, callback));
+ _connection.loadEntityRelations(entityID, afterLoad(cid, callback));
+ }
+ };
+ context.zoomToEntity = (entityID, zoomTo) => {
+ context.loadEntity(entityID, (err, result) => {
+ if (err)
+ return;
+ if (zoomTo !== false) {
+ const entity = result.data.find((e) => e.id === entityID);
+ if (entity) {
+ _map.zoomTo(entity);
+ }
+ }
+ });
+ _map.on("drawn.zoomToEntity", () => {
+ if (!context.hasEntity(entityID))
+ return;
+ _map.on("drawn.zoomToEntity", null);
+ context.on("enter.zoomToEntity", null);
+ context.enter(modeSelect(context, [entityID]));
+ });
+ context.on("enter.zoomToEntity", () => {
+ if (_mode.id !== "browse") {
+ _map.on("drawn.zoomToEntity", null);
+ context.on("enter.zoomToEntity", null);
+ }
+ });
+ };
+ let _minEditableZoom = 16;
+ context.minEditableZoom = function(val) {
+ if (!arguments.length)
+ return _minEditableZoom;
+ _minEditableZoom = val;
+ if (_connection) {
+ _connection.tileZoom(val);
+ }
+ return context;
+ };
+ context.maxCharsForTagKey = () => 255;
+ context.maxCharsForTagValue = () => 255;
+ context.maxCharsForRelationRole = () => 255;
+ context.cleanTagKey = (val) => utilCleanOsmString(val, context.maxCharsForTagKey());
+ context.cleanTagValue = (val) => utilCleanOsmString(val, context.maxCharsForTagValue());
+ context.cleanRelationRole = (val) => utilCleanOsmString(val, context.maxCharsForRelationRole());
+ let _inIntro = false;
+ context.inIntro = function(val) {
+ if (!arguments.length)
+ return _inIntro;
+ _inIntro = val;
+ return context;
+ };
+ context.save = () => {
+ if (_inIntro || context.container().select(".modal").size())
+ return;
+ let canSave;
+ if (_mode && _mode.id === "save") {
+ canSave = false;
+ if (services.osm && services.osm.isChangesetInflight()) {
+ _history.clearSaved();
+ return;
+ }
+ } else {
+ canSave = context.selectedIDs().every((id2) => {
+ const entity = context.hasEntity(id2);
+ return entity && !entity.isDegenerate();
+ });
+ }
+ if (canSave) {
+ _history.save();
+ }
+ if (_history.hasChanges()) {
+ return _t("save.unsaved_changes");
+ }
+ };
+ context.debouncedSave = debounce_default(context.save, 350);
+ function withDebouncedSave(fn) {
+ return function() {
+ const result = fn.apply(_history, arguments);
+ context.debouncedSave();
+ return result;
+ };
+ }
+ context.hasEntity = (id2) => _history.graph().hasEntity(id2);
+ context.entity = (id2) => _history.graph().entity(id2);
+ let _mode;
+ context.mode = () => _mode;
+ context.enter = (newMode) => {
+ if (_mode) {
+ _mode.exit();
+ dispatch10.call("exit", this, _mode);
+ }
+ _mode = newMode;
+ _mode.enter();
+ dispatch10.call("enter", this, _mode);
+ };
+ context.selectedIDs = () => _mode && _mode.selectedIDs && _mode.selectedIDs() || [];
+ context.activeID = () => _mode && _mode.activeID && _mode.activeID();
+ let _selectedNoteID;
+ context.selectedNoteID = function(noteID) {
+ if (!arguments.length)
+ return _selectedNoteID;
+ _selectedNoteID = noteID;
+ return context;
+ };
+ let _selectedErrorID;
+ context.selectedErrorID = function(errorID) {
+ if (!arguments.length)
+ return _selectedErrorID;
+ _selectedErrorID = errorID;
+ return context;
+ };
+ context.install = (behavior) => context.surface().call(behavior);
+ context.uninstall = (behavior) => context.surface().call(behavior.off);
+ let _copyGraph;
+ context.copyGraph = () => _copyGraph;
+ let _copyIDs = [];
+ context.copyIDs = function(val) {
+ if (!arguments.length)
+ return _copyIDs;
+ _copyIDs = val;
+ _copyGraph = _history.graph();
+ return context;
+ };
+ let _copyLonLat;
+ context.copyLonLat = function(val) {
+ if (!arguments.length)
+ return _copyLonLat;
+ _copyLonLat = val;
+ return context;
+ };
+ let _background;
+ context.background = () => _background;
+ let _features;
+ context.features = () => _features;
+ context.hasHiddenConnections = (id2) => {
+ const graph = _history.graph();
+ const entity = graph.entity(id2);
+ return _features.hasHiddenConnections(entity, graph);
+ };
+ let _photos;
+ context.photos = () => _photos;
+ let _map;
+ context.map = () => _map;
+ context.layers = () => _map.layers();
+ context.surface = () => _map.surface;
+ context.editableDataEnabled = () => _map.editableDataEnabled();
+ context.surfaceRect = () => _map.surface.node().getBoundingClientRect();
+ context.editable = () => {
+ const mode = context.mode();
+ if (!mode || mode.id === "save")
+ return false;
+ return _map.editableDataEnabled();
+ };
+ let _debugFlags = {
+ tile: false,
+ // tile boundaries
+ collision: false,
+ // label collision bounding boxes
+ imagery: false,
+ // imagery bounding polygons
+ target: false,
+ // touch targets
+ downloaded: false
+ // downloaded data from osm
+ };
+ context.debugFlags = () => _debugFlags;
+ context.getDebug = (flag) => flag && _debugFlags[flag];
+ context.setDebug = function(flag, val) {
+ if (arguments.length === 1)
+ val = true;
+ _debugFlags[flag] = val;
+ dispatch10.call("change");
+ return context;
+ };
+ let _container = select_default2(null);
+ context.container = function(val) {
+ if (!arguments.length)
+ return _container;
+ _container = val;
+ _container.classed("ideditor", true);
+ return context;
+ };
+ context.containerNode = function(val) {
+ if (!arguments.length)
+ return context.container().node();
+ context.container(select_default2(val));
+ return context;
+ };
+ let _embed;
+ context.embed = function(val) {
+ if (!arguments.length)
+ return _embed;
+ _embed = val;
+ return context;
+ };
+ let _assetPath = "";
+ context.assetPath = function(val) {
+ if (!arguments.length)
+ return _assetPath;
+ _assetPath = val;
+ _mainFileFetcher.assetPath(val);
+ return context;
+ };
+ let _assetMap = {};
+ context.assetMap = function(val) {
+ if (!arguments.length)
+ return _assetMap;
+ _assetMap = val;
+ _mainFileFetcher.assetMap(val);
+ return context;
+ };
+ context.asset = (val) => {
+ if (/^http(s)?:\/\//i.test(val))
+ return val;
+ const filename = _assetPath + val;
+ return _assetMap[filename] || filename;
+ };
+ context.imagePath = (val) => context.asset(`img/${val}`);
+ context.reset = context.flush = () => {
+ context.debouncedSave.cancel();
+ Array.from(_deferred2).forEach((handle) => {
+ window.cancelIdleCallback(handle);
+ _deferred2.delete(handle);
+ });
+ Object.values(services).forEach((service) => {
+ if (service && typeof service.reset === "function") {
+ service.reset(context);
+ }
+ });
+ context.changeset = null;
+ _validator.reset();
+ _features.reset();
+ _history.reset();
+ _uploader.reset();
+ context.container().select(".inspector-wrap *").remove();
+ return context;
+ };
+ context.projection = geoRawMercator();
+ context.curtainProjection = geoRawMercator();
+ context.init = () => {
+ instantiateInternal();
+ initializeDependents();
+ return context;
+ function instantiateInternal() {
+ _history = coreHistory(context);
+ context.graph = _history.graph;
+ context.pauseChangeDispatch = _history.pauseChangeDispatch;
+ context.resumeChangeDispatch = _history.resumeChangeDispatch;
+ context.perform = withDebouncedSave(_history.perform);
+ context.replace = withDebouncedSave(_history.replace);
+ context.pop = withDebouncedSave(_history.pop);
+ context.overwrite = withDebouncedSave(_history.overwrite);
+ context.undo = withDebouncedSave(_history.undo);
+ context.redo = withDebouncedSave(_history.redo);
+ _validator = coreValidator(context);
+ _uploader = coreUploader(context);
+ _background = rendererBackground(context);
+ _features = rendererFeatures(context);
+ _map = rendererMap(context);
+ _photos = rendererPhotos(context);
+ _ui = uiInit(context);
+ }
+ function initializeDependents() {
+ if (context.initialHashParams.presets) {
+ _mainPresetIndex.addablePresetIDs(new Set(context.initialHashParams.presets.split(",")));
+ }
+ if (context.initialHashParams.locale) {
+ _mainLocalizer.preferredLocaleCodes(context.initialHashParams.locale);
+ }
+ _mainLocalizer.ensureLoaded();
+ _mainPresetIndex.ensureLoaded();
+ _background.ensureLoaded();
+ Object.values(services).forEach((service) => {
+ if (service && typeof service.init === "function") {
+ service.init();
+ }
+ });
+ _map.init();
+ _validator.init();
+ _features.init();
+ if (services.maprules && context.initialHashParams.maprules) {
+ json_default(context.initialHashParams.maprules).then((mapcss) => {
+ services.maprules.init();
+ mapcss.forEach((mapcssSelector) => services.maprules.addRule(mapcssSelector));
+ }).catch(() => {
+ });
+ }
+ if (!context.container().empty()) {
+ _ui.ensureLoaded().then(() => {
+ _background.init();
+ _photos.init();
+ });
+ }
+ }
+ };
+ return context;
+ }
+
+ // modules/services/nominatim.js
+ var apibase = nominatimApiUrl;
+ var _inflight = {};
+ var _nominatimCache;
+ var nominatim_default = {
+ init: function() {
+ _inflight = {};
+ _nominatimCache = new import_rbush7.default();
+ },
+ reset: function() {
+ Object.values(_inflight).forEach(function(controller) {
+ controller.abort();
+ });
+ _inflight = {};
+ _nominatimCache = new import_rbush7.default();
+ },
+ countryCode: function(location, callback) {
+ this.reverse(location, function(err, result) {
+ if (err) {
+ return callback(err);
+ } else if (result.address) {
+ return callback(null, result.address.country_code);
+ } else {
+ return callback("Unable to geocode", null);
+ }
+ });
+ },
+ reverse: function(loc, callback) {
+ var cached = _nominatimCache.search(
+ { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] }
+ );
+ if (cached.length > 0) {
+ if (callback)
+ callback(null, cached[0].data);
+ return;
+ }
+ var params = { zoom: 13, format: "json", addressdetails: 1, lat: loc[1], lon: loc[0] };
+ var url = apibase + "reverse?" + utilQsString(params);
+ if (_inflight[url])
+ return;
+ var controller = new AbortController();
+ _inflight[url] = controller;
+ json_default(url, {
+ signal: controller.signal,
+ headers: {
+ "Accept-Language": _mainLocalizer.localeCodes().join(",")
+ }
+ }).then(function(result) {
+ delete _inflight[url];
+ if (result && result.error) {
+ throw new Error(result.error);
+ }
+ var extent = geoExtent(loc).padByMeters(200);
+ _nominatimCache.insert(Object.assign(extent.bbox(), { data: result }));
+ if (callback)
+ callback(null, result);
+ }).catch(function(err) {
+ delete _inflight[url];
+ if (err.name === "AbortError")
+ return;
+ if (callback)
+ callback(err.message);
+ });
+ },
+ search: function(val, callback) {
+ var searchVal = encodeURIComponent(val);
+ var url = apibase + "search/" + searchVal + "?limit=10&format=json";
+ if (_inflight[url])
+ return;
+ var controller = new AbortController();
+ _inflight[url] = controller;
+ json_default(url, {
+ signal: controller.signal,
+ headers: {
+ "Accept-Language": _mainLocalizer.localeCodes().join(",")
+ }
+ }).then(function(result) {
+ delete _inflight[url];
+ if (result && result.error) {
+ throw new Error(result.error);
+ }
+ if (callback)
+ callback(null, result);
+ }).catch(function(err) {
+ delete _inflight[url];
+ if (err.name === "AbortError")
+ return;
+ if (callback)
+ callback(err.message);
+ });
+ }
+ };
+
+ // node_modules/name-suggestion-index/lib/matcher.js
+ var import_which_polygon4 = __toESM(require_which_polygon(), 1);
+
+ // node_modules/name-suggestion-index/lib/simplify.js
+ var import_diacritics3 = __toESM(require_diacritics(), 1);
+ function simplify2(str2) {
+ if (typeof str2 !== "string")
+ return "";
+ return import_diacritics3.default.remove(
+ str2.replace(/&/g, "and").replace(/İ/ig, "i").replace(/[\s\-=_!"#%'*{},.\/:;?\(\)\[\]@\\$\^*+<>«»~`’\u00a1\u00a7\u00b6\u00b7\u00bf\u037e\u0387\u055a-\u055f\u0589\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0af0\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f14\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1360-\u1368\u166d\u166e\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u1805\u1807-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cc0-\u1cc7\u1cd3\u2000-\u206f\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e7f\u3001-\u3003\u303d\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uaaf0\uaaf1\uabeb\ufe10-\ufe16\ufe19\ufe30\ufe45\ufe46\ufe49-\ufe4c\ufe50-\ufe52\ufe54-\ufe57\ufe5f-\ufe61\ufe68\ufe6a\ufe6b\ufeff\uff01-\uff03\uff05-\uff07\uff0a\uff0c\uff0e\uff0f\uff1a\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65]+/g, "").toLowerCase()
+ );
+ }
+
+ // node_modules/name-suggestion-index/config/matchGroups.json
+ var matchGroups_default = {
+ matchGroups: {
+ adult_gaming_centre: [
+ "amenity/casino",
+ "amenity/gambling",
+ "leisure/adult_gaming_centre"
+ ],
+ beauty: [
+ "shop/beauty",
+ "shop/hairdresser_supply"
+ ],
+ bed: [
+ "shop/bed",
+ "shop/furniture"
+ ],
+ beverages: [
+ "shop/alcohol",
+ "shop/beer",
+ "shop/beverages",
+ "shop/kiosk",
+ "shop/wine"
+ ],
+ camping: [
+ "tourism/camp_site",
+ "tourism/caravan_site"
+ ],
+ car_parts: [
+ "shop/car_parts",
+ "shop/car_repair",
+ "shop/tires",
+ "shop/tyres"
+ ],
+ clinic: [
+ "amenity/clinic",
+ "amenity/doctors",
+ "healthcare/clinic",
+ "healthcare/laboratory",
+ "healthcare/physiotherapist",
+ "healthcare/sample_collection",
+ "healthcare/dialysis"
+ ],
+ convenience: [
+ "shop/beauty",
+ "shop/chemist",
+ "shop/convenience",
+ "shop/cosmetics",
+ "shop/grocery",
+ "shop/kiosk",
+ "shop/newsagent",
+ "shop/perfumery"
+ ],
+ coworking: [
+ "amenity/coworking_space",
+ "office/coworking",
+ "office/coworking_space"
+ ],
+ dentist: [
+ "amenity/dentist",
+ "amenity/doctors",
+ "healthcare/dentist"
+ ],
+ electronics: [
+ "office/telecommunication",
+ "shop/computer",
+ "shop/electronics",
+ "shop/hifi",
+ "shop/kiosk",
+ "shop/mobile",
+ "shop/mobile_phone",
+ "shop/telecommunication"
+ ],
+ fabric: [
+ "shop/fabric",
+ "shop/haberdashery",
+ "shop/sewing"
+ ],
+ fashion: [
+ "shop/accessories",
+ "shop/bag",
+ "shop/boutique",
+ "shop/clothes",
+ "shop/department_store",
+ "shop/fashion",
+ "shop/fashion_accessories",
+ "shop/sports",
+ "shop/shoes"
+ ],
+ financial: [
+ "amenity/bank",
+ "office/accountant",
+ "office/financial",
+ "office/financial_advisor",
+ "office/tax_advisor",
+ "shop/tax"
+ ],
+ fitness: [
+ "leisure/fitness_centre",
+ "leisure/fitness_center",
+ "leisure/sports_centre",
+ "leisure/sports_center"
+ ],
+ food: [
+ "amenity/bar",
+ "amenity/cafe",
+ "amenity/fast_food",
+ "amenity/ice_cream",
+ "amenity/pub",
+ "amenity/restaurant",
+ "shop/bakery",
+ "shop/candy",
+ "shop/chocolate",
+ "shop/coffee",
+ "shop/confectionary",
+ "shop/confectionery",
+ "shop/food",
+ "shop/kiosk",
+ "shop/ice_cream",
+ "shop/pastry",
+ "shop/tea"
+ ],
+ fuel: [
+ "amenity/fuel",
+ "shop/gas",
+ "shop/convenience;gas",
+ "shop/gas;convenience"
+ ],
+ gift: [
+ "shop/gift",
+ "shop/card",
+ "shop/cards",
+ "shop/kiosk",
+ "shop/stationery"
+ ],
+ hardware: [
+ "shop/bathroom_furnishing",
+ "shop/carpet",
+ "shop/diy",
+ "shop/doityourself",
+ "shop/doors",
+ "shop/electrical",
+ "shop/flooring",
+ "shop/hardware",
+ "shop/hardware_store",
+ "shop/power_tools",
+ "shop/tool_hire",
+ "shop/tools",
+ "shop/trade"
+ ],
+ health_food: [
+ "shop/health",
+ "shop/health_food",
+ "shop/herbalist",
+ "shop/nutrition_supplements"
+ ],
+ hobby: [
+ "shop/electronics",
+ "shop/hobby",
+ "shop/books",
+ "shop/games",
+ "shop/collector",
+ "shop/toys",
+ "shop/model",
+ "shop/video_games",
+ "shop/anime"
+ ],
+ hospital: [
+ "amenity/doctors",
+ "amenity/hospital",
+ "healthcare/hospital"
+ ],
+ houseware: [
+ "shop/houseware",
+ "shop/interior_decoration"
+ ],
+ lifeboat_station: [
+ "amenity/lifeboat_station",
+ "emergency/lifeboat_station",
+ "emergency/marine_rescue"
+ ],
+ lodging: [
+ "tourism/hotel",
+ "tourism/motel"
+ ],
+ money_transfer: [
+ "amenity/money_transfer",
+ "shop/money_transfer"
+ ],
+ office_supplies: [
+ "shop/office_supplies",
+ "shop/stationary",
+ "shop/stationery"
+ ],
+ outdoor: [
+ "shop/clothes",
+ "shop/outdoor",
+ "shop/sports"
+ ],
+ parcel_locker: [
+ "amenity/parcel_locker",
+ "amenity/vending_machine"
+ ],
+ pharmacy: [
+ "amenity/doctors",
+ "amenity/pharmacy",
+ "healthcare/pharmacy"
+ ],
+ playground: [
+ "amenity/theme_park",
+ "leisure/amusement_arcade",
+ "leisure/playground"
+ ],
+ rental: [
+ "amenity/bicycle_rental",
+ "amenity/boat_rental",
+ "amenity/car_rental",
+ "amenity/truck_rental",
+ "amenity/vehicle_rental",
+ "shop/kiosk",
+ "shop/rental"
+ ],
+ school: [
+ "amenity/childcare",
+ "amenity/college",
+ "amenity/kindergarten",
+ "amenity/language_school",
+ "amenity/prep_school",
+ "amenity/school",
+ "amenity/university"
+ ],
+ storage: [
+ "shop/storage_units",
+ "shop/storage_rental"
+ ],
+ substation: [
+ "power/station",
+ "power/substation",
+ "power/sub_station"
+ ],
+ supermarket: [
+ "shop/food",
+ "shop/frozen_food",
+ "shop/greengrocer",
+ "shop/grocery",
+ "shop/supermarket",
+ "shop/wholesale"
+ ],
+ variety_store: [
+ "shop/variety_store",
+ "shop/discount",
+ "shop/convenience"
+ ],
+ vending: [
+ "amenity/vending_machine",
+ "shop/kiosk",
+ "shop/vending_machine"
+ ],
+ weight_loss: [
+ "amenity/clinic",
+ "amenity/doctors",
+ "amenity/weight_clinic",
+ "healthcare/counselling",
+ "leisure/fitness_centre",
+ "office/therapist",
+ "shop/beauty",
+ "shop/diet",
+ "shop/food",
+ "shop/health_food",
+ "shop/herbalist",
+ "shop/nutrition",
+ "shop/nutrition_supplements",
+ "shop/weight_loss"
+ ],
+ wholesale: [
+ "shop/wholesale",
+ "shop/supermarket",
+ "shop/department_store"
+ ]
+ }
+ };
+
+ // node_modules/name-suggestion-index/config/genericWords.json
+ var genericWords_default = {
+ genericWords: [
+ "^(barn|bazaa?r|bench|bou?tique|building|casa|church)$",
+ "^(baseball|basketball|football|soccer|softball|tennis(halle)?)\\s?(field|court)?$",
+ "^(club|green|out|ware)\\s?house$",
+ "^(driveway|el \xE1rbol|fountain|generic|golf|government|graveyard)$",
+ "^(fixme|n\\s?\\/?\\s?a|name|no\\s?name|none|null|temporary|test|unknown)$",
+ "^(hofladen|librairie|magazine?|maison)$",
+ "^(mobile home|skate)?\\s?park$",
+ "^(obuwie|pond|pool|sale|shops?|sklep|stores?)$",
+ "^\\?+$",
+ "^private$",
+ "^tattoo( studio)?$",
+ "^windmill$",
+ "^\u0446\u0435\u0440\u043A\u043E\u0432\u043D\u0430\u044F( \u043B\u0430\u0432\u043A\u0430)?$"
+ ]
+ };
+
+ // node_modules/name-suggestion-index/config/trees.json
+ var trees_default = {
+ trees: {
+ brands: {
+ emoji: "\u{1F354}",
+ mainTag: "brand:wikidata",
+ sourceTags: ["brand", "name"],
+ nameTags: {
+ primary: "^(name|name:\\w+)$",
+ alternate: "^(brand|brand:\\w+|operator|operator:\\w+|\\w+_name|\\w+_name:\\w+)$"
+ }
+ },
+ flags: {
+ emoji: "\u{1F6A9}",
+ mainTag: "flag:wikidata",
+ nameTags: {
+ primary: "^(flag:name|flag:name:\\w+)$",
+ alternate: "^(country|country:\\w+|flag|flag:\\w+|subject|subject:\\w+)$"
+ }
+ },
+ operators: {
+ emoji: "\u{1F4BC}",
+ mainTag: "operator:wikidata",
+ sourceTags: ["operator"],
+ nameTags: {
+ primary: "^(name|name:\\w+|operator|operator:\\w+)$",
+ alternate: "^(brand|brand:\\w+|\\w+_name|\\w+_name:\\w+)$"
+ }
+ },
+ transit: {
+ emoji: "\u{1F687}",
+ mainTag: "network:wikidata",
+ sourceTags: ["network"],
+ nameTags: {
+ primary: "^network$",
+ alternate: "^(operator|operator:\\w+|network:\\w+|\\w+_name|\\w+_name:\\w+)$"
+ }
+ }
+ }
+ };
+
+ // node_modules/name-suggestion-index/lib/matcher.js
+ var matchGroups = matchGroups_default.matchGroups;
+ var trees = trees_default.trees;
+ var Matcher = class {
+ //
+ // `constructor`
+ // initialize the genericWords regexes
+ constructor() {
+ this.matchIndex = void 0;
+ this.genericWords = /* @__PURE__ */ new Map();
+ (genericWords_default.genericWords || []).forEach((s) => this.genericWords.set(s, new RegExp(s, "i")));
+ this.itemLocation = void 0;
+ this.locationSets = void 0;
+ this.locationIndex = void 0;
+ this.warnings = [];
+ }
+ //
+ // `buildMatchIndex()`
+ // Call this to prepare the matcher for use
+ //
+ // `data` needs to be an Object indexed on a 'tree/key/value' path.
+ // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
+ // {
+ // 'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
+ // 'brands/amenity/bar': { properties: {}, items: [ {}, {}, … ] },
+ // …
+ // }
+ //
+ buildMatchIndex(data) {
+ const that = this;
+ if (that.matchIndex)
+ return;
+ that.matchIndex = /* @__PURE__ */ new Map();
+ const seenTree = /* @__PURE__ */ new Map();
+ Object.keys(data).forEach((tkv) => {
+ const category = data[tkv];
+ const parts = tkv.split("/", 3);
+ const t = parts[0];
+ const k = parts[1];
+ const v = parts[2];
+ const thiskv = `${k}/${v}`;
+ const tree = trees[t];
+ let branch = that.matchIndex.get(thiskv);
+ if (!branch) {
+ branch = {
+ primary: /* @__PURE__ */ new Map(),
+ alternate: /* @__PURE__ */ new Map(),
+ excludeGeneric: /* @__PURE__ */ new Map(),
+ excludeNamed: /* @__PURE__ */ new Map()
+ };
+ that.matchIndex.set(thiskv, branch);
+ }
+ const properties = category.properties || {};
+ const exclude = properties.exclude || {};
+ (exclude.generic || []).forEach((s) => branch.excludeGeneric.set(s, new RegExp(s, "i")));
+ (exclude.named || []).forEach((s) => branch.excludeNamed.set(s, new RegExp(s, "i")));
+ const excludeRegexes = [...branch.excludeGeneric.values(), ...branch.excludeNamed.values()];
+ let items = category.items;
+ if (!Array.isArray(items) || !items.length)
+ return;
+ const primaryName = new RegExp(tree.nameTags.primary, "i");
+ const alternateName = new RegExp(tree.nameTags.alternate, "i");
+ const notName = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
+ const skipGenericKV = skipGenericKVMatches(t, k, v);
+ const genericKV = /* @__PURE__ */ new Set([`${k}/yes`, `building/yes`]);
+ const matchGroupKV = /* @__PURE__ */ new Set();
+ Object.values(matchGroups).forEach((matchGroup) => {
+ const inGroup = matchGroup.some((otherkv) => otherkv === thiskv);
+ if (!inGroup)
+ return;
+ matchGroup.forEach((otherkv) => {
+ if (otherkv === thiskv)
+ return;
+ matchGroupKV.add(otherkv);
+ const otherk = otherkv.split("/", 2)[0];
+ genericKV.add(`${otherk}/yes`);
+ });
+ });
+ items.forEach((item) => {
+ if (!item.id)
+ return;
+ if (Array.isArray(item.matchTags) && item.matchTags.length) {
+ item.matchTags = item.matchTags.filter((matchTag) => !matchGroupKV.has(matchTag) && !genericKV.has(matchTag));
+ if (!item.matchTags.length)
+ delete item.matchTags;
+ }
+ let kvTags = [`${thiskv}`].concat(item.matchTags || []);
+ if (!skipGenericKV) {
+ kvTags = kvTags.concat(Array.from(genericKV));
+ }
+ Object.keys(item.tags).forEach((osmkey) => {
+ if (notName.test(osmkey))
+ return;
+ const osmvalue = item.tags[osmkey];
+ if (!osmvalue || excludeRegexes.some((regex) => regex.test(osmvalue)))
+ return;
+ if (primaryName.test(osmkey)) {
+ kvTags.forEach((kv) => insertName("primary", t, kv, simplify2(osmvalue), item.id));
+ } else if (alternateName.test(osmkey)) {
+ kvTags.forEach((kv) => insertName("alternate", t, kv, simplify2(osmvalue), item.id));
+ }
+ });
+ let keepMatchNames = /* @__PURE__ */ new Set();
+ (item.matchNames || []).forEach((matchName) => {
+ const nsimple = simplify2(matchName);
+ kvTags.forEach((kv) => {
+ const branch2 = that.matchIndex.get(kv);
+ const primaryLeaf = branch2 && branch2.primary.get(nsimple);
+ const alternateLeaf = branch2 && branch2.alternate.get(nsimple);
+ const inPrimary = primaryLeaf && primaryLeaf.has(item.id);
+ const inAlternate = alternateLeaf && alternateLeaf.has(item.id);
+ if (!inPrimary && !inAlternate) {
+ insertName("alternate", t, kv, nsimple, item.id);
+ keepMatchNames.add(matchName);
+ }
+ });
+ });
+ if (keepMatchNames.size) {
+ item.matchNames = Array.from(keepMatchNames);
+ } else {
+ delete item.matchNames;
+ }
+ });
+ });
+ function insertName(which, t, kv, nsimple, itemID) {
+ if (!nsimple) {
+ that.warnings.push(`Warning: skipping empty ${which} name for item ${t}/${kv}: ${itemID}`);
+ return;
+ }
+ let branch = that.matchIndex.get(kv);
+ if (!branch) {
+ branch = {
+ primary: /* @__PURE__ */ new Map(),
+ alternate: /* @__PURE__ */ new Map(),
+ excludeGeneric: /* @__PURE__ */ new Map(),
+ excludeNamed: /* @__PURE__ */ new Map()
+ };
+ that.matchIndex.set(kv, branch);
+ }
+ let leaf = branch[which].get(nsimple);
+ if (!leaf) {
+ leaf = /* @__PURE__ */ new Set();
+ branch[which].set(nsimple, leaf);
+ }
+ leaf.add(itemID);
+ if (!/yes$/.test(kv)) {
+ const kvnsimple = `${kv}/${nsimple}`;
+ const existing = seenTree.get(kvnsimple);
+ if (existing && existing !== t) {
+ const items = Array.from(leaf);
+ that.warnings.push(`Duplicate cache key "${kvnsimple}" in trees "${t}" and "${existing}", check items: ${items}`);
+ return;
+ }
+ seenTree.set(kvnsimple, t);
+ }
+ }
+ function skipGenericKVMatches(t, k, v) {
+ return t === "flags" || t === "transit" || k === "landuse" || v === "atm" || v === "bicycle_parking" || v === "car_sharing" || v === "caravan_site" || v === "charging_station" || v === "dog_park" || v === "parking" || v === "phone" || v === "playground" || v === "post_box" || v === "public_bookcase" || v === "recycling" || v === "vending_machine";
+ }
+ }
+ //
+ // `buildLocationIndex()`
+ // Call this to prepare a which-polygon location index.
+ // This *resolves* all the locationSets into GeoJSON, which takes some time.
+ // You can skip this step if you don't care about matching within a location.
+ //
+ // `data` needs to be an Object indexed on a 'tree/key/value' path.
+ // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
+ // {
+ // 'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
+ // 'brands/amenity/bar': { properties: {}, items: [ {}, {}, … ] },
+ // …
+ // }
+ //
+ buildLocationIndex(data, loco) {
+ const that = this;
+ if (that.locationIndex)
+ return;
+ that.itemLocation = /* @__PURE__ */ new Map();
+ that.locationSets = /* @__PURE__ */ new Map();
+ Object.keys(data).forEach((tkv) => {
+ const items = data[tkv].items;
+ if (!Array.isArray(items) || !items.length)
+ return;
+ items.forEach((item) => {
+ if (that.itemLocation.has(item.id))
+ return;
+ let resolved;
+ try {
+ resolved = loco.resolveLocationSet(item.locationSet);
+ } catch (err) {
+ console.warn(`buildLocationIndex: ${err.message}`);
+ }
+ if (!resolved || !resolved.id)
+ return;
+ that.itemLocation.set(item.id, resolved.id);
+ if (that.locationSets.has(resolved.id))
+ return;
+ let feature3 = _cloneDeep2(resolved.feature);
+ feature3.id = resolved.id;
+ feature3.properties.id = resolved.id;
+ if (!feature3.geometry.coordinates.length || !feature3.properties.area) {
+ console.warn(`buildLocationIndex: locationSet ${resolved.id} for ${item.id} resolves to an empty feature:`);
+ console.warn(JSON.stringify(feature3));
+ return;