]> git.openstreetmap.org Git - rails.git/blob - vendor/assets/iD/iD.js
bd1f5a5ddbe6811066ed7995b852e3e156dc75d9
[rails.git] / vendor / assets / iD / iD.js
1 "use strict";
2 (() => {
3   var __create = Object.create;
4   var __freeze = Object.freeze;
5   var __defProp = Object.defineProperty;
6   var __defProps = Object.defineProperties;
7   var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8   var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9   var __getOwnPropNames = Object.getOwnPropertyNames;
10   var __getOwnPropSymbols = Object.getOwnPropertySymbols;
11   var __getProtoOf = Object.getPrototypeOf;
12   var __hasOwnProp = Object.prototype.hasOwnProperty;
13   var __propIsEnum = Object.prototype.propertyIsEnumerable;
14   var __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : Symbol.for("Symbol." + name);
15   var __typeError = (msg) => {
16     throw TypeError(msg);
17   };
18   var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
19   var __spreadValues = (a2, b2) => {
20     for (var prop in b2 || (b2 = {}))
21       if (__hasOwnProp.call(b2, prop))
22         __defNormalProp(a2, prop, b2[prop]);
23     if (__getOwnPropSymbols)
24       for (var prop of __getOwnPropSymbols(b2)) {
25         if (__propIsEnum.call(b2, prop))
26           __defNormalProp(a2, prop, b2[prop]);
27       }
28     return a2;
29   };
30   var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
31   var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
32     get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2]
33   }) : x2)(function(x2) {
34     if (typeof require !== "undefined") return require.apply(this, arguments);
35     throw Error('Dynamic require of "' + x2 + '" is not supported');
36   });
37   var __commonJS = (cb, mod) => function __require2() {
38     return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
39   };
40   var __export = (target, all) => {
41     for (var name in all)
42       __defProp(target, name, { get: all[name], enumerable: true });
43   };
44   var __copyProps = (to, from, except, desc) => {
45     if (from && typeof from === "object" || typeof from === "function") {
46       for (let key of __getOwnPropNames(from))
47         if (!__hasOwnProp.call(to, key) && key !== except)
48           __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
49     }
50     return to;
51   };
52   var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
53     // If the importer is in node compatibility mode or this is not an ESM
54     // file that has been converted to a CommonJS file using a Babel-
55     // compatible transform (i.e. "__esModule" has not been set), then set
56     // "default" to the CommonJS "module.exports" for node compatibility.
57     isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
58     mod
59   ));
60   var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
61   var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(raw || cooked.slice()) }));
62   var __await = function(promise, isYieldStar) {
63     this[0] = promise;
64     this[1] = isYieldStar;
65   };
66   var __yieldStar = (value) => {
67     var obj = value[__knownSymbol("asyncIterator")], isAwait = false, method, it = {};
68     if (obj == null) {
69       obj = value[__knownSymbol("iterator")]();
70       method = (k2) => it[k2] = (x2) => obj[k2](x2);
71     } else {
72       obj = obj.call(value);
73       method = (k2) => it[k2] = (v2) => {
74         if (isAwait) {
75           isAwait = false;
76           if (k2 === "throw") throw v2;
77           return v2;
78         }
79         isAwait = true;
80         return {
81           done: false,
82           value: new __await(new Promise((resolve) => {
83             var x2 = obj[k2](v2);
84             if (!(x2 instanceof Object)) __typeError("Object expected");
85             resolve(x2);
86           }), 1)
87         };
88       };
89     }
90     return it[__knownSymbol("iterator")] = () => it, method("next"), "throw" in obj ? method("throw") : it.throw = (x2) => {
91       throw x2;
92     }, "return" in obj && method("return"), it;
93   };
94
95   // node_modules/diacritics/index.js
96   var require_diacritics = __commonJS({
97     "node_modules/diacritics/index.js"(exports2) {
98       exports2.remove = removeDiacritics2;
99       var replacementList = [
100         {
101           base: " ",
102           chars: "\xA0"
103         },
104         {
105           base: "0",
106           chars: "\u07C0"
107         },
108         {
109           base: "A",
110           chars: "\u24B6\uFF21\xC0\xC1\xC2\u1EA6\u1EA4\u1EAA\u1EA8\xC3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\xC4\u01DE\u1EA2\xC5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F"
111         },
112         {
113           base: "AA",
114           chars: "\uA732"
115         },
116         {
117           base: "AE",
118           chars: "\xC6\u01FC\u01E2"
119         },
120         {
121           base: "AO",
122           chars: "\uA734"
123         },
124         {
125           base: "AU",
126           chars: "\uA736"
127         },
128         {
129           base: "AV",
130           chars: "\uA738\uA73A"
131         },
132         {
133           base: "AY",
134           chars: "\uA73C"
135         },
136         {
137           base: "B",
138           chars: "\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0181"
139         },
140         {
141           base: "C",
142           chars: "\u24B8\uFF23\uA73E\u1E08\u0106C\u0108\u010A\u010C\xC7\u0187\u023B"
143         },
144         {
145           base: "D",
146           chars: "\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018A\u0189\u1D05\uA779"
147         },
148         {
149           base: "Dh",
150           chars: "\xD0"
151         },
152         {
153           base: "DZ",
154           chars: "\u01F1\u01C4"
155         },
156         {
157           base: "Dz",
158           chars: "\u01F2\u01C5"
159         },
160         {
161           base: "E",
162           chars: "\u025B\u24BA\uFF25\xC8\xC9\xCA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\xCB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E\u1D07"
163         },
164         {
165           base: "F",
166           chars: "\uA77C\u24BB\uFF26\u1E1E\u0191\uA77B"
167         },
168         {
169           base: "G",
170           chars: "\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E\u0262"
171         },
172         {
173           base: "H",
174           chars: "\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D"
175         },
176         {
177           base: "I",
178           chars: "\u24BE\uFF29\xCC\xCD\xCE\u0128\u012A\u012C\u0130\xCF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197"
179         },
180         {
181           base: "J",
182           chars: "\u24BF\uFF2A\u0134\u0248\u0237"
183         },
184         {
185           base: "K",
186           chars: "\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2"
187         },
188         {
189           base: "L",
190           chars: "\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780"
191         },
192         {
193           base: "LJ",
194           chars: "\u01C7"
195         },
196         {
197           base: "Lj",
198           chars: "\u01C8"
199         },
200         {
201           base: "M",
202           chars: "\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C\u03FB"
203         },
204         {
205           base: "N",
206           chars: "\uA7A4\u0220\u24C3\uFF2E\u01F8\u0143\xD1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u019D\uA790\u1D0E"
207         },
208         {
209           base: "NJ",
210           chars: "\u01CA"
211         },
212         {
213           base: "Nj",
214           chars: "\u01CB"
215         },
216         {
217           base: "O",
218           chars: "\u24C4\uFF2F\xD2\xD3\xD4\u1ED2\u1ED0\u1ED6\u1ED4\xD5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\xD6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\xD8\u01FE\u0186\u019F\uA74A\uA74C"
219         },
220         {
221           base: "OE",
222           chars: "\u0152"
223         },
224         {
225           base: "OI",
226           chars: "\u01A2"
227         },
228         {
229           base: "OO",
230           chars: "\uA74E"
231         },
232         {
233           base: "OU",
234           chars: "\u0222"
235         },
236         {
237           base: "P",
238           chars: "\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754"
239         },
240         {
241           base: "Q",
242           chars: "\u24C6\uFF31\uA756\uA758\u024A"
243         },
244         {
245           base: "R",
246           chars: "\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782"
247         },
248         {
249           base: "S",
250           chars: "\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784"
251         },
252         {
253           base: "T",
254           chars: "\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786"
255         },
256         {
257           base: "Th",
258           chars: "\xDE"
259         },
260         {
261           base: "TZ",
262           chars: "\uA728"
263         },
264         {
265           base: "U",
266           chars: "\u24CA\uFF35\xD9\xDA\xDB\u0168\u1E78\u016A\u1E7A\u016C\xDC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244"
267         },
268         {
269           base: "V",
270           chars: "\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245"
271         },
272         {
273           base: "VY",
274           chars: "\uA760"
275         },
276         {
277           base: "W",
278           chars: "\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72"
279         },
280         {
281           base: "X",
282           chars: "\u24CD\uFF38\u1E8A\u1E8C"
283         },
284         {
285           base: "Y",
286           chars: "\u24CE\uFF39\u1EF2\xDD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE"
287         },
288         {
289           base: "Z",
290           chars: "\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762"
291         },
292         {
293           base: "a",
294           chars: "\u24D0\uFF41\u1E9A\xE0\xE1\xE2\u1EA7\u1EA5\u1EAB\u1EA9\xE3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\xE4\u01DF\u1EA3\xE5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250\u0251"
295         },
296         {
297           base: "aa",
298           chars: "\uA733"
299         },
300         {
301           base: "ae",
302           chars: "\xE6\u01FD\u01E3"
303         },
304         {
305           base: "ao",
306           chars: "\uA735"
307         },
308         {
309           base: "au",
310           chars: "\uA737"
311         },
312         {
313           base: "av",
314           chars: "\uA739\uA73B"
315         },
316         {
317           base: "ay",
318           chars: "\uA73D"
319         },
320         {
321           base: "b",
322           chars: "\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253\u0182"
323         },
324         {
325           base: "c",
326           chars: "\uFF43\u24D2\u0107\u0109\u010B\u010D\xE7\u1E09\u0188\u023C\uA73F\u2184"
327         },
328         {
329           base: "d",
330           chars: "\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\u018B\u13E7\u0501\uA7AA"
331         },
332         {
333           base: "dh",
334           chars: "\xF0"
335         },
336         {
337           base: "dz",
338           chars: "\u01F3\u01C6"
339         },
340         {
341           base: "e",
342           chars: "\u24D4\uFF45\xE8\xE9\xEA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\xEB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u01DD"
343         },
344         {
345           base: "f",
346           chars: "\u24D5\uFF46\u1E1F\u0192"
347         },
348         {
349           base: "ff",
350           chars: "\uFB00"
351         },
352         {
353           base: "fi",
354           chars: "\uFB01"
355         },
356         {
357           base: "fl",
358           chars: "\uFB02"
359         },
360         {
361           base: "ffi",
362           chars: "\uFB03"
363         },
364         {
365           base: "ffl",
366           chars: "\uFB04"
367         },
368         {
369           base: "g",
370           chars: "\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\uA77F\u1D79"
371         },
372         {
373           base: "h",
374           chars: "\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265"
375         },
376         {
377           base: "hv",
378           chars: "\u0195"
379         },
380         {
381           base: "i",
382           chars: "\u24D8\uFF49\xEC\xED\xEE\u0129\u012B\u012D\xEF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131"
383         },
384         {
385           base: "j",
386           chars: "\u24D9\uFF4A\u0135\u01F0\u0249"
387         },
388         {
389           base: "k",
390           chars: "\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3"
391         },
392         {
393           base: "l",
394           chars: "\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747\u026D"
395         },
396         {
397           base: "lj",
398           chars: "\u01C9"
399         },
400         {
401           base: "m",
402           chars: "\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F"
403         },
404         {
405           base: "n",
406           chars: "\u24DD\uFF4E\u01F9\u0144\xF1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5\u043B\u0509"
407         },
408         {
409           base: "nj",
410           chars: "\u01CC"
411         },
412         {
413           base: "o",
414           chars: "\u24DE\uFF4F\xF2\xF3\xF4\u1ED3\u1ED1\u1ED7\u1ED5\xF5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\xF6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\xF8\u01FF\uA74B\uA74D\u0275\u0254\u1D11"
415         },
416         {
417           base: "oe",
418           chars: "\u0153"
419         },
420         {
421           base: "oi",
422           chars: "\u01A3"
423         },
424         {
425           base: "oo",
426           chars: "\uA74F"
427         },
428         {
429           base: "ou",
430           chars: "\u0223"
431         },
432         {
433           base: "p",
434           chars: "\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755\u03C1"
435         },
436         {
437           base: "q",
438           chars: "\u24E0\uFF51\u024B\uA757\uA759"
439         },
440         {
441           base: "r",
442           chars: "\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783"
443         },
444         {
445           base: "s",
446           chars: "\u24E2\uFF53\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B\u0282"
447         },
448         {
449           base: "ss",
450           chars: "\xDF"
451         },
452         {
453           base: "t",
454           chars: "\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787"
455         },
456         {
457           base: "th",
458           chars: "\xFE"
459         },
460         {
461           base: "tz",
462           chars: "\uA729"
463         },
464         {
465           base: "u",
466           chars: "\u24E4\uFF55\xF9\xFA\xFB\u0169\u1E79\u016B\u1E7B\u016D\xFC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289"
467         },
468         {
469           base: "v",
470           chars: "\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C"
471         },
472         {
473           base: "vy",
474           chars: "\uA761"
475         },
476         {
477           base: "w",
478           chars: "\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73"
479         },
480         {
481           base: "x",
482           chars: "\u24E7\uFF58\u1E8B\u1E8D"
483         },
484         {
485           base: "y",
486           chars: "\u24E8\uFF59\u1EF3\xFD\u0177\u1EF9\u0233\u1E8F\xFF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF"
487         },
488         {
489           base: "z",
490           chars: "\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763"
491         }
492       ];
493       var diacriticsMap = {};
494       for (i3 = 0; i3 < replacementList.length; i3 += 1) {
495         chars = replacementList[i3].chars;
496         for (j2 = 0; j2 < chars.length; j2 += 1) {
497           diacriticsMap[chars[j2]] = replacementList[i3].base;
498         }
499       }
500       var chars;
501       var j2;
502       var i3;
503       function removeDiacritics2(str) {
504         return str.replace(/[^\u0000-\u007e]/g, function(c2) {
505           return diacriticsMap[c2] || c2;
506         });
507       }
508       exports2.replacementList = replacementList;
509       exports2.diacriticsMap = diacriticsMap;
510     }
511   });
512
513   // node_modules/alif-toolkit/lib/isArabic.js
514   var require_isArabic = __commonJS({
515     "node_modules/alif-toolkit/lib/isArabic.js"(exports2) {
516       "use strict";
517       Object.defineProperty(exports2, "__esModule", { value: true });
518       exports2.isArabic = isArabic;
519       exports2.isMath = isMath;
520       var arabicBlocks = [
521         [1536, 1791],
522         // Arabic https://www.unicode.org/charts/PDF/U0600.pdf
523         [1872, 1919],
524         // supplement https://www.unicode.org/charts/PDF/U0750.pdf
525         [2208, 2303],
526         // Extended-A https://www.unicode.org/charts/PDF/U08A0.pdf
527         [64336, 65023],
528         // Presentation Forms-A https://www.unicode.org/charts/PDF/UFB50.pdf
529         [65136, 65279],
530         // Presentation Forms-B https://www.unicode.org/charts/PDF/UFE70.pdf
531         [69216, 69247],
532         // Rumi numerals https://www.unicode.org/charts/PDF/U10E60.pdf
533         [126064, 126143],
534         // Indic Siyaq numerals https://www.unicode.org/charts/PDF/U1EC70.pdf
535         [126464, 126719]
536         // Mathematical Alphabetic symbols https://www.unicode.org/charts/PDF/U1EE00.pdf
537       ];
538       function isArabic(char) {
539         if (char.length > 1) {
540           throw new Error("isArabic works on only one-character strings");
541         }
542         let code = char.charCodeAt(0);
543         for (let i3 = 0; i3 < arabicBlocks.length; i3++) {
544           let block2 = arabicBlocks[i3];
545           if (code >= block2[0] && code <= block2[1]) {
546             return true;
547           }
548         }
549         return false;
550       }
551       function isMath(char) {
552         if (char.length > 2) {
553           throw new Error("isMath works on only one-character strings");
554         }
555         let code = char.charCodeAt(0);
556         return code >= 1632 && code <= 1644 || code >= 1776 && code <= 1785;
557       }
558     }
559   });
560
561   // node_modules/alif-toolkit/lib/unicode-arabic.js
562   var require_unicode_arabic = __commonJS({
563     "node_modules/alif-toolkit/lib/unicode-arabic.js"(exports2) {
564       "use strict";
565       Object.defineProperty(exports2, "__esModule", { value: true });
566       var arabicReference = {
567         "alef": {
568           "normal": [
569             "\u0627"
570           ],
571           "madda_above": {
572             "normal": [
573               "\u0627\u0653",
574               "\u0622"
575             ],
576             "isolated": "\uFE81",
577             "final": "\uFE82"
578           },
579           "hamza_above": {
580             "normal": [
581               "\u0627\u0654",
582               "\u0623"
583             ],
584             "isolated": "\uFE83",
585             "final": "\uFE84"
586           },
587           "hamza_below": {
588             "normal": [
589               "\u0627\u0655",
590               "\u0625"
591             ],
592             "isolated": "\uFE87",
593             "final": "\uFE88"
594           },
595           "wasla": {
596             "normal": "\u0671",
597             "isolated": "\uFB50",
598             "final": "\uFB51"
599           },
600           "wavy_hamza_above": [
601             "\u0672"
602           ],
603           "wavy_hamza_below": [
604             "\u0627\u065F",
605             "\u0673"
606           ],
607           "high_hamza": [
608             "\u0675",
609             "\u0627\u0674"
610           ],
611           "indic_two_above": [
612             "\u0773"
613           ],
614           "indic_three_above": [
615             "\u0774"
616           ],
617           "fathatan": {
618             "normal": [
619               "\u0627\u064B"
620             ],
621             "final": "\uFD3C",
622             "isolated": "\uFD3D"
623           },
624           "isolated": "\uFE8D",
625           "final": "\uFE8E"
626         },
627         "beh": {
628           "normal": [
629             "\u0628"
630           ],
631           "dotless": [
632             "\u066E"
633           ],
634           "three_dots_horizontally_below": [
635             "\u0750"
636           ],
637           "dot_below_three_dots_above": [
638             "\u0751"
639           ],
640           "three_dots_pointing_upwards_below": [
641             "\u0752"
642           ],
643           "three_dots_pointing_upwards_below_two_dots_above": [
644             "\u0753"
645           ],
646           "two_dots_below_dot_above": [
647             "\u0754"
648           ],
649           "inverted_small_v_below": [
650             "\u0755"
651           ],
652           "small_v": [
653             "\u0756"
654           ],
655           "small_v_below": [
656             "\u08A0"
657           ],
658           "hamza_above": [
659             "\u08A1"
660           ],
661           "small_meem_above": [
662             "\u08B6"
663           ],
664           "isolated": "\uFE8F",
665           "final": "\uFE90",
666           "initial": "\uFE91",
667           "medial": "\uFE92"
668         },
669         "teh marbuta": {
670           "normal": [
671             "\u0629"
672           ],
673           "isolated": "\uFE93",
674           "final": "\uFE94"
675         },
676         "teh": {
677           "normal": [
678             "\u062A"
679           ],
680           "ring": [
681             "\u067C"
682           ],
683           "three_dots_above_downwards": [
684             "\u067D"
685           ],
686           "small_teh_above": [
687             "\u08B8"
688           ],
689           "isolated": "\uFE95",
690           "final": "\uFE96",
691           "initial": "\uFE97",
692           "medial": "\uFE98"
693         },
694         "theh": {
695           "normal": [
696             "\u062B"
697           ],
698           "isolated": "\uFE99",
699           "final": "\uFE9A",
700           "initial": "\uFE9B",
701           "medial": "\uFE9C"
702         },
703         "jeem": {
704           "normal": [
705             "\u062C"
706           ],
707           "two_dots_above": [
708             "\u08A2"
709           ],
710           "isolated": "\uFE9D",
711           "final": "\uFE9E",
712           "initial": "\uFE9F",
713           "medial": "\uFEA0"
714         },
715         "hah": {
716           "normal": [
717             "\u062D"
718           ],
719           "hamza_above": [
720             "\u0681"
721           ],
722           "two_dots_vertical_above": [
723             "\u0682"
724           ],
725           "three_dots_above": [
726             "\u0685"
727           ],
728           "two_dots_above": [
729             "\u0757"
730           ],
731           "three_dots_pointing_upwards_below": [
732             "\u0758"
733           ],
734           "small_tah_below": [
735             "\u076E"
736           ],
737           "small_tah_two_dots": [
738             "\u076F"
739           ],
740           "small_tah_above": [
741             "\u0772"
742           ],
743           "indic_four_below": [
744             "\u077C"
745           ],
746           "isolated": "\uFEA1",
747           "final": "\uFEA2",
748           "initial": "\uFEA3",
749           "medial": "\uFEA4"
750         },
751         "khah": {
752           "normal": [
753             "\u062E"
754           ],
755           "isolated": "\uFEA5",
756           "final": "\uFEA6",
757           "initial": "\uFEA7",
758           "medial": "\uFEA8"
759         },
760         "dal": {
761           "normal": [
762             "\u062F"
763           ],
764           "ring": [
765             "\u0689"
766           ],
767           "dot_below": [
768             "\u068A"
769           ],
770           "dot_below_small_tah": [
771             "\u068B"
772           ],
773           "three_dots_above_downwards": [
774             "\u068F"
775           ],
776           "four_dots_above": [
777             "\u0690"
778           ],
779           "inverted_v": [
780             "\u06EE"
781           ],
782           "two_dots_vertically_below_small_tah": [
783             "\u0759"
784           ],
785           "inverted_small_v_below": [
786             "\u075A"
787           ],
788           "three_dots_below": [
789             "\u08AE"
790           ],
791           "isolated": "\uFEA9",
792           "final": "\uFEAA"
793         },
794         "thal": {
795           "normal": [
796             "\u0630"
797           ],
798           "isolated": "\uFEAB",
799           "final": "\uFEAC"
800         },
801         "reh": {
802           "normal": [
803             "\u0631"
804           ],
805           "small_v": [
806             "\u0692"
807           ],
808           "ring": [
809             "\u0693"
810           ],
811           "dot_below": [
812             "\u0694"
813           ],
814           "small_v_below": [
815             "\u0695"
816           ],
817           "dot_below_dot_above": [
818             "\u0696"
819           ],
820           "two_dots_above": [
821             "\u0697"
822           ],
823           "four_dots_above": [
824             "\u0699"
825           ],
826           "inverted_v": [
827             "\u06EF"
828           ],
829           "stroke": [
830             "\u075B"
831           ],
832           "two_dots_vertically_above": [
833             "\u076B"
834           ],
835           "hamza_above": [
836             "\u076C"
837           ],
838           "small_tah_two_dots": [
839             "\u0771"
840           ],
841           "loop": [
842             "\u08AA"
843           ],
844           "small_noon_above": [
845             "\u08B9"
846           ],
847           "isolated": "\uFEAD",
848           "final": "\uFEAE"
849         },
850         "zain": {
851           "normal": [
852             "\u0632"
853           ],
854           "inverted_v_above": [
855             "\u08B2"
856           ],
857           "isolated": "\uFEAF",
858           "final": "\uFEB0"
859         },
860         "seen": {
861           "normal": [
862             "\u0633"
863           ],
864           "dot_below_dot_above": [
865             "\u069A"
866           ],
867           "three_dots_below": [
868             "\u069B"
869           ],
870           "three_dots_below_three_dots_above": [
871             "\u069C"
872           ],
873           "four_dots_above": [
874             "\u075C"
875           ],
876           "two_dots_vertically_above": [
877             "\u076D"
878           ],
879           "small_tah_two_dots": [
880             "\u0770"
881           ],
882           "indic_four_above": [
883             "\u077D"
884           ],
885           "inverted_v": [
886             "\u077E"
887           ],
888           "isolated": "\uFEB1",
889           "final": "\uFEB2",
890           "initial": "\uFEB3",
891           "medial": "\uFEB4"
892         },
893         "sheen": {
894           "normal": [
895             "\u0634"
896           ],
897           "dot_below": [
898             "\u06FA"
899           ],
900           "isolated": "\uFEB5",
901           "final": "\uFEB6",
902           "initial": "\uFEB7",
903           "medial": "\uFEB8"
904         },
905         "sad": {
906           "normal": [
907             "\u0635"
908           ],
909           "two_dots_below": [
910             "\u069D"
911           ],
912           "three_dots_above": [
913             "\u069E"
914           ],
915           "three_dots_below": [
916             "\u08AF"
917           ],
918           "isolated": "\uFEB9",
919           "final": "\uFEBA",
920           "initial": "\uFEBB",
921           "medial": "\uFEBC"
922         },
923         "dad": {
924           "normal": [
925             "\u0636"
926           ],
927           "dot_below": [
928             "\u06FB"
929           ],
930           "isolated": "\uFEBD",
931           "final": "\uFEBE",
932           "initial": "\uFEBF",
933           "medial": "\uFEC0"
934         },
935         "tah": {
936           "normal": [
937             "\u0637"
938           ],
939           "three_dots_above": [
940             "\u069F"
941           ],
942           "two_dots_above": [
943             "\u08A3"
944           ],
945           "isolated": "\uFEC1",
946           "final": "\uFEC2",
947           "initial": "\uFEC3",
948           "medial": "\uFEC4"
949         },
950         "zah": {
951           "normal": [
952             "\u0638"
953           ],
954           "isolated": "\uFEC5",
955           "final": "\uFEC6",
956           "initial": "\uFEC7",
957           "medial": "\uFEC8"
958         },
959         "ain": {
960           "normal": [
961             "\u0639"
962           ],
963           "three_dots_above": [
964             "\u06A0"
965           ],
966           "two_dots_above": [
967             "\u075D"
968           ],
969           "three_dots_pointing_downwards_above": [
970             "\u075E"
971           ],
972           "two_dots_vertically_above": [
973             "\u075F"
974           ],
975           "three_dots_below": [
976             "\u08B3"
977           ],
978           "isolated": "\uFEC9",
979           "final": "\uFECA",
980           "initial": "\uFECB",
981           "medial": "\uFECC"
982         },
983         "ghain": {
984           "normal": [
985             "\u063A"
986           ],
987           "dot_below": [
988             "\u06FC"
989           ],
990           "isolated": "\uFECD",
991           "final": "\uFECE",
992           "initial": "\uFECF",
993           "medial": "\uFED0"
994         },
995         "feh": {
996           "normal": [
997             "\u0641"
998           ],
999           "dotless": [
1000             "\u06A1"
1001           ],
1002           "dot_moved_below": [
1003             "\u06A2"
1004           ],
1005           "dot_below": [
1006             "\u06A3"
1007           ],
1008           "three_dots_below": [
1009             "\u06A5"
1010           ],
1011           "two_dots_below": [
1012             "\u0760"
1013           ],
1014           "three_dots_pointing_upwards_below": [
1015             "\u0761"
1016           ],
1017           "dot_below_three_dots_above": [
1018             "\u08A4"
1019           ],
1020           "isolated": "\uFED1",
1021           "final": "\uFED2",
1022           "initial": "\uFED3",
1023           "medial": "\uFED4"
1024         },
1025         "qaf": {
1026           "normal": [
1027             "\u0642"
1028           ],
1029           "dotless": [
1030             "\u066F"
1031           ],
1032           "dot_above": [
1033             "\u06A7"
1034           ],
1035           "three_dots_above": [
1036             "\u06A8"
1037           ],
1038           "dot_below": [
1039             "\u08A5"
1040           ],
1041           "isolated": "\uFED5",
1042           "final": "\uFED6",
1043           "initial": "\uFED7",
1044           "medial": "\uFED8"
1045         },
1046         "kaf": {
1047           "normal": [
1048             "\u0643"
1049           ],
1050           "swash": [
1051             "\u06AA"
1052           ],
1053           "ring": [
1054             "\u06AB"
1055           ],
1056           "dot_above": [
1057             "\u06AC"
1058           ],
1059           "three_dots_below": [
1060             "\u06AE"
1061           ],
1062           "two_dots_above": [
1063             "\u077F"
1064           ],
1065           "dot_below": [
1066             "\u08B4"
1067           ],
1068           "isolated": "\uFED9",
1069           "final": "\uFEDA",
1070           "initial": "\uFEDB",
1071           "medial": "\uFEDC"
1072         },
1073         "lam": {
1074           "normal": [
1075             "\u0644"
1076           ],
1077           "small_v": [
1078             "\u06B5"
1079           ],
1080           "dot_above": [
1081             "\u06B6"
1082           ],
1083           "three_dots_above": [
1084             "\u06B7"
1085           ],
1086           "three_dots_below": [
1087             "\u06B8"
1088           ],
1089           "bar": [
1090             "\u076A"
1091           ],
1092           "double_bar": [
1093             "\u08A6"
1094           ],
1095           "isolated": "\uFEDD",
1096           "final": "\uFEDE",
1097           "initial": "\uFEDF",
1098           "medial": "\uFEE0"
1099         },
1100         "meem": {
1101           "normal": [
1102             "\u0645"
1103           ],
1104           "dot_above": [
1105             "\u0765"
1106           ],
1107           "dot_below": [
1108             "\u0766"
1109           ],
1110           "three_dots_above": [
1111             "\u08A7"
1112           ],
1113           "isolated": "\uFEE1",
1114           "final": "\uFEE2",
1115           "initial": "\uFEE3",
1116           "medial": "\uFEE4"
1117         },
1118         "noon": {
1119           "normal": [
1120             "\u0646"
1121           ],
1122           "dot_below": [
1123             "\u06B9"
1124           ],
1125           "ring": [
1126             "\u06BC"
1127           ],
1128           "three_dots_above": [
1129             "\u06BD"
1130           ],
1131           "two_dots_below": [
1132             "\u0767"
1133           ],
1134           "small_tah": [
1135             "\u0768"
1136           ],
1137           "small_v": [
1138             "\u0769"
1139           ],
1140           "isolated": "\uFEE5",
1141           "final": "\uFEE6",
1142           "initial": "\uFEE7",
1143           "medial": "\uFEE8"
1144         },
1145         "heh": {
1146           "normal": [
1147             "\u0647"
1148           ],
1149           "isolated": "\uFEE9",
1150           "final": "\uFEEA",
1151           "initial": "\uFEEB",
1152           "medial": "\uFEEC"
1153         },
1154         "waw": {
1155           "normal": [
1156             "\u0648"
1157           ],
1158           "hamza_above": {
1159             "normal": [
1160               "\u0624",
1161               "\u0648\u0654"
1162             ],
1163             "isolated": "\uFE85",
1164             "final": "\uFE86"
1165           },
1166           "high_hamza": [
1167             "\u0676",
1168             "\u0648\u0674"
1169           ],
1170           "ring": [
1171             "\u06C4"
1172           ],
1173           "two_dots_above": [
1174             "\u06CA"
1175           ],
1176           "dot_above": [
1177             "\u06CF"
1178           ],
1179           "indic_two_above": [
1180             "\u0778"
1181           ],
1182           "indic_three_above": [
1183             "\u0779"
1184           ],
1185           "dot_within": [
1186             "\u08AB"
1187           ],
1188           "isolated": "\uFEED",
1189           "final": "\uFEEE"
1190         },
1191         "alef_maksura": {
1192           "normal": [
1193             "\u0649"
1194           ],
1195           "hamza_above": [
1196             "\u0626",
1197             "\u064A\u0654"
1198           ],
1199           "initial": "\uFBE8",
1200           "medial": "\uFBE9",
1201           "isolated": "\uFEEF",
1202           "final": "\uFEF0"
1203         },
1204         "yeh": {
1205           "normal": [
1206             "\u064A"
1207           ],
1208           "hamza_above": {
1209             "normal": [
1210               "\u0626",
1211               "\u0649\u0654"
1212             ],
1213             "isolated": "\uFE89",
1214             "final": "\uFE8A",
1215             "initial": "\uFE8B",
1216             "medial": "\uFE8C"
1217           },
1218           "two_dots_below_hamza_above": [
1219             "\u08A8"
1220           ],
1221           "high_hamza": [
1222             "\u0678",
1223             "\u064A\u0674"
1224           ],
1225           "tail": [
1226             "\u06CD"
1227           ],
1228           "small_v": [
1229             "\u06CE"
1230           ],
1231           "three_dots_below": [
1232             "\u06D1"
1233           ],
1234           "two_dots_below_dot_above": [
1235             "\u08A9"
1236           ],
1237           "two_dots_below_small_noon_above": [
1238             "\u08BA"
1239           ],
1240           "isolated": "\uFEF1",
1241           "final": "\uFEF2",
1242           "initial": "\uFEF3",
1243           "medial": "\uFEF4"
1244         },
1245         "tteh": {
1246           "normal": [
1247             "\u0679"
1248           ],
1249           "isolated": "\uFB66",
1250           "final": "\uFB67",
1251           "initial": "\uFB68",
1252           "medial": "\uFB69"
1253         },
1254         "tteheh": {
1255           "normal": [
1256             "\u067A"
1257           ],
1258           "isolated": "\uFB5E",
1259           "final": "\uFB5F",
1260           "initial": "\uFB60",
1261           "medial": "\uFB61"
1262         },
1263         "beeh": {
1264           "normal": [
1265             "\u067B"
1266           ],
1267           "isolated": "\uFB52",
1268           "final": "\uFB53",
1269           "initial": "\uFB54",
1270           "medial": "\uFB55"
1271         },
1272         "peh": {
1273           "normal": [
1274             "\u067E"
1275           ],
1276           "small_meem_above": [
1277             "\u08B7"
1278           ],
1279           "isolated": "\uFB56",
1280           "final": "\uFB57",
1281           "initial": "\uFB58",
1282           "medial": "\uFB59"
1283         },
1284         "teheh": {
1285           "normal": [
1286             "\u067F"
1287           ],
1288           "isolated": "\uFB62",
1289           "final": "\uFB63",
1290           "initial": "\uFB64",
1291           "medial": "\uFB65"
1292         },
1293         "beheh": {
1294           "normal": [
1295             "\u0680"
1296           ],
1297           "isolated": "\uFB5A",
1298           "final": "\uFB5B",
1299           "initial": "\uFB5C",
1300           "medial": "\uFB5D"
1301         },
1302         "nyeh": {
1303           "normal": [
1304             "\u0683"
1305           ],
1306           "isolated": "\uFB76",
1307           "final": "\uFB77",
1308           "initial": "\uFB78",
1309           "medial": "\uFB79"
1310         },
1311         "dyeh": {
1312           "normal": [
1313             "\u0684"
1314           ],
1315           "isolated": "\uFB72",
1316           "final": "\uFB73",
1317           "initial": "\uFB74",
1318           "medial": "\uFB75"
1319         },
1320         "tcheh": {
1321           "normal": [
1322             "\u0686"
1323           ],
1324           "dot_above": [
1325             "\u06BF"
1326           ],
1327           "isolated": "\uFB7A",
1328           "final": "\uFB7B",
1329           "initial": "\uFB7C",
1330           "medial": "\uFB7D"
1331         },
1332         "tcheheh": {
1333           "normal": [
1334             "\u0687"
1335           ],
1336           "isolated": "\uFB7E",
1337           "final": "\uFB7F",
1338           "initial": "\uFB80",
1339           "medial": "\uFB81"
1340         },
1341         "ddal": {
1342           "normal": [
1343             "\u0688"
1344           ],
1345           "isolated": "\uFB88",
1346           "final": "\uFB89"
1347         },
1348         "dahal": {
1349           "normal": [
1350             "\u068C"
1351           ],
1352           "isolated": "\uFB84",
1353           "final": "\uFB85"
1354         },
1355         "ddahal": {
1356           "normal": [
1357             "\u068D"
1358           ],
1359           "isolated": "\uFB82",
1360           "final": "\uFB83"
1361         },
1362         "dul": {
1363           "normal": [
1364             "\u068F",
1365             "\u068E"
1366           ],
1367           "isolated": "\uFB86",
1368           "final": "\uFB87"
1369         },
1370         "rreh": {
1371           "normal": [
1372             "\u0691"
1373           ],
1374           "isolated": "\uFB8C",
1375           "final": "\uFB8D"
1376         },
1377         "jeh": {
1378           "normal": [
1379             "\u0698"
1380           ],
1381           "isolated": "\uFB8A",
1382           "final": "\uFB8B"
1383         },
1384         "veh": {
1385           "normal": [
1386             "\u06A4"
1387           ],
1388           "isolated": "\uFB6A",
1389           "final": "\uFB6B",
1390           "initial": "\uFB6C",
1391           "medial": "\uFB6D"
1392         },
1393         "peheh": {
1394           "normal": [
1395             "\u06A6"
1396           ],
1397           "isolated": "\uFB6E",
1398           "final": "\uFB6F",
1399           "initial": "\uFB70",
1400           "medial": "\uFB71"
1401         },
1402         "keheh": {
1403           "normal": [
1404             "\u06A9"
1405           ],
1406           "dot_above": [
1407             "\u0762"
1408           ],
1409           "three_dots_above": [
1410             "\u0763"
1411           ],
1412           "three_dots_pointing_upwards_below": [
1413             "\u0764"
1414           ],
1415           "isolated": "\uFB8E",
1416           "final": "\uFB8F",
1417           "initial": "\uFB90",
1418           "medial": "\uFB91"
1419         },
1420         "ng": {
1421           "normal": [
1422             "\u06AD"
1423           ],
1424           "isolated": "\uFBD3",
1425           "final": "\uFBD4",
1426           "initial": "\uFBD5",
1427           "medial": "\uFBD6"
1428         },
1429         "gaf": {
1430           "normal": [
1431             "\u06AF"
1432           ],
1433           "ring": [
1434             "\u06B0"
1435           ],
1436           "two_dots_below": [
1437             "\u06B2"
1438           ],
1439           "three_dots_above": [
1440             "\u06B4"
1441           ],
1442           "inverted_stroke": [
1443             "\u08B0"
1444           ],
1445           "isolated": "\uFB92",
1446           "final": "\uFB93",
1447           "initial": "\uFB94",
1448           "medial": "\uFB95"
1449         },
1450         "ngoeh": {
1451           "normal": [
1452             "\u06B1"
1453           ],
1454           "isolated": "\uFB9A",
1455           "final": "\uFB9B",
1456           "initial": "\uFB9C",
1457           "medial": "\uFB9D"
1458         },
1459         "gueh": {
1460           "normal": [
1461             "\u06B3"
1462           ],
1463           "isolated": "\uFB96",
1464           "final": "\uFB97",
1465           "initial": "\uFB98",
1466           "medial": "\uFB99"
1467         },
1468         "noon ghunna": {
1469           "normal": [
1470             "\u06BA"
1471           ],
1472           "isolated": "\uFB9E",
1473           "final": "\uFB9F"
1474         },
1475         "rnoon": {
1476           "normal": [
1477             "\u06BB"
1478           ],
1479           "isolated": "\uFBA0",
1480           "final": "\uFBA1",
1481           "initial": "\uFBA2",
1482           "medial": "\uFBA3"
1483         },
1484         "heh doachashmee": {
1485           "normal": [
1486             "\u06BE"
1487           ],
1488           "isolated": "\uFBAA",
1489           "final": "\uFBAB",
1490           "initial": "\uFBAC",
1491           "medial": "\uFBAD"
1492         },
1493         "heh goal": {
1494           "normal": [
1495             "\u06C1"
1496           ],
1497           "hamza_above": [
1498             "\u06C1\u0654",
1499             "\u06C2"
1500           ],
1501           "isolated": "\uFBA6",
1502           "final": "\uFBA7",
1503           "initial": "\uFBA8",
1504           "medial": "\uFBA9"
1505         },
1506         "teh marbuta goal": {
1507           "normal": [
1508             "\u06C3"
1509           ]
1510         },
1511         "kirghiz oe": {
1512           "normal": [
1513             "\u06C5"
1514           ],
1515           "isolated": "\uFBE0",
1516           "final": "\uFBE1"
1517         },
1518         "oe": {
1519           "normal": [
1520             "\u06C6"
1521           ],
1522           "isolated": "\uFBD9",
1523           "final": "\uFBDA"
1524         },
1525         "u": {
1526           "normal": [
1527             "\u06C7"
1528           ],
1529           "hamza_above": {
1530             "normal": [
1531               "\u0677",
1532               "\u06C7\u0674"
1533             ],
1534             "isolated": "\uFBDD"
1535           },
1536           "isolated": "\uFBD7",
1537           "final": "\uFBD8"
1538         },
1539         "yu": {
1540           "normal": [
1541             "\u06C8"
1542           ],
1543           "isolated": "\uFBDB",
1544           "final": "\uFBDC"
1545         },
1546         "kirghiz yu": {
1547           "normal": [
1548             "\u06C9"
1549           ],
1550           "isolated": "\uFBE2",
1551           "final": "\uFBE3"
1552         },
1553         "ve": {
1554           "normal": [
1555             "\u06CB"
1556           ],
1557           "isolated": "\uFBDE",
1558           "final": "\uFBDF"
1559         },
1560         "farsi yeh": {
1561           "normal": [
1562             "\u06CC"
1563           ],
1564           "indic_two_above": [
1565             "\u0775"
1566           ],
1567           "indic_three_above": [
1568             "\u0776"
1569           ],
1570           "indic_four_above": [
1571             "\u0777"
1572           ],
1573           "isolated": "\uFBFC",
1574           "final": "\uFBFD",
1575           "initial": "\uFBFE",
1576           "medial": "\uFBFF"
1577         },
1578         "e": {
1579           "normal": [
1580             "\u06D0"
1581           ],
1582           "isolated": "\uFBE4",
1583           "final": "\uFBE5",
1584           "initial": "\uFBE6",
1585           "medial": "\uFBE7"
1586         },
1587         "yeh barree": {
1588           "normal": [
1589             "\u06D2"
1590           ],
1591           "hamza_above": {
1592             "normal": [
1593               "\u06D2\u0654",
1594               "\u06D3"
1595             ],
1596             "isolated": "\uFBB0",
1597             "final": "\uFBB1"
1598           },
1599           "indic_two_above": [
1600             "\u077A"
1601           ],
1602           "indic_three_above": [
1603             "\u077B"
1604           ],
1605           "isolated": "\uFBAE",
1606           "final": "\uFBAF"
1607         },
1608         "ae": {
1609           "normal": [
1610             "\u06D5"
1611           ],
1612           "isolated": "\u06D5",
1613           "final": "\uFEEA",
1614           "yeh_above": {
1615             "normal": [
1616               "\u06C0",
1617               "\u06D5\u0654"
1618             ],
1619             "isolated": "\uFBA4",
1620             "final": "\uFBA5"
1621           }
1622         },
1623         "rohingya yeh": {
1624           "normal": [
1625             "\u08AC"
1626           ]
1627         },
1628         "low alef": {
1629           "normal": [
1630             "\u08AD"
1631           ]
1632         },
1633         "straight waw": {
1634           "normal": [
1635             "\u08B1"
1636           ]
1637         },
1638         "african feh": {
1639           "normal": [
1640             "\u08BB"
1641           ]
1642         },
1643         "african qaf": {
1644           "normal": [
1645             "\u08BC"
1646           ]
1647         },
1648         "african noon": {
1649           "normal": [
1650             "\u08BD"
1651           ]
1652         }
1653       };
1654       exports2.default = arabicReference;
1655     }
1656   });
1657
1658   // node_modules/alif-toolkit/lib/unicode-ligatures.js
1659   var require_unicode_ligatures = __commonJS({
1660     "node_modules/alif-toolkit/lib/unicode-ligatures.js"(exports2) {
1661       "use strict";
1662       Object.defineProperty(exports2, "__esModule", { value: true });
1663       var ligatureReference = {
1664         "\u0626\u0627": {
1665           "isolated": "\uFBEA",
1666           "final": "\uFBEB"
1667         },
1668         "\u0626\u06D5": {
1669           "isolated": "\uFBEC",
1670           "final": "\uFBED"
1671         },
1672         "\u0626\u0648": {
1673           "isolated": "\uFBEE",
1674           "final": "\uFBEF"
1675         },
1676         "\u0626\u06C7": {
1677           "isolated": "\uFBF0",
1678           "final": "\uFBF1"
1679         },
1680         "\u0626\u06C6": {
1681           "isolated": "\uFBF2",
1682           "final": "\uFBF3"
1683         },
1684         "\u0626\u06C8": {
1685           "isolated": "\uFBF4",
1686           "final": "\uFBF5"
1687         },
1688         "\u0626\u06D0": {
1689           "isolated": "\uFBF6",
1690           "final": "\uFBF7",
1691           "initial": "\uFBF8"
1692         },
1693         "\u0626\u0649": {
1694           "uighur_kirghiz": {
1695             "isolated": "\uFBF9",
1696             "final": "\uFBFA",
1697             "initial": "\uFBFB"
1698           },
1699           "isolated": "\uFC03",
1700           "final": "\uFC68"
1701         },
1702         "\u0626\u062C": {
1703           "isolated": "\uFC00",
1704           "initial": "\uFC97"
1705         },
1706         "\u0626\u062D": {
1707           "isolated": "\uFC01",
1708           "initial": "\uFC98"
1709         },
1710         "\u0626\u0645": {
1711           "isolated": "\uFC02",
1712           "final": "\uFC66",
1713           "initial": "\uFC9A",
1714           "medial": "\uFCDF"
1715         },
1716         "\u0626\u064A": {
1717           "isolated": "\uFC04",
1718           "final": "\uFC69"
1719         },
1720         "\u0628\u062C": {
1721           "isolated": "\uFC05",
1722           "initial": "\uFC9C"
1723         },
1724         "\u0628\u062D": {
1725           "isolated": "\uFC06",
1726           "initial": "\uFC9D"
1727         },
1728         "\u0628\u062E": {
1729           "isolated": "\uFC07",
1730           "initial": "\uFC9E"
1731         },
1732         "\u0628\u0645": {
1733           "isolated": "\uFC08",
1734           "final": "\uFC6C",
1735           "initial": "\uFC9F",
1736           "medial": "\uFCE1"
1737         },
1738         "\u0628\u0649": {
1739           "isolated": "\uFC09",
1740           "final": "\uFC6E"
1741         },
1742         "\u0628\u064A": {
1743           "isolated": "\uFC0A",
1744           "final": "\uFC6F"
1745         },
1746         "\u062A\u062C": {
1747           "isolated": "\uFC0B",
1748           "initial": "\uFCA1"
1749         },
1750         "\u062A\u062D": {
1751           "isolated": "\uFC0C",
1752           "initial": "\uFCA2"
1753         },
1754         "\u062A\u062E": {
1755           "isolated": "\uFC0D",
1756           "initial": "\uFCA3"
1757         },
1758         "\u062A\u0645": {
1759           "isolated": "\uFC0E",
1760           "final": "\uFC72",
1761           "initial": "\uFCA4",
1762           "medial": "\uFCE3"
1763         },
1764         "\u062A\u0649": {
1765           "isolated": "\uFC0F",
1766           "final": "\uFC74"
1767         },
1768         "\u062A\u064A": {
1769           "isolated": "\uFC10",
1770           "final": "\uFC75"
1771         },
1772         "\u062B\u062C": {
1773           "isolated": "\uFC11"
1774         },
1775         "\u062B\u0645": {
1776           "isolated": "\uFC12",
1777           "final": "\uFC78",
1778           "initial": "\uFCA6",
1779           "medial": "\uFCE5"
1780         },
1781         "\u062B\u0649": {
1782           "isolated": "\uFC13",
1783           "final": "\uFC7A"
1784         },
1785         "\u062B\u0648": {
1786           "isolated": "\uFC14"
1787         },
1788         "\u062C\u062D": {
1789           "isolated": "\uFC15",
1790           "initial": "\uFCA7"
1791         },
1792         "\u062C\u0645": {
1793           "isolated": "\uFC16",
1794           "initial": "\uFCA8"
1795         },
1796         "\u062D\u062C": {
1797           "isolated": "\uFC17",
1798           "initial": "\uFCA9"
1799         },
1800         "\u062D\u0645": {
1801           "isolated": "\uFC18",
1802           "initial": "\uFCAA"
1803         },
1804         "\u062E\u062C": {
1805           "isolated": "\uFC19",
1806           "initial": "\uFCAB"
1807         },
1808         "\u062E\u062D": {
1809           "isolated": "\uFC1A"
1810         },
1811         "\u062E\u0645": {
1812           "isolated": "\uFC1B",
1813           "initial": "\uFCAC"
1814         },
1815         "\u0633\u062C": {
1816           "isolated": "\uFC1C",
1817           "initial": "\uFCAD",
1818           "medial": "\uFD34"
1819         },
1820         "\u0633\u062D": {
1821           "isolated": "\uFC1D",
1822           "initial": "\uFCAE",
1823           "medial": "\uFD35"
1824         },
1825         "\u0633\u062E": {
1826           "isolated": "\uFC1E",
1827           "initial": "\uFCAF",
1828           "medial": "\uFD36"
1829         },
1830         "\u0633\u0645": {
1831           "isolated": "\uFC1F",
1832           "initial": "\uFCB0",
1833           "medial": "\uFCE7"
1834         },
1835         "\u0635\u062D": {
1836           "isolated": "\uFC20",
1837           "initial": "\uFCB1"
1838         },
1839         "\u0635\u0645": {
1840           "isolated": "\uFC21",
1841           "initial": "\uFCB3"
1842         },
1843         "\u0636\u062C": {
1844           "isolated": "\uFC22",
1845           "initial": "\uFCB4"
1846         },
1847         "\u0636\u062D": {
1848           "isolated": "\uFC23",
1849           "initial": "\uFCB5"
1850         },
1851         "\u0636\u062E": {
1852           "isolated": "\uFC24",
1853           "initial": "\uFCB6"
1854         },
1855         "\u0636\u0645": {
1856           "isolated": "\uFC25",
1857           "initial": "\uFCB7"
1858         },
1859         "\u0637\u062D": {
1860           "isolated": "\uFC26",
1861           "initial": "\uFCB8"
1862         },
1863         "\u0637\u0645": {
1864           "isolated": "\uFC27",
1865           "initial": "\uFD33",
1866           "medial": "\uFD3A"
1867         },
1868         "\u0638\u0645": {
1869           "isolated": "\uFC28",
1870           "initial": "\uFCB9",
1871           "medial": "\uFD3B"
1872         },
1873         "\u0639\u062C": {
1874           "isolated": "\uFC29",
1875           "initial": "\uFCBA"
1876         },
1877         "\u0639\u0645": {
1878           "isolated": "\uFC2A",
1879           "initial": "\uFCBB"
1880         },
1881         "\u063A\u062C": {
1882           "isolated": "\uFC2B",
1883           "initial": "\uFCBC"
1884         },
1885         "\u063A\u0645": {
1886           "isolated": "\uFC2C",
1887           "initial": "\uFCBD"
1888         },
1889         "\u0641\u062C": {
1890           "isolated": "\uFC2D",
1891           "initial": "\uFCBE"
1892         },
1893         "\u0641\u062D": {
1894           "isolated": "\uFC2E",
1895           "initial": "\uFCBF"
1896         },
1897         "\u0641\u062E": {
1898           "isolated": "\uFC2F",
1899           "initial": "\uFCC0"
1900         },
1901         "\u0641\u0645": {
1902           "isolated": "\uFC30",
1903           "initial": "\uFCC1"
1904         },
1905         "\u0641\u0649": {
1906           "isolated": "\uFC31",
1907           "final": "\uFC7C"
1908         },
1909         "\u0641\u064A": {
1910           "isolated": "\uFC32",
1911           "final": "\uFC7D"
1912         },
1913         "\u0642\u062D": {
1914           "isolated": "\uFC33",
1915           "initial": "\uFCC2"
1916         },
1917         "\u0642\u0645": {
1918           "isolated": "\uFC34",
1919           "initial": "\uFCC3"
1920         },
1921         "\u0642\u0649": {
1922           "isolated": "\uFC35",
1923           "final": "\uFC7E"
1924         },
1925         "\u0642\u064A": {
1926           "isolated": "\uFC36",
1927           "final": "\uFC7F"
1928         },
1929         "\u0643\u0627": {
1930           "isolated": "\uFC37",
1931           "final": "\uFC80"
1932         },
1933         "\u0643\u062C": {
1934           "isolated": "\uFC38",
1935           "initial": "\uFCC4"
1936         },
1937         "\u0643\u062D": {
1938           "isolated": "\uFC39",
1939           "initial": "\uFCC5"
1940         },
1941         "\u0643\u062E": {
1942           "isolated": "\uFC3A",
1943           "initial": "\uFCC6"
1944         },
1945         "\u0643\u0644": {
1946           "isolated": "\uFC3B",
1947           "final": "\uFC81",
1948           "initial": "\uFCC7",
1949           "medial": "\uFCEB"
1950         },
1951         "\u0643\u0645": {
1952           "isolated": "\uFC3C",
1953           "final": "\uFC82",
1954           "initial": "\uFCC8",
1955           "medial": "\uFCEC"
1956         },
1957         "\u0643\u0649": {
1958           "isolated": "\uFC3D",
1959           "final": "\uFC83"
1960         },
1961         "\u0643\u064A": {
1962           "isolated": "\uFC3E",
1963           "final": "\uFC84"
1964         },
1965         "\u0644\u062C": {
1966           "isolated": "\uFC3F",
1967           "initial": "\uFCC9"
1968         },
1969         "\u0644\u062D": {
1970           "isolated": "\uFC40",
1971           "initial": "\uFCCA"
1972         },
1973         "\u0644\u062E": {
1974           "isolated": "\uFC41",
1975           "initial": "\uFCCB"
1976         },
1977         "\u0644\u0645": {
1978           "isolated": "\uFC42",
1979           "final": "\uFC85",
1980           "initial": "\uFCCC",
1981           "medial": "\uFCED"
1982         },
1983         "\u0644\u0649": {
1984           "isolated": "\uFC43",
1985           "final": "\uFC86"
1986         },
1987         "\u0644\u064A": {
1988           "isolated": "\uFC44",
1989           "final": "\uFC87"
1990         },
1991         "\u0645\u062C": {
1992           "isolated": "\uFC45",
1993           "initial": "\uFCCE"
1994         },
1995         "\u0645\u062D": {
1996           "isolated": "\uFC46",
1997           "initial": "\uFCCF"
1998         },
1999         "\u0645\u062E": {
2000           "isolated": "\uFC47",
2001           "initial": "\uFCD0"
2002         },
2003         "\u0645\u0645": {
2004           "isolated": "\uFC48",
2005           "final": "\uFC89",
2006           "initial": "\uFCD1"
2007         },
2008         "\u0645\u0649": {
2009           "isolated": "\uFC49"
2010         },
2011         "\u0645\u064A": {
2012           "isolated": "\uFC4A"
2013         },
2014         "\u0646\u062C": {
2015           "isolated": "\uFC4B",
2016           "initial": "\uFCD2"
2017         },
2018         "\u0646\u062D": {
2019           "isolated": "\uFC4C",
2020           "initial": "\uFCD3"
2021         },
2022         "\u0646\u062E": {
2023           "isolated": "\uFC4D",
2024           "initial": "\uFCD4"
2025         },
2026         "\u0646\u0645": {
2027           "isolated": "\uFC4E",
2028           "final": "\uFC8C",
2029           "initial": "\uFCD5",
2030           "medial": "\uFCEE"
2031         },
2032         "\u0646\u0649": {
2033           "isolated": "\uFC4F",
2034           "final": "\uFC8E"
2035         },
2036         "\u0646\u064A": {
2037           "isolated": "\uFC50",
2038           "final": "\uFC8F"
2039         },
2040         "\u0647\u062C": {
2041           "isolated": "\uFC51",
2042           "initial": "\uFCD7"
2043         },
2044         "\u0647\u0645": {
2045           "isolated": "\uFC52",
2046           "initial": "\uFCD8"
2047         },
2048         "\u0647\u0649": {
2049           "isolated": "\uFC53"
2050         },
2051         "\u0647\u064A": {
2052           "isolated": "\uFC54"
2053         },
2054         "\u064A\u062C": {
2055           "isolated": "\uFC55",
2056           "initial": "\uFCDA"
2057         },
2058         "\u064A\u062D": {
2059           "isolated": "\uFC56",
2060           "initial": "\uFCDB"
2061         },
2062         "\u064A\u062E": {
2063           "isolated": "\uFC57",
2064           "initial": "\uFCDC"
2065         },
2066         "\u064A\u0645": {
2067           "isolated": "\uFC58",
2068           "final": "\uFC93",
2069           "initial": "\uFCDD",
2070           "medial": "\uFCF0"
2071         },
2072         "\u064A\u0649": {
2073           "isolated": "\uFC59",
2074           "final": "\uFC95"
2075         },
2076         "\u064A\u064A": {
2077           "isolated": "\uFC5A",
2078           "final": "\uFC96"
2079         },
2080         "\u0630\u0670": {
2081           "isolated": "\uFC5B"
2082         },
2083         "\u0631\u0670": {
2084           "isolated": "\uFC5C"
2085         },
2086         "\u0649\u0670": {
2087           "isolated": "\uFC5D",
2088           "final": "\uFC90"
2089         },
2090         "\u064C\u0651": {
2091           "isolated": "\uFC5E"
2092         },
2093         "\u064D\u0651": {
2094           "isolated": "\uFC5F"
2095         },
2096         "\u064E\u0651": {
2097           "isolated": "\uFC60"
2098         },
2099         "\u064F\u0651": {
2100           "isolated": "\uFC61"
2101         },
2102         "\u0650\u0651": {
2103           "isolated": "\uFC62"
2104         },
2105         "\u0651\u0670": {
2106           "isolated": "\uFC63"
2107         },
2108         "\u0626\u0631": {
2109           "final": "\uFC64"
2110         },
2111         "\u0626\u0632": {
2112           "final": "\uFC65"
2113         },
2114         "\u0626\u0646": {
2115           "final": "\uFC67"
2116         },
2117         "\u0628\u0631": {
2118           "final": "\uFC6A"
2119         },
2120         "\u0628\u0632": {
2121           "final": "\uFC6B"
2122         },
2123         "\u0628\u0646": {
2124           "final": "\uFC6D"
2125         },
2126         "\u062A\u0631": {
2127           "final": "\uFC70"
2128         },
2129         "\u062A\u0632": {
2130           "final": "\uFC71"
2131         },
2132         "\u062A\u0646": {
2133           "final": "\uFC73"
2134         },
2135         "\u062B\u0631": {
2136           "final": "\uFC76"
2137         },
2138         "\u062B\u0632": {
2139           "final": "\uFC77"
2140         },
2141         "\u062B\u0646": {
2142           "final": "\uFC79"
2143         },
2144         "\u062B\u064A": {
2145           "final": "\uFC7B"
2146         },
2147         "\u0645\u0627": {
2148           "final": "\uFC88"
2149         },
2150         "\u0646\u0631": {
2151           "final": "\uFC8A"
2152         },
2153         "\u0646\u0632": {
2154           "final": "\uFC8B"
2155         },
2156         "\u0646\u0646": {
2157           "final": "\uFC8D"
2158         },
2159         "\u064A\u0631": {
2160           "final": "\uFC91"
2161         },
2162         "\u064A\u0632": {
2163           "final": "\uFC92"
2164         },
2165         "\u064A\u0646": {
2166           "final": "\uFC94"
2167         },
2168         "\u0626\u062E": {
2169           "initial": "\uFC99"
2170         },
2171         "\u0626\u0647": {
2172           "initial": "\uFC9B",
2173           "medial": "\uFCE0"
2174         },
2175         "\u0628\u0647": {
2176           "initial": "\uFCA0",
2177           "medial": "\uFCE2"
2178         },
2179         "\u062A\u0647": {
2180           "initial": "\uFCA5",
2181           "medial": "\uFCE4"
2182         },
2183         "\u0635\u062E": {
2184           "initial": "\uFCB2"
2185         },
2186         "\u0644\u0647": {
2187           "initial": "\uFCCD"
2188         },
2189         "\u0646\u0647": {
2190           "initial": "\uFCD6",
2191           "medial": "\uFCEF"
2192         },
2193         "\u0647\u0670": {
2194           "initial": "\uFCD9"
2195         },
2196         "\u064A\u0647": {
2197           "initial": "\uFCDE",
2198           "medial": "\uFCF1"
2199         },
2200         "\u062B\u0647": {
2201           "medial": "\uFCE6"
2202         },
2203         "\u0633\u0647": {
2204           "medial": "\uFCE8",
2205           "initial": "\uFD31"
2206         },
2207         "\u0634\u0645": {
2208           "medial": "\uFCE9",
2209           "isolated": "\uFD0C",
2210           "final": "\uFD28",
2211           "initial": "\uFD30"
2212         },
2213         "\u0634\u0647": {
2214           "medial": "\uFCEA",
2215           "initial": "\uFD32"
2216         },
2217         "\u0640\u064E\u0651": {
2218           "medial": "\uFCF2"
2219         },
2220         "\u0640\u064F\u0651": {
2221           "medial": "\uFCF3"
2222         },
2223         "\u0640\u0650\u0651": {
2224           "medial": "\uFCF4"
2225         },
2226         "\u0637\u0649": {
2227           "isolated": "\uFCF5",
2228           "final": "\uFD11"
2229         },
2230         "\u0637\u064A": {
2231           "isolated": "\uFCF6",
2232           "final": "\uFD12"
2233         },
2234         "\u0639\u0649": {
2235           "isolated": "\uFCF7",
2236           "final": "\uFD13"
2237         },
2238         "\u0639\u064A": {
2239           "isolated": "\uFCF8",
2240           "final": "\uFD14"
2241         },
2242         "\u063A\u0649": {
2243           "isolated": "\uFCF9",
2244           "final": "\uFD15"
2245         },
2246         "\u063A\u064A": {
2247           "isolated": "\uFCFA",
2248           "final": "\uFD16"
2249         },
2250         "\u0633\u0649": {
2251           "isolated": "\uFCFB"
2252         },
2253         "\u0633\u064A": {
2254           "isolated": "\uFCFC",
2255           "final": "\uFD18"
2256         },
2257         "\u0634\u0649": {
2258           "isolated": "\uFCFD",
2259           "final": "\uFD19"
2260         },
2261         "\u0634\u064A": {
2262           "isolated": "\uFCFE",
2263           "final": "\uFD1A"
2264         },
2265         "\u062D\u0649": {
2266           "isolated": "\uFCFF",
2267           "final": "\uFD1B"
2268         },
2269         "\u062D\u064A": {
2270           "isolated": "\uFD00",
2271           "final": "\uFD1C"
2272         },
2273         "\u062C\u0649": {
2274           "isolated": "\uFD01",
2275           "final": "\uFD1D"
2276         },
2277         "\u062C\u064A": {
2278           "isolated": "\uFD02",
2279           "final": "\uFD1E"
2280         },
2281         "\u062E\u0649": {
2282           "isolated": "\uFD03",
2283           "final": "\uFD1F"
2284         },
2285         "\u062E\u064A": {
2286           "isolated": "\uFD04",
2287           "final": "\uFD20"
2288         },
2289         "\u0635\u0649": {
2290           "isolated": "\uFD05",
2291           "final": "\uFD21"
2292         },
2293         "\u0635\u064A": {
2294           "isolated": "\uFD06",
2295           "final": "\uFD22"
2296         },
2297         "\u0636\u0649": {
2298           "isolated": "\uFD07",
2299           "final": "\uFD23"
2300         },
2301         "\u0636\u064A": {
2302           "isolated": "\uFD08",
2303           "final": "\uFD24"
2304         },
2305         "\u0634\u062C": {
2306           "isolated": "\uFD09",
2307           "final": "\uFD25",
2308           "initial": "\uFD2D",
2309           "medial": "\uFD37"
2310         },
2311         "\u0634\u062D": {
2312           "isolated": "\uFD0A",
2313           "final": "\uFD26",
2314           "initial": "\uFD2E",
2315           "medial": "\uFD38"
2316         },
2317         "\u0634\u062E": {
2318           "isolated": "\uFD0B",
2319           "final": "\uFD27",
2320           "initial": "\uFD2F",
2321           "medial": "\uFD39"
2322         },
2323         "\u0634\u0631": {
2324           "isolated": "\uFD0D",
2325           "final": "\uFD29"
2326         },
2327         "\u0633\u0631": {
2328           "isolated": "\uFD0E",
2329           "final": "\uFD2A"
2330         },
2331         "\u0635\u0631": {
2332           "isolated": "\uFD0F",
2333           "final": "\uFD2B"
2334         },
2335         "\u0636\u0631": {
2336           "isolated": "\uFD10",
2337           "final": "\uFD2C"
2338         },
2339         "\u0633\u0639": {
2340           "final": "\uFD17"
2341         },
2342         "\u062A\u062C\u0645": {
2343           "initial": "\uFD50"
2344         },
2345         "\u062A\u062D\u062C": {
2346           "final": "\uFD51",
2347           "initial": "\uFD52"
2348         },
2349         "\u062A\u062D\u0645": {
2350           "initial": "\uFD53"
2351         },
2352         "\u062A\u062E\u0645": {
2353           "initial": "\uFD54"
2354         },
2355         "\u062A\u0645\u062C": {
2356           "initial": "\uFD55"
2357         },
2358         "\u062A\u0645\u062D": {
2359           "initial": "\uFD56"
2360         },
2361         "\u062A\u0645\u062E": {
2362           "initial": "\uFD57"
2363         },
2364         "\u062C\u0645\u062D": {
2365           "final": "\uFD58",
2366           "initial": "\uFD59"
2367         },
2368         "\u062D\u0645\u064A": {
2369           "final": "\uFD5A"
2370         },
2371         "\u062D\u0645\u0649": {
2372           "final": "\uFD5B"
2373         },
2374         "\u0633\u062D\u062C": {
2375           "initial": "\uFD5C"
2376         },
2377         "\u0633\u062C\u062D": {
2378           "initial": "\uFD5D"
2379         },
2380         "\u0633\u062C\u0649": {
2381           "final": "\uFD5E"
2382         },
2383         "\u0633\u0645\u062D": {
2384           "final": "\uFD5F",
2385           "initial": "\uFD60"
2386         },
2387         "\u0633\u0645\u062C": {
2388           "initial": "\uFD61"
2389         },
2390         "\u0633\u0645\u0645": {
2391           "final": "\uFD62",
2392           "initial": "\uFD63"
2393         },
2394         "\u0635\u062D\u062D": {
2395           "final": "\uFD64",
2396           "initial": "\uFD65"
2397         },
2398         "\u0635\u0645\u0645": {
2399           "final": "\uFD66",
2400           "initial": "\uFDC5"
2401         },
2402         "\u0634\u062D\u0645": {
2403           "final": "\uFD67",
2404           "initial": "\uFD68"
2405         },
2406         "\u0634\u062C\u064A": {
2407           "final": "\uFD69"
2408         },
2409         "\u0634\u0645\u062E": {
2410           "final": "\uFD6A",
2411           "initial": "\uFD6B"
2412         },
2413         "\u0634\u0645\u0645": {
2414           "final": "\uFD6C",
2415           "initial": "\uFD6D"
2416         },
2417         "\u0636\u062D\u0649": {
2418           "final": "\uFD6E"
2419         },
2420         "\u0636\u062E\u0645": {
2421           "final": "\uFD6F",
2422           "initial": "\uFD70"
2423         },
2424         "\u0636\u0645\u062D": {
2425           "final": "\uFD71"
2426         },
2427         "\u0637\u0645\u062D": {
2428           "initial": "\uFD72"
2429         },
2430         "\u0637\u0645\u0645": {
2431           "initial": "\uFD73"
2432         },
2433         "\u0637\u0645\u064A": {
2434           "final": "\uFD74"
2435         },
2436         "\u0639\u062C\u0645": {
2437           "final": "\uFD75",
2438           "initial": "\uFDC4"
2439         },
2440         "\u0639\u0645\u0645": {
2441           "final": "\uFD76",
2442           "initial": "\uFD77"
2443         },
2444         "\u0639\u0645\u0649": {
2445           "final": "\uFD78"
2446         },
2447         "\u063A\u0645\u0645": {
2448           "final": "\uFD79"
2449         },
2450         "\u063A\u0645\u064A": {
2451           "final": "\uFD7A"
2452         },
2453         "\u063A\u0645\u0649": {
2454           "final": "\uFD7B"
2455         },
2456         "\u0641\u062E\u0645": {
2457           "final": "\uFD7C",
2458           "initial": "\uFD7D"
2459         },
2460         "\u0642\u0645\u062D": {
2461           "final": "\uFD7E",
2462           "initial": "\uFDB4"
2463         },
2464         "\u0642\u0645\u0645": {
2465           "final": "\uFD7F"
2466         },
2467         "\u0644\u062D\u0645": {
2468           "final": "\uFD80",
2469           "initial": "\uFDB5"
2470         },
2471         "\u0644\u062D\u064A": {
2472           "final": "\uFD81"
2473         },
2474         "\u0644\u062D\u0649": {
2475           "final": "\uFD82"
2476         },
2477         "\u0644\u062C\u062C": {
2478           "initial": "\uFD83",
2479           "final": "\uFD84"
2480         },
2481         "\u0644\u062E\u0645": {
2482           "final": "\uFD85",
2483           "initial": "\uFD86"
2484         },
2485         "\u0644\u0645\u062D": {
2486           "final": "\uFD87",
2487           "initial": "\uFD88"
2488         },
2489         "\u0645\u062D\u062C": {
2490           "initial": "\uFD89"
2491         },
2492         "\u0645\u062D\u0645": {
2493           "initial": "\uFD8A"
2494         },
2495         "\u0645\u062D\u064A": {
2496           "final": "\uFD8B"
2497         },
2498         "\u0645\u062C\u062D": {
2499           "initial": "\uFD8C"
2500         },
2501         "\u0645\u062C\u0645": {
2502           "initial": "\uFD8D"
2503         },
2504         "\u0645\u062E\u062C": {
2505           "initial": "\uFD8E"
2506         },
2507         "\u0645\u062E\u0645": {
2508           "initial": "\uFD8F"
2509         },
2510         "\u0645\u062C\u062E": {
2511           "initial": "\uFD92"
2512         },
2513         "\u0647\u0645\u062C": {
2514           "initial": "\uFD93"
2515         },
2516         "\u0647\u0645\u0645": {
2517           "initial": "\uFD94"
2518         },
2519         "\u0646\u062D\u0645": {
2520           "initial": "\uFD95"
2521         },
2522         "\u0646\u062D\u0649": {
2523           "final": "\uFD96"
2524         },
2525         "\u0646\u062C\u0645": {
2526           "final": "\uFD97",
2527           "initial": "\uFD98"
2528         },
2529         "\u0646\u062C\u0649": {
2530           "final": "\uFD99"
2531         },
2532         "\u0646\u0645\u064A": {
2533           "final": "\uFD9A"
2534         },
2535         "\u0646\u0645\u0649": {
2536           "final": "\uFD9B"
2537         },
2538         "\u064A\u0645\u0645": {
2539           "final": "\uFD9C",
2540           "initial": "\uFD9D"
2541         },
2542         "\u0628\u062E\u064A": {
2543           "final": "\uFD9E"
2544         },
2545         "\u062A\u062C\u064A": {
2546           "final": "\uFD9F"
2547         },
2548         "\u062A\u062C\u0649": {
2549           "final": "\uFDA0"
2550         },
2551         "\u062A\u062E\u064A": {
2552           "final": "\uFDA1"
2553         },
2554         "\u062A\u062E\u0649": {
2555           "final": "\uFDA2"
2556         },
2557         "\u062A\u0645\u064A": {
2558           "final": "\uFDA3"
2559         },
2560         "\u062A\u0645\u0649": {
2561           "final": "\uFDA4"
2562         },
2563         "\u062C\u0645\u064A": {
2564           "final": "\uFDA5"
2565         },
2566         "\u062C\u062D\u0649": {
2567           "final": "\uFDA6"
2568         },
2569         "\u062C\u0645\u0649": {
2570           "final": "\uFDA7"
2571         },
2572         "\u0633\u062E\u0649": {
2573           "final": "\uFDA8"
2574         },
2575         "\u0635\u062D\u064A": {
2576           "final": "\uFDA9"
2577         },
2578         "\u0634\u062D\u064A": {
2579           "final": "\uFDAA"
2580         },
2581         "\u0636\u062D\u064A": {
2582           "final": "\uFDAB"
2583         },
2584         "\u0644\u062C\u064A": {
2585           "final": "\uFDAC"
2586         },
2587         "\u0644\u0645\u064A": {
2588           "final": "\uFDAD"
2589         },
2590         "\u064A\u062D\u064A": {
2591           "final": "\uFDAE"
2592         },
2593         "\u064A\u062C\u064A": {
2594           "final": "\uFDAF"
2595         },
2596         "\u064A\u0645\u064A": {
2597           "final": "\uFDB0"
2598         },
2599         "\u0645\u0645\u064A": {
2600           "final": "\uFDB1"
2601         },
2602         "\u0642\u0645\u064A": {
2603           "final": "\uFDB2"
2604         },
2605         "\u0646\u062D\u064A": {
2606           "final": "\uFDB3"
2607         },
2608         "\u0639\u0645\u064A": {
2609           "final": "\uFDB6"
2610         },
2611         "\u0643\u0645\u064A": {
2612           "final": "\uFDB7"
2613         },
2614         "\u0646\u062C\u062D": {
2615           "initial": "\uFDB8",
2616           "final": "\uFDBD"
2617         },
2618         "\u0645\u062E\u064A": {
2619           "final": "\uFDB9"
2620         },
2621         "\u0644\u062C\u0645": {
2622           "initial": "\uFDBA",
2623           "final": "\uFDBC"
2624         },
2625         "\u0643\u0645\u0645": {
2626           "final": "\uFDBB",
2627           "initial": "\uFDC3"
2628         },
2629         "\u062C\u062D\u064A": {
2630           "final": "\uFDBE"
2631         },
2632         "\u062D\u062C\u064A": {
2633           "final": "\uFDBF"
2634         },
2635         "\u0645\u062C\u064A": {
2636           "final": "\uFDC0"
2637         },
2638         "\u0641\u0645\u064A": {
2639           "final": "\uFDC1"
2640         },
2641         "\u0628\u062D\u064A": {
2642           "final": "\uFDC2"
2643         },
2644         "\u0633\u062E\u064A": {
2645           "final": "\uFDC6"
2646         },
2647         "\u0646\u062C\u064A": {
2648           "final": "\uFDC7"
2649         },
2650         "\u0644\u0622": {
2651           "isolated": "\uFEF5",
2652           "final": "\uFEF6"
2653         },
2654         "\u0644\u0623": {
2655           "isolated": "\uFEF7",
2656           "final": "\uFEF8"
2657         },
2658         "\u0644\u0625": {
2659           "isolated": "\uFEF9",
2660           "final": "\uFEFA"
2661         },
2662         "\u0644\u0627": {
2663           "isolated": "\uFEFB",
2664           "final": "\uFEFC"
2665         },
2666         "words": {
2667           "\u0635\u0644\u06D2": "\uFDF0",
2668           "\u0642\u0644\u06D2": "\uFDF1",
2669           "\u0627\u0644\u0644\u0647": "\uFDF2",
2670           "\u0627\u0643\u0628\u0631": "\uFDF3",
2671           "\u0645\u062D\u0645\u062F": "\uFDF4",
2672           "\u0635\u0644\u0639\u0645": "\uFDF5",
2673           "\u0631\u0633\u0648\u0644": "\uFDF6",
2674           "\u0639\u0644\u064A\u0647": "\uFDF7",
2675           "\u0648\u0633\u0644\u0645": "\uFDF8",
2676           "\u0635\u0644\u0649": "\uFDF9",
2677           "\u0635\u0644\u0649\u0627\u0644\u0644\u0647\u0639\u0644\u064A\u0647\u0648\u0633\u0644\u0645": "\uFDFA",
2678           "\u062C\u0644\u062C\u0644\u0627\u0644\u0647": "\uFDFB",
2679           "\u0631\u06CC\u0627\u0644": "\uFDFC"
2680         }
2681       };
2682       exports2.default = ligatureReference;
2683     }
2684   });
2685
2686   // node_modules/alif-toolkit/lib/reference.js
2687   var require_reference = __commonJS({
2688     "node_modules/alif-toolkit/lib/reference.js"(exports2) {
2689       "use strict";
2690       Object.defineProperty(exports2, "__esModule", { value: true });
2691       exports2.ligatureWordList = exports2.ligatureList = exports2.letterList = exports2.alefs = exports2.lams = exports2.lineBreakers = exports2.tashkeel = void 0;
2692       var unicode_arabic_1 = require_unicode_arabic();
2693       var unicode_ligatures_1 = require_unicode_ligatures();
2694       var letterList = Object.keys(unicode_arabic_1.default);
2695       exports2.letterList = letterList;
2696       var ligatureList = Object.keys(unicode_ligatures_1.default);
2697       exports2.ligatureList = ligatureList;
2698       var ligatureWordList = Object.keys(unicode_ligatures_1.default.words);
2699       exports2.ligatureWordList = ligatureWordList;
2700       var lams = "\u0644\u06B5\u06B6\u06B7\u06B8";
2701       exports2.lams = lams;
2702       var alefs = "\u0627\u0622\u0623\u0625\u0671\u0672\u0673\u0675\u0773\u0774";
2703       exports2.alefs = alefs;
2704       var tashkeel = "\u0605\u0640\u0670\u0674\u06DF\u06E7\u06E8";
2705       exports2.tashkeel = tashkeel;
2706       function addToTashkeel(start2, finish) {
2707         for (var i3 = start2; i3 <= finish; i3++) {
2708           exports2.tashkeel = tashkeel += String.fromCharCode(i3);
2709         }
2710       }
2711       addToTashkeel(1552, 1562);
2712       addToTashkeel(1611, 1631);
2713       addToTashkeel(1750, 1756);
2714       addToTashkeel(1760, 1764);
2715       addToTashkeel(1770, 1773);
2716       addToTashkeel(2259, 2273);
2717       addToTashkeel(2275, 2303);
2718       addToTashkeel(65136, 65151);
2719       var lineBreakers = "\u0627\u0629\u0648\u06C0\u06CF\u06FD\u06FE\u076B\u076C\u0771\u0773\u0774\u0778\u0779\u08E2\u08B1\u08B2\u08B9";
2720       exports2.lineBreakers = lineBreakers;
2721       function addToLineBreakers(start2, finish) {
2722         for (var i3 = start2; i3 <= finish; i3++) {
2723           exports2.lineBreakers = lineBreakers += String.fromCharCode(i3);
2724         }
2725       }
2726       addToLineBreakers(1536, 1567);
2727       addToLineBreakers(1569, 1573);
2728       addToLineBreakers(1583, 1586);
2729       addToLineBreakers(1632, 1645);
2730       addToLineBreakers(1649, 1655);
2731       addToLineBreakers(1672, 1689);
2732       addToLineBreakers(1731, 1739);
2733       addToLineBreakers(1746, 1785);
2734       addToLineBreakers(1881, 1883);
2735       addToLineBreakers(2218, 2222);
2736       addToLineBreakers(64336, 65021);
2737       addToLineBreakers(65152, 65276);
2738       addToLineBreakers(69216, 69247);
2739       addToLineBreakers(126064, 126143);
2740       addToLineBreakers(126464, 126719);
2741     }
2742   });
2743
2744   // node_modules/alif-toolkit/lib/GlyphSplitter.js
2745   var require_GlyphSplitter = __commonJS({
2746     "node_modules/alif-toolkit/lib/GlyphSplitter.js"(exports2) {
2747       "use strict";
2748       Object.defineProperty(exports2, "__esModule", { value: true });
2749       exports2.GlyphSplitter = GlyphSplitter;
2750       var isArabic_1 = require_isArabic();
2751       var reference_1 = require_reference();
2752       function GlyphSplitter(word) {
2753         let letters = [];
2754         let lastLetter = "";
2755         word.split("").forEach((letter) => {
2756           if ((0, isArabic_1.isArabic)(letter)) {
2757             if (reference_1.tashkeel.indexOf(letter) > -1) {
2758               letters[letters.length - 1] += letter;
2759             } else if (lastLetter.length && (reference_1.lams.indexOf(lastLetter) === 0 && reference_1.alefs.indexOf(letter) > -1 || reference_1.lams.indexOf(lastLetter) > 0 && reference_1.alefs.indexOf(letter) === 0)) {
2760               letters[letters.length - 1] += letter;
2761             } else {
2762               letters.push(letter);
2763             }
2764           } else {
2765             letters.push(letter);
2766           }
2767           if (reference_1.tashkeel.indexOf(letter) === -1) {
2768             lastLetter = letter;
2769           }
2770         });
2771         return letters;
2772       }
2773     }
2774   });
2775
2776   // node_modules/alif-toolkit/lib/BaselineSplitter.js
2777   var require_BaselineSplitter = __commonJS({
2778     "node_modules/alif-toolkit/lib/BaselineSplitter.js"(exports2) {
2779       "use strict";
2780       Object.defineProperty(exports2, "__esModule", { value: true });
2781       exports2.BaselineSplitter = BaselineSplitter;
2782       var isArabic_1 = require_isArabic();
2783       var reference_1 = require_reference();
2784       function BaselineSplitter(word) {
2785         let letters = [];
2786         let lastLetter = "";
2787         word.split("").forEach((letter) => {
2788           if ((0, isArabic_1.isArabic)(letter) && (0, isArabic_1.isArabic)(lastLetter)) {
2789             if (lastLetter.length && reference_1.tashkeel.indexOf(letter) > -1) {
2790               letters[letters.length - 1] += letter;
2791             } else if (reference_1.lineBreakers.indexOf(lastLetter) > -1) {
2792               letters.push(letter);
2793             } else {
2794               letters[letters.length - 1] += letter;
2795             }
2796           } else {
2797             letters.push(letter);
2798           }
2799           if (reference_1.tashkeel.indexOf(letter) === -1) {
2800             lastLetter = letter;
2801           }
2802         });
2803         return letters;
2804       }
2805     }
2806   });
2807
2808   // node_modules/alif-toolkit/lib/Normalization.js
2809   var require_Normalization = __commonJS({
2810     "node_modules/alif-toolkit/lib/Normalization.js"(exports2) {
2811       "use strict";
2812       Object.defineProperty(exports2, "__esModule", { value: true });
2813       exports2.Normal = Normal;
2814       var unicode_arabic_1 = require_unicode_arabic();
2815       var unicode_ligatures_1 = require_unicode_ligatures();
2816       var isArabic_1 = require_isArabic();
2817       var reference_1 = require_reference();
2818       function Normal(word, breakPresentationForm) {
2819         if (typeof breakPresentationForm === "undefined") {
2820           breakPresentationForm = true;
2821         }
2822         let returnable = "";
2823         word.split("").forEach((letter) => {
2824           if (!(0, isArabic_1.isArabic)(letter)) {
2825             returnable += letter;
2826             return;
2827           }
2828           for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2829             let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2830             let versions = Object.keys(letterForms);
2831             for (let v2 = 0; v2 < versions.length; v2++) {
2832               let localVersion = letterForms[versions[v2]];
2833               if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2834                 let embeddedForms = Object.keys(localVersion);
2835                 for (let ef = 0; ef < embeddedForms.length; ef++) {
2836                   let form = localVersion[embeddedForms[ef]];
2837                   if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2838                     if (form === letter) {
2839                       if (breakPresentationForm && localVersion["normal"] && ["isolated", "initial", "medial", "final"].indexOf(embeddedForms[ef]) > -1) {
2840                         if (typeof localVersion["normal"] === "object") {
2841                           returnable += localVersion["normal"][0];
2842                         } else {
2843                           returnable += localVersion["normal"];
2844                         }
2845                         return;
2846                       }
2847                       returnable += letter;
2848                       return;
2849                     } else if (typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2850                       returnable += form[0];
2851                       return;
2852                     }
2853                   }
2854                 }
2855               } else if (localVersion === letter) {
2856                 if (breakPresentationForm && letterForms["normal"] && ["isolated", "initial", "medial", "final"].indexOf(versions[v2]) > -1) {
2857                   if (typeof letterForms["normal"] === "object") {
2858                     returnable += letterForms["normal"][0];
2859                   } else {
2860                     returnable += letterForms["normal"];
2861                   }
2862                   return;
2863                 }
2864                 returnable += letter;
2865                 return;
2866               } else if (typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2867                 returnable += localVersion[0];
2868                 return;
2869               }
2870             }
2871           }
2872           for (let v2 = 0; v2 < reference_1.ligatureList.length; v2++) {
2873             let normalForm = reference_1.ligatureList[v2];
2874             if (normalForm !== "words") {
2875               let ligForms = Object.keys(unicode_ligatures_1.default[normalForm]);
2876               for (let f2 = 0; f2 < ligForms.length; f2++) {
2877                 if (unicode_ligatures_1.default[normalForm][ligForms[f2]] === letter) {
2878                   returnable += normalForm;
2879                   return;
2880                 }
2881               }
2882             }
2883           }
2884           for (let v3 = 0; v3 < reference_1.ligatureWordList.length; v3++) {
2885             let normalForm = reference_1.ligatureWordList[v3];
2886             if (unicode_ligatures_1.default.words[normalForm] === letter) {
2887               returnable += normalForm;
2888               return;
2889             }
2890           }
2891           returnable += letter;
2892         });
2893         return returnable;
2894       }
2895     }
2896   });
2897
2898   // node_modules/alif-toolkit/lib/CharShaper.js
2899   var require_CharShaper = __commonJS({
2900     "node_modules/alif-toolkit/lib/CharShaper.js"(exports2) {
2901       "use strict";
2902       Object.defineProperty(exports2, "__esModule", { value: true });
2903       exports2.CharShaper = CharShaper;
2904       var unicode_arabic_1 = require_unicode_arabic();
2905       var isArabic_1 = require_isArabic();
2906       var reference_1 = require_reference();
2907       function CharShaper(letter, form) {
2908         if (!(0, isArabic_1.isArabic)(letter)) {
2909           throw new Error("Not Arabic");
2910         }
2911         if (letter === "\u0621") {
2912           return "\u0621";
2913         }
2914         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2915           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2916           let versions = Object.keys(letterForms);
2917           for (let v2 = 0; v2 < versions.length; v2++) {
2918             let localVersion = letterForms[versions[v2]];
2919             if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2920               if (versions.indexOf(form) > -1) {
2921                 return letterForms[form];
2922               }
2923             } else if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2924               let embeddedVersions = Object.keys(localVersion);
2925               for (let ev = 0; ev < embeddedVersions.length; ev++) {
2926                 if (localVersion[embeddedVersions[ev]] === letter || typeof localVersion[embeddedVersions[ev]] === "object" && localVersion[embeddedVersions[ev]].indexOf && localVersion[embeddedVersions[ev]].indexOf(letter) > -1) {
2927                   if (embeddedVersions.indexOf(form) > -1) {
2928                     return localVersion[form];
2929                   }
2930                 }
2931               }
2932             }
2933           }
2934         }
2935       }
2936     }
2937   });
2938
2939   // node_modules/alif-toolkit/lib/WordShaper.js
2940   var require_WordShaper = __commonJS({
2941     "node_modules/alif-toolkit/lib/WordShaper.js"(exports2) {
2942       "use strict";
2943       Object.defineProperty(exports2, "__esModule", { value: true });
2944       exports2.WordShaper = WordShaper2;
2945       var isArabic_1 = require_isArabic();
2946       var reference_1 = require_reference();
2947       var CharShaper_1 = require_CharShaper();
2948       var unicode_ligatures_1 = require_unicode_ligatures();
2949       function WordShaper2(word) {
2950         let state = "initial";
2951         let output = "";
2952         for (let w2 = 0; w2 < word.length; w2++) {
2953           let nextLetter = " ";
2954           for (let nxw = w2 + 1; nxw < word.length; nxw++) {
2955             if (!(0, isArabic_1.isArabic)(word[nxw])) {
2956               break;
2957             }
2958             if (reference_1.tashkeel.indexOf(word[nxw]) === -1) {
2959               nextLetter = word[nxw];
2960               break;
2961             }
2962           }
2963           if (!(0, isArabic_1.isArabic)(word[w2]) || (0, isArabic_1.isMath)(word[w2])) {
2964             output += word[w2];
2965             state = "initial";
2966           } else if (reference_1.tashkeel.indexOf(word[w2]) > -1) {
2967             output += word[w2];
2968           } else if (nextLetter === " " || reference_1.lineBreakers.indexOf(word[w2]) > -1) {
2969             output += (0, CharShaper_1.CharShaper)(word[w2], state === "initial" ? "isolated" : "final");
2970             state = "initial";
2971           } else if (reference_1.lams.indexOf(word[w2]) > -1 && reference_1.alefs.indexOf(nextLetter) > -1) {
2972             output += unicode_ligatures_1.default[word[w2] + nextLetter][state === "initial" ? "isolated" : "final"];
2973             while (word[w2] !== nextLetter) {
2974               w2++;
2975             }
2976             state = "initial";
2977           } else {
2978             output += (0, CharShaper_1.CharShaper)(word[w2], state);
2979             state = "medial";
2980           }
2981         }
2982         return output;
2983       }
2984     }
2985   });
2986
2987   // node_modules/alif-toolkit/lib/ParentLetter.js
2988   var require_ParentLetter = __commonJS({
2989     "node_modules/alif-toolkit/lib/ParentLetter.js"(exports2) {
2990       "use strict";
2991       Object.defineProperty(exports2, "__esModule", { value: true });
2992       exports2.ParentLetter = ParentLetter;
2993       exports2.GrandparentLetter = GrandparentLetter;
2994       var unicode_arabic_1 = require_unicode_arabic();
2995       var isArabic_1 = require_isArabic();
2996       var reference_1 = require_reference();
2997       function ParentLetter(letter) {
2998         if (!(0, isArabic_1.isArabic)(letter)) {
2999           throw new Error("Not an Arabic letter");
3000         }
3001         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
3002           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
3003           let versions = Object.keys(letterForms);
3004           for (let v2 = 0; v2 < versions.length; v2++) {
3005             let localVersion = letterForms[versions[v2]];
3006             if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
3007               let embeddedForms = Object.keys(localVersion);
3008               for (let ef = 0; ef < embeddedForms.length; ef++) {
3009                 let form = localVersion[embeddedForms[ef]];
3010                 if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
3011                   return localVersion;
3012                 }
3013               }
3014             } else if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
3015               return letterForms;
3016             }
3017           }
3018           return null;
3019         }
3020       }
3021       function GrandparentLetter(letter) {
3022         if (!(0, isArabic_1.isArabic)(letter)) {
3023           throw new Error("Not an Arabic letter");
3024         }
3025         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
3026           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
3027           let versions = Object.keys(letterForms);
3028           for (let v2 = 0; v2 < versions.length; v2++) {
3029             let localVersion = letterForms[versions[v2]];
3030             if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
3031               let embeddedForms = Object.keys(localVersion);
3032               for (let ef = 0; ef < embeddedForms.length; ef++) {
3033                 let form = localVersion[embeddedForms[ef]];
3034                 if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
3035                   return letterForms;
3036                 }
3037               }
3038             } else if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
3039               return letterForms;
3040             }
3041           }
3042           return null;
3043         }
3044       }
3045     }
3046   });
3047
3048   // node_modules/alif-toolkit/lib/index.js
3049   var require_lib = __commonJS({
3050     "node_modules/alif-toolkit/lib/index.js"(exports2) {
3051       "use strict";
3052       Object.defineProperty(exports2, "__esModule", { value: true });
3053       exports2.GrandparentLetter = exports2.ParentLetter = exports2.WordShaper = exports2.CharShaper = exports2.Normal = exports2.BaselineSplitter = exports2.GlyphSplitter = exports2.isArabic = void 0;
3054       var isArabic_1 = require_isArabic();
3055       Object.defineProperty(exports2, "isArabic", { enumerable: true, get: function() {
3056         return isArabic_1.isArabic;
3057       } });
3058       var GlyphSplitter_1 = require_GlyphSplitter();
3059       Object.defineProperty(exports2, "GlyphSplitter", { enumerable: true, get: function() {
3060         return GlyphSplitter_1.GlyphSplitter;
3061       } });
3062       var BaselineSplitter_1 = require_BaselineSplitter();
3063       Object.defineProperty(exports2, "BaselineSplitter", { enumerable: true, get: function() {
3064         return BaselineSplitter_1.BaselineSplitter;
3065       } });
3066       var Normalization_1 = require_Normalization();
3067       Object.defineProperty(exports2, "Normal", { enumerable: true, get: function() {
3068         return Normalization_1.Normal;
3069       } });
3070       var CharShaper_1 = require_CharShaper();
3071       Object.defineProperty(exports2, "CharShaper", { enumerable: true, get: function() {
3072         return CharShaper_1.CharShaper;
3073       } });
3074       var WordShaper_1 = require_WordShaper();
3075       Object.defineProperty(exports2, "WordShaper", { enumerable: true, get: function() {
3076         return WordShaper_1.WordShaper;
3077       } });
3078       var ParentLetter_1 = require_ParentLetter();
3079       Object.defineProperty(exports2, "ParentLetter", { enumerable: true, get: function() {
3080         return ParentLetter_1.ParentLetter;
3081       } });
3082       Object.defineProperty(exports2, "GrandparentLetter", { enumerable: true, get: function() {
3083         return ParentLetter_1.GrandparentLetter;
3084       } });
3085     }
3086   });
3087
3088   // node_modules/vparse/index.js
3089   var require_vparse = __commonJS({
3090     "node_modules/vparse/index.js"(exports2, module2) {
3091       (function(window2) {
3092         "use strict";
3093         function parseVersion3(v2) {
3094           var m2 = v2.replace(/[^0-9.]/g, "").match(/[0-9]*\.|[0-9]+/g) || [];
3095           v2 = {
3096             major: +m2[0] || 0,
3097             minor: +m2[1] || 0,
3098             patch: +m2[2] || 0,
3099             build: +m2[3] || 0
3100           };
3101           v2.isEmpty = !v2.major && !v2.minor && !v2.patch && !v2.build;
3102           v2.parsed = [v2.major, v2.minor, v2.patch, v2.build];
3103           v2.text = v2.parsed.join(".");
3104           v2.compare = compare2;
3105           return v2;
3106         }
3107         function compare2(v2) {
3108           if (typeof v2 === "string") {
3109             v2 = parseVersion3(v2);
3110           }
3111           for (var i3 = 0; i3 < 4; i3++) {
3112             if (this.parsed[i3] !== v2.parsed[i3]) {
3113               return this.parsed[i3] > v2.parsed[i3] ? 1 : -1;
3114             }
3115           }
3116           return 0;
3117         }
3118         if (typeof module2 === "object" && module2 && typeof module2.exports === "object") {
3119           module2.exports = parseVersion3;
3120         } else {
3121           window2.parseVersion = parseVersion3;
3122         }
3123       })(exports2);
3124     }
3125   });
3126
3127   // node_modules/aes-js/index.js
3128   var require_aes_js = __commonJS({
3129     "node_modules/aes-js/index.js"(exports2, module2) {
3130       (function(root3) {
3131         "use strict";
3132         function checkInt(value) {
3133           return parseInt(value) === value;
3134         }
3135         function checkInts(arrayish) {
3136           if (!checkInt(arrayish.length)) {
3137             return false;
3138           }
3139           for (var i3 = 0; i3 < arrayish.length; i3++) {
3140             if (!checkInt(arrayish[i3]) || arrayish[i3] < 0 || arrayish[i3] > 255) {
3141               return false;
3142             }
3143           }
3144           return true;
3145         }
3146         function coerceArray(arg, copy2) {
3147           if (arg.buffer && arg.name === "Uint8Array") {
3148             if (copy2) {
3149               if (arg.slice) {
3150                 arg = arg.slice();
3151               } else {
3152                 arg = Array.prototype.slice.call(arg);
3153               }
3154             }
3155             return arg;
3156           }
3157           if (Array.isArray(arg)) {
3158             if (!checkInts(arg)) {
3159               throw new Error("Array contains invalid value: " + arg);
3160             }
3161             return new Uint8Array(arg);
3162           }
3163           if (checkInt(arg.length) && checkInts(arg)) {
3164             return new Uint8Array(arg);
3165           }
3166           throw new Error("unsupported array-like object");
3167         }
3168         function createArray(length2) {
3169           return new Uint8Array(length2);
3170         }
3171         function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) {
3172           if (sourceStart != null || sourceEnd != null) {
3173             if (sourceArray.slice) {
3174               sourceArray = sourceArray.slice(sourceStart, sourceEnd);
3175             } else {
3176               sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd);
3177             }
3178           }
3179           targetArray.set(sourceArray, targetStart);
3180         }
3181         var convertUtf8 = /* @__PURE__ */ function() {
3182           function toBytes(text) {
3183             var result = [], i3 = 0;
3184             text = encodeURI(text);
3185             while (i3 < text.length) {
3186               var c2 = text.charCodeAt(i3++);
3187               if (c2 === 37) {
3188                 result.push(parseInt(text.substr(i3, 2), 16));
3189                 i3 += 2;
3190               } else {
3191                 result.push(c2);
3192               }
3193             }
3194             return coerceArray(result);
3195           }
3196           function fromBytes(bytes) {
3197             var result = [], i3 = 0;
3198             while (i3 < bytes.length) {
3199               var c2 = bytes[i3];
3200               if (c2 < 128) {
3201                 result.push(String.fromCharCode(c2));
3202                 i3++;
3203               } else if (c2 > 191 && c2 < 224) {
3204                 result.push(String.fromCharCode((c2 & 31) << 6 | bytes[i3 + 1] & 63));
3205                 i3 += 2;
3206               } else {
3207                 result.push(String.fromCharCode((c2 & 15) << 12 | (bytes[i3 + 1] & 63) << 6 | bytes[i3 + 2] & 63));
3208                 i3 += 3;
3209               }
3210             }
3211             return result.join("");
3212           }
3213           return {
3214             toBytes,
3215             fromBytes
3216           };
3217         }();
3218         var convertHex = /* @__PURE__ */ function() {
3219           function toBytes(text) {
3220             var result = [];
3221             for (var i3 = 0; i3 < text.length; i3 += 2) {
3222               result.push(parseInt(text.substr(i3, 2), 16));
3223             }
3224             return result;
3225           }
3226           var Hex = "0123456789abcdef";
3227           function fromBytes(bytes) {
3228             var result = [];
3229             for (var i3 = 0; i3 < bytes.length; i3++) {
3230               var v2 = bytes[i3];
3231               result.push(Hex[(v2 & 240) >> 4] + Hex[v2 & 15]);
3232             }
3233             return result.join("");
3234           }
3235           return {
3236             toBytes,
3237             fromBytes
3238           };
3239         }();
3240         var numberOfRounds = { 16: 10, 24: 12, 32: 14 };
3241         var rcon = [1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145];
3242         var S2 = [99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22];
3243         var Si = [82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251, 124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222, 233, 203, 84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78, 8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37, 114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146, 108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132, 144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6, 208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107, 58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115, 150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110, 71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27, 252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244, 31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95, 96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239, 160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97, 23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125];
3244         var T1 = [3328402341, 4168907908, 4000806809, 4135287693, 4294111757, 3597364157, 3731845041, 2445657428, 1613770832, 33620227, 3462883241, 1445669757, 3892248089, 3050821474, 1303096294, 3967186586, 2412431941, 528646813, 2311702848, 4202528135, 4026202645, 2992200171, 2387036105, 4226871307, 1101901292, 3017069671, 1604494077, 1169141738, 597466303, 1403299063, 3832705686, 2613100635, 1974974402, 3791519004, 1033081774, 1277568618, 1815492186, 2118074177, 4126668546, 2211236943, 1748251740, 1369810420, 3521504564, 4193382664, 3799085459, 2883115123, 1647391059, 706024767, 134480908, 2512897874, 1176707941, 2646852446, 806885416, 932615841, 168101135, 798661301, 235341577, 605164086, 461406363, 3756188221, 3454790438, 1311188841, 2142417613, 3933566367, 302582043, 495158174, 1479289972, 874125870, 907746093, 3698224818, 3025820398, 1537253627, 2756858614, 1983593293, 3084310113, 2108928974, 1378429307, 3722699582, 1580150641, 327451799, 2790478837, 3117535592, 0, 3253595436, 1075847264, 3825007647, 2041688520, 3059440621, 3563743934, 2378943302, 1740553945, 1916352843, 2487896798, 2555137236, 2958579944, 2244988746, 3151024235, 3320835882, 1336584933, 3992714006, 2252555205, 2588757463, 1714631509, 293963156, 2319795663, 3925473552, 67240454, 4269768577, 2689618160, 2017213508, 631218106, 1269344483, 2723238387, 1571005438, 2151694528, 93294474, 1066570413, 563977660, 1882732616, 4059428100, 1673313503, 2008463041, 2950355573, 1109467491, 537923632, 3858759450, 4260623118, 3218264685, 2177748300, 403442708, 638784309, 3287084079, 3193921505, 899127202, 2286175436, 773265209, 2479146071, 1437050866, 4236148354, 2050833735, 3362022572, 3126681063, 840505643, 3866325909, 3227541664, 427917720, 2655997905, 2749160575, 1143087718, 1412049534, 999329963, 193497219, 2353415882, 3354324521, 1807268051, 672404540, 2816401017, 3160301282, 369822493, 2916866934, 3688947771, 1681011286, 1949973070, 336202270, 2454276571, 201721354, 1210328172, 3093060836, 2680341085, 3184776046, 1135389935, 3294782118, 965841320, 831886756, 3554993207, 4068047243, 3588745010, 2345191491, 1849112409, 3664604599, 26054028, 2983581028, 2622377682, 1235855840, 3630984372, 2891339514, 4092916743, 3488279077, 3395642799, 4101667470, 1202630377, 268961816, 1874508501, 4034427016, 1243948399, 1546530418, 941366308, 1470539505, 1941222599, 2546386513, 3421038627, 2715671932, 3899946140, 1042226977, 2521517021, 1639824860, 227249030, 260737669, 3765465232, 2084453954, 1907733956, 3429263018, 2420656344, 100860677, 4160157185, 470683154, 3261161891, 1781871967, 2924959737, 1773779408, 394692241, 2579611992, 974986535, 664706745, 3655459128, 3958962195, 731420851, 571543859, 3530123707, 2849626480, 126783113, 865375399, 765172662, 1008606754, 361203602, 3387549984, 2278477385, 2857719295, 1344809080, 2782912378, 59542671, 1503764984, 160008576, 437062935, 1707065306, 3622233649, 2218934982, 3496503480, 2185314755, 697932208, 1512910199, 504303377, 2075177163, 2824099068, 1841019862, 739644986];
3245         var T2 = [2781242211, 2230877308, 2582542199, 2381740923, 234877682, 3184946027, 2984144751, 1418839493, 1348481072, 50462977, 2848876391, 2102799147, 434634494, 1656084439, 3863849899, 2599188086, 1167051466, 2636087938, 1082771913, 2281340285, 368048890, 3954334041, 3381544775, 201060592, 3963727277, 1739838676, 4250903202, 3930435503, 3206782108, 4149453988, 2531553906, 1536934080, 3262494647, 484572669, 2923271059, 1783375398, 1517041206, 1098792767, 49674231, 1334037708, 1550332980, 4098991525, 886171109, 150598129, 2481090929, 1940642008, 1398944049, 1059722517, 201851908, 1385547719, 1699095331, 1587397571, 674240536, 2704774806, 252314885, 3039795866, 151914247, 908333586, 2602270848, 1038082786, 651029483, 1766729511, 3447698098, 2682942837, 454166793, 2652734339, 1951935532, 775166490, 758520603, 3000790638, 4004797018, 4217086112, 4137964114, 1299594043, 1639438038, 3464344499, 2068982057, 1054729187, 1901997871, 2534638724, 4121318227, 1757008337, 0, 750906861, 1614815264, 535035132, 3363418545, 3988151131, 3201591914, 1183697867, 3647454910, 1265776953, 3734260298, 3566750796, 3903871064, 1250283471, 1807470800, 717615087, 3847203498, 384695291, 3313910595, 3617213773, 1432761139, 2484176261, 3481945413, 283769337, 100925954, 2180939647, 4037038160, 1148730428, 3123027871, 3813386408, 4087501137, 4267549603, 3229630528, 2315620239, 2906624658, 3156319645, 1215313976, 82966005, 3747855548, 3245848246, 1974459098, 1665278241, 807407632, 451280895, 251524083, 1841287890, 1283575245, 337120268, 891687699, 801369324, 3787349855, 2721421207, 3431482436, 959321879, 1469301956, 4065699751, 2197585534, 1199193405, 2898814052, 3887750493, 724703513, 2514908019, 2696962144, 2551808385, 3516813135, 2141445340, 1715741218, 2119445034, 2872807568, 2198571144, 3398190662, 700968686, 3547052216, 1009259540, 2041044702, 3803995742, 487983883, 1991105499, 1004265696, 1449407026, 1316239930, 504629770, 3683797321, 168560134, 1816667172, 3837287516, 1570751170, 1857934291, 4014189740, 2797888098, 2822345105, 2754712981, 936633572, 2347923833, 852879335, 1133234376, 1500395319, 3084545389, 2348912013, 1689376213, 3533459022, 3762923945, 3034082412, 4205598294, 133428468, 634383082, 2949277029, 2398386810, 3913789102, 403703816, 3580869306, 2297460856, 1867130149, 1918643758, 607656988, 4049053350, 3346248884, 1368901318, 600565992, 2090982877, 2632479860, 557719327, 3717614411, 3697393085, 2249034635, 2232388234, 2430627952, 1115438654, 3295786421, 2865522278, 3633334344, 84280067, 33027830, 303828494, 2747425121, 1600795957, 4188952407, 3496589753, 2434238086, 1486471617, 658119965, 3106381470, 953803233, 334231800, 3005978776, 857870609, 3151128937, 1890179545, 2298973838, 2805175444, 3056442267, 574365214, 2450884487, 550103529, 1233637070, 4289353045, 2018519080, 2057691103, 2399374476, 4166623649, 2148108681, 387583245, 3664101311, 836232934, 3330556482, 3100665960, 3280093505, 2955516313, 2002398509, 287182607, 3413881008, 4238890068, 3597515707, 975967766];
3246         var T3 = [1671808611, 2089089148, 2006576759, 2072901243, 4061003762, 1807603307, 1873927791, 3310653893, 810573872, 16974337, 1739181671, 729634347, 4263110654, 3613570519, 2883997099, 1989864566, 3393556426, 2191335298, 3376449993, 2106063485, 4195741690, 1508618841, 1204391495, 4027317232, 2917941677, 3563566036, 2734514082, 2951366063, 2629772188, 2767672228, 1922491506, 3227229120, 3082974647, 4246528509, 2477669779, 644500518, 911895606, 1061256767, 4144166391, 3427763148, 878471220, 2784252325, 3845444069, 4043897329, 1905517169, 3631459288, 827548209, 356461077, 67897348, 3344078279, 593839651, 3277757891, 405286936, 2527147926, 84871685, 2595565466, 118033927, 305538066, 2157648768, 3795705826, 3945188843, 661212711, 2999812018, 1973414517, 152769033, 2208177539, 745822252, 439235610, 455947803, 1857215598, 1525593178, 2700827552, 1391895634, 994932283, 3596728278, 3016654259, 695947817, 3812548067, 795958831, 2224493444, 1408607827, 3513301457, 0, 3979133421, 543178784, 4229948412, 2982705585, 1542305371, 1790891114, 3410398667, 3201918910, 961245753, 1256100938, 1289001036, 1491644504, 3477767631, 3496721360, 4012557807, 2867154858, 4212583931, 1137018435, 1305975373, 861234739, 2241073541, 1171229253, 4178635257, 33948674, 2139225727, 1357946960, 1011120188, 2679776671, 2833468328, 1374921297, 2751356323, 1086357568, 2408187279, 2460827538, 2646352285, 944271416, 4110742005, 3168756668, 3066132406, 3665145818, 560153121, 271589392, 4279952895, 4077846003, 3530407890, 3444343245, 202643468, 322250259, 3962553324, 1608629855, 2543990167, 1154254916, 389623319, 3294073796, 2817676711, 2122513534, 1028094525, 1689045092, 1575467613, 422261273, 1939203699, 1621147744, 2174228865, 1339137615, 3699352540, 577127458, 712922154, 2427141008, 2290289544, 1187679302, 3995715566, 3100863416, 339486740, 3732514782, 1591917662, 186455563, 3681988059, 3762019296, 844522546, 978220090, 169743370, 1239126601, 101321734, 611076132, 1558493276, 3260915650, 3547250131, 2901361580, 1655096418, 2443721105, 2510565781, 3828863972, 2039214713, 3878868455, 3359869896, 928607799, 1840765549, 2374762893, 3580146133, 1322425422, 2850048425, 1823791212, 1459268694, 4094161908, 3928346602, 1706019429, 2056189050, 2934523822, 135794696, 3134549946, 2022240376, 628050469, 779246638, 472135708, 2800834470, 3032970164, 3327236038, 3894660072, 3715932637, 1956440180, 522272287, 1272813131, 3185336765, 2340818315, 2323976074, 1888542832, 1044544574, 3049550261, 1722469478, 1222152264, 50660867, 4127324150, 236067854, 1638122081, 895445557, 1475980887, 3117443513, 2257655686, 3243809217, 489110045, 2662934430, 3778599393, 4162055160, 2561878936, 288563729, 1773916777, 3648039385, 2391345038, 2493985684, 2612407707, 505560094, 2274497927, 3911240169, 3460925390, 1442818645, 678973480, 3749357023, 2358182796, 2717407649, 2306869641, 219617805, 3218761151, 3862026214, 1120306242, 1756942440, 1103331905, 2578459033, 762796589, 252780047, 2966125488, 1425844308, 3151392187, 372911126];
3247         var T4 = [1667474886, 2088535288, 2004326894, 2071694838, 4075949567, 1802223062, 1869591006, 3318043793, 808472672, 16843522, 1734846926, 724270422, 4278065639, 3621216949, 2880169549, 1987484396, 3402253711, 2189597983, 3385409673, 2105378810, 4210693615, 1499065266, 1195886990, 4042263547, 2913856577, 3570689971, 2728590687, 2947541573, 2627518243, 2762274643, 1920112356, 3233831835, 3082273397, 4261223649, 2475929149, 640051788, 909531756, 1061110142, 4160160501, 3435941763, 875846760, 2779116625, 3857003729, 4059105529, 1903268834, 3638064043, 825316194, 353713962, 67374088, 3351728789, 589522246, 3284360861, 404236336, 2526454071, 84217610, 2593830191, 117901582, 303183396, 2155911963, 3806477791, 3958056653, 656894286, 2998062463, 1970642922, 151591698, 2206440989, 741110872, 437923380, 454765878, 1852748508, 1515908788, 2694904667, 1381168804, 993742198, 3604373943, 3014905469, 690584402, 3823320797, 791638366, 2223281939, 1398011302, 3520161977, 0, 3991743681, 538992704, 4244381667, 2981218425, 1532751286, 1785380564, 3419096717, 3200178535, 960056178, 1246420628, 1280103576, 1482221744, 3486468741, 3503319995, 4025428677, 2863326543, 4227536621, 1128514950, 1296947098, 859002214, 2240123921, 1162203018, 4193849577, 33687044, 2139062782, 1347481760, 1010582648, 2678045221, 2829640523, 1364325282, 2745433693, 1077985408, 2408548869, 2459086143, 2644360225, 943212656, 4126475505, 3166494563, 3065430391, 3671750063, 555836226, 269496352, 4294908645, 4092792573, 3537006015, 3452783745, 202118168, 320025894, 3974901699, 1600119230, 2543297077, 1145359496, 387397934, 3301201811, 2812801621, 2122220284, 1027426170, 1684319432, 1566435258, 421079858, 1936954854, 1616945344, 2172753945, 1330631070, 3705438115, 572679748, 707427924, 2425400123, 2290647819, 1179044492, 4008585671, 3099120491, 336870440, 3739122087, 1583276732, 185277718, 3688593069, 3772791771, 842159716, 976899700, 168435220, 1229577106, 101059084, 606366792, 1549591736, 3267517855, 3553849021, 2897014595, 1650632388, 2442242105, 2509612081, 3840161747, 2038008818, 3890688725, 3368567691, 926374254, 1835907034, 2374863873, 3587531953, 1313788572, 2846482505, 1819063512, 1448540844, 4109633523, 3941213647, 1701162954, 2054852340, 2930698567, 134748176, 3132806511, 2021165296, 623210314, 774795868, 471606328, 2795958615, 3031746419, 3334885783, 3907527627, 3722280097, 1953799400, 522133822, 1263263126, 3183336545, 2341176845, 2324333839, 1886425312, 1044267644, 3048588401, 1718004428, 1212733584, 50529542, 4143317495, 235803164, 1633788866, 892690282, 1465383342, 3115962473, 2256965911, 3250673817, 488449850, 2661202215, 3789633753, 4177007595, 2560144171, 286339874, 1768537042, 3654906025, 2391705863, 2492770099, 2610673197, 505291324, 2273808917, 3924369609, 3469625735, 1431699370, 673740880, 3755965093, 2358021891, 2711746649, 2307489801, 218961690, 3217021541, 3873845719, 1111672452, 1751693520, 1094828930, 2576986153, 757954394, 252645662, 2964376443, 1414855848, 3149649517, 370555436];
3248         var T5 = [1374988112, 2118214995, 437757123, 975658646, 1001089995, 530400753, 2902087851, 1273168787, 540080725, 2910219766, 2295101073, 4110568485, 1340463100, 3307916247, 641025152, 3043140495, 3736164937, 632953703, 1172967064, 1576976609, 3274667266, 2169303058, 2370213795, 1809054150, 59727847, 361929877, 3211623147, 2505202138, 3569255213, 1484005843, 1239443753, 2395588676, 1975683434, 4102977912, 2572697195, 666464733, 3202437046, 4035489047, 3374361702, 2110667444, 1675577880, 3843699074, 2538681184, 1649639237, 2976151520, 3144396420, 4269907996, 4178062228, 1883793496, 2403728665, 2497604743, 1383856311, 2876494627, 1917518562, 3810496343, 1716890410, 3001755655, 800440835, 2261089178, 3543599269, 807962610, 599762354, 33778362, 3977675356, 2328828971, 2809771154, 4077384432, 1315562145, 1708848333, 101039829, 3509871135, 3299278474, 875451293, 2733856160, 92987698, 2767645557, 193195065, 1080094634, 1584504582, 3178106961, 1042385657, 2531067453, 3711829422, 1306967366, 2438237621, 1908694277, 67556463, 1615861247, 429456164, 3602770327, 2302690252, 1742315127, 2968011453, 126454664, 3877198648, 2043211483, 2709260871, 2084704233, 4169408201, 0, 159417987, 841739592, 504459436, 1817866830, 4245618683, 260388950, 1034867998, 908933415, 168810852, 1750902305, 2606453969, 607530554, 202008497, 2472011535, 3035535058, 463180190, 2160117071, 1641816226, 1517767529, 470948374, 3801332234, 3231722213, 1008918595, 303765277, 235474187, 4069246893, 766945465, 337553864, 1475418501, 2943682380, 4003061179, 2743034109, 4144047775, 1551037884, 1147550661, 1543208500, 2336434550, 3408119516, 3069049960, 3102011747, 3610369226, 1113818384, 328671808, 2227573024, 2236228733, 3535486456, 2935566865, 3341394285, 496906059, 3702665459, 226906860, 2009195472, 733156972, 2842737049, 294930682, 1206477858, 2835123396, 2700099354, 1451044056, 573804783, 2269728455, 3644379585, 2362090238, 2564033334, 2801107407, 2776292904, 3669462566, 1068351396, 742039012, 1350078989, 1784663195, 1417561698, 4136440770, 2430122216, 775550814, 2193862645, 2673705150, 1775276924, 1876241833, 3475313331, 3366754619, 270040487, 3902563182, 3678124923, 3441850377, 1851332852, 3969562369, 2203032232, 3868552805, 2868897406, 566021896, 4011190502, 3135740889, 1248802510, 3936291284, 699432150, 832877231, 708780849, 3332740144, 899835584, 1951317047, 4236429990, 3767586992, 866637845, 4043610186, 1106041591, 2144161806, 395441711, 1984812685, 1139781709, 3433712980, 3835036895, 2664543715, 1282050075, 3240894392, 1181045119, 2640243204, 25965917, 4203181171, 4211818798, 3009879386, 2463879762, 3910161971, 1842759443, 2597806476, 933301370, 1509430414, 3943906441, 3467192302, 3076639029, 3776767469, 2051518780, 2631065433, 1441952575, 404016761, 1942435775, 1408749034, 1610459739, 3745345300, 2017778566, 3400528769, 3110650942, 941896748, 3265478751, 371049330, 3168937228, 675039627, 4279080257, 967311729, 135050206, 3635733660, 1683407248, 2076935265, 3576870512, 1215061108, 3501741890];
3249         var T6 = [1347548327, 1400783205, 3273267108, 2520393566, 3409685355, 4045380933, 2880240216, 2471224067, 1428173050, 4138563181, 2441661558, 636813900, 4233094615, 3620022987, 2149987652, 2411029155, 1239331162, 1730525723, 2554718734, 3781033664, 46346101, 310463728, 2743944855, 3328955385, 3875770207, 2501218972, 3955191162, 3667219033, 768917123, 3545789473, 692707433, 1150208456, 1786102409, 2029293177, 1805211710, 3710368113, 3065962831, 401639597, 1724457132, 3028143674, 409198410, 2196052529, 1620529459, 1164071807, 3769721975, 2226875310, 486441376, 2499348523, 1483753576, 428819965, 2274680428, 3075636216, 598438867, 3799141122, 1474502543, 711349675, 129166120, 53458370, 2592523643, 2782082824, 4063242375, 2988687269, 3120694122, 1559041666, 730517276, 2460449204, 4042459122, 2706270690, 3446004468, 3573941694, 533804130, 2328143614, 2637442643, 2695033685, 839224033, 1973745387, 957055980, 2856345839, 106852767, 1371368976, 4181598602, 1033297158, 2933734917, 1179510461, 3046200461, 91341917, 1862534868, 4284502037, 605657339, 2547432937, 3431546947, 2003294622, 3182487618, 2282195339, 954669403, 3682191598, 1201765386, 3917234703, 3388507166, 0, 2198438022, 1211247597, 2887651696, 1315723890, 4227665663, 1443857720, 507358933, 657861945, 1678381017, 560487590, 3516619604, 975451694, 2970356327, 261314535, 3535072918, 2652609425, 1333838021, 2724322336, 1767536459, 370938394, 182621114, 3854606378, 1128014560, 487725847, 185469197, 2918353863, 3106780840, 3356761769, 2237133081, 1286567175, 3152976349, 4255350624, 2683765030, 3160175349, 3309594171, 878443390, 1988838185, 3704300486, 1756818940, 1673061617, 3403100636, 272786309, 1075025698, 545572369, 2105887268, 4174560061, 296679730, 1841768865, 1260232239, 4091327024, 3960309330, 3497509347, 1814803222, 2578018489, 4195456072, 575138148, 3299409036, 446754879, 3629546796, 4011996048, 3347532110, 3252238545, 4270639778, 915985419, 3483825537, 681933534, 651868046, 2755636671, 3828103837, 223377554, 2607439820, 1649704518, 3270937875, 3901806776, 1580087799, 4118987695, 3198115200, 2087309459, 2842678573, 3016697106, 1003007129, 2802849917, 1860738147, 2077965243, 164439672, 4100872472, 32283319, 2827177882, 1709610350, 2125135846, 136428751, 3874428392, 3652904859, 3460984630, 3572145929, 3593056380, 2939266226, 824852259, 818324884, 3224740454, 930369212, 2801566410, 2967507152, 355706840, 1257309336, 4148292826, 243256656, 790073846, 2373340630, 1296297904, 1422699085, 3756299780, 3818836405, 457992840, 3099667487, 2135319889, 77422314, 1560382517, 1945798516, 788204353, 1521706781, 1385356242, 870912086, 325965383, 2358957921, 2050466060, 2388260884, 2313884476, 4006521127, 901210569, 3990953189, 1014646705, 1503449823, 1062597235, 2031621326, 3212035895, 3931371469, 1533017514, 350174575, 2256028891, 2177544179, 1052338372, 741876788, 1606591296, 1914052035, 213705253, 2334669897, 1107234197, 1899603969, 3725069491, 2631447780, 2422494913, 1635502980, 1893020342, 1950903388, 1120974935];
3250         var T7 = [2807058932, 1699970625, 2764249623, 1586903591, 1808481195, 1173430173, 1487645946, 59984867, 4199882800, 1844882806, 1989249228, 1277555970, 3623636965, 3419915562, 1149249077, 2744104290, 1514790577, 459744698, 244860394, 3235995134, 1963115311, 4027744588, 2544078150, 4190530515, 1608975247, 2627016082, 2062270317, 1507497298, 2200818878, 567498868, 1764313568, 3359936201, 2305455554, 2037970062, 1047239e3, 1910319033, 1337376481, 2904027272, 2892417312, 984907214, 1243112415, 830661914, 861968209, 2135253587, 2011214180, 2927934315, 2686254721, 731183368, 1750626376, 4246310725, 1820824798, 4172763771, 3542330227, 48394827, 2404901663, 2871682645, 671593195, 3254988725, 2073724613, 145085239, 2280796200, 2779915199, 1790575107, 2187128086, 472615631, 3029510009, 4075877127, 3802222185, 4107101658, 3201631749, 1646252340, 4270507174, 1402811438, 1436590835, 3778151818, 3950355702, 3963161475, 4020912224, 2667994737, 273792366, 2331590177, 104699613, 95345982, 3175501286, 2377486676, 1560637892, 3564045318, 369057872, 4213447064, 3919042237, 1137477952, 2658625497, 1119727848, 2340947849, 1530455833, 4007360968, 172466556, 266959938, 516552836, 0, 2256734592, 3980931627, 1890328081, 1917742170, 4294704398, 945164165, 3575528878, 958871085, 3647212047, 2787207260, 1423022939, 775562294, 1739656202, 3876557655, 2530391278, 2443058075, 3310321856, 547512796, 1265195639, 437656594, 3121275539, 719700128, 3762502690, 387781147, 218828297, 3350065803, 2830708150, 2848461854, 428169201, 122466165, 3720081049, 1627235199, 648017665, 4122762354, 1002783846, 2117360635, 695634755, 3336358691, 4234721005, 4049844452, 3704280881, 2232435299, 574624663, 287343814, 612205898, 1039717051, 840019705, 2708326185, 793451934, 821288114, 1391201670, 3822090177, 376187827, 3113855344, 1224348052, 1679968233, 2361698556, 1058709744, 752375421, 2431590963, 1321699145, 3519142200, 2734591178, 188127444, 2177869557, 3727205754, 2384911031, 3215212461, 2648976442, 2450346104, 3432737375, 1180849278, 331544205, 3102249176, 4150144569, 2952102595, 2159976285, 2474404304, 766078933, 313773861, 2570832044, 2108100632, 1668212892, 3145456443, 2013908262, 418672217, 3070356634, 2594734927, 1852171925, 3867060991, 3473416636, 3907448597, 2614737639, 919489135, 164948639, 2094410160, 2997825956, 590424639, 2486224549, 1723872674, 3157750862, 3399941250, 3501252752, 3625268135, 2555048196, 3673637356, 1343127501, 4130281361, 3599595085, 2957853679, 1297403050, 81781910, 3051593425, 2283490410, 532201772, 1367295589, 3926170974, 895287692, 1953757831, 1093597963, 492483431, 3528626907, 1446242576, 1192455638, 1636604631, 209336225, 344873464, 1015671571, 669961897, 3375740769, 3857572124, 2973530695, 3747192018, 1933530610, 3464042516, 935293895, 3454686199, 2858115069, 1863638845, 3683022916, 4085369519, 3292445032, 875313188, 1080017571, 3279033885, 621591778, 1233856572, 2504130317, 24197544, 3017672716, 3835484340, 3247465558, 2220981195, 3060847922, 1551124588, 1463996600];
3251         var T8 = [4104605777, 1097159550, 396673818, 660510266, 2875968315, 2638606623, 4200115116, 3808662347, 821712160, 1986918061, 3430322568, 38544885, 3856137295, 718002117, 893681702, 1654886325, 2975484382, 3122358053, 3926825029, 4274053469, 796197571, 1290801793, 1184342925, 3556361835, 2405426947, 2459735317, 1836772287, 1381620373, 3196267988, 1948373848, 3764988233, 3385345166, 3263785589, 2390325492, 1480485785, 3111247143, 3780097726, 2293045232, 548169417, 3459953789, 3746175075, 439452389, 1362321559, 1400849762, 1685577905, 1806599355, 2174754046, 137073913, 1214797936, 1174215055, 3731654548, 2079897426, 1943217067, 1258480242, 529487843, 1437280870, 3945269170, 3049390895, 3313212038, 923313619, 679998e3, 3215307299, 57326082, 377642221, 3474729866, 2041877159, 133361907, 1776460110, 3673476453, 96392454, 878845905, 2801699524, 777231668, 4082475170, 2330014213, 4142626212, 2213296395, 1626319424, 1906247262, 1846563261, 562755902, 3708173718, 1040559837, 3871163981, 1418573201, 3294430577, 114585348, 1343618912, 2566595609, 3186202582, 1078185097, 3651041127, 3896688048, 2307622919, 425408743, 3371096953, 2081048481, 1108339068, 2216610296, 0, 2156299017, 736970802, 292596766, 1517440620, 251657213, 2235061775, 2933202493, 758720310, 265905162, 1554391400, 1532285339, 908999204, 174567692, 1474760595, 4002861748, 2610011675, 3234156416, 3693126241, 2001430874, 303699484, 2478443234, 2687165888, 585122620, 454499602, 151849742, 2345119218, 3064510765, 514443284, 4044981591, 1963412655, 2581445614, 2137062819, 19308535, 1928707164, 1715193156, 4219352155, 1126790795, 600235211, 3992742070, 3841024952, 836553431, 1669664834, 2535604243, 3323011204, 1243905413, 3141400786, 4180808110, 698445255, 2653899549, 2989552604, 2253581325, 3252932727, 3004591147, 1891211689, 2487810577, 3915653703, 4237083816, 4030667424, 2100090966, 865136418, 1229899655, 953270745, 3399679628, 3557504664, 4118925222, 2061379749, 3079546586, 2915017791, 983426092, 2022837584, 1607244650, 2118541908, 2366882550, 3635996816, 972512814, 3283088770, 1568718495, 3499326569, 3576539503, 621982671, 2895723464, 410887952, 2623762152, 1002142683, 645401037, 1494807662, 2595684844, 1335535747, 2507040230, 4293295786, 3167684641, 367585007, 3885750714, 1865862730, 2668221674, 2960971305, 2763173681, 1059270954, 2777952454, 2724642869, 1320957812, 2194319100, 2429595872, 2815956275, 77089521, 3973773121, 3444575871, 2448830231, 1305906550, 4021308739, 2857194700, 2516901860, 3518358430, 1787304780, 740276417, 1699839814, 1592394909, 2352307457, 2272556026, 188821243, 1729977011, 3687994002, 274084841, 3594982253, 3613494426, 2701949495, 4162096729, 322734571, 2837966542, 1640576439, 484830689, 1202797690, 3537852828, 4067639125, 349075736, 3342319475, 4157467219, 4255800159, 1030690015, 1155237496, 2951971274, 1757691577, 607398968, 2738905026, 499347990, 3794078908, 1011452712, 227885567, 2818666809, 213114376, 3034881240, 1455525988, 3414450555, 850817237, 1817998408, 3092726480];
3252         var U1 = [0, 235474187, 470948374, 303765277, 941896748, 908933415, 607530554, 708780849, 1883793496, 2118214995, 1817866830, 1649639237, 1215061108, 1181045119, 1417561698, 1517767529, 3767586992, 4003061179, 4236429990, 4069246893, 3635733660, 3602770327, 3299278474, 3400528769, 2430122216, 2664543715, 2362090238, 2193862645, 2835123396, 2801107407, 3035535058, 3135740889, 3678124923, 3576870512, 3341394285, 3374361702, 3810496343, 3977675356, 4279080257, 4043610186, 2876494627, 2776292904, 3076639029, 3110650942, 2472011535, 2640243204, 2403728665, 2169303058, 1001089995, 899835584, 666464733, 699432150, 59727847, 226906860, 530400753, 294930682, 1273168787, 1172967064, 1475418501, 1509430414, 1942435775, 2110667444, 1876241833, 1641816226, 2910219766, 2743034109, 2976151520, 3211623147, 2505202138, 2606453969, 2302690252, 2269728455, 3711829422, 3543599269, 3240894392, 3475313331, 3843699074, 3943906441, 4178062228, 4144047775, 1306967366, 1139781709, 1374988112, 1610459739, 1975683434, 2076935265, 1775276924, 1742315127, 1034867998, 866637845, 566021896, 800440835, 92987698, 193195065, 429456164, 395441711, 1984812685, 2017778566, 1784663195, 1683407248, 1315562145, 1080094634, 1383856311, 1551037884, 101039829, 135050206, 437757123, 337553864, 1042385657, 807962610, 573804783, 742039012, 2531067453, 2564033334, 2328828971, 2227573024, 2935566865, 2700099354, 3001755655, 3168937228, 3868552805, 3902563182, 4203181171, 4102977912, 3736164937, 3501741890, 3265478751, 3433712980, 1106041591, 1340463100, 1576976609, 1408749034, 2043211483, 2009195472, 1708848333, 1809054150, 832877231, 1068351396, 766945465, 599762354, 159417987, 126454664, 361929877, 463180190, 2709260871, 2943682380, 3178106961, 3009879386, 2572697195, 2538681184, 2236228733, 2336434550, 3509871135, 3745345300, 3441850377, 3274667266, 3910161971, 3877198648, 4110568485, 4211818798, 2597806476, 2497604743, 2261089178, 2295101073, 2733856160, 2902087851, 3202437046, 2968011453, 3936291284, 3835036895, 4136440770, 4169408201, 3535486456, 3702665459, 3467192302, 3231722213, 2051518780, 1951317047, 1716890410, 1750902305, 1113818384, 1282050075, 1584504582, 1350078989, 168810852, 67556463, 371049330, 404016761, 841739592, 1008918595, 775550814, 540080725, 3969562369, 3801332234, 4035489047, 4269907996, 3569255213, 3669462566, 3366754619, 3332740144, 2631065433, 2463879762, 2160117071, 2395588676, 2767645557, 2868897406, 3102011747, 3069049960, 202008497, 33778362, 270040487, 504459436, 875451293, 975658646, 675039627, 641025152, 2084704233, 1917518562, 1615861247, 1851332852, 1147550661, 1248802510, 1484005843, 1451044056, 933301370, 967311729, 733156972, 632953703, 260388950, 25965917, 328671808, 496906059, 1206477858, 1239443753, 1543208500, 1441952575, 2144161806, 1908694277, 1675577880, 1842759443, 3610369226, 3644379585, 3408119516, 3307916247, 4011190502, 3776767469, 4077384432, 4245618683, 2809771154, 2842737049, 3144396420, 3043140495, 2673705150, 2438237621, 2203032232, 2370213795];
3253         var U2 = [0, 185469197, 370938394, 487725847, 741876788, 657861945, 975451694, 824852259, 1483753576, 1400783205, 1315723890, 1164071807, 1950903388, 2135319889, 1649704518, 1767536459, 2967507152, 3152976349, 2801566410, 2918353863, 2631447780, 2547432937, 2328143614, 2177544179, 3901806776, 3818836405, 4270639778, 4118987695, 3299409036, 3483825537, 3535072918, 3652904859, 2077965243, 1893020342, 1841768865, 1724457132, 1474502543, 1559041666, 1107234197, 1257309336, 598438867, 681933534, 901210569, 1052338372, 261314535, 77422314, 428819965, 310463728, 3409685355, 3224740454, 3710368113, 3593056380, 3875770207, 3960309330, 4045380933, 4195456072, 2471224067, 2554718734, 2237133081, 2388260884, 3212035895, 3028143674, 2842678573, 2724322336, 4138563181, 4255350624, 3769721975, 3955191162, 3667219033, 3516619604, 3431546947, 3347532110, 2933734917, 2782082824, 3099667487, 3016697106, 2196052529, 2313884476, 2499348523, 2683765030, 1179510461, 1296297904, 1347548327, 1533017514, 1786102409, 1635502980, 2087309459, 2003294622, 507358933, 355706840, 136428751, 53458370, 839224033, 957055980, 605657339, 790073846, 2373340630, 2256028891, 2607439820, 2422494913, 2706270690, 2856345839, 3075636216, 3160175349, 3573941694, 3725069491, 3273267108, 3356761769, 4181598602, 4063242375, 4011996048, 3828103837, 1033297158, 915985419, 730517276, 545572369, 296679730, 446754879, 129166120, 213705253, 1709610350, 1860738147, 1945798516, 2029293177, 1239331162, 1120974935, 1606591296, 1422699085, 4148292826, 4233094615, 3781033664, 3931371469, 3682191598, 3497509347, 3446004468, 3328955385, 2939266226, 2755636671, 3106780840, 2988687269, 2198438022, 2282195339, 2501218972, 2652609425, 1201765386, 1286567175, 1371368976, 1521706781, 1805211710, 1620529459, 2105887268, 1988838185, 533804130, 350174575, 164439672, 46346101, 870912086, 954669403, 636813900, 788204353, 2358957921, 2274680428, 2592523643, 2441661558, 2695033685, 2880240216, 3065962831, 3182487618, 3572145929, 3756299780, 3270937875, 3388507166, 4174560061, 4091327024, 4006521127, 3854606378, 1014646705, 930369212, 711349675, 560487590, 272786309, 457992840, 106852767, 223377554, 1678381017, 1862534868, 1914052035, 2031621326, 1211247597, 1128014560, 1580087799, 1428173050, 32283319, 182621114, 401639597, 486441376, 768917123, 651868046, 1003007129, 818324884, 1503449823, 1385356242, 1333838021, 1150208456, 1973745387, 2125135846, 1673061617, 1756818940, 2970356327, 3120694122, 2802849917, 2887651696, 2637442643, 2520393566, 2334669897, 2149987652, 3917234703, 3799141122, 4284502037, 4100872472, 3309594171, 3460984630, 3545789473, 3629546796, 2050466060, 1899603969, 1814803222, 1730525723, 1443857720, 1560382517, 1075025698, 1260232239, 575138148, 692707433, 878443390, 1062597235, 243256656, 91341917, 409198410, 325965383, 3403100636, 3252238545, 3704300486, 3620022987, 3874428392, 3990953189, 4042459122, 4227665663, 2460449204, 2578018489, 2226875310, 2411029155, 3198115200, 3046200461, 2827177882, 2743944855];
3254         var U3 = [0, 218828297, 437656594, 387781147, 875313188, 958871085, 775562294, 590424639, 1750626376, 1699970625, 1917742170, 2135253587, 1551124588, 1367295589, 1180849278, 1265195639, 3501252752, 3720081049, 3399941250, 3350065803, 3835484340, 3919042237, 4270507174, 4085369519, 3102249176, 3051593425, 2734591178, 2952102595, 2361698556, 2177869557, 2530391278, 2614737639, 3145456443, 3060847922, 2708326185, 2892417312, 2404901663, 2187128086, 2504130317, 2555048196, 3542330227, 3727205754, 3375740769, 3292445032, 3876557655, 3926170974, 4246310725, 4027744588, 1808481195, 1723872674, 1910319033, 2094410160, 1608975247, 1391201670, 1173430173, 1224348052, 59984867, 244860394, 428169201, 344873464, 935293895, 984907214, 766078933, 547512796, 1844882806, 1627235199, 2011214180, 2062270317, 1507497298, 1423022939, 1137477952, 1321699145, 95345982, 145085239, 532201772, 313773861, 830661914, 1015671571, 731183368, 648017665, 3175501286, 2957853679, 2807058932, 2858115069, 2305455554, 2220981195, 2474404304, 2658625497, 3575528878, 3625268135, 3473416636, 3254988725, 3778151818, 3963161475, 4213447064, 4130281361, 3599595085, 3683022916, 3432737375, 3247465558, 3802222185, 4020912224, 4172763771, 4122762354, 3201631749, 3017672716, 2764249623, 2848461854, 2331590177, 2280796200, 2431590963, 2648976442, 104699613, 188127444, 472615631, 287343814, 840019705, 1058709744, 671593195, 621591778, 1852171925, 1668212892, 1953757831, 2037970062, 1514790577, 1463996600, 1080017571, 1297403050, 3673637356, 3623636965, 3235995134, 3454686199, 4007360968, 3822090177, 4107101658, 4190530515, 2997825956, 3215212461, 2830708150, 2779915199, 2256734592, 2340947849, 2627016082, 2443058075, 172466556, 122466165, 273792366, 492483431, 1047239e3, 861968209, 612205898, 695634755, 1646252340, 1863638845, 2013908262, 1963115311, 1446242576, 1530455833, 1277555970, 1093597963, 1636604631, 1820824798, 2073724613, 1989249228, 1436590835, 1487645946, 1337376481, 1119727848, 164948639, 81781910, 331544205, 516552836, 1039717051, 821288114, 669961897, 719700128, 2973530695, 3157750862, 2871682645, 2787207260, 2232435299, 2283490410, 2667994737, 2450346104, 3647212047, 3564045318, 3279033885, 3464042516, 3980931627, 3762502690, 4150144569, 4199882800, 3070356634, 3121275539, 2904027272, 2686254721, 2200818878, 2384911031, 2570832044, 2486224549, 3747192018, 3528626907, 3310321856, 3359936201, 3950355702, 3867060991, 4049844452, 4234721005, 1739656202, 1790575107, 2108100632, 1890328081, 1402811438, 1586903591, 1233856572, 1149249077, 266959938, 48394827, 369057872, 418672217, 1002783846, 919489135, 567498868, 752375421, 209336225, 24197544, 376187827, 459744698, 945164165, 895287692, 574624663, 793451934, 1679968233, 1764313568, 2117360635, 1933530610, 1343127501, 1560637892, 1243112415, 1192455638, 3704280881, 3519142200, 3336358691, 3419915562, 3907448597, 3857572124, 4075877127, 4294704398, 3029510009, 3113855344, 2927934315, 2744104290, 2159976285, 2377486676, 2594734927, 2544078150];
3255         var U4 = [0, 151849742, 303699484, 454499602, 607398968, 758720310, 908999204, 1059270954, 1214797936, 1097159550, 1517440620, 1400849762, 1817998408, 1699839814, 2118541908, 2001430874, 2429595872, 2581445614, 2194319100, 2345119218, 3034881240, 3186202582, 2801699524, 2951971274, 3635996816, 3518358430, 3399679628, 3283088770, 4237083816, 4118925222, 4002861748, 3885750714, 1002142683, 850817237, 698445255, 548169417, 529487843, 377642221, 227885567, 77089521, 1943217067, 2061379749, 1640576439, 1757691577, 1474760595, 1592394909, 1174215055, 1290801793, 2875968315, 2724642869, 3111247143, 2960971305, 2405426947, 2253581325, 2638606623, 2487810577, 3808662347, 3926825029, 4044981591, 4162096729, 3342319475, 3459953789, 3576539503, 3693126241, 1986918061, 2137062819, 1685577905, 1836772287, 1381620373, 1532285339, 1078185097, 1229899655, 1040559837, 923313619, 740276417, 621982671, 439452389, 322734571, 137073913, 19308535, 3871163981, 4021308739, 4104605777, 4255800159, 3263785589, 3414450555, 3499326569, 3651041127, 2933202493, 2815956275, 3167684641, 3049390895, 2330014213, 2213296395, 2566595609, 2448830231, 1305906550, 1155237496, 1607244650, 1455525988, 1776460110, 1626319424, 2079897426, 1928707164, 96392454, 213114376, 396673818, 514443284, 562755902, 679998e3, 865136418, 983426092, 3708173718, 3557504664, 3474729866, 3323011204, 4180808110, 4030667424, 3945269170, 3794078908, 2507040230, 2623762152, 2272556026, 2390325492, 2975484382, 3092726480, 2738905026, 2857194700, 3973773121, 3856137295, 4274053469, 4157467219, 3371096953, 3252932727, 3673476453, 3556361835, 2763173681, 2915017791, 3064510765, 3215307299, 2156299017, 2307622919, 2459735317, 2610011675, 2081048481, 1963412655, 1846563261, 1729977011, 1480485785, 1362321559, 1243905413, 1126790795, 878845905, 1030690015, 645401037, 796197571, 274084841, 425408743, 38544885, 188821243, 3613494426, 3731654548, 3313212038, 3430322568, 4082475170, 4200115116, 3780097726, 3896688048, 2668221674, 2516901860, 2366882550, 2216610296, 3141400786, 2989552604, 2837966542, 2687165888, 1202797690, 1320957812, 1437280870, 1554391400, 1669664834, 1787304780, 1906247262, 2022837584, 265905162, 114585348, 499347990, 349075736, 736970802, 585122620, 972512814, 821712160, 2595684844, 2478443234, 2293045232, 2174754046, 3196267988, 3079546586, 2895723464, 2777952454, 3537852828, 3687994002, 3234156416, 3385345166, 4142626212, 4293295786, 3841024952, 3992742070, 174567692, 57326082, 410887952, 292596766, 777231668, 660510266, 1011452712, 893681702, 1108339068, 1258480242, 1343618912, 1494807662, 1715193156, 1865862730, 1948373848, 2100090966, 2701949495, 2818666809, 3004591147, 3122358053, 2235061775, 2352307457, 2535604243, 2653899549, 3915653703, 3764988233, 4219352155, 4067639125, 3444575871, 3294430577, 3746175075, 3594982253, 836553431, 953270745, 600235211, 718002117, 367585007, 484830689, 133361907, 251657213, 2041877159, 1891211689, 1806599355, 1654886325, 1568718495, 1418573201, 1335535747, 1184342925];
3256         function convertToInt32(bytes) {
3257           var result = [];
3258           for (var i3 = 0; i3 < bytes.length; i3 += 4) {
3259             result.push(
3260               bytes[i3] << 24 | bytes[i3 + 1] << 16 | bytes[i3 + 2] << 8 | bytes[i3 + 3]
3261             );
3262           }
3263           return result;
3264         }
3265         var AES = function(key) {
3266           if (!(this instanceof AES)) {
3267             throw Error("AES must be instanitated with `new`");
3268           }
3269           Object.defineProperty(this, "key", {
3270             value: coerceArray(key, true)
3271           });
3272           this._prepare();
3273         };
3274         AES.prototype._prepare = function() {
3275           var rounds = numberOfRounds[this.key.length];
3276           if (rounds == null) {
3277             throw new Error("invalid key size (must be 16, 24 or 32 bytes)");
3278           }
3279           this._Ke = [];
3280           this._Kd = [];
3281           for (var i3 = 0; i3 <= rounds; i3++) {
3282             this._Ke.push([0, 0, 0, 0]);
3283             this._Kd.push([0, 0, 0, 0]);
3284           }
3285           var roundKeyCount = (rounds + 1) * 4;
3286           var KC = this.key.length / 4;
3287           var tk = convertToInt32(this.key);
3288           var index;
3289           for (var i3 = 0; i3 < KC; i3++) {
3290             index = i3 >> 2;
3291             this._Ke[index][i3 % 4] = tk[i3];
3292             this._Kd[rounds - index][i3 % 4] = tk[i3];
3293           }
3294           var rconpointer = 0;
3295           var t2 = KC, tt2;
3296           while (t2 < roundKeyCount) {
3297             tt2 = tk[KC - 1];
3298             tk[0] ^= S2[tt2 >> 16 & 255] << 24 ^ S2[tt2 >> 8 & 255] << 16 ^ S2[tt2 & 255] << 8 ^ S2[tt2 >> 24 & 255] ^ rcon[rconpointer] << 24;
3299             rconpointer += 1;
3300             if (KC != 8) {
3301               for (var i3 = 1; i3 < KC; i3++) {
3302                 tk[i3] ^= tk[i3 - 1];
3303               }
3304             } else {
3305               for (var i3 = 1; i3 < KC / 2; i3++) {
3306                 tk[i3] ^= tk[i3 - 1];
3307               }
3308               tt2 = tk[KC / 2 - 1];
3309               tk[KC / 2] ^= S2[tt2 & 255] ^ S2[tt2 >> 8 & 255] << 8 ^ S2[tt2 >> 16 & 255] << 16 ^ S2[tt2 >> 24 & 255] << 24;
3310               for (var i3 = KC / 2 + 1; i3 < KC; i3++) {
3311                 tk[i3] ^= tk[i3 - 1];
3312               }
3313             }
3314             var i3 = 0, r2, c2;
3315             while (i3 < KC && t2 < roundKeyCount) {
3316               r2 = t2 >> 2;
3317               c2 = t2 % 4;
3318               this._Ke[r2][c2] = tk[i3];
3319               this._Kd[rounds - r2][c2] = tk[i3++];
3320               t2++;
3321             }
3322           }
3323           for (var r2 = 1; r2 < rounds; r2++) {
3324             for (var c2 = 0; c2 < 4; c2++) {
3325               tt2 = this._Kd[r2][c2];
3326               this._Kd[r2][c2] = U1[tt2 >> 24 & 255] ^ U2[tt2 >> 16 & 255] ^ U3[tt2 >> 8 & 255] ^ U4[tt2 & 255];
3327             }
3328           }
3329         };
3330         AES.prototype.encrypt = function(plaintext) {
3331           if (plaintext.length != 16) {
3332             throw new Error("invalid plaintext size (must be 16 bytes)");
3333           }
3334           var rounds = this._Ke.length - 1;
3335           var a2 = [0, 0, 0, 0];
3336           var t2 = convertToInt32(plaintext);
3337           for (var i3 = 0; i3 < 4; i3++) {
3338             t2[i3] ^= this._Ke[0][i3];
3339           }
3340           for (var r2 = 1; r2 < rounds; r2++) {
3341             for (var i3 = 0; i3 < 4; i3++) {
3342               a2[i3] = T1[t2[i3] >> 24 & 255] ^ T2[t2[(i3 + 1) % 4] >> 16 & 255] ^ T3[t2[(i3 + 2) % 4] >> 8 & 255] ^ T4[t2[(i3 + 3) % 4] & 255] ^ this._Ke[r2][i3];
3343             }
3344             t2 = a2.slice();
3345           }
3346           var result = createArray(16), tt2;
3347           for (var i3 = 0; i3 < 4; i3++) {
3348             tt2 = this._Ke[rounds][i3];
3349             result[4 * i3] = (S2[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255;
3350             result[4 * i3 + 1] = (S2[t2[(i3 + 1) % 4] >> 16 & 255] ^ tt2 >> 16) & 255;
3351             result[4 * i3 + 2] = (S2[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255;
3352             result[4 * i3 + 3] = (S2[t2[(i3 + 3) % 4] & 255] ^ tt2) & 255;
3353           }
3354           return result;
3355         };
3356         AES.prototype.decrypt = function(ciphertext) {
3357           if (ciphertext.length != 16) {
3358             throw new Error("invalid ciphertext size (must be 16 bytes)");
3359           }
3360           var rounds = this._Kd.length - 1;
3361           var a2 = [0, 0, 0, 0];
3362           var t2 = convertToInt32(ciphertext);
3363           for (var i3 = 0; i3 < 4; i3++) {
3364             t2[i3] ^= this._Kd[0][i3];
3365           }
3366           for (var r2 = 1; r2 < rounds; r2++) {
3367             for (var i3 = 0; i3 < 4; i3++) {
3368               a2[i3] = T5[t2[i3] >> 24 & 255] ^ T6[t2[(i3 + 3) % 4] >> 16 & 255] ^ T7[t2[(i3 + 2) % 4] >> 8 & 255] ^ T8[t2[(i3 + 1) % 4] & 255] ^ this._Kd[r2][i3];
3369             }
3370             t2 = a2.slice();
3371           }
3372           var result = createArray(16), tt2;
3373           for (var i3 = 0; i3 < 4; i3++) {
3374             tt2 = this._Kd[rounds][i3];
3375             result[4 * i3] = (Si[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255;
3376             result[4 * i3 + 1] = (Si[t2[(i3 + 3) % 4] >> 16 & 255] ^ tt2 >> 16) & 255;
3377             result[4 * i3 + 2] = (Si[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255;
3378             result[4 * i3 + 3] = (Si[t2[(i3 + 1) % 4] & 255] ^ tt2) & 255;
3379           }
3380           return result;
3381         };
3382         var ModeOfOperationECB = function(key) {
3383           if (!(this instanceof ModeOfOperationECB)) {
3384             throw Error("AES must be instanitated with `new`");
3385           }
3386           this.description = "Electronic Code Block";
3387           this.name = "ecb";
3388           this._aes = new AES(key);
3389         };
3390         ModeOfOperationECB.prototype.encrypt = function(plaintext) {
3391           plaintext = coerceArray(plaintext);
3392           if (plaintext.length % 16 !== 0) {
3393             throw new Error("invalid plaintext size (must be multiple of 16 bytes)");
3394           }
3395           var ciphertext = createArray(plaintext.length);
3396           var block2 = createArray(16);
3397           for (var i3 = 0; i3 < plaintext.length; i3 += 16) {
3398             copyArray(plaintext, block2, 0, i3, i3 + 16);
3399             block2 = this._aes.encrypt(block2);
3400             copyArray(block2, ciphertext, i3);
3401           }
3402           return ciphertext;
3403         };
3404         ModeOfOperationECB.prototype.decrypt = function(ciphertext) {
3405           ciphertext = coerceArray(ciphertext);
3406           if (ciphertext.length % 16 !== 0) {
3407             throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");
3408           }
3409           var plaintext = createArray(ciphertext.length);
3410           var block2 = createArray(16);
3411           for (var i3 = 0; i3 < ciphertext.length; i3 += 16) {
3412             copyArray(ciphertext, block2, 0, i3, i3 + 16);
3413             block2 = this._aes.decrypt(block2);
3414             copyArray(block2, plaintext, i3);
3415           }
3416           return plaintext;
3417         };
3418         var ModeOfOperationCBC = function(key, iv) {
3419           if (!(this instanceof ModeOfOperationCBC)) {
3420             throw Error("AES must be instanitated with `new`");
3421           }
3422           this.description = "Cipher Block Chaining";
3423           this.name = "cbc";
3424           if (!iv) {
3425             iv = createArray(16);
3426           } else if (iv.length != 16) {
3427             throw new Error("invalid initialation vector size (must be 16 bytes)");
3428           }
3429           this._lastCipherblock = coerceArray(iv, true);
3430           this._aes = new AES(key);
3431         };
3432         ModeOfOperationCBC.prototype.encrypt = function(plaintext) {
3433           plaintext = coerceArray(plaintext);
3434           if (plaintext.length % 16 !== 0) {
3435             throw new Error("invalid plaintext size (must be multiple of 16 bytes)");
3436           }
3437           var ciphertext = createArray(plaintext.length);
3438           var block2 = createArray(16);
3439           for (var i3 = 0; i3 < plaintext.length; i3 += 16) {
3440             copyArray(plaintext, block2, 0, i3, i3 + 16);
3441             for (var j2 = 0; j2 < 16; j2++) {
3442               block2[j2] ^= this._lastCipherblock[j2];
3443             }
3444             this._lastCipherblock = this._aes.encrypt(block2);
3445             copyArray(this._lastCipherblock, ciphertext, i3);
3446           }
3447           return ciphertext;
3448         };
3449         ModeOfOperationCBC.prototype.decrypt = function(ciphertext) {
3450           ciphertext = coerceArray(ciphertext);
3451           if (ciphertext.length % 16 !== 0) {
3452             throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");
3453           }
3454           var plaintext = createArray(ciphertext.length);
3455           var block2 = createArray(16);
3456           for (var i3 = 0; i3 < ciphertext.length; i3 += 16) {
3457             copyArray(ciphertext, block2, 0, i3, i3 + 16);
3458             block2 = this._aes.decrypt(block2);
3459             for (var j2 = 0; j2 < 16; j2++) {
3460               plaintext[i3 + j2] = block2[j2] ^ this._lastCipherblock[j2];
3461             }
3462             copyArray(ciphertext, this._lastCipherblock, 0, i3, i3 + 16);
3463           }
3464           return plaintext;
3465         };
3466         var ModeOfOperationCFB = function(key, iv, segmentSize) {
3467           if (!(this instanceof ModeOfOperationCFB)) {
3468             throw Error("AES must be instanitated with `new`");
3469           }
3470           this.description = "Cipher Feedback";
3471           this.name = "cfb";
3472           if (!iv) {
3473             iv = createArray(16);
3474           } else if (iv.length != 16) {
3475             throw new Error("invalid initialation vector size (must be 16 size)");
3476           }
3477           if (!segmentSize) {
3478             segmentSize = 1;
3479           }
3480           this.segmentSize = segmentSize;
3481           this._shiftRegister = coerceArray(iv, true);
3482           this._aes = new AES(key);
3483         };
3484         ModeOfOperationCFB.prototype.encrypt = function(plaintext) {
3485           if (plaintext.length % this.segmentSize != 0) {
3486             throw new Error("invalid plaintext size (must be segmentSize bytes)");
3487           }
3488           var encrypted = coerceArray(plaintext, true);
3489           var xorSegment;
3490           for (var i3 = 0; i3 < encrypted.length; i3 += this.segmentSize) {
3491             xorSegment = this._aes.encrypt(this._shiftRegister);
3492             for (var j2 = 0; j2 < this.segmentSize; j2++) {
3493               encrypted[i3 + j2] ^= xorSegment[j2];
3494             }
3495             copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
3496             copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize);
3497           }
3498           return encrypted;
3499         };
3500         ModeOfOperationCFB.prototype.decrypt = function(ciphertext) {
3501           if (ciphertext.length % this.segmentSize != 0) {
3502             throw new Error("invalid ciphertext size (must be segmentSize bytes)");
3503           }
3504           var plaintext = coerceArray(ciphertext, true);
3505           var xorSegment;
3506           for (var i3 = 0; i3 < plaintext.length; i3 += this.segmentSize) {
3507             xorSegment = this._aes.encrypt(this._shiftRegister);
3508             for (var j2 = 0; j2 < this.segmentSize; j2++) {
3509               plaintext[i3 + j2] ^= xorSegment[j2];
3510             }
3511             copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
3512             copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize);
3513           }
3514           return plaintext;
3515         };
3516         var ModeOfOperationOFB = function(key, iv) {
3517           if (!(this instanceof ModeOfOperationOFB)) {
3518             throw Error("AES must be instanitated with `new`");
3519           }
3520           this.description = "Output Feedback";
3521           this.name = "ofb";
3522           if (!iv) {
3523             iv = createArray(16);
3524           } else if (iv.length != 16) {
3525             throw new Error("invalid initialation vector size (must be 16 bytes)");
3526           }
3527           this._lastPrecipher = coerceArray(iv, true);
3528           this._lastPrecipherIndex = 16;
3529           this._aes = new AES(key);
3530         };
3531         ModeOfOperationOFB.prototype.encrypt = function(plaintext) {
3532           var encrypted = coerceArray(plaintext, true);
3533           for (var i3 = 0; i3 < encrypted.length; i3++) {
3534             if (this._lastPrecipherIndex === 16) {
3535               this._lastPrecipher = this._aes.encrypt(this._lastPrecipher);
3536               this._lastPrecipherIndex = 0;
3537             }
3538             encrypted[i3] ^= this._lastPrecipher[this._lastPrecipherIndex++];
3539           }
3540           return encrypted;
3541         };
3542         ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt;
3543         var Counter = function(initialValue) {
3544           if (!(this instanceof Counter)) {
3545             throw Error("Counter must be instanitated with `new`");
3546           }
3547           if (initialValue !== 0 && !initialValue) {
3548             initialValue = 1;
3549           }
3550           if (typeof initialValue === "number") {
3551             this._counter = createArray(16);
3552             this.setValue(initialValue);
3553           } else {
3554             this.setBytes(initialValue);
3555           }
3556         };
3557         Counter.prototype.setValue = function(value) {
3558           if (typeof value !== "number" || parseInt(value) != value) {
3559             throw new Error("invalid counter value (must be an integer)");
3560           }
3561           if (value > Number.MAX_SAFE_INTEGER) {
3562             throw new Error("integer value out of safe range");
3563           }
3564           for (var index = 15; index >= 0; --index) {
3565             this._counter[index] = value % 256;
3566             value = parseInt(value / 256);
3567           }
3568         };
3569         Counter.prototype.setBytes = function(bytes) {
3570           bytes = coerceArray(bytes, true);
3571           if (bytes.length != 16) {
3572             throw new Error("invalid counter bytes size (must be 16 bytes)");
3573           }
3574           this._counter = bytes;
3575         };
3576         Counter.prototype.increment = function() {
3577           for (var i3 = 15; i3 >= 0; i3--) {
3578             if (this._counter[i3] === 255) {
3579               this._counter[i3] = 0;
3580             } else {
3581               this._counter[i3]++;
3582               break;
3583             }
3584           }
3585         };
3586         var ModeOfOperationCTR = function(key, counter) {
3587           if (!(this instanceof ModeOfOperationCTR)) {
3588             throw Error("AES must be instanitated with `new`");
3589           }
3590           this.description = "Counter";
3591           this.name = "ctr";
3592           if (!(counter instanceof Counter)) {
3593             counter = new Counter(counter);
3594           }
3595           this._counter = counter;
3596           this._remainingCounter = null;
3597           this._remainingCounterIndex = 16;
3598           this._aes = new AES(key);
3599         };
3600         ModeOfOperationCTR.prototype.encrypt = function(plaintext) {
3601           var encrypted = coerceArray(plaintext, true);
3602           for (var i3 = 0; i3 < encrypted.length; i3++) {
3603             if (this._remainingCounterIndex === 16) {
3604               this._remainingCounter = this._aes.encrypt(this._counter._counter);
3605               this._remainingCounterIndex = 0;
3606               this._counter.increment();
3607             }
3608             encrypted[i3] ^= this._remainingCounter[this._remainingCounterIndex++];
3609           }
3610           return encrypted;
3611         };
3612         ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt;
3613         function pkcs7pad(data) {
3614           data = coerceArray(data, true);
3615           var padder = 16 - data.length % 16;
3616           var result = createArray(data.length + padder);
3617           copyArray(data, result);
3618           for (var i3 = data.length; i3 < result.length; i3++) {
3619             result[i3] = padder;
3620           }
3621           return result;
3622         }
3623         function pkcs7strip(data) {
3624           data = coerceArray(data, true);
3625           if (data.length < 16) {
3626             throw new Error("PKCS#7 invalid length");
3627           }
3628           var padder = data[data.length - 1];
3629           if (padder > 16) {
3630             throw new Error("PKCS#7 padding byte out of range");
3631           }
3632           var length2 = data.length - padder;
3633           for (var i3 = 0; i3 < padder; i3++) {
3634             if (data[length2 + i3] !== padder) {
3635               throw new Error("PKCS#7 invalid padding byte");
3636             }
3637           }
3638           var result = createArray(length2);
3639           copyArray(data, result, 0, 0, length2);
3640           return result;
3641         }
3642         var aesjs2 = {
3643           AES,
3644           Counter,
3645           ModeOfOperation: {
3646             ecb: ModeOfOperationECB,
3647             cbc: ModeOfOperationCBC,
3648             cfb: ModeOfOperationCFB,
3649             ofb: ModeOfOperationOFB,
3650             ctr: ModeOfOperationCTR
3651           },
3652           utils: {
3653             hex: convertHex,
3654             utf8: convertUtf8
3655           },
3656           padding: {
3657             pkcs7: {
3658               pad: pkcs7pad,
3659               strip: pkcs7strip
3660             }
3661           },
3662           _arrayTest: {
3663             coerceArray,
3664             createArray,
3665             copyArray
3666           }
3667         };
3668         if (typeof exports2 !== "undefined") {
3669           module2.exports = aesjs2;
3670         } else if (typeof define === "function" && define.amd) {
3671           define([], function() {
3672             return aesjs2;
3673           });
3674         } else {
3675           if (root3.aesjs) {
3676             aesjs2._aesjs = root3.aesjs;
3677           }
3678           root3.aesjs = aesjs2;
3679         }
3680       })(exports2);
3681     }
3682   });
3683
3684   // node_modules/fast-deep-equal/index.js
3685   var require_fast_deep_equal = __commonJS({
3686     "node_modules/fast-deep-equal/index.js"(exports2, module2) {
3687       "use strict";
3688       module2.exports = function equal(a2, b2) {
3689         if (a2 === b2) return true;
3690         if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
3691           if (a2.constructor !== b2.constructor) return false;
3692           var length2, i3, keys2;
3693           if (Array.isArray(a2)) {
3694             length2 = a2.length;
3695             if (length2 != b2.length) return false;
3696             for (i3 = length2; i3-- !== 0; )
3697               if (!equal(a2[i3], b2[i3])) return false;
3698             return true;
3699           }
3700           if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
3701           if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
3702           if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
3703           keys2 = Object.keys(a2);
3704           length2 = keys2.length;
3705           if (length2 !== Object.keys(b2).length) return false;
3706           for (i3 = length2; i3-- !== 0; )
3707             if (!Object.prototype.hasOwnProperty.call(b2, keys2[i3])) return false;
3708           for (i3 = length2; i3-- !== 0; ) {
3709             var key = keys2[i3];
3710             if (!equal(a2[key], b2[key])) return false;
3711           }
3712           return true;
3713         }
3714         return a2 !== a2 && b2 !== b2;
3715       };
3716     }
3717   });
3718
3719   // node_modules/lodash/lodash.js
3720   var require_lodash = __commonJS({
3721     "node_modules/lodash/lodash.js"(exports2, module2) {
3722       (function() {
3723         var undefined2;
3724         var VERSION = "4.17.21";
3725         var LARGE_ARRAY_SIZE2 = 200;
3726         var CORE_ERROR_TEXT = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", FUNC_ERROR_TEXT3 = "Expected a function", INVALID_TEMPL_VAR_ERROR_TEXT = "Invalid `variable` option passed into `_.template`";
3727         var HASH_UNDEFINED4 = "__lodash_hash_undefined__";
3728         var MAX_MEMOIZE_SIZE = 500;
3729         var PLACEHOLDER = "__lodash_placeholder__";
3730         var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
3731         var COMPARE_PARTIAL_FLAG5 = 1, COMPARE_UNORDERED_FLAG3 = 2;
3732         var WRAP_BIND_FLAG = 1, WRAP_BIND_KEY_FLAG = 2, WRAP_CURRY_BOUND_FLAG = 4, WRAP_CURRY_FLAG = 8, WRAP_CURRY_RIGHT_FLAG = 16, WRAP_PARTIAL_FLAG = 32, WRAP_PARTIAL_RIGHT_FLAG = 64, WRAP_ARY_FLAG = 128, WRAP_REARG_FLAG = 256, WRAP_FLIP_FLAG = 512;
3733         var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = "...";
3734         var HOT_COUNT = 800, HOT_SPAN = 16;
3735         var LAZY_FILTER_FLAG = 1, LAZY_MAP_FLAG = 2, LAZY_WHILE_FLAG = 3;
3736         var INFINITY2 = 1 / 0, MAX_SAFE_INTEGER4 = 9007199254740991, MAX_INTEGER = 17976931348623157e292, NAN2 = 0 / 0;
3737         var MAX_ARRAY_LENGTH = 4294967295, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
3738         var wrapFlags = [
3739           ["ary", WRAP_ARY_FLAG],
3740           ["bind", WRAP_BIND_FLAG],
3741           ["bindKey", WRAP_BIND_KEY_FLAG],
3742           ["curry", WRAP_CURRY_FLAG],
3743           ["curryRight", WRAP_CURRY_RIGHT_FLAG],
3744           ["flip", WRAP_FLIP_FLAG],
3745           ["partial", WRAP_PARTIAL_FLAG],
3746           ["partialRight", WRAP_PARTIAL_RIGHT_FLAG],
3747           ["rearg", WRAP_REARG_FLAG]
3748         ];
3749         var argsTag4 = "[object Arguments]", arrayTag3 = "[object Array]", asyncTag2 = "[object AsyncFunction]", boolTag3 = "[object Boolean]", dateTag3 = "[object Date]", domExcTag = "[object DOMException]", errorTag3 = "[object Error]", funcTag3 = "[object Function]", genTag2 = "[object GeneratorFunction]", mapTag4 = "[object Map]", numberTag4 = "[object Number]", nullTag2 = "[object Null]", objectTag4 = "[object Object]", promiseTag2 = "[object Promise]", proxyTag2 = "[object Proxy]", regexpTag3 = "[object RegExp]", setTag4 = "[object Set]", stringTag3 = "[object String]", symbolTag3 = "[object Symbol]", undefinedTag2 = "[object Undefined]", weakMapTag3 = "[object WeakMap]", weakSetTag = "[object WeakSet]";
3750         var arrayBufferTag3 = "[object ArrayBuffer]", dataViewTag4 = "[object DataView]", float32Tag2 = "[object Float32Array]", float64Tag2 = "[object Float64Array]", int8Tag2 = "[object Int8Array]", int16Tag2 = "[object Int16Array]", int32Tag2 = "[object Int32Array]", uint8Tag2 = "[object Uint8Array]", uint8ClampedTag2 = "[object Uint8ClampedArray]", uint16Tag2 = "[object Uint16Array]", uint32Tag2 = "[object Uint32Array]";
3751         var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
3752         var reEscapedHtml2 = /&(?:amp|lt|gt|quot|#39);/g, reUnescapedHtml2 = /[&<>"']/g, reHasEscapedHtml2 = RegExp(reEscapedHtml2.source), reHasUnescapedHtml2 = RegExp(reUnescapedHtml2.source);
3753         var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g;
3754         var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
3755         var reRegExpChar2 = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar2.source);
3756         var reTrimStart2 = /^\s+/;
3757         var reWhitespace2 = /\s/;
3758         var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, reSplitDetails = /,? & /;
3759         var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
3760         var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
3761         var reEscapeChar = /\\(\\)?/g;
3762         var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
3763         var reFlags = /\w*$/;
3764         var reIsBadHex2 = /^[-+]0x[0-9a-f]+$/i;
3765         var reIsBinary2 = /^0b[01]+$/i;
3766         var reIsHostCtor2 = /^\[object .+?Constructor\]$/;
3767         var reIsOctal2 = /^0o[0-7]+$/i;
3768         var reIsUint2 = /^(?:0|[1-9]\d*)$/;
3769         var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
3770         var reNoMatch = /($^)/;
3771         var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
3772         var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsDingbatRange = "\\u2700-\\u27bf", rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff", rsMathOpRange = "\\xac\\xb1\\xd7\\xf7", rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", rsPunctuationRange = "\\u2000-\\u206f", rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde", rsVarRange = "\\ufe0e\\ufe0f", rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
3773         var rsApos = "['\u2019]", rsAstral = "[" + rsAstralRange + "]", rsBreak = "[" + rsBreakRange + "]", rsCombo = "[" + rsComboRange + "]", rsDigits = "\\d+", rsDingbat = "[" + rsDingbatRange + "]", rsLower = "[" + rsLowerRange + "]", rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsUpper = "[" + rsUpperRange + "]", rsZWJ = "\\u200d";
3774         var rsMiscLower = "(?:" + rsLower + "|" + rsMisc + ")", rsMiscUpper = "(?:" + rsUpper + "|" + rsMisc + ")", rsOptContrLower = "(?:" + rsApos + "(?:d|ll|m|re|s|t|ve))?", rsOptContrUpper = "(?:" + rsApos + "(?:D|LL|M|RE|S|T|VE))?", reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*", rsOrdLower = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", rsOrdUpper = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsEmoji = "(?:" + [rsDingbat, rsRegional, rsSurrPair].join("|") + ")" + rsSeq, rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
3775         var reApos = RegExp(rsApos, "g");
3776         var reComboMark = RegExp(rsCombo, "g");
3777         var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
3778         var reUnicodeWord = RegExp([
3779           rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [rsBreak, rsUpper, "$"].join("|") + ")",
3780           rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [rsBreak, rsUpper + rsMiscLower, "$"].join("|") + ")",
3781           rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower,
3782           rsUpper + "+" + rsOptContrUpper,
3783           rsOrdUpper,
3784           rsOrdLower,
3785           rsDigits,
3786           rsEmoji
3787         ].join("|"), "g");
3788         var reHasUnicode = RegExp("[" + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + "]");
3789         var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
3790         var contextProps = [
3791           "Array",
3792           "Buffer",
3793           "DataView",
3794           "Date",
3795           "Error",
3796           "Float32Array",
3797           "Float64Array",
3798           "Function",
3799           "Int8Array",
3800           "Int16Array",
3801           "Int32Array",
3802           "Map",
3803           "Math",
3804           "Object",
3805           "Promise",
3806           "RegExp",
3807           "Set",
3808           "String",
3809           "Symbol",
3810           "TypeError",
3811           "Uint8Array",
3812           "Uint8ClampedArray",
3813           "Uint16Array",
3814           "Uint32Array",
3815           "WeakMap",
3816           "_",
3817           "clearTimeout",
3818           "isFinite",
3819           "parseInt",
3820           "setTimeout"
3821         ];
3822         var templateCounter = -1;
3823         var typedArrayTags2 = {};
3824         typedArrayTags2[float32Tag2] = typedArrayTags2[float64Tag2] = typedArrayTags2[int8Tag2] = typedArrayTags2[int16Tag2] = typedArrayTags2[int32Tag2] = typedArrayTags2[uint8Tag2] = typedArrayTags2[uint8ClampedTag2] = typedArrayTags2[uint16Tag2] = typedArrayTags2[uint32Tag2] = true;
3825         typedArrayTags2[argsTag4] = typedArrayTags2[arrayTag3] = typedArrayTags2[arrayBufferTag3] = typedArrayTags2[boolTag3] = typedArrayTags2[dataViewTag4] = typedArrayTags2[dateTag3] = typedArrayTags2[errorTag3] = typedArrayTags2[funcTag3] = typedArrayTags2[mapTag4] = typedArrayTags2[numberTag4] = typedArrayTags2[objectTag4] = typedArrayTags2[regexpTag3] = typedArrayTags2[setTag4] = typedArrayTags2[stringTag3] = typedArrayTags2[weakMapTag3] = false;
3826         var cloneableTags = {};
3827         cloneableTags[argsTag4] = cloneableTags[arrayTag3] = cloneableTags[arrayBufferTag3] = cloneableTags[dataViewTag4] = cloneableTags[boolTag3] = cloneableTags[dateTag3] = cloneableTags[float32Tag2] = cloneableTags[float64Tag2] = cloneableTags[int8Tag2] = cloneableTags[int16Tag2] = cloneableTags[int32Tag2] = cloneableTags[mapTag4] = cloneableTags[numberTag4] = cloneableTags[objectTag4] = cloneableTags[regexpTag3] = cloneableTags[setTag4] = cloneableTags[stringTag3] = cloneableTags[symbolTag3] = cloneableTags[uint8Tag2] = cloneableTags[uint8ClampedTag2] = cloneableTags[uint16Tag2] = cloneableTags[uint32Tag2] = true;
3828         cloneableTags[errorTag3] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
3829         var deburredLetters = {
3830           // Latin-1 Supplement block.
3831           "\xC0": "A",
3832           "\xC1": "A",
3833           "\xC2": "A",
3834           "\xC3": "A",
3835           "\xC4": "A",
3836           "\xC5": "A",
3837           "\xE0": "a",
3838           "\xE1": "a",
3839           "\xE2": "a",
3840           "\xE3": "a",
3841           "\xE4": "a",
3842           "\xE5": "a",
3843           "\xC7": "C",
3844           "\xE7": "c",
3845           "\xD0": "D",
3846           "\xF0": "d",
3847           "\xC8": "E",
3848           "\xC9": "E",
3849           "\xCA": "E",
3850           "\xCB": "E",
3851           "\xE8": "e",
3852           "\xE9": "e",
3853           "\xEA": "e",
3854           "\xEB": "e",
3855           "\xCC": "I",
3856           "\xCD": "I",
3857           "\xCE": "I",
3858           "\xCF": "I",
3859           "\xEC": "i",
3860           "\xED": "i",
3861           "\xEE": "i",
3862           "\xEF": "i",
3863           "\xD1": "N",
3864           "\xF1": "n",
3865           "\xD2": "O",
3866           "\xD3": "O",
3867           "\xD4": "O",
3868           "\xD5": "O",
3869           "\xD6": "O",
3870           "\xD8": "O",
3871           "\xF2": "o",
3872           "\xF3": "o",
3873           "\xF4": "o",
3874           "\xF5": "o",
3875           "\xF6": "o",
3876           "\xF8": "o",
3877           "\xD9": "U",
3878           "\xDA": "U",
3879           "\xDB": "U",
3880           "\xDC": "U",
3881           "\xF9": "u",
3882           "\xFA": "u",
3883           "\xFB": "u",
3884           "\xFC": "u",
3885           "\xDD": "Y",
3886           "\xFD": "y",
3887           "\xFF": "y",
3888           "\xC6": "Ae",
3889           "\xE6": "ae",
3890           "\xDE": "Th",
3891           "\xFE": "th",
3892           "\xDF": "ss",
3893           // Latin Extended-A block.
3894           "\u0100": "A",
3895           "\u0102": "A",
3896           "\u0104": "A",
3897           "\u0101": "a",
3898           "\u0103": "a",
3899           "\u0105": "a",
3900           "\u0106": "C",
3901           "\u0108": "C",
3902           "\u010A": "C",
3903           "\u010C": "C",
3904           "\u0107": "c",
3905           "\u0109": "c",
3906           "\u010B": "c",
3907           "\u010D": "c",
3908           "\u010E": "D",
3909           "\u0110": "D",
3910           "\u010F": "d",
3911           "\u0111": "d",
3912           "\u0112": "E",
3913           "\u0114": "E",
3914           "\u0116": "E",
3915           "\u0118": "E",
3916           "\u011A": "E",
3917           "\u0113": "e",
3918           "\u0115": "e",
3919           "\u0117": "e",
3920           "\u0119": "e",
3921           "\u011B": "e",
3922           "\u011C": "G",
3923           "\u011E": "G",
3924           "\u0120": "G",
3925           "\u0122": "G",
3926           "\u011D": "g",
3927           "\u011F": "g",
3928           "\u0121": "g",
3929           "\u0123": "g",
3930           "\u0124": "H",
3931           "\u0126": "H",
3932           "\u0125": "h",
3933           "\u0127": "h",
3934           "\u0128": "I",
3935           "\u012A": "I",
3936           "\u012C": "I",
3937           "\u012E": "I",
3938           "\u0130": "I",
3939           "\u0129": "i",
3940           "\u012B": "i",
3941           "\u012D": "i",
3942           "\u012F": "i",
3943           "\u0131": "i",
3944           "\u0134": "J",
3945           "\u0135": "j",
3946           "\u0136": "K",
3947           "\u0137": "k",
3948           "\u0138": "k",
3949           "\u0139": "L",
3950           "\u013B": "L",
3951           "\u013D": "L",
3952           "\u013F": "L",
3953           "\u0141": "L",
3954           "\u013A": "l",
3955           "\u013C": "l",
3956           "\u013E": "l",
3957           "\u0140": "l",
3958           "\u0142": "l",
3959           "\u0143": "N",
3960           "\u0145": "N",
3961           "\u0147": "N",
3962           "\u014A": "N",
3963           "\u0144": "n",
3964           "\u0146": "n",
3965           "\u0148": "n",
3966           "\u014B": "n",
3967           "\u014C": "O",
3968           "\u014E": "O",
3969           "\u0150": "O",
3970           "\u014D": "o",
3971           "\u014F": "o",
3972           "\u0151": "o",
3973           "\u0154": "R",
3974           "\u0156": "R",
3975           "\u0158": "R",
3976           "\u0155": "r",
3977           "\u0157": "r",
3978           "\u0159": "r",
3979           "\u015A": "S",
3980           "\u015C": "S",
3981           "\u015E": "S",
3982           "\u0160": "S",
3983           "\u015B": "s",
3984           "\u015D": "s",
3985           "\u015F": "s",
3986           "\u0161": "s",
3987           "\u0162": "T",
3988           "\u0164": "T",
3989           "\u0166": "T",
3990           "\u0163": "t",
3991           "\u0165": "t",
3992           "\u0167": "t",
3993           "\u0168": "U",
3994           "\u016A": "U",
3995           "\u016C": "U",
3996           "\u016E": "U",
3997           "\u0170": "U",
3998           "\u0172": "U",
3999           "\u0169": "u",
4000           "\u016B": "u",
4001           "\u016D": "u",
4002           "\u016F": "u",
4003           "\u0171": "u",
4004           "\u0173": "u",
4005           "\u0174": "W",
4006           "\u0175": "w",
4007           "\u0176": "Y",
4008           "\u0177": "y",
4009           "\u0178": "Y",
4010           "\u0179": "Z",
4011           "\u017B": "Z",
4012           "\u017D": "Z",
4013           "\u017A": "z",
4014           "\u017C": "z",
4015           "\u017E": "z",
4016           "\u0132": "IJ",
4017           "\u0133": "ij",
4018           "\u0152": "Oe",
4019           "\u0153": "oe",
4020           "\u0149": "'n",
4021           "\u017F": "s"
4022         };
4023         var htmlEscapes2 = {
4024           "&": "&amp;",
4025           "<": "&lt;",
4026           ">": "&gt;",
4027           '"': "&quot;",
4028           "'": "&#39;"
4029         };
4030         var htmlUnescapes2 = {
4031           "&amp;": "&",
4032           "&lt;": "<",
4033           "&gt;": ">",
4034           "&quot;": '"',
4035           "&#39;": "'"
4036         };
4037         var stringEscapes = {
4038           "\\": "\\",
4039           "'": "'",
4040           "\n": "n",
4041           "\r": "r",
4042           "\u2028": "u2028",
4043           "\u2029": "u2029"
4044         };
4045         var freeParseFloat = parseFloat, freeParseInt2 = parseInt;
4046         var freeGlobal2 = typeof global == "object" && global && global.Object === Object && global;
4047         var freeSelf2 = typeof self == "object" && self && self.Object === Object && self;
4048         var root3 = freeGlobal2 || freeSelf2 || Function("return this")();
4049         var freeExports3 = typeof exports2 == "object" && exports2 && !exports2.nodeType && exports2;
4050         var freeModule3 = freeExports3 && typeof module2 == "object" && module2 && !module2.nodeType && module2;
4051         var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
4052         var freeProcess2 = moduleExports3 && freeGlobal2.process;
4053         var nodeUtil2 = function() {
4054           try {
4055             var types = freeModule3 && freeModule3.require && freeModule3.require("util").types;
4056             if (types) {
4057               return types;
4058             }
4059             return freeProcess2 && freeProcess2.binding && freeProcess2.binding("util");
4060           } catch (e3) {
4061           }
4062         }();
4063         var nodeIsArrayBuffer = nodeUtil2 && nodeUtil2.isArrayBuffer, nodeIsDate = nodeUtil2 && nodeUtil2.isDate, nodeIsMap = nodeUtil2 && nodeUtil2.isMap, nodeIsRegExp = nodeUtil2 && nodeUtil2.isRegExp, nodeIsSet = nodeUtil2 && nodeUtil2.isSet, nodeIsTypedArray2 = nodeUtil2 && nodeUtil2.isTypedArray;
4064         function apply(func, thisArg, args) {
4065           switch (args.length) {
4066             case 0:
4067               return func.call(thisArg);
4068             case 1:
4069               return func.call(thisArg, args[0]);
4070             case 2:
4071               return func.call(thisArg, args[0], args[1]);
4072             case 3:
4073               return func.call(thisArg, args[0], args[1], args[2]);
4074           }
4075           return func.apply(thisArg, args);
4076         }
4077         function arrayAggregator(array2, setter, iteratee, accumulator) {
4078           var index = -1, length2 = array2 == null ? 0 : array2.length;
4079           while (++index < length2) {
4080             var value = array2[index];
4081             setter(accumulator, value, iteratee(value), array2);
4082           }
4083           return accumulator;
4084         }
4085         function arrayEach(array2, iteratee) {
4086           var index = -1, length2 = array2 == null ? 0 : array2.length;
4087           while (++index < length2) {
4088             if (iteratee(array2[index], index, array2) === false) {
4089               break;
4090             }
4091           }
4092           return array2;
4093         }
4094         function arrayEachRight(array2, iteratee) {
4095           var length2 = array2 == null ? 0 : array2.length;
4096           while (length2--) {
4097             if (iteratee(array2[length2], length2, array2) === false) {
4098               break;
4099             }
4100           }
4101           return array2;
4102         }
4103         function arrayEvery(array2, predicate) {
4104           var index = -1, length2 = array2 == null ? 0 : array2.length;
4105           while (++index < length2) {
4106             if (!predicate(array2[index], index, array2)) {
4107               return false;
4108             }
4109           }
4110           return true;
4111         }
4112         function arrayFilter2(array2, predicate) {
4113           var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
4114           while (++index < length2) {
4115             var value = array2[index];
4116             if (predicate(value, index, array2)) {
4117               result[resIndex++] = value;
4118             }
4119           }
4120           return result;
4121         }
4122         function arrayIncludes(array2, value) {
4123           var length2 = array2 == null ? 0 : array2.length;
4124           return !!length2 && baseIndexOf(array2, value, 0) > -1;
4125         }
4126         function arrayIncludesWith(array2, value, comparator) {
4127           var index = -1, length2 = array2 == null ? 0 : array2.length;
4128           while (++index < length2) {
4129             if (comparator(value, array2[index])) {
4130               return true;
4131             }
4132           }
4133           return false;
4134         }
4135         function arrayMap2(array2, iteratee) {
4136           var index = -1, length2 = array2 == null ? 0 : array2.length, result = Array(length2);
4137           while (++index < length2) {
4138             result[index] = iteratee(array2[index], index, array2);
4139           }
4140           return result;
4141         }
4142         function arrayPush2(array2, values) {
4143           var index = -1, length2 = values.length, offset = array2.length;
4144           while (++index < length2) {
4145             array2[offset + index] = values[index];
4146           }
4147           return array2;
4148         }
4149         function arrayReduce(array2, iteratee, accumulator, initAccum) {
4150           var index = -1, length2 = array2 == null ? 0 : array2.length;
4151           if (initAccum && length2) {
4152             accumulator = array2[++index];
4153           }
4154           while (++index < length2) {
4155             accumulator = iteratee(accumulator, array2[index], index, array2);
4156           }
4157           return accumulator;
4158         }
4159         function arrayReduceRight(array2, iteratee, accumulator, initAccum) {
4160           var length2 = array2 == null ? 0 : array2.length;
4161           if (initAccum && length2) {
4162             accumulator = array2[--length2];
4163           }
4164           while (length2--) {
4165             accumulator = iteratee(accumulator, array2[length2], length2, array2);
4166           }
4167           return accumulator;
4168         }
4169         function arraySome2(array2, predicate) {
4170           var index = -1, length2 = array2 == null ? 0 : array2.length;
4171           while (++index < length2) {
4172             if (predicate(array2[index], index, array2)) {
4173               return true;
4174             }
4175           }
4176           return false;
4177         }
4178         var asciiSize = baseProperty("length");
4179         function asciiToArray(string) {
4180           return string.split("");
4181         }
4182         function asciiWords(string) {
4183           return string.match(reAsciiWord) || [];
4184         }
4185         function baseFindKey(collection, predicate, eachFunc) {
4186           var result;
4187           eachFunc(collection, function(value, key, collection2) {
4188             if (predicate(value, key, collection2)) {
4189               result = key;
4190               return false;
4191             }
4192           });
4193           return result;
4194         }
4195         function baseFindIndex(array2, predicate, fromIndex, fromRight) {
4196           var length2 = array2.length, index = fromIndex + (fromRight ? 1 : -1);
4197           while (fromRight ? index-- : ++index < length2) {
4198             if (predicate(array2[index], index, array2)) {
4199               return index;
4200             }
4201           }
4202           return -1;
4203         }
4204         function baseIndexOf(array2, value, fromIndex) {
4205           return value === value ? strictIndexOf(array2, value, fromIndex) : baseFindIndex(array2, baseIsNaN, fromIndex);
4206         }
4207         function baseIndexOfWith(array2, value, fromIndex, comparator) {
4208           var index = fromIndex - 1, length2 = array2.length;
4209           while (++index < length2) {
4210             if (comparator(array2[index], value)) {
4211               return index;
4212             }
4213           }
4214           return -1;
4215         }
4216         function baseIsNaN(value) {
4217           return value !== value;
4218         }
4219         function baseMean(array2, iteratee) {
4220           var length2 = array2 == null ? 0 : array2.length;
4221           return length2 ? baseSum(array2, iteratee) / length2 : NAN2;
4222         }
4223         function baseProperty(key) {
4224           return function(object) {
4225             return object == null ? undefined2 : object[key];
4226           };
4227         }
4228         function basePropertyOf2(object) {
4229           return function(key) {
4230             return object == null ? undefined2 : object[key];
4231           };
4232         }
4233         function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
4234           eachFunc(collection, function(value, index, collection2) {
4235             accumulator = initAccum ? (initAccum = false, value) : iteratee(accumulator, value, index, collection2);
4236           });
4237           return accumulator;
4238         }
4239         function baseSortBy(array2, comparer) {
4240           var length2 = array2.length;
4241           array2.sort(comparer);
4242           while (length2--) {
4243             array2[length2] = array2[length2].value;
4244           }
4245           return array2;
4246         }
4247         function baseSum(array2, iteratee) {
4248           var result, index = -1, length2 = array2.length;
4249           while (++index < length2) {
4250             var current = iteratee(array2[index]);
4251             if (current !== undefined2) {
4252               result = result === undefined2 ? current : result + current;
4253             }
4254           }
4255           return result;
4256         }
4257         function baseTimes2(n3, iteratee) {
4258           var index = -1, result = Array(n3);
4259           while (++index < n3) {
4260             result[index] = iteratee(index);
4261           }
4262           return result;
4263         }
4264         function baseToPairs(object, props) {
4265           return arrayMap2(props, function(key) {
4266             return [key, object[key]];
4267           });
4268         }
4269         function baseTrim2(string) {
4270           return string ? string.slice(0, trimmedEndIndex2(string) + 1).replace(reTrimStart2, "") : string;
4271         }
4272         function baseUnary2(func) {
4273           return function(value) {
4274             return func(value);
4275           };
4276         }
4277         function baseValues(object, props) {
4278           return arrayMap2(props, function(key) {
4279             return object[key];
4280           });
4281         }
4282         function cacheHas2(cache, key) {
4283           return cache.has(key);
4284         }
4285         function charsStartIndex(strSymbols, chrSymbols) {
4286           var index = -1, length2 = strSymbols.length;
4287           while (++index < length2 && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {
4288           }
4289           return index;
4290         }
4291         function charsEndIndex(strSymbols, chrSymbols) {
4292           var index = strSymbols.length;
4293           while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {
4294           }
4295           return index;
4296         }
4297         function countHolders(array2, placeholder) {
4298           var length2 = array2.length, result = 0;
4299           while (length2--) {
4300             if (array2[length2] === placeholder) {
4301               ++result;
4302             }
4303           }
4304           return result;
4305         }
4306         var deburrLetter = basePropertyOf2(deburredLetters);
4307         var escapeHtmlChar2 = basePropertyOf2(htmlEscapes2);
4308         function escapeStringChar(chr) {
4309           return "\\" + stringEscapes[chr];
4310         }
4311         function getValue2(object, key) {
4312           return object == null ? undefined2 : object[key];
4313         }
4314         function hasUnicode(string) {
4315           return reHasUnicode.test(string);
4316         }
4317         function hasUnicodeWord(string) {
4318           return reHasUnicodeWord.test(string);
4319         }
4320         function iteratorToArray(iterator) {
4321           var data, result = [];
4322           while (!(data = iterator.next()).done) {
4323             result.push(data.value);
4324           }
4325           return result;
4326         }
4327         function mapToArray2(map2) {
4328           var index = -1, result = Array(map2.size);
4329           map2.forEach(function(value, key) {
4330             result[++index] = [key, value];
4331           });
4332           return result;
4333         }
4334         function overArg2(func, transform2) {
4335           return function(arg) {
4336             return func(transform2(arg));
4337           };
4338         }
4339         function replaceHolders(array2, placeholder) {
4340           var index = -1, length2 = array2.length, resIndex = 0, result = [];
4341           while (++index < length2) {
4342             var value = array2[index];
4343             if (value === placeholder || value === PLACEHOLDER) {
4344               array2[index] = PLACEHOLDER;
4345               result[resIndex++] = index;
4346             }
4347           }
4348           return result;
4349         }
4350         function setToArray2(set4) {
4351           var index = -1, result = Array(set4.size);
4352           set4.forEach(function(value) {
4353             result[++index] = value;
4354           });
4355           return result;
4356         }
4357         function setToPairs(set4) {
4358           var index = -1, result = Array(set4.size);
4359           set4.forEach(function(value) {
4360             result[++index] = [value, value];
4361           });
4362           return result;
4363         }
4364         function strictIndexOf(array2, value, fromIndex) {
4365           var index = fromIndex - 1, length2 = array2.length;
4366           while (++index < length2) {
4367             if (array2[index] === value) {
4368               return index;
4369             }
4370           }
4371           return -1;
4372         }
4373         function strictLastIndexOf(array2, value, fromIndex) {
4374           var index = fromIndex + 1;
4375           while (index--) {
4376             if (array2[index] === value) {
4377               return index;
4378             }
4379           }
4380           return index;
4381         }
4382         function stringSize(string) {
4383           return hasUnicode(string) ? unicodeSize(string) : asciiSize(string);
4384         }
4385         function stringToArray(string) {
4386           return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
4387         }
4388         function trimmedEndIndex2(string) {
4389           var index = string.length;
4390           while (index-- && reWhitespace2.test(string.charAt(index))) {
4391           }
4392           return index;
4393         }
4394         var unescapeHtmlChar2 = basePropertyOf2(htmlUnescapes2);
4395         function unicodeSize(string) {
4396           var result = reUnicode.lastIndex = 0;
4397           while (reUnicode.test(string)) {
4398             ++result;
4399           }
4400           return result;
4401         }
4402         function unicodeToArray(string) {
4403           return string.match(reUnicode) || [];
4404         }
4405         function unicodeWords(string) {
4406           return string.match(reUnicodeWord) || [];
4407         }
4408         var runInContext = function runInContext2(context) {
4409           context = context == null ? root3 : _2.defaults(root3.Object(), context, _2.pick(root3, contextProps));
4410           var Array2 = context.Array, Date2 = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String2 = context.String, TypeError2 = context.TypeError;
4411           var arrayProto2 = Array2.prototype, funcProto3 = Function2.prototype, objectProto13 = Object2.prototype;
4412           var coreJsData2 = context["__core-js_shared__"];
4413           var funcToString3 = funcProto3.toString;
4414           var hasOwnProperty10 = objectProto13.hasOwnProperty;
4415           var idCounter = 0;
4416           var maskSrcKey2 = function() {
4417             var uid = /[^.]+$/.exec(coreJsData2 && coreJsData2.keys && coreJsData2.keys.IE_PROTO || "");
4418             return uid ? "Symbol(src)_1." + uid : "";
4419           }();
4420           var nativeObjectToString3 = objectProto13.toString;
4421           var objectCtorString = funcToString3.call(Object2);
4422           var oldDash = root3._;
4423           var reIsNative2 = RegExp2(
4424             "^" + funcToString3.call(hasOwnProperty10).replace(reRegExpChar2, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
4425           );
4426           var Buffer3 = moduleExports3 ? context.Buffer : undefined2, Symbol3 = context.Symbol, Uint8Array3 = context.Uint8Array, allocUnsafe = Buffer3 ? Buffer3.allocUnsafe : undefined2, getPrototype = overArg2(Object2.getPrototypeOf, Object2), objectCreate = Object2.create, propertyIsEnumerable3 = objectProto13.propertyIsEnumerable, splice2 = arrayProto2.splice, spreadableSymbol = Symbol3 ? Symbol3.isConcatSpreadable : undefined2, symIterator = Symbol3 ? Symbol3.iterator : undefined2, symToStringTag3 = Symbol3 ? Symbol3.toStringTag : undefined2;
4427           var defineProperty = function() {
4428             try {
4429               var func = getNative2(Object2, "defineProperty");
4430               func({}, "", {});
4431               return func;
4432             } catch (e3) {
4433             }
4434           }();
4435           var ctxClearTimeout = context.clearTimeout !== root3.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root3.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root3.setTimeout && context.setTimeout;
4436           var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols2 = Object2.getOwnPropertySymbols, nativeIsBuffer2 = Buffer3 ? Buffer3.isBuffer : undefined2, nativeIsFinite = context.isFinite, nativeJoin = arrayProto2.join, nativeKeys2 = overArg2(Object2.keys, Object2), nativeMax2 = Math2.max, nativeMin2 = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto2.reverse;
4437           var DataView3 = getNative2(context, "DataView"), Map3 = getNative2(context, "Map"), Promise3 = getNative2(context, "Promise"), Set3 = getNative2(context, "Set"), WeakMap2 = getNative2(context, "WeakMap"), nativeCreate2 = getNative2(Object2, "create");
4438           var metaMap = WeakMap2 && new WeakMap2();
4439           var realNames = {};
4440           var dataViewCtorString2 = toSource2(DataView3), mapCtorString2 = toSource2(Map3), promiseCtorString2 = toSource2(Promise3), setCtorString2 = toSource2(Set3), weakMapCtorString2 = toSource2(WeakMap2);
4441           var symbolProto3 = Symbol3 ? Symbol3.prototype : undefined2, symbolValueOf2 = symbolProto3 ? symbolProto3.valueOf : undefined2, symbolToString2 = symbolProto3 ? symbolProto3.toString : undefined2;
4442           function lodash(value) {
4443             if (isObjectLike2(value) && !isArray2(value) && !(value instanceof LazyWrapper)) {
4444               if (value instanceof LodashWrapper) {
4445                 return value;
4446               }
4447               if (hasOwnProperty10.call(value, "__wrapped__")) {
4448                 return wrapperClone(value);
4449               }
4450             }
4451             return new LodashWrapper(value);
4452           }
4453           var baseCreate = /* @__PURE__ */ function() {
4454             function object() {
4455             }
4456             return function(proto) {
4457               if (!isObject2(proto)) {
4458                 return {};
4459               }
4460               if (objectCreate) {
4461                 return objectCreate(proto);
4462               }
4463               object.prototype = proto;
4464               var result2 = new object();
4465               object.prototype = undefined2;
4466               return result2;
4467             };
4468           }();
4469           function baseLodash() {
4470           }
4471           function LodashWrapper(value, chainAll) {
4472             this.__wrapped__ = value;
4473             this.__actions__ = [];
4474             this.__chain__ = !!chainAll;
4475             this.__index__ = 0;
4476             this.__values__ = undefined2;
4477           }
4478           lodash.templateSettings = {
4479             /**
4480              * Used to detect `data` property values to be HTML-escaped.
4481              *
4482              * @memberOf _.templateSettings
4483              * @type {RegExp}
4484              */
4485             "escape": reEscape,
4486             /**
4487              * Used to detect code to be evaluated.
4488              *
4489              * @memberOf _.templateSettings
4490              * @type {RegExp}
4491              */
4492             "evaluate": reEvaluate,
4493             /**
4494              * Used to detect `data` property values to inject.
4495              *
4496              * @memberOf _.templateSettings
4497              * @type {RegExp}
4498              */
4499             "interpolate": reInterpolate,
4500             /**
4501              * Used to reference the data object in the template text.
4502              *
4503              * @memberOf _.templateSettings
4504              * @type {string}
4505              */
4506             "variable": "",
4507             /**
4508              * Used to import variables into the compiled template.
4509              *
4510              * @memberOf _.templateSettings
4511              * @type {Object}
4512              */
4513             "imports": {
4514               /**
4515                * A reference to the `lodash` function.
4516                *
4517                * @memberOf _.templateSettings.imports
4518                * @type {Function}
4519                */
4520               "_": lodash
4521             }
4522           };
4523           lodash.prototype = baseLodash.prototype;
4524           lodash.prototype.constructor = lodash;
4525           LodashWrapper.prototype = baseCreate(baseLodash.prototype);
4526           LodashWrapper.prototype.constructor = LodashWrapper;
4527           function LazyWrapper(value) {
4528             this.__wrapped__ = value;
4529             this.__actions__ = [];
4530             this.__dir__ = 1;
4531             this.__filtered__ = false;
4532             this.__iteratees__ = [];
4533             this.__takeCount__ = MAX_ARRAY_LENGTH;
4534             this.__views__ = [];
4535           }
4536           function lazyClone() {
4537             var result2 = new LazyWrapper(this.__wrapped__);
4538             result2.__actions__ = copyArray(this.__actions__);
4539             result2.__dir__ = this.__dir__;
4540             result2.__filtered__ = this.__filtered__;
4541             result2.__iteratees__ = copyArray(this.__iteratees__);
4542             result2.__takeCount__ = this.__takeCount__;
4543             result2.__views__ = copyArray(this.__views__);
4544             return result2;
4545           }
4546           function lazyReverse() {
4547             if (this.__filtered__) {
4548               var result2 = new LazyWrapper(this);
4549               result2.__dir__ = -1;
4550               result2.__filtered__ = true;
4551             } else {
4552               result2 = this.clone();
4553               result2.__dir__ *= -1;
4554             }
4555             return result2;
4556           }
4557           function lazyValue() {
4558             var array2 = this.__wrapped__.value(), dir = this.__dir__, isArr = isArray2(array2), isRight = dir < 0, arrLength = isArr ? array2.length : 0, view = getView(0, arrLength, this.__views__), start2 = view.start, end = view.end, length2 = end - start2, index = isRight ? end : start2 - 1, iteratees = this.__iteratees__, iterLength = iteratees.length, resIndex = 0, takeCount = nativeMin2(length2, this.__takeCount__);
4559             if (!isArr || !isRight && arrLength == length2 && takeCount == length2) {
4560               return baseWrapperValue(array2, this.__actions__);
4561             }
4562             var result2 = [];
4563             outer:
4564               while (length2-- && resIndex < takeCount) {
4565                 index += dir;
4566                 var iterIndex = -1, value = array2[index];
4567                 while (++iterIndex < iterLength) {
4568                   var data = iteratees[iterIndex], iteratee2 = data.iteratee, type2 = data.type, computed = iteratee2(value);
4569                   if (type2 == LAZY_MAP_FLAG) {
4570                     value = computed;
4571                   } else if (!computed) {
4572                     if (type2 == LAZY_FILTER_FLAG) {
4573                       continue outer;
4574                     } else {
4575                       break outer;
4576                     }
4577                   }
4578                 }
4579                 result2[resIndex++] = value;
4580               }
4581             return result2;
4582           }
4583           LazyWrapper.prototype = baseCreate(baseLodash.prototype);
4584           LazyWrapper.prototype.constructor = LazyWrapper;
4585           function Hash2(entries) {
4586             var index = -1, length2 = entries == null ? 0 : entries.length;
4587             this.clear();
4588             while (++index < length2) {
4589               var entry = entries[index];
4590               this.set(entry[0], entry[1]);
4591             }
4592           }
4593           function hashClear2() {
4594             this.__data__ = nativeCreate2 ? nativeCreate2(null) : {};
4595             this.size = 0;
4596           }
4597           function hashDelete2(key) {
4598             var result2 = this.has(key) && delete this.__data__[key];
4599             this.size -= result2 ? 1 : 0;
4600             return result2;
4601           }
4602           function hashGet2(key) {
4603             var data = this.__data__;
4604             if (nativeCreate2) {
4605               var result2 = data[key];
4606               return result2 === HASH_UNDEFINED4 ? undefined2 : result2;
4607             }
4608             return hasOwnProperty10.call(data, key) ? data[key] : undefined2;
4609           }
4610           function hashHas2(key) {
4611             var data = this.__data__;
4612             return nativeCreate2 ? data[key] !== undefined2 : hasOwnProperty10.call(data, key);
4613           }
4614           function hashSet2(key, value) {
4615             var data = this.__data__;
4616             this.size += this.has(key) ? 0 : 1;
4617             data[key] = nativeCreate2 && value === undefined2 ? HASH_UNDEFINED4 : value;
4618             return this;
4619           }
4620           Hash2.prototype.clear = hashClear2;
4621           Hash2.prototype["delete"] = hashDelete2;
4622           Hash2.prototype.get = hashGet2;
4623           Hash2.prototype.has = hashHas2;
4624           Hash2.prototype.set = hashSet2;
4625           function ListCache2(entries) {
4626             var index = -1, length2 = entries == null ? 0 : entries.length;
4627             this.clear();
4628             while (++index < length2) {
4629               var entry = entries[index];
4630               this.set(entry[0], entry[1]);
4631             }
4632           }
4633           function listCacheClear2() {
4634             this.__data__ = [];
4635             this.size = 0;
4636           }
4637           function listCacheDelete2(key) {
4638             var data = this.__data__, index = assocIndexOf2(data, key);
4639             if (index < 0) {
4640               return false;
4641             }
4642             var lastIndex = data.length - 1;
4643             if (index == lastIndex) {
4644               data.pop();
4645             } else {
4646               splice2.call(data, index, 1);
4647             }
4648             --this.size;
4649             return true;
4650           }
4651           function listCacheGet2(key) {
4652             var data = this.__data__, index = assocIndexOf2(data, key);
4653             return index < 0 ? undefined2 : data[index][1];
4654           }
4655           function listCacheHas2(key) {
4656             return assocIndexOf2(this.__data__, key) > -1;
4657           }
4658           function listCacheSet2(key, value) {
4659             var data = this.__data__, index = assocIndexOf2(data, key);
4660             if (index < 0) {
4661               ++this.size;
4662               data.push([key, value]);
4663             } else {
4664               data[index][1] = value;
4665             }
4666             return this;
4667           }
4668           ListCache2.prototype.clear = listCacheClear2;
4669           ListCache2.prototype["delete"] = listCacheDelete2;
4670           ListCache2.prototype.get = listCacheGet2;
4671           ListCache2.prototype.has = listCacheHas2;
4672           ListCache2.prototype.set = listCacheSet2;
4673           function MapCache2(entries) {
4674             var index = -1, length2 = entries == null ? 0 : entries.length;
4675             this.clear();
4676             while (++index < length2) {
4677               var entry = entries[index];
4678               this.set(entry[0], entry[1]);
4679             }
4680           }
4681           function mapCacheClear2() {
4682             this.size = 0;
4683             this.__data__ = {
4684               "hash": new Hash2(),
4685               "map": new (Map3 || ListCache2)(),
4686               "string": new Hash2()
4687             };
4688           }
4689           function mapCacheDelete2(key) {
4690             var result2 = getMapData2(this, key)["delete"](key);
4691             this.size -= result2 ? 1 : 0;
4692             return result2;
4693           }
4694           function mapCacheGet2(key) {
4695             return getMapData2(this, key).get(key);
4696           }
4697           function mapCacheHas2(key) {
4698             return getMapData2(this, key).has(key);
4699           }
4700           function mapCacheSet2(key, value) {
4701             var data = getMapData2(this, key), size2 = data.size;
4702             data.set(key, value);
4703             this.size += data.size == size2 ? 0 : 1;
4704             return this;
4705           }
4706           MapCache2.prototype.clear = mapCacheClear2;
4707           MapCache2.prototype["delete"] = mapCacheDelete2;
4708           MapCache2.prototype.get = mapCacheGet2;
4709           MapCache2.prototype.has = mapCacheHas2;
4710           MapCache2.prototype.set = mapCacheSet2;
4711           function SetCache2(values2) {
4712             var index = -1, length2 = values2 == null ? 0 : values2.length;
4713             this.__data__ = new MapCache2();
4714             while (++index < length2) {
4715               this.add(values2[index]);
4716             }
4717           }
4718           function setCacheAdd2(value) {
4719             this.__data__.set(value, HASH_UNDEFINED4);
4720             return this;
4721           }
4722           function setCacheHas2(value) {
4723             return this.__data__.has(value);
4724           }
4725           SetCache2.prototype.add = SetCache2.prototype.push = setCacheAdd2;
4726           SetCache2.prototype.has = setCacheHas2;
4727           function Stack2(entries) {
4728             var data = this.__data__ = new ListCache2(entries);
4729             this.size = data.size;
4730           }
4731           function stackClear2() {
4732             this.__data__ = new ListCache2();
4733             this.size = 0;
4734           }
4735           function stackDelete2(key) {
4736             var data = this.__data__, result2 = data["delete"](key);
4737             this.size = data.size;
4738             return result2;
4739           }
4740           function stackGet2(key) {
4741             return this.__data__.get(key);
4742           }
4743           function stackHas2(key) {
4744             return this.__data__.has(key);
4745           }
4746           function stackSet2(key, value) {
4747             var data = this.__data__;
4748             if (data instanceof ListCache2) {
4749               var pairs2 = data.__data__;
4750               if (!Map3 || pairs2.length < LARGE_ARRAY_SIZE2 - 1) {
4751                 pairs2.push([key, value]);
4752                 this.size = ++data.size;
4753                 return this;
4754               }
4755               data = this.__data__ = new MapCache2(pairs2);
4756             }
4757             data.set(key, value);
4758             this.size = data.size;
4759             return this;
4760           }
4761           Stack2.prototype.clear = stackClear2;
4762           Stack2.prototype["delete"] = stackDelete2;
4763           Stack2.prototype.get = stackGet2;
4764           Stack2.prototype.has = stackHas2;
4765           Stack2.prototype.set = stackSet2;
4766           function arrayLikeKeys2(value, inherited) {
4767             var isArr = isArray2(value), isArg = !isArr && isArguments2(value), isBuff = !isArr && !isArg && isBuffer2(value), isType = !isArr && !isArg && !isBuff && isTypedArray2(value), skipIndexes = isArr || isArg || isBuff || isType, result2 = skipIndexes ? baseTimes2(value.length, String2) : [], length2 = result2.length;
4768             for (var key in value) {
4769               if ((inherited || hasOwnProperty10.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
4770               (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
4771               isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
4772               isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
4773               isIndex2(key, length2)))) {
4774                 result2.push(key);
4775               }
4776             }
4777             return result2;
4778           }
4779           function arraySample(array2) {
4780             var length2 = array2.length;
4781             return length2 ? array2[baseRandom(0, length2 - 1)] : undefined2;
4782           }
4783           function arraySampleSize(array2, n3) {
4784             return shuffleSelf(copyArray(array2), baseClamp(n3, 0, array2.length));
4785           }
4786           function arrayShuffle(array2) {
4787             return shuffleSelf(copyArray(array2));
4788           }
4789           function assignMergeValue(object, key, value) {
4790             if (value !== undefined2 && !eq2(object[key], value) || value === undefined2 && !(key in object)) {
4791               baseAssignValue(object, key, value);
4792             }
4793           }
4794           function assignValue(object, key, value) {
4795             var objValue = object[key];
4796             if (!(hasOwnProperty10.call(object, key) && eq2(objValue, value)) || value === undefined2 && !(key in object)) {
4797               baseAssignValue(object, key, value);
4798             }
4799           }
4800           function assocIndexOf2(array2, key) {
4801             var length2 = array2.length;
4802             while (length2--) {
4803               if (eq2(array2[length2][0], key)) {
4804                 return length2;
4805               }
4806             }
4807             return -1;
4808           }
4809           function baseAggregator(collection, setter, iteratee2, accumulator) {
4810             baseEach(collection, function(value, key, collection2) {
4811               setter(accumulator, value, iteratee2(value), collection2);
4812             });
4813             return accumulator;
4814           }
4815           function baseAssign(object, source) {
4816             return object && copyObject(source, keys2(source), object);
4817           }
4818           function baseAssignIn(object, source) {
4819             return object && copyObject(source, keysIn(source), object);
4820           }
4821           function baseAssignValue(object, key, value) {
4822             if (key == "__proto__" && defineProperty) {
4823               defineProperty(object, key, {
4824                 "configurable": true,
4825                 "enumerable": true,
4826                 "value": value,
4827                 "writable": true
4828               });
4829             } else {
4830               object[key] = value;
4831             }
4832           }
4833           function baseAt(object, paths) {
4834             var index = -1, length2 = paths.length, result2 = Array2(length2), skip = object == null;
4835             while (++index < length2) {
4836               result2[index] = skip ? undefined2 : get4(object, paths[index]);
4837             }
4838             return result2;
4839           }
4840           function baseClamp(number3, lower2, upper) {
4841             if (number3 === number3) {
4842               if (upper !== undefined2) {
4843                 number3 = number3 <= upper ? number3 : upper;
4844               }
4845               if (lower2 !== undefined2) {
4846                 number3 = number3 >= lower2 ? number3 : lower2;
4847               }
4848             }
4849             return number3;
4850           }
4851           function baseClone(value, bitmask, customizer, key, object, stack) {
4852             var result2, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
4853             if (customizer) {
4854               result2 = object ? customizer(value, key, object, stack) : customizer(value);
4855             }
4856             if (result2 !== undefined2) {
4857               return result2;
4858             }
4859             if (!isObject2(value)) {
4860               return value;
4861             }
4862             var isArr = isArray2(value);
4863             if (isArr) {
4864               result2 = initCloneArray(value);
4865               if (!isDeep) {
4866                 return copyArray(value, result2);
4867               }
4868             } else {
4869               var tag2 = getTag2(value), isFunc = tag2 == funcTag3 || tag2 == genTag2;
4870               if (isBuffer2(value)) {
4871                 return cloneBuffer(value, isDeep);
4872               }
4873               if (tag2 == objectTag4 || tag2 == argsTag4 || isFunc && !object) {
4874                 result2 = isFlat || isFunc ? {} : initCloneObject(value);
4875                 if (!isDeep) {
4876                   return isFlat ? copySymbolsIn(value, baseAssignIn(result2, value)) : copySymbols(value, baseAssign(result2, value));
4877                 }
4878               } else {
4879                 if (!cloneableTags[tag2]) {
4880                   return object ? value : {};
4881                 }
4882                 result2 = initCloneByTag(value, tag2, isDeep);
4883               }
4884             }
4885             stack || (stack = new Stack2());
4886             var stacked = stack.get(value);
4887             if (stacked) {
4888               return stacked;
4889             }
4890             stack.set(value, result2);
4891             if (isSet(value)) {
4892               value.forEach(function(subValue) {
4893                 result2.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
4894               });
4895             } else if (isMap(value)) {
4896               value.forEach(function(subValue, key2) {
4897                 result2.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
4898               });
4899             }
4900             var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys2 : isFlat ? keysIn : keys2;
4901             var props = isArr ? undefined2 : keysFunc(value);
4902             arrayEach(props || value, function(subValue, key2) {
4903               if (props) {
4904                 key2 = subValue;
4905                 subValue = value[key2];
4906               }
4907               assignValue(result2, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
4908             });
4909             return result2;
4910           }
4911           function baseConforms(source) {
4912             var props = keys2(source);
4913             return function(object) {
4914               return baseConformsTo(object, source, props);
4915             };
4916           }
4917           function baseConformsTo(object, source, props) {
4918             var length2 = props.length;
4919             if (object == null) {
4920               return !length2;
4921             }
4922             object = Object2(object);
4923             while (length2--) {
4924               var key = props[length2], predicate = source[key], value = object[key];
4925               if (value === undefined2 && !(key in object) || !predicate(value)) {
4926                 return false;
4927               }
4928             }
4929             return true;
4930           }
4931           function baseDelay(func, wait, args) {
4932             if (typeof func != "function") {
4933               throw new TypeError2(FUNC_ERROR_TEXT3);
4934             }
4935             return setTimeout2(function() {
4936               func.apply(undefined2, args);
4937             }, wait);
4938           }
4939           function baseDifference(array2, values2, iteratee2, comparator) {
4940             var index = -1, includes2 = arrayIncludes, isCommon = true, length2 = array2.length, result2 = [], valuesLength = values2.length;
4941             if (!length2) {
4942               return result2;
4943             }
4944             if (iteratee2) {
4945               values2 = arrayMap2(values2, baseUnary2(iteratee2));
4946             }
4947             if (comparator) {
4948               includes2 = arrayIncludesWith;
4949               isCommon = false;
4950             } else if (values2.length >= LARGE_ARRAY_SIZE2) {
4951               includes2 = cacheHas2;
4952               isCommon = false;
4953               values2 = new SetCache2(values2);
4954             }
4955             outer:
4956               while (++index < length2) {
4957                 var value = array2[index], computed = iteratee2 == null ? value : iteratee2(value);
4958                 value = comparator || value !== 0 ? value : 0;
4959                 if (isCommon && computed === computed) {
4960                   var valuesIndex = valuesLength;
4961                   while (valuesIndex--) {
4962                     if (values2[valuesIndex] === computed) {
4963                       continue outer;
4964                     }
4965                   }
4966                   result2.push(value);
4967                 } else if (!includes2(values2, computed, comparator)) {
4968                   result2.push(value);
4969                 }
4970               }
4971             return result2;
4972           }
4973           var baseEach = createBaseEach(baseForOwn);
4974           var baseEachRight = createBaseEach(baseForOwnRight, true);
4975           function baseEvery(collection, predicate) {
4976             var result2 = true;
4977             baseEach(collection, function(value, index, collection2) {
4978               result2 = !!predicate(value, index, collection2);
4979               return result2;
4980             });
4981             return result2;
4982           }
4983           function baseExtremum(array2, iteratee2, comparator) {
4984             var index = -1, length2 = array2.length;
4985             while (++index < length2) {
4986               var value = array2[index], current = iteratee2(value);
4987               if (current != null && (computed === undefined2 ? current === current && !isSymbol2(current) : comparator(current, computed))) {
4988                 var computed = current, result2 = value;
4989               }
4990             }
4991             return result2;
4992           }
4993           function baseFill(array2, value, start2, end) {
4994             var length2 = array2.length;
4995             start2 = toInteger(start2);
4996             if (start2 < 0) {
4997               start2 = -start2 > length2 ? 0 : length2 + start2;
4998             }
4999             end = end === undefined2 || end > length2 ? length2 : toInteger(end);
5000             if (end < 0) {
5001               end += length2;
5002             }
5003             end = start2 > end ? 0 : toLength(end);
5004             while (start2 < end) {
5005               array2[start2++] = value;
5006             }
5007             return array2;
5008           }
5009           function baseFilter(collection, predicate) {
5010             var result2 = [];
5011             baseEach(collection, function(value, index, collection2) {
5012               if (predicate(value, index, collection2)) {
5013                 result2.push(value);
5014               }
5015             });
5016             return result2;
5017           }
5018           function baseFlatten(array2, depth, predicate, isStrict, result2) {
5019             var index = -1, length2 = array2.length;
5020             predicate || (predicate = isFlattenable);
5021             result2 || (result2 = []);
5022             while (++index < length2) {
5023               var value = array2[index];
5024               if (depth > 0 && predicate(value)) {
5025                 if (depth > 1) {
5026                   baseFlatten(value, depth - 1, predicate, isStrict, result2);
5027                 } else {
5028                   arrayPush2(result2, value);
5029                 }
5030               } else if (!isStrict) {
5031                 result2[result2.length] = value;
5032               }
5033             }
5034             return result2;
5035           }
5036           var baseFor = createBaseFor();
5037           var baseForRight = createBaseFor(true);
5038           function baseForOwn(object, iteratee2) {
5039             return object && baseFor(object, iteratee2, keys2);
5040           }
5041           function baseForOwnRight(object, iteratee2) {
5042             return object && baseForRight(object, iteratee2, keys2);
5043           }
5044           function baseFunctions(object, props) {
5045             return arrayFilter2(props, function(key) {
5046               return isFunction2(object[key]);
5047             });
5048           }
5049           function baseGet(object, path) {
5050             path = castPath(path, object);
5051             var index = 0, length2 = path.length;
5052             while (object != null && index < length2) {
5053               object = object[toKey(path[index++])];
5054             }
5055             return index && index == length2 ? object : undefined2;
5056           }
5057           function baseGetAllKeys2(object, keysFunc, symbolsFunc) {
5058             var result2 = keysFunc(object);
5059             return isArray2(object) ? result2 : arrayPush2(result2, symbolsFunc(object));
5060           }
5061           function baseGetTag2(value) {
5062             if (value == null) {
5063               return value === undefined2 ? undefinedTag2 : nullTag2;
5064             }
5065             return symToStringTag3 && symToStringTag3 in Object2(value) ? getRawTag2(value) : objectToString2(value);
5066           }
5067           function baseGt(value, other2) {
5068             return value > other2;
5069           }
5070           function baseHas(object, key) {
5071             return object != null && hasOwnProperty10.call(object, key);
5072           }
5073           function baseHasIn(object, key) {
5074             return object != null && key in Object2(object);
5075           }
5076           function baseInRange(number3, start2, end) {
5077             return number3 >= nativeMin2(start2, end) && number3 < nativeMax2(start2, end);
5078           }
5079           function baseIntersection(arrays, iteratee2, comparator) {
5080             var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length2 = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array2(othLength), maxLength = Infinity, result2 = [];
5081             while (othIndex--) {
5082               var array2 = arrays[othIndex];
5083               if (othIndex && iteratee2) {
5084                 array2 = arrayMap2(array2, baseUnary2(iteratee2));
5085               }
5086               maxLength = nativeMin2(array2.length, maxLength);
5087               caches[othIndex] = !comparator && (iteratee2 || length2 >= 120 && array2.length >= 120) ? new SetCache2(othIndex && array2) : undefined2;
5088             }
5089             array2 = arrays[0];
5090             var index = -1, seen = caches[0];
5091             outer:
5092               while (++index < length2 && result2.length < maxLength) {
5093                 var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
5094                 value = comparator || value !== 0 ? value : 0;
5095                 if (!(seen ? cacheHas2(seen, computed) : includes2(result2, computed, comparator))) {
5096                   othIndex = othLength;
5097                   while (--othIndex) {
5098                     var cache = caches[othIndex];
5099                     if (!(cache ? cacheHas2(cache, computed) : includes2(arrays[othIndex], computed, comparator))) {
5100                       continue outer;
5101                     }
5102                   }
5103                   if (seen) {
5104                     seen.push(computed);
5105                   }
5106                   result2.push(value);
5107                 }
5108               }
5109             return result2;
5110           }
5111           function baseInverter(object, setter, iteratee2, accumulator) {
5112             baseForOwn(object, function(value, key, object2) {
5113               setter(accumulator, iteratee2(value), key, object2);
5114             });
5115             return accumulator;
5116           }
5117           function baseInvoke(object, path, args) {
5118             path = castPath(path, object);
5119             object = parent(object, path);
5120             var func = object == null ? object : object[toKey(last(path))];
5121             return func == null ? undefined2 : apply(func, object, args);
5122           }
5123           function baseIsArguments2(value) {
5124             return isObjectLike2(value) && baseGetTag2(value) == argsTag4;
5125           }
5126           function baseIsArrayBuffer(value) {
5127             return isObjectLike2(value) && baseGetTag2(value) == arrayBufferTag3;
5128           }
5129           function baseIsDate(value) {
5130             return isObjectLike2(value) && baseGetTag2(value) == dateTag3;
5131           }
5132           function baseIsEqual2(value, other2, bitmask, customizer, stack) {
5133             if (value === other2) {
5134               return true;
5135             }
5136             if (value == null || other2 == null || !isObjectLike2(value) && !isObjectLike2(other2)) {
5137               return value !== value && other2 !== other2;
5138             }
5139             return baseIsEqualDeep2(value, other2, bitmask, customizer, baseIsEqual2, stack);
5140           }
5141           function baseIsEqualDeep2(object, other2, bitmask, customizer, equalFunc, stack) {
5142             var objIsArr = isArray2(object), othIsArr = isArray2(other2), objTag = objIsArr ? arrayTag3 : getTag2(object), othTag = othIsArr ? arrayTag3 : getTag2(other2);
5143             objTag = objTag == argsTag4 ? objectTag4 : objTag;
5144             othTag = othTag == argsTag4 ? objectTag4 : othTag;
5145             var objIsObj = objTag == objectTag4, othIsObj = othTag == objectTag4, isSameTag = objTag == othTag;
5146             if (isSameTag && isBuffer2(object)) {
5147               if (!isBuffer2(other2)) {
5148                 return false;
5149               }
5150               objIsArr = true;
5151               objIsObj = false;
5152             }
5153             if (isSameTag && !objIsObj) {
5154               stack || (stack = new Stack2());
5155               return objIsArr || isTypedArray2(object) ? equalArrays2(object, other2, bitmask, customizer, equalFunc, stack) : equalByTag2(object, other2, objTag, bitmask, customizer, equalFunc, stack);
5156             }
5157             if (!(bitmask & COMPARE_PARTIAL_FLAG5)) {
5158               var objIsWrapped = objIsObj && hasOwnProperty10.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty10.call(other2, "__wrapped__");
5159               if (objIsWrapped || othIsWrapped) {
5160                 var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other2.value() : other2;
5161                 stack || (stack = new Stack2());
5162                 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
5163               }
5164             }
5165             if (!isSameTag) {
5166               return false;
5167             }
5168             stack || (stack = new Stack2());
5169             return equalObjects2(object, other2, bitmask, customizer, equalFunc, stack);
5170           }
5171           function baseIsMap(value) {
5172             return isObjectLike2(value) && getTag2(value) == mapTag4;
5173           }
5174           function baseIsMatch(object, source, matchData, customizer) {
5175             var index = matchData.length, length2 = index, noCustomizer = !customizer;
5176             if (object == null) {
5177               return !length2;
5178             }
5179             object = Object2(object);
5180             while (index--) {
5181               var data = matchData[index];
5182               if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
5183                 return false;
5184               }
5185             }
5186             while (++index < length2) {
5187               data = matchData[index];
5188               var key = data[0], objValue = object[key], srcValue = data[1];
5189               if (noCustomizer && data[2]) {
5190                 if (objValue === undefined2 && !(key in object)) {
5191                   return false;
5192                 }
5193               } else {
5194                 var stack = new Stack2();
5195                 if (customizer) {
5196                   var result2 = customizer(objValue, srcValue, key, object, source, stack);
5197                 }
5198                 if (!(result2 === undefined2 ? baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG5 | COMPARE_UNORDERED_FLAG3, customizer, stack) : result2)) {
5199                   return false;
5200                 }
5201               }
5202             }
5203             return true;
5204           }
5205           function baseIsNative2(value) {
5206             if (!isObject2(value) || isMasked2(value)) {
5207               return false;
5208             }
5209             var pattern = isFunction2(value) ? reIsNative2 : reIsHostCtor2;
5210             return pattern.test(toSource2(value));
5211           }
5212           function baseIsRegExp(value) {
5213             return isObjectLike2(value) && baseGetTag2(value) == regexpTag3;
5214           }
5215           function baseIsSet(value) {
5216             return isObjectLike2(value) && getTag2(value) == setTag4;
5217           }
5218           function baseIsTypedArray2(value) {
5219             return isObjectLike2(value) && isLength2(value.length) && !!typedArrayTags2[baseGetTag2(value)];
5220           }
5221           function baseIteratee(value) {
5222             if (typeof value == "function") {
5223               return value;
5224             }
5225             if (value == null) {
5226               return identity4;
5227             }
5228             if (typeof value == "object") {
5229               return isArray2(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
5230             }
5231             return property(value);
5232           }
5233           function baseKeys2(object) {
5234             if (!isPrototype2(object)) {
5235               return nativeKeys2(object);
5236             }
5237             var result2 = [];
5238             for (var key in Object2(object)) {
5239               if (hasOwnProperty10.call(object, key) && key != "constructor") {
5240                 result2.push(key);
5241               }
5242             }
5243             return result2;
5244           }
5245           function baseKeysIn(object) {
5246             if (!isObject2(object)) {
5247               return nativeKeysIn(object);
5248             }
5249             var isProto = isPrototype2(object), result2 = [];
5250             for (var key in object) {
5251               if (!(key == "constructor" && (isProto || !hasOwnProperty10.call(object, key)))) {
5252                 result2.push(key);
5253               }
5254             }
5255             return result2;
5256           }
5257           function baseLt(value, other2) {
5258             return value < other2;
5259           }
5260           function baseMap(collection, iteratee2) {
5261             var index = -1, result2 = isArrayLike2(collection) ? Array2(collection.length) : [];
5262             baseEach(collection, function(value, key, collection2) {
5263               result2[++index] = iteratee2(value, key, collection2);
5264             });
5265             return result2;
5266           }
5267           function baseMatches(source) {
5268             var matchData = getMatchData(source);
5269             if (matchData.length == 1 && matchData[0][2]) {
5270               return matchesStrictComparable(matchData[0][0], matchData[0][1]);
5271             }
5272             return function(object) {
5273               return object === source || baseIsMatch(object, source, matchData);
5274             };
5275           }
5276           function baseMatchesProperty(path, srcValue) {
5277             if (isKey(path) && isStrictComparable(srcValue)) {
5278               return matchesStrictComparable(toKey(path), srcValue);
5279             }
5280             return function(object) {
5281               var objValue = get4(object, path);
5282               return objValue === undefined2 && objValue === srcValue ? hasIn(object, path) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG5 | COMPARE_UNORDERED_FLAG3);
5283             };
5284           }
5285           function baseMerge(object, source, srcIndex, customizer, stack) {
5286             if (object === source) {
5287               return;
5288             }
5289             baseFor(source, function(srcValue, key) {
5290               stack || (stack = new Stack2());
5291               if (isObject2(srcValue)) {
5292                 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
5293               } else {
5294                 var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack) : undefined2;
5295                 if (newValue === undefined2) {
5296                   newValue = srcValue;
5297                 }
5298                 assignMergeValue(object, key, newValue);
5299               }
5300             }, keysIn);
5301           }
5302           function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
5303             var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack.get(srcValue);
5304             if (stacked) {
5305               assignMergeValue(object, key, stacked);
5306               return;
5307             }
5308             var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : undefined2;
5309             var isCommon = newValue === undefined2;
5310             if (isCommon) {
5311               var isArr = isArray2(srcValue), isBuff = !isArr && isBuffer2(srcValue), isTyped = !isArr && !isBuff && isTypedArray2(srcValue);
5312               newValue = srcValue;
5313               if (isArr || isBuff || isTyped) {
5314                 if (isArray2(objValue)) {
5315                   newValue = objValue;
5316                 } else if (isArrayLikeObject(objValue)) {
5317                   newValue = copyArray(objValue);
5318                 } else if (isBuff) {
5319                   isCommon = false;
5320                   newValue = cloneBuffer(srcValue, true);
5321                 } else if (isTyped) {
5322                   isCommon = false;
5323                   newValue = cloneTypedArray(srcValue, true);
5324                 } else {
5325                   newValue = [];
5326                 }
5327               } else if (isPlainObject(srcValue) || isArguments2(srcValue)) {
5328                 newValue = objValue;
5329                 if (isArguments2(objValue)) {
5330                   newValue = toPlainObject(objValue);
5331                 } else if (!isObject2(objValue) || isFunction2(objValue)) {
5332                   newValue = initCloneObject(srcValue);
5333                 }
5334               } else {
5335                 isCommon = false;
5336               }
5337             }
5338             if (isCommon) {
5339               stack.set(srcValue, newValue);
5340               mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
5341               stack["delete"](srcValue);
5342             }
5343             assignMergeValue(object, key, newValue);
5344           }
5345           function baseNth(array2, n3) {
5346             var length2 = array2.length;
5347             if (!length2) {
5348               return;
5349             }
5350             n3 += n3 < 0 ? length2 : 0;
5351             return isIndex2(n3, length2) ? array2[n3] : undefined2;
5352           }
5353           function baseOrderBy(collection, iteratees, orders) {
5354             if (iteratees.length) {
5355               iteratees = arrayMap2(iteratees, function(iteratee2) {
5356                 if (isArray2(iteratee2)) {
5357                   return function(value) {
5358                     return baseGet(value, iteratee2.length === 1 ? iteratee2[0] : iteratee2);
5359                   };
5360                 }
5361                 return iteratee2;
5362               });
5363             } else {
5364               iteratees = [identity4];
5365             }
5366             var index = -1;
5367             iteratees = arrayMap2(iteratees, baseUnary2(getIteratee()));
5368             var result2 = baseMap(collection, function(value, key, collection2) {
5369               var criteria = arrayMap2(iteratees, function(iteratee2) {
5370                 return iteratee2(value);
5371               });
5372               return { "criteria": criteria, "index": ++index, "value": value };
5373             });
5374             return baseSortBy(result2, function(object, other2) {
5375               return compareMultiple(object, other2, orders);
5376             });
5377           }
5378           function basePick(object, paths) {
5379             return basePickBy(object, paths, function(value, path) {
5380               return hasIn(object, path);
5381             });
5382           }
5383           function basePickBy(object, paths, predicate) {
5384             var index = -1, length2 = paths.length, result2 = {};
5385             while (++index < length2) {
5386               var path = paths[index], value = baseGet(object, path);
5387               if (predicate(value, path)) {
5388                 baseSet(result2, castPath(path, object), value);
5389               }
5390             }
5391             return result2;
5392           }
5393           function basePropertyDeep(path) {
5394             return function(object) {
5395               return baseGet(object, path);
5396             };
5397           }
5398           function basePullAll(array2, values2, iteratee2, comparator) {
5399             var indexOf2 = comparator ? baseIndexOfWith : baseIndexOf, index = -1, length2 = values2.length, seen = array2;
5400             if (array2 === values2) {
5401               values2 = copyArray(values2);
5402             }
5403             if (iteratee2) {
5404               seen = arrayMap2(array2, baseUnary2(iteratee2));
5405             }
5406             while (++index < length2) {
5407               var fromIndex = 0, value = values2[index], computed = iteratee2 ? iteratee2(value) : value;
5408               while ((fromIndex = indexOf2(seen, computed, fromIndex, comparator)) > -1) {
5409                 if (seen !== array2) {
5410                   splice2.call(seen, fromIndex, 1);
5411                 }
5412                 splice2.call(array2, fromIndex, 1);
5413               }
5414             }
5415             return array2;
5416           }
5417           function basePullAt(array2, indexes) {
5418             var length2 = array2 ? indexes.length : 0, lastIndex = length2 - 1;
5419             while (length2--) {
5420               var index = indexes[length2];
5421               if (length2 == lastIndex || index !== previous) {
5422                 var previous = index;
5423                 if (isIndex2(index)) {
5424                   splice2.call(array2, index, 1);
5425                 } else {
5426                   baseUnset(array2, index);
5427                 }
5428               }
5429             }
5430             return array2;
5431           }
5432           function baseRandom(lower2, upper) {
5433             return lower2 + nativeFloor(nativeRandom() * (upper - lower2 + 1));
5434           }
5435           function baseRange(start2, end, step, fromRight) {
5436             var index = -1, length2 = nativeMax2(nativeCeil((end - start2) / (step || 1)), 0), result2 = Array2(length2);
5437             while (length2--) {
5438               result2[fromRight ? length2 : ++index] = start2;
5439               start2 += step;
5440             }
5441             return result2;
5442           }
5443           function baseRepeat(string, n3) {
5444             var result2 = "";
5445             if (!string || n3 < 1 || n3 > MAX_SAFE_INTEGER4) {
5446               return result2;
5447             }
5448             do {
5449               if (n3 % 2) {
5450                 result2 += string;
5451               }
5452               n3 = nativeFloor(n3 / 2);
5453               if (n3) {
5454                 string += string;
5455               }
5456             } while (n3);
5457             return result2;
5458           }
5459           function baseRest(func, start2) {
5460             return setToString(overRest(func, start2, identity4), func + "");
5461           }
5462           function baseSample(collection) {
5463             return arraySample(values(collection));
5464           }
5465           function baseSampleSize(collection, n3) {
5466             var array2 = values(collection);
5467             return shuffleSelf(array2, baseClamp(n3, 0, array2.length));
5468           }
5469           function baseSet(object, path, value, customizer) {
5470             if (!isObject2(object)) {
5471               return object;
5472             }
5473             path = castPath(path, object);
5474             var index = -1, length2 = path.length, lastIndex = length2 - 1, nested = object;
5475             while (nested != null && ++index < length2) {
5476               var key = toKey(path[index]), newValue = value;
5477               if (key === "__proto__" || key === "constructor" || key === "prototype") {
5478                 return object;
5479               }
5480               if (index != lastIndex) {
5481                 var objValue = nested[key];
5482                 newValue = customizer ? customizer(objValue, key, nested) : undefined2;
5483                 if (newValue === undefined2) {
5484                   newValue = isObject2(objValue) ? objValue : isIndex2(path[index + 1]) ? [] : {};
5485                 }
5486               }
5487               assignValue(nested, key, newValue);
5488               nested = nested[key];
5489             }
5490             return object;
5491           }
5492           var baseSetData = !metaMap ? identity4 : function(func, data) {
5493             metaMap.set(func, data);
5494             return func;
5495           };
5496           var baseSetToString = !defineProperty ? identity4 : function(func, string) {
5497             return defineProperty(func, "toString", {
5498               "configurable": true,
5499               "enumerable": false,
5500               "value": constant(string),
5501               "writable": true
5502             });
5503           };
5504           function baseShuffle(collection) {
5505             return shuffleSelf(values(collection));
5506           }
5507           function baseSlice(array2, start2, end) {
5508             var index = -1, length2 = array2.length;
5509             if (start2 < 0) {
5510               start2 = -start2 > length2 ? 0 : length2 + start2;
5511             }
5512             end = end > length2 ? length2 : end;
5513             if (end < 0) {
5514               end += length2;
5515             }
5516             length2 = start2 > end ? 0 : end - start2 >>> 0;
5517             start2 >>>= 0;
5518             var result2 = Array2(length2);
5519             while (++index < length2) {
5520               result2[index] = array2[index + start2];
5521             }
5522             return result2;
5523           }
5524           function baseSome(collection, predicate) {
5525             var result2;
5526             baseEach(collection, function(value, index, collection2) {
5527               result2 = predicate(value, index, collection2);
5528               return !result2;
5529             });
5530             return !!result2;
5531           }
5532           function baseSortedIndex(array2, value, retHighest) {
5533             var low = 0, high = array2 == null ? low : array2.length;
5534             if (typeof value == "number" && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
5535               while (low < high) {
5536                 var mid = low + high >>> 1, computed = array2[mid];
5537                 if (computed !== null && !isSymbol2(computed) && (retHighest ? computed <= value : computed < value)) {
5538                   low = mid + 1;
5539                 } else {
5540                   high = mid;
5541                 }
5542               }
5543               return high;
5544             }
5545             return baseSortedIndexBy(array2, value, identity4, retHighest);
5546           }
5547           function baseSortedIndexBy(array2, value, iteratee2, retHighest) {
5548             var low = 0, high = array2 == null ? 0 : array2.length;
5549             if (high === 0) {
5550               return 0;
5551             }
5552             value = iteratee2(value);
5553             var valIsNaN = value !== value, valIsNull = value === null, valIsSymbol = isSymbol2(value), valIsUndefined = value === undefined2;
5554             while (low < high) {
5555               var mid = nativeFloor((low + high) / 2), computed = iteratee2(array2[mid]), othIsDefined = computed !== undefined2, othIsNull = computed === null, othIsReflexive = computed === computed, othIsSymbol = isSymbol2(computed);
5556               if (valIsNaN) {
5557                 var setLow = retHighest || othIsReflexive;
5558               } else if (valIsUndefined) {
5559                 setLow = othIsReflexive && (retHighest || othIsDefined);
5560               } else if (valIsNull) {
5561                 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
5562               } else if (valIsSymbol) {
5563                 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
5564               } else if (othIsNull || othIsSymbol) {
5565                 setLow = false;
5566               } else {
5567                 setLow = retHighest ? computed <= value : computed < value;
5568               }
5569               if (setLow) {
5570                 low = mid + 1;
5571               } else {
5572                 high = mid;
5573               }
5574             }
5575             return nativeMin2(high, MAX_ARRAY_INDEX);
5576           }
5577           function baseSortedUniq(array2, iteratee2) {
5578             var index = -1, length2 = array2.length, resIndex = 0, result2 = [];
5579             while (++index < length2) {
5580               var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
5581               if (!index || !eq2(computed, seen)) {
5582                 var seen = computed;
5583                 result2[resIndex++] = value === 0 ? 0 : value;
5584               }
5585             }
5586             return result2;
5587           }
5588           function baseToNumber(value) {
5589             if (typeof value == "number") {
5590               return value;
5591             }
5592             if (isSymbol2(value)) {
5593               return NAN2;
5594             }
5595             return +value;
5596           }
5597           function baseToString2(value) {
5598             if (typeof value == "string") {
5599               return value;
5600             }
5601             if (isArray2(value)) {
5602               return arrayMap2(value, baseToString2) + "";
5603             }
5604             if (isSymbol2(value)) {
5605               return symbolToString2 ? symbolToString2.call(value) : "";
5606             }
5607             var result2 = value + "";
5608             return result2 == "0" && 1 / value == -INFINITY2 ? "-0" : result2;
5609           }
5610           function baseUniq(array2, iteratee2, comparator) {
5611             var index = -1, includes2 = arrayIncludes, length2 = array2.length, isCommon = true, result2 = [], seen = result2;
5612             if (comparator) {
5613               isCommon = false;
5614               includes2 = arrayIncludesWith;
5615             } else if (length2 >= LARGE_ARRAY_SIZE2) {
5616               var set5 = iteratee2 ? null : createSet(array2);
5617               if (set5) {
5618                 return setToArray2(set5);
5619               }
5620               isCommon = false;
5621               includes2 = cacheHas2;
5622               seen = new SetCache2();
5623             } else {
5624               seen = iteratee2 ? [] : result2;
5625             }
5626             outer:
5627               while (++index < length2) {
5628                 var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
5629                 value = comparator || value !== 0 ? value : 0;
5630                 if (isCommon && computed === computed) {
5631                   var seenIndex = seen.length;
5632                   while (seenIndex--) {
5633                     if (seen[seenIndex] === computed) {
5634                       continue outer;
5635                     }
5636                   }
5637                   if (iteratee2) {
5638                     seen.push(computed);
5639                   }
5640                   result2.push(value);
5641                 } else if (!includes2(seen, computed, comparator)) {
5642                   if (seen !== result2) {
5643                     seen.push(computed);
5644                   }
5645                   result2.push(value);
5646                 }
5647               }
5648             return result2;
5649           }
5650           function baseUnset(object, path) {
5651             path = castPath(path, object);
5652             object = parent(object, path);
5653             return object == null || delete object[toKey(last(path))];
5654           }
5655           function baseUpdate(object, path, updater, customizer) {
5656             return baseSet(object, path, updater(baseGet(object, path)), customizer);
5657           }
5658           function baseWhile(array2, predicate, isDrop, fromRight) {
5659             var length2 = array2.length, index = fromRight ? length2 : -1;
5660             while ((fromRight ? index-- : ++index < length2) && predicate(array2[index], index, array2)) {
5661             }
5662             return isDrop ? baseSlice(array2, fromRight ? 0 : index, fromRight ? index + 1 : length2) : baseSlice(array2, fromRight ? index + 1 : 0, fromRight ? length2 : index);
5663           }
5664           function baseWrapperValue(value, actions) {
5665             var result2 = value;
5666             if (result2 instanceof LazyWrapper) {
5667               result2 = result2.value();
5668             }
5669             return arrayReduce(actions, function(result3, action) {
5670               return action.func.apply(action.thisArg, arrayPush2([result3], action.args));
5671             }, result2);
5672           }
5673           function baseXor(arrays, iteratee2, comparator) {
5674             var length2 = arrays.length;
5675             if (length2 < 2) {
5676               return length2 ? baseUniq(arrays[0]) : [];
5677             }
5678             var index = -1, result2 = Array2(length2);
5679             while (++index < length2) {
5680               var array2 = arrays[index], othIndex = -1;
5681               while (++othIndex < length2) {
5682                 if (othIndex != index) {
5683                   result2[index] = baseDifference(result2[index] || array2, arrays[othIndex], iteratee2, comparator);
5684                 }
5685               }
5686             }
5687             return baseUniq(baseFlatten(result2, 1), iteratee2, comparator);
5688           }
5689           function baseZipObject(props, values2, assignFunc) {
5690             var index = -1, length2 = props.length, valsLength = values2.length, result2 = {};
5691             while (++index < length2) {
5692               var value = index < valsLength ? values2[index] : undefined2;
5693               assignFunc(result2, props[index], value);
5694             }
5695             return result2;
5696           }
5697           function castArrayLikeObject(value) {
5698             return isArrayLikeObject(value) ? value : [];
5699           }
5700           function castFunction(value) {
5701             return typeof value == "function" ? value : identity4;
5702           }
5703           function castPath(value, object) {
5704             if (isArray2(value)) {
5705               return value;
5706             }
5707             return isKey(value, object) ? [value] : stringToPath(toString2(value));
5708           }
5709           var castRest = baseRest;
5710           function castSlice(array2, start2, end) {
5711             var length2 = array2.length;
5712             end = end === undefined2 ? length2 : end;
5713             return !start2 && end >= length2 ? array2 : baseSlice(array2, start2, end);
5714           }
5715           var clearTimeout2 = ctxClearTimeout || function(id2) {
5716             return root3.clearTimeout(id2);
5717           };
5718           function cloneBuffer(buffer, isDeep) {
5719             if (isDeep) {
5720               return buffer.slice();
5721             }
5722             var length2 = buffer.length, result2 = allocUnsafe ? allocUnsafe(length2) : new buffer.constructor(length2);
5723             buffer.copy(result2);
5724             return result2;
5725           }
5726           function cloneArrayBuffer(arrayBuffer) {
5727             var result2 = new arrayBuffer.constructor(arrayBuffer.byteLength);
5728             new Uint8Array3(result2).set(new Uint8Array3(arrayBuffer));
5729             return result2;
5730           }
5731           function cloneDataView(dataView, isDeep) {
5732             var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
5733             return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
5734           }
5735           function cloneRegExp(regexp) {
5736             var result2 = new regexp.constructor(regexp.source, reFlags.exec(regexp));
5737             result2.lastIndex = regexp.lastIndex;
5738             return result2;
5739           }
5740           function cloneSymbol(symbol) {
5741             return symbolValueOf2 ? Object2(symbolValueOf2.call(symbol)) : {};
5742           }
5743           function cloneTypedArray(typedArray, isDeep) {
5744             var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
5745             return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
5746           }
5747           function compareAscending(value, other2) {
5748             if (value !== other2) {
5749               var valIsDefined = value !== undefined2, valIsNull = value === null, valIsReflexive = value === value, valIsSymbol = isSymbol2(value);
5750               var othIsDefined = other2 !== undefined2, othIsNull = other2 === null, othIsReflexive = other2 === other2, othIsSymbol = isSymbol2(other2);
5751               if (!othIsNull && !othIsSymbol && !valIsSymbol && value > other2 || valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol || valIsNull && othIsDefined && othIsReflexive || !valIsDefined && othIsReflexive || !valIsReflexive) {
5752                 return 1;
5753               }
5754               if (!valIsNull && !valIsSymbol && !othIsSymbol && value < other2 || othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol || othIsNull && valIsDefined && valIsReflexive || !othIsDefined && valIsReflexive || !othIsReflexive) {
5755                 return -1;
5756               }
5757             }
5758             return 0;
5759           }
5760           function compareMultiple(object, other2, orders) {
5761             var index = -1, objCriteria = object.criteria, othCriteria = other2.criteria, length2 = objCriteria.length, ordersLength = orders.length;
5762             while (++index < length2) {
5763               var result2 = compareAscending(objCriteria[index], othCriteria[index]);
5764               if (result2) {
5765                 if (index >= ordersLength) {
5766                   return result2;
5767                 }
5768                 var order = orders[index];
5769                 return result2 * (order == "desc" ? -1 : 1);
5770               }
5771             }
5772             return object.index - other2.index;
5773           }
5774           function composeArgs(args, partials, holders, isCurried) {
5775             var argsIndex = -1, argsLength = args.length, holdersLength = holders.length, leftIndex = -1, leftLength = partials.length, rangeLength = nativeMax2(argsLength - holdersLength, 0), result2 = Array2(leftLength + rangeLength), isUncurried = !isCurried;
5776             while (++leftIndex < leftLength) {
5777               result2[leftIndex] = partials[leftIndex];
5778             }
5779             while (++argsIndex < holdersLength) {
5780               if (isUncurried || argsIndex < argsLength) {
5781                 result2[holders[argsIndex]] = args[argsIndex];
5782               }
5783             }
5784             while (rangeLength--) {
5785               result2[leftIndex++] = args[argsIndex++];
5786             }
5787             return result2;
5788           }
5789           function composeArgsRight(args, partials, holders, isCurried) {
5790             var argsIndex = -1, argsLength = args.length, holdersIndex = -1, holdersLength = holders.length, rightIndex = -1, rightLength = partials.length, rangeLength = nativeMax2(argsLength - holdersLength, 0), result2 = Array2(rangeLength + rightLength), isUncurried = !isCurried;
5791             while (++argsIndex < rangeLength) {
5792               result2[argsIndex] = args[argsIndex];
5793             }
5794             var offset = argsIndex;
5795             while (++rightIndex < rightLength) {
5796               result2[offset + rightIndex] = partials[rightIndex];
5797             }
5798             while (++holdersIndex < holdersLength) {
5799               if (isUncurried || argsIndex < argsLength) {
5800                 result2[offset + holders[holdersIndex]] = args[argsIndex++];
5801               }
5802             }
5803             return result2;
5804           }
5805           function copyArray(source, array2) {
5806             var index = -1, length2 = source.length;
5807             array2 || (array2 = Array2(length2));
5808             while (++index < length2) {
5809               array2[index] = source[index];
5810             }
5811             return array2;
5812           }
5813           function copyObject(source, props, object, customizer) {
5814             var isNew = !object;
5815             object || (object = {});
5816             var index = -1, length2 = props.length;
5817             while (++index < length2) {
5818               var key = props[index];
5819               var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined2;
5820               if (newValue === undefined2) {
5821                 newValue = source[key];
5822               }
5823               if (isNew) {
5824                 baseAssignValue(object, key, newValue);
5825               } else {
5826                 assignValue(object, key, newValue);
5827               }
5828             }
5829             return object;
5830           }
5831           function copySymbols(source, object) {
5832             return copyObject(source, getSymbols2(source), object);
5833           }
5834           function copySymbolsIn(source, object) {
5835             return copyObject(source, getSymbolsIn(source), object);
5836           }
5837           function createAggregator(setter, initializer) {
5838             return function(collection, iteratee2) {
5839               var func = isArray2(collection) ? arrayAggregator : baseAggregator, accumulator = initializer ? initializer() : {};
5840               return func(collection, setter, getIteratee(iteratee2, 2), accumulator);
5841             };
5842           }
5843           function createAssigner(assigner) {
5844             return baseRest(function(object, sources) {
5845               var index = -1, length2 = sources.length, customizer = length2 > 1 ? sources[length2 - 1] : undefined2, guard = length2 > 2 ? sources[2] : undefined2;
5846               customizer = assigner.length > 3 && typeof customizer == "function" ? (length2--, customizer) : undefined2;
5847               if (guard && isIterateeCall(sources[0], sources[1], guard)) {
5848                 customizer = length2 < 3 ? undefined2 : customizer;
5849                 length2 = 1;
5850               }
5851               object = Object2(object);
5852               while (++index < length2) {
5853                 var source = sources[index];
5854                 if (source) {
5855                   assigner(object, source, index, customizer);
5856                 }
5857               }
5858               return object;
5859             });
5860           }
5861           function createBaseEach(eachFunc, fromRight) {
5862             return function(collection, iteratee2) {
5863               if (collection == null) {
5864                 return collection;
5865               }
5866               if (!isArrayLike2(collection)) {
5867                 return eachFunc(collection, iteratee2);
5868               }
5869               var length2 = collection.length, index = fromRight ? length2 : -1, iterable = Object2(collection);
5870               while (fromRight ? index-- : ++index < length2) {
5871                 if (iteratee2(iterable[index], index, iterable) === false) {
5872                   break;
5873                 }
5874               }
5875               return collection;
5876             };
5877           }
5878           function createBaseFor(fromRight) {
5879             return function(object, iteratee2, keysFunc) {
5880               var index = -1, iterable = Object2(object), props = keysFunc(object), length2 = props.length;
5881               while (length2--) {
5882                 var key = props[fromRight ? length2 : ++index];
5883                 if (iteratee2(iterable[key], key, iterable) === false) {
5884                   break;
5885                 }
5886               }
5887               return object;
5888             };
5889           }
5890           function createBind(func, bitmask, thisArg) {
5891             var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
5892             function wrapper() {
5893               var fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
5894               return fn.apply(isBind ? thisArg : this, arguments);
5895             }
5896             return wrapper;
5897           }
5898           function createCaseFirst(methodName) {
5899             return function(string) {
5900               string = toString2(string);
5901               var strSymbols = hasUnicode(string) ? stringToArray(string) : undefined2;
5902               var chr = strSymbols ? strSymbols[0] : string.charAt(0);
5903               var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string.slice(1);
5904               return chr[methodName]() + trailing;
5905             };
5906           }
5907           function createCompounder(callback) {
5908             return function(string) {
5909               return arrayReduce(words(deburr(string).replace(reApos, "")), callback, "");
5910             };
5911           }
5912           function createCtor(Ctor) {
5913             return function() {
5914               var args = arguments;
5915               switch (args.length) {
5916                 case 0:
5917                   return new Ctor();
5918                 case 1:
5919                   return new Ctor(args[0]);
5920                 case 2:
5921                   return new Ctor(args[0], args[1]);
5922                 case 3:
5923                   return new Ctor(args[0], args[1], args[2]);
5924                 case 4:
5925                   return new Ctor(args[0], args[1], args[2], args[3]);
5926                 case 5:
5927                   return new Ctor(args[0], args[1], args[2], args[3], args[4]);
5928                 case 6:
5929                   return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
5930                 case 7:
5931                   return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
5932               }
5933               var thisBinding = baseCreate(Ctor.prototype), result2 = Ctor.apply(thisBinding, args);
5934               return isObject2(result2) ? result2 : thisBinding;
5935             };
5936           }
5937           function createCurry(func, bitmask, arity) {
5938             var Ctor = createCtor(func);
5939             function wrapper() {
5940               var length2 = arguments.length, args = Array2(length2), index = length2, placeholder = getHolder(wrapper);
5941               while (index--) {
5942                 args[index] = arguments[index];
5943               }
5944               var holders = length2 < 3 && args[0] !== placeholder && args[length2 - 1] !== placeholder ? [] : replaceHolders(args, placeholder);
5945               length2 -= holders.length;
5946               if (length2 < arity) {
5947                 return createRecurry(
5948                   func,
5949                   bitmask,
5950                   createHybrid,
5951                   wrapper.placeholder,
5952                   undefined2,
5953                   args,
5954                   holders,
5955                   undefined2,
5956                   undefined2,
5957                   arity - length2
5958                 );
5959               }
5960               var fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
5961               return apply(fn, this, args);
5962             }
5963             return wrapper;
5964           }
5965           function createFind(findIndexFunc) {
5966             return function(collection, predicate, fromIndex) {
5967               var iterable = Object2(collection);
5968               if (!isArrayLike2(collection)) {
5969                 var iteratee2 = getIteratee(predicate, 3);
5970                 collection = keys2(collection);
5971                 predicate = function(key) {
5972                   return iteratee2(iterable[key], key, iterable);
5973                 };
5974               }
5975               var index = findIndexFunc(collection, predicate, fromIndex);
5976               return index > -1 ? iterable[iteratee2 ? collection[index] : index] : undefined2;
5977             };
5978           }
5979           function createFlow(fromRight) {
5980             return flatRest(function(funcs) {
5981               var length2 = funcs.length, index = length2, prereq = LodashWrapper.prototype.thru;
5982               if (fromRight) {
5983                 funcs.reverse();
5984               }
5985               while (index--) {
5986                 var func = funcs[index];
5987                 if (typeof func != "function") {
5988                   throw new TypeError2(FUNC_ERROR_TEXT3);
5989                 }
5990                 if (prereq && !wrapper && getFuncName(func) == "wrapper") {
5991                   var wrapper = new LodashWrapper([], true);
5992                 }
5993               }
5994               index = wrapper ? index : length2;
5995               while (++index < length2) {
5996                 func = funcs[index];
5997                 var funcName = getFuncName(func), data = funcName == "wrapper" ? getData(func) : undefined2;
5998                 if (data && isLaziable(data[0]) && data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && !data[4].length && data[9] == 1) {
5999                   wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
6000                 } else {
6001                   wrapper = func.length == 1 && isLaziable(func) ? wrapper[funcName]() : wrapper.thru(func);
6002                 }
6003               }
6004               return function() {
6005                 var args = arguments, value = args[0];
6006                 if (wrapper && args.length == 1 && isArray2(value)) {
6007                   return wrapper.plant(value).value();
6008                 }
6009                 var index2 = 0, result2 = length2 ? funcs[index2].apply(this, args) : value;
6010                 while (++index2 < length2) {
6011                   result2 = funcs[index2].call(this, result2);
6012                 }
6013                 return result2;
6014               };
6015             });
6016           }
6017           function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary2, arity) {
6018             var isAry = bitmask & WRAP_ARY_FLAG, isBind = bitmask & WRAP_BIND_FLAG, isBindKey = bitmask & WRAP_BIND_KEY_FLAG, isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), isFlip = bitmask & WRAP_FLIP_FLAG, Ctor = isBindKey ? undefined2 : createCtor(func);
6019             function wrapper() {
6020               var length2 = arguments.length, args = Array2(length2), index = length2;
6021               while (index--) {
6022                 args[index] = arguments[index];
6023               }
6024               if (isCurried) {
6025                 var placeholder = getHolder(wrapper), holdersCount = countHolders(args, placeholder);
6026               }
6027               if (partials) {
6028                 args = composeArgs(args, partials, holders, isCurried);
6029               }
6030               if (partialsRight) {
6031                 args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
6032               }
6033               length2 -= holdersCount;
6034               if (isCurried && length2 < arity) {
6035                 var newHolders = replaceHolders(args, placeholder);
6036                 return createRecurry(
6037                   func,
6038                   bitmask,
6039                   createHybrid,
6040                   wrapper.placeholder,
6041                   thisArg,
6042                   args,
6043                   newHolders,
6044                   argPos,
6045                   ary2,
6046                   arity - length2
6047                 );
6048               }
6049               var thisBinding = isBind ? thisArg : this, fn = isBindKey ? thisBinding[func] : func;
6050               length2 = args.length;
6051               if (argPos) {
6052                 args = reorder(args, argPos);
6053               } else if (isFlip && length2 > 1) {
6054                 args.reverse();
6055               }
6056               if (isAry && ary2 < length2) {
6057                 args.length = ary2;
6058               }
6059               if (this && this !== root3 && this instanceof wrapper) {
6060                 fn = Ctor || createCtor(fn);
6061               }
6062               return fn.apply(thisBinding, args);
6063             }
6064             return wrapper;
6065           }
6066           function createInverter(setter, toIteratee) {
6067             return function(object, iteratee2) {
6068               return baseInverter(object, setter, toIteratee(iteratee2), {});
6069             };
6070           }
6071           function createMathOperation(operator, defaultValue) {
6072             return function(value, other2) {
6073               var result2;
6074               if (value === undefined2 && other2 === undefined2) {
6075                 return defaultValue;
6076               }
6077               if (value !== undefined2) {
6078                 result2 = value;
6079               }
6080               if (other2 !== undefined2) {
6081                 if (result2 === undefined2) {
6082                   return other2;
6083                 }
6084                 if (typeof value == "string" || typeof other2 == "string") {
6085                   value = baseToString2(value);
6086                   other2 = baseToString2(other2);
6087                 } else {
6088                   value = baseToNumber(value);
6089                   other2 = baseToNumber(other2);
6090                 }
6091                 result2 = operator(value, other2);
6092               }
6093               return result2;
6094             };
6095           }
6096           function createOver(arrayFunc) {
6097             return flatRest(function(iteratees) {
6098               iteratees = arrayMap2(iteratees, baseUnary2(getIteratee()));
6099               return baseRest(function(args) {
6100                 var thisArg = this;
6101                 return arrayFunc(iteratees, function(iteratee2) {
6102                   return apply(iteratee2, thisArg, args);
6103                 });
6104               });
6105             });
6106           }
6107           function createPadding(length2, chars) {
6108             chars = chars === undefined2 ? " " : baseToString2(chars);
6109             var charsLength = chars.length;
6110             if (charsLength < 2) {
6111               return charsLength ? baseRepeat(chars, length2) : chars;
6112             }
6113             var result2 = baseRepeat(chars, nativeCeil(length2 / stringSize(chars)));
6114             return hasUnicode(chars) ? castSlice(stringToArray(result2), 0, length2).join("") : result2.slice(0, length2);
6115           }
6116           function createPartial(func, bitmask, thisArg, partials) {
6117             var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
6118             function wrapper() {
6119               var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array2(leftLength + argsLength), fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
6120               while (++leftIndex < leftLength) {
6121                 args[leftIndex] = partials[leftIndex];
6122               }
6123               while (argsLength--) {
6124                 args[leftIndex++] = arguments[++argsIndex];
6125               }
6126               return apply(fn, isBind ? thisArg : this, args);
6127             }
6128             return wrapper;
6129           }
6130           function createRange(fromRight) {
6131             return function(start2, end, step) {
6132               if (step && typeof step != "number" && isIterateeCall(start2, end, step)) {
6133                 end = step = undefined2;
6134               }
6135               start2 = toFinite(start2);
6136               if (end === undefined2) {
6137                 end = start2;
6138                 start2 = 0;
6139               } else {
6140                 end = toFinite(end);
6141               }
6142               step = step === undefined2 ? start2 < end ? 1 : -1 : toFinite(step);
6143               return baseRange(start2, end, step, fromRight);
6144             };
6145           }
6146           function createRelationalOperation(operator) {
6147             return function(value, other2) {
6148               if (!(typeof value == "string" && typeof other2 == "string")) {
6149                 value = toNumber3(value);
6150                 other2 = toNumber3(other2);
6151               }
6152               return operator(value, other2);
6153             };
6154           }
6155           function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary2, arity) {
6156             var isCurry = bitmask & WRAP_CURRY_FLAG, newHolders = isCurry ? holders : undefined2, newHoldersRight = isCurry ? undefined2 : holders, newPartials = isCurry ? partials : undefined2, newPartialsRight = isCurry ? undefined2 : partials;
6157             bitmask |= isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG;
6158             bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
6159             if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
6160               bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
6161             }
6162             var newData = [
6163               func,
6164               bitmask,
6165               thisArg,
6166               newPartials,
6167               newHolders,
6168               newPartialsRight,
6169               newHoldersRight,
6170               argPos,
6171               ary2,
6172               arity
6173             ];
6174             var result2 = wrapFunc.apply(undefined2, newData);
6175             if (isLaziable(func)) {
6176               setData(result2, newData);
6177             }
6178             result2.placeholder = placeholder;
6179             return setWrapToString(result2, func, bitmask);
6180           }
6181           function createRound(methodName) {
6182             var func = Math2[methodName];
6183             return function(number3, precision3) {
6184               number3 = toNumber3(number3);
6185               precision3 = precision3 == null ? 0 : nativeMin2(toInteger(precision3), 292);
6186               if (precision3 && nativeIsFinite(number3)) {
6187                 var pair3 = (toString2(number3) + "e").split("e"), value = func(pair3[0] + "e" + (+pair3[1] + precision3));
6188                 pair3 = (toString2(value) + "e").split("e");
6189                 return +(pair3[0] + "e" + (+pair3[1] - precision3));
6190               }
6191               return func(number3);
6192             };
6193           }
6194           var createSet = !(Set3 && 1 / setToArray2(new Set3([, -0]))[1] == INFINITY2) ? noop3 : function(values2) {
6195             return new Set3(values2);
6196           };
6197           function createToPairs(keysFunc) {
6198             return function(object) {
6199               var tag2 = getTag2(object);
6200               if (tag2 == mapTag4) {
6201                 return mapToArray2(object);
6202               }
6203               if (tag2 == setTag4) {
6204                 return setToPairs(object);
6205               }
6206               return baseToPairs(object, keysFunc(object));
6207             };
6208           }
6209           function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary2, arity) {
6210             var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
6211             if (!isBindKey && typeof func != "function") {
6212               throw new TypeError2(FUNC_ERROR_TEXT3);
6213             }
6214             var length2 = partials ? partials.length : 0;
6215             if (!length2) {
6216               bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
6217               partials = holders = undefined2;
6218             }
6219             ary2 = ary2 === undefined2 ? ary2 : nativeMax2(toInteger(ary2), 0);
6220             arity = arity === undefined2 ? arity : toInteger(arity);
6221             length2 -= holders ? holders.length : 0;
6222             if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
6223               var partialsRight = partials, holdersRight = holders;
6224               partials = holders = undefined2;
6225             }
6226             var data = isBindKey ? undefined2 : getData(func);
6227             var newData = [
6228               func,
6229               bitmask,
6230               thisArg,
6231               partials,
6232               holders,
6233               partialsRight,
6234               holdersRight,
6235               argPos,
6236               ary2,
6237               arity
6238             ];
6239             if (data) {
6240               mergeData(newData, data);
6241             }
6242             func = newData[0];
6243             bitmask = newData[1];
6244             thisArg = newData[2];
6245             partials = newData[3];
6246             holders = newData[4];
6247             arity = newData[9] = newData[9] === undefined2 ? isBindKey ? 0 : func.length : nativeMax2(newData[9] - length2, 0);
6248             if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
6249               bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
6250             }
6251             if (!bitmask || bitmask == WRAP_BIND_FLAG) {
6252               var result2 = createBind(func, bitmask, thisArg);
6253             } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
6254               result2 = createCurry(func, bitmask, arity);
6255             } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
6256               result2 = createPartial(func, bitmask, thisArg, partials);
6257             } else {
6258               result2 = createHybrid.apply(undefined2, newData);
6259             }
6260             var setter = data ? baseSetData : setData;
6261             return setWrapToString(setter(result2, newData), func, bitmask);
6262           }
6263           function customDefaultsAssignIn(objValue, srcValue, key, object) {
6264             if (objValue === undefined2 || eq2(objValue, objectProto13[key]) && !hasOwnProperty10.call(object, key)) {
6265               return srcValue;
6266             }
6267             return objValue;
6268           }
6269           function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
6270             if (isObject2(objValue) && isObject2(srcValue)) {
6271               stack.set(srcValue, objValue);
6272               baseMerge(objValue, srcValue, undefined2, customDefaultsMerge, stack);
6273               stack["delete"](srcValue);
6274             }
6275             return objValue;
6276           }
6277           function customOmitClone(value) {
6278             return isPlainObject(value) ? undefined2 : value;
6279           }
6280           function equalArrays2(array2, other2, bitmask, customizer, equalFunc, stack) {
6281             var isPartial = bitmask & COMPARE_PARTIAL_FLAG5, arrLength = array2.length, othLength = other2.length;
6282             if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
6283               return false;
6284             }
6285             var arrStacked = stack.get(array2);
6286             var othStacked = stack.get(other2);
6287             if (arrStacked && othStacked) {
6288               return arrStacked == other2 && othStacked == array2;
6289             }
6290             var index = -1, result2 = true, seen = bitmask & COMPARE_UNORDERED_FLAG3 ? new SetCache2() : undefined2;
6291             stack.set(array2, other2);
6292             stack.set(other2, array2);
6293             while (++index < arrLength) {
6294               var arrValue = array2[index], othValue = other2[index];
6295               if (customizer) {
6296                 var compared = isPartial ? customizer(othValue, arrValue, index, other2, array2, stack) : customizer(arrValue, othValue, index, array2, other2, stack);
6297               }
6298               if (compared !== undefined2) {
6299                 if (compared) {
6300                   continue;
6301                 }
6302                 result2 = false;
6303                 break;
6304               }
6305               if (seen) {
6306                 if (!arraySome2(other2, function(othValue2, othIndex) {
6307                   if (!cacheHas2(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
6308                     return seen.push(othIndex);
6309                   }
6310                 })) {
6311                   result2 = false;
6312                   break;
6313                 }
6314               } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
6315                 result2 = false;
6316                 break;
6317               }
6318             }
6319             stack["delete"](array2);
6320             stack["delete"](other2);
6321             return result2;
6322           }
6323           function equalByTag2(object, other2, tag2, bitmask, customizer, equalFunc, stack) {
6324             switch (tag2) {
6325               case dataViewTag4:
6326                 if (object.byteLength != other2.byteLength || object.byteOffset != other2.byteOffset) {
6327                   return false;
6328                 }
6329                 object = object.buffer;
6330                 other2 = other2.buffer;
6331               case arrayBufferTag3:
6332                 if (object.byteLength != other2.byteLength || !equalFunc(new Uint8Array3(object), new Uint8Array3(other2))) {
6333                   return false;
6334                 }
6335                 return true;
6336               case boolTag3:
6337               case dateTag3:
6338               case numberTag4:
6339                 return eq2(+object, +other2);
6340               case errorTag3:
6341                 return object.name == other2.name && object.message == other2.message;
6342               case regexpTag3:
6343               case stringTag3:
6344                 return object == other2 + "";
6345               case mapTag4:
6346                 var convert = mapToArray2;
6347               case setTag4:
6348                 var isPartial = bitmask & COMPARE_PARTIAL_FLAG5;
6349                 convert || (convert = setToArray2);
6350                 if (object.size != other2.size && !isPartial) {
6351                   return false;
6352                 }
6353                 var stacked = stack.get(object);
6354                 if (stacked) {
6355                   return stacked == other2;
6356                 }
6357                 bitmask |= COMPARE_UNORDERED_FLAG3;
6358                 stack.set(object, other2);
6359                 var result2 = equalArrays2(convert(object), convert(other2), bitmask, customizer, equalFunc, stack);
6360                 stack["delete"](object);
6361                 return result2;
6362               case symbolTag3:
6363                 if (symbolValueOf2) {
6364                   return symbolValueOf2.call(object) == symbolValueOf2.call(other2);
6365                 }
6366             }
6367             return false;
6368           }
6369           function equalObjects2(object, other2, bitmask, customizer, equalFunc, stack) {
6370             var isPartial = bitmask & COMPARE_PARTIAL_FLAG5, objProps = getAllKeys2(object), objLength = objProps.length, othProps = getAllKeys2(other2), othLength = othProps.length;
6371             if (objLength != othLength && !isPartial) {
6372               return false;
6373             }
6374             var index = objLength;
6375             while (index--) {
6376               var key = objProps[index];
6377               if (!(isPartial ? key in other2 : hasOwnProperty10.call(other2, key))) {
6378                 return false;
6379               }
6380             }
6381             var objStacked = stack.get(object);
6382             var othStacked = stack.get(other2);
6383             if (objStacked && othStacked) {
6384               return objStacked == other2 && othStacked == object;
6385             }
6386             var result2 = true;
6387             stack.set(object, other2);
6388             stack.set(other2, object);
6389             var skipCtor = isPartial;
6390             while (++index < objLength) {
6391               key = objProps[index];
6392               var objValue = object[key], othValue = other2[key];
6393               if (customizer) {
6394                 var compared = isPartial ? customizer(othValue, objValue, key, other2, object, stack) : customizer(objValue, othValue, key, object, other2, stack);
6395               }
6396               if (!(compared === undefined2 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
6397                 result2 = false;
6398                 break;
6399               }
6400               skipCtor || (skipCtor = key == "constructor");
6401             }
6402             if (result2 && !skipCtor) {
6403               var objCtor = object.constructor, othCtor = other2.constructor;
6404               if (objCtor != othCtor && ("constructor" in object && "constructor" in other2) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
6405                 result2 = false;
6406               }
6407             }
6408             stack["delete"](object);
6409             stack["delete"](other2);
6410             return result2;
6411           }
6412           function flatRest(func) {
6413             return setToString(overRest(func, undefined2, flatten2), func + "");
6414           }
6415           function getAllKeys2(object) {
6416             return baseGetAllKeys2(object, keys2, getSymbols2);
6417           }
6418           function getAllKeysIn(object) {
6419             return baseGetAllKeys2(object, keysIn, getSymbolsIn);
6420           }
6421           var getData = !metaMap ? noop3 : function(func) {
6422             return metaMap.get(func);
6423           };
6424           function getFuncName(func) {
6425             var result2 = func.name + "", array2 = realNames[result2], length2 = hasOwnProperty10.call(realNames, result2) ? array2.length : 0;
6426             while (length2--) {
6427               var data = array2[length2], otherFunc = data.func;
6428               if (otherFunc == null || otherFunc == func) {
6429                 return data.name;
6430               }
6431             }
6432             return result2;
6433           }
6434           function getHolder(func) {
6435             var object = hasOwnProperty10.call(lodash, "placeholder") ? lodash : func;
6436             return object.placeholder;
6437           }
6438           function getIteratee() {
6439             var result2 = lodash.iteratee || iteratee;
6440             result2 = result2 === iteratee ? baseIteratee : result2;
6441             return arguments.length ? result2(arguments[0], arguments[1]) : result2;
6442           }
6443           function getMapData2(map3, key) {
6444             var data = map3.__data__;
6445             return isKeyable2(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
6446           }
6447           function getMatchData(object) {
6448             var result2 = keys2(object), length2 = result2.length;
6449             while (length2--) {
6450               var key = result2[length2], value = object[key];
6451               result2[length2] = [key, value, isStrictComparable(value)];
6452             }
6453             return result2;
6454           }
6455           function getNative2(object, key) {
6456             var value = getValue2(object, key);
6457             return baseIsNative2(value) ? value : undefined2;
6458           }
6459           function getRawTag2(value) {
6460             var isOwn = hasOwnProperty10.call(value, symToStringTag3), tag2 = value[symToStringTag3];
6461             try {
6462               value[symToStringTag3] = undefined2;
6463               var unmasked = true;
6464             } catch (e3) {
6465             }
6466             var result2 = nativeObjectToString3.call(value);
6467             if (unmasked) {
6468               if (isOwn) {
6469                 value[symToStringTag3] = tag2;
6470               } else {
6471                 delete value[symToStringTag3];
6472               }
6473             }
6474             return result2;
6475           }
6476           var getSymbols2 = !nativeGetSymbols2 ? stubArray2 : function(object) {
6477             if (object == null) {
6478               return [];
6479             }
6480             object = Object2(object);
6481             return arrayFilter2(nativeGetSymbols2(object), function(symbol) {
6482               return propertyIsEnumerable3.call(object, symbol);
6483             });
6484           };
6485           var getSymbolsIn = !nativeGetSymbols2 ? stubArray2 : function(object) {
6486             var result2 = [];
6487             while (object) {
6488               arrayPush2(result2, getSymbols2(object));
6489               object = getPrototype(object);
6490             }
6491             return result2;
6492           };
6493           var getTag2 = baseGetTag2;
6494           if (DataView3 && getTag2(new DataView3(new ArrayBuffer(1))) != dataViewTag4 || Map3 && getTag2(new Map3()) != mapTag4 || Promise3 && getTag2(Promise3.resolve()) != promiseTag2 || Set3 && getTag2(new Set3()) != setTag4 || WeakMap2 && getTag2(new WeakMap2()) != weakMapTag3) {
6495             getTag2 = function(value) {
6496               var result2 = baseGetTag2(value), Ctor = result2 == objectTag4 ? value.constructor : undefined2, ctorString = Ctor ? toSource2(Ctor) : "";
6497               if (ctorString) {
6498                 switch (ctorString) {
6499                   case dataViewCtorString2:
6500                     return dataViewTag4;
6501                   case mapCtorString2:
6502                     return mapTag4;
6503                   case promiseCtorString2:
6504                     return promiseTag2;
6505                   case setCtorString2:
6506                     return setTag4;
6507                   case weakMapCtorString2:
6508                     return weakMapTag3;
6509                 }
6510               }
6511               return result2;
6512             };
6513           }
6514           function getView(start2, end, transforms) {
6515             var index = -1, length2 = transforms.length;
6516             while (++index < length2) {
6517               var data = transforms[index], size2 = data.size;
6518               switch (data.type) {
6519                 case "drop":
6520                   start2 += size2;
6521                   break;
6522                 case "dropRight":
6523                   end -= size2;
6524                   break;
6525                 case "take":
6526                   end = nativeMin2(end, start2 + size2);
6527                   break;
6528                 case "takeRight":
6529                   start2 = nativeMax2(start2, end - size2);
6530                   break;
6531               }
6532             }
6533             return { "start": start2, "end": end };
6534           }
6535           function getWrapDetails(source) {
6536             var match = source.match(reWrapDetails);
6537             return match ? match[1].split(reSplitDetails) : [];
6538           }
6539           function hasPath(object, path, hasFunc) {
6540             path = castPath(path, object);
6541             var index = -1, length2 = path.length, result2 = false;
6542             while (++index < length2) {
6543               var key = toKey(path[index]);
6544               if (!(result2 = object != null && hasFunc(object, key))) {
6545                 break;
6546               }
6547               object = object[key];
6548             }
6549             if (result2 || ++index != length2) {
6550               return result2;
6551             }
6552             length2 = object == null ? 0 : object.length;
6553             return !!length2 && isLength2(length2) && isIndex2(key, length2) && (isArray2(object) || isArguments2(object));
6554           }
6555           function initCloneArray(array2) {
6556             var length2 = array2.length, result2 = new array2.constructor(length2);
6557             if (length2 && typeof array2[0] == "string" && hasOwnProperty10.call(array2, "index")) {
6558               result2.index = array2.index;
6559               result2.input = array2.input;
6560             }
6561             return result2;
6562           }
6563           function initCloneObject(object) {
6564             return typeof object.constructor == "function" && !isPrototype2(object) ? baseCreate(getPrototype(object)) : {};
6565           }
6566           function initCloneByTag(object, tag2, isDeep) {
6567             var Ctor = object.constructor;
6568             switch (tag2) {
6569               case arrayBufferTag3:
6570                 return cloneArrayBuffer(object);
6571               case boolTag3:
6572               case dateTag3:
6573                 return new Ctor(+object);
6574               case dataViewTag4:
6575                 return cloneDataView(object, isDeep);
6576               case float32Tag2:
6577               case float64Tag2:
6578               case int8Tag2:
6579               case int16Tag2:
6580               case int32Tag2:
6581               case uint8Tag2:
6582               case uint8ClampedTag2:
6583               case uint16Tag2:
6584               case uint32Tag2:
6585                 return cloneTypedArray(object, isDeep);
6586               case mapTag4:
6587                 return new Ctor();
6588               case numberTag4:
6589               case stringTag3:
6590                 return new Ctor(object);
6591               case regexpTag3:
6592                 return cloneRegExp(object);
6593               case setTag4:
6594                 return new Ctor();
6595               case symbolTag3:
6596                 return cloneSymbol(object);
6597             }
6598           }
6599           function insertWrapDetails(source, details) {
6600             var length2 = details.length;
6601             if (!length2) {
6602               return source;
6603             }
6604             var lastIndex = length2 - 1;
6605             details[lastIndex] = (length2 > 1 ? "& " : "") + details[lastIndex];
6606             details = details.join(length2 > 2 ? ", " : " ");
6607             return source.replace(reWrapComment, "{\n/* [wrapped with " + details + "] */\n");
6608           }
6609           function isFlattenable(value) {
6610             return isArray2(value) || isArguments2(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
6611           }
6612           function isIndex2(value, length2) {
6613             var type2 = typeof value;
6614             length2 = length2 == null ? MAX_SAFE_INTEGER4 : length2;
6615             return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint2.test(value)) && (value > -1 && value % 1 == 0 && value < length2);
6616           }
6617           function isIterateeCall(value, index, object) {
6618             if (!isObject2(object)) {
6619               return false;
6620             }
6621             var type2 = typeof index;
6622             if (type2 == "number" ? isArrayLike2(object) && isIndex2(index, object.length) : type2 == "string" && index in object) {
6623               return eq2(object[index], value);
6624             }
6625             return false;
6626           }
6627           function isKey(value, object) {
6628             if (isArray2(value)) {
6629               return false;
6630             }
6631             var type2 = typeof value;
6632             if (type2 == "number" || type2 == "symbol" || type2 == "boolean" || value == null || isSymbol2(value)) {
6633               return true;
6634             }
6635             return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object2(object);
6636           }
6637           function isKeyable2(value) {
6638             var type2 = typeof value;
6639             return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null;
6640           }
6641           function isLaziable(func) {
6642             var funcName = getFuncName(func), other2 = lodash[funcName];
6643             if (typeof other2 != "function" || !(funcName in LazyWrapper.prototype)) {
6644               return false;
6645             }
6646             if (func === other2) {
6647               return true;
6648             }
6649             var data = getData(other2);
6650             return !!data && func === data[0];
6651           }
6652           function isMasked2(func) {
6653             return !!maskSrcKey2 && maskSrcKey2 in func;
6654           }
6655           var isMaskable = coreJsData2 ? isFunction2 : stubFalse2;
6656           function isPrototype2(value) {
6657             var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto13;
6658             return value === proto;
6659           }
6660           function isStrictComparable(value) {
6661             return value === value && !isObject2(value);
6662           }
6663           function matchesStrictComparable(key, srcValue) {
6664             return function(object) {
6665               if (object == null) {
6666                 return false;
6667               }
6668               return object[key] === srcValue && (srcValue !== undefined2 || key in Object2(object));
6669             };
6670           }
6671           function memoizeCapped(func) {
6672             var result2 = memoize(func, function(key) {
6673               if (cache.size === MAX_MEMOIZE_SIZE) {
6674                 cache.clear();
6675               }
6676               return key;
6677             });
6678             var cache = result2.cache;
6679             return result2;
6680           }
6681           function mergeData(data, source) {
6682             var bitmask = data[1], srcBitmask = source[1], newBitmask = bitmask | srcBitmask, isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
6683             var isCombo = srcBitmask == WRAP_ARY_FLAG && bitmask == WRAP_CURRY_FLAG || srcBitmask == WRAP_ARY_FLAG && bitmask == WRAP_REARG_FLAG && data[7].length <= source[8] || srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG) && source[7].length <= source[8] && bitmask == WRAP_CURRY_FLAG;
6684             if (!(isCommon || isCombo)) {
6685               return data;
6686             }
6687             if (srcBitmask & WRAP_BIND_FLAG) {
6688               data[2] = source[2];
6689               newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
6690             }
6691             var value = source[3];
6692             if (value) {
6693               var partials = data[3];
6694               data[3] = partials ? composeArgs(partials, value, source[4]) : value;
6695               data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
6696             }
6697             value = source[5];
6698             if (value) {
6699               partials = data[5];
6700               data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
6701               data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
6702             }
6703             value = source[7];
6704             if (value) {
6705               data[7] = value;
6706             }
6707             if (srcBitmask & WRAP_ARY_FLAG) {
6708               data[8] = data[8] == null ? source[8] : nativeMin2(data[8], source[8]);
6709             }
6710             if (data[9] == null) {
6711               data[9] = source[9];
6712             }
6713             data[0] = source[0];
6714             data[1] = newBitmask;
6715             return data;
6716           }
6717           function nativeKeysIn(object) {
6718             var result2 = [];
6719             if (object != null) {
6720               for (var key in Object2(object)) {
6721                 result2.push(key);
6722               }
6723             }
6724             return result2;
6725           }
6726           function objectToString2(value) {
6727             return nativeObjectToString3.call(value);
6728           }
6729           function overRest(func, start2, transform3) {
6730             start2 = nativeMax2(start2 === undefined2 ? func.length - 1 : start2, 0);
6731             return function() {
6732               var args = arguments, index = -1, length2 = nativeMax2(args.length - start2, 0), array2 = Array2(length2);
6733               while (++index < length2) {
6734                 array2[index] = args[start2 + index];
6735               }
6736               index = -1;
6737               var otherArgs = Array2(start2 + 1);
6738               while (++index < start2) {
6739                 otherArgs[index] = args[index];
6740               }
6741               otherArgs[start2] = transform3(array2);
6742               return apply(func, this, otherArgs);
6743             };
6744           }
6745           function parent(object, path) {
6746             return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
6747           }
6748           function reorder(array2, indexes) {
6749             var arrLength = array2.length, length2 = nativeMin2(indexes.length, arrLength), oldArray = copyArray(array2);
6750             while (length2--) {
6751               var index = indexes[length2];
6752               array2[length2] = isIndex2(index, arrLength) ? oldArray[index] : undefined2;
6753             }
6754             return array2;
6755           }
6756           function safeGet(object, key) {
6757             if (key === "constructor" && typeof object[key] === "function") {
6758               return;
6759             }
6760             if (key == "__proto__") {
6761               return;
6762             }
6763             return object[key];
6764           }
6765           var setData = shortOut(baseSetData);
6766           var setTimeout2 = ctxSetTimeout || function(func, wait) {
6767             return root3.setTimeout(func, wait);
6768           };
6769           var setToString = shortOut(baseSetToString);
6770           function setWrapToString(wrapper, reference, bitmask) {
6771             var source = reference + "";
6772             return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
6773           }
6774           function shortOut(func) {
6775             var count = 0, lastCalled = 0;
6776             return function() {
6777               var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
6778               lastCalled = stamp;
6779               if (remaining > 0) {
6780                 if (++count >= HOT_COUNT) {
6781                   return arguments[0];
6782                 }
6783               } else {
6784                 count = 0;
6785               }
6786               return func.apply(undefined2, arguments);
6787             };
6788           }
6789           function shuffleSelf(array2, size2) {
6790             var index = -1, length2 = array2.length, lastIndex = length2 - 1;
6791             size2 = size2 === undefined2 ? length2 : size2;
6792             while (++index < size2) {
6793               var rand = baseRandom(index, lastIndex), value = array2[rand];
6794               array2[rand] = array2[index];
6795               array2[index] = value;
6796             }
6797             array2.length = size2;
6798             return array2;
6799           }
6800           var stringToPath = memoizeCapped(function(string) {
6801             var result2 = [];
6802             if (string.charCodeAt(0) === 46) {
6803               result2.push("");
6804             }
6805             string.replace(rePropName, function(match, number3, quote, subString) {
6806               result2.push(quote ? subString.replace(reEscapeChar, "$1") : number3 || match);
6807             });
6808             return result2;
6809           });
6810           function toKey(value) {
6811             if (typeof value == "string" || isSymbol2(value)) {
6812               return value;
6813             }
6814             var result2 = value + "";
6815             return result2 == "0" && 1 / value == -INFINITY2 ? "-0" : result2;
6816           }
6817           function toSource2(func) {
6818             if (func != null) {
6819               try {
6820                 return funcToString3.call(func);
6821               } catch (e3) {
6822               }
6823               try {
6824                 return func + "";
6825               } catch (e3) {
6826               }
6827             }
6828             return "";
6829           }
6830           function updateWrapDetails(details, bitmask) {
6831             arrayEach(wrapFlags, function(pair3) {
6832               var value = "_." + pair3[0];
6833               if (bitmask & pair3[1] && !arrayIncludes(details, value)) {
6834                 details.push(value);
6835               }
6836             });
6837             return details.sort();
6838           }
6839           function wrapperClone(wrapper) {
6840             if (wrapper instanceof LazyWrapper) {
6841               return wrapper.clone();
6842             }
6843             var result2 = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
6844             result2.__actions__ = copyArray(wrapper.__actions__);
6845             result2.__index__ = wrapper.__index__;
6846             result2.__values__ = wrapper.__values__;
6847             return result2;
6848           }
6849           function chunk(array2, size2, guard) {
6850             if (guard ? isIterateeCall(array2, size2, guard) : size2 === undefined2) {
6851               size2 = 1;
6852             } else {
6853               size2 = nativeMax2(toInteger(size2), 0);
6854             }
6855             var length2 = array2 == null ? 0 : array2.length;
6856             if (!length2 || size2 < 1) {
6857               return [];
6858             }
6859             var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length2 / size2));
6860             while (index < length2) {
6861               result2[resIndex++] = baseSlice(array2, index, index += size2);
6862             }
6863             return result2;
6864           }
6865           function compact(array2) {
6866             var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result2 = [];
6867             while (++index < length2) {
6868               var value = array2[index];
6869               if (value) {
6870                 result2[resIndex++] = value;
6871               }
6872             }
6873             return result2;
6874           }
6875           function concat() {
6876             var length2 = arguments.length;
6877             if (!length2) {
6878               return [];
6879             }
6880             var args = Array2(length2 - 1), array2 = arguments[0], index = length2;
6881             while (index--) {
6882               args[index - 1] = arguments[index];
6883             }
6884             return arrayPush2(isArray2(array2) ? copyArray(array2) : [array2], baseFlatten(args, 1));
6885           }
6886           var difference2 = baseRest(function(array2, values2) {
6887             return isArrayLikeObject(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject, true)) : [];
6888           });
6889           var differenceBy = baseRest(function(array2, values2) {
6890             var iteratee2 = last(values2);
6891             if (isArrayLikeObject(iteratee2)) {
6892               iteratee2 = undefined2;
6893             }
6894             return isArrayLikeObject(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject, true), getIteratee(iteratee2, 2)) : [];
6895           });
6896           var differenceWith = baseRest(function(array2, values2) {
6897             var comparator = last(values2);
6898             if (isArrayLikeObject(comparator)) {
6899               comparator = undefined2;
6900             }
6901             return isArrayLikeObject(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject, true), undefined2, comparator) : [];
6902           });
6903           function drop(array2, n3, guard) {
6904             var length2 = array2 == null ? 0 : array2.length;
6905             if (!length2) {
6906               return [];
6907             }
6908             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
6909             return baseSlice(array2, n3 < 0 ? 0 : n3, length2);
6910           }
6911           function dropRight(array2, n3, guard) {
6912             var length2 = array2 == null ? 0 : array2.length;
6913             if (!length2) {
6914               return [];
6915             }
6916             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
6917             n3 = length2 - n3;
6918             return baseSlice(array2, 0, n3 < 0 ? 0 : n3);
6919           }
6920           function dropRightWhile(array2, predicate) {
6921             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), true, true) : [];
6922           }
6923           function dropWhile(array2, predicate) {
6924             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), true) : [];
6925           }
6926           function fill(array2, value, start2, end) {
6927             var length2 = array2 == null ? 0 : array2.length;
6928             if (!length2) {
6929               return [];
6930             }
6931             if (start2 && typeof start2 != "number" && isIterateeCall(array2, value, start2)) {
6932               start2 = 0;
6933               end = length2;
6934             }
6935             return baseFill(array2, value, start2, end);
6936           }
6937           function findIndex(array2, predicate, fromIndex) {
6938             var length2 = array2 == null ? 0 : array2.length;
6939             if (!length2) {
6940               return -1;
6941             }
6942             var index = fromIndex == null ? 0 : toInteger(fromIndex);
6943             if (index < 0) {
6944               index = nativeMax2(length2 + index, 0);
6945             }
6946             return baseFindIndex(array2, getIteratee(predicate, 3), index);
6947           }
6948           function findLastIndex(array2, predicate, fromIndex) {
6949             var length2 = array2 == null ? 0 : array2.length;
6950             if (!length2) {
6951               return -1;
6952             }
6953             var index = length2 - 1;
6954             if (fromIndex !== undefined2) {
6955               index = toInteger(fromIndex);
6956               index = fromIndex < 0 ? nativeMax2(length2 + index, 0) : nativeMin2(index, length2 - 1);
6957             }
6958             return baseFindIndex(array2, getIteratee(predicate, 3), index, true);
6959           }
6960           function flatten2(array2) {
6961             var length2 = array2 == null ? 0 : array2.length;
6962             return length2 ? baseFlatten(array2, 1) : [];
6963           }
6964           function flattenDeep(array2) {
6965             var length2 = array2 == null ? 0 : array2.length;
6966             return length2 ? baseFlatten(array2, INFINITY2) : [];
6967           }
6968           function flattenDepth(array2, depth) {
6969             var length2 = array2 == null ? 0 : array2.length;
6970             if (!length2) {
6971               return [];
6972             }
6973             depth = depth === undefined2 ? 1 : toInteger(depth);
6974             return baseFlatten(array2, depth);
6975           }
6976           function fromPairs(pairs2) {
6977             var index = -1, length2 = pairs2 == null ? 0 : pairs2.length, result2 = {};
6978             while (++index < length2) {
6979               var pair3 = pairs2[index];
6980               result2[pair3[0]] = pair3[1];
6981             }
6982             return result2;
6983           }
6984           function head(array2) {
6985             return array2 && array2.length ? array2[0] : undefined2;
6986           }
6987           function indexOf(array2, value, fromIndex) {
6988             var length2 = array2 == null ? 0 : array2.length;
6989             if (!length2) {
6990               return -1;
6991             }
6992             var index = fromIndex == null ? 0 : toInteger(fromIndex);
6993             if (index < 0) {
6994               index = nativeMax2(length2 + index, 0);
6995             }
6996             return baseIndexOf(array2, value, index);
6997           }
6998           function initial(array2) {
6999             var length2 = array2 == null ? 0 : array2.length;
7000             return length2 ? baseSlice(array2, 0, -1) : [];
7001           }
7002           var intersection2 = baseRest(function(arrays) {
7003             var mapped = arrayMap2(arrays, castArrayLikeObject);
7004             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped) : [];
7005           });
7006           var intersectionBy = baseRest(function(arrays) {
7007             var iteratee2 = last(arrays), mapped = arrayMap2(arrays, castArrayLikeObject);
7008             if (iteratee2 === last(mapped)) {
7009               iteratee2 = undefined2;
7010             } else {
7011               mapped.pop();
7012             }
7013             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, getIteratee(iteratee2, 2)) : [];
7014           });
7015           var intersectionWith = baseRest(function(arrays) {
7016             var comparator = last(arrays), mapped = arrayMap2(arrays, castArrayLikeObject);
7017             comparator = typeof comparator == "function" ? comparator : undefined2;
7018             if (comparator) {
7019               mapped.pop();
7020             }
7021             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
7022           });
7023           function join(array2, separator) {
7024             return array2 == null ? "" : nativeJoin.call(array2, separator);
7025           }
7026           function last(array2) {
7027             var length2 = array2 == null ? 0 : array2.length;
7028             return length2 ? array2[length2 - 1] : undefined2;
7029           }
7030           function lastIndexOf(array2, value, fromIndex) {
7031             var length2 = array2 == null ? 0 : array2.length;
7032             if (!length2) {
7033               return -1;
7034             }
7035             var index = length2;
7036             if (fromIndex !== undefined2) {
7037               index = toInteger(fromIndex);
7038               index = index < 0 ? nativeMax2(length2 + index, 0) : nativeMin2(index, length2 - 1);
7039             }
7040             return value === value ? strictLastIndexOf(array2, value, index) : baseFindIndex(array2, baseIsNaN, index, true);
7041           }
7042           function nth(array2, n3) {
7043             return array2 && array2.length ? baseNth(array2, toInteger(n3)) : undefined2;
7044           }
7045           var pull = baseRest(pullAll);
7046           function pullAll(array2, values2) {
7047             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2) : array2;
7048           }
7049           function pullAllBy(array2, values2, iteratee2) {
7050             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2, getIteratee(iteratee2, 2)) : array2;
7051           }
7052           function pullAllWith(array2, values2, comparator) {
7053             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2, undefined2, comparator) : array2;
7054           }
7055           var pullAt = flatRest(function(array2, indexes) {
7056             var length2 = array2 == null ? 0 : array2.length, result2 = baseAt(array2, indexes);
7057             basePullAt(array2, arrayMap2(indexes, function(index) {
7058               return isIndex2(index, length2) ? +index : index;
7059             }).sort(compareAscending));
7060             return result2;
7061           });
7062           function remove2(array2, predicate) {
7063             var result2 = [];
7064             if (!(array2 && array2.length)) {
7065               return result2;
7066             }
7067             var index = -1, indexes = [], length2 = array2.length;
7068             predicate = getIteratee(predicate, 3);
7069             while (++index < length2) {
7070               var value = array2[index];
7071               if (predicate(value, index, array2)) {
7072                 result2.push(value);
7073                 indexes.push(index);
7074               }
7075             }
7076             basePullAt(array2, indexes);
7077             return result2;
7078           }
7079           function reverse(array2) {
7080             return array2 == null ? array2 : nativeReverse.call(array2);
7081           }
7082           function slice(array2, start2, end) {
7083             var length2 = array2 == null ? 0 : array2.length;
7084             if (!length2) {
7085               return [];
7086             }
7087             if (end && typeof end != "number" && isIterateeCall(array2, start2, end)) {
7088               start2 = 0;
7089               end = length2;
7090             } else {
7091               start2 = start2 == null ? 0 : toInteger(start2);
7092               end = end === undefined2 ? length2 : toInteger(end);
7093             }
7094             return baseSlice(array2, start2, end);
7095           }
7096           function sortedIndex(array2, value) {
7097             return baseSortedIndex(array2, value);
7098           }
7099           function sortedIndexBy(array2, value, iteratee2) {
7100             return baseSortedIndexBy(array2, value, getIteratee(iteratee2, 2));
7101           }
7102           function sortedIndexOf(array2, value) {
7103             var length2 = array2 == null ? 0 : array2.length;
7104             if (length2) {
7105               var index = baseSortedIndex(array2, value);
7106               if (index < length2 && eq2(array2[index], value)) {
7107                 return index;
7108               }
7109             }
7110             return -1;
7111           }
7112           function sortedLastIndex(array2, value) {
7113             return baseSortedIndex(array2, value, true);
7114           }
7115           function sortedLastIndexBy(array2, value, iteratee2) {
7116             return baseSortedIndexBy(array2, value, getIteratee(iteratee2, 2), true);
7117           }
7118           function sortedLastIndexOf(array2, value) {
7119             var length2 = array2 == null ? 0 : array2.length;
7120             if (length2) {
7121               var index = baseSortedIndex(array2, value, true) - 1;
7122               if (eq2(array2[index], value)) {
7123                 return index;
7124               }
7125             }
7126             return -1;
7127           }
7128           function sortedUniq(array2) {
7129             return array2 && array2.length ? baseSortedUniq(array2) : [];
7130           }
7131           function sortedUniqBy(array2, iteratee2) {
7132             return array2 && array2.length ? baseSortedUniq(array2, getIteratee(iteratee2, 2)) : [];
7133           }
7134           function tail(array2) {
7135             var length2 = array2 == null ? 0 : array2.length;
7136             return length2 ? baseSlice(array2, 1, length2) : [];
7137           }
7138           function take(array2, n3, guard) {
7139             if (!(array2 && array2.length)) {
7140               return [];
7141             }
7142             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
7143             return baseSlice(array2, 0, n3 < 0 ? 0 : n3);
7144           }
7145           function takeRight(array2, n3, guard) {
7146             var length2 = array2 == null ? 0 : array2.length;
7147             if (!length2) {
7148               return [];
7149             }
7150             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
7151             n3 = length2 - n3;
7152             return baseSlice(array2, n3 < 0 ? 0 : n3, length2);
7153           }
7154           function takeRightWhile(array2, predicate) {
7155             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), false, true) : [];
7156           }
7157           function takeWhile(array2, predicate) {
7158             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3)) : [];
7159           }
7160           var union2 = baseRest(function(arrays) {
7161             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
7162           });
7163           var unionBy = baseRest(function(arrays) {
7164             var iteratee2 = last(arrays);
7165             if (isArrayLikeObject(iteratee2)) {
7166               iteratee2 = undefined2;
7167             }
7168             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee2, 2));
7169           });
7170           var unionWith = baseRest(function(arrays) {
7171             var comparator = last(arrays);
7172             comparator = typeof comparator == "function" ? comparator : undefined2;
7173             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined2, comparator);
7174           });
7175           function uniq(array2) {
7176             return array2 && array2.length ? baseUniq(array2) : [];
7177           }
7178           function uniqBy(array2, iteratee2) {
7179             return array2 && array2.length ? baseUniq(array2, getIteratee(iteratee2, 2)) : [];
7180           }
7181           function uniqWith(array2, comparator) {
7182             comparator = typeof comparator == "function" ? comparator : undefined2;
7183             return array2 && array2.length ? baseUniq(array2, undefined2, comparator) : [];
7184           }
7185           function unzip(array2) {
7186             if (!(array2 && array2.length)) {
7187               return [];
7188             }
7189             var length2 = 0;
7190             array2 = arrayFilter2(array2, function(group) {
7191               if (isArrayLikeObject(group)) {
7192                 length2 = nativeMax2(group.length, length2);
7193                 return true;
7194               }
7195             });
7196             return baseTimes2(length2, function(index) {
7197               return arrayMap2(array2, baseProperty(index));
7198             });
7199           }
7200           function unzipWith(array2, iteratee2) {
7201             if (!(array2 && array2.length)) {
7202               return [];
7203             }
7204             var result2 = unzip(array2);
7205             if (iteratee2 == null) {
7206               return result2;
7207             }
7208             return arrayMap2(result2, function(group) {
7209               return apply(iteratee2, undefined2, group);
7210             });
7211           }
7212           var without = baseRest(function(array2, values2) {
7213             return isArrayLikeObject(array2) ? baseDifference(array2, values2) : [];
7214           });
7215           var xor = baseRest(function(arrays) {
7216             return baseXor(arrayFilter2(arrays, isArrayLikeObject));
7217           });
7218           var xorBy = baseRest(function(arrays) {
7219             var iteratee2 = last(arrays);
7220             if (isArrayLikeObject(iteratee2)) {
7221               iteratee2 = undefined2;
7222             }
7223             return baseXor(arrayFilter2(arrays, isArrayLikeObject), getIteratee(iteratee2, 2));
7224           });
7225           var xorWith = baseRest(function(arrays) {
7226             var comparator = last(arrays);
7227             comparator = typeof comparator == "function" ? comparator : undefined2;
7228             return baseXor(arrayFilter2(arrays, isArrayLikeObject), undefined2, comparator);
7229           });
7230           var zip = baseRest(unzip);
7231           function zipObject(props, values2) {
7232             return baseZipObject(props || [], values2 || [], assignValue);
7233           }
7234           function zipObjectDeep(props, values2) {
7235             return baseZipObject(props || [], values2 || [], baseSet);
7236           }
7237           var zipWith = baseRest(function(arrays) {
7238             var length2 = arrays.length, iteratee2 = length2 > 1 ? arrays[length2 - 1] : undefined2;
7239             iteratee2 = typeof iteratee2 == "function" ? (arrays.pop(), iteratee2) : undefined2;
7240             return unzipWith(arrays, iteratee2);
7241           });
7242           function chain(value) {
7243             var result2 = lodash(value);
7244             result2.__chain__ = true;
7245             return result2;
7246           }
7247           function tap(value, interceptor) {
7248             interceptor(value);
7249             return value;
7250           }
7251           function thru(value, interceptor) {
7252             return interceptor(value);
7253           }
7254           var wrapperAt = flatRest(function(paths) {
7255             var length2 = paths.length, start2 = length2 ? paths[0] : 0, value = this.__wrapped__, interceptor = function(object) {
7256               return baseAt(object, paths);
7257             };
7258             if (length2 > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex2(start2)) {
7259               return this.thru(interceptor);
7260             }
7261             value = value.slice(start2, +start2 + (length2 ? 1 : 0));
7262             value.__actions__.push({
7263               "func": thru,
7264               "args": [interceptor],
7265               "thisArg": undefined2
7266             });
7267             return new LodashWrapper(value, this.__chain__).thru(function(array2) {
7268               if (length2 && !array2.length) {
7269                 array2.push(undefined2);
7270               }
7271               return array2;
7272             });
7273           });
7274           function wrapperChain() {
7275             return chain(this);
7276           }
7277           function wrapperCommit() {
7278             return new LodashWrapper(this.value(), this.__chain__);
7279           }
7280           function wrapperNext() {
7281             if (this.__values__ === undefined2) {
7282               this.__values__ = toArray(this.value());
7283             }
7284             var done = this.__index__ >= this.__values__.length, value = done ? undefined2 : this.__values__[this.__index__++];
7285             return { "done": done, "value": value };
7286           }
7287           function wrapperToIterator() {
7288             return this;
7289           }
7290           function wrapperPlant(value) {
7291             var result2, parent2 = this;
7292             while (parent2 instanceof baseLodash) {
7293               var clone3 = wrapperClone(parent2);
7294               clone3.__index__ = 0;
7295               clone3.__values__ = undefined2;
7296               if (result2) {
7297                 previous.__wrapped__ = clone3;
7298               } else {
7299                 result2 = clone3;
7300               }
7301               var previous = clone3;
7302               parent2 = parent2.__wrapped__;
7303             }
7304             previous.__wrapped__ = value;
7305             return result2;
7306           }
7307           function wrapperReverse() {
7308             var value = this.__wrapped__;
7309             if (value instanceof LazyWrapper) {
7310               var wrapped = value;
7311               if (this.__actions__.length) {
7312                 wrapped = new LazyWrapper(this);
7313               }
7314               wrapped = wrapped.reverse();
7315               wrapped.__actions__.push({
7316                 "func": thru,
7317                 "args": [reverse],
7318                 "thisArg": undefined2
7319               });
7320               return new LodashWrapper(wrapped, this.__chain__);
7321             }
7322             return this.thru(reverse);
7323           }
7324           function wrapperValue() {
7325             return baseWrapperValue(this.__wrapped__, this.__actions__);
7326           }
7327           var countBy = createAggregator(function(result2, value, key) {
7328             if (hasOwnProperty10.call(result2, key)) {
7329               ++result2[key];
7330             } else {
7331               baseAssignValue(result2, key, 1);
7332             }
7333           });
7334           function every(collection, predicate, guard) {
7335             var func = isArray2(collection) ? arrayEvery : baseEvery;
7336             if (guard && isIterateeCall(collection, predicate, guard)) {
7337               predicate = undefined2;
7338             }
7339             return func(collection, getIteratee(predicate, 3));
7340           }
7341           function filter2(collection, predicate) {
7342             var func = isArray2(collection) ? arrayFilter2 : baseFilter;
7343             return func(collection, getIteratee(predicate, 3));
7344           }
7345           var find2 = createFind(findIndex);
7346           var findLast = createFind(findLastIndex);
7347           function flatMap(collection, iteratee2) {
7348             return baseFlatten(map2(collection, iteratee2), 1);
7349           }
7350           function flatMapDeep(collection, iteratee2) {
7351             return baseFlatten(map2(collection, iteratee2), INFINITY2);
7352           }
7353           function flatMapDepth(collection, iteratee2, depth) {
7354             depth = depth === undefined2 ? 1 : toInteger(depth);
7355             return baseFlatten(map2(collection, iteratee2), depth);
7356           }
7357           function forEach(collection, iteratee2) {
7358             var func = isArray2(collection) ? arrayEach : baseEach;
7359             return func(collection, getIteratee(iteratee2, 3));
7360           }
7361           function forEachRight(collection, iteratee2) {
7362             var func = isArray2(collection) ? arrayEachRight : baseEachRight;
7363             return func(collection, getIteratee(iteratee2, 3));
7364           }
7365           var groupBy = createAggregator(function(result2, value, key) {
7366             if (hasOwnProperty10.call(result2, key)) {
7367               result2[key].push(value);
7368             } else {
7369               baseAssignValue(result2, key, [value]);
7370             }
7371           });
7372           function includes(collection, value, fromIndex, guard) {
7373             collection = isArrayLike2(collection) ? collection : values(collection);
7374             fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0;
7375             var length2 = collection.length;
7376             if (fromIndex < 0) {
7377               fromIndex = nativeMax2(length2 + fromIndex, 0);
7378             }
7379             return isString(collection) ? fromIndex <= length2 && collection.indexOf(value, fromIndex) > -1 : !!length2 && baseIndexOf(collection, value, fromIndex) > -1;
7380           }
7381           var invokeMap = baseRest(function(collection, path, args) {
7382             var index = -1, isFunc = typeof path == "function", result2 = isArrayLike2(collection) ? Array2(collection.length) : [];
7383             baseEach(collection, function(value) {
7384               result2[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
7385             });
7386             return result2;
7387           });
7388           var keyBy = createAggregator(function(result2, value, key) {
7389             baseAssignValue(result2, key, value);
7390           });
7391           function map2(collection, iteratee2) {
7392             var func = isArray2(collection) ? arrayMap2 : baseMap;
7393             return func(collection, getIteratee(iteratee2, 3));
7394           }
7395           function orderBy(collection, iteratees, orders, guard) {
7396             if (collection == null) {
7397               return [];
7398             }
7399             if (!isArray2(iteratees)) {
7400               iteratees = iteratees == null ? [] : [iteratees];
7401             }
7402             orders = guard ? undefined2 : orders;
7403             if (!isArray2(orders)) {
7404               orders = orders == null ? [] : [orders];
7405             }
7406             return baseOrderBy(collection, iteratees, orders);
7407           }
7408           var partition = createAggregator(function(result2, value, key) {
7409             result2[key ? 0 : 1].push(value);
7410           }, function() {
7411             return [[], []];
7412           });
7413           function reduce(collection, iteratee2, accumulator) {
7414             var func = isArray2(collection) ? arrayReduce : baseReduce, initAccum = arguments.length < 3;
7415             return func(collection, getIteratee(iteratee2, 4), accumulator, initAccum, baseEach);
7416           }
7417           function reduceRight(collection, iteratee2, accumulator) {
7418             var func = isArray2(collection) ? arrayReduceRight : baseReduce, initAccum = arguments.length < 3;
7419             return func(collection, getIteratee(iteratee2, 4), accumulator, initAccum, baseEachRight);
7420           }
7421           function reject(collection, predicate) {
7422             var func = isArray2(collection) ? arrayFilter2 : baseFilter;
7423             return func(collection, negate(getIteratee(predicate, 3)));
7424           }
7425           function sample(collection) {
7426             var func = isArray2(collection) ? arraySample : baseSample;
7427             return func(collection);
7428           }
7429           function sampleSize(collection, n3, guard) {
7430             if (guard ? isIterateeCall(collection, n3, guard) : n3 === undefined2) {
7431               n3 = 1;
7432             } else {
7433               n3 = toInteger(n3);
7434             }
7435             var func = isArray2(collection) ? arraySampleSize : baseSampleSize;
7436             return func(collection, n3);
7437           }
7438           function shuffle(collection) {
7439             var func = isArray2(collection) ? arrayShuffle : baseShuffle;
7440             return func(collection);
7441           }
7442           function size(collection) {
7443             if (collection == null) {
7444               return 0;
7445             }
7446             if (isArrayLike2(collection)) {
7447               return isString(collection) ? stringSize(collection) : collection.length;
7448             }
7449             var tag2 = getTag2(collection);
7450             if (tag2 == mapTag4 || tag2 == setTag4) {
7451               return collection.size;
7452             }
7453             return baseKeys2(collection).length;
7454           }
7455           function some(collection, predicate, guard) {
7456             var func = isArray2(collection) ? arraySome2 : baseSome;
7457             if (guard && isIterateeCall(collection, predicate, guard)) {
7458               predicate = undefined2;
7459             }
7460             return func(collection, getIteratee(predicate, 3));
7461           }
7462           var sortBy = baseRest(function(collection, iteratees) {
7463             if (collection == null) {
7464               return [];
7465             }
7466             var length2 = iteratees.length;
7467             if (length2 > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
7468               iteratees = [];
7469             } else if (length2 > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
7470               iteratees = [iteratees[0]];
7471             }
7472             return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
7473           });
7474           var now3 = ctxNow || function() {
7475             return root3.Date.now();
7476           };
7477           function after(n3, func) {
7478             if (typeof func != "function") {
7479               throw new TypeError2(FUNC_ERROR_TEXT3);
7480             }
7481             n3 = toInteger(n3);
7482             return function() {
7483               if (--n3 < 1) {
7484                 return func.apply(this, arguments);
7485               }
7486             };
7487           }
7488           function ary(func, n3, guard) {
7489             n3 = guard ? undefined2 : n3;
7490             n3 = func && n3 == null ? func.length : n3;
7491             return createWrap(func, WRAP_ARY_FLAG, undefined2, undefined2, undefined2, undefined2, n3);
7492           }
7493           function before(n3, func) {
7494             var result2;
7495             if (typeof func != "function") {
7496               throw new TypeError2(FUNC_ERROR_TEXT3);
7497             }
7498             n3 = toInteger(n3);
7499             return function() {
7500               if (--n3 > 0) {
7501                 result2 = func.apply(this, arguments);
7502               }
7503               if (n3 <= 1) {
7504                 func = undefined2;
7505               }
7506               return result2;
7507             };
7508           }
7509           var bind = baseRest(function(func, thisArg, partials) {
7510             var bitmask = WRAP_BIND_FLAG;
7511             if (partials.length) {
7512               var holders = replaceHolders(partials, getHolder(bind));
7513               bitmask |= WRAP_PARTIAL_FLAG;
7514             }
7515             return createWrap(func, bitmask, thisArg, partials, holders);
7516           });
7517           var bindKey2 = baseRest(function(object, key, partials) {
7518             var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
7519             if (partials.length) {
7520               var holders = replaceHolders(partials, getHolder(bindKey2));
7521               bitmask |= WRAP_PARTIAL_FLAG;
7522             }
7523             return createWrap(key, bitmask, object, partials, holders);
7524           });
7525           function curry(func, arity, guard) {
7526             arity = guard ? undefined2 : arity;
7527             var result2 = createWrap(func, WRAP_CURRY_FLAG, undefined2, undefined2, undefined2, undefined2, undefined2, arity);
7528             result2.placeholder = curry.placeholder;
7529             return result2;
7530           }
7531           function curryRight(func, arity, guard) {
7532             arity = guard ? undefined2 : arity;
7533             var result2 = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined2, undefined2, undefined2, undefined2, undefined2, arity);
7534             result2.placeholder = curryRight.placeholder;
7535             return result2;
7536           }
7537           function debounce2(func, wait, options2) {
7538             var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
7539             if (typeof func != "function") {
7540               throw new TypeError2(FUNC_ERROR_TEXT3);
7541             }
7542             wait = toNumber3(wait) || 0;
7543             if (isObject2(options2)) {
7544               leading = !!options2.leading;
7545               maxing = "maxWait" in options2;
7546               maxWait = maxing ? nativeMax2(toNumber3(options2.maxWait) || 0, wait) : maxWait;
7547               trailing = "trailing" in options2 ? !!options2.trailing : trailing;
7548             }
7549             function invokeFunc(time) {
7550               var args = lastArgs, thisArg = lastThis;
7551               lastArgs = lastThis = undefined2;
7552               lastInvokeTime = time;
7553               result2 = func.apply(thisArg, args);
7554               return result2;
7555             }
7556             function leadingEdge(time) {
7557               lastInvokeTime = time;
7558               timerId = setTimeout2(timerExpired, wait);
7559               return leading ? invokeFunc(time) : result2;
7560             }
7561             function remainingWait(time) {
7562               var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
7563               return maxing ? nativeMin2(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
7564             }
7565             function shouldInvoke(time) {
7566               var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
7567               return lastCallTime === undefined2 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
7568             }
7569             function timerExpired() {
7570               var time = now3();
7571               if (shouldInvoke(time)) {
7572                 return trailingEdge(time);
7573               }
7574               timerId = setTimeout2(timerExpired, remainingWait(time));
7575             }
7576             function trailingEdge(time) {
7577               timerId = undefined2;
7578               if (trailing && lastArgs) {
7579                 return invokeFunc(time);
7580               }
7581               lastArgs = lastThis = undefined2;
7582               return result2;
7583             }
7584             function cancel() {
7585               if (timerId !== undefined2) {
7586                 clearTimeout2(timerId);
7587               }
7588               lastInvokeTime = 0;
7589               lastArgs = lastCallTime = lastThis = timerId = undefined2;
7590             }
7591             function flush() {
7592               return timerId === undefined2 ? result2 : trailingEdge(now3());
7593             }
7594             function debounced() {
7595               var time = now3(), isInvoking = shouldInvoke(time);
7596               lastArgs = arguments;
7597               lastThis = this;
7598               lastCallTime = time;
7599               if (isInvoking) {
7600                 if (timerId === undefined2) {
7601                   return leadingEdge(lastCallTime);
7602                 }
7603                 if (maxing) {
7604                   clearTimeout2(timerId);
7605                   timerId = setTimeout2(timerExpired, wait);
7606                   return invokeFunc(lastCallTime);
7607                 }
7608               }
7609               if (timerId === undefined2) {
7610                 timerId = setTimeout2(timerExpired, wait);
7611               }
7612               return result2;
7613             }
7614             debounced.cancel = cancel;
7615             debounced.flush = flush;
7616             return debounced;
7617           }
7618           var defer = baseRest(function(func, args) {
7619             return baseDelay(func, 1, args);
7620           });
7621           var delay = baseRest(function(func, wait, args) {
7622             return baseDelay(func, toNumber3(wait) || 0, args);
7623           });
7624           function flip(func) {
7625             return createWrap(func, WRAP_FLIP_FLAG);
7626           }
7627           function memoize(func, resolver) {
7628             if (typeof func != "function" || resolver != null && typeof resolver != "function") {
7629               throw new TypeError2(FUNC_ERROR_TEXT3);
7630             }
7631             var memoized = function() {
7632               var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
7633               if (cache.has(key)) {
7634                 return cache.get(key);
7635               }
7636               var result2 = func.apply(this, args);
7637               memoized.cache = cache.set(key, result2) || cache;
7638               return result2;
7639             };
7640             memoized.cache = new (memoize.Cache || MapCache2)();
7641             return memoized;
7642           }
7643           memoize.Cache = MapCache2;
7644           function negate(predicate) {
7645             if (typeof predicate != "function") {
7646               throw new TypeError2(FUNC_ERROR_TEXT3);
7647             }
7648             return function() {
7649               var args = arguments;
7650               switch (args.length) {
7651                 case 0:
7652                   return !predicate.call(this);
7653                 case 1:
7654                   return !predicate.call(this, args[0]);
7655                 case 2:
7656                   return !predicate.call(this, args[0], args[1]);
7657                 case 3:
7658                   return !predicate.call(this, args[0], args[1], args[2]);
7659               }
7660               return !predicate.apply(this, args);
7661             };
7662           }
7663           function once(func) {
7664             return before(2, func);
7665           }
7666           var overArgs = castRest(function(func, transforms) {
7667             transforms = transforms.length == 1 && isArray2(transforms[0]) ? arrayMap2(transforms[0], baseUnary2(getIteratee())) : arrayMap2(baseFlatten(transforms, 1), baseUnary2(getIteratee()));
7668             var funcsLength = transforms.length;
7669             return baseRest(function(args) {
7670               var index = -1, length2 = nativeMin2(args.length, funcsLength);
7671               while (++index < length2) {
7672                 args[index] = transforms[index].call(this, args[index]);
7673               }
7674               return apply(func, this, args);
7675             });
7676           });
7677           var partial = baseRest(function(func, partials) {
7678             var holders = replaceHolders(partials, getHolder(partial));
7679             return createWrap(func, WRAP_PARTIAL_FLAG, undefined2, partials, holders);
7680           });
7681           var partialRight = baseRest(function(func, partials) {
7682             var holders = replaceHolders(partials, getHolder(partialRight));
7683             return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined2, partials, holders);
7684           });
7685           var rearg = flatRest(function(func, indexes) {
7686             return createWrap(func, WRAP_REARG_FLAG, undefined2, undefined2, undefined2, indexes);
7687           });
7688           function rest(func, start2) {
7689             if (typeof func != "function") {
7690               throw new TypeError2(FUNC_ERROR_TEXT3);
7691             }
7692             start2 = start2 === undefined2 ? start2 : toInteger(start2);
7693             return baseRest(func, start2);
7694           }
7695           function spread(func, start2) {
7696             if (typeof func != "function") {
7697               throw new TypeError2(FUNC_ERROR_TEXT3);
7698             }
7699             start2 = start2 == null ? 0 : nativeMax2(toInteger(start2), 0);
7700             return baseRest(function(args) {
7701               var array2 = args[start2], otherArgs = castSlice(args, 0, start2);
7702               if (array2) {
7703                 arrayPush2(otherArgs, array2);
7704               }
7705               return apply(func, this, otherArgs);
7706             });
7707           }
7708           function throttle2(func, wait, options2) {
7709             var leading = true, trailing = true;
7710             if (typeof func != "function") {
7711               throw new TypeError2(FUNC_ERROR_TEXT3);
7712             }
7713             if (isObject2(options2)) {
7714               leading = "leading" in options2 ? !!options2.leading : leading;
7715               trailing = "trailing" in options2 ? !!options2.trailing : trailing;
7716             }
7717             return debounce2(func, wait, {
7718               "leading": leading,
7719               "maxWait": wait,
7720               "trailing": trailing
7721             });
7722           }
7723           function unary(func) {
7724             return ary(func, 1);
7725           }
7726           function wrap2(value, wrapper) {
7727             return partial(castFunction(wrapper), value);
7728           }
7729           function castArray() {
7730             if (!arguments.length) {
7731               return [];
7732             }
7733             var value = arguments[0];
7734             return isArray2(value) ? value : [value];
7735           }
7736           function clone2(value) {
7737             return baseClone(value, CLONE_SYMBOLS_FLAG);
7738           }
7739           function cloneWith(value, customizer) {
7740             customizer = typeof customizer == "function" ? customizer : undefined2;
7741             return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
7742           }
7743           function cloneDeep(value) {
7744             return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
7745           }
7746           function cloneDeepWith(value, customizer) {
7747             customizer = typeof customizer == "function" ? customizer : undefined2;
7748             return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
7749           }
7750           function conformsTo(object, source) {
7751             return source == null || baseConformsTo(object, source, keys2(source));
7752           }
7753           function eq2(value, other2) {
7754             return value === other2 || value !== value && other2 !== other2;
7755           }
7756           var gt2 = createRelationalOperation(baseGt);
7757           var gte = createRelationalOperation(function(value, other2) {
7758             return value >= other2;
7759           });
7760           var isArguments2 = baseIsArguments2(/* @__PURE__ */ function() {
7761             return arguments;
7762           }()) ? baseIsArguments2 : function(value) {
7763             return isObjectLike2(value) && hasOwnProperty10.call(value, "callee") && !propertyIsEnumerable3.call(value, "callee");
7764           };
7765           var isArray2 = Array2.isArray;
7766           var isArrayBuffer = nodeIsArrayBuffer ? baseUnary2(nodeIsArrayBuffer) : baseIsArrayBuffer;
7767           function isArrayLike2(value) {
7768             return value != null && isLength2(value.length) && !isFunction2(value);
7769           }
7770           function isArrayLikeObject(value) {
7771             return isObjectLike2(value) && isArrayLike2(value);
7772           }
7773           function isBoolean(value) {
7774             return value === true || value === false || isObjectLike2(value) && baseGetTag2(value) == boolTag3;
7775           }
7776           var isBuffer2 = nativeIsBuffer2 || stubFalse2;
7777           var isDate = nodeIsDate ? baseUnary2(nodeIsDate) : baseIsDate;
7778           function isElement2(value) {
7779             return isObjectLike2(value) && value.nodeType === 1 && !isPlainObject(value);
7780           }
7781           function isEmpty(value) {
7782             if (value == null) {
7783               return true;
7784             }
7785             if (isArrayLike2(value) && (isArray2(value) || typeof value == "string" || typeof value.splice == "function" || isBuffer2(value) || isTypedArray2(value) || isArguments2(value))) {
7786               return !value.length;
7787             }
7788             var tag2 = getTag2(value);
7789             if (tag2 == mapTag4 || tag2 == setTag4) {
7790               return !value.size;
7791             }
7792             if (isPrototype2(value)) {
7793               return !baseKeys2(value).length;
7794             }
7795             for (var key in value) {
7796               if (hasOwnProperty10.call(value, key)) {
7797                 return false;
7798               }
7799             }
7800             return true;
7801           }
7802           function isEqual4(value, other2) {
7803             return baseIsEqual2(value, other2);
7804           }
7805           function isEqualWith(value, other2, customizer) {
7806             customizer = typeof customizer == "function" ? customizer : undefined2;
7807             var result2 = customizer ? customizer(value, other2) : undefined2;
7808             return result2 === undefined2 ? baseIsEqual2(value, other2, undefined2, customizer) : !!result2;
7809           }
7810           function isError(value) {
7811             if (!isObjectLike2(value)) {
7812               return false;
7813             }
7814             var tag2 = baseGetTag2(value);
7815             return tag2 == errorTag3 || tag2 == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject(value);
7816           }
7817           function isFinite2(value) {
7818             return typeof value == "number" && nativeIsFinite(value);
7819           }
7820           function isFunction2(value) {
7821             if (!isObject2(value)) {
7822               return false;
7823             }
7824             var tag2 = baseGetTag2(value);
7825             return tag2 == funcTag3 || tag2 == genTag2 || tag2 == asyncTag2 || tag2 == proxyTag2;
7826           }
7827           function isInteger(value) {
7828             return typeof value == "number" && value == toInteger(value);
7829           }
7830           function isLength2(value) {
7831             return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER4;
7832           }
7833           function isObject2(value) {
7834             var type2 = typeof value;
7835             return value != null && (type2 == "object" || type2 == "function");
7836           }
7837           function isObjectLike2(value) {
7838             return value != null && typeof value == "object";
7839           }
7840           var isMap = nodeIsMap ? baseUnary2(nodeIsMap) : baseIsMap;
7841           function isMatch(object, source) {
7842             return object === source || baseIsMatch(object, source, getMatchData(source));
7843           }
7844           function isMatchWith(object, source, customizer) {
7845             customizer = typeof customizer == "function" ? customizer : undefined2;
7846             return baseIsMatch(object, source, getMatchData(source), customizer);
7847           }
7848           function isNaN2(value) {
7849             return isNumber2(value) && value != +value;
7850           }
7851           function isNative(value) {
7852             if (isMaskable(value)) {
7853               throw new Error2(CORE_ERROR_TEXT);
7854             }
7855             return baseIsNative2(value);
7856           }
7857           function isNull(value) {
7858             return value === null;
7859           }
7860           function isNil(value) {
7861             return value == null;
7862           }
7863           function isNumber2(value) {
7864             return typeof value == "number" || isObjectLike2(value) && baseGetTag2(value) == numberTag4;
7865           }
7866           function isPlainObject(value) {
7867             if (!isObjectLike2(value) || baseGetTag2(value) != objectTag4) {
7868               return false;
7869             }
7870             var proto = getPrototype(value);
7871             if (proto === null) {
7872               return true;
7873             }
7874             var Ctor = hasOwnProperty10.call(proto, "constructor") && proto.constructor;
7875             return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString3.call(Ctor) == objectCtorString;
7876           }
7877           var isRegExp = nodeIsRegExp ? baseUnary2(nodeIsRegExp) : baseIsRegExp;
7878           function isSafeInteger(value) {
7879             return isInteger(value) && value >= -MAX_SAFE_INTEGER4 && value <= MAX_SAFE_INTEGER4;
7880           }
7881           var isSet = nodeIsSet ? baseUnary2(nodeIsSet) : baseIsSet;
7882           function isString(value) {
7883             return typeof value == "string" || !isArray2(value) && isObjectLike2(value) && baseGetTag2(value) == stringTag3;
7884           }
7885           function isSymbol2(value) {
7886             return typeof value == "symbol" || isObjectLike2(value) && baseGetTag2(value) == symbolTag3;
7887           }
7888           var isTypedArray2 = nodeIsTypedArray2 ? baseUnary2(nodeIsTypedArray2) : baseIsTypedArray2;
7889           function isUndefined(value) {
7890             return value === undefined2;
7891           }
7892           function isWeakMap(value) {
7893             return isObjectLike2(value) && getTag2(value) == weakMapTag3;
7894           }
7895           function isWeakSet(value) {
7896             return isObjectLike2(value) && baseGetTag2(value) == weakSetTag;
7897           }
7898           var lt2 = createRelationalOperation(baseLt);
7899           var lte = createRelationalOperation(function(value, other2) {
7900             return value <= other2;
7901           });
7902           function toArray(value) {
7903             if (!value) {
7904               return [];
7905             }
7906             if (isArrayLike2(value)) {
7907               return isString(value) ? stringToArray(value) : copyArray(value);
7908             }
7909             if (symIterator && value[symIterator]) {
7910               return iteratorToArray(value[symIterator]());
7911             }
7912             var tag2 = getTag2(value), func = tag2 == mapTag4 ? mapToArray2 : tag2 == setTag4 ? setToArray2 : values;
7913             return func(value);
7914           }
7915           function toFinite(value) {
7916             if (!value) {
7917               return value === 0 ? value : 0;
7918             }
7919             value = toNumber3(value);
7920             if (value === INFINITY2 || value === -INFINITY2) {
7921               var sign2 = value < 0 ? -1 : 1;
7922               return sign2 * MAX_INTEGER;
7923             }
7924             return value === value ? value : 0;
7925           }
7926           function toInteger(value) {
7927             var result2 = toFinite(value), remainder = result2 % 1;
7928             return result2 === result2 ? remainder ? result2 - remainder : result2 : 0;
7929           }
7930           function toLength(value) {
7931             return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
7932           }
7933           function toNumber3(value) {
7934             if (typeof value == "number") {
7935               return value;
7936             }
7937             if (isSymbol2(value)) {
7938               return NAN2;
7939             }
7940             if (isObject2(value)) {
7941               var other2 = typeof value.valueOf == "function" ? value.valueOf() : value;
7942               value = isObject2(other2) ? other2 + "" : other2;
7943             }
7944             if (typeof value != "string") {
7945               return value === 0 ? value : +value;
7946             }
7947             value = baseTrim2(value);
7948             var isBinary = reIsBinary2.test(value);
7949             return isBinary || reIsOctal2.test(value) ? freeParseInt2(value.slice(2), isBinary ? 2 : 8) : reIsBadHex2.test(value) ? NAN2 : +value;
7950           }
7951           function toPlainObject(value) {
7952             return copyObject(value, keysIn(value));
7953           }
7954           function toSafeInteger(value) {
7955             return value ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER4, MAX_SAFE_INTEGER4) : value === 0 ? value : 0;
7956           }
7957           function toString2(value) {
7958             return value == null ? "" : baseToString2(value);
7959           }
7960           var assign = createAssigner(function(object, source) {
7961             if (isPrototype2(source) || isArrayLike2(source)) {
7962               copyObject(source, keys2(source), object);
7963               return;
7964             }
7965             for (var key in source) {
7966               if (hasOwnProperty10.call(source, key)) {
7967                 assignValue(object, key, source[key]);
7968               }
7969             }
7970           });
7971           var assignIn = createAssigner(function(object, source) {
7972             copyObject(source, keysIn(source), object);
7973           });
7974           var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
7975             copyObject(source, keysIn(source), object, customizer);
7976           });
7977           var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
7978             copyObject(source, keys2(source), object, customizer);
7979           });
7980           var at2 = flatRest(baseAt);
7981           function create2(prototype, properties) {
7982             var result2 = baseCreate(prototype);
7983             return properties == null ? result2 : baseAssign(result2, properties);
7984           }
7985           var defaults = baseRest(function(object, sources) {
7986             object = Object2(object);
7987             var index = -1;
7988             var length2 = sources.length;
7989             var guard = length2 > 2 ? sources[2] : undefined2;
7990             if (guard && isIterateeCall(sources[0], sources[1], guard)) {
7991               length2 = 1;
7992             }
7993             while (++index < length2) {
7994               var source = sources[index];
7995               var props = keysIn(source);
7996               var propsIndex = -1;
7997               var propsLength = props.length;
7998               while (++propsIndex < propsLength) {
7999                 var key = props[propsIndex];
8000                 var value = object[key];
8001                 if (value === undefined2 || eq2(value, objectProto13[key]) && !hasOwnProperty10.call(object, key)) {
8002                   object[key] = source[key];
8003                 }
8004               }
8005             }
8006             return object;
8007           });
8008           var defaultsDeep = baseRest(function(args) {
8009             args.push(undefined2, customDefaultsMerge);
8010             return apply(mergeWith, undefined2, args);
8011           });
8012           function findKey(object, predicate) {
8013             return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
8014           }
8015           function findLastKey(object, predicate) {
8016             return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
8017           }
8018           function forIn(object, iteratee2) {
8019             return object == null ? object : baseFor(object, getIteratee(iteratee2, 3), keysIn);
8020           }
8021           function forInRight(object, iteratee2) {
8022             return object == null ? object : baseForRight(object, getIteratee(iteratee2, 3), keysIn);
8023           }
8024           function forOwn(object, iteratee2) {
8025             return object && baseForOwn(object, getIteratee(iteratee2, 3));
8026           }
8027           function forOwnRight(object, iteratee2) {
8028             return object && baseForOwnRight(object, getIteratee(iteratee2, 3));
8029           }
8030           function functions(object) {
8031             return object == null ? [] : baseFunctions(object, keys2(object));
8032           }
8033           function functionsIn(object) {
8034             return object == null ? [] : baseFunctions(object, keysIn(object));
8035           }
8036           function get4(object, path, defaultValue) {
8037             var result2 = object == null ? undefined2 : baseGet(object, path);
8038             return result2 === undefined2 ? defaultValue : result2;
8039           }
8040           function has(object, path) {
8041             return object != null && hasPath(object, path, baseHas);
8042           }
8043           function hasIn(object, path) {
8044             return object != null && hasPath(object, path, baseHasIn);
8045           }
8046           var invert = createInverter(function(result2, value, key) {
8047             if (value != null && typeof value.toString != "function") {
8048               value = nativeObjectToString3.call(value);
8049             }
8050             result2[value] = key;
8051           }, constant(identity4));
8052           var invertBy = createInverter(function(result2, value, key) {
8053             if (value != null && typeof value.toString != "function") {
8054               value = nativeObjectToString3.call(value);
8055             }
8056             if (hasOwnProperty10.call(result2, value)) {
8057               result2[value].push(key);
8058             } else {
8059               result2[value] = [key];
8060             }
8061           }, getIteratee);
8062           var invoke = baseRest(baseInvoke);
8063           function keys2(object) {
8064             return isArrayLike2(object) ? arrayLikeKeys2(object) : baseKeys2(object);
8065           }
8066           function keysIn(object) {
8067             return isArrayLike2(object) ? arrayLikeKeys2(object, true) : baseKeysIn(object);
8068           }
8069           function mapKeys(object, iteratee2) {
8070             var result2 = {};
8071             iteratee2 = getIteratee(iteratee2, 3);
8072             baseForOwn(object, function(value, key, object2) {
8073               baseAssignValue(result2, iteratee2(value, key, object2), value);
8074             });
8075             return result2;
8076           }
8077           function mapValues(object, iteratee2) {
8078             var result2 = {};
8079             iteratee2 = getIteratee(iteratee2, 3);
8080             baseForOwn(object, function(value, key, object2) {
8081               baseAssignValue(result2, key, iteratee2(value, key, object2));
8082             });
8083             return result2;
8084           }
8085           var merge2 = createAssigner(function(object, source, srcIndex) {
8086             baseMerge(object, source, srcIndex);
8087           });
8088           var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
8089             baseMerge(object, source, srcIndex, customizer);
8090           });
8091           var omit = flatRest(function(object, paths) {
8092             var result2 = {};
8093             if (object == null) {
8094               return result2;
8095             }
8096             var isDeep = false;
8097             paths = arrayMap2(paths, function(path) {
8098               path = castPath(path, object);
8099               isDeep || (isDeep = path.length > 1);
8100               return path;
8101             });
8102             copyObject(object, getAllKeysIn(object), result2);
8103             if (isDeep) {
8104               result2 = baseClone(result2, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
8105             }
8106             var length2 = paths.length;
8107             while (length2--) {
8108               baseUnset(result2, paths[length2]);
8109             }
8110             return result2;
8111           });
8112           function omitBy(object, predicate) {
8113             return pickBy(object, negate(getIteratee(predicate)));
8114           }
8115           var pick = flatRest(function(object, paths) {
8116             return object == null ? {} : basePick(object, paths);
8117           });
8118           function pickBy(object, predicate) {
8119             if (object == null) {
8120               return {};
8121             }
8122             var props = arrayMap2(getAllKeysIn(object), function(prop) {
8123               return [prop];
8124             });
8125             predicate = getIteratee(predicate);
8126             return basePickBy(object, props, function(value, path) {
8127               return predicate(value, path[0]);
8128             });
8129           }
8130           function result(object, path, defaultValue) {
8131             path = castPath(path, object);
8132             var index = -1, length2 = path.length;
8133             if (!length2) {
8134               length2 = 1;
8135               object = undefined2;
8136             }
8137             while (++index < length2) {
8138               var value = object == null ? undefined2 : object[toKey(path[index])];
8139               if (value === undefined2) {
8140                 index = length2;
8141                 value = defaultValue;
8142               }
8143               object = isFunction2(value) ? value.call(object) : value;
8144             }
8145             return object;
8146           }
8147           function set4(object, path, value) {
8148             return object == null ? object : baseSet(object, path, value);
8149           }
8150           function setWith(object, path, value, customizer) {
8151             customizer = typeof customizer == "function" ? customizer : undefined2;
8152             return object == null ? object : baseSet(object, path, value, customizer);
8153           }
8154           var toPairs = createToPairs(keys2);
8155           var toPairsIn = createToPairs(keysIn);
8156           function transform2(object, iteratee2, accumulator) {
8157             var isArr = isArray2(object), isArrLike = isArr || isBuffer2(object) || isTypedArray2(object);
8158             iteratee2 = getIteratee(iteratee2, 4);
8159             if (accumulator == null) {
8160               var Ctor = object && object.constructor;
8161               if (isArrLike) {
8162                 accumulator = isArr ? new Ctor() : [];
8163               } else if (isObject2(object)) {
8164                 accumulator = isFunction2(Ctor) ? baseCreate(getPrototype(object)) : {};
8165               } else {
8166                 accumulator = {};
8167               }
8168             }
8169             (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object2) {
8170               return iteratee2(accumulator, value, index, object2);
8171             });
8172             return accumulator;
8173           }
8174           function unset(object, path) {
8175             return object == null ? true : baseUnset(object, path);
8176           }
8177           function update(object, path, updater) {
8178             return object == null ? object : baseUpdate(object, path, castFunction(updater));
8179           }
8180           function updateWith(object, path, updater, customizer) {
8181             customizer = typeof customizer == "function" ? customizer : undefined2;
8182             return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
8183           }
8184           function values(object) {
8185             return object == null ? [] : baseValues(object, keys2(object));
8186           }
8187           function valuesIn(object) {
8188             return object == null ? [] : baseValues(object, keysIn(object));
8189           }
8190           function clamp3(number3, lower2, upper) {
8191             if (upper === undefined2) {
8192               upper = lower2;
8193               lower2 = undefined2;
8194             }
8195             if (upper !== undefined2) {
8196               upper = toNumber3(upper);
8197               upper = upper === upper ? upper : 0;
8198             }
8199             if (lower2 !== undefined2) {
8200               lower2 = toNumber3(lower2);
8201               lower2 = lower2 === lower2 ? lower2 : 0;
8202             }
8203             return baseClamp(toNumber3(number3), lower2, upper);
8204           }
8205           function inRange(number3, start2, end) {
8206             start2 = toFinite(start2);
8207             if (end === undefined2) {
8208               end = start2;
8209               start2 = 0;
8210             } else {
8211               end = toFinite(end);
8212             }
8213             number3 = toNumber3(number3);
8214             return baseInRange(number3, start2, end);
8215           }
8216           function random(lower2, upper, floating) {
8217             if (floating && typeof floating != "boolean" && isIterateeCall(lower2, upper, floating)) {
8218               upper = floating = undefined2;
8219             }
8220             if (floating === undefined2) {
8221               if (typeof upper == "boolean") {
8222                 floating = upper;
8223                 upper = undefined2;
8224               } else if (typeof lower2 == "boolean") {
8225                 floating = lower2;
8226                 lower2 = undefined2;
8227               }
8228             }
8229             if (lower2 === undefined2 && upper === undefined2) {
8230               lower2 = 0;
8231               upper = 1;
8232             } else {
8233               lower2 = toFinite(lower2);
8234               if (upper === undefined2) {
8235                 upper = lower2;
8236                 lower2 = 0;
8237               } else {
8238                 upper = toFinite(upper);
8239               }
8240             }
8241             if (lower2 > upper) {
8242               var temp = lower2;
8243               lower2 = upper;
8244               upper = temp;
8245             }
8246             if (floating || lower2 % 1 || upper % 1) {
8247               var rand = nativeRandom();
8248               return nativeMin2(lower2 + rand * (upper - lower2 + freeParseFloat("1e-" + ((rand + "").length - 1))), upper);
8249             }
8250             return baseRandom(lower2, upper);
8251           }
8252           var camelCase = createCompounder(function(result2, word, index) {
8253             word = word.toLowerCase();
8254             return result2 + (index ? capitalize(word) : word);
8255           });
8256           function capitalize(string) {
8257             return upperFirst(toString2(string).toLowerCase());
8258           }
8259           function deburr(string) {
8260             string = toString2(string);
8261             return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
8262           }
8263           function endsWith(string, target, position) {
8264             string = toString2(string);
8265             target = baseToString2(target);
8266             var length2 = string.length;
8267             position = position === undefined2 ? length2 : baseClamp(toInteger(position), 0, length2);
8268             var end = position;
8269             position -= target.length;
8270             return position >= 0 && string.slice(position, end) == target;
8271           }
8272           function escape6(string) {
8273             string = toString2(string);
8274             return string && reHasUnescapedHtml2.test(string) ? string.replace(reUnescapedHtml2, escapeHtmlChar2) : string;
8275           }
8276           function escapeRegExp(string) {
8277             string = toString2(string);
8278             return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar2, "\\$&") : string;
8279           }
8280           var kebabCase = createCompounder(function(result2, word, index) {
8281             return result2 + (index ? "-" : "") + word.toLowerCase();
8282           });
8283           var lowerCase = createCompounder(function(result2, word, index) {
8284             return result2 + (index ? " " : "") + word.toLowerCase();
8285           });
8286           var lowerFirst = createCaseFirst("toLowerCase");
8287           function pad2(string, length2, chars) {
8288             string = toString2(string);
8289             length2 = toInteger(length2);
8290             var strLength = length2 ? stringSize(string) : 0;
8291             if (!length2 || strLength >= length2) {
8292               return string;
8293             }
8294             var mid = (length2 - strLength) / 2;
8295             return createPadding(nativeFloor(mid), chars) + string + createPadding(nativeCeil(mid), chars);
8296           }
8297           function padEnd(string, length2, chars) {
8298             string = toString2(string);
8299             length2 = toInteger(length2);
8300             var strLength = length2 ? stringSize(string) : 0;
8301             return length2 && strLength < length2 ? string + createPadding(length2 - strLength, chars) : string;
8302           }
8303           function padStart(string, length2, chars) {
8304             string = toString2(string);
8305             length2 = toInteger(length2);
8306             var strLength = length2 ? stringSize(string) : 0;
8307             return length2 && strLength < length2 ? createPadding(length2 - strLength, chars) + string : string;
8308           }
8309           function parseInt2(string, radix, guard) {
8310             if (guard || radix == null) {
8311               radix = 0;
8312             } else if (radix) {
8313               radix = +radix;
8314             }
8315             return nativeParseInt(toString2(string).replace(reTrimStart2, ""), radix || 0);
8316           }
8317           function repeat(string, n3, guard) {
8318             if (guard ? isIterateeCall(string, n3, guard) : n3 === undefined2) {
8319               n3 = 1;
8320             } else {
8321               n3 = toInteger(n3);
8322             }
8323             return baseRepeat(toString2(string), n3);
8324           }
8325           function replace() {
8326             var args = arguments, string = toString2(args[0]);
8327             return args.length < 3 ? string : string.replace(args[1], args[2]);
8328           }
8329           var snakeCase = createCompounder(function(result2, word, index) {
8330             return result2 + (index ? "_" : "") + word.toLowerCase();
8331           });
8332           function split(string, separator, limit) {
8333             if (limit && typeof limit != "number" && isIterateeCall(string, separator, limit)) {
8334               separator = limit = undefined2;
8335             }
8336             limit = limit === undefined2 ? MAX_ARRAY_LENGTH : limit >>> 0;
8337             if (!limit) {
8338               return [];
8339             }
8340             string = toString2(string);
8341             if (string && (typeof separator == "string" || separator != null && !isRegExp(separator))) {
8342               separator = baseToString2(separator);
8343               if (!separator && hasUnicode(string)) {
8344                 return castSlice(stringToArray(string), 0, limit);
8345               }
8346             }
8347             return string.split(separator, limit);
8348           }
8349           var startCase = createCompounder(function(result2, word, index) {
8350             return result2 + (index ? " " : "") + upperFirst(word);
8351           });
8352           function startsWith(string, target, position) {
8353             string = toString2(string);
8354             position = position == null ? 0 : baseClamp(toInteger(position), 0, string.length);
8355             target = baseToString2(target);
8356             return string.slice(position, position + target.length) == target;
8357           }
8358           function template(string, options2, guard) {
8359             var settings = lodash.templateSettings;
8360             if (guard && isIterateeCall(string, options2, guard)) {
8361               options2 = undefined2;
8362             }
8363             string = toString2(string);
8364             options2 = assignInWith({}, options2, settings, customDefaultsAssignIn);
8365             var imports = assignInWith({}, options2.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys2(imports), importsValues = baseValues(imports, importsKeys);
8366             var isEscaping, isEvaluating, index = 0, interpolate = options2.interpolate || reNoMatch, source = "__p += '";
8367             var reDelimiters = RegExp2(
8368               (options2.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options2.evaluate || reNoMatch).source + "|$",
8369               "g"
8370             );
8371             var sourceURL = "//# sourceURL=" + (hasOwnProperty10.call(options2, "sourceURL") ? (options2.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++templateCounter + "]") + "\n";
8372             string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
8373               interpolateValue || (interpolateValue = esTemplateValue);
8374               source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
8375               if (escapeValue) {
8376                 isEscaping = true;
8377                 source += "' +\n__e(" + escapeValue + ") +\n'";
8378               }
8379               if (evaluateValue) {
8380                 isEvaluating = true;
8381                 source += "';\n" + evaluateValue + ";\n__p += '";
8382               }
8383               if (interpolateValue) {
8384                 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
8385               }
8386               index = offset + match.length;
8387               return match;
8388             });
8389             source += "';\n";
8390             var variable = hasOwnProperty10.call(options2, "variable") && options2.variable;
8391             if (!variable) {
8392               source = "with (obj) {\n" + source + "\n}\n";
8393             } else if (reForbiddenIdentifierChars.test(variable)) {
8394               throw new Error2(INVALID_TEMPL_VAR_ERROR_TEXT);
8395             }
8396             source = (isEvaluating ? source.replace(reEmptyStringLeading, "") : source).replace(reEmptyStringMiddle, "$1").replace(reEmptyStringTrailing, "$1;");
8397             source = "function(" + (variable || "obj") + ") {\n" + (variable ? "" : "obj || (obj = {});\n") + "var __t, __p = ''" + (isEscaping ? ", __e = _.escape" : "") + (isEvaluating ? ", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n" : ";\n") + source + "return __p\n}";
8398             var result2 = attempt(function() {
8399               return Function2(importsKeys, sourceURL + "return " + source).apply(undefined2, importsValues);
8400             });
8401             result2.source = source;
8402             if (isError(result2)) {
8403               throw result2;
8404             }
8405             return result2;
8406           }
8407           function toLower(value) {
8408             return toString2(value).toLowerCase();
8409           }
8410           function toUpper(value) {
8411             return toString2(value).toUpperCase();
8412           }
8413           function trim(string, chars, guard) {
8414             string = toString2(string);
8415             if (string && (guard || chars === undefined2)) {
8416               return baseTrim2(string);
8417             }
8418             if (!string || !(chars = baseToString2(chars))) {
8419               return string;
8420             }
8421             var strSymbols = stringToArray(string), chrSymbols = stringToArray(chars), start2 = charsStartIndex(strSymbols, chrSymbols), end = charsEndIndex(strSymbols, chrSymbols) + 1;
8422             return castSlice(strSymbols, start2, end).join("");
8423           }
8424           function trimEnd(string, chars, guard) {
8425             string = toString2(string);
8426             if (string && (guard || chars === undefined2)) {
8427               return string.slice(0, trimmedEndIndex2(string) + 1);
8428             }
8429             if (!string || !(chars = baseToString2(chars))) {
8430               return string;
8431             }
8432             var strSymbols = stringToArray(string), end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
8433             return castSlice(strSymbols, 0, end).join("");
8434           }
8435           function trimStart(string, chars, guard) {
8436             string = toString2(string);
8437             if (string && (guard || chars === undefined2)) {
8438               return string.replace(reTrimStart2, "");
8439             }
8440             if (!string || !(chars = baseToString2(chars))) {
8441               return string;
8442             }
8443             var strSymbols = stringToArray(string), start2 = charsStartIndex(strSymbols, stringToArray(chars));
8444             return castSlice(strSymbols, start2).join("");
8445           }
8446           function truncate(string, options2) {
8447             var length2 = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
8448             if (isObject2(options2)) {
8449               var separator = "separator" in options2 ? options2.separator : separator;
8450               length2 = "length" in options2 ? toInteger(options2.length) : length2;
8451               omission = "omission" in options2 ? baseToString2(options2.omission) : omission;
8452             }
8453             string = toString2(string);
8454             var strLength = string.length;
8455             if (hasUnicode(string)) {
8456               var strSymbols = stringToArray(string);
8457               strLength = strSymbols.length;
8458             }
8459             if (length2 >= strLength) {
8460               return string;
8461             }
8462             var end = length2 - stringSize(omission);
8463             if (end < 1) {
8464               return omission;
8465             }
8466             var result2 = strSymbols ? castSlice(strSymbols, 0, end).join("") : string.slice(0, end);
8467             if (separator === undefined2) {
8468               return result2 + omission;
8469             }
8470             if (strSymbols) {
8471               end += result2.length - end;
8472             }
8473             if (isRegExp(separator)) {
8474               if (string.slice(end).search(separator)) {
8475                 var match, substring = result2;
8476                 if (!separator.global) {
8477                   separator = RegExp2(separator.source, toString2(reFlags.exec(separator)) + "g");
8478                 }
8479                 separator.lastIndex = 0;
8480                 while (match = separator.exec(substring)) {
8481                   var newEnd = match.index;
8482                 }
8483                 result2 = result2.slice(0, newEnd === undefined2 ? end : newEnd);
8484               }
8485             } else if (string.indexOf(baseToString2(separator), end) != end) {
8486               var index = result2.lastIndexOf(separator);
8487               if (index > -1) {
8488                 result2 = result2.slice(0, index);
8489               }
8490             }
8491             return result2 + omission;
8492           }
8493           function unescape2(string) {
8494             string = toString2(string);
8495             return string && reHasEscapedHtml2.test(string) ? string.replace(reEscapedHtml2, unescapeHtmlChar2) : string;
8496           }
8497           var upperCase = createCompounder(function(result2, word, index) {
8498             return result2 + (index ? " " : "") + word.toUpperCase();
8499           });
8500           var upperFirst = createCaseFirst("toUpperCase");
8501           function words(string, pattern, guard) {
8502             string = toString2(string);
8503             pattern = guard ? undefined2 : pattern;
8504             if (pattern === undefined2) {
8505               return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
8506             }
8507             return string.match(pattern) || [];
8508           }
8509           var attempt = baseRest(function(func, args) {
8510             try {
8511               return apply(func, undefined2, args);
8512             } catch (e3) {
8513               return isError(e3) ? e3 : new Error2(e3);
8514             }
8515           });
8516           var bindAll = flatRest(function(object, methodNames) {
8517             arrayEach(methodNames, function(key) {
8518               key = toKey(key);
8519               baseAssignValue(object, key, bind(object[key], object));
8520             });
8521             return object;
8522           });
8523           function cond(pairs2) {
8524             var length2 = pairs2 == null ? 0 : pairs2.length, toIteratee = getIteratee();
8525             pairs2 = !length2 ? [] : arrayMap2(pairs2, function(pair3) {
8526               if (typeof pair3[1] != "function") {
8527                 throw new TypeError2(FUNC_ERROR_TEXT3);
8528               }
8529               return [toIteratee(pair3[0]), pair3[1]];
8530             });
8531             return baseRest(function(args) {
8532               var index = -1;
8533               while (++index < length2) {
8534                 var pair3 = pairs2[index];
8535                 if (apply(pair3[0], this, args)) {
8536                   return apply(pair3[1], this, args);
8537                 }
8538               }
8539             });
8540           }
8541           function conforms(source) {
8542             return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
8543           }
8544           function constant(value) {
8545             return function() {
8546               return value;
8547             };
8548           }
8549           function defaultTo(value, defaultValue) {
8550             return value == null || value !== value ? defaultValue : value;
8551           }
8552           var flow = createFlow();
8553           var flowRight = createFlow(true);
8554           function identity4(value) {
8555             return value;
8556           }
8557           function iteratee(func) {
8558             return baseIteratee(typeof func == "function" ? func : baseClone(func, CLONE_DEEP_FLAG));
8559           }
8560           function matches(source) {
8561             return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
8562           }
8563           function matchesProperty(path, srcValue) {
8564             return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
8565           }
8566           var method = baseRest(function(path, args) {
8567             return function(object) {
8568               return baseInvoke(object, path, args);
8569             };
8570           });
8571           var methodOf = baseRest(function(object, args) {
8572             return function(path) {
8573               return baseInvoke(object, path, args);
8574             };
8575           });
8576           function mixin(object, source, options2) {
8577             var props = keys2(source), methodNames = baseFunctions(source, props);
8578             if (options2 == null && !(isObject2(source) && (methodNames.length || !props.length))) {
8579               options2 = source;
8580               source = object;
8581               object = this;
8582               methodNames = baseFunctions(source, keys2(source));
8583             }
8584             var chain2 = !(isObject2(options2) && "chain" in options2) || !!options2.chain, isFunc = isFunction2(object);
8585             arrayEach(methodNames, function(methodName) {
8586               var func = source[methodName];
8587               object[methodName] = func;
8588               if (isFunc) {
8589                 object.prototype[methodName] = function() {
8590                   var chainAll = this.__chain__;
8591                   if (chain2 || chainAll) {
8592                     var result2 = object(this.__wrapped__), actions = result2.__actions__ = copyArray(this.__actions__);
8593                     actions.push({ "func": func, "args": arguments, "thisArg": object });
8594                     result2.__chain__ = chainAll;
8595                     return result2;
8596                   }
8597                   return func.apply(object, arrayPush2([this.value()], arguments));
8598                 };
8599               }
8600             });
8601             return object;
8602           }
8603           function noConflict() {
8604             if (root3._ === this) {
8605               root3._ = oldDash;
8606             }
8607             return this;
8608           }
8609           function noop3() {
8610           }
8611           function nthArg(n3) {
8612             n3 = toInteger(n3);
8613             return baseRest(function(args) {
8614               return baseNth(args, n3);
8615             });
8616           }
8617           var over = createOver(arrayMap2);
8618           var overEvery = createOver(arrayEvery);
8619           var overSome = createOver(arraySome2);
8620           function property(path) {
8621             return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
8622           }
8623           function propertyOf(object) {
8624             return function(path) {
8625               return object == null ? undefined2 : baseGet(object, path);
8626             };
8627           }
8628           var range3 = createRange();
8629           var rangeRight = createRange(true);
8630           function stubArray2() {
8631             return [];
8632           }
8633           function stubFalse2() {
8634             return false;
8635           }
8636           function stubObject() {
8637             return {};
8638           }
8639           function stubString() {
8640             return "";
8641           }
8642           function stubTrue() {
8643             return true;
8644           }
8645           function times(n3, iteratee2) {
8646             n3 = toInteger(n3);
8647             if (n3 < 1 || n3 > MAX_SAFE_INTEGER4) {
8648               return [];
8649             }
8650             var index = MAX_ARRAY_LENGTH, length2 = nativeMin2(n3, MAX_ARRAY_LENGTH);
8651             iteratee2 = getIteratee(iteratee2);
8652             n3 -= MAX_ARRAY_LENGTH;
8653             var result2 = baseTimes2(length2, iteratee2);
8654             while (++index < n3) {
8655               iteratee2(index);
8656             }
8657             return result2;
8658           }
8659           function toPath(value) {
8660             if (isArray2(value)) {
8661               return arrayMap2(value, toKey);
8662             }
8663             return isSymbol2(value) ? [value] : copyArray(stringToPath(toString2(value)));
8664           }
8665           function uniqueId(prefix) {
8666             var id2 = ++idCounter;
8667             return toString2(prefix) + id2;
8668           }
8669           var add = createMathOperation(function(augend, addend) {
8670             return augend + addend;
8671           }, 0);
8672           var ceil = createRound("ceil");
8673           var divide = createMathOperation(function(dividend, divisor) {
8674             return dividend / divisor;
8675           }, 1);
8676           var floor = createRound("floor");
8677           function max3(array2) {
8678             return array2 && array2.length ? baseExtremum(array2, identity4, baseGt) : undefined2;
8679           }
8680           function maxBy(array2, iteratee2) {
8681             return array2 && array2.length ? baseExtremum(array2, getIteratee(iteratee2, 2), baseGt) : undefined2;
8682           }
8683           function mean(array2) {
8684             return baseMean(array2, identity4);
8685           }
8686           function meanBy(array2, iteratee2) {
8687             return baseMean(array2, getIteratee(iteratee2, 2));
8688           }
8689           function min3(array2) {
8690             return array2 && array2.length ? baseExtremum(array2, identity4, baseLt) : undefined2;
8691           }
8692           function minBy(array2, iteratee2) {
8693             return array2 && array2.length ? baseExtremum(array2, getIteratee(iteratee2, 2), baseLt) : undefined2;
8694           }
8695           var multiply = createMathOperation(function(multiplier, multiplicand) {
8696             return multiplier * multiplicand;
8697           }, 1);
8698           var round = createRound("round");
8699           var subtract = createMathOperation(function(minuend, subtrahend) {
8700             return minuend - subtrahend;
8701           }, 0);
8702           function sum(array2) {
8703             return array2 && array2.length ? baseSum(array2, identity4) : 0;
8704           }
8705           function sumBy(array2, iteratee2) {
8706             return array2 && array2.length ? baseSum(array2, getIteratee(iteratee2, 2)) : 0;
8707           }
8708           lodash.after = after;
8709           lodash.ary = ary;
8710           lodash.assign = assign;
8711           lodash.assignIn = assignIn;
8712           lodash.assignInWith = assignInWith;
8713           lodash.assignWith = assignWith;
8714           lodash.at = at2;
8715           lodash.before = before;
8716           lodash.bind = bind;
8717           lodash.bindAll = bindAll;
8718           lodash.bindKey = bindKey2;
8719           lodash.castArray = castArray;
8720           lodash.chain = chain;
8721           lodash.chunk = chunk;
8722           lodash.compact = compact;
8723           lodash.concat = concat;
8724           lodash.cond = cond;
8725           lodash.conforms = conforms;
8726           lodash.constant = constant;
8727           lodash.countBy = countBy;
8728           lodash.create = create2;
8729           lodash.curry = curry;
8730           lodash.curryRight = curryRight;
8731           lodash.debounce = debounce2;
8732           lodash.defaults = defaults;
8733           lodash.defaultsDeep = defaultsDeep;
8734           lodash.defer = defer;
8735           lodash.delay = delay;
8736           lodash.difference = difference2;
8737           lodash.differenceBy = differenceBy;
8738           lodash.differenceWith = differenceWith;
8739           lodash.drop = drop;
8740           lodash.dropRight = dropRight;
8741           lodash.dropRightWhile = dropRightWhile;
8742           lodash.dropWhile = dropWhile;
8743           lodash.fill = fill;
8744           lodash.filter = filter2;
8745           lodash.flatMap = flatMap;
8746           lodash.flatMapDeep = flatMapDeep;
8747           lodash.flatMapDepth = flatMapDepth;
8748           lodash.flatten = flatten2;
8749           lodash.flattenDeep = flattenDeep;
8750           lodash.flattenDepth = flattenDepth;
8751           lodash.flip = flip;
8752           lodash.flow = flow;
8753           lodash.flowRight = flowRight;
8754           lodash.fromPairs = fromPairs;
8755           lodash.functions = functions;
8756           lodash.functionsIn = functionsIn;
8757           lodash.groupBy = groupBy;
8758           lodash.initial = initial;
8759           lodash.intersection = intersection2;
8760           lodash.intersectionBy = intersectionBy;
8761           lodash.intersectionWith = intersectionWith;
8762           lodash.invert = invert;
8763           lodash.invertBy = invertBy;
8764           lodash.invokeMap = invokeMap;
8765           lodash.iteratee = iteratee;
8766           lodash.keyBy = keyBy;
8767           lodash.keys = keys2;
8768           lodash.keysIn = keysIn;
8769           lodash.map = map2;
8770           lodash.mapKeys = mapKeys;
8771           lodash.mapValues = mapValues;
8772           lodash.matches = matches;
8773           lodash.matchesProperty = matchesProperty;
8774           lodash.memoize = memoize;
8775           lodash.merge = merge2;
8776           lodash.mergeWith = mergeWith;
8777           lodash.method = method;
8778           lodash.methodOf = methodOf;
8779           lodash.mixin = mixin;
8780           lodash.negate = negate;
8781           lodash.nthArg = nthArg;
8782           lodash.omit = omit;
8783           lodash.omitBy = omitBy;
8784           lodash.once = once;
8785           lodash.orderBy = orderBy;
8786           lodash.over = over;
8787           lodash.overArgs = overArgs;
8788           lodash.overEvery = overEvery;
8789           lodash.overSome = overSome;
8790           lodash.partial = partial;
8791           lodash.partialRight = partialRight;
8792           lodash.partition = partition;
8793           lodash.pick = pick;
8794           lodash.pickBy = pickBy;
8795           lodash.property = property;
8796           lodash.propertyOf = propertyOf;
8797           lodash.pull = pull;
8798           lodash.pullAll = pullAll;
8799           lodash.pullAllBy = pullAllBy;
8800           lodash.pullAllWith = pullAllWith;
8801           lodash.pullAt = pullAt;
8802           lodash.range = range3;
8803           lodash.rangeRight = rangeRight;
8804           lodash.rearg = rearg;
8805           lodash.reject = reject;
8806           lodash.remove = remove2;
8807           lodash.rest = rest;
8808           lodash.reverse = reverse;
8809           lodash.sampleSize = sampleSize;
8810           lodash.set = set4;
8811           lodash.setWith = setWith;
8812           lodash.shuffle = shuffle;
8813           lodash.slice = slice;
8814           lodash.sortBy = sortBy;
8815           lodash.sortedUniq = sortedUniq;
8816           lodash.sortedUniqBy = sortedUniqBy;
8817           lodash.split = split;
8818           lodash.spread = spread;
8819           lodash.tail = tail;
8820           lodash.take = take;
8821           lodash.takeRight = takeRight;
8822           lodash.takeRightWhile = takeRightWhile;
8823           lodash.takeWhile = takeWhile;
8824           lodash.tap = tap;
8825           lodash.throttle = throttle2;
8826           lodash.thru = thru;
8827           lodash.toArray = toArray;
8828           lodash.toPairs = toPairs;
8829           lodash.toPairsIn = toPairsIn;
8830           lodash.toPath = toPath;
8831           lodash.toPlainObject = toPlainObject;
8832           lodash.transform = transform2;
8833           lodash.unary = unary;
8834           lodash.union = union2;
8835           lodash.unionBy = unionBy;
8836           lodash.unionWith = unionWith;
8837           lodash.uniq = uniq;
8838           lodash.uniqBy = uniqBy;
8839           lodash.uniqWith = uniqWith;
8840           lodash.unset = unset;
8841           lodash.unzip = unzip;
8842           lodash.unzipWith = unzipWith;
8843           lodash.update = update;
8844           lodash.updateWith = updateWith;
8845           lodash.values = values;
8846           lodash.valuesIn = valuesIn;
8847           lodash.without = without;
8848           lodash.words = words;
8849           lodash.wrap = wrap2;
8850           lodash.xor = xor;
8851           lodash.xorBy = xorBy;
8852           lodash.xorWith = xorWith;
8853           lodash.zip = zip;
8854           lodash.zipObject = zipObject;
8855           lodash.zipObjectDeep = zipObjectDeep;
8856           lodash.zipWith = zipWith;
8857           lodash.entries = toPairs;
8858           lodash.entriesIn = toPairsIn;
8859           lodash.extend = assignIn;
8860           lodash.extendWith = assignInWith;
8861           mixin(lodash, lodash);
8862           lodash.add = add;
8863           lodash.attempt = attempt;
8864           lodash.camelCase = camelCase;
8865           lodash.capitalize = capitalize;
8866           lodash.ceil = ceil;
8867           lodash.clamp = clamp3;
8868           lodash.clone = clone2;
8869           lodash.cloneDeep = cloneDeep;
8870           lodash.cloneDeepWith = cloneDeepWith;
8871           lodash.cloneWith = cloneWith;
8872           lodash.conformsTo = conformsTo;
8873           lodash.deburr = deburr;
8874           lodash.defaultTo = defaultTo;
8875           lodash.divide = divide;
8876           lodash.endsWith = endsWith;
8877           lodash.eq = eq2;
8878           lodash.escape = escape6;
8879           lodash.escapeRegExp = escapeRegExp;
8880           lodash.every = every;
8881           lodash.find = find2;
8882           lodash.findIndex = findIndex;
8883           lodash.findKey = findKey;
8884           lodash.findLast = findLast;
8885           lodash.findLastIndex = findLastIndex;
8886           lodash.findLastKey = findLastKey;
8887           lodash.floor = floor;
8888           lodash.forEach = forEach;
8889           lodash.forEachRight = forEachRight;
8890           lodash.forIn = forIn;
8891           lodash.forInRight = forInRight;
8892           lodash.forOwn = forOwn;
8893           lodash.forOwnRight = forOwnRight;
8894           lodash.get = get4;
8895           lodash.gt = gt2;
8896           lodash.gte = gte;
8897           lodash.has = has;
8898           lodash.hasIn = hasIn;
8899           lodash.head = head;
8900           lodash.identity = identity4;
8901           lodash.includes = includes;
8902           lodash.indexOf = indexOf;
8903           lodash.inRange = inRange;
8904           lodash.invoke = invoke;
8905           lodash.isArguments = isArguments2;
8906           lodash.isArray = isArray2;
8907           lodash.isArrayBuffer = isArrayBuffer;
8908           lodash.isArrayLike = isArrayLike2;
8909           lodash.isArrayLikeObject = isArrayLikeObject;
8910           lodash.isBoolean = isBoolean;
8911           lodash.isBuffer = isBuffer2;
8912           lodash.isDate = isDate;
8913           lodash.isElement = isElement2;
8914           lodash.isEmpty = isEmpty;
8915           lodash.isEqual = isEqual4;
8916           lodash.isEqualWith = isEqualWith;
8917           lodash.isError = isError;
8918           lodash.isFinite = isFinite2;
8919           lodash.isFunction = isFunction2;
8920           lodash.isInteger = isInteger;
8921           lodash.isLength = isLength2;
8922           lodash.isMap = isMap;
8923           lodash.isMatch = isMatch;
8924           lodash.isMatchWith = isMatchWith;
8925           lodash.isNaN = isNaN2;
8926           lodash.isNative = isNative;
8927           lodash.isNil = isNil;
8928           lodash.isNull = isNull;
8929           lodash.isNumber = isNumber2;
8930           lodash.isObject = isObject2;
8931           lodash.isObjectLike = isObjectLike2;
8932           lodash.isPlainObject = isPlainObject;
8933           lodash.isRegExp = isRegExp;
8934           lodash.isSafeInteger = isSafeInteger;
8935           lodash.isSet = isSet;
8936           lodash.isString = isString;
8937           lodash.isSymbol = isSymbol2;
8938           lodash.isTypedArray = isTypedArray2;
8939           lodash.isUndefined = isUndefined;
8940           lodash.isWeakMap = isWeakMap;
8941           lodash.isWeakSet = isWeakSet;
8942           lodash.join = join;
8943           lodash.kebabCase = kebabCase;
8944           lodash.last = last;
8945           lodash.lastIndexOf = lastIndexOf;
8946           lodash.lowerCase = lowerCase;
8947           lodash.lowerFirst = lowerFirst;
8948           lodash.lt = lt2;
8949           lodash.lte = lte;
8950           lodash.max = max3;
8951           lodash.maxBy = maxBy;
8952           lodash.mean = mean;
8953           lodash.meanBy = meanBy;
8954           lodash.min = min3;
8955           lodash.minBy = minBy;
8956           lodash.stubArray = stubArray2;
8957           lodash.stubFalse = stubFalse2;
8958           lodash.stubObject = stubObject;
8959           lodash.stubString = stubString;
8960           lodash.stubTrue = stubTrue;
8961           lodash.multiply = multiply;
8962           lodash.nth = nth;
8963           lodash.noConflict = noConflict;
8964           lodash.noop = noop3;
8965           lodash.now = now3;
8966           lodash.pad = pad2;
8967           lodash.padEnd = padEnd;
8968           lodash.padStart = padStart;
8969           lodash.parseInt = parseInt2;
8970           lodash.random = random;
8971           lodash.reduce = reduce;
8972           lodash.reduceRight = reduceRight;
8973           lodash.repeat = repeat;
8974           lodash.replace = replace;
8975           lodash.result = result;
8976           lodash.round = round;
8977           lodash.runInContext = runInContext2;
8978           lodash.sample = sample;
8979           lodash.size = size;
8980           lodash.snakeCase = snakeCase;
8981           lodash.some = some;
8982           lodash.sortedIndex = sortedIndex;
8983           lodash.sortedIndexBy = sortedIndexBy;
8984           lodash.sortedIndexOf = sortedIndexOf;
8985           lodash.sortedLastIndex = sortedLastIndex;
8986           lodash.sortedLastIndexBy = sortedLastIndexBy;
8987           lodash.sortedLastIndexOf = sortedLastIndexOf;
8988           lodash.startCase = startCase;
8989           lodash.startsWith = startsWith;
8990           lodash.subtract = subtract;
8991           lodash.sum = sum;
8992           lodash.sumBy = sumBy;
8993           lodash.template = template;
8994           lodash.times = times;
8995           lodash.toFinite = toFinite;
8996           lodash.toInteger = toInteger;
8997           lodash.toLength = toLength;
8998           lodash.toLower = toLower;
8999           lodash.toNumber = toNumber3;
9000           lodash.toSafeInteger = toSafeInteger;
9001           lodash.toString = toString2;
9002           lodash.toUpper = toUpper;
9003           lodash.trim = trim;
9004           lodash.trimEnd = trimEnd;
9005           lodash.trimStart = trimStart;
9006           lodash.truncate = truncate;
9007           lodash.unescape = unescape2;
9008           lodash.uniqueId = uniqueId;
9009           lodash.upperCase = upperCase;
9010           lodash.upperFirst = upperFirst;
9011           lodash.each = forEach;
9012           lodash.eachRight = forEachRight;
9013           lodash.first = head;
9014           mixin(lodash, function() {
9015             var source = {};
9016             baseForOwn(lodash, function(func, methodName) {
9017               if (!hasOwnProperty10.call(lodash.prototype, methodName)) {
9018                 source[methodName] = func;
9019               }
9020             });
9021             return source;
9022           }(), { "chain": false });
9023           lodash.VERSION = VERSION;
9024           arrayEach(["bind", "bindKey", "curry", "curryRight", "partial", "partialRight"], function(methodName) {
9025             lodash[methodName].placeholder = lodash;
9026           });
9027           arrayEach(["drop", "take"], function(methodName, index) {
9028             LazyWrapper.prototype[methodName] = function(n3) {
9029               n3 = n3 === undefined2 ? 1 : nativeMax2(toInteger(n3), 0);
9030               var result2 = this.__filtered__ && !index ? new LazyWrapper(this) : this.clone();
9031               if (result2.__filtered__) {
9032                 result2.__takeCount__ = nativeMin2(n3, result2.__takeCount__);
9033               } else {
9034                 result2.__views__.push({
9035                   "size": nativeMin2(n3, MAX_ARRAY_LENGTH),
9036                   "type": methodName + (result2.__dir__ < 0 ? "Right" : "")
9037                 });
9038               }
9039               return result2;
9040             };
9041             LazyWrapper.prototype[methodName + "Right"] = function(n3) {
9042               return this.reverse()[methodName](n3).reverse();
9043             };
9044           });
9045           arrayEach(["filter", "map", "takeWhile"], function(methodName, index) {
9046             var type2 = index + 1, isFilter = type2 == LAZY_FILTER_FLAG || type2 == LAZY_WHILE_FLAG;
9047             LazyWrapper.prototype[methodName] = function(iteratee2) {
9048               var result2 = this.clone();
9049               result2.__iteratees__.push({
9050                 "iteratee": getIteratee(iteratee2, 3),
9051                 "type": type2
9052               });
9053               result2.__filtered__ = result2.__filtered__ || isFilter;
9054               return result2;
9055             };
9056           });
9057           arrayEach(["head", "last"], function(methodName, index) {
9058             var takeName = "take" + (index ? "Right" : "");
9059             LazyWrapper.prototype[methodName] = function() {
9060               return this[takeName](1).value()[0];
9061             };
9062           });
9063           arrayEach(["initial", "tail"], function(methodName, index) {
9064             var dropName = "drop" + (index ? "" : "Right");
9065             LazyWrapper.prototype[methodName] = function() {
9066               return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
9067             };
9068           });
9069           LazyWrapper.prototype.compact = function() {
9070             return this.filter(identity4);
9071           };
9072           LazyWrapper.prototype.find = function(predicate) {
9073             return this.filter(predicate).head();
9074           };
9075           LazyWrapper.prototype.findLast = function(predicate) {
9076             return this.reverse().find(predicate);
9077           };
9078           LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
9079             if (typeof path == "function") {
9080               return new LazyWrapper(this);
9081             }
9082             return this.map(function(value) {
9083               return baseInvoke(value, path, args);
9084             });
9085           });
9086           LazyWrapper.prototype.reject = function(predicate) {
9087             return this.filter(negate(getIteratee(predicate)));
9088           };
9089           LazyWrapper.prototype.slice = function(start2, end) {
9090             start2 = toInteger(start2);
9091             var result2 = this;
9092             if (result2.__filtered__ && (start2 > 0 || end < 0)) {
9093               return new LazyWrapper(result2);
9094             }
9095             if (start2 < 0) {
9096               result2 = result2.takeRight(-start2);
9097             } else if (start2) {
9098               result2 = result2.drop(start2);
9099             }
9100             if (end !== undefined2) {
9101               end = toInteger(end);
9102               result2 = end < 0 ? result2.dropRight(-end) : result2.take(end - start2);
9103             }
9104             return result2;
9105           };
9106           LazyWrapper.prototype.takeRightWhile = function(predicate) {
9107             return this.reverse().takeWhile(predicate).reverse();
9108           };
9109           LazyWrapper.prototype.toArray = function() {
9110             return this.take(MAX_ARRAY_LENGTH);
9111           };
9112           baseForOwn(LazyWrapper.prototype, function(func, methodName) {
9113             var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), isTaker = /^(?:head|last)$/.test(methodName), lodashFunc = lodash[isTaker ? "take" + (methodName == "last" ? "Right" : "") : methodName], retUnwrapped = isTaker || /^find/.test(methodName);
9114             if (!lodashFunc) {
9115               return;
9116             }
9117             lodash.prototype[methodName] = function() {
9118               var value = this.__wrapped__, args = isTaker ? [1] : arguments, isLazy = value instanceof LazyWrapper, iteratee2 = args[0], useLazy = isLazy || isArray2(value);
9119               var interceptor = function(value2) {
9120                 var result3 = lodashFunc.apply(lodash, arrayPush2([value2], args));
9121                 return isTaker && chainAll ? result3[0] : result3;
9122               };
9123               if (useLazy && checkIteratee && typeof iteratee2 == "function" && iteratee2.length != 1) {
9124                 isLazy = useLazy = false;
9125               }
9126               var chainAll = this.__chain__, isHybrid = !!this.__actions__.length, isUnwrapped = retUnwrapped && !chainAll, onlyLazy = isLazy && !isHybrid;
9127               if (!retUnwrapped && useLazy) {
9128                 value = onlyLazy ? value : new LazyWrapper(this);
9129                 var result2 = func.apply(value, args);
9130                 result2.__actions__.push({ "func": thru, "args": [interceptor], "thisArg": undefined2 });
9131                 return new LodashWrapper(result2, chainAll);
9132               }
9133               if (isUnwrapped && onlyLazy) {
9134                 return func.apply(this, args);
9135               }
9136               result2 = this.thru(interceptor);
9137               return isUnwrapped ? isTaker ? result2.value()[0] : result2.value() : result2;
9138             };
9139           });
9140           arrayEach(["pop", "push", "shift", "sort", "splice", "unshift"], function(methodName) {
9141             var func = arrayProto2[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:pop|shift)$/.test(methodName);
9142             lodash.prototype[methodName] = function() {
9143               var args = arguments;
9144               if (retUnwrapped && !this.__chain__) {
9145                 var value = this.value();
9146                 return func.apply(isArray2(value) ? value : [], args);
9147               }
9148               return this[chainName](function(value2) {
9149                 return func.apply(isArray2(value2) ? value2 : [], args);
9150               });
9151             };
9152           });
9153           baseForOwn(LazyWrapper.prototype, function(func, methodName) {
9154             var lodashFunc = lodash[methodName];
9155             if (lodashFunc) {
9156               var key = lodashFunc.name + "";
9157               if (!hasOwnProperty10.call(realNames, key)) {
9158                 realNames[key] = [];
9159               }
9160               realNames[key].push({ "name": methodName, "func": lodashFunc });
9161             }
9162           });
9163           realNames[createHybrid(undefined2, WRAP_BIND_KEY_FLAG).name] = [{
9164             "name": "wrapper",
9165             "func": undefined2
9166           }];
9167           LazyWrapper.prototype.clone = lazyClone;
9168           LazyWrapper.prototype.reverse = lazyReverse;
9169           LazyWrapper.prototype.value = lazyValue;
9170           lodash.prototype.at = wrapperAt;
9171           lodash.prototype.chain = wrapperChain;
9172           lodash.prototype.commit = wrapperCommit;
9173           lodash.prototype.next = wrapperNext;
9174           lodash.prototype.plant = wrapperPlant;
9175           lodash.prototype.reverse = wrapperReverse;
9176           lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
9177           lodash.prototype.first = lodash.prototype.head;
9178           if (symIterator) {
9179             lodash.prototype[symIterator] = wrapperToIterator;
9180           }
9181           return lodash;
9182         };
9183         var _2 = runInContext();
9184         if (typeof define == "function" && typeof define.amd == "object" && define.amd) {
9185           root3._ = _2;
9186           define(function() {
9187             return _2;
9188           });
9189         } else if (freeModule3) {
9190           (freeModule3.exports = _2)._ = _2;
9191           freeExports3._ = _2;
9192         } else {
9193           root3._ = _2;
9194         }
9195       }).call(exports2);
9196     }
9197   });
9198
9199   // node_modules/which-polygon/node_modules/quickselect/quickselect.js
9200   var require_quickselect = __commonJS({
9201     "node_modules/which-polygon/node_modules/quickselect/quickselect.js"(exports2, module2) {
9202       (function(global2, factory) {
9203         typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.quickselect = factory();
9204       })(exports2, function() {
9205         "use strict";
9206         function quickselect3(arr, k2, left, right, compare2) {
9207           quickselectStep(arr, k2, left || 0, right || arr.length - 1, compare2 || defaultCompare2);
9208         }
9209         function quickselectStep(arr, k2, left, right, compare2) {
9210           while (right > left) {
9211             if (right - left > 600) {
9212               var n3 = right - left + 1;
9213               var m2 = k2 - left + 1;
9214               var z2 = Math.log(n3);
9215               var s2 = 0.5 * Math.exp(2 * z2 / 3);
9216               var sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1);
9217               var newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd));
9218               var newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd));
9219               quickselectStep(arr, k2, newLeft, newRight, compare2);
9220             }
9221             var t2 = arr[k2];
9222             var i3 = left;
9223             var j2 = right;
9224             swap3(arr, left, k2);
9225             if (compare2(arr[right], t2) > 0) swap3(arr, left, right);
9226             while (i3 < j2) {
9227               swap3(arr, i3, j2);
9228               i3++;
9229               j2--;
9230               while (compare2(arr[i3], t2) < 0) i3++;
9231               while (compare2(arr[j2], t2) > 0) j2--;
9232             }
9233             if (compare2(arr[left], t2) === 0) swap3(arr, left, j2);
9234             else {
9235               j2++;
9236               swap3(arr, j2, right);
9237             }
9238             if (j2 <= k2) left = j2 + 1;
9239             if (k2 <= j2) right = j2 - 1;
9240           }
9241         }
9242         function swap3(arr, i3, j2) {
9243           var tmp = arr[i3];
9244           arr[i3] = arr[j2];
9245           arr[j2] = tmp;
9246         }
9247         function defaultCompare2(a2, b2) {
9248           return a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
9249         }
9250         return quickselect3;
9251       });
9252     }
9253   });
9254
9255   // node_modules/which-polygon/node_modules/rbush/index.js
9256   var require_rbush = __commonJS({
9257     "node_modules/which-polygon/node_modules/rbush/index.js"(exports2, module2) {
9258       "use strict";
9259       module2.exports = rbush;
9260       module2.exports.default = rbush;
9261       var quickselect3 = require_quickselect();
9262       function rbush(maxEntries, format2) {
9263         if (!(this instanceof rbush)) return new rbush(maxEntries, format2);
9264         this._maxEntries = Math.max(4, maxEntries || 9);
9265         this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
9266         if (format2) {
9267           this._initFormat(format2);
9268         }
9269         this.clear();
9270       }
9271       rbush.prototype = {
9272         all: function() {
9273           return this._all(this.data, []);
9274         },
9275         search: function(bbox2) {
9276           var node = this.data, result = [], toBBox = this.toBBox;
9277           if (!intersects2(bbox2, node)) return result;
9278           var nodesToSearch = [], i3, len, child, childBBox;
9279           while (node) {
9280             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
9281               child = node.children[i3];
9282               childBBox = node.leaf ? toBBox(child) : child;
9283               if (intersects2(bbox2, childBBox)) {
9284                 if (node.leaf) result.push(child);
9285                 else if (contains2(bbox2, childBBox)) this._all(child, result);
9286                 else nodesToSearch.push(child);
9287               }
9288             }
9289             node = nodesToSearch.pop();
9290           }
9291           return result;
9292         },
9293         collides: function(bbox2) {
9294           var node = this.data, toBBox = this.toBBox;
9295           if (!intersects2(bbox2, node)) return false;
9296           var nodesToSearch = [], i3, len, child, childBBox;
9297           while (node) {
9298             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
9299               child = node.children[i3];
9300               childBBox = node.leaf ? toBBox(child) : child;
9301               if (intersects2(bbox2, childBBox)) {
9302                 if (node.leaf || contains2(bbox2, childBBox)) return true;
9303                 nodesToSearch.push(child);
9304               }
9305             }
9306             node = nodesToSearch.pop();
9307           }
9308           return false;
9309         },
9310         load: function(data) {
9311           if (!(data && data.length)) return this;
9312           if (data.length < this._minEntries) {
9313             for (var i3 = 0, len = data.length; i3 < len; i3++) {
9314               this.insert(data[i3]);
9315             }
9316             return this;
9317           }
9318           var node = this._build(data.slice(), 0, data.length - 1, 0);
9319           if (!this.data.children.length) {
9320             this.data = node;
9321           } else if (this.data.height === node.height) {
9322             this._splitRoot(this.data, node);
9323           } else {
9324             if (this.data.height < node.height) {
9325               var tmpNode = this.data;
9326               this.data = node;
9327               node = tmpNode;
9328             }
9329             this._insert(node, this.data.height - node.height - 1, true);
9330           }
9331           return this;
9332         },
9333         insert: function(item) {
9334           if (item) this._insert(item, this.data.height - 1);
9335           return this;
9336         },
9337         clear: function() {
9338           this.data = createNode2([]);
9339           return this;
9340         },
9341         remove: function(item, equalsFn) {
9342           if (!item) return this;
9343           var node = this.data, bbox2 = this.toBBox(item), path = [], indexes = [], i3, parent, index, goingUp;
9344           while (node || path.length) {
9345             if (!node) {
9346               node = path.pop();
9347               parent = path[path.length - 1];
9348               i3 = indexes.pop();
9349               goingUp = true;
9350             }
9351             if (node.leaf) {
9352               index = findItem2(item, node.children, equalsFn);
9353               if (index !== -1) {
9354                 node.children.splice(index, 1);
9355                 path.push(node);
9356                 this._condense(path);
9357                 return this;
9358               }
9359             }
9360             if (!goingUp && !node.leaf && contains2(node, bbox2)) {
9361               path.push(node);
9362               indexes.push(i3);
9363               i3 = 0;
9364               parent = node;
9365               node = node.children[0];
9366             } else if (parent) {
9367               i3++;
9368               node = parent.children[i3];
9369               goingUp = false;
9370             } else node = null;
9371           }
9372           return this;
9373         },
9374         toBBox: function(item) {
9375           return item;
9376         },
9377         compareMinX: compareNodeMinX2,
9378         compareMinY: compareNodeMinY2,
9379         toJSON: function() {
9380           return this.data;
9381         },
9382         fromJSON: function(data) {
9383           this.data = data;
9384           return this;
9385         },
9386         _all: function(node, result) {
9387           var nodesToSearch = [];
9388           while (node) {
9389             if (node.leaf) result.push.apply(result, node.children);
9390             else nodesToSearch.push.apply(nodesToSearch, node.children);
9391             node = nodesToSearch.pop();
9392           }
9393           return result;
9394         },
9395         _build: function(items, left, right, height) {
9396           var N2 = right - left + 1, M2 = this._maxEntries, node;
9397           if (N2 <= M2) {
9398             node = createNode2(items.slice(left, right + 1));
9399             calcBBox2(node, this.toBBox);
9400             return node;
9401           }
9402           if (!height) {
9403             height = Math.ceil(Math.log(N2) / Math.log(M2));
9404             M2 = Math.ceil(N2 / Math.pow(M2, height - 1));
9405           }
9406           node = createNode2([]);
9407           node.leaf = false;
9408           node.height = height;
9409           var N22 = Math.ceil(N2 / M2), N1 = N22 * Math.ceil(Math.sqrt(M2)), i3, j2, right2, right3;
9410           multiSelect2(items, left, right, N1, this.compareMinX);
9411           for (i3 = left; i3 <= right; i3 += N1) {
9412             right2 = Math.min(i3 + N1 - 1, right);
9413             multiSelect2(items, i3, right2, N22, this.compareMinY);
9414             for (j2 = i3; j2 <= right2; j2 += N22) {
9415               right3 = Math.min(j2 + N22 - 1, right2);
9416               node.children.push(this._build(items, j2, right3, height - 1));
9417             }
9418           }
9419           calcBBox2(node, this.toBBox);
9420           return node;
9421         },
9422         _chooseSubtree: function(bbox2, node, level, path) {
9423           var i3, len, child, targetNode, area, enlargement, minArea, minEnlargement;
9424           while (true) {
9425             path.push(node);
9426             if (node.leaf || path.length - 1 === level) break;
9427             minArea = minEnlargement = Infinity;
9428             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
9429               child = node.children[i3];
9430               area = bboxArea2(child);
9431               enlargement = enlargedArea2(bbox2, child) - area;
9432               if (enlargement < minEnlargement) {
9433                 minEnlargement = enlargement;
9434                 minArea = area < minArea ? area : minArea;
9435                 targetNode = child;
9436               } else if (enlargement === minEnlargement) {
9437                 if (area < minArea) {
9438                   minArea = area;
9439                   targetNode = child;
9440                 }
9441               }
9442             }
9443             node = targetNode || node.children[0];
9444           }
9445           return node;
9446         },
9447         _insert: function(item, level, isNode) {
9448           var toBBox = this.toBBox, bbox2 = isNode ? item : toBBox(item), insertPath = [];
9449           var node = this._chooseSubtree(bbox2, this.data, level, insertPath);
9450           node.children.push(item);
9451           extend3(node, bbox2);
9452           while (level >= 0) {
9453             if (insertPath[level].children.length > this._maxEntries) {
9454               this._split(insertPath, level);
9455               level--;
9456             } else break;
9457           }
9458           this._adjustParentBBoxes(bbox2, insertPath, level);
9459         },
9460         // split overflowed node into two
9461         _split: function(insertPath, level) {
9462           var node = insertPath[level], M2 = node.children.length, m2 = this._minEntries;
9463           this._chooseSplitAxis(node, m2, M2);
9464           var splitIndex = this._chooseSplitIndex(node, m2, M2);
9465           var newNode = createNode2(node.children.splice(splitIndex, node.children.length - splitIndex));
9466           newNode.height = node.height;
9467           newNode.leaf = node.leaf;
9468           calcBBox2(node, this.toBBox);
9469           calcBBox2(newNode, this.toBBox);
9470           if (level) insertPath[level - 1].children.push(newNode);
9471           else this._splitRoot(node, newNode);
9472         },
9473         _splitRoot: function(node, newNode) {
9474           this.data = createNode2([node, newNode]);
9475           this.data.height = node.height + 1;
9476           this.data.leaf = false;
9477           calcBBox2(this.data, this.toBBox);
9478         },
9479         _chooseSplitIndex: function(node, m2, M2) {
9480           var i3, bbox1, bbox2, overlap, area, minOverlap, minArea, index;
9481           minOverlap = minArea = Infinity;
9482           for (i3 = m2; i3 <= M2 - m2; i3++) {
9483             bbox1 = distBBox2(node, 0, i3, this.toBBox);
9484             bbox2 = distBBox2(node, i3, M2, this.toBBox);
9485             overlap = intersectionArea2(bbox1, bbox2);
9486             area = bboxArea2(bbox1) + bboxArea2(bbox2);
9487             if (overlap < minOverlap) {
9488               minOverlap = overlap;
9489               index = i3;
9490               minArea = area < minArea ? area : minArea;
9491             } else if (overlap === minOverlap) {
9492               if (area < minArea) {
9493                 minArea = area;
9494                 index = i3;
9495               }
9496             }
9497           }
9498           return index;
9499         },
9500         // sorts node children by the best axis for split
9501         _chooseSplitAxis: function(node, m2, M2) {
9502           var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX2, compareMinY = node.leaf ? this.compareMinY : compareNodeMinY2, xMargin = this._allDistMargin(node, m2, M2, compareMinX), yMargin = this._allDistMargin(node, m2, M2, compareMinY);
9503           if (xMargin < yMargin) node.children.sort(compareMinX);
9504         },
9505         // total margin of all possible split distributions where each node is at least m full
9506         _allDistMargin: function(node, m2, M2, compare2) {
9507           node.children.sort(compare2);
9508           var toBBox = this.toBBox, leftBBox = distBBox2(node, 0, m2, toBBox), rightBBox = distBBox2(node, M2 - m2, M2, toBBox), margin = bboxMargin2(leftBBox) + bboxMargin2(rightBBox), i3, child;
9509           for (i3 = m2; i3 < M2 - m2; i3++) {
9510             child = node.children[i3];
9511             extend3(leftBBox, node.leaf ? toBBox(child) : child);
9512             margin += bboxMargin2(leftBBox);
9513           }
9514           for (i3 = M2 - m2 - 1; i3 >= m2; i3--) {
9515             child = node.children[i3];
9516             extend3(rightBBox, node.leaf ? toBBox(child) : child);
9517             margin += bboxMargin2(rightBBox);
9518           }
9519           return margin;
9520         },
9521         _adjustParentBBoxes: function(bbox2, path, level) {
9522           for (var i3 = level; i3 >= 0; i3--) {
9523             extend3(path[i3], bbox2);
9524           }
9525         },
9526         _condense: function(path) {
9527           for (var i3 = path.length - 1, siblings; i3 >= 0; i3--) {
9528             if (path[i3].children.length === 0) {
9529               if (i3 > 0) {
9530                 siblings = path[i3 - 1].children;
9531                 siblings.splice(siblings.indexOf(path[i3]), 1);
9532               } else this.clear();
9533             } else calcBBox2(path[i3], this.toBBox);
9534           }
9535         },
9536         _initFormat: function(format2) {
9537           var compareArr = ["return a", " - b", ";"];
9538           this.compareMinX = new Function("a", "b", compareArr.join(format2[0]));
9539           this.compareMinY = new Function("a", "b", compareArr.join(format2[1]));
9540           this.toBBox = new Function(
9541             "a",
9542             "return {minX: a" + format2[0] + ", minY: a" + format2[1] + ", maxX: a" + format2[2] + ", maxY: a" + format2[3] + "};"
9543           );
9544         }
9545       };
9546       function findItem2(item, items, equalsFn) {
9547         if (!equalsFn) return items.indexOf(item);
9548         for (var i3 = 0; i3 < items.length; i3++) {
9549           if (equalsFn(item, items[i3])) return i3;
9550         }
9551         return -1;
9552       }
9553       function calcBBox2(node, toBBox) {
9554         distBBox2(node, 0, node.children.length, toBBox, node);
9555       }
9556       function distBBox2(node, k2, p2, toBBox, destNode) {
9557         if (!destNode) destNode = createNode2(null);
9558         destNode.minX = Infinity;
9559         destNode.minY = Infinity;
9560         destNode.maxX = -Infinity;
9561         destNode.maxY = -Infinity;
9562         for (var i3 = k2, child; i3 < p2; i3++) {
9563           child = node.children[i3];
9564           extend3(destNode, node.leaf ? toBBox(child) : child);
9565         }
9566         return destNode;
9567       }
9568       function extend3(a2, b2) {
9569         a2.minX = Math.min(a2.minX, b2.minX);
9570         a2.minY = Math.min(a2.minY, b2.minY);
9571         a2.maxX = Math.max(a2.maxX, b2.maxX);
9572         a2.maxY = Math.max(a2.maxY, b2.maxY);
9573         return a2;
9574       }
9575       function compareNodeMinX2(a2, b2) {
9576         return a2.minX - b2.minX;
9577       }
9578       function compareNodeMinY2(a2, b2) {
9579         return a2.minY - b2.minY;
9580       }
9581       function bboxArea2(a2) {
9582         return (a2.maxX - a2.minX) * (a2.maxY - a2.minY);
9583       }
9584       function bboxMargin2(a2) {
9585         return a2.maxX - a2.minX + (a2.maxY - a2.minY);
9586       }
9587       function enlargedArea2(a2, b2) {
9588         return (Math.max(b2.maxX, a2.maxX) - Math.min(b2.minX, a2.minX)) * (Math.max(b2.maxY, a2.maxY) - Math.min(b2.minY, a2.minY));
9589       }
9590       function intersectionArea2(a2, b2) {
9591         var minX = Math.max(a2.minX, b2.minX), minY = Math.max(a2.minY, b2.minY), maxX = Math.min(a2.maxX, b2.maxX), maxY = Math.min(a2.maxY, b2.maxY);
9592         return Math.max(0, maxX - minX) * Math.max(0, maxY - minY);
9593       }
9594       function contains2(a2, b2) {
9595         return a2.minX <= b2.minX && a2.minY <= b2.minY && b2.maxX <= a2.maxX && b2.maxY <= a2.maxY;
9596       }
9597       function intersects2(a2, b2) {
9598         return b2.minX <= a2.maxX && b2.minY <= a2.maxY && b2.maxX >= a2.minX && b2.maxY >= a2.minY;
9599       }
9600       function createNode2(children2) {
9601         return {
9602           children: children2,
9603           height: 1,
9604           leaf: true,
9605           minX: Infinity,
9606           minY: Infinity,
9607           maxX: -Infinity,
9608           maxY: -Infinity
9609         };
9610       }
9611       function multiSelect2(arr, left, right, n3, compare2) {
9612         var stack = [left, right], mid;
9613         while (stack.length) {
9614           right = stack.pop();
9615           left = stack.pop();
9616           if (right - left <= n3) continue;
9617           mid = left + Math.ceil((right - left) / n3 / 2) * n3;
9618           quickselect3(arr, mid, left, right, compare2);
9619           stack.push(left, mid, mid, right);
9620         }
9621       }
9622     }
9623   });
9624
9625   // node_modules/lineclip/index.js
9626   var require_lineclip = __commonJS({
9627     "node_modules/lineclip/index.js"(exports2, module2) {
9628       "use strict";
9629       module2.exports = lineclip2;
9630       lineclip2.polyline = lineclip2;
9631       lineclip2.polygon = polygonclip2;
9632       function lineclip2(points, bbox2, result) {
9633         var len = points.length, codeA = bitCode2(points[0], bbox2), part = [], i3, a2, b2, codeB, lastCode;
9634         if (!result) result = [];
9635         for (i3 = 1; i3 < len; i3++) {
9636           a2 = points[i3 - 1];
9637           b2 = points[i3];
9638           codeB = lastCode = bitCode2(b2, bbox2);
9639           while (true) {
9640             if (!(codeA | codeB)) {
9641               part.push(a2);
9642               if (codeB !== lastCode) {
9643                 part.push(b2);
9644                 if (i3 < len - 1) {
9645                   result.push(part);
9646                   part = [];
9647                 }
9648               } else if (i3 === len - 1) {
9649                 part.push(b2);
9650               }
9651               break;
9652             } else if (codeA & codeB) {
9653               break;
9654             } else if (codeA) {
9655               a2 = intersect2(a2, b2, codeA, bbox2);
9656               codeA = bitCode2(a2, bbox2);
9657             } else {
9658               b2 = intersect2(a2, b2, codeB, bbox2);
9659               codeB = bitCode2(b2, bbox2);
9660             }
9661           }
9662           codeA = lastCode;
9663         }
9664         if (part.length) result.push(part);
9665         return result;
9666       }
9667       function polygonclip2(points, bbox2) {
9668         var result, edge, prev, prevInside, i3, p2, inside;
9669         for (edge = 1; edge <= 8; edge *= 2) {
9670           result = [];
9671           prev = points[points.length - 1];
9672           prevInside = !(bitCode2(prev, bbox2) & edge);
9673           for (i3 = 0; i3 < points.length; i3++) {
9674             p2 = points[i3];
9675             inside = !(bitCode2(p2, bbox2) & edge);
9676             if (inside !== prevInside) result.push(intersect2(prev, p2, edge, bbox2));
9677             if (inside) result.push(p2);
9678             prev = p2;
9679             prevInside = inside;
9680           }
9681           points = result;
9682           if (!points.length) break;
9683         }
9684         return result;
9685       }
9686       function intersect2(a2, b2, edge, bbox2) {
9687         return edge & 8 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[3] - a2[1]) / (b2[1] - a2[1]), bbox2[3]] : (
9688           // top
9689           edge & 4 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[1] - a2[1]) / (b2[1] - a2[1]), bbox2[1]] : (
9690             // bottom
9691             edge & 2 ? [bbox2[2], a2[1] + (b2[1] - a2[1]) * (bbox2[2] - a2[0]) / (b2[0] - a2[0])] : (
9692               // right
9693               edge & 1 ? [bbox2[0], a2[1] + (b2[1] - a2[1]) * (bbox2[0] - a2[0]) / (b2[0] - a2[0])] : (
9694                 // left
9695                 null
9696               )
9697             )
9698           )
9699         );
9700       }
9701       function bitCode2(p2, bbox2) {
9702         var code = 0;
9703         if (p2[0] < bbox2[0]) code |= 1;
9704         else if (p2[0] > bbox2[2]) code |= 2;
9705         if (p2[1] < bbox2[1]) code |= 4;
9706         else if (p2[1] > bbox2[3]) code |= 8;
9707         return code;
9708       }
9709     }
9710   });
9711
9712   // node_modules/which-polygon/index.js
9713   var require_which_polygon = __commonJS({
9714     "node_modules/which-polygon/index.js"(exports2, module2) {
9715       "use strict";
9716       var rbush = require_rbush();
9717       var lineclip2 = require_lineclip();
9718       module2.exports = whichPolygon5;
9719       function whichPolygon5(data) {
9720         var bboxes = [];
9721         for (var i3 = 0; i3 < data.features.length; i3++) {
9722           var feature3 = data.features[i3];
9723           if (!feature3.geometry) continue;
9724           var coords = feature3.geometry.coordinates;
9725           if (feature3.geometry.type === "Polygon") {
9726             bboxes.push(treeItem(coords, feature3.properties));
9727           } else if (feature3.geometry.type === "MultiPolygon") {
9728             for (var j2 = 0; j2 < coords.length; j2++) {
9729               bboxes.push(treeItem(coords[j2], feature3.properties));
9730             }
9731           }
9732         }
9733         var tree = rbush().load(bboxes);
9734         function query(p2, multi) {
9735           var output = [], result = tree.search({
9736             minX: p2[0],
9737             minY: p2[1],
9738             maxX: p2[0],
9739             maxY: p2[1]
9740           });
9741           for (var i4 = 0; i4 < result.length; i4++) {
9742             if (insidePolygon(result[i4].coords, p2)) {
9743               if (multi)
9744                 output.push(result[i4].props);
9745               else
9746                 return result[i4].props;
9747             }
9748           }
9749           return multi && output.length ? output : null;
9750         }
9751         query.tree = tree;
9752         query.bbox = function queryBBox(bbox2) {
9753           var output = [];
9754           var result = tree.search({
9755             minX: bbox2[0],
9756             minY: bbox2[1],
9757             maxX: bbox2[2],
9758             maxY: bbox2[3]
9759           });
9760           for (var i4 = 0; i4 < result.length; i4++) {
9761             if (polygonIntersectsBBox(result[i4].coords, bbox2)) {
9762               output.push(result[i4].props);
9763             }
9764           }
9765           return output;
9766         };
9767         return query;
9768       }
9769       function polygonIntersectsBBox(polygon2, bbox2) {
9770         var bboxCenter = [
9771           (bbox2[0] + bbox2[2]) / 2,
9772           (bbox2[1] + bbox2[3]) / 2
9773         ];
9774         if (insidePolygon(polygon2, bboxCenter)) return true;
9775         for (var i3 = 0; i3 < polygon2.length; i3++) {
9776           if (lineclip2(polygon2[i3], bbox2).length > 0) return true;
9777         }
9778         return false;
9779       }
9780       function insidePolygon(rings, p2) {
9781         var inside = false;
9782         for (var i3 = 0, len = rings.length; i3 < len; i3++) {
9783           var ring = rings[i3];
9784           for (var j2 = 0, len2 = ring.length, k2 = len2 - 1; j2 < len2; k2 = j2++) {
9785             if (rayIntersect(p2, ring[j2], ring[k2])) inside = !inside;
9786           }
9787         }
9788         return inside;
9789       }
9790       function rayIntersect(p2, p1, p22) {
9791         return p1[1] > p2[1] !== p22[1] > p2[1] && p2[0] < (p22[0] - p1[0]) * (p2[1] - p1[1]) / (p22[1] - p1[1]) + p1[0];
9792       }
9793       function treeItem(coords, props) {
9794         var item = {
9795           minX: Infinity,
9796           minY: Infinity,
9797           maxX: -Infinity,
9798           maxY: -Infinity,
9799           coords,
9800           props
9801         };
9802         for (var i3 = 0; i3 < coords[0].length; i3++) {
9803           var p2 = coords[0][i3];
9804           item.minX = Math.min(item.minX, p2[0]);
9805           item.minY = Math.min(item.minY, p2[1]);
9806           item.maxX = Math.max(item.maxX, p2[0]);
9807           item.maxY = Math.max(item.maxY, p2[1]);
9808         }
9809         return item;
9810       }
9811     }
9812   });
9813
9814   // node_modules/wgs84/index.js
9815   var require_wgs84 = __commonJS({
9816     "node_modules/wgs84/index.js"(exports2, module2) {
9817       module2.exports.RADIUS = 6378137;
9818       module2.exports.FLATTENING = 1 / 298.257223563;
9819       module2.exports.POLAR_RADIUS = 63567523142e-4;
9820     }
9821   });
9822
9823   // node_modules/@mapbox/geojson-area/index.js
9824   var require_geojson_area = __commonJS({
9825     "node_modules/@mapbox/geojson-area/index.js"(exports2, module2) {
9826       var wgs84 = require_wgs84();
9827       module2.exports.geometry = geometry;
9828       module2.exports.ring = ringArea;
9829       function geometry(_2) {
9830         var area = 0, i3;
9831         switch (_2.type) {
9832           case "Polygon":
9833             return polygonArea(_2.coordinates);
9834           case "MultiPolygon":
9835             for (i3 = 0; i3 < _2.coordinates.length; i3++) {
9836               area += polygonArea(_2.coordinates[i3]);
9837             }
9838             return area;
9839           case "Point":
9840           case "MultiPoint":
9841           case "LineString":
9842           case "MultiLineString":
9843             return 0;
9844           case "GeometryCollection":
9845             for (i3 = 0; i3 < _2.geometries.length; i3++) {
9846               area += geometry(_2.geometries[i3]);
9847             }
9848             return area;
9849         }
9850       }
9851       function polygonArea(coords) {
9852         var area = 0;
9853         if (coords && coords.length > 0) {
9854           area += Math.abs(ringArea(coords[0]));
9855           for (var i3 = 1; i3 < coords.length; i3++) {
9856             area -= Math.abs(ringArea(coords[i3]));
9857           }
9858         }
9859         return area;
9860       }
9861       function ringArea(coords) {
9862         var p1, p2, p3, lowerIndex, middleIndex, upperIndex, i3, area = 0, coordsLength = coords.length;
9863         if (coordsLength > 2) {
9864           for (i3 = 0; i3 < coordsLength; i3++) {
9865             if (i3 === coordsLength - 2) {
9866               lowerIndex = coordsLength - 2;
9867               middleIndex = coordsLength - 1;
9868               upperIndex = 0;
9869             } else if (i3 === coordsLength - 1) {
9870               lowerIndex = coordsLength - 1;
9871               middleIndex = 0;
9872               upperIndex = 1;
9873             } else {
9874               lowerIndex = i3;
9875               middleIndex = i3 + 1;
9876               upperIndex = i3 + 2;
9877             }
9878             p1 = coords[lowerIndex];
9879             p2 = coords[middleIndex];
9880             p3 = coords[upperIndex];
9881             area += (rad(p3[0]) - rad(p1[0])) * Math.sin(rad(p2[1]));
9882           }
9883           area = area * wgs84.RADIUS * wgs84.RADIUS / 2;
9884         }
9885         return area;
9886       }
9887       function rad(_2) {
9888         return _2 * Math.PI / 180;
9889       }
9890     }
9891   });
9892
9893   // node_modules/circle-to-polygon/input-validation/validateCenter.js
9894   var require_validateCenter = __commonJS({
9895     "node_modules/circle-to-polygon/input-validation/validateCenter.js"(exports2) {
9896       exports2.validateCenter = function validateCenter(center) {
9897         var validCenterLengths = [2, 3];
9898         if (!Array.isArray(center) || !validCenterLengths.includes(center.length)) {
9899           throw new Error("ERROR! Center has to be an array of length two or three");
9900         }
9901         var [lng, lat] = center;
9902         if (typeof lng !== "number" || typeof lat !== "number") {
9903           throw new Error(
9904             "ERROR! Longitude and Latitude has to be numbers but where ".concat(typeof lng, " and ").concat(typeof lat)
9905           );
9906         }
9907         if (lng > 180 || lng < -180) {
9908           throw new Error("ERROR! Longitude has to be between -180 and 180 but was ".concat(lng));
9909         }
9910         if (lat > 90 || lat < -90) {
9911           throw new Error("ERROR! Latitude has to be between -90 and 90 but was ".concat(lat));
9912         }
9913       };
9914     }
9915   });
9916
9917   // node_modules/circle-to-polygon/input-validation/validateRadius.js
9918   var require_validateRadius = __commonJS({
9919     "node_modules/circle-to-polygon/input-validation/validateRadius.js"(exports2) {
9920       exports2.validateRadius = function validateRadius(radius) {
9921         if (typeof radius !== "number") {
9922           throw new Error("ERROR! Radius has to be a positive number but was: ".concat(typeof radius));
9923         }
9924         if (radius <= 0) {
9925           throw new Error("ERROR! Radius has to be a positive number but was: ".concat(radius));
9926         }
9927       };
9928     }
9929   });
9930
9931   // node_modules/circle-to-polygon/input-validation/validateNumberOfEdges.js
9932   var require_validateNumberOfEdges = __commonJS({
9933     "node_modules/circle-to-polygon/input-validation/validateNumberOfEdges.js"(exports2) {
9934       exports2.validateNumberOfEdges = function validateNumberOfEdges(numberOfEdges) {
9935         if (typeof numberOfEdges !== "number") {
9936           const ARGUMENT_TYPE = Array.isArray(numberOfEdges) ? "array" : typeof numberOfEdges;
9937           throw new Error("ERROR! Number of edges has to be a number but was: ".concat(ARGUMENT_TYPE));
9938         }
9939         if (numberOfEdges < 3) {
9940           throw new Error("ERROR! Number of edges has to be at least 3 but was: ".concat(numberOfEdges));
9941         }
9942       };
9943     }
9944   });
9945
9946   // node_modules/circle-to-polygon/input-validation/validateEarthRadius.js
9947   var require_validateEarthRadius = __commonJS({
9948     "node_modules/circle-to-polygon/input-validation/validateEarthRadius.js"(exports2) {
9949       exports2.validateEarthRadius = function validateEarthRadius(earthRadius2) {
9950         if (typeof earthRadius2 !== "number") {
9951           const ARGUMENT_TYPE = Array.isArray(earthRadius2) ? "array" : typeof earthRadius2;
9952           throw new Error("ERROR! Earth radius has to be a number but was: ".concat(ARGUMENT_TYPE));
9953         }
9954         if (earthRadius2 <= 0) {
9955           throw new Error("ERROR! Earth radius has to be a positive number but was: ".concat(earthRadius2));
9956         }
9957       };
9958     }
9959   });
9960
9961   // node_modules/circle-to-polygon/input-validation/validateBearing.js
9962   var require_validateBearing = __commonJS({
9963     "node_modules/circle-to-polygon/input-validation/validateBearing.js"(exports2) {
9964       exports2.validateBearing = function validateBearing(bearing) {
9965         if (typeof bearing !== "number") {
9966           const ARGUMENT_TYPE = Array.isArray(bearing) ? "array" : typeof bearing;
9967           throw new Error("ERROR! Bearing has to be a number but was: ".concat(ARGUMENT_TYPE));
9968         }
9969       };
9970     }
9971   });
9972
9973   // node_modules/circle-to-polygon/input-validation/index.js
9974   var require_input_validation = __commonJS({
9975     "node_modules/circle-to-polygon/input-validation/index.js"(exports2) {
9976       var validateCenter = require_validateCenter().validateCenter;
9977       var validateRadius = require_validateRadius().validateRadius;
9978       var validateNumberOfEdges = require_validateNumberOfEdges().validateNumberOfEdges;
9979       var validateEarthRadius = require_validateEarthRadius().validateEarthRadius;
9980       var validateBearing = require_validateBearing().validateBearing;
9981       function validateInput({ center, radius, numberOfEdges, earthRadius: earthRadius2, bearing }) {
9982         validateCenter(center);
9983         validateRadius(radius);
9984         validateNumberOfEdges(numberOfEdges);
9985         validateEarthRadius(earthRadius2);
9986         validateBearing(bearing);
9987       }
9988       exports2.validateCenter = validateCenter;
9989       exports2.validateRadius = validateRadius;
9990       exports2.validateNumberOfEdges = validateNumberOfEdges;
9991       exports2.validateEarthRadius = validateEarthRadius;
9992       exports2.validateBearing = validateBearing;
9993       exports2.validateInput = validateInput;
9994     }
9995   });
9996
9997   // node_modules/circle-to-polygon/index.js
9998   var require_circle_to_polygon = __commonJS({
9999     "node_modules/circle-to-polygon/index.js"(exports2, module2) {
10000       "use strict";
10001       var { validateInput } = require_input_validation();
10002       var defaultEarthRadius = 6378137;
10003       function toRadians(angleInDegrees) {
10004         return angleInDegrees * Math.PI / 180;
10005       }
10006       function toDegrees(angleInRadians) {
10007         return angleInRadians * 180 / Math.PI;
10008       }
10009       function offset(c1, distance, earthRadius2, bearing) {
10010         var lat1 = toRadians(c1[1]);
10011         var lon1 = toRadians(c1[0]);
10012         var dByR = distance / earthRadius2;
10013         var lat = Math.asin(
10014           Math.sin(lat1) * Math.cos(dByR) + Math.cos(lat1) * Math.sin(dByR) * Math.cos(bearing)
10015         );
10016         var lon = lon1 + Math.atan2(
10017           Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1),
10018           Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat)
10019         );
10020         return [toDegrees(lon), toDegrees(lat)];
10021       }
10022       module2.exports = function circleToPolygon2(center, radius, options2) {
10023         var n3 = getNumberOfEdges(options2);
10024         var earthRadius2 = getEarthRadius(options2);
10025         var bearing = getBearing(options2);
10026         var direction = getDirection(options2);
10027         validateInput({ center, radius, numberOfEdges: n3, earthRadius: earthRadius2, bearing });
10028         var start2 = toRadians(bearing);
10029         var coordinates = [];
10030         for (var i3 = 0; i3 < n3; ++i3) {
10031           coordinates.push(
10032             offset(
10033               center,
10034               radius,
10035               earthRadius2,
10036               start2 + direction * 2 * Math.PI * -i3 / n3
10037             )
10038           );
10039         }
10040         coordinates.push(coordinates[0]);
10041         return {
10042           type: "Polygon",
10043           coordinates: [coordinates]
10044         };
10045       };
10046       function getNumberOfEdges(options2) {
10047         if (isUndefinedOrNull(options2)) {
10048           return 32;
10049         } else if (isObjectNotArray(options2)) {
10050           var numberOfEdges = options2.numberOfEdges;
10051           return numberOfEdges === void 0 ? 32 : numberOfEdges;
10052         }
10053         return options2;
10054       }
10055       function getEarthRadius(options2) {
10056         if (isUndefinedOrNull(options2)) {
10057           return defaultEarthRadius;
10058         } else if (isObjectNotArray(options2)) {
10059           var earthRadius2 = options2.earthRadius;
10060           return earthRadius2 === void 0 ? defaultEarthRadius : earthRadius2;
10061         }
10062         return defaultEarthRadius;
10063       }
10064       function getDirection(options2) {
10065         if (isObjectNotArray(options2) && options2.rightHandRule) {
10066           return -1;
10067         }
10068         return 1;
10069       }
10070       function getBearing(options2) {
10071         if (isUndefinedOrNull(options2)) {
10072           return 0;
10073         } else if (isObjectNotArray(options2)) {
10074           var bearing = options2.bearing;
10075           return bearing === void 0 ? 0 : bearing;
10076         }
10077         return 0;
10078       }
10079       function isObjectNotArray(argument) {
10080         return argument !== null && typeof argument === "object" && !Array.isArray(argument);
10081       }
10082       function isUndefinedOrNull(argument) {
10083         return argument === null || argument === void 0;
10084       }
10085     }
10086   });
10087
10088   // node_modules/geojson-precision/index.js
10089   var require_geojson_precision = __commonJS({
10090     "node_modules/geojson-precision/index.js"(exports2, module2) {
10091       (function() {
10092         function parse(t2, coordinatePrecision, extrasPrecision) {
10093           function point(p2) {
10094             return p2.map(function(e3, index) {
10095               if (index < 2) {
10096                 return 1 * e3.toFixed(coordinatePrecision);
10097               } else {
10098                 return 1 * e3.toFixed(extrasPrecision);
10099               }
10100             });
10101           }
10102           function multi(l2) {
10103             return l2.map(point);
10104           }
10105           function poly(p2) {
10106             return p2.map(multi);
10107           }
10108           function multiPoly(m2) {
10109             return m2.map(poly);
10110           }
10111           function geometry(obj) {
10112             if (!obj) {
10113               return {};
10114             }
10115             switch (obj.type) {
10116               case "Point":
10117                 obj.coordinates = point(obj.coordinates);
10118                 return obj;
10119               case "LineString":
10120               case "MultiPoint":
10121                 obj.coordinates = multi(obj.coordinates);
10122                 return obj;
10123               case "Polygon":
10124               case "MultiLineString":
10125                 obj.coordinates = poly(obj.coordinates);
10126                 return obj;
10127               case "MultiPolygon":
10128                 obj.coordinates = multiPoly(obj.coordinates);
10129                 return obj;
10130               case "GeometryCollection":
10131                 obj.geometries = obj.geometries.map(geometry);
10132                 return obj;
10133               default:
10134                 return {};
10135             }
10136           }
10137           function feature3(obj) {
10138             obj.geometry = geometry(obj.geometry);
10139             return obj;
10140           }
10141           function featureCollection(f2) {
10142             f2.features = f2.features.map(feature3);
10143             return f2;
10144           }
10145           function geometryCollection(g3) {
10146             g3.geometries = g3.geometries.map(geometry);
10147             return g3;
10148           }
10149           if (!t2) {
10150             return t2;
10151           }
10152           switch (t2.type) {
10153             case "Feature":
10154               return feature3(t2);
10155             case "GeometryCollection":
10156               return geometryCollection(t2);
10157             case "FeatureCollection":
10158               return featureCollection(t2);
10159             case "Point":
10160             case "LineString":
10161             case "Polygon":
10162             case "MultiPoint":
10163             case "MultiPolygon":
10164             case "MultiLineString":
10165               return geometry(t2);
10166             default:
10167               return t2;
10168           }
10169         }
10170         module2.exports = parse;
10171         module2.exports.parse = parse;
10172       })();
10173     }
10174   });
10175
10176   // node_modules/@aitodotai/json-stringify-pretty-compact/index.js
10177   var require_json_stringify_pretty_compact = __commonJS({
10178     "node_modules/@aitodotai/json-stringify-pretty-compact/index.js"(exports2, module2) {
10179       function isObject2(obj) {
10180         return typeof obj === "object" && obj !== null;
10181       }
10182       function forEach(obj, cb) {
10183         if (Array.isArray(obj)) {
10184           obj.forEach(cb);
10185         } else if (isObject2(obj)) {
10186           Object.keys(obj).forEach(function(key) {
10187             var val = obj[key];
10188             cb(val, key);
10189           });
10190         }
10191       }
10192       function getTreeDepth(obj) {
10193         var depth = 0;
10194         if (Array.isArray(obj) || isObject2(obj)) {
10195           forEach(obj, function(val) {
10196             if (Array.isArray(val) || isObject2(val)) {
10197               var tmpDepth = getTreeDepth(val);
10198               if (tmpDepth > depth) {
10199                 depth = tmpDepth;
10200               }
10201             }
10202           });
10203           return depth + 1;
10204         }
10205         return depth;
10206       }
10207       function stringify3(obj, options2) {
10208         options2 = options2 || {};
10209         var indent = JSON.stringify([1], null, get4(options2, "indent", 2)).slice(2, -3);
10210         var addMargin = get4(options2, "margins", false);
10211         var addArrayMargin = get4(options2, "arrayMargins", false);
10212         var addObjectMargin = get4(options2, "objectMargins", false);
10213         var maxLength = indent === "" ? Infinity : get4(options2, "maxLength", 80);
10214         var maxNesting = get4(options2, "maxNesting", Infinity);
10215         return function _stringify(obj2, currentIndent, reserved) {
10216           if (obj2 && typeof obj2.toJSON === "function") {
10217             obj2 = obj2.toJSON();
10218           }
10219           var string = JSON.stringify(obj2);
10220           if (string === void 0) {
10221             return string;
10222           }
10223           var length2 = maxLength - currentIndent.length - reserved;
10224           var treeDepth = getTreeDepth(obj2);
10225           if (treeDepth <= maxNesting && string.length <= length2) {
10226             var prettified = prettify(string, {
10227               addMargin,
10228               addArrayMargin,
10229               addObjectMargin
10230             });
10231             if (prettified.length <= length2) {
10232               return prettified;
10233             }
10234           }
10235           if (isObject2(obj2)) {
10236             var nextIndent = currentIndent + indent;
10237             var items = [];
10238             var delimiters;
10239             var comma = function(array2, index2) {
10240               return index2 === array2.length - 1 ? 0 : 1;
10241             };
10242             if (Array.isArray(obj2)) {
10243               for (var index = 0; index < obj2.length; index++) {
10244                 items.push(
10245                   _stringify(obj2[index], nextIndent, comma(obj2, index)) || "null"
10246                 );
10247               }
10248               delimiters = "[]";
10249             } else {
10250               Object.keys(obj2).forEach(function(key, index2, array2) {
10251                 var keyPart = JSON.stringify(key) + ": ";
10252                 var value = _stringify(
10253                   obj2[key],
10254                   nextIndent,
10255                   keyPart.length + comma(array2, index2)
10256                 );
10257                 if (value !== void 0) {
10258                   items.push(keyPart + value);
10259                 }
10260               });
10261               delimiters = "{}";
10262             }
10263             if (items.length > 0) {
10264               return [
10265                 delimiters[0],
10266                 indent + items.join(",\n" + nextIndent),
10267                 delimiters[1]
10268               ].join("\n" + currentIndent);
10269             }
10270           }
10271           return string;
10272         }(obj, "", 0);
10273       }
10274       var stringOrChar = /("(?:[^\\"]|\\.)*")|[:,\][}{]/g;
10275       function prettify(string, options2) {
10276         options2 = options2 || {};
10277         var tokens = {
10278           "{": "{",
10279           "}": "}",
10280           "[": "[",
10281           "]": "]",
10282           ",": ", ",
10283           ":": ": "
10284         };
10285         if (options2.addMargin || options2.addObjectMargin) {
10286           tokens["{"] = "{ ";
10287           tokens["}"] = " }";
10288         }
10289         if (options2.addMargin || options2.addArrayMargin) {
10290           tokens["["] = "[ ";
10291           tokens["]"] = " ]";
10292         }
10293         return string.replace(stringOrChar, function(match, string2) {
10294           return string2 ? match : tokens[match];
10295         });
10296       }
10297       function get4(options2, name, defaultValue) {
10298         return name in options2 ? options2[name] : defaultValue;
10299       }
10300       module2.exports = stringify3;
10301     }
10302   });
10303
10304   // node_modules/fast-json-stable-stringify/index.js
10305   var require_fast_json_stable_stringify = __commonJS({
10306     "node_modules/fast-json-stable-stringify/index.js"(exports2, module2) {
10307       "use strict";
10308       module2.exports = function(data, opts) {
10309         if (!opts) opts = {};
10310         if (typeof opts === "function") opts = { cmp: opts };
10311         var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
10312         var cmp = opts.cmp && /* @__PURE__ */ function(f2) {
10313           return function(node) {
10314             return function(a2, b2) {
10315               var aobj = { key: a2, value: node[a2] };
10316               var bobj = { key: b2, value: node[b2] };
10317               return f2(aobj, bobj);
10318             };
10319           };
10320         }(opts.cmp);
10321         var seen = [];
10322         return function stringify3(node) {
10323           if (node && node.toJSON && typeof node.toJSON === "function") {
10324             node = node.toJSON();
10325           }
10326           if (node === void 0) return;
10327           if (typeof node == "number") return isFinite(node) ? "" + node : "null";
10328           if (typeof node !== "object") return JSON.stringify(node);
10329           var i3, out;
10330           if (Array.isArray(node)) {
10331             out = "[";
10332             for (i3 = 0; i3 < node.length; i3++) {
10333               if (i3) out += ",";
10334               out += stringify3(node[i3]) || "null";
10335             }
10336             return out + "]";
10337           }
10338           if (node === null) return "null";
10339           if (seen.indexOf(node) !== -1) {
10340             if (cycles) return JSON.stringify("__cycle__");
10341             throw new TypeError("Converting circular structure to JSON");
10342           }
10343           var seenIndex = seen.push(node) - 1;
10344           var keys2 = Object.keys(node).sort(cmp && cmp(node));
10345           out = "";
10346           for (i3 = 0; i3 < keys2.length; i3++) {
10347             var key = keys2[i3];
10348             var value = stringify3(node[key]);
10349             if (!value) continue;
10350             if (out) out += ",";
10351             out += JSON.stringify(key) + ":" + value;
10352           }
10353           seen.splice(seenIndex, 1);
10354           return "{" + out + "}";
10355         }(data);
10356       };
10357     }
10358   });
10359
10360   // node_modules/@mapbox/sexagesimal/index.js
10361   var require_sexagesimal = __commonJS({
10362     "node_modules/@mapbox/sexagesimal/index.js"(exports2, module2) {
10363       module2.exports = element;
10364       module2.exports.pair = pair3;
10365       module2.exports.format = format2;
10366       module2.exports.formatPair = formatPair;
10367       module2.exports.coordToDMS = coordToDMS;
10368       function element(input, dims) {
10369         var result = search(input, dims);
10370         return result === null ? null : result.val;
10371       }
10372       function formatPair(input) {
10373         return format2(input.lat, "lat") + " " + format2(input.lon, "lon");
10374       }
10375       function format2(input, dim) {
10376         var dms = coordToDMS(input, dim);
10377         return dms.whole + "\xB0 " + (dms.minutes ? dms.minutes + "' " : "") + (dms.seconds ? dms.seconds + '" ' : "") + dms.dir;
10378       }
10379       function coordToDMS(input, dim) {
10380         var dirs = { lat: ["N", "S"], lon: ["E", "W"] }[dim] || "";
10381         var dir = dirs[input >= 0 ? 0 : 1];
10382         var abs3 = Math.abs(input);
10383         var whole = Math.floor(abs3);
10384         var fraction = abs3 - whole;
10385         var fractionMinutes = fraction * 60;
10386         var minutes = Math.floor(fractionMinutes);
10387         var seconds = Math.floor((fractionMinutes - minutes) * 60);
10388         return {
10389           whole,
10390           minutes,
10391           seconds,
10392           dir
10393         };
10394       }
10395       function search(input, dims) {
10396         if (!dims) dims = "NSEW";
10397         if (typeof input !== "string") return null;
10398         input = input.toUpperCase();
10399         var regex = /^[\s\,]*([NSEW])?\s*([\-|\—|\―]?[0-9.]+)[°º˚]?\s*(?:([0-9.]+)['’′‘]\s*)?(?:([0-9.]+)(?:''|"|”|″)\s*)?([NSEW])?/;
10400         var m2 = input.match(regex);
10401         if (!m2) return null;
10402         var matched = m2[0];
10403         var dim;
10404         if (m2[1] && m2[5]) {
10405           dim = m2[1];
10406           matched = matched.slice(0, -1);
10407         } else {
10408           dim = m2[1] || m2[5];
10409         }
10410         if (dim && dims.indexOf(dim) === -1) return null;
10411         var deg = m2[2] ? parseFloat(m2[2]) : 0;
10412         var min3 = m2[3] ? parseFloat(m2[3]) / 60 : 0;
10413         var sec = m2[4] ? parseFloat(m2[4]) / 3600 : 0;
10414         var sign2 = deg < 0 ? -1 : 1;
10415         if (dim === "S" || dim === "W") sign2 *= -1;
10416         return {
10417           val: (Math.abs(deg) + min3 + sec) * sign2,
10418           dim,
10419           matched,
10420           remain: input.slice(matched.length)
10421         };
10422       }
10423       function pair3(input, dims) {
10424         input = input.trim();
10425         var one2 = search(input, dims);
10426         if (!one2) return null;
10427         input = one2.remain.trim();
10428         var two = search(input, dims);
10429         if (!two || two.remain) return null;
10430         if (one2.dim) {
10431           return swapdim(one2.val, two.val, one2.dim);
10432         } else {
10433           return [one2.val, two.val];
10434         }
10435       }
10436       function swapdim(a2, b2, dim) {
10437         if (dim === "N" || dim === "S") return [a2, b2];
10438         if (dim === "W" || dim === "E") return [b2, a2];
10439       }
10440     }
10441   });
10442
10443   // node_modules/polygon-clipping/dist/polygon-clipping.umd.js
10444   var require_polygon_clipping_umd = __commonJS({
10445     "node_modules/polygon-clipping/dist/polygon-clipping.umd.js"(exports2, module2) {
10446       (function(global2, factory) {
10447         typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, global2.polygonClipping = factory());
10448       })(exports2, function() {
10449         "use strict";
10450         function __generator(thisArg, body) {
10451           var _2 = {
10452             label: 0,
10453             sent: function() {
10454               if (t2[0] & 1) throw t2[1];
10455               return t2[1];
10456             },
10457             trys: [],
10458             ops: []
10459           }, f2, y2, t2, g3;
10460           return g3 = {
10461             next: verb(0),
10462             "throw": verb(1),
10463             "return": verb(2)
10464           }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() {
10465             return this;
10466           }), g3;
10467           function verb(n3) {
10468             return function(v2) {
10469               return step([n3, v2]);
10470             };
10471           }
10472           function step(op) {
10473             if (f2) throw new TypeError("Generator is already executing.");
10474             while (_2) try {
10475               if (f2 = 1, y2 && (t2 = op[0] & 2 ? y2["return"] : op[0] ? y2["throw"] || ((t2 = y2["return"]) && t2.call(y2), 0) : y2.next) && !(t2 = t2.call(y2, op[1])).done) return t2;
10476               if (y2 = 0, t2) op = [op[0] & 2, t2.value];
10477               switch (op[0]) {
10478                 case 0:
10479                 case 1:
10480                   t2 = op;
10481                   break;
10482                 case 4:
10483                   _2.label++;
10484                   return {
10485                     value: op[1],
10486                     done: false
10487                   };
10488                 case 5:
10489                   _2.label++;
10490                   y2 = op[1];
10491                   op = [0];
10492                   continue;
10493                 case 7:
10494                   op = _2.ops.pop();
10495                   _2.trys.pop();
10496                   continue;
10497                 default:
10498                   if (!(t2 = _2.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) {
10499                     _2 = 0;
10500                     continue;
10501                   }
10502                   if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) {
10503                     _2.label = op[1];
10504                     break;
10505                   }
10506                   if (op[0] === 6 && _2.label < t2[1]) {
10507                     _2.label = t2[1];
10508                     t2 = op;
10509                     break;
10510                   }
10511                   if (t2 && _2.label < t2[2]) {
10512                     _2.label = t2[2];
10513                     _2.ops.push(op);
10514                     break;
10515                   }
10516                   if (t2[2]) _2.ops.pop();
10517                   _2.trys.pop();
10518                   continue;
10519               }
10520               op = body.call(thisArg, _2);
10521             } catch (e3) {
10522               op = [6, e3];
10523               y2 = 0;
10524             } finally {
10525               f2 = t2 = 0;
10526             }
10527             if (op[0] & 5) throw op[1];
10528             return {
10529               value: op[0] ? op[1] : void 0,
10530               done: true
10531             };
10532           }
10533         }
10534         var Node = (
10535           /** @class */
10536           /* @__PURE__ */ function() {
10537             function Node2(key, data) {
10538               this.next = null;
10539               this.key = key;
10540               this.data = data;
10541               this.left = null;
10542               this.right = null;
10543             }
10544             return Node2;
10545           }()
10546         );
10547         function DEFAULT_COMPARE(a2, b2) {
10548           return a2 > b2 ? 1 : a2 < b2 ? -1 : 0;
10549         }
10550         function splay(i3, t2, comparator) {
10551           var N2 = new Node(null, null);
10552           var l2 = N2;
10553           var r2 = N2;
10554           while (true) {
10555             var cmp2 = comparator(i3, t2.key);
10556             if (cmp2 < 0) {
10557               if (t2.left === null) break;
10558               if (comparator(i3, t2.left.key) < 0) {
10559                 var y2 = t2.left;
10560                 t2.left = y2.right;
10561                 y2.right = t2;
10562                 t2 = y2;
10563                 if (t2.left === null) break;
10564               }
10565               r2.left = t2;
10566               r2 = t2;
10567               t2 = t2.left;
10568             } else if (cmp2 > 0) {
10569               if (t2.right === null) break;
10570               if (comparator(i3, t2.right.key) > 0) {
10571                 var y2 = t2.right;
10572                 t2.right = y2.left;
10573                 y2.left = t2;
10574                 t2 = y2;
10575                 if (t2.right === null) break;
10576               }
10577               l2.right = t2;
10578               l2 = t2;
10579               t2 = t2.right;
10580             } else break;
10581           }
10582           l2.right = t2.left;
10583           r2.left = t2.right;
10584           t2.left = N2.right;
10585           t2.right = N2.left;
10586           return t2;
10587         }
10588         function insert(i3, data, t2, comparator) {
10589           var node = new Node(i3, data);
10590           if (t2 === null) {
10591             node.left = node.right = null;
10592             return node;
10593           }
10594           t2 = splay(i3, t2, comparator);
10595           var cmp2 = comparator(i3, t2.key);
10596           if (cmp2 < 0) {
10597             node.left = t2.left;
10598             node.right = t2;
10599             t2.left = null;
10600           } else if (cmp2 >= 0) {
10601             node.right = t2.right;
10602             node.left = t2;
10603             t2.right = null;
10604           }
10605           return node;
10606         }
10607         function split(key, v2, comparator) {
10608           var left = null;
10609           var right = null;
10610           if (v2) {
10611             v2 = splay(key, v2, comparator);
10612             var cmp2 = comparator(v2.key, key);
10613             if (cmp2 === 0) {
10614               left = v2.left;
10615               right = v2.right;
10616             } else if (cmp2 < 0) {
10617               right = v2.right;
10618               v2.right = null;
10619               left = v2;
10620             } else {
10621               left = v2.left;
10622               v2.left = null;
10623               right = v2;
10624             }
10625           }
10626           return {
10627             left,
10628             right
10629           };
10630         }
10631         function merge2(left, right, comparator) {
10632           if (right === null) return left;
10633           if (left === null) return right;
10634           right = splay(left.key, right, comparator);
10635           right.left = left;
10636           return right;
10637         }
10638         function printRow(root3, prefix, isTail, out, printNode) {
10639           if (root3) {
10640             out("" + prefix + (isTail ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ") + printNode(root3) + "\n");
10641             var indent = prefix + (isTail ? "    " : "\u2502   ");
10642             if (root3.left) printRow(root3.left, indent, false, out, printNode);
10643             if (root3.right) printRow(root3.right, indent, true, out, printNode);
10644           }
10645         }
10646         var Tree = (
10647           /** @class */
10648           function() {
10649             function Tree2(comparator) {
10650               if (comparator === void 0) {
10651                 comparator = DEFAULT_COMPARE;
10652               }
10653               this._root = null;
10654               this._size = 0;
10655               this._comparator = comparator;
10656             }
10657             Tree2.prototype.insert = function(key, data) {
10658               this._size++;
10659               return this._root = insert(key, data, this._root, this._comparator);
10660             };
10661             Tree2.prototype.add = function(key, data) {
10662               var node = new Node(key, data);
10663               if (this._root === null) {
10664                 node.left = node.right = null;
10665                 this._size++;
10666                 this._root = node;
10667               }
10668               var comparator = this._comparator;
10669               var t2 = splay(key, this._root, comparator);
10670               var cmp2 = comparator(key, t2.key);
10671               if (cmp2 === 0) this._root = t2;
10672               else {
10673                 if (cmp2 < 0) {
10674                   node.left = t2.left;
10675                   node.right = t2;
10676                   t2.left = null;
10677                 } else if (cmp2 > 0) {
10678                   node.right = t2.right;
10679                   node.left = t2;
10680                   t2.right = null;
10681                 }
10682                 this._size++;
10683                 this._root = node;
10684               }
10685               return this._root;
10686             };
10687             Tree2.prototype.remove = function(key) {
10688               this._root = this._remove(key, this._root, this._comparator);
10689             };
10690             Tree2.prototype._remove = function(i3, t2, comparator) {
10691               var x2;
10692               if (t2 === null) return null;
10693               t2 = splay(i3, t2, comparator);
10694               var cmp2 = comparator(i3, t2.key);
10695               if (cmp2 === 0) {
10696                 if (t2.left === null) {
10697                   x2 = t2.right;
10698                 } else {
10699                   x2 = splay(i3, t2.left, comparator);
10700                   x2.right = t2.right;
10701                 }
10702                 this._size--;
10703                 return x2;
10704               }
10705               return t2;
10706             };
10707             Tree2.prototype.pop = function() {
10708               var node = this._root;
10709               if (node) {
10710                 while (node.left) node = node.left;
10711                 this._root = splay(node.key, this._root, this._comparator);
10712                 this._root = this._remove(node.key, this._root, this._comparator);
10713                 return {
10714                   key: node.key,
10715                   data: node.data
10716                 };
10717               }
10718               return null;
10719             };
10720             Tree2.prototype.findStatic = function(key) {
10721               var current = this._root;
10722               var compare2 = this._comparator;
10723               while (current) {
10724                 var cmp2 = compare2(key, current.key);
10725                 if (cmp2 === 0) return current;
10726                 else if (cmp2 < 0) current = current.left;
10727                 else current = current.right;
10728               }
10729               return null;
10730             };
10731             Tree2.prototype.find = function(key) {
10732               if (this._root) {
10733                 this._root = splay(key, this._root, this._comparator);
10734                 if (this._comparator(key, this._root.key) !== 0) return null;
10735               }
10736               return this._root;
10737             };
10738             Tree2.prototype.contains = function(key) {
10739               var current = this._root;
10740               var compare2 = this._comparator;
10741               while (current) {
10742                 var cmp2 = compare2(key, current.key);
10743                 if (cmp2 === 0) return true;
10744                 else if (cmp2 < 0) current = current.left;
10745                 else current = current.right;
10746               }
10747               return false;
10748             };
10749             Tree2.prototype.forEach = function(visitor, ctx) {
10750               var current = this._root;
10751               var Q2 = [];
10752               var done = false;
10753               while (!done) {
10754                 if (current !== null) {
10755                   Q2.push(current);
10756                   current = current.left;
10757                 } else {
10758                   if (Q2.length !== 0) {
10759                     current = Q2.pop();
10760                     visitor.call(ctx, current);
10761                     current = current.right;
10762                   } else done = true;
10763                 }
10764               }
10765               return this;
10766             };
10767             Tree2.prototype.range = function(low, high, fn, ctx) {
10768               var Q2 = [];
10769               var compare2 = this._comparator;
10770               var node = this._root;
10771               var cmp2;
10772               while (Q2.length !== 0 || node) {
10773                 if (node) {
10774                   Q2.push(node);
10775                   node = node.left;
10776                 } else {
10777                   node = Q2.pop();
10778                   cmp2 = compare2(node.key, high);
10779                   if (cmp2 > 0) {
10780                     break;
10781                   } else if (compare2(node.key, low) >= 0) {
10782                     if (fn.call(ctx, node)) return this;
10783                   }
10784                   node = node.right;
10785                 }
10786               }
10787               return this;
10788             };
10789             Tree2.prototype.keys = function() {
10790               var keys2 = [];
10791               this.forEach(function(_a4) {
10792                 var key = _a4.key;
10793                 return keys2.push(key);
10794               });
10795               return keys2;
10796             };
10797             Tree2.prototype.values = function() {
10798               var values = [];
10799               this.forEach(function(_a4) {
10800                 var data = _a4.data;
10801                 return values.push(data);
10802               });
10803               return values;
10804             };
10805             Tree2.prototype.min = function() {
10806               if (this._root) return this.minNode(this._root).key;
10807               return null;
10808             };
10809             Tree2.prototype.max = function() {
10810               if (this._root) return this.maxNode(this._root).key;
10811               return null;
10812             };
10813             Tree2.prototype.minNode = function(t2) {
10814               if (t2 === void 0) {
10815                 t2 = this._root;
10816               }
10817               if (t2) while (t2.left) t2 = t2.left;
10818               return t2;
10819             };
10820             Tree2.prototype.maxNode = function(t2) {
10821               if (t2 === void 0) {
10822                 t2 = this._root;
10823               }
10824               if (t2) while (t2.right) t2 = t2.right;
10825               return t2;
10826             };
10827             Tree2.prototype.at = function(index2) {
10828               var current = this._root;
10829               var done = false;
10830               var i3 = 0;
10831               var Q2 = [];
10832               while (!done) {
10833                 if (current) {
10834                   Q2.push(current);
10835                   current = current.left;
10836                 } else {
10837                   if (Q2.length > 0) {
10838                     current = Q2.pop();
10839                     if (i3 === index2) return current;
10840                     i3++;
10841                     current = current.right;
10842                   } else done = true;
10843                 }
10844               }
10845               return null;
10846             };
10847             Tree2.prototype.next = function(d2) {
10848               var root3 = this._root;
10849               var successor = null;
10850               if (d2.right) {
10851                 successor = d2.right;
10852                 while (successor.left) successor = successor.left;
10853                 return successor;
10854               }
10855               var comparator = this._comparator;
10856               while (root3) {
10857                 var cmp2 = comparator(d2.key, root3.key);
10858                 if (cmp2 === 0) break;
10859                 else if (cmp2 < 0) {
10860                   successor = root3;
10861                   root3 = root3.left;
10862                 } else root3 = root3.right;
10863               }
10864               return successor;
10865             };
10866             Tree2.prototype.prev = function(d2) {
10867               var root3 = this._root;
10868               var predecessor = null;
10869               if (d2.left !== null) {
10870                 predecessor = d2.left;
10871                 while (predecessor.right) predecessor = predecessor.right;
10872                 return predecessor;
10873               }
10874               var comparator = this._comparator;
10875               while (root3) {
10876                 var cmp2 = comparator(d2.key, root3.key);
10877                 if (cmp2 === 0) break;
10878                 else if (cmp2 < 0) root3 = root3.left;
10879                 else {
10880                   predecessor = root3;
10881                   root3 = root3.right;
10882                 }
10883               }
10884               return predecessor;
10885             };
10886             Tree2.prototype.clear = function() {
10887               this._root = null;
10888               this._size = 0;
10889               return this;
10890             };
10891             Tree2.prototype.toList = function() {
10892               return toList(this._root);
10893             };
10894             Tree2.prototype.load = function(keys2, values, presort) {
10895               if (values === void 0) {
10896                 values = [];
10897               }
10898               if (presort === void 0) {
10899                 presort = false;
10900               }
10901               var size = keys2.length;
10902               var comparator = this._comparator;
10903               if (presort) sort(keys2, values, 0, size - 1, comparator);
10904               if (this._root === null) {
10905                 this._root = loadRecursive(keys2, values, 0, size);
10906                 this._size = size;
10907               } else {
10908                 var mergedList = mergeLists(this.toList(), createList(keys2, values), comparator);
10909                 size = this._size + size;
10910                 this._root = sortedListToBST({
10911                   head: mergedList
10912                 }, 0, size);
10913               }
10914               return this;
10915             };
10916             Tree2.prototype.isEmpty = function() {
10917               return this._root === null;
10918             };
10919             Object.defineProperty(Tree2.prototype, "size", {
10920               get: function() {
10921                 return this._size;
10922               },
10923               enumerable: true,
10924               configurable: true
10925             });
10926             Object.defineProperty(Tree2.prototype, "root", {
10927               get: function() {
10928                 return this._root;
10929               },
10930               enumerable: true,
10931               configurable: true
10932             });
10933             Tree2.prototype.toString = function(printNode) {
10934               if (printNode === void 0) {
10935                 printNode = function(n3) {
10936                   return String(n3.key);
10937                 };
10938               }
10939               var out = [];
10940               printRow(this._root, "", true, function(v2) {
10941                 return out.push(v2);
10942               }, printNode);
10943               return out.join("");
10944             };
10945             Tree2.prototype.update = function(key, newKey, newData) {
10946               var comparator = this._comparator;
10947               var _a4 = split(key, this._root, comparator), left = _a4.left, right = _a4.right;
10948               if (comparator(key, newKey) < 0) {
10949                 right = insert(newKey, newData, right, comparator);
10950               } else {
10951                 left = insert(newKey, newData, left, comparator);
10952               }
10953               this._root = merge2(left, right, comparator);
10954             };
10955             Tree2.prototype.split = function(key) {
10956               return split(key, this._root, this._comparator);
10957             };
10958             Tree2.prototype[Symbol.iterator] = function() {
10959               var current, Q2, done;
10960               return __generator(this, function(_a4) {
10961                 switch (_a4.label) {
10962                   case 0:
10963                     current = this._root;
10964                     Q2 = [];
10965                     done = false;
10966                     _a4.label = 1;
10967                   case 1:
10968                     if (!!done) return [3, 6];
10969                     if (!(current !== null)) return [3, 2];
10970                     Q2.push(current);
10971                     current = current.left;
10972                     return [3, 5];
10973                   case 2:
10974                     if (!(Q2.length !== 0)) return [3, 4];
10975                     current = Q2.pop();
10976                     return [4, current];
10977                   case 3:
10978                     _a4.sent();
10979                     current = current.right;
10980                     return [3, 5];
10981                   case 4:
10982                     done = true;
10983                     _a4.label = 5;
10984                   case 5:
10985                     return [3, 1];
10986                   case 6:
10987                     return [
10988                       2
10989                       /*return*/
10990                     ];
10991                 }
10992               });
10993             };
10994             return Tree2;
10995           }()
10996         );
10997         function loadRecursive(keys2, values, start2, end) {
10998           var size = end - start2;
10999           if (size > 0) {
11000             var middle = start2 + Math.floor(size / 2);
11001             var key = keys2[middle];
11002             var data = values[middle];
11003             var node = new Node(key, data);
11004             node.left = loadRecursive(keys2, values, start2, middle);
11005             node.right = loadRecursive(keys2, values, middle + 1, end);
11006             return node;
11007           }
11008           return null;
11009         }
11010         function createList(keys2, values) {
11011           var head = new Node(null, null);
11012           var p2 = head;
11013           for (var i3 = 0; i3 < keys2.length; i3++) {
11014             p2 = p2.next = new Node(keys2[i3], values[i3]);
11015           }
11016           p2.next = null;
11017           return head.next;
11018         }
11019         function toList(root3) {
11020           var current = root3;
11021           var Q2 = [];
11022           var done = false;
11023           var head = new Node(null, null);
11024           var p2 = head;
11025           while (!done) {
11026             if (current) {
11027               Q2.push(current);
11028               current = current.left;
11029             } else {
11030               if (Q2.length > 0) {
11031                 current = p2 = p2.next = Q2.pop();
11032                 current = current.right;
11033               } else done = true;
11034             }
11035           }
11036           p2.next = null;
11037           return head.next;
11038         }
11039         function sortedListToBST(list2, start2, end) {
11040           var size = end - start2;
11041           if (size > 0) {
11042             var middle = start2 + Math.floor(size / 2);
11043             var left = sortedListToBST(list2, start2, middle);
11044             var root3 = list2.head;
11045             root3.left = left;
11046             list2.head = list2.head.next;
11047             root3.right = sortedListToBST(list2, middle + 1, end);
11048             return root3;
11049           }
11050           return null;
11051         }
11052         function mergeLists(l1, l2, compare2) {
11053           var head = new Node(null, null);
11054           var p2 = head;
11055           var p1 = l1;
11056           var p22 = l2;
11057           while (p1 !== null && p22 !== null) {
11058             if (compare2(p1.key, p22.key) < 0) {
11059               p2.next = p1;
11060               p1 = p1.next;
11061             } else {
11062               p2.next = p22;
11063               p22 = p22.next;
11064             }
11065             p2 = p2.next;
11066           }
11067           if (p1 !== null) {
11068             p2.next = p1;
11069           } else if (p22 !== null) {
11070             p2.next = p22;
11071           }
11072           return head.next;
11073         }
11074         function sort(keys2, values, left, right, compare2) {
11075           if (left >= right) return;
11076           var pivot = keys2[left + right >> 1];
11077           var i3 = left - 1;
11078           var j2 = right + 1;
11079           while (true) {
11080             do
11081               i3++;
11082             while (compare2(keys2[i3], pivot) < 0);
11083             do
11084               j2--;
11085             while (compare2(keys2[j2], pivot) > 0);
11086             if (i3 >= j2) break;
11087             var tmp = keys2[i3];
11088             keys2[i3] = keys2[j2];
11089             keys2[j2] = tmp;
11090             tmp = values[i3];
11091             values[i3] = values[j2];
11092             values[j2] = tmp;
11093           }
11094           sort(keys2, values, left, j2, compare2);
11095           sort(keys2, values, j2 + 1, right, compare2);
11096         }
11097         const isInBbox2 = (bbox2, point) => {
11098           return bbox2.ll.x <= point.x && point.x <= bbox2.ur.x && bbox2.ll.y <= point.y && point.y <= bbox2.ur.y;
11099         };
11100         const getBboxOverlap2 = (b1, b2) => {
11101           if (b2.ur.x < b1.ll.x || b1.ur.x < b2.ll.x || b2.ur.y < b1.ll.y || b1.ur.y < b2.ll.y) return null;
11102           const lowerX = b1.ll.x < b2.ll.x ? b2.ll.x : b1.ll.x;
11103           const upperX = b1.ur.x < b2.ur.x ? b1.ur.x : b2.ur.x;
11104           const lowerY = b1.ll.y < b2.ll.y ? b2.ll.y : b1.ll.y;
11105           const upperY = b1.ur.y < b2.ur.y ? b1.ur.y : b2.ur.y;
11106           return {
11107             ll: {
11108               x: lowerX,
11109               y: lowerY
11110             },
11111             ur: {
11112               x: upperX,
11113               y: upperY
11114             }
11115           };
11116         };
11117         let epsilon$1 = Number.EPSILON;
11118         if (epsilon$1 === void 0) epsilon$1 = Math.pow(2, -52);
11119         const EPSILON_SQ = epsilon$1 * epsilon$1;
11120         const cmp = (a2, b2) => {
11121           if (-epsilon$1 < a2 && a2 < epsilon$1) {
11122             if (-epsilon$1 < b2 && b2 < epsilon$1) {
11123               return 0;
11124             }
11125           }
11126           const ab = a2 - b2;
11127           if (ab * ab < EPSILON_SQ * a2 * b2) {
11128             return 0;
11129           }
11130           return a2 < b2 ? -1 : 1;
11131         };
11132         class PtRounder {
11133           constructor() {
11134             this.reset();
11135           }
11136           reset() {
11137             this.xRounder = new CoordRounder();
11138             this.yRounder = new CoordRounder();
11139           }
11140           round(x2, y2) {
11141             return {
11142               x: this.xRounder.round(x2),
11143               y: this.yRounder.round(y2)
11144             };
11145           }
11146         }
11147         class CoordRounder {
11148           constructor() {
11149             this.tree = new Tree();
11150             this.round(0);
11151           }
11152           // Note: this can rounds input values backwards or forwards.
11153           //       You might ask, why not restrict this to just rounding
11154           //       forwards? Wouldn't that allow left endpoints to always
11155           //       remain left endpoints during splitting (never change to
11156           //       right). No - it wouldn't, because we snap intersections
11157           //       to endpoints (to establish independence from the segment
11158           //       angle for t-intersections).
11159           round(coord2) {
11160             const node = this.tree.add(coord2);
11161             const prevNode = this.tree.prev(node);
11162             if (prevNode !== null && cmp(node.key, prevNode.key) === 0) {
11163               this.tree.remove(coord2);
11164               return prevNode.key;
11165             }
11166             const nextNode = this.tree.next(node);
11167             if (nextNode !== null && cmp(node.key, nextNode.key) === 0) {
11168               this.tree.remove(coord2);
11169               return nextNode.key;
11170             }
11171             return coord2;
11172           }
11173         }
11174         const rounder = new PtRounder();
11175         const epsilon3 = 11102230246251565e-32;
11176         const splitter = 134217729;
11177         const resulterrbound = (3 + 8 * epsilon3) * epsilon3;
11178         function sum(elen, e3, flen, f2, h2) {
11179           let Q2, Qnew, hh, bvirt;
11180           let enow = e3[0];
11181           let fnow = f2[0];
11182           let eindex = 0;
11183           let findex = 0;
11184           if (fnow > enow === fnow > -enow) {
11185             Q2 = enow;
11186             enow = e3[++eindex];
11187           } else {
11188             Q2 = fnow;
11189             fnow = f2[++findex];
11190           }
11191           let hindex = 0;
11192           if (eindex < elen && findex < flen) {
11193             if (fnow > enow === fnow > -enow) {
11194               Qnew = enow + Q2;
11195               hh = Q2 - (Qnew - enow);
11196               enow = e3[++eindex];
11197             } else {
11198               Qnew = fnow + Q2;
11199               hh = Q2 - (Qnew - fnow);
11200               fnow = f2[++findex];
11201             }
11202             Q2 = Qnew;
11203             if (hh !== 0) {
11204               h2[hindex++] = hh;
11205             }
11206             while (eindex < elen && findex < flen) {
11207               if (fnow > enow === fnow > -enow) {
11208                 Qnew = Q2 + enow;
11209                 bvirt = Qnew - Q2;
11210                 hh = Q2 - (Qnew - bvirt) + (enow - bvirt);
11211                 enow = e3[++eindex];
11212               } else {
11213                 Qnew = Q2 + fnow;
11214                 bvirt = Qnew - Q2;
11215                 hh = Q2 - (Qnew - bvirt) + (fnow - bvirt);
11216                 fnow = f2[++findex];
11217               }
11218               Q2 = Qnew;
11219               if (hh !== 0) {
11220                 h2[hindex++] = hh;
11221               }
11222             }
11223           }
11224           while (eindex < elen) {
11225             Qnew = Q2 + enow;
11226             bvirt = Qnew - Q2;
11227             hh = Q2 - (Qnew - bvirt) + (enow - bvirt);
11228             enow = e3[++eindex];
11229             Q2 = Qnew;
11230             if (hh !== 0) {
11231               h2[hindex++] = hh;
11232             }
11233           }
11234           while (findex < flen) {
11235             Qnew = Q2 + fnow;
11236             bvirt = Qnew - Q2;
11237             hh = Q2 - (Qnew - bvirt) + (fnow - bvirt);
11238             fnow = f2[++findex];
11239             Q2 = Qnew;
11240             if (hh !== 0) {
11241               h2[hindex++] = hh;
11242             }
11243           }
11244           if (Q2 !== 0 || hindex === 0) {
11245             h2[hindex++] = Q2;
11246           }
11247           return hindex;
11248         }
11249         function estimate(elen, e3) {
11250           let Q2 = e3[0];
11251           for (let i3 = 1; i3 < elen; i3++) Q2 += e3[i3];
11252           return Q2;
11253         }
11254         function vec(n3) {
11255           return new Float64Array(n3);
11256         }
11257         const ccwerrboundA = (3 + 16 * epsilon3) * epsilon3;
11258         const ccwerrboundB = (2 + 12 * epsilon3) * epsilon3;
11259         const ccwerrboundC = (9 + 64 * epsilon3) * epsilon3 * epsilon3;
11260         const B2 = vec(4);
11261         const C1 = vec(8);
11262         const C2 = vec(12);
11263         const D2 = vec(16);
11264         const u2 = vec(4);
11265         function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
11266           let acxtail, acytail, bcxtail, bcytail;
11267           let bvirt, c2, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u3;
11268           const acx = ax - cx;
11269           const bcx = bx - cx;
11270           const acy = ay - cy;
11271           const bcy = by - cy;
11272           s1 = acx * bcy;
11273           c2 = splitter * acx;
11274           ahi = c2 - (c2 - acx);
11275           alo = acx - ahi;
11276           c2 = splitter * bcy;
11277           bhi = c2 - (c2 - bcy);
11278           blo = bcy - bhi;
11279           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
11280           t1 = acy * bcx;
11281           c2 = splitter * acy;
11282           ahi = c2 - (c2 - acy);
11283           alo = acy - ahi;
11284           c2 = splitter * bcx;
11285           bhi = c2 - (c2 - bcx);
11286           blo = bcx - bhi;
11287           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
11288           _i = s0 - t0;
11289           bvirt = s0 - _i;
11290           B2[0] = s0 - (_i + bvirt) + (bvirt - t0);
11291           _j = s1 + _i;
11292           bvirt = _j - s1;
11293           _0 = s1 - (_j - bvirt) + (_i - bvirt);
11294           _i = _0 - t1;
11295           bvirt = _0 - _i;
11296           B2[1] = _0 - (_i + bvirt) + (bvirt - t1);
11297           u3 = _j + _i;
11298           bvirt = u3 - _j;
11299           B2[2] = _j - (u3 - bvirt) + (_i - bvirt);
11300           B2[3] = u3;
11301           let det = estimate(4, B2);
11302           let errbound = ccwerrboundB * detsum;
11303           if (det >= errbound || -det >= errbound) {
11304             return det;
11305           }
11306           bvirt = ax - acx;
11307           acxtail = ax - (acx + bvirt) + (bvirt - cx);
11308           bvirt = bx - bcx;
11309           bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
11310           bvirt = ay - acy;
11311           acytail = ay - (acy + bvirt) + (bvirt - cy);
11312           bvirt = by - bcy;
11313           bcytail = by - (bcy + bvirt) + (bvirt - cy);
11314           if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
11315             return det;
11316           }
11317           errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
11318           det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
11319           if (det >= errbound || -det >= errbound) return det;
11320           s1 = acxtail * bcy;
11321           c2 = splitter * acxtail;
11322           ahi = c2 - (c2 - acxtail);
11323           alo = acxtail - ahi;
11324           c2 = splitter * bcy;
11325           bhi = c2 - (c2 - bcy);
11326           blo = bcy - bhi;
11327           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
11328           t1 = acytail * bcx;
11329           c2 = splitter * acytail;
11330           ahi = c2 - (c2 - acytail);
11331           alo = acytail - ahi;
11332           c2 = splitter * bcx;
11333           bhi = c2 - (c2 - bcx);
11334           blo = bcx - bhi;
11335           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
11336           _i = s0 - t0;
11337           bvirt = s0 - _i;
11338           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
11339           _j = s1 + _i;
11340           bvirt = _j - s1;
11341           _0 = s1 - (_j - bvirt) + (_i - bvirt);
11342           _i = _0 - t1;
11343           bvirt = _0 - _i;
11344           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
11345           u3 = _j + _i;
11346           bvirt = u3 - _j;
11347           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
11348           u2[3] = u3;
11349           const C1len = sum(4, B2, 4, u2, C1);
11350           s1 = acx * bcytail;
11351           c2 = splitter * acx;
11352           ahi = c2 - (c2 - acx);
11353           alo = acx - ahi;
11354           c2 = splitter * bcytail;
11355           bhi = c2 - (c2 - bcytail);
11356           blo = bcytail - bhi;
11357           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
11358           t1 = acy * bcxtail;
11359           c2 = splitter * acy;
11360           ahi = c2 - (c2 - acy);
11361           alo = acy - ahi;
11362           c2 = splitter * bcxtail;
11363           bhi = c2 - (c2 - bcxtail);
11364           blo = bcxtail - bhi;
11365           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
11366           _i = s0 - t0;
11367           bvirt = s0 - _i;
11368           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
11369           _j = s1 + _i;
11370           bvirt = _j - s1;
11371           _0 = s1 - (_j - bvirt) + (_i - bvirt);
11372           _i = _0 - t1;
11373           bvirt = _0 - _i;
11374           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
11375           u3 = _j + _i;
11376           bvirt = u3 - _j;
11377           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
11378           u2[3] = u3;
11379           const C2len = sum(C1len, C1, 4, u2, C2);
11380           s1 = acxtail * bcytail;
11381           c2 = splitter * acxtail;
11382           ahi = c2 - (c2 - acxtail);
11383           alo = acxtail - ahi;
11384           c2 = splitter * bcytail;
11385           bhi = c2 - (c2 - bcytail);
11386           blo = bcytail - bhi;
11387           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
11388           t1 = acytail * bcxtail;
11389           c2 = splitter * acytail;
11390           ahi = c2 - (c2 - acytail);
11391           alo = acytail - ahi;
11392           c2 = splitter * bcxtail;
11393           bhi = c2 - (c2 - bcxtail);
11394           blo = bcxtail - bhi;
11395           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
11396           _i = s0 - t0;
11397           bvirt = s0 - _i;
11398           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
11399           _j = s1 + _i;
11400           bvirt = _j - s1;
11401           _0 = s1 - (_j - bvirt) + (_i - bvirt);
11402           _i = _0 - t1;
11403           bvirt = _0 - _i;
11404           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
11405           u3 = _j + _i;
11406           bvirt = u3 - _j;
11407           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
11408           u2[3] = u3;
11409           const Dlen = sum(C2len, C2, 4, u2, D2);
11410           return D2[Dlen - 1];
11411         }
11412         function orient2d(ax, ay, bx, by, cx, cy) {
11413           const detleft = (ay - cy) * (bx - cx);
11414           const detright = (ax - cx) * (by - cy);
11415           const det = detleft - detright;
11416           const detsum = Math.abs(detleft + detright);
11417           if (Math.abs(det) >= ccwerrboundA * detsum) return det;
11418           return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
11419         }
11420         const crossProduct2 = (a2, b2) => a2.x * b2.y - a2.y * b2.x;
11421         const dotProduct2 = (a2, b2) => a2.x * b2.x + a2.y * b2.y;
11422         const compareVectorAngles = (basePt, endPt1, endPt2) => {
11423           const res = orient2d(basePt.x, basePt.y, endPt1.x, endPt1.y, endPt2.x, endPt2.y);
11424           if (res > 0) return -1;
11425           if (res < 0) return 1;
11426           return 0;
11427         };
11428         const length2 = (v2) => Math.sqrt(dotProduct2(v2, v2));
11429         const sineOfAngle2 = (pShared, pBase, pAngle) => {
11430           const vBase = {
11431             x: pBase.x - pShared.x,
11432             y: pBase.y - pShared.y
11433           };
11434           const vAngle = {
11435             x: pAngle.x - pShared.x,
11436             y: pAngle.y - pShared.y
11437           };
11438           return crossProduct2(vAngle, vBase) / length2(vAngle) / length2(vBase);
11439         };
11440         const cosineOfAngle2 = (pShared, pBase, pAngle) => {
11441           const vBase = {
11442             x: pBase.x - pShared.x,
11443             y: pBase.y - pShared.y
11444           };
11445           const vAngle = {
11446             x: pAngle.x - pShared.x,
11447             y: pAngle.y - pShared.y
11448           };
11449           return dotProduct2(vAngle, vBase) / length2(vAngle) / length2(vBase);
11450         };
11451         const horizontalIntersection2 = (pt2, v2, y2) => {
11452           if (v2.y === 0) return null;
11453           return {
11454             x: pt2.x + v2.x / v2.y * (y2 - pt2.y),
11455             y: y2
11456           };
11457         };
11458         const verticalIntersection2 = (pt2, v2, x2) => {
11459           if (v2.x === 0) return null;
11460           return {
11461             x: x2,
11462             y: pt2.y + v2.y / v2.x * (x2 - pt2.x)
11463           };
11464         };
11465         const intersection$1 = (pt1, v1, pt2, v2) => {
11466           if (v1.x === 0) return verticalIntersection2(pt2, v2, pt1.x);
11467           if (v2.x === 0) return verticalIntersection2(pt1, v1, pt2.x);
11468           if (v1.y === 0) return horizontalIntersection2(pt2, v2, pt1.y);
11469           if (v2.y === 0) return horizontalIntersection2(pt1, v1, pt2.y);
11470           const kross = crossProduct2(v1, v2);
11471           if (kross == 0) return null;
11472           const ve2 = {
11473             x: pt2.x - pt1.x,
11474             y: pt2.y - pt1.y
11475           };
11476           const d1 = crossProduct2(ve2, v1) / kross;
11477           const d2 = crossProduct2(ve2, v2) / kross;
11478           const x12 = pt1.x + d2 * v1.x, x2 = pt2.x + d1 * v2.x;
11479           const y12 = pt1.y + d2 * v1.y, y2 = pt2.y + d1 * v2.y;
11480           const x3 = (x12 + x2) / 2;
11481           const y3 = (y12 + y2) / 2;
11482           return {
11483             x: x3,
11484             y: y3
11485           };
11486         };
11487         class SweepEvent2 {
11488           // for ordering sweep events in the sweep event queue
11489           static compare(a2, b2) {
11490             const ptCmp = SweepEvent2.comparePoints(a2.point, b2.point);
11491             if (ptCmp !== 0) return ptCmp;
11492             if (a2.point !== b2.point) a2.link(b2);
11493             if (a2.isLeft !== b2.isLeft) return a2.isLeft ? 1 : -1;
11494             return Segment2.compare(a2.segment, b2.segment);
11495           }
11496           // for ordering points in sweep line order
11497           static comparePoints(aPt, bPt) {
11498             if (aPt.x < bPt.x) return -1;
11499             if (aPt.x > bPt.x) return 1;
11500             if (aPt.y < bPt.y) return -1;
11501             if (aPt.y > bPt.y) return 1;
11502             return 0;
11503           }
11504           // Warning: 'point' input will be modified and re-used (for performance)
11505           constructor(point, isLeft) {
11506             if (point.events === void 0) point.events = [this];
11507             else point.events.push(this);
11508             this.point = point;
11509             this.isLeft = isLeft;
11510           }
11511           link(other2) {
11512             if (other2.point === this.point) {
11513               throw new Error("Tried to link already linked events");
11514             }
11515             const otherEvents = other2.point.events;
11516             for (let i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) {
11517               const evt = otherEvents[i3];
11518               this.point.events.push(evt);
11519               evt.point = this.point;
11520             }
11521             this.checkForConsuming();
11522           }
11523           /* Do a pass over our linked events and check to see if any pair
11524            * of segments match, and should be consumed. */
11525           checkForConsuming() {
11526             const numEvents = this.point.events.length;
11527             for (let i3 = 0; i3 < numEvents; i3++) {
11528               const evt1 = this.point.events[i3];
11529               if (evt1.segment.consumedBy !== void 0) continue;
11530               for (let j2 = i3 + 1; j2 < numEvents; j2++) {
11531                 const evt2 = this.point.events[j2];
11532                 if (evt2.consumedBy !== void 0) continue;
11533                 if (evt1.otherSE.point.events !== evt2.otherSE.point.events) continue;
11534                 evt1.segment.consume(evt2.segment);
11535               }
11536             }
11537           }
11538           getAvailableLinkedEvents() {
11539             const events = [];
11540             for (let i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) {
11541               const evt = this.point.events[i3];
11542               if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) {
11543                 events.push(evt);
11544               }
11545             }
11546             return events;
11547           }
11548           /**
11549            * Returns a comparator function for sorting linked events that will
11550            * favor the event that will give us the smallest left-side angle.
11551            * All ring construction starts as low as possible heading to the right,
11552            * so by always turning left as sharp as possible we'll get polygons
11553            * without uncessary loops & holes.
11554            *
11555            * The comparator function has a compute cache such that it avoids
11556            * re-computing already-computed values.
11557            */
11558           getLeftmostComparator(baseEvent) {
11559             const cache = /* @__PURE__ */ new Map();
11560             const fillCache = (linkedEvent) => {
11561               const nextEvent = linkedEvent.otherSE;
11562               cache.set(linkedEvent, {
11563                 sine: sineOfAngle2(this.point, baseEvent.point, nextEvent.point),
11564                 cosine: cosineOfAngle2(this.point, baseEvent.point, nextEvent.point)
11565               });
11566             };
11567             return (a2, b2) => {
11568               if (!cache.has(a2)) fillCache(a2);
11569               if (!cache.has(b2)) fillCache(b2);
11570               const {
11571                 sine: asine,
11572                 cosine: acosine
11573               } = cache.get(a2);
11574               const {
11575                 sine: bsine,
11576                 cosine: bcosine
11577               } = cache.get(b2);
11578               if (asine >= 0 && bsine >= 0) {
11579                 if (acosine < bcosine) return 1;
11580                 if (acosine > bcosine) return -1;
11581                 return 0;
11582               }
11583               if (asine < 0 && bsine < 0) {
11584                 if (acosine < bcosine) return -1;
11585                 if (acosine > bcosine) return 1;
11586                 return 0;
11587               }
11588               if (bsine < asine) return -1;
11589               if (bsine > asine) return 1;
11590               return 0;
11591             };
11592           }
11593         }
11594         let segmentId2 = 0;
11595         class Segment2 {
11596           /* This compare() function is for ordering segments in the sweep
11597            * line tree, and does so according to the following criteria:
11598            *
11599            * Consider the vertical line that lies an infinestimal step to the
11600            * right of the right-more of the two left endpoints of the input
11601            * segments. Imagine slowly moving a point up from negative infinity
11602            * in the increasing y direction. Which of the two segments will that
11603            * point intersect first? That segment comes 'before' the other one.
11604            *
11605            * If neither segment would be intersected by such a line, (if one
11606            * or more of the segments are vertical) then the line to be considered
11607            * is directly on the right-more of the two left inputs.
11608            */
11609           static compare(a2, b2) {
11610             const alx = a2.leftSE.point.x;
11611             const blx = b2.leftSE.point.x;
11612             const arx = a2.rightSE.point.x;
11613             const brx = b2.rightSE.point.x;
11614             if (brx < alx) return 1;
11615             if (arx < blx) return -1;
11616             const aly = a2.leftSE.point.y;
11617             const bly = b2.leftSE.point.y;
11618             const ary = a2.rightSE.point.y;
11619             const bry = b2.rightSE.point.y;
11620             if (alx < blx) {
11621               if (bly < aly && bly < ary) return 1;
11622               if (bly > aly && bly > ary) return -1;
11623               const aCmpBLeft = a2.comparePoint(b2.leftSE.point);
11624               if (aCmpBLeft < 0) return 1;
11625               if (aCmpBLeft > 0) return -1;
11626               const bCmpARight = b2.comparePoint(a2.rightSE.point);
11627               if (bCmpARight !== 0) return bCmpARight;
11628               return -1;
11629             }
11630             if (alx > blx) {
11631               if (aly < bly && aly < bry) return -1;
11632               if (aly > bly && aly > bry) return 1;
11633               const bCmpALeft = b2.comparePoint(a2.leftSE.point);
11634               if (bCmpALeft !== 0) return bCmpALeft;
11635               const aCmpBRight = a2.comparePoint(b2.rightSE.point);
11636               if (aCmpBRight < 0) return 1;
11637               if (aCmpBRight > 0) return -1;
11638               return 1;
11639             }
11640             if (aly < bly) return -1;
11641             if (aly > bly) return 1;
11642             if (arx < brx) {
11643               const bCmpARight = b2.comparePoint(a2.rightSE.point);
11644               if (bCmpARight !== 0) return bCmpARight;
11645             }
11646             if (arx > brx) {
11647               const aCmpBRight = a2.comparePoint(b2.rightSE.point);
11648               if (aCmpBRight < 0) return 1;
11649               if (aCmpBRight > 0) return -1;
11650             }
11651             if (arx !== brx) {
11652               const ay = ary - aly;
11653               const ax = arx - alx;
11654               const by = bry - bly;
11655               const bx = brx - blx;
11656               if (ay > ax && by < bx) return 1;
11657               if (ay < ax && by > bx) return -1;
11658             }
11659             if (arx > brx) return 1;
11660             if (arx < brx) return -1;
11661             if (ary < bry) return -1;
11662             if (ary > bry) return 1;
11663             if (a2.id < b2.id) return -1;
11664             if (a2.id > b2.id) return 1;
11665             return 0;
11666           }
11667           /* Warning: a reference to ringWindings input will be stored,
11668            *  and possibly will be later modified */
11669           constructor(leftSE, rightSE, rings, windings) {
11670             this.id = ++segmentId2;
11671             this.leftSE = leftSE;
11672             leftSE.segment = this;
11673             leftSE.otherSE = rightSE;
11674             this.rightSE = rightSE;
11675             rightSE.segment = this;
11676             rightSE.otherSE = leftSE;
11677             this.rings = rings;
11678             this.windings = windings;
11679           }
11680           static fromRing(pt1, pt2, ring) {
11681             let leftPt, rightPt, winding;
11682             const cmpPts = SweepEvent2.comparePoints(pt1, pt2);
11683             if (cmpPts < 0) {
11684               leftPt = pt1;
11685               rightPt = pt2;
11686               winding = 1;
11687             } else if (cmpPts > 0) {
11688               leftPt = pt2;
11689               rightPt = pt1;
11690               winding = -1;
11691             } else throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]"));
11692             const leftSE = new SweepEvent2(leftPt, true);
11693             const rightSE = new SweepEvent2(rightPt, false);
11694             return new Segment2(leftSE, rightSE, [ring], [winding]);
11695           }
11696           /* When a segment is split, the rightSE is replaced with a new sweep event */
11697           replaceRightSE(newRightSE) {
11698             this.rightSE = newRightSE;
11699             this.rightSE.segment = this;
11700             this.rightSE.otherSE = this.leftSE;
11701             this.leftSE.otherSE = this.rightSE;
11702           }
11703           bbox() {
11704             const y12 = this.leftSE.point.y;
11705             const y2 = this.rightSE.point.y;
11706             return {
11707               ll: {
11708                 x: this.leftSE.point.x,
11709                 y: y12 < y2 ? y12 : y2
11710               },
11711               ur: {
11712                 x: this.rightSE.point.x,
11713                 y: y12 > y2 ? y12 : y2
11714               }
11715             };
11716           }
11717           /* A vector from the left point to the right */
11718           vector() {
11719             return {
11720               x: this.rightSE.point.x - this.leftSE.point.x,
11721               y: this.rightSE.point.y - this.leftSE.point.y
11722             };
11723           }
11724           isAnEndpoint(pt2) {
11725             return pt2.x === this.leftSE.point.x && pt2.y === this.leftSE.point.y || pt2.x === this.rightSE.point.x && pt2.y === this.rightSE.point.y;
11726           }
11727           /* Compare this segment with a point.
11728            *
11729            * A point P is considered to be colinear to a segment if there
11730            * exists a distance D such that if we travel along the segment
11731            * from one * endpoint towards the other a distance D, we find
11732            * ourselves at point P.
11733            *
11734            * Return value indicates:
11735            *
11736            *   1: point lies above the segment (to the left of vertical)
11737            *   0: point is colinear to segment
11738            *  -1: point lies below the segment (to the right of vertical)
11739            */
11740           comparePoint(point) {
11741             if (this.isAnEndpoint(point)) return 0;
11742             const lPt = this.leftSE.point;
11743             const rPt = this.rightSE.point;
11744             const v2 = this.vector();
11745             if (lPt.x === rPt.x) {
11746               if (point.x === lPt.x) return 0;
11747               return point.x < lPt.x ? 1 : -1;
11748             }
11749             const yDist = (point.y - lPt.y) / v2.y;
11750             const xFromYDist = lPt.x + yDist * v2.x;
11751             if (point.x === xFromYDist) return 0;
11752             const xDist = (point.x - lPt.x) / v2.x;
11753             const yFromXDist = lPt.y + xDist * v2.y;
11754             if (point.y === yFromXDist) return 0;
11755             return point.y < yFromXDist ? -1 : 1;
11756           }
11757           /**
11758            * Given another segment, returns the first non-trivial intersection
11759            * between the two segments (in terms of sweep line ordering), if it exists.
11760            *
11761            * A 'non-trivial' intersection is one that will cause one or both of the
11762            * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection:
11763            *
11764            *   * endpoint of segA with endpoint of segB --> trivial
11765            *   * endpoint of segA with point along segB --> non-trivial
11766            *   * endpoint of segB with point along segA --> non-trivial
11767            *   * point along segA with point along segB --> non-trivial
11768            *
11769            * If no non-trivial intersection exists, return null
11770            * Else, return null.
11771            */
11772           getIntersection(other2) {
11773             const tBbox = this.bbox();
11774             const oBbox = other2.bbox();
11775             const bboxOverlap = getBboxOverlap2(tBbox, oBbox);
11776             if (bboxOverlap === null) return null;
11777             const tlp = this.leftSE.point;
11778             const trp = this.rightSE.point;
11779             const olp = other2.leftSE.point;
11780             const orp = other2.rightSE.point;
11781             const touchesOtherLSE = isInBbox2(tBbox, olp) && this.comparePoint(olp) === 0;
11782             const touchesThisLSE = isInBbox2(oBbox, tlp) && other2.comparePoint(tlp) === 0;
11783             const touchesOtherRSE = isInBbox2(tBbox, orp) && this.comparePoint(orp) === 0;
11784             const touchesThisRSE = isInBbox2(oBbox, trp) && other2.comparePoint(trp) === 0;
11785             if (touchesThisLSE && touchesOtherLSE) {
11786               if (touchesThisRSE && !touchesOtherRSE) return trp;
11787               if (!touchesThisRSE && touchesOtherRSE) return orp;
11788               return null;
11789             }
11790             if (touchesThisLSE) {
11791               if (touchesOtherRSE) {
11792                 if (tlp.x === orp.x && tlp.y === orp.y) return null;
11793               }
11794               return tlp;
11795             }
11796             if (touchesOtherLSE) {
11797               if (touchesThisRSE) {
11798                 if (trp.x === olp.x && trp.y === olp.y) return null;
11799               }
11800               return olp;
11801             }
11802             if (touchesThisRSE && touchesOtherRSE) return null;
11803             if (touchesThisRSE) return trp;
11804             if (touchesOtherRSE) return orp;
11805             const pt2 = intersection$1(tlp, this.vector(), olp, other2.vector());
11806             if (pt2 === null) return null;
11807             if (!isInBbox2(bboxOverlap, pt2)) return null;
11808             return rounder.round(pt2.x, pt2.y);
11809           }
11810           /**
11811            * Split the given segment into multiple segments on the given points.
11812            *  * Each existing segment will retain its leftSE and a new rightSE will be
11813            *    generated for it.
11814            *  * A new segment will be generated which will adopt the original segment's
11815            *    rightSE, and a new leftSE will be generated for it.
11816            *  * If there are more than two points given to split on, new segments
11817            *    in the middle will be generated with new leftSE and rightSE's.
11818            *  * An array of the newly generated SweepEvents will be returned.
11819            *
11820            * Warning: input array of points is modified
11821            */
11822           split(point) {
11823             const newEvents = [];
11824             const alreadyLinked = point.events !== void 0;
11825             const newLeftSE = new SweepEvent2(point, true);
11826             const newRightSE = new SweepEvent2(point, false);
11827             const oldRightSE = this.rightSE;
11828             this.replaceRightSE(newRightSE);
11829             newEvents.push(newRightSE);
11830             newEvents.push(newLeftSE);
11831             const newSeg = new Segment2(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice());
11832             if (SweepEvent2.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) {
11833               newSeg.swapEvents();
11834             }
11835             if (SweepEvent2.comparePoints(this.leftSE.point, this.rightSE.point) > 0) {
11836               this.swapEvents();
11837             }
11838             if (alreadyLinked) {
11839               newLeftSE.checkForConsuming();
11840               newRightSE.checkForConsuming();
11841             }
11842             return newEvents;
11843           }
11844           /* Swap which event is left and right */
11845           swapEvents() {
11846             const tmpEvt = this.rightSE;
11847             this.rightSE = this.leftSE;
11848             this.leftSE = tmpEvt;
11849             this.leftSE.isLeft = true;
11850             this.rightSE.isLeft = false;
11851             for (let i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) {
11852               this.windings[i3] *= -1;
11853             }
11854           }
11855           /* Consume another segment. We take their rings under our wing
11856            * and mark them as consumed. Use for perfectly overlapping segments */
11857           consume(other2) {
11858             let consumer = this;
11859             let consumee = other2;
11860             while (consumer.consumedBy) consumer = consumer.consumedBy;
11861             while (consumee.consumedBy) consumee = consumee.consumedBy;
11862             const cmp2 = Segment2.compare(consumer, consumee);
11863             if (cmp2 === 0) return;
11864             if (cmp2 > 0) {
11865               const tmp = consumer;
11866               consumer = consumee;
11867               consumee = tmp;
11868             }
11869             if (consumer.prev === consumee) {
11870               const tmp = consumer;
11871               consumer = consumee;
11872               consumee = tmp;
11873             }
11874             for (let i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) {
11875               const ring = consumee.rings[i3];
11876               const winding = consumee.windings[i3];
11877               const index2 = consumer.rings.indexOf(ring);
11878               if (index2 === -1) {
11879                 consumer.rings.push(ring);
11880                 consumer.windings.push(winding);
11881               } else consumer.windings[index2] += winding;
11882             }
11883             consumee.rings = null;
11884             consumee.windings = null;
11885             consumee.consumedBy = consumer;
11886             consumee.leftSE.consumedBy = consumer.leftSE;
11887             consumee.rightSE.consumedBy = consumer.rightSE;
11888           }
11889           /* The first segment previous segment chain that is in the result */
11890           prevInResult() {
11891             if (this._prevInResult !== void 0) return this._prevInResult;
11892             if (!this.prev) this._prevInResult = null;
11893             else if (this.prev.isInResult()) this._prevInResult = this.prev;
11894             else this._prevInResult = this.prev.prevInResult();
11895             return this._prevInResult;
11896           }
11897           beforeState() {
11898             if (this._beforeState !== void 0) return this._beforeState;
11899             if (!this.prev) this._beforeState = {
11900               rings: [],
11901               windings: [],
11902               multiPolys: []
11903             };
11904             else {
11905               const seg = this.prev.consumedBy || this.prev;
11906               this._beforeState = seg.afterState();
11907             }
11908             return this._beforeState;
11909           }
11910           afterState() {
11911             if (this._afterState !== void 0) return this._afterState;
11912             const beforeState = this.beforeState();
11913             this._afterState = {
11914               rings: beforeState.rings.slice(0),
11915               windings: beforeState.windings.slice(0),
11916               multiPolys: []
11917             };
11918             const ringsAfter = this._afterState.rings;
11919             const windingsAfter = this._afterState.windings;
11920             const mpsAfter = this._afterState.multiPolys;
11921             for (let i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) {
11922               const ring = this.rings[i3];
11923               const winding = this.windings[i3];
11924               const index2 = ringsAfter.indexOf(ring);
11925               if (index2 === -1) {
11926                 ringsAfter.push(ring);
11927                 windingsAfter.push(winding);
11928               } else windingsAfter[index2] += winding;
11929             }
11930             const polysAfter = [];
11931             const polysExclude = [];
11932             for (let i3 = 0, iMax = ringsAfter.length; i3 < iMax; i3++) {
11933               if (windingsAfter[i3] === 0) continue;
11934               const ring = ringsAfter[i3];
11935               const poly = ring.poly;
11936               if (polysExclude.indexOf(poly) !== -1) continue;
11937               if (ring.isExterior) polysAfter.push(poly);
11938               else {
11939                 if (polysExclude.indexOf(poly) === -1) polysExclude.push(poly);
11940                 const index2 = polysAfter.indexOf(ring.poly);
11941                 if (index2 !== -1) polysAfter.splice(index2, 1);
11942               }
11943             }
11944             for (let i3 = 0, iMax = polysAfter.length; i3 < iMax; i3++) {
11945               const mp = polysAfter[i3].multiPoly;
11946               if (mpsAfter.indexOf(mp) === -1) mpsAfter.push(mp);
11947             }
11948             return this._afterState;
11949           }
11950           /* Is this segment part of the final result? */
11951           isInResult() {
11952             if (this.consumedBy) return false;
11953             if (this._isInResult !== void 0) return this._isInResult;
11954             const mpsBefore = this.beforeState().multiPolys;
11955             const mpsAfter = this.afterState().multiPolys;
11956             switch (operation2.type) {
11957               case "union": {
11958                 const noBefores = mpsBefore.length === 0;
11959                 const noAfters = mpsAfter.length === 0;
11960                 this._isInResult = noBefores !== noAfters;
11961                 break;
11962               }
11963               case "intersection": {
11964                 let least;
11965                 let most;
11966                 if (mpsBefore.length < mpsAfter.length) {
11967                   least = mpsBefore.length;
11968                   most = mpsAfter.length;
11969                 } else {
11970                   least = mpsAfter.length;
11971                   most = mpsBefore.length;
11972                 }
11973                 this._isInResult = most === operation2.numMultiPolys && least < most;
11974                 break;
11975               }
11976               case "xor": {
11977                 const diff = Math.abs(mpsBefore.length - mpsAfter.length);
11978                 this._isInResult = diff % 2 === 1;
11979                 break;
11980               }
11981               case "difference": {
11982                 const isJustSubject = (mps) => mps.length === 1 && mps[0].isSubject;
11983                 this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter);
11984                 break;
11985               }
11986               default:
11987                 throw new Error("Unrecognized operation type found ".concat(operation2.type));
11988             }
11989             return this._isInResult;
11990           }
11991         }
11992         class RingIn2 {
11993           constructor(geomRing, poly, isExterior) {
11994             if (!Array.isArray(geomRing) || geomRing.length === 0) {
11995               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
11996             }
11997             this.poly = poly;
11998             this.isExterior = isExterior;
11999             this.segments = [];
12000             if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
12001               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
12002             }
12003             const firstPoint = rounder.round(geomRing[0][0], geomRing[0][1]);
12004             this.bbox = {
12005               ll: {
12006                 x: firstPoint.x,
12007                 y: firstPoint.y
12008               },
12009               ur: {
12010                 x: firstPoint.x,
12011                 y: firstPoint.y
12012               }
12013             };
12014             let prevPoint = firstPoint;
12015             for (let i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) {
12016               if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") {
12017                 throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
12018               }
12019               let point = rounder.round(geomRing[i3][0], geomRing[i3][1]);
12020               if (point.x === prevPoint.x && point.y === prevPoint.y) continue;
12021               this.segments.push(Segment2.fromRing(prevPoint, point, this));
12022               if (point.x < this.bbox.ll.x) this.bbox.ll.x = point.x;
12023               if (point.y < this.bbox.ll.y) this.bbox.ll.y = point.y;
12024               if (point.x > this.bbox.ur.x) this.bbox.ur.x = point.x;
12025               if (point.y > this.bbox.ur.y) this.bbox.ur.y = point.y;
12026               prevPoint = point;
12027             }
12028             if (firstPoint.x !== prevPoint.x || firstPoint.y !== prevPoint.y) {
12029               this.segments.push(Segment2.fromRing(prevPoint, firstPoint, this));
12030             }
12031           }
12032           getSweepEvents() {
12033             const sweepEvents = [];
12034             for (let i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) {
12035               const segment = this.segments[i3];
12036               sweepEvents.push(segment.leftSE);
12037               sweepEvents.push(segment.rightSE);
12038             }
12039             return sweepEvents;
12040           }
12041         }
12042         class PolyIn2 {
12043           constructor(geomPoly, multiPoly) {
12044             if (!Array.isArray(geomPoly)) {
12045               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
12046             }
12047             this.exteriorRing = new RingIn2(geomPoly[0], this, true);
12048             this.bbox = {
12049               ll: {
12050                 x: this.exteriorRing.bbox.ll.x,
12051                 y: this.exteriorRing.bbox.ll.y
12052               },
12053               ur: {
12054                 x: this.exteriorRing.bbox.ur.x,
12055                 y: this.exteriorRing.bbox.ur.y
12056               }
12057             };
12058             this.interiorRings = [];
12059             for (let i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) {
12060               const ring = new RingIn2(geomPoly[i3], this, false);
12061               if (ring.bbox.ll.x < this.bbox.ll.x) this.bbox.ll.x = ring.bbox.ll.x;
12062               if (ring.bbox.ll.y < this.bbox.ll.y) this.bbox.ll.y = ring.bbox.ll.y;
12063               if (ring.bbox.ur.x > this.bbox.ur.x) this.bbox.ur.x = ring.bbox.ur.x;
12064               if (ring.bbox.ur.y > this.bbox.ur.y) this.bbox.ur.y = ring.bbox.ur.y;
12065               this.interiorRings.push(ring);
12066             }
12067             this.multiPoly = multiPoly;
12068           }
12069           getSweepEvents() {
12070             const sweepEvents = this.exteriorRing.getSweepEvents();
12071             for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
12072               const ringSweepEvents = this.interiorRings[i3].getSweepEvents();
12073               for (let j2 = 0, jMax = ringSweepEvents.length; j2 < jMax; j2++) {
12074                 sweepEvents.push(ringSweepEvents[j2]);
12075               }
12076             }
12077             return sweepEvents;
12078           }
12079         }
12080         class MultiPolyIn2 {
12081           constructor(geom, isSubject) {
12082             if (!Array.isArray(geom)) {
12083               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
12084             }
12085             try {
12086               if (typeof geom[0][0][0] === "number") geom = [geom];
12087             } catch (ex) {
12088             }
12089             this.polys = [];
12090             this.bbox = {
12091               ll: {
12092                 x: Number.POSITIVE_INFINITY,
12093                 y: Number.POSITIVE_INFINITY
12094               },
12095               ur: {
12096                 x: Number.NEGATIVE_INFINITY,
12097                 y: Number.NEGATIVE_INFINITY
12098               }
12099             };
12100             for (let i3 = 0, iMax = geom.length; i3 < iMax; i3++) {
12101               const poly = new PolyIn2(geom[i3], this);
12102               if (poly.bbox.ll.x < this.bbox.ll.x) this.bbox.ll.x = poly.bbox.ll.x;
12103               if (poly.bbox.ll.y < this.bbox.ll.y) this.bbox.ll.y = poly.bbox.ll.y;
12104               if (poly.bbox.ur.x > this.bbox.ur.x) this.bbox.ur.x = poly.bbox.ur.x;
12105               if (poly.bbox.ur.y > this.bbox.ur.y) this.bbox.ur.y = poly.bbox.ur.y;
12106               this.polys.push(poly);
12107             }
12108             this.isSubject = isSubject;
12109           }
12110           getSweepEvents() {
12111             const sweepEvents = [];
12112             for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
12113               const polySweepEvents = this.polys[i3].getSweepEvents();
12114               for (let j2 = 0, jMax = polySweepEvents.length; j2 < jMax; j2++) {
12115                 sweepEvents.push(polySweepEvents[j2]);
12116               }
12117             }
12118             return sweepEvents;
12119           }
12120         }
12121         class RingOut2 {
12122           /* Given the segments from the sweep line pass, compute & return a series
12123            * of closed rings from all the segments marked to be part of the result */
12124           static factory(allSegments) {
12125             const ringsOut = [];
12126             for (let i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) {
12127               const segment = allSegments[i3];
12128               if (!segment.isInResult() || segment.ringOut) continue;
12129               let prevEvent = null;
12130               let event = segment.leftSE;
12131               let nextEvent = segment.rightSE;
12132               const events = [event];
12133               const startingPoint = event.point;
12134               const intersectionLEs = [];
12135               while (true) {
12136                 prevEvent = event;
12137                 event = nextEvent;
12138                 events.push(event);
12139                 if (event.point === startingPoint) break;
12140                 while (true) {
12141                   const availableLEs = event.getAvailableLinkedEvents();
12142                   if (availableLEs.length === 0) {
12143                     const firstPt = events[0].point;
12144                     const lastPt = events[events.length - 1].point;
12145                     throw new Error("Unable to complete output ring starting at [".concat(firstPt.x, ",") + " ".concat(firstPt.y, "]. Last matching segment found ends at") + " [".concat(lastPt.x, ", ").concat(lastPt.y, "]."));
12146                   }
12147                   if (availableLEs.length === 1) {
12148                     nextEvent = availableLEs[0].otherSE;
12149                     break;
12150                   }
12151                   let indexLE = null;
12152                   for (let j2 = 0, jMax = intersectionLEs.length; j2 < jMax; j2++) {
12153                     if (intersectionLEs[j2].point === event.point) {
12154                       indexLE = j2;
12155                       break;
12156                     }
12157                   }
12158                   if (indexLE !== null) {
12159                     const intersectionLE = intersectionLEs.splice(indexLE)[0];
12160                     const ringEvents = events.splice(intersectionLE.index);
12161                     ringEvents.unshift(ringEvents[0].otherSE);
12162                     ringsOut.push(new RingOut2(ringEvents.reverse()));
12163                     continue;
12164                   }
12165                   intersectionLEs.push({
12166                     index: events.length,
12167                     point: event.point
12168                   });
12169                   const comparator = event.getLeftmostComparator(prevEvent);
12170                   nextEvent = availableLEs.sort(comparator)[0].otherSE;
12171                   break;
12172                 }
12173               }
12174               ringsOut.push(new RingOut2(events));
12175             }
12176             return ringsOut;
12177           }
12178           constructor(events) {
12179             this.events = events;
12180             for (let i3 = 0, iMax = events.length; i3 < iMax; i3++) {
12181               events[i3].segment.ringOut = this;
12182             }
12183             this.poly = null;
12184           }
12185           getGeom() {
12186             let prevPt = this.events[0].point;
12187             const points = [prevPt];
12188             for (let i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) {
12189               const pt3 = this.events[i3].point;
12190               const nextPt2 = this.events[i3 + 1].point;
12191               if (compareVectorAngles(pt3, prevPt, nextPt2) === 0) continue;
12192               points.push(pt3);
12193               prevPt = pt3;
12194             }
12195             if (points.length === 1) return null;
12196             const pt2 = points[0];
12197             const nextPt = points[1];
12198             if (compareVectorAngles(pt2, prevPt, nextPt) === 0) points.shift();
12199             points.push(points[0]);
12200             const step = this.isExteriorRing() ? 1 : -1;
12201             const iStart = this.isExteriorRing() ? 0 : points.length - 1;
12202             const iEnd = this.isExteriorRing() ? points.length : -1;
12203             const orderedPoints = [];
12204             for (let i3 = iStart; i3 != iEnd; i3 += step) orderedPoints.push([points[i3].x, points[i3].y]);
12205             return orderedPoints;
12206           }
12207           isExteriorRing() {
12208             if (this._isExteriorRing === void 0) {
12209               const enclosing = this.enclosingRing();
12210               this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true;
12211             }
12212             return this._isExteriorRing;
12213           }
12214           enclosingRing() {
12215             if (this._enclosingRing === void 0) {
12216               this._enclosingRing = this._calcEnclosingRing();
12217             }
12218             return this._enclosingRing;
12219           }
12220           /* Returns the ring that encloses this one, if any */
12221           _calcEnclosingRing() {
12222             let leftMostEvt = this.events[0];
12223             for (let i3 = 1, iMax = this.events.length; i3 < iMax; i3++) {
12224               const evt = this.events[i3];
12225               if (SweepEvent2.compare(leftMostEvt, evt) > 0) leftMostEvt = evt;
12226             }
12227             let prevSeg = leftMostEvt.segment.prevInResult();
12228             let prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
12229             while (true) {
12230               if (!prevSeg) return null;
12231               if (!prevPrevSeg) return prevSeg.ringOut;
12232               if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
12233                 if (prevPrevSeg.ringOut.enclosingRing() !== prevSeg.ringOut) {
12234                   return prevSeg.ringOut;
12235                 } else return prevSeg.ringOut.enclosingRing();
12236               }
12237               prevSeg = prevPrevSeg.prevInResult();
12238               prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
12239             }
12240           }
12241         }
12242         class PolyOut2 {
12243           constructor(exteriorRing) {
12244             this.exteriorRing = exteriorRing;
12245             exteriorRing.poly = this;
12246             this.interiorRings = [];
12247           }
12248           addInterior(ring) {
12249             this.interiorRings.push(ring);
12250             ring.poly = this;
12251           }
12252           getGeom() {
12253             const geom = [this.exteriorRing.getGeom()];
12254             if (geom[0] === null) return null;
12255             for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
12256               const ringGeom = this.interiorRings[i3].getGeom();
12257               if (ringGeom === null) continue;
12258               geom.push(ringGeom);
12259             }
12260             return geom;
12261           }
12262         }
12263         class MultiPolyOut2 {
12264           constructor(rings) {
12265             this.rings = rings;
12266             this.polys = this._composePolys(rings);
12267           }
12268           getGeom() {
12269             const geom = [];
12270             for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
12271               const polyGeom = this.polys[i3].getGeom();
12272               if (polyGeom === null) continue;
12273               geom.push(polyGeom);
12274             }
12275             return geom;
12276           }
12277           _composePolys(rings) {
12278             const polys = [];
12279             for (let i3 = 0, iMax = rings.length; i3 < iMax; i3++) {
12280               const ring = rings[i3];
12281               if (ring.poly) continue;
12282               if (ring.isExteriorRing()) polys.push(new PolyOut2(ring));
12283               else {
12284                 const enclosingRing = ring.enclosingRing();
12285                 if (!enclosingRing.poly) polys.push(new PolyOut2(enclosingRing));
12286                 enclosingRing.poly.addInterior(ring);
12287               }
12288             }
12289             return polys;
12290           }
12291         }
12292         class SweepLine2 {
12293           constructor(queue) {
12294             let comparator = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Segment2.compare;
12295             this.queue = queue;
12296             this.tree = new Tree(comparator);
12297             this.segments = [];
12298           }
12299           process(event) {
12300             const segment = event.segment;
12301             const newEvents = [];
12302             if (event.consumedBy) {
12303               if (event.isLeft) this.queue.remove(event.otherSE);
12304               else this.tree.remove(segment);
12305               return newEvents;
12306             }
12307             const node = event.isLeft ? this.tree.add(segment) : this.tree.find(segment);
12308             if (!node) throw new Error("Unable to find segment #".concat(segment.id, " ") + "[".concat(segment.leftSE.point.x, ", ").concat(segment.leftSE.point.y, "] -> ") + "[".concat(segment.rightSE.point.x, ", ").concat(segment.rightSE.point.y, "] ") + "in SweepLine tree.");
12309             let prevNode = node;
12310             let nextNode = node;
12311             let prevSeg = void 0;
12312             let nextSeg = void 0;
12313             while (prevSeg === void 0) {
12314               prevNode = this.tree.prev(prevNode);
12315               if (prevNode === null) prevSeg = null;
12316               else if (prevNode.key.consumedBy === void 0) prevSeg = prevNode.key;
12317             }
12318             while (nextSeg === void 0) {
12319               nextNode = this.tree.next(nextNode);
12320               if (nextNode === null) nextSeg = null;
12321               else if (nextNode.key.consumedBy === void 0) nextSeg = nextNode.key;
12322             }
12323             if (event.isLeft) {
12324               let prevMySplitter = null;
12325               if (prevSeg) {
12326                 const prevInter = prevSeg.getIntersection(segment);
12327                 if (prevInter !== null) {
12328                   if (!segment.isAnEndpoint(prevInter)) prevMySplitter = prevInter;
12329                   if (!prevSeg.isAnEndpoint(prevInter)) {
12330                     const newEventsFromSplit = this._splitSafely(prevSeg, prevInter);
12331                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
12332                       newEvents.push(newEventsFromSplit[i3]);
12333                     }
12334                   }
12335                 }
12336               }
12337               let nextMySplitter = null;
12338               if (nextSeg) {
12339                 const nextInter = nextSeg.getIntersection(segment);
12340                 if (nextInter !== null) {
12341                   if (!segment.isAnEndpoint(nextInter)) nextMySplitter = nextInter;
12342                   if (!nextSeg.isAnEndpoint(nextInter)) {
12343                     const newEventsFromSplit = this._splitSafely(nextSeg, nextInter);
12344                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
12345                       newEvents.push(newEventsFromSplit[i3]);
12346                     }
12347                   }
12348                 }
12349               }
12350               if (prevMySplitter !== null || nextMySplitter !== null) {
12351                 let mySplitter = null;
12352                 if (prevMySplitter === null) mySplitter = nextMySplitter;
12353                 else if (nextMySplitter === null) mySplitter = prevMySplitter;
12354                 else {
12355                   const cmpSplitters = SweepEvent2.comparePoints(prevMySplitter, nextMySplitter);
12356                   mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter;
12357                 }
12358                 this.queue.remove(segment.rightSE);
12359                 newEvents.push(segment.rightSE);
12360                 const newEventsFromSplit = segment.split(mySplitter);
12361                 for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
12362                   newEvents.push(newEventsFromSplit[i3]);
12363                 }
12364               }
12365               if (newEvents.length > 0) {
12366                 this.tree.remove(segment);
12367                 newEvents.push(event);
12368               } else {
12369                 this.segments.push(segment);
12370                 segment.prev = prevSeg;
12371               }
12372             } else {
12373               if (prevSeg && nextSeg) {
12374                 const inter = prevSeg.getIntersection(nextSeg);
12375                 if (inter !== null) {
12376                   if (!prevSeg.isAnEndpoint(inter)) {
12377                     const newEventsFromSplit = this._splitSafely(prevSeg, inter);
12378                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
12379                       newEvents.push(newEventsFromSplit[i3]);
12380                     }
12381                   }
12382                   if (!nextSeg.isAnEndpoint(inter)) {
12383                     const newEventsFromSplit = this._splitSafely(nextSeg, inter);
12384                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
12385                       newEvents.push(newEventsFromSplit[i3]);
12386                     }
12387                   }
12388                 }
12389               }
12390               this.tree.remove(segment);
12391             }
12392             return newEvents;
12393           }
12394           /* Safely split a segment that is currently in the datastructures
12395            * IE - a segment other than the one that is currently being processed. */
12396           _splitSafely(seg, pt2) {
12397             this.tree.remove(seg);
12398             const rightSE = seg.rightSE;
12399             this.queue.remove(rightSE);
12400             const newEvents = seg.split(pt2);
12401             newEvents.push(rightSE);
12402             if (seg.consumedBy === void 0) this.tree.add(seg);
12403             return newEvents;
12404           }
12405         }
12406         const POLYGON_CLIPPING_MAX_QUEUE_SIZE = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE || 1e6;
12407         const POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS || 1e6;
12408         class Operation2 {
12409           run(type2, geom, moreGeoms) {
12410             operation2.type = type2;
12411             rounder.reset();
12412             const multipolys = [new MultiPolyIn2(geom, true)];
12413             for (let i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) {
12414               multipolys.push(new MultiPolyIn2(moreGeoms[i3], false));
12415             }
12416             operation2.numMultiPolys = multipolys.length;
12417             if (operation2.type === "difference") {
12418               const subject = multipolys[0];
12419               let i3 = 1;
12420               while (i3 < multipolys.length) {
12421                 if (getBboxOverlap2(multipolys[i3].bbox, subject.bbox) !== null) i3++;
12422                 else multipolys.splice(i3, 1);
12423               }
12424             }
12425             if (operation2.type === "intersection") {
12426               for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
12427                 const mpA = multipolys[i3];
12428                 for (let j2 = i3 + 1, jMax = multipolys.length; j2 < jMax; j2++) {
12429                   if (getBboxOverlap2(mpA.bbox, multipolys[j2].bbox) === null) return [];
12430                 }
12431               }
12432             }
12433             const queue = new Tree(SweepEvent2.compare);
12434             for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
12435               const sweepEvents = multipolys[i3].getSweepEvents();
12436               for (let j2 = 0, jMax = sweepEvents.length; j2 < jMax; j2++) {
12437                 queue.insert(sweepEvents[j2]);
12438                 if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
12439                   throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).");
12440                 }
12441               }
12442             }
12443             const sweepLine = new SweepLine2(queue);
12444             let prevQueueSize = queue.size;
12445             let node = queue.pop();
12446             while (node) {
12447               const evt = node.key;
12448               if (queue.size === prevQueueSize) {
12449                 const seg = evt.segment;
12450                 throw new Error("Unable to pop() ".concat(evt.isLeft ? "left" : "right", " SweepEvent ") + "[".concat(evt.point.x, ", ").concat(evt.point.y, "] from segment #").concat(seg.id, " ") + "[".concat(seg.leftSE.point.x, ", ").concat(seg.leftSE.point.y, "] -> ") + "[".concat(seg.rightSE.point.x, ", ").concat(seg.rightSE.point.y, "] from queue."));
12451               }
12452               if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
12453                 throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");
12454               }
12455               if (sweepLine.segments.length > POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS) {
12456                 throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");
12457               }
12458               const newEvents = sweepLine.process(evt);
12459               for (let i3 = 0, iMax = newEvents.length; i3 < iMax; i3++) {
12460                 const evt2 = newEvents[i3];
12461                 if (evt2.consumedBy === void 0) queue.insert(evt2);
12462               }
12463               prevQueueSize = queue.size;
12464               node = queue.pop();
12465             }
12466             rounder.reset();
12467             const ringsOut = RingOut2.factory(sweepLine.segments);
12468             const result = new MultiPolyOut2(ringsOut);
12469             return result.getGeom();
12470           }
12471         }
12472         const operation2 = new Operation2();
12473         const union2 = function(geom) {
12474           for (var _len = arguments.length, moreGeoms = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
12475             moreGeoms[_key - 1] = arguments[_key];
12476           }
12477           return operation2.run("union", geom, moreGeoms);
12478         };
12479         const intersection2 = function(geom) {
12480           for (var _len2 = arguments.length, moreGeoms = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
12481             moreGeoms[_key2 - 1] = arguments[_key2];
12482           }
12483           return operation2.run("intersection", geom, moreGeoms);
12484         };
12485         const xor = function(geom) {
12486           for (var _len3 = arguments.length, moreGeoms = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
12487             moreGeoms[_key3 - 1] = arguments[_key3];
12488           }
12489           return operation2.run("xor", geom, moreGeoms);
12490         };
12491         const difference2 = function(subjectGeom) {
12492           for (var _len4 = arguments.length, clippingGeoms = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
12493             clippingGeoms[_key4 - 1] = arguments[_key4];
12494           }
12495           return operation2.run("difference", subjectGeom, clippingGeoms);
12496         };
12497         var index = {
12498           union: union2,
12499           intersection: intersection2,
12500           xor,
12501           difference: difference2
12502         };
12503         return index;
12504       });
12505     }
12506   });
12507
12508   // node_modules/whatwg-fetch/fetch.js
12509   var g = typeof globalThis !== "undefined" && globalThis || typeof self !== "undefined" && self || // eslint-disable-next-line no-undef
12510   typeof global !== "undefined" && global || {};
12511   var support = {
12512     searchParams: "URLSearchParams" in g,
12513     iterable: "Symbol" in g && "iterator" in Symbol,
12514     blob: "FileReader" in g && "Blob" in g && function() {
12515       try {
12516         new Blob();
12517         return true;
12518       } catch (e3) {
12519         return false;
12520       }
12521     }(),
12522     formData: "FormData" in g,
12523     arrayBuffer: "ArrayBuffer" in g
12524   };
12525   function isDataView(obj) {
12526     return obj && DataView.prototype.isPrototypeOf(obj);
12527   }
12528   if (support.arrayBuffer) {
12529     viewClasses = [
12530       "[object Int8Array]",
12531       "[object Uint8Array]",
12532       "[object Uint8ClampedArray]",
12533       "[object Int16Array]",
12534       "[object Uint16Array]",
12535       "[object Int32Array]",
12536       "[object Uint32Array]",
12537       "[object Float32Array]",
12538       "[object Float64Array]"
12539     ];
12540     isArrayBufferView = ArrayBuffer.isView || function(obj) {
12541       return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
12542     };
12543   }
12544   var viewClasses;
12545   var isArrayBufferView;
12546   function normalizeName(name) {
12547     if (typeof name !== "string") {
12548       name = String(name);
12549     }
12550     if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
12551       throw new TypeError('Invalid character in header field name: "' + name + '"');
12552     }
12553     return name.toLowerCase();
12554   }
12555   function normalizeValue(value) {
12556     if (typeof value !== "string") {
12557       value = String(value);
12558     }
12559     return value;
12560   }
12561   function iteratorFor(items) {
12562     var iterator = {
12563       next: function() {
12564         var value = items.shift();
12565         return { done: value === void 0, value };
12566       }
12567     };
12568     if (support.iterable) {
12569       iterator[Symbol.iterator] = function() {
12570         return iterator;
12571       };
12572     }
12573     return iterator;
12574   }
12575   function Headers(headers) {
12576     this.map = {};
12577     if (headers instanceof Headers) {
12578       headers.forEach(function(value, name) {
12579         this.append(name, value);
12580       }, this);
12581     } else if (Array.isArray(headers)) {
12582       headers.forEach(function(header) {
12583         if (header.length != 2) {
12584           throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + header.length);
12585         }
12586         this.append(header[0], header[1]);
12587       }, this);
12588     } else if (headers) {
12589       Object.getOwnPropertyNames(headers).forEach(function(name) {
12590         this.append(name, headers[name]);
12591       }, this);
12592     }
12593   }
12594   Headers.prototype.append = function(name, value) {
12595     name = normalizeName(name);
12596     value = normalizeValue(value);
12597     var oldValue = this.map[name];
12598     this.map[name] = oldValue ? oldValue + ", " + value : value;
12599   };
12600   Headers.prototype["delete"] = function(name) {
12601     delete this.map[normalizeName(name)];
12602   };
12603   Headers.prototype.get = function(name) {
12604     name = normalizeName(name);
12605     return this.has(name) ? this.map[name] : null;
12606   };
12607   Headers.prototype.has = function(name) {
12608     return this.map.hasOwnProperty(normalizeName(name));
12609   };
12610   Headers.prototype.set = function(name, value) {
12611     this.map[normalizeName(name)] = normalizeValue(value);
12612   };
12613   Headers.prototype.forEach = function(callback, thisArg) {
12614     for (var name in this.map) {
12615       if (this.map.hasOwnProperty(name)) {
12616         callback.call(thisArg, this.map[name], name, this);
12617       }
12618     }
12619   };
12620   Headers.prototype.keys = function() {
12621     var items = [];
12622     this.forEach(function(value, name) {
12623       items.push(name);
12624     });
12625     return iteratorFor(items);
12626   };
12627   Headers.prototype.values = function() {
12628     var items = [];
12629     this.forEach(function(value) {
12630       items.push(value);
12631     });
12632     return iteratorFor(items);
12633   };
12634   Headers.prototype.entries = function() {
12635     var items = [];
12636     this.forEach(function(value, name) {
12637       items.push([name, value]);
12638     });
12639     return iteratorFor(items);
12640   };
12641   if (support.iterable) {
12642     Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
12643   }
12644   function consumed(body) {
12645     if (body._noBody) return;
12646     if (body.bodyUsed) {
12647       return Promise.reject(new TypeError("Already read"));
12648     }
12649     body.bodyUsed = true;
12650   }
12651   function fileReaderReady(reader) {
12652     return new Promise(function(resolve, reject) {
12653       reader.onload = function() {
12654         resolve(reader.result);
12655       };
12656       reader.onerror = function() {
12657         reject(reader.error);
12658       };
12659     });
12660   }
12661   function readBlobAsArrayBuffer(blob) {
12662     var reader = new FileReader();
12663     var promise = fileReaderReady(reader);
12664     reader.readAsArrayBuffer(blob);
12665     return promise;
12666   }
12667   function readBlobAsText(blob) {
12668     var reader = new FileReader();
12669     var promise = fileReaderReady(reader);
12670     var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
12671     var encoding = match ? match[1] : "utf-8";
12672     reader.readAsText(blob, encoding);
12673     return promise;
12674   }
12675   function readArrayBufferAsText(buf) {
12676     var view = new Uint8Array(buf);
12677     var chars = new Array(view.length);
12678     for (var i3 = 0; i3 < view.length; i3++) {
12679       chars[i3] = String.fromCharCode(view[i3]);
12680     }
12681     return chars.join("");
12682   }
12683   function bufferClone(buf) {
12684     if (buf.slice) {
12685       return buf.slice(0);
12686     } else {
12687       var view = new Uint8Array(buf.byteLength);
12688       view.set(new Uint8Array(buf));
12689       return view.buffer;
12690     }
12691   }
12692   function Body() {
12693     this.bodyUsed = false;
12694     this._initBody = function(body) {
12695       this.bodyUsed = this.bodyUsed;
12696       this._bodyInit = body;
12697       if (!body) {
12698         this._noBody = true;
12699         this._bodyText = "";
12700       } else if (typeof body === "string") {
12701         this._bodyText = body;
12702       } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
12703         this._bodyBlob = body;
12704       } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
12705         this._bodyFormData = body;
12706       } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
12707         this._bodyText = body.toString();
12708       } else if (support.arrayBuffer && support.blob && isDataView(body)) {
12709         this._bodyArrayBuffer = bufferClone(body.buffer);
12710         this._bodyInit = new Blob([this._bodyArrayBuffer]);
12711       } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
12712         this._bodyArrayBuffer = bufferClone(body);
12713       } else {
12714         this._bodyText = body = Object.prototype.toString.call(body);
12715       }
12716       if (!this.headers.get("content-type")) {
12717         if (typeof body === "string") {
12718           this.headers.set("content-type", "text/plain;charset=UTF-8");
12719         } else if (this._bodyBlob && this._bodyBlob.type) {
12720           this.headers.set("content-type", this._bodyBlob.type);
12721         } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
12722           this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
12723         }
12724       }
12725     };
12726     if (support.blob) {
12727       this.blob = function() {
12728         var rejected = consumed(this);
12729         if (rejected) {
12730           return rejected;
12731         }
12732         if (this._bodyBlob) {
12733           return Promise.resolve(this._bodyBlob);
12734         } else if (this._bodyArrayBuffer) {
12735           return Promise.resolve(new Blob([this._bodyArrayBuffer]));
12736         } else if (this._bodyFormData) {
12737           throw new Error("could not read FormData body as blob");
12738         } else {
12739           return Promise.resolve(new Blob([this._bodyText]));
12740         }
12741       };
12742     }
12743     this.arrayBuffer = function() {
12744       if (this._bodyArrayBuffer) {
12745         var isConsumed = consumed(this);
12746         if (isConsumed) {
12747           return isConsumed;
12748         } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
12749           return Promise.resolve(
12750             this._bodyArrayBuffer.buffer.slice(
12751               this._bodyArrayBuffer.byteOffset,
12752               this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
12753             )
12754           );
12755         } else {
12756           return Promise.resolve(this._bodyArrayBuffer);
12757         }
12758       } else if (support.blob) {
12759         return this.blob().then(readBlobAsArrayBuffer);
12760       } else {
12761         throw new Error("could not read as ArrayBuffer");
12762       }
12763     };
12764     this.text = function() {
12765       var rejected = consumed(this);
12766       if (rejected) {
12767         return rejected;
12768       }
12769       if (this._bodyBlob) {
12770         return readBlobAsText(this._bodyBlob);
12771       } else if (this._bodyArrayBuffer) {
12772         return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
12773       } else if (this._bodyFormData) {
12774         throw new Error("could not read FormData body as text");
12775       } else {
12776         return Promise.resolve(this._bodyText);
12777       }
12778     };
12779     if (support.formData) {
12780       this.formData = function() {
12781         return this.text().then(decode);
12782       };
12783     }
12784     this.json = function() {
12785       return this.text().then(JSON.parse);
12786     };
12787     return this;
12788   }
12789   var methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
12790   function normalizeMethod(method) {
12791     var upcased = method.toUpperCase();
12792     return methods.indexOf(upcased) > -1 ? upcased : method;
12793   }
12794   function Request(input, options2) {
12795     if (!(this instanceof Request)) {
12796       throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
12797     }
12798     options2 = options2 || {};
12799     var body = options2.body;
12800     if (input instanceof Request) {
12801       if (input.bodyUsed) {
12802         throw new TypeError("Already read");
12803       }
12804       this.url = input.url;
12805       this.credentials = input.credentials;
12806       if (!options2.headers) {
12807         this.headers = new Headers(input.headers);
12808       }
12809       this.method = input.method;
12810       this.mode = input.mode;
12811       this.signal = input.signal;
12812       if (!body && input._bodyInit != null) {
12813         body = input._bodyInit;
12814         input.bodyUsed = true;
12815       }
12816     } else {
12817       this.url = String(input);
12818     }
12819     this.credentials = options2.credentials || this.credentials || "same-origin";
12820     if (options2.headers || !this.headers) {
12821       this.headers = new Headers(options2.headers);
12822     }
12823     this.method = normalizeMethod(options2.method || this.method || "GET");
12824     this.mode = options2.mode || this.mode || null;
12825     this.signal = options2.signal || this.signal || function() {
12826       if ("AbortController" in g) {
12827         var ctrl = new AbortController();
12828         return ctrl.signal;
12829       }
12830     }();
12831     this.referrer = null;
12832     if ((this.method === "GET" || this.method === "HEAD") && body) {
12833       throw new TypeError("Body not allowed for GET or HEAD requests");
12834     }
12835     this._initBody(body);
12836     if (this.method === "GET" || this.method === "HEAD") {
12837       if (options2.cache === "no-store" || options2.cache === "no-cache") {
12838         var reParamSearch = /([?&])_=[^&]*/;
12839         if (reParamSearch.test(this.url)) {
12840           this.url = this.url.replace(reParamSearch, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
12841         } else {
12842           var reQueryString = /\?/;
12843           this.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
12844         }
12845       }
12846     }
12847   }
12848   Request.prototype.clone = function() {
12849     return new Request(this, { body: this._bodyInit });
12850   };
12851   function decode(body) {
12852     var form = new FormData();
12853     body.trim().split("&").forEach(function(bytes) {
12854       if (bytes) {
12855         var split = bytes.split("=");
12856         var name = split.shift().replace(/\+/g, " ");
12857         var value = split.join("=").replace(/\+/g, " ");
12858         form.append(decodeURIComponent(name), decodeURIComponent(value));
12859       }
12860     });
12861     return form;
12862   }
12863   function parseHeaders(rawHeaders) {
12864     var headers = new Headers();
12865     var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
12866     preProcessedHeaders.split("\r").map(function(header) {
12867       return header.indexOf("\n") === 0 ? header.substr(1, header.length) : header;
12868     }).forEach(function(line) {
12869       var parts = line.split(":");
12870       var key = parts.shift().trim();
12871       if (key) {
12872         var value = parts.join(":").trim();
12873         try {
12874           headers.append(key, value);
12875         } catch (error) {
12876           console.warn("Response " + error.message);
12877         }
12878       }
12879     });
12880     return headers;
12881   }
12882   Body.call(Request.prototype);
12883   function Response(bodyInit, options2) {
12884     if (!(this instanceof Response)) {
12885       throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
12886     }
12887     if (!options2) {
12888       options2 = {};
12889     }
12890     this.type = "default";
12891     this.status = options2.status === void 0 ? 200 : options2.status;
12892     if (this.status < 200 || this.status > 599) {
12893       throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
12894     }
12895     this.ok = this.status >= 200 && this.status < 300;
12896     this.statusText = options2.statusText === void 0 ? "" : "" + options2.statusText;
12897     this.headers = new Headers(options2.headers);
12898     this.url = options2.url || "";
12899     this._initBody(bodyInit);
12900   }
12901   Body.call(Response.prototype);
12902   Response.prototype.clone = function() {
12903     return new Response(this._bodyInit, {
12904       status: this.status,
12905       statusText: this.statusText,
12906       headers: new Headers(this.headers),
12907       url: this.url
12908     });
12909   };
12910   Response.error = function() {
12911     var response = new Response(null, { status: 200, statusText: "" });
12912     response.ok = false;
12913     response.status = 0;
12914     response.type = "error";
12915     return response;
12916   };
12917   var redirectStatuses = [301, 302, 303, 307, 308];
12918   Response.redirect = function(url, status) {
12919     if (redirectStatuses.indexOf(status) === -1) {
12920       throw new RangeError("Invalid status code");
12921     }
12922     return new Response(null, { status, headers: { location: url } });
12923   };
12924   var DOMException2 = g.DOMException;
12925   try {
12926     new DOMException2();
12927   } catch (err) {
12928     DOMException2 = function(message, name) {
12929       this.message = message;
12930       this.name = name;
12931       var error = Error(message);
12932       this.stack = error.stack;
12933     };
12934     DOMException2.prototype = Object.create(Error.prototype);
12935     DOMException2.prototype.constructor = DOMException2;
12936   }
12937   function fetch2(input, init2) {
12938     return new Promise(function(resolve, reject) {
12939       var request3 = new Request(input, init2);
12940       if (request3.signal && request3.signal.aborted) {
12941         return reject(new DOMException2("Aborted", "AbortError"));
12942       }
12943       var xhr = new XMLHttpRequest();
12944       function abortXhr() {
12945         xhr.abort();
12946       }
12947       xhr.onload = function() {
12948         var options2 = {
12949           statusText: xhr.statusText,
12950           headers: parseHeaders(xhr.getAllResponseHeaders() || "")
12951         };
12952         if (request3.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
12953           options2.status = 200;
12954         } else {
12955           options2.status = xhr.status;
12956         }
12957         options2.url = "responseURL" in xhr ? xhr.responseURL : options2.headers.get("X-Request-URL");
12958         var body = "response" in xhr ? xhr.response : xhr.responseText;
12959         setTimeout(function() {
12960           resolve(new Response(body, options2));
12961         }, 0);
12962       };
12963       xhr.onerror = function() {
12964         setTimeout(function() {
12965           reject(new TypeError("Network request failed"));
12966         }, 0);
12967       };
12968       xhr.ontimeout = function() {
12969         setTimeout(function() {
12970           reject(new TypeError("Network request timed out"));
12971         }, 0);
12972       };
12973       xhr.onabort = function() {
12974         setTimeout(function() {
12975           reject(new DOMException2("Aborted", "AbortError"));
12976         }, 0);
12977       };
12978       function fixUrl(url) {
12979         try {
12980           return url === "" && g.location.href ? g.location.href : url;
12981         } catch (e3) {
12982           return url;
12983         }
12984       }
12985       xhr.open(request3.method, fixUrl(request3.url), true);
12986       if (request3.credentials === "include") {
12987         xhr.withCredentials = true;
12988       } else if (request3.credentials === "omit") {
12989         xhr.withCredentials = false;
12990       }
12991       if ("responseType" in xhr) {
12992         if (support.blob) {
12993           xhr.responseType = "blob";
12994         } else if (support.arrayBuffer) {
12995           xhr.responseType = "arraybuffer";
12996         }
12997       }
12998       if (init2 && typeof init2.headers === "object" && !(init2.headers instanceof Headers || g.Headers && init2.headers instanceof g.Headers)) {
12999         var names = [];
13000         Object.getOwnPropertyNames(init2.headers).forEach(function(name) {
13001           names.push(normalizeName(name));
13002           xhr.setRequestHeader(name, normalizeValue(init2.headers[name]));
13003         });
13004         request3.headers.forEach(function(value, name) {
13005           if (names.indexOf(name) === -1) {
13006             xhr.setRequestHeader(name, value);
13007           }
13008         });
13009       } else {
13010         request3.headers.forEach(function(value, name) {
13011           xhr.setRequestHeader(name, value);
13012         });
13013       }
13014       if (request3.signal) {
13015         request3.signal.addEventListener("abort", abortXhr);
13016         xhr.onreadystatechange = function() {
13017           if (xhr.readyState === 4) {
13018             request3.signal.removeEventListener("abort", abortXhr);
13019           }
13020         };
13021       }
13022       xhr.send(typeof request3._bodyInit === "undefined" ? null : request3._bodyInit);
13023     });
13024   }
13025   fetch2.polyfill = true;
13026   if (!g.fetch) {
13027     g.fetch = fetch2;
13028     g.Headers = Headers;
13029     g.Request = Request;
13030     g.Response = Response;
13031   }
13032
13033   // node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js
13034   (function(factory) {
13035     typeof define === "function" && define.amd ? define(factory) : factory();
13036   })(function() {
13037     "use strict";
13038     function _arrayLikeToArray(r2, a2) {
13039       (null == a2 || a2 > r2.length) && (a2 = r2.length);
13040       for (var e3 = 0, n3 = Array(a2); e3 < a2; e3++) n3[e3] = r2[e3];
13041       return n3;
13042     }
13043     function _assertThisInitialized(e3) {
13044       if (void 0 === e3) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
13045       return e3;
13046     }
13047     function _callSuper(t2, o2, e3) {
13048       return o2 = _getPrototypeOf(o2), _possibleConstructorReturn(t2, _isNativeReflectConstruct() ? Reflect.construct(o2, e3 || [], _getPrototypeOf(t2).constructor) : o2.apply(t2, e3));
13049     }
13050     function _classCallCheck(a2, n3) {
13051       if (!(a2 instanceof n3)) throw new TypeError("Cannot call a class as a function");
13052     }
13053     function _defineProperties(e3, r2) {
13054       for (var t2 = 0; t2 < r2.length; t2++) {
13055         var o2 = r2[t2];
13056         o2.enumerable = o2.enumerable || false, o2.configurable = true, "value" in o2 && (o2.writable = true), Object.defineProperty(e3, _toPropertyKey(o2.key), o2);
13057       }
13058     }
13059     function _createClass(e3, r2, t2) {
13060       return r2 && _defineProperties(e3.prototype, r2), t2 && _defineProperties(e3, t2), Object.defineProperty(e3, "prototype", {
13061         writable: false
13062       }), e3;
13063     }
13064     function _createForOfIteratorHelper(r2, e3) {
13065       var t2 = "undefined" != typeof Symbol && r2[Symbol.iterator] || r2["@@iterator"];
13066       if (!t2) {
13067         if (Array.isArray(r2) || (t2 = _unsupportedIterableToArray(r2)) || e3 && r2 && "number" == typeof r2.length) {
13068           t2 && (r2 = t2);
13069           var n3 = 0, F2 = function() {
13070           };
13071           return {
13072             s: F2,
13073             n: function() {
13074               return n3 >= r2.length ? {
13075                 done: true
13076               } : {
13077                 done: false,
13078                 value: r2[n3++]
13079               };
13080             },
13081             e: function(r3) {
13082               throw r3;
13083             },
13084             f: F2
13085           };
13086         }
13087         throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
13088       }
13089       var o2, a2 = true, u2 = false;
13090       return {
13091         s: function() {
13092           t2 = t2.call(r2);
13093         },
13094         n: function() {
13095           var r3 = t2.next();
13096           return a2 = r3.done, r3;
13097         },
13098         e: function(r3) {
13099           u2 = true, o2 = r3;
13100         },
13101         f: function() {
13102           try {
13103             a2 || null == t2.return || t2.return();
13104           } finally {
13105             if (u2) throw o2;
13106           }
13107         }
13108       };
13109     }
13110     function _get() {
13111       return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function(e3, t2, r2) {
13112         var p2 = _superPropBase(e3, t2);
13113         if (p2) {
13114           var n3 = Object.getOwnPropertyDescriptor(p2, t2);
13115           return n3.get ? n3.get.call(arguments.length < 3 ? e3 : r2) : n3.value;
13116         }
13117       }, _get.apply(null, arguments);
13118     }
13119     function _getPrototypeOf(t2) {
13120       return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(t3) {
13121         return t3.__proto__ || Object.getPrototypeOf(t3);
13122       }, _getPrototypeOf(t2);
13123     }
13124     function _inherits(t2, e3) {
13125       if ("function" != typeof e3 && null !== e3) throw new TypeError("Super expression must either be null or a function");
13126       t2.prototype = Object.create(e3 && e3.prototype, {
13127         constructor: {
13128           value: t2,
13129           writable: true,
13130           configurable: true
13131         }
13132       }), Object.defineProperty(t2, "prototype", {
13133         writable: false
13134       }), e3 && _setPrototypeOf(t2, e3);
13135     }
13136     function _isNativeReflectConstruct() {
13137       try {
13138         var t2 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
13139         }));
13140       } catch (t3) {
13141       }
13142       return (_isNativeReflectConstruct = function() {
13143         return !!t2;
13144       })();
13145     }
13146     function _possibleConstructorReturn(t2, e3) {
13147       if (e3 && ("object" == typeof e3 || "function" == typeof e3)) return e3;
13148       if (void 0 !== e3) throw new TypeError("Derived constructors may only return object or undefined");
13149       return _assertThisInitialized(t2);
13150     }
13151     function _setPrototypeOf(t2, e3) {
13152       return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(t3, e4) {
13153         return t3.__proto__ = e4, t3;
13154       }, _setPrototypeOf(t2, e3);
13155     }
13156     function _superPropBase(t2, o2) {
13157       for (; !{}.hasOwnProperty.call(t2, o2) && null !== (t2 = _getPrototypeOf(t2)); ) ;
13158       return t2;
13159     }
13160     function _superPropGet(t2, o2, e3, r2) {
13161       var p2 = _get(_getPrototypeOf(1 & r2 ? t2.prototype : t2), o2, e3);
13162       return 2 & r2 && "function" == typeof p2 ? function(t3) {
13163         return p2.apply(e3, t3);
13164       } : p2;
13165     }
13166     function _toPrimitive(t2, r2) {
13167       if ("object" != typeof t2 || !t2) return t2;
13168       var e3 = t2[Symbol.toPrimitive];
13169       if (void 0 !== e3) {
13170         var i3 = e3.call(t2, r2 || "default");
13171         if ("object" != typeof i3) return i3;
13172         throw new TypeError("@@toPrimitive must return a primitive value.");
13173       }
13174       return ("string" === r2 ? String : Number)(t2);
13175     }
13176     function _toPropertyKey(t2) {
13177       var i3 = _toPrimitive(t2, "string");
13178       return "symbol" == typeof i3 ? i3 : i3 + "";
13179     }
13180     function _unsupportedIterableToArray(r2, a2) {
13181       if (r2) {
13182         if ("string" == typeof r2) return _arrayLikeToArray(r2, a2);
13183         var t2 = {}.toString.call(r2).slice(8, -1);
13184         return "Object" === t2 && r2.constructor && (t2 = r2.constructor.name), "Map" === t2 || "Set" === t2 ? Array.from(r2) : "Arguments" === t2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t2) ? _arrayLikeToArray(r2, a2) : void 0;
13185       }
13186     }
13187     (function(self2) {
13188       return {
13189         NativeAbortSignal: self2.AbortSignal,
13190         NativeAbortController: self2.AbortController
13191       };
13192     })(typeof self !== "undefined" ? self : global);
13193     function createAbortEvent(reason) {
13194       var event;
13195       try {
13196         event = new Event("abort");
13197       } catch (e3) {
13198         if (typeof document !== "undefined") {
13199           if (!document.createEvent) {
13200             event = document.createEventObject();
13201             event.type = "abort";
13202           } else {
13203             event = document.createEvent("Event");
13204             event.initEvent("abort", false, false);
13205           }
13206         } else {
13207           event = {
13208             type: "abort",
13209             bubbles: false,
13210             cancelable: false
13211           };
13212         }
13213       }
13214       event.reason = reason;
13215       return event;
13216     }
13217     function normalizeAbortReason(reason) {
13218       if (reason === void 0) {
13219         if (typeof document === "undefined") {
13220           reason = new Error("This operation was aborted");
13221           reason.name = "AbortError";
13222         } else {
13223           try {
13224             reason = new DOMException("signal is aborted without reason");
13225             Object.defineProperty(reason, "name", {
13226               value: "AbortError"
13227             });
13228           } catch (err) {
13229             reason = new Error("This operation was aborted");
13230             reason.name = "AbortError";
13231           }
13232         }
13233       }
13234       return reason;
13235     }
13236     var Emitter = /* @__PURE__ */ function() {
13237       function Emitter2() {
13238         _classCallCheck(this, Emitter2);
13239         Object.defineProperty(this, "listeners", {
13240           value: {},
13241           writable: true,
13242           configurable: true
13243         });
13244       }
13245       return _createClass(Emitter2, [{
13246         key: "addEventListener",
13247         value: function addEventListener(type2, callback, options2) {
13248           if (!(type2 in this.listeners)) {
13249             this.listeners[type2] = [];
13250           }
13251           this.listeners[type2].push({
13252             callback,
13253             options: options2
13254           });
13255         }
13256       }, {
13257         key: "removeEventListener",
13258         value: function removeEventListener(type2, callback) {
13259           if (!(type2 in this.listeners)) {
13260             return;
13261           }
13262           var stack = this.listeners[type2];
13263           for (var i3 = 0, l2 = stack.length; i3 < l2; i3++) {
13264             if (stack[i3].callback === callback) {
13265               stack.splice(i3, 1);
13266               return;
13267             }
13268           }
13269         }
13270       }, {
13271         key: "dispatchEvent",
13272         value: function dispatchEvent2(event) {
13273           var _this = this;
13274           if (!(event.type in this.listeners)) {
13275             return;
13276           }
13277           var stack = this.listeners[event.type];
13278           var stackToCall = stack.slice();
13279           var _loop = function _loop2() {
13280             var listener = stackToCall[i3];
13281             try {
13282               listener.callback.call(_this, event);
13283             } catch (e3) {
13284               Promise.resolve().then(function() {
13285                 throw e3;
13286               });
13287             }
13288             if (listener.options && listener.options.once) {
13289               _this.removeEventListener(event.type, listener.callback);
13290             }
13291           };
13292           for (var i3 = 0, l2 = stackToCall.length; i3 < l2; i3++) {
13293             _loop();
13294           }
13295           return !event.defaultPrevented;
13296         }
13297       }]);
13298     }();
13299     var AbortSignal = /* @__PURE__ */ function(_Emitter) {
13300       function AbortSignal2() {
13301         var _this2;
13302         _classCallCheck(this, AbortSignal2);
13303         _this2 = _callSuper(this, AbortSignal2);
13304         if (!_this2.listeners) {
13305           Emitter.call(_this2);
13306         }
13307         Object.defineProperty(_this2, "aborted", {
13308           value: false,
13309           writable: true,
13310           configurable: true
13311         });
13312         Object.defineProperty(_this2, "onabort", {
13313           value: null,
13314           writable: true,
13315           configurable: true
13316         });
13317         Object.defineProperty(_this2, "reason", {
13318           value: void 0,
13319           writable: true,
13320           configurable: true
13321         });
13322         return _this2;
13323       }
13324       _inherits(AbortSignal2, _Emitter);
13325       return _createClass(AbortSignal2, [{
13326         key: "toString",
13327         value: function toString2() {
13328           return "[object AbortSignal]";
13329         }
13330       }, {
13331         key: "dispatchEvent",
13332         value: function dispatchEvent2(event) {
13333           if (event.type === "abort") {
13334             this.aborted = true;
13335             if (typeof this.onabort === "function") {
13336               this.onabort.call(this, event);
13337             }
13338           }
13339           _superPropGet(AbortSignal2, "dispatchEvent", this, 3)([event]);
13340         }
13341         /**
13342          * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/throwIfAborted}
13343          */
13344       }, {
13345         key: "throwIfAborted",
13346         value: function throwIfAborted() {
13347           var aborted = this.aborted, _this$reason = this.reason, reason = _this$reason === void 0 ? "Aborted" : _this$reason;
13348           if (!aborted) return;
13349           throw reason;
13350         }
13351         /**
13352          * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/API/AbortSignal/timeout_static}
13353          * @param {number} time The "active" time in milliseconds before the returned {@link AbortSignal} will abort.
13354          *                      The value must be within range of 0 and {@link Number.MAX_SAFE_INTEGER}.
13355          * @returns {AbortSignal} The signal will abort with its {@link AbortSignal.reason} property set to a `TimeoutError` {@link DOMException} on timeout,
13356          *                        or an `AbortError` {@link DOMException} if the operation was user-triggered.
13357          */
13358       }], [{
13359         key: "timeout",
13360         value: function timeout2(time) {
13361           var controller = new AbortController2();
13362           setTimeout(function() {
13363             return controller.abort(new DOMException("This signal is timeout in ".concat(time, "ms"), "TimeoutError"));
13364           }, time);
13365           return controller.signal;
13366         }
13367         /**
13368          * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/any_static}
13369          * @param {Iterable<AbortSignal>} iterable An {@link Iterable} (such as an {@link Array}) of abort signals.
13370          * @returns {AbortSignal} - **Already aborted**, if any of the abort signals given is already aborted.
13371          *                          The returned {@link AbortSignal}'s reason will be already set to the `reason` of the first abort signal that was already aborted.
13372          *                        - **Asynchronously aborted**, when any abort signal in `iterable` aborts.
13373          *                          The `reason` will be set to the reason of the first abort signal that is aborted.
13374          */
13375       }, {
13376         key: "any",
13377         value: function any(iterable) {
13378           var controller = new AbortController2();
13379           function abort() {
13380             controller.abort(this.reason);
13381             clean2();
13382           }
13383           function clean2() {
13384             var _iterator = _createForOfIteratorHelper(iterable), _step;
13385             try {
13386               for (_iterator.s(); !(_step = _iterator.n()).done; ) {
13387                 var signal2 = _step.value;
13388                 signal2.removeEventListener("abort", abort);
13389               }
13390             } catch (err) {
13391               _iterator.e(err);
13392             } finally {
13393               _iterator.f();
13394             }
13395           }
13396           var _iterator2 = _createForOfIteratorHelper(iterable), _step2;
13397           try {
13398             for (_iterator2.s(); !(_step2 = _iterator2.n()).done; ) {
13399               var signal = _step2.value;
13400               if (signal.aborted) {
13401                 controller.abort(signal.reason);
13402                 break;
13403               } else signal.addEventListener("abort", abort);
13404             }
13405           } catch (err) {
13406             _iterator2.e(err);
13407           } finally {
13408             _iterator2.f();
13409           }
13410           return controller.signal;
13411         }
13412       }]);
13413     }(Emitter);
13414     var AbortController2 = /* @__PURE__ */ function() {
13415       function AbortController3() {
13416         _classCallCheck(this, AbortController3);
13417         Object.defineProperty(this, "signal", {
13418           value: new AbortSignal(),
13419           writable: true,
13420           configurable: true
13421         });
13422       }
13423       return _createClass(AbortController3, [{
13424         key: "abort",
13425         value: function abort(reason) {
13426           var signalReason = normalizeAbortReason(reason);
13427           var event = createAbortEvent(signalReason);
13428           this.signal.reason = signalReason;
13429           this.signal.dispatchEvent(event);
13430         }
13431       }, {
13432         key: "toString",
13433         value: function toString2() {
13434           return "[object AbortController]";
13435         }
13436       }]);
13437     }();
13438     if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
13439       AbortController2.prototype[Symbol.toStringTag] = "AbortController";
13440       AbortSignal.prototype[Symbol.toStringTag] = "AbortSignal";
13441     }
13442     function polyfillNeeded(self2) {
13443       if (self2.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
13444         console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill");
13445         return true;
13446       }
13447       return typeof self2.Request === "function" && !self2.Request.prototype.hasOwnProperty("signal") || !self2.AbortController;
13448     }
13449     function abortableFetchDecorator(patchTargets) {
13450       if ("function" === typeof patchTargets) {
13451         patchTargets = {
13452           fetch: patchTargets
13453         };
13454       }
13455       var _patchTargets = patchTargets, fetch3 = _patchTargets.fetch, _patchTargets$Request = _patchTargets.Request, NativeRequest = _patchTargets$Request === void 0 ? fetch3.Request : _patchTargets$Request, NativeAbortController = _patchTargets.AbortController, _patchTargets$__FORCE = _patchTargets.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL, __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL = _patchTargets$__FORCE === void 0 ? false : _patchTargets$__FORCE;
13456       if (!polyfillNeeded({
13457         fetch: fetch3,
13458         Request: NativeRequest,
13459         AbortController: NativeAbortController,
13460         __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL
13461       })) {
13462         return {
13463           fetch: fetch3,
13464           Request: Request2
13465         };
13466       }
13467       var Request2 = NativeRequest;
13468       if (Request2 && !Request2.prototype.hasOwnProperty("signal") || __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
13469         Request2 = function Request3(input, init2) {
13470           var signal;
13471           if (init2 && init2.signal) {
13472             signal = init2.signal;
13473             delete init2.signal;
13474           }
13475           var request3 = new NativeRequest(input, init2);
13476           if (signal) {
13477             Object.defineProperty(request3, "signal", {
13478               writable: false,
13479               enumerable: false,
13480               configurable: true,
13481               value: signal
13482             });
13483           }
13484           return request3;
13485         };
13486         Request2.prototype = NativeRequest.prototype;
13487       }
13488       var realFetch = fetch3;
13489       var abortableFetch = function abortableFetch2(input, init2) {
13490         var signal = Request2 && Request2.prototype.isPrototypeOf(input) ? input.signal : init2 ? init2.signal : void 0;
13491         if (signal) {
13492           var abortError;
13493           try {
13494             abortError = new DOMException("Aborted", "AbortError");
13495           } catch (err) {
13496             abortError = new Error("Aborted");
13497             abortError.name = "AbortError";
13498           }
13499           if (signal.aborted) {
13500             return Promise.reject(abortError);
13501           }
13502           var cancellation = new Promise(function(_2, reject) {
13503             signal.addEventListener("abort", function() {
13504               return reject(abortError);
13505             }, {
13506               once: true
13507             });
13508           });
13509           if (init2 && init2.signal) {
13510             delete init2.signal;
13511           }
13512           return Promise.race([cancellation, realFetch(input, init2)]);
13513         }
13514         return realFetch(input, init2);
13515       };
13516       return {
13517         fetch: abortableFetch,
13518         Request: Request2
13519       };
13520     }
13521     (function(self2) {
13522       if (!polyfillNeeded(self2)) {
13523         return;
13524       }
13525       if (!self2.fetch) {
13526         console.warn("fetch() is not available, cannot install abortcontroller-polyfill");
13527         return;
13528       }
13529       var _abortableFetch = abortableFetchDecorator(self2), fetch3 = _abortableFetch.fetch, Request2 = _abortableFetch.Request;
13530       self2.fetch = fetch3;
13531       self2.Request = Request2;
13532       Object.defineProperty(self2, "AbortController", {
13533         writable: true,
13534         enumerable: false,
13535         configurable: true,
13536         value: AbortController2
13537       });
13538       Object.defineProperty(self2, "AbortSignal", {
13539         writable: true,
13540         enumerable: false,
13541         configurable: true,
13542         value: AbortSignal
13543       });
13544     })(typeof self !== "undefined" ? self : global);
13545   });
13546
13547   // modules/index.js
13548   var index_exports = {};
13549   __export(index_exports, {
13550     LANGUAGE_SUFFIX_REGEX: () => LANGUAGE_SUFFIX_REGEX,
13551     LocationManager: () => LocationManager,
13552     QAItem: () => QAItem,
13553     actionAddEntity: () => actionAddEntity,
13554     actionAddMember: () => actionAddMember,
13555     actionAddMidpoint: () => actionAddMidpoint,
13556     actionAddVertex: () => actionAddVertex,
13557     actionChangeMember: () => actionChangeMember,
13558     actionChangePreset: () => actionChangePreset,
13559     actionChangeTags: () => actionChangeTags,
13560     actionCircularize: () => actionCircularize,
13561     actionConnect: () => actionConnect,
13562     actionCopyEntities: () => actionCopyEntities,
13563     actionDeleteMember: () => actionDeleteMember,
13564     actionDeleteMultiple: () => actionDeleteMultiple,
13565     actionDeleteNode: () => actionDeleteNode,
13566     actionDeleteRelation: () => actionDeleteRelation,
13567     actionDeleteWay: () => actionDeleteWay,
13568     actionDiscardTags: () => actionDiscardTags,
13569     actionDisconnect: () => actionDisconnect,
13570     actionExtract: () => actionExtract,
13571     actionJoin: () => actionJoin,
13572     actionMerge: () => actionMerge,
13573     actionMergeNodes: () => actionMergeNodes,
13574     actionMergePolygon: () => actionMergePolygon,
13575     actionMergeRemoteChanges: () => actionMergeRemoteChanges,
13576     actionMove: () => actionMove,
13577     actionMoveMember: () => actionMoveMember,
13578     actionMoveNode: () => actionMoveNode,
13579     actionNoop: () => actionNoop,
13580     actionOrthogonalize: () => actionOrthogonalize,
13581     actionReflect: () => actionReflect,
13582     actionRestrictTurn: () => actionRestrictTurn,
13583     actionReverse: () => actionReverse,
13584     actionRevert: () => actionRevert,
13585     actionRotate: () => actionRotate,
13586     actionScale: () => actionScale,
13587     actionSplit: () => actionSplit,
13588     actionStraightenNodes: () => actionStraightenNodes,
13589     actionStraightenWay: () => actionStraightenWay,
13590     actionUnrestrictTurn: () => actionUnrestrictTurn,
13591     actionUpgradeTags: () => actionUpgradeTags,
13592     behaviorAddWay: () => behaviorAddWay,
13593     behaviorBreathe: () => behaviorBreathe,
13594     behaviorDrag: () => behaviorDrag,
13595     behaviorDraw: () => behaviorDraw,
13596     behaviorDrawWay: () => behaviorDrawWay,
13597     behaviorEdit: () => behaviorEdit,
13598     behaviorHash: () => behaviorHash,
13599     behaviorHover: () => behaviorHover,
13600     behaviorLasso: () => behaviorLasso,
13601     behaviorOperation: () => behaviorOperation,
13602     behaviorPaste: () => behaviorPaste,
13603     behaviorSelect: () => behaviorSelect,
13604     coreContext: () => coreContext,
13605     coreDifference: () => coreDifference,
13606     coreFileFetcher: () => coreFileFetcher,
13607     coreGraph: () => coreGraph,
13608     coreHistory: () => coreHistory,
13609     coreLocalizer: () => coreLocalizer,
13610     coreTree: () => coreTree,
13611     coreUploader: () => coreUploader,
13612     coreValidator: () => coreValidator,
13613     d3: () => d3,
13614     debug: () => debug,
13615     dmsCoordinatePair: () => dmsCoordinatePair,
13616     dmsMatcher: () => dmsMatcher,
13617     fileFetcher: () => _mainFileFetcher,
13618     geoAngle: () => geoAngle,
13619     geoChooseEdge: () => geoChooseEdge,
13620     geoEdgeEqual: () => geoEdgeEqual,
13621     geoExtent: () => geoExtent,
13622     geoGetSmallestSurroundingRectangle: () => geoGetSmallestSurroundingRectangle,
13623     geoHasLineIntersections: () => geoHasLineIntersections,
13624     geoHasSelfIntersections: () => geoHasSelfIntersections,
13625     geoLatToMeters: () => geoLatToMeters,
13626     geoLineIntersection: () => geoLineIntersection,
13627     geoLonToMeters: () => geoLonToMeters,
13628     geoMetersToLat: () => geoMetersToLat,
13629     geoMetersToLon: () => geoMetersToLon,
13630     geoMetersToOffset: () => geoMetersToOffset,
13631     geoOffsetToMeters: () => geoOffsetToMeters,
13632     geoOrthoCalcScore: () => geoOrthoCalcScore,
13633     geoOrthoCanOrthogonalize: () => geoOrthoCanOrthogonalize,
13634     geoOrthoMaxOffsetAngle: () => geoOrthoMaxOffsetAngle,
13635     geoOrthoNormalizedDotProduct: () => geoOrthoNormalizedDotProduct,
13636     geoPathHasIntersections: () => geoPathHasIntersections,
13637     geoPathIntersections: () => geoPathIntersections,
13638     geoPathLength: () => geoPathLength,
13639     geoPointInPolygon: () => geoPointInPolygon,
13640     geoPolygonContainsPolygon: () => geoPolygonContainsPolygon,
13641     geoPolygonIntersectsPolygon: () => geoPolygonIntersectsPolygon,
13642     geoRawMercator: () => geoRawMercator,
13643     geoRotate: () => geoRotate,
13644     geoScaleToZoom: () => geoScaleToZoom,
13645     geoSphericalClosestNode: () => geoSphericalClosestNode,
13646     geoSphericalDistance: () => geoSphericalDistance,
13647     geoVecAdd: () => geoVecAdd,
13648     geoVecAngle: () => geoVecAngle,
13649     geoVecCross: () => geoVecCross,
13650     geoVecDot: () => geoVecDot,
13651     geoVecEqual: () => geoVecEqual,
13652     geoVecFloor: () => geoVecFloor,
13653     geoVecInterp: () => geoVecInterp,
13654     geoVecLength: () => geoVecLength,
13655     geoVecLengthSquare: () => geoVecLengthSquare,
13656     geoVecNormalize: () => geoVecNormalize,
13657     geoVecNormalizedDot: () => geoVecNormalizedDot,
13658     geoVecProject: () => geoVecProject,
13659     geoVecScale: () => geoVecScale,
13660     geoVecSubtract: () => geoVecSubtract,
13661     geoViewportEdge: () => geoViewportEdge,
13662     geoZoomToScale: () => geoZoomToScale,
13663     likelyRawNumberFormat: () => likelyRawNumberFormat,
13664     localizer: () => _mainLocalizer,
13665     locationManager: () => _sharedLocationManager,
13666     modeAddArea: () => modeAddArea,
13667     modeAddLine: () => modeAddLine,
13668     modeAddNote: () => modeAddNote,
13669     modeAddPoint: () => modeAddPoint,
13670     modeBrowse: () => modeBrowse,
13671     modeDragNode: () => modeDragNode,
13672     modeDragNote: () => modeDragNote,
13673     modeDrawArea: () => modeDrawArea,
13674     modeDrawLine: () => modeDrawLine,
13675     modeMove: () => modeMove,
13676     modeRotate: () => modeRotate,
13677     modeSave: () => modeSave,
13678     modeSelect: () => modeSelect,
13679     modeSelectData: () => modeSelectData,
13680     modeSelectError: () => modeSelectError,
13681     modeSelectNote: () => modeSelectNote,
13682     operationCircularize: () => operationCircularize,
13683     operationContinue: () => operationContinue,
13684     operationCopy: () => operationCopy,
13685     operationDelete: () => operationDelete,
13686     operationDisconnect: () => operationDisconnect,
13687     operationDowngrade: () => operationDowngrade,
13688     operationExtract: () => operationExtract,
13689     operationMerge: () => operationMerge,
13690     operationMove: () => operationMove,
13691     operationOrthogonalize: () => operationOrthogonalize,
13692     operationPaste: () => operationPaste,
13693     operationReflectLong: () => operationReflectLong,
13694     operationReflectShort: () => operationReflectShort,
13695     operationReverse: () => operationReverse,
13696     operationRotate: () => operationRotate,
13697     operationSplit: () => operationSplit,
13698     operationStraighten: () => operationStraighten,
13699     osmAreaKeys: () => osmAreaKeys,
13700     osmChangeset: () => osmChangeset,
13701     osmEntity: () => osmEntity,
13702     osmFlowingWaterwayTagValues: () => osmFlowingWaterwayTagValues,
13703     osmInferRestriction: () => osmInferRestriction,
13704     osmIntersection: () => osmIntersection,
13705     osmIsInterestingTag: () => osmIsInterestingTag,
13706     osmJoinWays: () => osmJoinWays,
13707     osmLanes: () => osmLanes,
13708     osmLifecyclePrefixes: () => osmLifecyclePrefixes,
13709     osmNode: () => osmNode,
13710     osmNodeGeometriesForTags: () => osmNodeGeometriesForTags,
13711     osmNote: () => osmNote,
13712     osmOneWayTags: () => osmOneWayTags,
13713     osmPavedTags: () => osmPavedTags,
13714     osmPointTags: () => osmPointTags,
13715     osmRailwayTrackTagValues: () => osmRailwayTrackTagValues,
13716     osmRelation: () => osmRelation,
13717     osmRemoveLifecyclePrefix: () => osmRemoveLifecyclePrefix,
13718     osmRoutableHighwayTagValues: () => osmRoutableHighwayTagValues,
13719     osmSetAreaKeys: () => osmSetAreaKeys,
13720     osmSetPointTags: () => osmSetPointTags,
13721     osmSetVertexTags: () => osmSetVertexTags,
13722     osmTagSuggestingArea: () => osmTagSuggestingArea,
13723     osmTurn: () => osmTurn,
13724     osmVertexTags: () => osmVertexTags,
13725     osmWay: () => osmWay,
13726     prefs: () => corePreferences,
13727     presetCategory: () => presetCategory,
13728     presetCollection: () => presetCollection,
13729     presetField: () => presetField,
13730     presetIndex: () => presetIndex,
13731     presetManager: () => _mainPresetIndex,
13732     presetPreset: () => presetPreset,
13733     rendererBackground: () => rendererBackground,
13734     rendererBackgroundSource: () => rendererBackgroundSource,
13735     rendererFeatures: () => rendererFeatures,
13736     rendererMap: () => rendererMap,
13737     rendererPhotos: () => rendererPhotos,
13738     rendererTileLayer: () => rendererTileLayer,
13739     serviceKartaview: () => kartaview_default,
13740     serviceKeepRight: () => keepRight_default,
13741     serviceMapRules: () => maprules_default,
13742     serviceMapilio: () => mapilio_default,
13743     serviceMapillary: () => mapillary_default,
13744     serviceNominatim: () => nominatim_default,
13745     serviceNsi: () => nsi_default,
13746     serviceOsm: () => osm_default,
13747     serviceOsmWikibase: () => osm_wikibase_default,
13748     serviceOsmose: () => osmose_default,
13749     servicePanoramax: () => panoramax_default,
13750     serviceStreetside: () => streetside_default,
13751     serviceTaginfo: () => taginfo_default,
13752     serviceVectorTile: () => vector_tile_default,
13753     serviceVegbilder: () => vegbilder_default,
13754     serviceWikidata: () => wikidata_default,
13755     serviceWikipedia: () => wikipedia_default,
13756     services: () => services,
13757     setDebug: () => setDebug,
13758     svgAreas: () => svgAreas,
13759     svgData: () => svgData,
13760     svgDebug: () => svgDebug,
13761     svgDefs: () => svgDefs,
13762     svgGeolocate: () => svgGeolocate,
13763     svgIcon: () => svgIcon,
13764     svgKartaviewImages: () => svgKartaviewImages,
13765     svgKeepRight: () => svgKeepRight,
13766     svgLabels: () => svgLabels,
13767     svgLayers: () => svgLayers,
13768     svgLines: () => svgLines,
13769     svgMapilioImages: () => svgMapilioImages,
13770     svgMapillaryImages: () => svgMapillaryImages,
13771     svgMapillarySigns: () => svgMapillarySigns,
13772     svgMarkerSegments: () => svgMarkerSegments,
13773     svgMidpoints: () => svgMidpoints,
13774     svgNotes: () => svgNotes,
13775     svgOsm: () => svgOsm,
13776     svgPanoramaxImages: () => svgPanoramaxImages,
13777     svgPassiveVertex: () => svgPassiveVertex,
13778     svgPath: () => svgPath,
13779     svgPointTransform: () => svgPointTransform,
13780     svgPoints: () => svgPoints,
13781     svgRelationMemberTags: () => svgRelationMemberTags,
13782     svgSegmentWay: () => svgSegmentWay,
13783     svgStreetside: () => svgStreetside,
13784     svgTagClasses: () => svgTagClasses,
13785     svgTagPattern: () => svgTagPattern,
13786     svgTouch: () => svgTouch,
13787     svgTurns: () => svgTurns,
13788     svgVegbilder: () => svgVegbilder,
13789     svgVertices: () => svgVertices,
13790     t: () => _t,
13791     uiAccount: () => uiAccount,
13792     uiAttribution: () => uiAttribution,
13793     uiChangesetEditor: () => uiChangesetEditor,
13794     uiCmd: () => uiCmd,
13795     uiCombobox: () => uiCombobox,
13796     uiCommit: () => uiCommit,
13797     uiCommitWarnings: () => uiCommitWarnings,
13798     uiConfirm: () => uiConfirm,
13799     uiConflicts: () => uiConflicts,
13800     uiContributors: () => uiContributors,
13801     uiCurtain: () => uiCurtain,
13802     uiDataEditor: () => uiDataEditor,
13803     uiDataHeader: () => uiDataHeader,
13804     uiDisclosure: () => uiDisclosure,
13805     uiEditMenu: () => uiEditMenu,
13806     uiEntityEditor: () => uiEntityEditor,
13807     uiFeatureInfo: () => uiFeatureInfo,
13808     uiFeatureList: () => uiFeatureList,
13809     uiField: () => uiField,
13810     uiFieldAccess: () => uiFieldAccess,
13811     uiFieldAddress: () => uiFieldAddress,
13812     uiFieldCheck: () => uiFieldCheck,
13813     uiFieldColour: () => uiFieldText,
13814     uiFieldCombo: () => uiFieldCombo,
13815     uiFieldDefaultCheck: () => uiFieldCheck,
13816     uiFieldDirectionalCombo: () => uiFieldDirectionalCombo,
13817     uiFieldEmail: () => uiFieldText,
13818     uiFieldHelp: () => uiFieldHelp,
13819     uiFieldIdentifier: () => uiFieldText,
13820     uiFieldLanes: () => uiFieldLanes,
13821     uiFieldLocalized: () => uiFieldLocalized,
13822     uiFieldManyCombo: () => uiFieldCombo,
13823     uiFieldMultiCombo: () => uiFieldCombo,
13824     uiFieldNetworkCombo: () => uiFieldCombo,
13825     uiFieldNumber: () => uiFieldText,
13826     uiFieldOnewayCheck: () => uiFieldCheck,
13827     uiFieldRadio: () => uiFieldRadio,
13828     uiFieldRestrictions: () => uiFieldRestrictions,
13829     uiFieldRoadheight: () => uiFieldRoadheight,
13830     uiFieldRoadspeed: () => uiFieldRoadspeed,
13831     uiFieldSemiCombo: () => uiFieldCombo,
13832     uiFieldStructureRadio: () => uiFieldRadio,
13833     uiFieldTel: () => uiFieldText,
13834     uiFieldText: () => uiFieldText,
13835     uiFieldTextarea: () => uiFieldTextarea,
13836     uiFieldTypeCombo: () => uiFieldCombo,
13837     uiFieldUrl: () => uiFieldText,
13838     uiFieldWikidata: () => uiFieldWikidata,
13839     uiFieldWikipedia: () => uiFieldWikipedia,
13840     uiFields: () => uiFields,
13841     uiFlash: () => uiFlash,
13842     uiFormFields: () => uiFormFields,
13843     uiFullScreen: () => uiFullScreen,
13844     uiGeolocate: () => uiGeolocate,
13845     uiInfo: () => uiInfo,
13846     uiInfoPanels: () => uiInfoPanels,
13847     uiInit: () => uiInit,
13848     uiInspector: () => uiInspector,
13849     uiIntro: () => uiIntro,
13850     uiIssuesInfo: () => uiIssuesInfo,
13851     uiKeepRightDetails: () => uiKeepRightDetails,
13852     uiKeepRightEditor: () => uiKeepRightEditor,
13853     uiKeepRightHeader: () => uiKeepRightHeader,
13854     uiLasso: () => uiLasso,
13855     uiLengthIndicator: () => uiLengthIndicator,
13856     uiLoading: () => uiLoading,
13857     uiMapInMap: () => uiMapInMap,
13858     uiModal: () => uiModal,
13859     uiNoteComments: () => uiNoteComments,
13860     uiNoteEditor: () => uiNoteEditor,
13861     uiNoteHeader: () => uiNoteHeader,
13862     uiNoteReport: () => uiNoteReport,
13863     uiNotice: () => uiNotice,
13864     uiPaneBackground: () => uiPaneBackground,
13865     uiPaneHelp: () => uiPaneHelp,
13866     uiPaneIssues: () => uiPaneIssues,
13867     uiPaneMapData: () => uiPaneMapData,
13868     uiPanePreferences: () => uiPanePreferences,
13869     uiPanelBackground: () => uiPanelBackground,
13870     uiPanelHistory: () => uiPanelHistory,
13871     uiPanelLocation: () => uiPanelLocation,
13872     uiPanelMeasurement: () => uiPanelMeasurement,
13873     uiPopover: () => uiPopover,
13874     uiPresetIcon: () => uiPresetIcon,
13875     uiPresetList: () => uiPresetList,
13876     uiRestore: () => uiRestore,
13877     uiScale: () => uiScale,
13878     uiSectionBackgroundDisplayOptions: () => uiSectionBackgroundDisplayOptions,
13879     uiSectionBackgroundList: () => uiSectionBackgroundList,
13880     uiSectionBackgroundOffset: () => uiSectionBackgroundOffset,
13881     uiSectionChanges: () => uiSectionChanges,
13882     uiSectionDataLayers: () => uiSectionDataLayers,
13883     uiSectionEntityIssues: () => uiSectionEntityIssues,
13884     uiSectionFeatureType: () => uiSectionFeatureType,
13885     uiSectionMapFeatures: () => uiSectionMapFeatures,
13886     uiSectionMapStyleOptions: () => uiSectionMapStyleOptions,
13887     uiSectionOverlayList: () => uiSectionOverlayList,
13888     uiSectionPhotoOverlays: () => uiSectionPhotoOverlays,
13889     uiSectionPresetFields: () => uiSectionPresetFields,
13890     uiSectionPrivacy: () => uiSectionPrivacy,
13891     uiSectionRawMemberEditor: () => uiSectionRawMemberEditor,
13892     uiSectionRawMembershipEditor: () => uiSectionRawMembershipEditor,
13893     uiSectionRawTagEditor: () => uiSectionRawTagEditor,
13894     uiSectionSelectionList: () => uiSectionSelectionList,
13895     uiSectionValidationIssues: () => uiSectionValidationIssues,
13896     uiSectionValidationOptions: () => uiSectionValidationOptions,
13897     uiSectionValidationRules: () => uiSectionValidationRules,
13898     uiSectionValidationStatus: () => uiSectionValidationStatus,
13899     uiSettingsCustomBackground: () => uiSettingsCustomBackground,
13900     uiSettingsCustomData: () => uiSettingsCustomData,
13901     uiSidebar: () => uiSidebar,
13902     uiSourceSwitch: () => uiSourceSwitch,
13903     uiSpinner: () => uiSpinner,
13904     uiSplash: () => uiSplash,
13905     uiStatus: () => uiStatus,
13906     uiSuccess: () => uiSuccess,
13907     uiTagReference: () => uiTagReference,
13908     uiToggle: () => uiToggle,
13909     uiTooltip: () => uiTooltip,
13910     uiVersion: () => uiVersion,
13911     uiViewOnKeepRight: () => uiViewOnKeepRight,
13912     uiViewOnOSM: () => uiViewOnOSM,
13913     uiZoom: () => uiZoom,
13914     utilAesDecrypt: () => utilAesDecrypt,
13915     utilAesEncrypt: () => utilAesEncrypt,
13916     utilArrayChunk: () => utilArrayChunk,
13917     utilArrayDifference: () => utilArrayDifference,
13918     utilArrayFlatten: () => utilArrayFlatten,
13919     utilArrayGroupBy: () => utilArrayGroupBy,
13920     utilArrayIdentical: () => utilArrayIdentical,
13921     utilArrayIntersection: () => utilArrayIntersection,
13922     utilArrayUnion: () => utilArrayUnion,
13923     utilArrayUniq: () => utilArrayUniq,
13924     utilArrayUniqBy: () => utilArrayUniqBy,
13925     utilAsyncMap: () => utilAsyncMap,
13926     utilCleanOsmString: () => utilCleanOsmString,
13927     utilCleanTags: () => utilCleanTags,
13928     utilCombinedTags: () => utilCombinedTags,
13929     utilCompareIDs: () => utilCompareIDs,
13930     utilDeepMemberSelector: () => utilDeepMemberSelector,
13931     utilDetect: () => utilDetect,
13932     utilDisplayName: () => utilDisplayName,
13933     utilDisplayNameForPath: () => utilDisplayNameForPath,
13934     utilDisplayType: () => utilDisplayType,
13935     utilEditDistance: () => utilEditDistance,
13936     utilEntityAndDeepMemberIDs: () => utilEntityAndDeepMemberIDs,
13937     utilEntityOrDeepMemberSelector: () => utilEntityOrDeepMemberSelector,
13938     utilEntityOrMemberSelector: () => utilEntityOrMemberSelector,
13939     utilEntityRoot: () => utilEntityRoot,
13940     utilEntitySelector: () => utilEntitySelector,
13941     utilFastMouse: () => utilFastMouse,
13942     utilFunctor: () => utilFunctor,
13943     utilGetAllNodes: () => utilGetAllNodes,
13944     utilGetSetValue: () => utilGetSetValue,
13945     utilHashcode: () => utilHashcode,
13946     utilHighlightEntities: () => utilHighlightEntities,
13947     utilKeybinding: () => utilKeybinding,
13948     utilNoAuto: () => utilNoAuto,
13949     utilObjectOmit: () => utilObjectOmit,
13950     utilOldestID: () => utilOldestID,
13951     utilPrefixCSSProperty: () => utilPrefixCSSProperty,
13952     utilPrefixDOMProperty: () => utilPrefixDOMProperty,
13953     utilQsString: () => utilQsString,
13954     utilRebind: () => utilRebind,
13955     utilSafeClassName: () => utilSafeClassName,
13956     utilSessionMutex: () => utilSessionMutex,
13957     utilSetTransform: () => utilSetTransform,
13958     utilStringQs: () => utilStringQs,
13959     utilTagDiff: () => utilTagDiff,
13960     utilTagText: () => utilTagText,
13961     utilTiler: () => utilTiler,
13962     utilTotalExtent: () => utilTotalExtent,
13963     utilTriggerEvent: () => utilTriggerEvent,
13964     utilUnicodeCharsCount: () => utilUnicodeCharsCount,
13965     utilUnicodeCharsTruncated: () => utilUnicodeCharsTruncated,
13966     utilUniqueDomId: () => utilUniqueDomId,
13967     utilWrap: () => utilWrap,
13968     validationAlmostJunction: () => validationAlmostJunction,
13969     validationCloseNodes: () => validationCloseNodes,
13970     validationCrossingWays: () => validationCrossingWays,
13971     validationDisconnectedWay: () => validationDisconnectedWay,
13972     validationFormatting: () => validationFormatting,
13973     validationHelpRequest: () => validationHelpRequest,
13974     validationImpossibleOneway: () => validationImpossibleOneway,
13975     validationIncompatibleSource: () => validationIncompatibleSource,
13976     validationMaprules: () => validationMaprules,
13977     validationMismatchedGeometry: () => validationMismatchedGeometry,
13978     validationMissingRole: () => validationMissingRole,
13979     validationMissingTag: () => validationMissingTag,
13980     validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags,
13981     validationOutdatedTags: () => validationOutdatedTags,
13982     validationPrivateData: () => validationPrivateData,
13983     validationSuspiciousName: () => validationSuspiciousName,
13984     validationUnsquareWay: () => validationUnsquareWay
13985   });
13986
13987   // modules/actions/add_entity.js
13988   function actionAddEntity(way) {
13989     return function(graph) {
13990       return graph.replace(way);
13991     };
13992   }
13993
13994   // modules/actions/reverse.js
13995   function actionReverse(entityID, options2) {
13996     var ignoreKey = /^.*(_|:)?(description|name|note|website|ref|source|comment|watch|attribution)(_|:)?/;
13997     var numeric = /^([+\-]?)(?=[\d.])/;
13998     var directionKey = /direction$/;
13999     var turn_lanes = /^turn:lanes:?/;
14000     var keyReplacements = [
14001       [/:right$/, ":left"],
14002       [/:left$/, ":right"],
14003       [/:forward$/, ":backward"],
14004       [/:backward$/, ":forward"],
14005       [/:right:/, ":left:"],
14006       [/:left:/, ":right:"],
14007       [/:forward:/, ":backward:"],
14008       [/:backward:/, ":forward:"]
14009     ];
14010     var valueReplacements = {
14011       left: "right",
14012       right: "left",
14013       up: "down",
14014       down: "up",
14015       forward: "backward",
14016       backward: "forward",
14017       forwards: "backward",
14018       backwards: "forward"
14019     };
14020     const valueReplacementsExceptions = {
14021       "side": [
14022         { highway: "cyclist_waiting_aid" }
14023       ]
14024     };
14025     var roleReplacements = {
14026       forward: "backward",
14027       backward: "forward",
14028       forwards: "backward",
14029       backwards: "forward"
14030     };
14031     var onewayReplacements = {
14032       yes: "-1",
14033       "1": "-1",
14034       "-1": "yes"
14035     };
14036     var compassReplacements = {
14037       N: "S",
14038       NNE: "SSW",
14039       NE: "SW",
14040       ENE: "WSW",
14041       E: "W",
14042       ESE: "WNW",
14043       SE: "NW",
14044       SSE: "NNW",
14045       S: "N",
14046       SSW: "NNE",
14047       SW: "NE",
14048       WSW: "ENE",
14049       W: "E",
14050       WNW: "ESE",
14051       NW: "SE",
14052       NNW: "SSE"
14053     };
14054     function reverseKey(key) {
14055       for (var i3 = 0; i3 < keyReplacements.length; ++i3) {
14056         var replacement = keyReplacements[i3];
14057         if (replacement[0].test(key)) {
14058           return key.replace(replacement[0], replacement[1]);
14059         }
14060       }
14061       return key;
14062     }
14063     function reverseValue(key, value, includeAbsolute, allTags) {
14064       if (ignoreKey.test(key)) return value;
14065       if (turn_lanes.test(key)) {
14066         return value;
14067       } else if (key === "incline" && numeric.test(value)) {
14068         return value.replace(numeric, function(_2, sign2) {
14069           return sign2 === "-" ? "" : "-";
14070         });
14071       } else if (options2 && options2.reverseOneway && key === "oneway") {
14072         return onewayReplacements[value] || value;
14073       } else if (includeAbsolute && directionKey.test(key)) {
14074         return value.split(";").map((value2) => {
14075           if (compassReplacements[value2]) return compassReplacements[value2];
14076           var degrees3 = Number(value2);
14077           if (isFinite(degrees3)) {
14078             if (degrees3 < 180) {
14079               degrees3 += 180;
14080             } else {
14081               degrees3 -= 180;
14082             }
14083             return degrees3.toString();
14084           } else {
14085             return valueReplacements[value2] || value2;
14086           }
14087         }).join(";");
14088       }
14089       if (valueReplacementsExceptions[key] && valueReplacementsExceptions[key].some(
14090         (exceptionTags) => Object.keys(exceptionTags).every((k2) => {
14091           const v2 = exceptionTags[k2];
14092           return allTags[k2] && (v2 === "*" || allTags[k2] === v2);
14093         })
14094       )) {
14095         return value;
14096       }
14097       return valueReplacements[value] || value;
14098     }
14099     function reverseNodeTags(graph, nodeIDs) {
14100       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
14101         var node = graph.hasEntity(nodeIDs[i3]);
14102         if (!node || !Object.keys(node.tags).length) continue;
14103         var tags = {};
14104         for (var key in node.tags) {
14105           tags[reverseKey(key)] = reverseValue(key, node.tags[key], node.id === entityID, node.tags);
14106         }
14107         graph = graph.replace(node.update({ tags }));
14108       }
14109       return graph;
14110     }
14111     function reverseWay(graph, way) {
14112       var nodes = way.nodes.slice().reverse();
14113       var tags = {};
14114       var role;
14115       for (var key in way.tags) {
14116         tags[reverseKey(key)] = reverseValue(key, way.tags[key], false, way.tags);
14117       }
14118       graph.parentRelations(way).forEach(function(relation) {
14119         relation.members.forEach(function(member, index) {
14120           if (member.id === way.id && (role = roleReplacements[member.role])) {
14121             relation = relation.updateMember({ role }, index);
14122             graph = graph.replace(relation);
14123           }
14124         });
14125       });
14126       return reverseNodeTags(graph, nodes).replace(way.update({ nodes, tags }));
14127     }
14128     var action = function(graph) {
14129       var entity = graph.entity(entityID);
14130       if (entity.type === "way") {
14131         return reverseWay(graph, entity);
14132       }
14133       return reverseNodeTags(graph, [entityID]);
14134     };
14135     action.disabled = function(graph) {
14136       var entity = graph.hasEntity(entityID);
14137       if (!entity || entity.type === "way") return false;
14138       for (var key in entity.tags) {
14139         var value = entity.tags[key];
14140         if (reverseKey(key) !== key || reverseValue(key, value, true, entity.tags) !== value) {
14141           return false;
14142         }
14143       }
14144       return "nondirectional_node";
14145     };
14146     action.entityID = function() {
14147       return entityID;
14148     };
14149     return action;
14150   }
14151
14152   // node_modules/d3-array/src/ascending.js
14153   function ascending(a2, b2) {
14154     return a2 == null || b2 == null ? NaN : a2 < b2 ? -1 : a2 > b2 ? 1 : a2 >= b2 ? 0 : NaN;
14155   }
14156
14157   // node_modules/d3-array/src/descending.js
14158   function descending(a2, b2) {
14159     return a2 == null || b2 == null ? NaN : b2 < a2 ? -1 : b2 > a2 ? 1 : b2 >= a2 ? 0 : NaN;
14160   }
14161
14162   // node_modules/d3-array/src/bisector.js
14163   function bisector(f2) {
14164     let compare1, compare2, delta;
14165     if (f2.length !== 2) {
14166       compare1 = ascending;
14167       compare2 = (d2, x2) => ascending(f2(d2), x2);
14168       delta = (d2, x2) => f2(d2) - x2;
14169     } else {
14170       compare1 = f2 === ascending || f2 === descending ? f2 : zero;
14171       compare2 = f2;
14172       delta = f2;
14173     }
14174     function left(a2, x2, lo = 0, hi = a2.length) {
14175       if (lo < hi) {
14176         if (compare1(x2, x2) !== 0) return hi;
14177         do {
14178           const mid = lo + hi >>> 1;
14179           if (compare2(a2[mid], x2) < 0) lo = mid + 1;
14180           else hi = mid;
14181         } while (lo < hi);
14182       }
14183       return lo;
14184     }
14185     function right(a2, x2, lo = 0, hi = a2.length) {
14186       if (lo < hi) {
14187         if (compare1(x2, x2) !== 0) return hi;
14188         do {
14189           const mid = lo + hi >>> 1;
14190           if (compare2(a2[mid], x2) <= 0) lo = mid + 1;
14191           else hi = mid;
14192         } while (lo < hi);
14193       }
14194       return lo;
14195     }
14196     function center(a2, x2, lo = 0, hi = a2.length) {
14197       const i3 = left(a2, x2, lo, hi - 1);
14198       return i3 > lo && delta(a2[i3 - 1], x2) > -delta(a2[i3], x2) ? i3 - 1 : i3;
14199     }
14200     return { left, center, right };
14201   }
14202   function zero() {
14203     return 0;
14204   }
14205
14206   // node_modules/d3-array/src/number.js
14207   function number(x2) {
14208     return x2 === null ? NaN : +x2;
14209   }
14210   function* numbers(values, valueof) {
14211     if (valueof === void 0) {
14212       for (let value of values) {
14213         if (value != null && (value = +value) >= value) {
14214           yield value;
14215         }
14216       }
14217     } else {
14218       let index = -1;
14219       for (let value of values) {
14220         if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
14221           yield value;
14222         }
14223       }
14224     }
14225   }
14226
14227   // node_modules/d3-array/src/bisect.js
14228   var ascendingBisect = bisector(ascending);
14229   var bisectRight = ascendingBisect.right;
14230   var bisectLeft = ascendingBisect.left;
14231   var bisectCenter = bisector(number).center;
14232   var bisect_default = bisectRight;
14233
14234   // node_modules/d3-array/src/fsum.js
14235   var Adder = class {
14236     constructor() {
14237       this._partials = new Float64Array(32);
14238       this._n = 0;
14239     }
14240     add(x2) {
14241       const p2 = this._partials;
14242       let i3 = 0;
14243       for (let j2 = 0; j2 < this._n && j2 < 32; j2++) {
14244         const y2 = p2[j2], hi = x2 + y2, lo = Math.abs(x2) < Math.abs(y2) ? x2 - (hi - y2) : y2 - (hi - x2);
14245         if (lo) p2[i3++] = lo;
14246         x2 = hi;
14247       }
14248       p2[i3] = x2;
14249       this._n = i3 + 1;
14250       return this;
14251     }
14252     valueOf() {
14253       const p2 = this._partials;
14254       let n3 = this._n, x2, y2, lo, hi = 0;
14255       if (n3 > 0) {
14256         hi = p2[--n3];
14257         while (n3 > 0) {
14258           x2 = hi;
14259           y2 = p2[--n3];
14260           hi = x2 + y2;
14261           lo = y2 - (hi - x2);
14262           if (lo) break;
14263         }
14264         if (n3 > 0 && (lo < 0 && p2[n3 - 1] < 0 || lo > 0 && p2[n3 - 1] > 0)) {
14265           y2 = lo * 2;
14266           x2 = hi + y2;
14267           if (y2 == x2 - hi) hi = x2;
14268         }
14269       }
14270       return hi;
14271     }
14272   };
14273
14274   // node_modules/d3-array/src/sort.js
14275   function compareDefined(compare2 = ascending) {
14276     if (compare2 === ascending) return ascendingDefined;
14277     if (typeof compare2 !== "function") throw new TypeError("compare is not a function");
14278     return (a2, b2) => {
14279       const x2 = compare2(a2, b2);
14280       if (x2 || x2 === 0) return x2;
14281       return (compare2(b2, b2) === 0) - (compare2(a2, a2) === 0);
14282     };
14283   }
14284   function ascendingDefined(a2, b2) {
14285     return (a2 == null || !(a2 >= a2)) - (b2 == null || !(b2 >= b2)) || (a2 < b2 ? -1 : a2 > b2 ? 1 : 0);
14286   }
14287
14288   // node_modules/d3-array/src/ticks.js
14289   var e10 = Math.sqrt(50);
14290   var e5 = Math.sqrt(10);
14291   var e2 = Math.sqrt(2);
14292   function tickSpec(start2, stop, count) {
14293     const step = (stop - start2) / Math.max(0, count), power = Math.floor(Math.log10(step)), error = step / Math.pow(10, power), factor = error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1;
14294     let i1, i22, inc;
14295     if (power < 0) {
14296       inc = Math.pow(10, -power) / factor;
14297       i1 = Math.round(start2 * inc);
14298       i22 = Math.round(stop * inc);
14299       if (i1 / inc < start2) ++i1;
14300       if (i22 / inc > stop) --i22;
14301       inc = -inc;
14302     } else {
14303       inc = Math.pow(10, power) * factor;
14304       i1 = Math.round(start2 / inc);
14305       i22 = Math.round(stop / inc);
14306       if (i1 * inc < start2) ++i1;
14307       if (i22 * inc > stop) --i22;
14308     }
14309     if (i22 < i1 && 0.5 <= count && count < 2) return tickSpec(start2, stop, count * 2);
14310     return [i1, i22, inc];
14311   }
14312   function ticks(start2, stop, count) {
14313     stop = +stop, start2 = +start2, count = +count;
14314     if (!(count > 0)) return [];
14315     if (start2 === stop) return [start2];
14316     const reverse = stop < start2, [i1, i22, inc] = reverse ? tickSpec(stop, start2, count) : tickSpec(start2, stop, count);
14317     if (!(i22 >= i1)) return [];
14318     const n3 = i22 - i1 + 1, ticks2 = new Array(n3);
14319     if (reverse) {
14320       if (inc < 0) for (let i3 = 0; i3 < n3; ++i3) ticks2[i3] = (i22 - i3) / -inc;
14321       else for (let i3 = 0; i3 < n3; ++i3) ticks2[i3] = (i22 - i3) * inc;
14322     } else {
14323       if (inc < 0) for (let i3 = 0; i3 < n3; ++i3) ticks2[i3] = (i1 + i3) / -inc;
14324       else for (let i3 = 0; i3 < n3; ++i3) ticks2[i3] = (i1 + i3) * inc;
14325     }
14326     return ticks2;
14327   }
14328   function tickIncrement(start2, stop, count) {
14329     stop = +stop, start2 = +start2, count = +count;
14330     return tickSpec(start2, stop, count)[2];
14331   }
14332   function tickStep(start2, stop, count) {
14333     stop = +stop, start2 = +start2, count = +count;
14334     const reverse = stop < start2, inc = reverse ? tickIncrement(stop, start2, count) : tickIncrement(start2, stop, count);
14335     return (reverse ? -1 : 1) * (inc < 0 ? 1 / -inc : inc);
14336   }
14337
14338   // node_modules/d3-array/src/max.js
14339   function max(values, valueof) {
14340     let max3;
14341     if (valueof === void 0) {
14342       for (const value of values) {
14343         if (value != null && (max3 < value || max3 === void 0 && value >= value)) {
14344           max3 = value;
14345         }
14346       }
14347     } else {
14348       let index = -1;
14349       for (let value of values) {
14350         if ((value = valueof(value, ++index, values)) != null && (max3 < value || max3 === void 0 && value >= value)) {
14351           max3 = value;
14352         }
14353       }
14354     }
14355     return max3;
14356   }
14357
14358   // node_modules/d3-array/src/min.js
14359   function min(values, valueof) {
14360     let min3;
14361     if (valueof === void 0) {
14362       for (const value of values) {
14363         if (value != null && (min3 > value || min3 === void 0 && value >= value)) {
14364           min3 = value;
14365         }
14366       }
14367     } else {
14368       let index = -1;
14369       for (let value of values) {
14370         if ((value = valueof(value, ++index, values)) != null && (min3 > value || min3 === void 0 && value >= value)) {
14371           min3 = value;
14372         }
14373       }
14374     }
14375     return min3;
14376   }
14377
14378   // node_modules/d3-array/src/quickselect.js
14379   function quickselect(array2, k2, left = 0, right = Infinity, compare2) {
14380     k2 = Math.floor(k2);
14381     left = Math.floor(Math.max(0, left));
14382     right = Math.floor(Math.min(array2.length - 1, right));
14383     if (!(left <= k2 && k2 <= right)) return array2;
14384     compare2 = compare2 === void 0 ? ascendingDefined : compareDefined(compare2);
14385     while (right > left) {
14386       if (right - left > 600) {
14387         const n3 = right - left + 1;
14388         const m2 = k2 - left + 1;
14389         const z2 = Math.log(n3);
14390         const s2 = 0.5 * Math.exp(2 * z2 / 3);
14391         const sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1);
14392         const newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd));
14393         const newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd));
14394         quickselect(array2, k2, newLeft, newRight, compare2);
14395       }
14396       const t2 = array2[k2];
14397       let i3 = left;
14398       let j2 = right;
14399       swap(array2, left, k2);
14400       if (compare2(array2[right], t2) > 0) swap(array2, left, right);
14401       while (i3 < j2) {
14402         swap(array2, i3, j2), ++i3, --j2;
14403         while (compare2(array2[i3], t2) < 0) ++i3;
14404         while (compare2(array2[j2], t2) > 0) --j2;
14405       }
14406       if (compare2(array2[left], t2) === 0) swap(array2, left, j2);
14407       else ++j2, swap(array2, j2, right);
14408       if (j2 <= k2) left = j2 + 1;
14409       if (k2 <= j2) right = j2 - 1;
14410     }
14411     return array2;
14412   }
14413   function swap(array2, i3, j2) {
14414     const t2 = array2[i3];
14415     array2[i3] = array2[j2];
14416     array2[j2] = t2;
14417   }
14418
14419   // node_modules/d3-array/src/quantile.js
14420   function quantile(values, p2, valueof) {
14421     values = Float64Array.from(numbers(values, valueof));
14422     if (!(n3 = values.length) || isNaN(p2 = +p2)) return;
14423     if (p2 <= 0 || n3 < 2) return min(values);
14424     if (p2 >= 1) return max(values);
14425     var n3, i3 = (n3 - 1) * p2, i0 = Math.floor(i3), value0 = max(quickselect(values, i0).subarray(0, i0 + 1)), value1 = min(values.subarray(i0 + 1));
14426     return value0 + (value1 - value0) * (i3 - i0);
14427   }
14428
14429   // node_modules/d3-array/src/median.js
14430   function median(values, valueof) {
14431     return quantile(values, 0.5, valueof);
14432   }
14433
14434   // node_modules/d3-array/src/merge.js
14435   function* flatten(arrays) {
14436     for (const array2 of arrays) {
14437       yield* __yieldStar(array2);
14438     }
14439   }
14440   function merge(arrays) {
14441     return Array.from(flatten(arrays));
14442   }
14443
14444   // node_modules/d3-array/src/pairs.js
14445   function pairs(values, pairof = pair) {
14446     const pairs2 = [];
14447     let previous;
14448     let first = false;
14449     for (const value of values) {
14450       if (first) pairs2.push(pairof(previous, value));
14451       previous = value;
14452       first = true;
14453     }
14454     return pairs2;
14455   }
14456   function pair(a2, b2) {
14457     return [a2, b2];
14458   }
14459
14460   // node_modules/d3-array/src/range.js
14461   function range(start2, stop, step) {
14462     start2 = +start2, stop = +stop, step = (n3 = arguments.length) < 2 ? (stop = start2, start2 = 0, 1) : n3 < 3 ? 1 : +step;
14463     var i3 = -1, n3 = Math.max(0, Math.ceil((stop - start2) / step)) | 0, range3 = new Array(n3);
14464     while (++i3 < n3) {
14465       range3[i3] = start2 + i3 * step;
14466     }
14467     return range3;
14468   }
14469
14470   // node_modules/d3-geo/src/math.js
14471   var epsilon = 1e-6;
14472   var epsilon2 = 1e-12;
14473   var pi = Math.PI;
14474   var halfPi = pi / 2;
14475   var quarterPi = pi / 4;
14476   var tau = pi * 2;
14477   var degrees = 180 / pi;
14478   var radians = pi / 180;
14479   var abs = Math.abs;
14480   var atan = Math.atan;
14481   var atan2 = Math.atan2;
14482   var cos = Math.cos;
14483   var exp = Math.exp;
14484   var log = Math.log;
14485   var sin = Math.sin;
14486   var sign = Math.sign || function(x2) {
14487     return x2 > 0 ? 1 : x2 < 0 ? -1 : 0;
14488   };
14489   var sqrt = Math.sqrt;
14490   var tan = Math.tan;
14491   function acos(x2) {
14492     return x2 > 1 ? 0 : x2 < -1 ? pi : Math.acos(x2);
14493   }
14494   function asin(x2) {
14495     return x2 > 1 ? halfPi : x2 < -1 ? -halfPi : Math.asin(x2);
14496   }
14497
14498   // node_modules/d3-geo/src/noop.js
14499   function noop() {
14500   }
14501
14502   // node_modules/d3-geo/src/stream.js
14503   function streamGeometry(geometry, stream) {
14504     if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
14505       streamGeometryType[geometry.type](geometry, stream);
14506     }
14507   }
14508   var streamObjectType = {
14509     Feature: function(object, stream) {
14510       streamGeometry(object.geometry, stream);
14511     },
14512     FeatureCollection: function(object, stream) {
14513       var features = object.features, i3 = -1, n3 = features.length;
14514       while (++i3 < n3) streamGeometry(features[i3].geometry, stream);
14515     }
14516   };
14517   var streamGeometryType = {
14518     Sphere: function(object, stream) {
14519       stream.sphere();
14520     },
14521     Point: function(object, stream) {
14522       object = object.coordinates;
14523       stream.point(object[0], object[1], object[2]);
14524     },
14525     MultiPoint: function(object, stream) {
14526       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
14527       while (++i3 < n3) object = coordinates[i3], stream.point(object[0], object[1], object[2]);
14528     },
14529     LineString: function(object, stream) {
14530       streamLine(object.coordinates, stream, 0);
14531     },
14532     MultiLineString: function(object, stream) {
14533       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
14534       while (++i3 < n3) streamLine(coordinates[i3], stream, 0);
14535     },
14536     Polygon: function(object, stream) {
14537       streamPolygon(object.coordinates, stream);
14538     },
14539     MultiPolygon: function(object, stream) {
14540       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
14541       while (++i3 < n3) streamPolygon(coordinates[i3], stream);
14542     },
14543     GeometryCollection: function(object, stream) {
14544       var geometries = object.geometries, i3 = -1, n3 = geometries.length;
14545       while (++i3 < n3) streamGeometry(geometries[i3], stream);
14546     }
14547   };
14548   function streamLine(coordinates, stream, closed) {
14549     var i3 = -1, n3 = coordinates.length - closed, coordinate;
14550     stream.lineStart();
14551     while (++i3 < n3) coordinate = coordinates[i3], stream.point(coordinate[0], coordinate[1], coordinate[2]);
14552     stream.lineEnd();
14553   }
14554   function streamPolygon(coordinates, stream) {
14555     var i3 = -1, n3 = coordinates.length;
14556     stream.polygonStart();
14557     while (++i3 < n3) streamLine(coordinates[i3], stream, 1);
14558     stream.polygonEnd();
14559   }
14560   function stream_default(object, stream) {
14561     if (object && streamObjectType.hasOwnProperty(object.type)) {
14562       streamObjectType[object.type](object, stream);
14563     } else {
14564       streamGeometry(object, stream);
14565     }
14566   }
14567
14568   // node_modules/d3-geo/src/area.js
14569   var areaRingSum = new Adder();
14570   var areaSum = new Adder();
14571   var lambda00;
14572   var phi00;
14573   var lambda0;
14574   var cosPhi0;
14575   var sinPhi0;
14576   var areaStream = {
14577     point: noop,
14578     lineStart: noop,
14579     lineEnd: noop,
14580     polygonStart: function() {
14581       areaRingSum = new Adder();
14582       areaStream.lineStart = areaRingStart;
14583       areaStream.lineEnd = areaRingEnd;
14584     },
14585     polygonEnd: function() {
14586       var areaRing = +areaRingSum;
14587       areaSum.add(areaRing < 0 ? tau + areaRing : areaRing);
14588       this.lineStart = this.lineEnd = this.point = noop;
14589     },
14590     sphere: function() {
14591       areaSum.add(tau);
14592     }
14593   };
14594   function areaRingStart() {
14595     areaStream.point = areaPointFirst;
14596   }
14597   function areaRingEnd() {
14598     areaPoint(lambda00, phi00);
14599   }
14600   function areaPointFirst(lambda, phi) {
14601     areaStream.point = areaPoint;
14602     lambda00 = lambda, phi00 = phi;
14603     lambda *= radians, phi *= radians;
14604     lambda0 = lambda, cosPhi0 = cos(phi = phi / 2 + quarterPi), sinPhi0 = sin(phi);
14605   }
14606   function areaPoint(lambda, phi) {
14607     lambda *= radians, phi *= radians;
14608     phi = phi / 2 + quarterPi;
14609     var dLambda = lambda - lambda0, sdLambda = dLambda >= 0 ? 1 : -1, adLambda = sdLambda * dLambda, cosPhi = cos(phi), sinPhi = sin(phi), k2 = sinPhi0 * sinPhi, u2 = cosPhi0 * cosPhi + k2 * cos(adLambda), v2 = k2 * sdLambda * sin(adLambda);
14610     areaRingSum.add(atan2(v2, u2));
14611     lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
14612   }
14613   function area_default(object) {
14614     areaSum = new Adder();
14615     stream_default(object, areaStream);
14616     return areaSum * 2;
14617   }
14618
14619   // node_modules/d3-geo/src/cartesian.js
14620   function spherical(cartesian2) {
14621     return [atan2(cartesian2[1], cartesian2[0]), asin(cartesian2[2])];
14622   }
14623   function cartesian(spherical2) {
14624     var lambda = spherical2[0], phi = spherical2[1], cosPhi = cos(phi);
14625     return [cosPhi * cos(lambda), cosPhi * sin(lambda), sin(phi)];
14626   }
14627   function cartesianDot(a2, b2) {
14628     return a2[0] * b2[0] + a2[1] * b2[1] + a2[2] * b2[2];
14629   }
14630   function cartesianCross(a2, b2) {
14631     return [a2[1] * b2[2] - a2[2] * b2[1], a2[2] * b2[0] - a2[0] * b2[2], a2[0] * b2[1] - a2[1] * b2[0]];
14632   }
14633   function cartesianAddInPlace(a2, b2) {
14634     a2[0] += b2[0], a2[1] += b2[1], a2[2] += b2[2];
14635   }
14636   function cartesianScale(vector, k2) {
14637     return [vector[0] * k2, vector[1] * k2, vector[2] * k2];
14638   }
14639   function cartesianNormalizeInPlace(d2) {
14640     var l2 = sqrt(d2[0] * d2[0] + d2[1] * d2[1] + d2[2] * d2[2]);
14641     d2[0] /= l2, d2[1] /= l2, d2[2] /= l2;
14642   }
14643
14644   // node_modules/d3-geo/src/bounds.js
14645   var lambda02;
14646   var phi0;
14647   var lambda1;
14648   var phi1;
14649   var lambda2;
14650   var lambda002;
14651   var phi002;
14652   var p0;
14653   var deltaSum;
14654   var ranges;
14655   var range2;
14656   var boundsStream = {
14657     point: boundsPoint,
14658     lineStart: boundsLineStart,
14659     lineEnd: boundsLineEnd,
14660     polygonStart: function() {
14661       boundsStream.point = boundsRingPoint;
14662       boundsStream.lineStart = boundsRingStart;
14663       boundsStream.lineEnd = boundsRingEnd;
14664       deltaSum = new Adder();
14665       areaStream.polygonStart();
14666     },
14667     polygonEnd: function() {
14668       areaStream.polygonEnd();
14669       boundsStream.point = boundsPoint;
14670       boundsStream.lineStart = boundsLineStart;
14671       boundsStream.lineEnd = boundsLineEnd;
14672       if (areaRingSum < 0) lambda02 = -(lambda1 = 180), phi0 = -(phi1 = 90);
14673       else if (deltaSum > epsilon) phi1 = 90;
14674       else if (deltaSum < -epsilon) phi0 = -90;
14675       range2[0] = lambda02, range2[1] = lambda1;
14676     },
14677     sphere: function() {
14678       lambda02 = -(lambda1 = 180), phi0 = -(phi1 = 90);
14679     }
14680   };
14681   function boundsPoint(lambda, phi) {
14682     ranges.push(range2 = [lambda02 = lambda, lambda1 = lambda]);
14683     if (phi < phi0) phi0 = phi;
14684     if (phi > phi1) phi1 = phi;
14685   }
14686   function linePoint(lambda, phi) {
14687     var p2 = cartesian([lambda * radians, phi * radians]);
14688     if (p0) {
14689       var normal = cartesianCross(p0, p2), equatorial = [normal[1], -normal[0], 0], inflection = cartesianCross(equatorial, normal);
14690       cartesianNormalizeInPlace(inflection);
14691       inflection = spherical(inflection);
14692       var delta = lambda - lambda2, sign2 = delta > 0 ? 1 : -1, lambdai = inflection[0] * degrees * sign2, phii, antimeridian = abs(delta) > 180;
14693       if (antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
14694         phii = inflection[1] * degrees;
14695         if (phii > phi1) phi1 = phii;
14696       } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
14697         phii = -inflection[1] * degrees;
14698         if (phii < phi0) phi0 = phii;
14699       } else {
14700         if (phi < phi0) phi0 = phi;
14701         if (phi > phi1) phi1 = phi;
14702       }
14703       if (antimeridian) {
14704         if (lambda < lambda2) {
14705           if (angle(lambda02, lambda) > angle(lambda02, lambda1)) lambda1 = lambda;
14706         } else {
14707           if (angle(lambda, lambda1) > angle(lambda02, lambda1)) lambda02 = lambda;
14708         }
14709       } else {
14710         if (lambda1 >= lambda02) {
14711           if (lambda < lambda02) lambda02 = lambda;
14712           if (lambda > lambda1) lambda1 = lambda;
14713         } else {
14714           if (lambda > lambda2) {
14715             if (angle(lambda02, lambda) > angle(lambda02, lambda1)) lambda1 = lambda;
14716           } else {
14717             if (angle(lambda, lambda1) > angle(lambda02, lambda1)) lambda02 = lambda;
14718           }
14719         }
14720       }
14721     } else {
14722       ranges.push(range2 = [lambda02 = lambda, lambda1 = lambda]);
14723     }
14724     if (phi < phi0) phi0 = phi;
14725     if (phi > phi1) phi1 = phi;
14726     p0 = p2, lambda2 = lambda;
14727   }
14728   function boundsLineStart() {
14729     boundsStream.point = linePoint;
14730   }
14731   function boundsLineEnd() {
14732     range2[0] = lambda02, range2[1] = lambda1;
14733     boundsStream.point = boundsPoint;
14734     p0 = null;
14735   }
14736   function boundsRingPoint(lambda, phi) {
14737     if (p0) {
14738       var delta = lambda - lambda2;
14739       deltaSum.add(abs(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta);
14740     } else {
14741       lambda002 = lambda, phi002 = phi;
14742     }
14743     areaStream.point(lambda, phi);
14744     linePoint(lambda, phi);
14745   }
14746   function boundsRingStart() {
14747     areaStream.lineStart();
14748   }
14749   function boundsRingEnd() {
14750     boundsRingPoint(lambda002, phi002);
14751     areaStream.lineEnd();
14752     if (abs(deltaSum) > epsilon) lambda02 = -(lambda1 = 180);
14753     range2[0] = lambda02, range2[1] = lambda1;
14754     p0 = null;
14755   }
14756   function angle(lambda04, lambda12) {
14757     return (lambda12 -= lambda04) < 0 ? lambda12 + 360 : lambda12;
14758   }
14759   function rangeCompare(a2, b2) {
14760     return a2[0] - b2[0];
14761   }
14762   function rangeContains(range3, x2) {
14763     return range3[0] <= range3[1] ? range3[0] <= x2 && x2 <= range3[1] : x2 < range3[0] || range3[1] < x2;
14764   }
14765   function bounds_default(feature3) {
14766     var i3, n3, a2, b2, merged, deltaMax, delta;
14767     phi1 = lambda1 = -(lambda02 = phi0 = Infinity);
14768     ranges = [];
14769     stream_default(feature3, boundsStream);
14770     if (n3 = ranges.length) {
14771       ranges.sort(rangeCompare);
14772       for (i3 = 1, a2 = ranges[0], merged = [a2]; i3 < n3; ++i3) {
14773         b2 = ranges[i3];
14774         if (rangeContains(a2, b2[0]) || rangeContains(a2, b2[1])) {
14775           if (angle(a2[0], b2[1]) > angle(a2[0], a2[1])) a2[1] = b2[1];
14776           if (angle(b2[0], a2[1]) > angle(a2[0], a2[1])) a2[0] = b2[0];
14777         } else {
14778           merged.push(a2 = b2);
14779         }
14780       }
14781       for (deltaMax = -Infinity, n3 = merged.length - 1, i3 = 0, a2 = merged[n3]; i3 <= n3; a2 = b2, ++i3) {
14782         b2 = merged[i3];
14783         if ((delta = angle(a2[1], b2[0])) > deltaMax) deltaMax = delta, lambda02 = b2[0], lambda1 = a2[1];
14784       }
14785     }
14786     ranges = range2 = null;
14787     return lambda02 === Infinity || phi0 === Infinity ? [[NaN, NaN], [NaN, NaN]] : [[lambda02, phi0], [lambda1, phi1]];
14788   }
14789
14790   // node_modules/d3-geo/src/compose.js
14791   function compose_default(a2, b2) {
14792     function compose(x2, y2) {
14793       return x2 = a2(x2, y2), b2(x2[0], x2[1]);
14794     }
14795     if (a2.invert && b2.invert) compose.invert = function(x2, y2) {
14796       return x2 = b2.invert(x2, y2), x2 && a2.invert(x2[0], x2[1]);
14797     };
14798     return compose;
14799   }
14800
14801   // node_modules/d3-geo/src/rotation.js
14802   function rotationIdentity(lambda, phi) {
14803     if (abs(lambda) > pi) lambda -= Math.round(lambda / tau) * tau;
14804     return [lambda, phi];
14805   }
14806   rotationIdentity.invert = rotationIdentity;
14807   function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
14808     return (deltaLambda %= tau) ? deltaPhi || deltaGamma ? compose_default(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma)) : rotationLambda(deltaLambda) : deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma) : rotationIdentity;
14809   }
14810   function forwardRotationLambda(deltaLambda) {
14811     return function(lambda, phi) {
14812       lambda += deltaLambda;
14813       if (abs(lambda) > pi) lambda -= Math.round(lambda / tau) * tau;
14814       return [lambda, phi];
14815     };
14816   }
14817   function rotationLambda(deltaLambda) {
14818     var rotation = forwardRotationLambda(deltaLambda);
14819     rotation.invert = forwardRotationLambda(-deltaLambda);
14820     return rotation;
14821   }
14822   function rotationPhiGamma(deltaPhi, deltaGamma) {
14823     var cosDeltaPhi = cos(deltaPhi), sinDeltaPhi = sin(deltaPhi), cosDeltaGamma = cos(deltaGamma), sinDeltaGamma = sin(deltaGamma);
14824     function rotation(lambda, phi) {
14825       var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z2 = sin(phi), k2 = z2 * cosDeltaPhi + x2 * sinDeltaPhi;
14826       return [
14827         atan2(y2 * cosDeltaGamma - k2 * sinDeltaGamma, x2 * cosDeltaPhi - z2 * sinDeltaPhi),
14828         asin(k2 * cosDeltaGamma + y2 * sinDeltaGamma)
14829       ];
14830     }
14831     rotation.invert = function(lambda, phi) {
14832       var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z2 = sin(phi), k2 = z2 * cosDeltaGamma - y2 * sinDeltaGamma;
14833       return [
14834         atan2(y2 * cosDeltaGamma + z2 * sinDeltaGamma, x2 * cosDeltaPhi + k2 * sinDeltaPhi),
14835         asin(k2 * cosDeltaPhi - x2 * sinDeltaPhi)
14836       ];
14837     };
14838     return rotation;
14839   }
14840   function rotation_default(rotate) {
14841     rotate = rotateRadians(rotate[0] * radians, rotate[1] * radians, rotate.length > 2 ? rotate[2] * radians : 0);
14842     function forward(coordinates) {
14843       coordinates = rotate(coordinates[0] * radians, coordinates[1] * radians);
14844       return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
14845     }
14846     forward.invert = function(coordinates) {
14847       coordinates = rotate.invert(coordinates[0] * radians, coordinates[1] * radians);
14848       return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
14849     };
14850     return forward;
14851   }
14852
14853   // node_modules/d3-geo/src/circle.js
14854   function circleStream(stream, radius, delta, direction, t0, t1) {
14855     if (!delta) return;
14856     var cosRadius = cos(radius), sinRadius = sin(radius), step = direction * delta;
14857     if (t0 == null) {
14858       t0 = radius + direction * tau;
14859       t1 = radius - step / 2;
14860     } else {
14861       t0 = circleRadius(cosRadius, t0);
14862       t1 = circleRadius(cosRadius, t1);
14863       if (direction > 0 ? t0 < t1 : t0 > t1) t0 += direction * tau;
14864     }
14865     for (var point, t2 = t0; direction > 0 ? t2 > t1 : t2 < t1; t2 -= step) {
14866       point = spherical([cosRadius, -sinRadius * cos(t2), -sinRadius * sin(t2)]);
14867       stream.point(point[0], point[1]);
14868     }
14869   }
14870   function circleRadius(cosRadius, point) {
14871     point = cartesian(point), point[0] -= cosRadius;
14872     cartesianNormalizeInPlace(point);
14873     var radius = acos(-point[1]);
14874     return ((-point[2] < 0 ? -radius : radius) + tau - epsilon) % tau;
14875   }
14876
14877   // node_modules/d3-geo/src/clip/buffer.js
14878   function buffer_default() {
14879     var lines = [], line;
14880     return {
14881       point: function(x2, y2, m2) {
14882         line.push([x2, y2, m2]);
14883       },
14884       lineStart: function() {
14885         lines.push(line = []);
14886       },
14887       lineEnd: noop,
14888       rejoin: function() {
14889         if (lines.length > 1) lines.push(lines.pop().concat(lines.shift()));
14890       },
14891       result: function() {
14892         var result = lines;
14893         lines = [];
14894         line = null;
14895         return result;
14896       }
14897     };
14898   }
14899
14900   // node_modules/d3-geo/src/pointEqual.js
14901   function pointEqual_default(a2, b2) {
14902     return abs(a2[0] - b2[0]) < epsilon && abs(a2[1] - b2[1]) < epsilon;
14903   }
14904
14905   // node_modules/d3-geo/src/clip/rejoin.js
14906   function Intersection(point, points, other2, entry) {
14907     this.x = point;
14908     this.z = points;
14909     this.o = other2;
14910     this.e = entry;
14911     this.v = false;
14912     this.n = this.p = null;
14913   }
14914   function rejoin_default(segments, compareIntersection2, startInside, interpolate, stream) {
14915     var subject = [], clip = [], i3, n3;
14916     segments.forEach(function(segment) {
14917       if ((n4 = segment.length - 1) <= 0) return;
14918       var n4, p02 = segment[0], p1 = segment[n4], x2;
14919       if (pointEqual_default(p02, p1)) {
14920         if (!p02[2] && !p1[2]) {
14921           stream.lineStart();
14922           for (i3 = 0; i3 < n4; ++i3) stream.point((p02 = segment[i3])[0], p02[1]);
14923           stream.lineEnd();
14924           return;
14925         }
14926         p1[0] += 2 * epsilon;
14927       }
14928       subject.push(x2 = new Intersection(p02, segment, null, true));
14929       clip.push(x2.o = new Intersection(p02, null, x2, false));
14930       subject.push(x2 = new Intersection(p1, segment, null, false));
14931       clip.push(x2.o = new Intersection(p1, null, x2, true));
14932     });
14933     if (!subject.length) return;
14934     clip.sort(compareIntersection2);
14935     link(subject);
14936     link(clip);
14937     for (i3 = 0, n3 = clip.length; i3 < n3; ++i3) {
14938       clip[i3].e = startInside = !startInside;
14939     }
14940     var start2 = subject[0], points, point;
14941     while (1) {
14942       var current = start2, isSubject = true;
14943       while (current.v) if ((current = current.n) === start2) return;
14944       points = current.z;
14945       stream.lineStart();
14946       do {
14947         current.v = current.o.v = true;
14948         if (current.e) {
14949           if (isSubject) {
14950             for (i3 = 0, n3 = points.length; i3 < n3; ++i3) stream.point((point = points[i3])[0], point[1]);
14951           } else {
14952             interpolate(current.x, current.n.x, 1, stream);
14953           }
14954           current = current.n;
14955         } else {
14956           if (isSubject) {
14957             points = current.p.z;
14958             for (i3 = points.length - 1; i3 >= 0; --i3) stream.point((point = points[i3])[0], point[1]);
14959           } else {
14960             interpolate(current.x, current.p.x, -1, stream);
14961           }
14962           current = current.p;
14963         }
14964         current = current.o;
14965         points = current.z;
14966         isSubject = !isSubject;
14967       } while (!current.v);
14968       stream.lineEnd();
14969     }
14970   }
14971   function link(array2) {
14972     if (!(n3 = array2.length)) return;
14973     var n3, i3 = 0, a2 = array2[0], b2;
14974     while (++i3 < n3) {
14975       a2.n = b2 = array2[i3];
14976       b2.p = a2;
14977       a2 = b2;
14978     }
14979     a2.n = b2 = array2[0];
14980     b2.p = a2;
14981   }
14982
14983   // node_modules/d3-geo/src/polygonContains.js
14984   function longitude(point) {
14985     return abs(point[0]) <= pi ? point[0] : sign(point[0]) * ((abs(point[0]) + pi) % tau - pi);
14986   }
14987   function polygonContains_default(polygon2, point) {
14988     var lambda = longitude(point), phi = point[1], sinPhi = sin(phi), normal = [sin(lambda), -cos(lambda), 0], angle2 = 0, winding = 0;
14989     var sum = new Adder();
14990     if (sinPhi === 1) phi = halfPi + epsilon;
14991     else if (sinPhi === -1) phi = -halfPi - epsilon;
14992     for (var i3 = 0, n3 = polygon2.length; i3 < n3; ++i3) {
14993       if (!(m2 = (ring = polygon2[i3]).length)) continue;
14994       var ring, m2, point0 = ring[m2 - 1], lambda04 = longitude(point0), phi02 = point0[1] / 2 + quarterPi, sinPhi03 = sin(phi02), cosPhi03 = cos(phi02);
14995       for (var j2 = 0; j2 < m2; ++j2, lambda04 = lambda12, sinPhi03 = sinPhi1, cosPhi03 = cosPhi1, point0 = point1) {
14996         var point1 = ring[j2], lambda12 = longitude(point1), phi12 = point1[1] / 2 + quarterPi, sinPhi1 = sin(phi12), cosPhi1 = cos(phi12), delta = lambda12 - lambda04, sign2 = delta >= 0 ? 1 : -1, absDelta = sign2 * delta, antimeridian = absDelta > pi, k2 = sinPhi03 * sinPhi1;
14997         sum.add(atan2(k2 * sign2 * sin(absDelta), cosPhi03 * cosPhi1 + k2 * cos(absDelta)));
14998         angle2 += antimeridian ? delta + sign2 * tau : delta;
14999         if (antimeridian ^ lambda04 >= lambda ^ lambda12 >= lambda) {
15000           var arc = cartesianCross(cartesian(point0), cartesian(point1));
15001           cartesianNormalizeInPlace(arc);
15002           var intersection2 = cartesianCross(normal, arc);
15003           cartesianNormalizeInPlace(intersection2);
15004           var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection2[2]);
15005           if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
15006             winding += antimeridian ^ delta >= 0 ? 1 : -1;
15007           }
15008         }
15009       }
15010     }
15011     return (angle2 < -epsilon || angle2 < epsilon && sum < -epsilon2) ^ winding & 1;
15012   }
15013
15014   // node_modules/d3-geo/src/clip/index.js
15015   function clip_default(pointVisible, clipLine, interpolate, start2) {
15016     return function(sink) {
15017       var line = clipLine(sink), ringBuffer = buffer_default(), ringSink = clipLine(ringBuffer), polygonStarted = false, polygon2, segments, ring;
15018       var clip = {
15019         point,
15020         lineStart,
15021         lineEnd,
15022         polygonStart: function() {
15023           clip.point = pointRing;
15024           clip.lineStart = ringStart;
15025           clip.lineEnd = ringEnd;
15026           segments = [];
15027           polygon2 = [];
15028         },
15029         polygonEnd: function() {
15030           clip.point = point;
15031           clip.lineStart = lineStart;
15032           clip.lineEnd = lineEnd;
15033           segments = merge(segments);
15034           var startInside = polygonContains_default(polygon2, start2);
15035           if (segments.length) {
15036             if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
15037             rejoin_default(segments, compareIntersection, startInside, interpolate, sink);
15038           } else if (startInside) {
15039             if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
15040             sink.lineStart();
15041             interpolate(null, null, 1, sink);
15042             sink.lineEnd();
15043           }
15044           if (polygonStarted) sink.polygonEnd(), polygonStarted = false;
15045           segments = polygon2 = null;
15046         },
15047         sphere: function() {
15048           sink.polygonStart();
15049           sink.lineStart();
15050           interpolate(null, null, 1, sink);
15051           sink.lineEnd();
15052           sink.polygonEnd();
15053         }
15054       };
15055       function point(lambda, phi) {
15056         if (pointVisible(lambda, phi)) sink.point(lambda, phi);
15057       }
15058       function pointLine(lambda, phi) {
15059         line.point(lambda, phi);
15060       }
15061       function lineStart() {
15062         clip.point = pointLine;
15063         line.lineStart();
15064       }
15065       function lineEnd() {
15066         clip.point = point;
15067         line.lineEnd();
15068       }
15069       function pointRing(lambda, phi) {
15070         ring.push([lambda, phi]);
15071         ringSink.point(lambda, phi);
15072       }
15073       function ringStart() {
15074         ringSink.lineStart();
15075         ring = [];
15076       }
15077       function ringEnd() {
15078         pointRing(ring[0][0], ring[0][1]);
15079         ringSink.lineEnd();
15080         var clean2 = ringSink.clean(), ringSegments = ringBuffer.result(), i3, n3 = ringSegments.length, m2, segment, point2;
15081         ring.pop();
15082         polygon2.push(ring);
15083         ring = null;
15084         if (!n3) return;
15085         if (clean2 & 1) {
15086           segment = ringSegments[0];
15087           if ((m2 = segment.length - 1) > 0) {
15088             if (!polygonStarted) sink.polygonStart(), polygonStarted = true;
15089             sink.lineStart();
15090             for (i3 = 0; i3 < m2; ++i3) sink.point((point2 = segment[i3])[0], point2[1]);
15091             sink.lineEnd();
15092           }
15093           return;
15094         }
15095         if (n3 > 1 && clean2 & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
15096         segments.push(ringSegments.filter(validSegment));
15097       }
15098       return clip;
15099     };
15100   }
15101   function validSegment(segment) {
15102     return segment.length > 1;
15103   }
15104   function compareIntersection(a2, b2) {
15105     return ((a2 = a2.x)[0] < 0 ? a2[1] - halfPi - epsilon : halfPi - a2[1]) - ((b2 = b2.x)[0] < 0 ? b2[1] - halfPi - epsilon : halfPi - b2[1]);
15106   }
15107
15108   // node_modules/d3-geo/src/clip/antimeridian.js
15109   var antimeridian_default = clip_default(
15110     function() {
15111       return true;
15112     },
15113     clipAntimeridianLine,
15114     clipAntimeridianInterpolate,
15115     [-pi, -halfPi]
15116   );
15117   function clipAntimeridianLine(stream) {
15118     var lambda04 = NaN, phi02 = NaN, sign0 = NaN, clean2;
15119     return {
15120       lineStart: function() {
15121         stream.lineStart();
15122         clean2 = 1;
15123       },
15124       point: function(lambda12, phi12) {
15125         var sign1 = lambda12 > 0 ? pi : -pi, delta = abs(lambda12 - lambda04);
15126         if (abs(delta - pi) < epsilon) {
15127           stream.point(lambda04, phi02 = (phi02 + phi12) / 2 > 0 ? halfPi : -halfPi);
15128           stream.point(sign0, phi02);
15129           stream.lineEnd();
15130           stream.lineStart();
15131           stream.point(sign1, phi02);
15132           stream.point(lambda12, phi02);
15133           clean2 = 0;
15134         } else if (sign0 !== sign1 && delta >= pi) {
15135           if (abs(lambda04 - sign0) < epsilon) lambda04 -= sign0 * epsilon;
15136           if (abs(lambda12 - sign1) < epsilon) lambda12 -= sign1 * epsilon;
15137           phi02 = clipAntimeridianIntersect(lambda04, phi02, lambda12, phi12);
15138           stream.point(sign0, phi02);
15139           stream.lineEnd();
15140           stream.lineStart();
15141           stream.point(sign1, phi02);
15142           clean2 = 0;
15143         }
15144         stream.point(lambda04 = lambda12, phi02 = phi12);
15145         sign0 = sign1;
15146       },
15147       lineEnd: function() {
15148         stream.lineEnd();
15149         lambda04 = phi02 = NaN;
15150       },
15151       clean: function() {
15152         return 2 - clean2;
15153       }
15154     };
15155   }
15156   function clipAntimeridianIntersect(lambda04, phi02, lambda12, phi12) {
15157     var cosPhi03, cosPhi1, sinLambda0Lambda1 = sin(lambda04 - lambda12);
15158     return abs(sinLambda0Lambda1) > epsilon ? atan((sin(phi02) * (cosPhi1 = cos(phi12)) * sin(lambda12) - sin(phi12) * (cosPhi03 = cos(phi02)) * sin(lambda04)) / (cosPhi03 * cosPhi1 * sinLambda0Lambda1)) : (phi02 + phi12) / 2;
15159   }
15160   function clipAntimeridianInterpolate(from, to, direction, stream) {
15161     var phi;
15162     if (from == null) {
15163       phi = direction * halfPi;
15164       stream.point(-pi, phi);
15165       stream.point(0, phi);
15166       stream.point(pi, phi);
15167       stream.point(pi, 0);
15168       stream.point(pi, -phi);
15169       stream.point(0, -phi);
15170       stream.point(-pi, -phi);
15171       stream.point(-pi, 0);
15172       stream.point(-pi, phi);
15173     } else if (abs(from[0] - to[0]) > epsilon) {
15174       var lambda = from[0] < to[0] ? pi : -pi;
15175       phi = direction * lambda / 2;
15176       stream.point(-lambda, phi);
15177       stream.point(0, phi);
15178       stream.point(lambda, phi);
15179     } else {
15180       stream.point(to[0], to[1]);
15181     }
15182   }
15183
15184   // node_modules/d3-geo/src/clip/circle.js
15185   function circle_default(radius) {
15186     var cr = cos(radius), delta = 2 * radians, smallRadius = cr > 0, notHemisphere = abs(cr) > epsilon;
15187     function interpolate(from, to, direction, stream) {
15188       circleStream(stream, radius, delta, direction, from, to);
15189     }
15190     function visible(lambda, phi) {
15191       return cos(lambda) * cos(phi) > cr;
15192     }
15193     function clipLine(stream) {
15194       var point0, c0, v0, v00, clean2;
15195       return {
15196         lineStart: function() {
15197           v00 = v0 = false;
15198           clean2 = 1;
15199         },
15200         point: function(lambda, phi) {
15201           var point1 = [lambda, phi], point2, v2 = visible(lambda, phi), c2 = smallRadius ? v2 ? 0 : code(lambda, phi) : v2 ? code(lambda + (lambda < 0 ? pi : -pi), phi) : 0;
15202           if (!point0 && (v00 = v0 = v2)) stream.lineStart();
15203           if (v2 !== v0) {
15204             point2 = intersect2(point0, point1);
15205             if (!point2 || pointEqual_default(point0, point2) || pointEqual_default(point1, point2))
15206               point1[2] = 1;
15207           }
15208           if (v2 !== v0) {
15209             clean2 = 0;
15210             if (v2) {
15211               stream.lineStart();
15212               point2 = intersect2(point1, point0);
15213               stream.point(point2[0], point2[1]);
15214             } else {
15215               point2 = intersect2(point0, point1);
15216               stream.point(point2[0], point2[1], 2);
15217               stream.lineEnd();
15218             }
15219             point0 = point2;
15220           } else if (notHemisphere && point0 && smallRadius ^ v2) {
15221             var t2;
15222             if (!(c2 & c0) && (t2 = intersect2(point1, point0, true))) {
15223               clean2 = 0;
15224               if (smallRadius) {
15225                 stream.lineStart();
15226                 stream.point(t2[0][0], t2[0][1]);
15227                 stream.point(t2[1][0], t2[1][1]);
15228                 stream.lineEnd();
15229               } else {
15230                 stream.point(t2[1][0], t2[1][1]);
15231                 stream.lineEnd();
15232                 stream.lineStart();
15233                 stream.point(t2[0][0], t2[0][1], 3);
15234               }
15235             }
15236           }
15237           if (v2 && (!point0 || !pointEqual_default(point0, point1))) {
15238             stream.point(point1[0], point1[1]);
15239           }
15240           point0 = point1, v0 = v2, c0 = c2;
15241         },
15242         lineEnd: function() {
15243           if (v0) stream.lineEnd();
15244           point0 = null;
15245         },
15246         // Rejoin first and last segments if there were intersections and the first
15247         // and last points were visible.
15248         clean: function() {
15249           return clean2 | (v00 && v0) << 1;
15250         }
15251       };
15252     }
15253     function intersect2(a2, b2, two) {
15254       var pa = cartesian(a2), pb = cartesian(b2);
15255       var n1 = [1, 0, 0], n22 = cartesianCross(pa, pb), n2n2 = cartesianDot(n22, n22), n1n2 = n22[0], determinant = n2n2 - n1n2 * n1n2;
15256       if (!determinant) return !two && a2;
15257       var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = cartesianCross(n1, n22), A2 = cartesianScale(n1, c1), B2 = cartesianScale(n22, c2);
15258       cartesianAddInPlace(A2, B2);
15259       var u2 = n1xn2, w2 = cartesianDot(A2, u2), uu = cartesianDot(u2, u2), t2 = w2 * w2 - uu * (cartesianDot(A2, A2) - 1);
15260       if (t2 < 0) return;
15261       var t3 = sqrt(t2), q2 = cartesianScale(u2, (-w2 - t3) / uu);
15262       cartesianAddInPlace(q2, A2);
15263       q2 = spherical(q2);
15264       if (!two) return q2;
15265       var lambda04 = a2[0], lambda12 = b2[0], phi02 = a2[1], phi12 = b2[1], z2;
15266       if (lambda12 < lambda04) z2 = lambda04, lambda04 = lambda12, lambda12 = z2;
15267       var delta2 = lambda12 - lambda04, polar = abs(delta2 - pi) < epsilon, meridian = polar || delta2 < epsilon;
15268       if (!polar && phi12 < phi02) z2 = phi02, phi02 = phi12, phi12 = z2;
15269       if (meridian ? polar ? phi02 + phi12 > 0 ^ q2[1] < (abs(q2[0] - lambda04) < epsilon ? phi02 : phi12) : phi02 <= q2[1] && q2[1] <= phi12 : delta2 > pi ^ (lambda04 <= q2[0] && q2[0] <= lambda12)) {
15270         var q1 = cartesianScale(u2, (-w2 + t3) / uu);
15271         cartesianAddInPlace(q1, A2);
15272         return [q2, spherical(q1)];
15273       }
15274     }
15275     function code(lambda, phi) {
15276       var r2 = smallRadius ? radius : pi - radius, code2 = 0;
15277       if (lambda < -r2) code2 |= 1;
15278       else if (lambda > r2) code2 |= 2;
15279       if (phi < -r2) code2 |= 4;
15280       else if (phi > r2) code2 |= 8;
15281       return code2;
15282     }
15283     return clip_default(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-pi, radius - pi]);
15284   }
15285
15286   // node_modules/d3-geo/src/clip/line.js
15287   function line_default(a2, b2, x05, y05, x12, y12) {
15288     var ax = a2[0], ay = a2[1], bx = b2[0], by = b2[1], t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r2;
15289     r2 = x05 - ax;
15290     if (!dx && r2 > 0) return;
15291     r2 /= dx;
15292     if (dx < 0) {
15293       if (r2 < t0) return;
15294       if (r2 < t1) t1 = r2;
15295     } else if (dx > 0) {
15296       if (r2 > t1) return;
15297       if (r2 > t0) t0 = r2;
15298     }
15299     r2 = x12 - ax;
15300     if (!dx && r2 < 0) return;
15301     r2 /= dx;
15302     if (dx < 0) {
15303       if (r2 > t1) return;
15304       if (r2 > t0) t0 = r2;
15305     } else if (dx > 0) {
15306       if (r2 < t0) return;
15307       if (r2 < t1) t1 = r2;
15308     }
15309     r2 = y05 - ay;
15310     if (!dy && r2 > 0) return;
15311     r2 /= dy;
15312     if (dy < 0) {
15313       if (r2 < t0) return;
15314       if (r2 < t1) t1 = r2;
15315     } else if (dy > 0) {
15316       if (r2 > t1) return;
15317       if (r2 > t0) t0 = r2;
15318     }
15319     r2 = y12 - ay;
15320     if (!dy && r2 < 0) return;
15321     r2 /= dy;
15322     if (dy < 0) {
15323       if (r2 > t1) return;
15324       if (r2 > t0) t0 = r2;
15325     } else if (dy > 0) {
15326       if (r2 < t0) return;
15327       if (r2 < t1) t1 = r2;
15328     }
15329     if (t0 > 0) a2[0] = ax + t0 * dx, a2[1] = ay + t0 * dy;
15330     if (t1 < 1) b2[0] = ax + t1 * dx, b2[1] = ay + t1 * dy;
15331     return true;
15332   }
15333
15334   // node_modules/d3-geo/src/clip/rectangle.js
15335   var clipMax = 1e9;
15336   var clipMin = -clipMax;
15337   function clipRectangle(x05, y05, x12, y12) {
15338     function visible(x2, y2) {
15339       return x05 <= x2 && x2 <= x12 && y05 <= y2 && y2 <= y12;
15340     }
15341     function interpolate(from, to, direction, stream) {
15342       var a2 = 0, a1 = 0;
15343       if (from == null || (a2 = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoint(from, to) < 0 ^ direction > 0) {
15344         do
15345           stream.point(a2 === 0 || a2 === 3 ? x05 : x12, a2 > 1 ? y12 : y05);
15346         while ((a2 = (a2 + direction + 4) % 4) !== a1);
15347       } else {
15348         stream.point(to[0], to[1]);
15349       }
15350     }
15351     function corner(p2, direction) {
15352       return abs(p2[0] - x05) < epsilon ? direction > 0 ? 0 : 3 : abs(p2[0] - x12) < epsilon ? direction > 0 ? 2 : 1 : abs(p2[1] - y05) < epsilon ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2;
15353     }
15354     function compareIntersection2(a2, b2) {
15355       return comparePoint(a2.x, b2.x);
15356     }
15357     function comparePoint(a2, b2) {
15358       var ca = corner(a2, 1), cb = corner(b2, 1);
15359       return ca !== cb ? ca - cb : ca === 0 ? b2[1] - a2[1] : ca === 1 ? a2[0] - b2[0] : ca === 2 ? a2[1] - b2[1] : b2[0] - a2[0];
15360     }
15361     return function(stream) {
15362       var activeStream = stream, bufferStream = buffer_default(), segments, polygon2, ring, x__, y__, v__, x_, y_, v_, first, clean2;
15363       var clipStream = {
15364         point,
15365         lineStart,
15366         lineEnd,
15367         polygonStart,
15368         polygonEnd
15369       };
15370       function point(x2, y2) {
15371         if (visible(x2, y2)) activeStream.point(x2, y2);
15372       }
15373       function polygonInside() {
15374         var winding = 0;
15375         for (var i3 = 0, n3 = polygon2.length; i3 < n3; ++i3) {
15376           for (var ring2 = polygon2[i3], j2 = 1, m2 = ring2.length, point2 = ring2[0], a0, a1, b0 = point2[0], b1 = point2[1]; j2 < m2; ++j2) {
15377             a0 = b0, a1 = b1, point2 = ring2[j2], b0 = point2[0], b1 = point2[1];
15378             if (a1 <= y12) {
15379               if (b1 > y12 && (b0 - a0) * (y12 - a1) > (b1 - a1) * (x05 - a0)) ++winding;
15380             } else {
15381               if (b1 <= y12 && (b0 - a0) * (y12 - a1) < (b1 - a1) * (x05 - a0)) --winding;
15382             }
15383           }
15384         }
15385         return winding;
15386       }
15387       function polygonStart() {
15388         activeStream = bufferStream, segments = [], polygon2 = [], clean2 = true;
15389       }
15390       function polygonEnd() {
15391         var startInside = polygonInside(), cleanInside = clean2 && startInside, visible2 = (segments = merge(segments)).length;
15392         if (cleanInside || visible2) {
15393           stream.polygonStart();
15394           if (cleanInside) {
15395             stream.lineStart();
15396             interpolate(null, null, 1, stream);
15397             stream.lineEnd();
15398           }
15399           if (visible2) {
15400             rejoin_default(segments, compareIntersection2, startInside, interpolate, stream);
15401           }
15402           stream.polygonEnd();
15403         }
15404         activeStream = stream, segments = polygon2 = ring = null;
15405       }
15406       function lineStart() {
15407         clipStream.point = linePoint2;
15408         if (polygon2) polygon2.push(ring = []);
15409         first = true;
15410         v_ = false;
15411         x_ = y_ = NaN;
15412       }
15413       function lineEnd() {
15414         if (segments) {
15415           linePoint2(x__, y__);
15416           if (v__ && v_) bufferStream.rejoin();
15417           segments.push(bufferStream.result());
15418         }
15419         clipStream.point = point;
15420         if (v_) activeStream.lineEnd();
15421       }
15422       function linePoint2(x2, y2) {
15423         var v2 = visible(x2, y2);
15424         if (polygon2) ring.push([x2, y2]);
15425         if (first) {
15426           x__ = x2, y__ = y2, v__ = v2;
15427           first = false;
15428           if (v2) {
15429             activeStream.lineStart();
15430             activeStream.point(x2, y2);
15431           }
15432         } else {
15433           if (v2 && v_) activeStream.point(x2, y2);
15434           else {
15435             var a2 = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))], b2 = [x2 = Math.max(clipMin, Math.min(clipMax, x2)), y2 = Math.max(clipMin, Math.min(clipMax, y2))];
15436             if (line_default(a2, b2, x05, y05, x12, y12)) {
15437               if (!v_) {
15438                 activeStream.lineStart();
15439                 activeStream.point(a2[0], a2[1]);
15440               }
15441               activeStream.point(b2[0], b2[1]);
15442               if (!v2) activeStream.lineEnd();
15443               clean2 = false;
15444             } else if (v2) {
15445               activeStream.lineStart();
15446               activeStream.point(x2, y2);
15447               clean2 = false;
15448             }
15449           }
15450         }
15451         x_ = x2, y_ = y2, v_ = v2;
15452       }
15453       return clipStream;
15454     };
15455   }
15456
15457   // node_modules/d3-geo/src/length.js
15458   var lengthSum;
15459   var lambda03;
15460   var sinPhi02;
15461   var cosPhi02;
15462   var lengthStream = {
15463     sphere: noop,
15464     point: noop,
15465     lineStart: lengthLineStart,
15466     lineEnd: noop,
15467     polygonStart: noop,
15468     polygonEnd: noop
15469   };
15470   function lengthLineStart() {
15471     lengthStream.point = lengthPointFirst;
15472     lengthStream.lineEnd = lengthLineEnd;
15473   }
15474   function lengthLineEnd() {
15475     lengthStream.point = lengthStream.lineEnd = noop;
15476   }
15477   function lengthPointFirst(lambda, phi) {
15478     lambda *= radians, phi *= radians;
15479     lambda03 = lambda, sinPhi02 = sin(phi), cosPhi02 = cos(phi);
15480     lengthStream.point = lengthPoint;
15481   }
15482   function lengthPoint(lambda, phi) {
15483     lambda *= radians, phi *= radians;
15484     var sinPhi = sin(phi), cosPhi = cos(phi), delta = abs(lambda - lambda03), cosDelta = cos(delta), sinDelta = sin(delta), x2 = cosPhi * sinDelta, y2 = cosPhi02 * sinPhi - sinPhi02 * cosPhi * cosDelta, z2 = sinPhi02 * sinPhi + cosPhi02 * cosPhi * cosDelta;
15485     lengthSum.add(atan2(sqrt(x2 * x2 + y2 * y2), z2));
15486     lambda03 = lambda, sinPhi02 = sinPhi, cosPhi02 = cosPhi;
15487   }
15488   function length_default(object) {
15489     lengthSum = new Adder();
15490     stream_default(object, lengthStream);
15491     return +lengthSum;
15492   }
15493
15494   // node_modules/d3-geo/src/identity.js
15495   var identity_default = (x2) => x2;
15496
15497   // node_modules/d3-geo/src/path/area.js
15498   var areaSum2 = new Adder();
15499   var areaRingSum2 = new Adder();
15500   var x00;
15501   var y00;
15502   var x0;
15503   var y0;
15504   var areaStream2 = {
15505     point: noop,
15506     lineStart: noop,
15507     lineEnd: noop,
15508     polygonStart: function() {
15509       areaStream2.lineStart = areaRingStart2;
15510       areaStream2.lineEnd = areaRingEnd2;
15511     },
15512     polygonEnd: function() {
15513       areaStream2.lineStart = areaStream2.lineEnd = areaStream2.point = noop;
15514       areaSum2.add(abs(areaRingSum2));
15515       areaRingSum2 = new Adder();
15516     },
15517     result: function() {
15518       var area = areaSum2 / 2;
15519       areaSum2 = new Adder();
15520       return area;
15521     }
15522   };
15523   function areaRingStart2() {
15524     areaStream2.point = areaPointFirst2;
15525   }
15526   function areaPointFirst2(x2, y2) {
15527     areaStream2.point = areaPoint2;
15528     x00 = x0 = x2, y00 = y0 = y2;
15529   }
15530   function areaPoint2(x2, y2) {
15531     areaRingSum2.add(y0 * x2 - x0 * y2);
15532     x0 = x2, y0 = y2;
15533   }
15534   function areaRingEnd2() {
15535     areaPoint2(x00, y00);
15536   }
15537   var area_default2 = areaStream2;
15538
15539   // node_modules/d3-geo/src/path/bounds.js
15540   var x02 = Infinity;
15541   var y02 = x02;
15542   var x1 = -x02;
15543   var y1 = x1;
15544   var boundsStream2 = {
15545     point: boundsPoint2,
15546     lineStart: noop,
15547     lineEnd: noop,
15548     polygonStart: noop,
15549     polygonEnd: noop,
15550     result: function() {
15551       var bounds = [[x02, y02], [x1, y1]];
15552       x1 = y1 = -(y02 = x02 = Infinity);
15553       return bounds;
15554     }
15555   };
15556   function boundsPoint2(x2, y2) {
15557     if (x2 < x02) x02 = x2;
15558     if (x2 > x1) x1 = x2;
15559     if (y2 < y02) y02 = y2;
15560     if (y2 > y1) y1 = y2;
15561   }
15562   var bounds_default2 = boundsStream2;
15563
15564   // node_modules/d3-geo/src/path/centroid.js
15565   var X0 = 0;
15566   var Y0 = 0;
15567   var Z0 = 0;
15568   var X1 = 0;
15569   var Y1 = 0;
15570   var Z1 = 0;
15571   var X2 = 0;
15572   var Y2 = 0;
15573   var Z2 = 0;
15574   var x002;
15575   var y002;
15576   var x03;
15577   var y03;
15578   var centroidStream = {
15579     point: centroidPoint,
15580     lineStart: centroidLineStart,
15581     lineEnd: centroidLineEnd,
15582     polygonStart: function() {
15583       centroidStream.lineStart = centroidRingStart;
15584       centroidStream.lineEnd = centroidRingEnd;
15585     },
15586     polygonEnd: function() {
15587       centroidStream.point = centroidPoint;
15588       centroidStream.lineStart = centroidLineStart;
15589       centroidStream.lineEnd = centroidLineEnd;
15590     },
15591     result: function() {
15592       var centroid = Z2 ? [X2 / Z2, Y2 / Z2] : Z1 ? [X1 / Z1, Y1 / Z1] : Z0 ? [X0 / Z0, Y0 / Z0] : [NaN, NaN];
15593       X0 = Y0 = Z0 = X1 = Y1 = Z1 = X2 = Y2 = Z2 = 0;
15594       return centroid;
15595     }
15596   };
15597   function centroidPoint(x2, y2) {
15598     X0 += x2;
15599     Y0 += y2;
15600     ++Z0;
15601   }
15602   function centroidLineStart() {
15603     centroidStream.point = centroidPointFirstLine;
15604   }
15605   function centroidPointFirstLine(x2, y2) {
15606     centroidStream.point = centroidPointLine;
15607     centroidPoint(x03 = x2, y03 = y2);
15608   }
15609   function centroidPointLine(x2, y2) {
15610     var dx = x2 - x03, dy = y2 - y03, z2 = sqrt(dx * dx + dy * dy);
15611     X1 += z2 * (x03 + x2) / 2;
15612     Y1 += z2 * (y03 + y2) / 2;
15613     Z1 += z2;
15614     centroidPoint(x03 = x2, y03 = y2);
15615   }
15616   function centroidLineEnd() {
15617     centroidStream.point = centroidPoint;
15618   }
15619   function centroidRingStart() {
15620     centroidStream.point = centroidPointFirstRing;
15621   }
15622   function centroidRingEnd() {
15623     centroidPointRing(x002, y002);
15624   }
15625   function centroidPointFirstRing(x2, y2) {
15626     centroidStream.point = centroidPointRing;
15627     centroidPoint(x002 = x03 = x2, y002 = y03 = y2);
15628   }
15629   function centroidPointRing(x2, y2) {
15630     var dx = x2 - x03, dy = y2 - y03, z2 = sqrt(dx * dx + dy * dy);
15631     X1 += z2 * (x03 + x2) / 2;
15632     Y1 += z2 * (y03 + y2) / 2;
15633     Z1 += z2;
15634     z2 = y03 * x2 - x03 * y2;
15635     X2 += z2 * (x03 + x2);
15636     Y2 += z2 * (y03 + y2);
15637     Z2 += z2 * 3;
15638     centroidPoint(x03 = x2, y03 = y2);
15639   }
15640   var centroid_default = centroidStream;
15641
15642   // node_modules/d3-geo/src/path/context.js
15643   function PathContext(context) {
15644     this._context = context;
15645   }
15646   PathContext.prototype = {
15647     _radius: 4.5,
15648     pointRadius: function(_2) {
15649       return this._radius = _2, this;
15650     },
15651     polygonStart: function() {
15652       this._line = 0;
15653     },
15654     polygonEnd: function() {
15655       this._line = NaN;
15656     },
15657     lineStart: function() {
15658       this._point = 0;
15659     },
15660     lineEnd: function() {
15661       if (this._line === 0) this._context.closePath();
15662       this._point = NaN;
15663     },
15664     point: function(x2, y2) {
15665       switch (this._point) {
15666         case 0: {
15667           this._context.moveTo(x2, y2);
15668           this._point = 1;
15669           break;
15670         }
15671         case 1: {
15672           this._context.lineTo(x2, y2);
15673           break;
15674         }
15675         default: {
15676           this._context.moveTo(x2 + this._radius, y2);
15677           this._context.arc(x2, y2, this._radius, 0, tau);
15678           break;
15679         }
15680       }
15681     },
15682     result: noop
15683   };
15684
15685   // node_modules/d3-geo/src/path/measure.js
15686   var lengthSum2 = new Adder();
15687   var lengthRing;
15688   var x003;
15689   var y003;
15690   var x04;
15691   var y04;
15692   var lengthStream2 = {
15693     point: noop,
15694     lineStart: function() {
15695       lengthStream2.point = lengthPointFirst2;
15696     },
15697     lineEnd: function() {
15698       if (lengthRing) lengthPoint2(x003, y003);
15699       lengthStream2.point = noop;
15700     },
15701     polygonStart: function() {
15702       lengthRing = true;
15703     },
15704     polygonEnd: function() {
15705       lengthRing = null;
15706     },
15707     result: function() {
15708       var length2 = +lengthSum2;
15709       lengthSum2 = new Adder();
15710       return length2;
15711     }
15712   };
15713   function lengthPointFirst2(x2, y2) {
15714     lengthStream2.point = lengthPoint2;
15715     x003 = x04 = x2, y003 = y04 = y2;
15716   }
15717   function lengthPoint2(x2, y2) {
15718     x04 -= x2, y04 -= y2;
15719     lengthSum2.add(sqrt(x04 * x04 + y04 * y04));
15720     x04 = x2, y04 = y2;
15721   }
15722   var measure_default = lengthStream2;
15723
15724   // node_modules/d3-geo/src/path/string.js
15725   var cacheDigits;
15726   var cacheAppend;
15727   var cacheRadius;
15728   var cacheCircle;
15729   var _a, _b, _c, _d;
15730   var PathString = class {
15731     constructor(digits) {
15732       this._append = digits == null ? append : appendRound(digits);
15733       this._radius = 4.5;
15734       this._ = "";
15735     }
15736     pointRadius(_2) {
15737       this._radius = +_2;
15738       return this;
15739     }
15740     polygonStart() {
15741       this._line = 0;
15742     }
15743     polygonEnd() {
15744       this._line = NaN;
15745     }
15746     lineStart() {
15747       this._point = 0;
15748     }
15749     lineEnd() {
15750       if (this._line === 0) this._ += "Z";
15751       this._point = NaN;
15752     }
15753     point(x2, y2) {
15754       switch (this._point) {
15755         case 0: {
15756           this._append(_a || (_a = __template(["M", ",", ""])), x2, y2);
15757           this._point = 1;
15758           break;
15759         }
15760         case 1: {
15761           this._append(_b || (_b = __template(["L", ",", ""])), x2, y2);
15762           break;
15763         }
15764         default: {
15765           this._append(_c || (_c = __template(["M", ",", ""])), x2, y2);
15766           if (this._radius !== cacheRadius || this._append !== cacheAppend) {
15767             const r2 = this._radius;
15768             const s2 = this._;
15769             this._ = "";
15770             this._append(_d || (_d = __template(["m0,", "a", ",", " 0 1,1 0,", "a", ",", " 0 1,1 0,", "z"])), r2, r2, r2, -2 * r2, r2, r2, 2 * r2);
15771             cacheRadius = r2;
15772             cacheAppend = this._append;
15773             cacheCircle = this._;
15774             this._ = s2;
15775           }
15776           this._ += cacheCircle;
15777           break;
15778         }
15779       }
15780     }
15781     result() {
15782       const result = this._;
15783       this._ = "";
15784       return result.length ? result : null;
15785     }
15786   };
15787   function append(strings) {
15788     let i3 = 1;
15789     this._ += strings[0];
15790     for (const j2 = strings.length; i3 < j2; ++i3) {
15791       this._ += arguments[i3] + strings[i3];
15792     }
15793   }
15794   function appendRound(digits) {
15795     const d2 = Math.floor(digits);
15796     if (!(d2 >= 0)) throw new RangeError("invalid digits: ".concat(digits));
15797     if (d2 > 15) return append;
15798     if (d2 !== cacheDigits) {
15799       const k2 = 10 ** d2;
15800       cacheDigits = d2;
15801       cacheAppend = function append2(strings) {
15802         let i3 = 1;
15803         this._ += strings[0];
15804         for (const j2 = strings.length; i3 < j2; ++i3) {
15805           this._ += Math.round(arguments[i3] * k2) / k2 + strings[i3];
15806         }
15807       };
15808     }
15809     return cacheAppend;
15810   }
15811
15812   // node_modules/d3-geo/src/path/index.js
15813   function path_default(projection2, context) {
15814     let digits = 3, pointRadius = 4.5, projectionStream, contextStream;
15815     function path(object) {
15816       if (object) {
15817         if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments));
15818         stream_default(object, projectionStream(contextStream));
15819       }
15820       return contextStream.result();
15821     }
15822     path.area = function(object) {
15823       stream_default(object, projectionStream(area_default2));
15824       return area_default2.result();
15825     };
15826     path.measure = function(object) {
15827       stream_default(object, projectionStream(measure_default));
15828       return measure_default.result();
15829     };
15830     path.bounds = function(object) {
15831       stream_default(object, projectionStream(bounds_default2));
15832       return bounds_default2.result();
15833     };
15834     path.centroid = function(object) {
15835       stream_default(object, projectionStream(centroid_default));
15836       return centroid_default.result();
15837     };
15838     path.projection = function(_2) {
15839       if (!arguments.length) return projection2;
15840       projectionStream = _2 == null ? (projection2 = null, identity_default) : (projection2 = _2).stream;
15841       return path;
15842     };
15843     path.context = function(_2) {
15844       if (!arguments.length) return context;
15845       contextStream = _2 == null ? (context = null, new PathString(digits)) : new PathContext(context = _2);
15846       if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius);
15847       return path;
15848     };
15849     path.pointRadius = function(_2) {
15850       if (!arguments.length) return pointRadius;
15851       pointRadius = typeof _2 === "function" ? _2 : (contextStream.pointRadius(+_2), +_2);
15852       return path;
15853     };
15854     path.digits = function(_2) {
15855       if (!arguments.length) return digits;
15856       if (_2 == null) digits = null;
15857       else {
15858         const d2 = Math.floor(_2);
15859         if (!(d2 >= 0)) throw new RangeError("invalid digits: ".concat(_2));
15860         digits = d2;
15861       }
15862       if (context === null) contextStream = new PathString(digits);
15863       return path;
15864     };
15865     return path.projection(projection2).digits(digits).context(context);
15866   }
15867
15868   // node_modules/d3-geo/src/transform.js
15869   function transform_default(methods2) {
15870     return {
15871       stream: transformer(methods2)
15872     };
15873   }
15874   function transformer(methods2) {
15875     return function(stream) {
15876       var s2 = new TransformStream();
15877       for (var key in methods2) s2[key] = methods2[key];
15878       s2.stream = stream;
15879       return s2;
15880     };
15881   }
15882   function TransformStream() {
15883   }
15884   TransformStream.prototype = {
15885     constructor: TransformStream,
15886     point: function(x2, y2) {
15887       this.stream.point(x2, y2);
15888     },
15889     sphere: function() {
15890       this.stream.sphere();
15891     },
15892     lineStart: function() {
15893       this.stream.lineStart();
15894     },
15895     lineEnd: function() {
15896       this.stream.lineEnd();
15897     },
15898     polygonStart: function() {
15899       this.stream.polygonStart();
15900     },
15901     polygonEnd: function() {
15902       this.stream.polygonEnd();
15903     }
15904   };
15905
15906   // node_modules/d3-geo/src/projection/fit.js
15907   function fit(projection2, fitBounds, object) {
15908     var clip = projection2.clipExtent && projection2.clipExtent();
15909     projection2.scale(150).translate([0, 0]);
15910     if (clip != null) projection2.clipExtent(null);
15911     stream_default(object, projection2.stream(bounds_default2));
15912     fitBounds(bounds_default2.result());
15913     if (clip != null) projection2.clipExtent(clip);
15914     return projection2;
15915   }
15916   function fitExtent(projection2, extent, object) {
15917     return fit(projection2, function(b2) {
15918       var w2 = extent[1][0] - extent[0][0], h2 = extent[1][1] - extent[0][1], k2 = Math.min(w2 / (b2[1][0] - b2[0][0]), h2 / (b2[1][1] - b2[0][1])), x2 = +extent[0][0] + (w2 - k2 * (b2[1][0] + b2[0][0])) / 2, y2 = +extent[0][1] + (h2 - k2 * (b2[1][1] + b2[0][1])) / 2;
15919       projection2.scale(150 * k2).translate([x2, y2]);
15920     }, object);
15921   }
15922   function fitSize(projection2, size, object) {
15923     return fitExtent(projection2, [[0, 0], size], object);
15924   }
15925   function fitWidth(projection2, width, object) {
15926     return fit(projection2, function(b2) {
15927       var w2 = +width, k2 = w2 / (b2[1][0] - b2[0][0]), x2 = (w2 - k2 * (b2[1][0] + b2[0][0])) / 2, y2 = -k2 * b2[0][1];
15928       projection2.scale(150 * k2).translate([x2, y2]);
15929     }, object);
15930   }
15931   function fitHeight(projection2, height, object) {
15932     return fit(projection2, function(b2) {
15933       var h2 = +height, k2 = h2 / (b2[1][1] - b2[0][1]), x2 = -k2 * b2[0][0], y2 = (h2 - k2 * (b2[1][1] + b2[0][1])) / 2;
15934       projection2.scale(150 * k2).translate([x2, y2]);
15935     }, object);
15936   }
15937
15938   // node_modules/d3-geo/src/projection/resample.js
15939   var maxDepth = 16;
15940   var cosMinDistance = cos(30 * radians);
15941   function resample_default(project, delta2) {
15942     return +delta2 ? resample(project, delta2) : resampleNone(project);
15943   }
15944   function resampleNone(project) {
15945     return transformer({
15946       point: function(x2, y2) {
15947         x2 = project(x2, y2);
15948         this.stream.point(x2[0], x2[1]);
15949       }
15950     });
15951   }
15952   function resample(project, delta2) {
15953     function resampleLineTo(x05, y05, lambda04, a0, b0, c0, x12, y12, lambda12, a1, b1, c1, depth, stream) {
15954       var dx = x12 - x05, dy = y12 - y05, d2 = dx * dx + dy * dy;
15955       if (d2 > 4 * delta2 && depth--) {
15956         var a2 = a0 + a1, b2 = b0 + b1, c2 = c0 + c1, m2 = sqrt(a2 * a2 + b2 * b2 + c2 * c2), phi2 = asin(c2 /= m2), lambda22 = abs(abs(c2) - 1) < epsilon || abs(lambda04 - lambda12) < epsilon ? (lambda04 + lambda12) / 2 : atan2(b2, a2), p2 = project(lambda22, phi2), x2 = p2[0], y2 = p2[1], dx2 = x2 - x05, dy2 = y2 - y05, dz = dy * dx2 - dx * dy2;
15957         if (dz * dz / d2 > delta2 || abs((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
15958           resampleLineTo(x05, y05, lambda04, a0, b0, c0, x2, y2, lambda22, a2 /= m2, b2 /= m2, c2, depth, stream);
15959           stream.point(x2, y2);
15960           resampleLineTo(x2, y2, lambda22, a2, b2, c2, x12, y12, lambda12, a1, b1, c1, depth, stream);
15961         }
15962       }
15963     }
15964     return function(stream) {
15965       var lambda003, x004, y004, a00, b00, c00, lambda04, x05, y05, a0, b0, c0;
15966       var resampleStream = {
15967         point,
15968         lineStart,
15969         lineEnd,
15970         polygonStart: function() {
15971           stream.polygonStart();
15972           resampleStream.lineStart = ringStart;
15973         },
15974         polygonEnd: function() {
15975           stream.polygonEnd();
15976           resampleStream.lineStart = lineStart;
15977         }
15978       };
15979       function point(x2, y2) {
15980         x2 = project(x2, y2);
15981         stream.point(x2[0], x2[1]);
15982       }
15983       function lineStart() {
15984         x05 = NaN;
15985         resampleStream.point = linePoint2;
15986         stream.lineStart();
15987       }
15988       function linePoint2(lambda, phi) {
15989         var c2 = cartesian([lambda, phi]), p2 = project(lambda, phi);
15990         resampleLineTo(x05, y05, lambda04, a0, b0, c0, x05 = p2[0], y05 = p2[1], lambda04 = lambda, a0 = c2[0], b0 = c2[1], c0 = c2[2], maxDepth, stream);
15991         stream.point(x05, y05);
15992       }
15993       function lineEnd() {
15994         resampleStream.point = point;
15995         stream.lineEnd();
15996       }
15997       function ringStart() {
15998         lineStart();
15999         resampleStream.point = ringPoint;
16000         resampleStream.lineEnd = ringEnd;
16001       }
16002       function ringPoint(lambda, phi) {
16003         linePoint2(lambda003 = lambda, phi), x004 = x05, y004 = y05, a00 = a0, b00 = b0, c00 = c0;
16004         resampleStream.point = linePoint2;
16005       }
16006       function ringEnd() {
16007         resampleLineTo(x05, y05, lambda04, a0, b0, c0, x004, y004, lambda003, a00, b00, c00, maxDepth, stream);
16008         resampleStream.lineEnd = lineEnd;
16009         lineEnd();
16010       }
16011       return resampleStream;
16012     };
16013   }
16014
16015   // node_modules/d3-geo/src/projection/index.js
16016   var transformRadians = transformer({
16017     point: function(x2, y2) {
16018       this.stream.point(x2 * radians, y2 * radians);
16019     }
16020   });
16021   function transformRotate(rotate) {
16022     return transformer({
16023       point: function(x2, y2) {
16024         var r2 = rotate(x2, y2);
16025         return this.stream.point(r2[0], r2[1]);
16026       }
16027     });
16028   }
16029   function scaleTranslate(k2, dx, dy, sx, sy) {
16030     function transform2(x2, y2) {
16031       x2 *= sx;
16032       y2 *= sy;
16033       return [dx + k2 * x2, dy - k2 * y2];
16034     }
16035     transform2.invert = function(x2, y2) {
16036       return [(x2 - dx) / k2 * sx, (dy - y2) / k2 * sy];
16037     };
16038     return transform2;
16039   }
16040   function scaleTranslateRotate(k2, dx, dy, sx, sy, alpha) {
16041     if (!alpha) return scaleTranslate(k2, dx, dy, sx, sy);
16042     var cosAlpha = cos(alpha), sinAlpha = sin(alpha), a2 = cosAlpha * k2, b2 = sinAlpha * k2, ai = cosAlpha / k2, bi = sinAlpha / k2, ci = (sinAlpha * dy - cosAlpha * dx) / k2, fi = (sinAlpha * dx + cosAlpha * dy) / k2;
16043     function transform2(x2, y2) {
16044       x2 *= sx;
16045       y2 *= sy;
16046       return [a2 * x2 - b2 * y2 + dx, dy - b2 * x2 - a2 * y2];
16047     }
16048     transform2.invert = function(x2, y2) {
16049       return [sx * (ai * x2 - bi * y2 + ci), sy * (fi - bi * x2 - ai * y2)];
16050     };
16051     return transform2;
16052   }
16053   function projection(project) {
16054     return projectionMutator(function() {
16055       return project;
16056     })();
16057   }
16058   function projectionMutator(projectAt) {
16059     var project, k2 = 150, x2 = 480, y2 = 250, lambda = 0, phi = 0, deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, alpha = 0, sx = 1, sy = 1, theta = null, preclip = antimeridian_default, x05 = null, y05, x12, y12, postclip = identity_default, delta2 = 0.5, projectResample, projectTransform, projectRotateTransform, cache, cacheStream;
16060     function projection2(point) {
16061       return projectRotateTransform(point[0] * radians, point[1] * radians);
16062     }
16063     function invert(point) {
16064       point = projectRotateTransform.invert(point[0], point[1]);
16065       return point && [point[0] * degrees, point[1] * degrees];
16066     }
16067     projection2.stream = function(stream) {
16068       return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream)))));
16069     };
16070     projection2.preclip = function(_2) {
16071       return arguments.length ? (preclip = _2, theta = void 0, reset()) : preclip;
16072     };
16073     projection2.postclip = function(_2) {
16074       return arguments.length ? (postclip = _2, x05 = y05 = x12 = y12 = null, reset()) : postclip;
16075     };
16076     projection2.clipAngle = function(_2) {
16077       return arguments.length ? (preclip = +_2 ? circle_default(theta = _2 * radians) : (theta = null, antimeridian_default), reset()) : theta * degrees;
16078     };
16079     projection2.clipExtent = function(_2) {
16080       return arguments.length ? (postclip = _2 == null ? (x05 = y05 = x12 = y12 = null, identity_default) : clipRectangle(x05 = +_2[0][0], y05 = +_2[0][1], x12 = +_2[1][0], y12 = +_2[1][1]), reset()) : x05 == null ? null : [[x05, y05], [x12, y12]];
16081     };
16082     projection2.scale = function(_2) {
16083       return arguments.length ? (k2 = +_2, recenter()) : k2;
16084     };
16085     projection2.translate = function(_2) {
16086       return arguments.length ? (x2 = +_2[0], y2 = +_2[1], recenter()) : [x2, y2];
16087     };
16088     projection2.center = function(_2) {
16089       return arguments.length ? (lambda = _2[0] % 360 * radians, phi = _2[1] % 360 * radians, recenter()) : [lambda * degrees, phi * degrees];
16090     };
16091     projection2.rotate = function(_2) {
16092       return arguments.length ? (deltaLambda = _2[0] % 360 * radians, deltaPhi = _2[1] % 360 * radians, deltaGamma = _2.length > 2 ? _2[2] % 360 * radians : 0, recenter()) : [deltaLambda * degrees, deltaPhi * degrees, deltaGamma * degrees];
16093     };
16094     projection2.angle = function(_2) {
16095       return arguments.length ? (alpha = _2 % 360 * radians, recenter()) : alpha * degrees;
16096     };
16097     projection2.reflectX = function(_2) {
16098       return arguments.length ? (sx = _2 ? -1 : 1, recenter()) : sx < 0;
16099     };
16100     projection2.reflectY = function(_2) {
16101       return arguments.length ? (sy = _2 ? -1 : 1, recenter()) : sy < 0;
16102     };
16103     projection2.precision = function(_2) {
16104       return arguments.length ? (projectResample = resample_default(projectTransform, delta2 = _2 * _2), reset()) : sqrt(delta2);
16105     };
16106     projection2.fitExtent = function(extent, object) {
16107       return fitExtent(projection2, extent, object);
16108     };
16109     projection2.fitSize = function(size, object) {
16110       return fitSize(projection2, size, object);
16111     };
16112     projection2.fitWidth = function(width, object) {
16113       return fitWidth(projection2, width, object);
16114     };
16115     projection2.fitHeight = function(height, object) {
16116       return fitHeight(projection2, height, object);
16117     };
16118     function recenter() {
16119       var center = scaleTranslateRotate(k2, 0, 0, sx, sy, alpha).apply(null, project(lambda, phi)), transform2 = scaleTranslateRotate(k2, x2 - center[0], y2 - center[1], sx, sy, alpha);
16120       rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma);
16121       projectTransform = compose_default(project, transform2);
16122       projectRotateTransform = compose_default(rotate, projectTransform);
16123       projectResample = resample_default(projectTransform, delta2);
16124       return reset();
16125     }
16126     function reset() {
16127       cache = cacheStream = null;
16128       return projection2;
16129     }
16130     return function() {
16131       project = projectAt.apply(this, arguments);
16132       projection2.invert = project.invert && invert;
16133       return recenter();
16134     };
16135   }
16136
16137   // node_modules/d3-geo/src/projection/mercator.js
16138   function mercatorRaw(lambda, phi) {
16139     return [lambda, log(tan((halfPi + phi) / 2))];
16140   }
16141   mercatorRaw.invert = function(x2, y2) {
16142     return [x2, 2 * atan(exp(y2)) - halfPi];
16143   };
16144   function mercator_default() {
16145     return mercatorProjection(mercatorRaw).scale(961 / tau);
16146   }
16147   function mercatorProjection(project) {
16148     var m2 = projection(project), center = m2.center, scale = m2.scale, translate = m2.translate, clipExtent = m2.clipExtent, x05 = null, y05, x12, y12;
16149     m2.scale = function(_2) {
16150       return arguments.length ? (scale(_2), reclip()) : scale();
16151     };
16152     m2.translate = function(_2) {
16153       return arguments.length ? (translate(_2), reclip()) : translate();
16154     };
16155     m2.center = function(_2) {
16156       return arguments.length ? (center(_2), reclip()) : center();
16157     };
16158     m2.clipExtent = function(_2) {
16159       return arguments.length ? (_2 == null ? x05 = y05 = x12 = y12 = null : (x05 = +_2[0][0], y05 = +_2[0][1], x12 = +_2[1][0], y12 = +_2[1][1]), reclip()) : x05 == null ? null : [[x05, y05], [x12, y12]];
16160     };
16161     function reclip() {
16162       var k2 = pi * scale(), t2 = m2(rotation_default(m2.rotate()).invert([0, 0]));
16163       return clipExtent(x05 == null ? [[t2[0] - k2, t2[1] - k2], [t2[0] + k2, t2[1] + k2]] : project === mercatorRaw ? [[Math.max(t2[0] - k2, x05), y05], [Math.min(t2[0] + k2, x12), y12]] : [[x05, Math.max(t2[1] - k2, y05)], [x12, Math.min(t2[1] + k2, y12)]]);
16164     }
16165     return reclip();
16166   }
16167
16168   // node_modules/d3-geo/src/projection/identity.js
16169   function identity_default2() {
16170     var k2 = 1, tx = 0, ty = 0, sx = 1, sy = 1, alpha = 0, ca, sa, x05 = null, y05, x12, y12, kx = 1, ky = 1, transform2 = transformer({
16171       point: function(x2, y2) {
16172         var p2 = projection2([x2, y2]);
16173         this.stream.point(p2[0], p2[1]);
16174       }
16175     }), postclip = identity_default, cache, cacheStream;
16176     function reset() {
16177       kx = k2 * sx;
16178       ky = k2 * sy;
16179       cache = cacheStream = null;
16180       return projection2;
16181     }
16182     function projection2(p2) {
16183       var x2 = p2[0] * kx, y2 = p2[1] * ky;
16184       if (alpha) {
16185         var t2 = y2 * ca - x2 * sa;
16186         x2 = x2 * ca + y2 * sa;
16187         y2 = t2;
16188       }
16189       return [x2 + tx, y2 + ty];
16190     }
16191     projection2.invert = function(p2) {
16192       var x2 = p2[0] - tx, y2 = p2[1] - ty;
16193       if (alpha) {
16194         var t2 = y2 * ca + x2 * sa;
16195         x2 = x2 * ca - y2 * sa;
16196         y2 = t2;
16197       }
16198       return [x2 / kx, y2 / ky];
16199     };
16200     projection2.stream = function(stream) {
16201       return cache && cacheStream === stream ? cache : cache = transform2(postclip(cacheStream = stream));
16202     };
16203     projection2.postclip = function(_2) {
16204       return arguments.length ? (postclip = _2, x05 = y05 = x12 = y12 = null, reset()) : postclip;
16205     };
16206     projection2.clipExtent = function(_2) {
16207       return arguments.length ? (postclip = _2 == null ? (x05 = y05 = x12 = y12 = null, identity_default) : clipRectangle(x05 = +_2[0][0], y05 = +_2[0][1], x12 = +_2[1][0], y12 = +_2[1][1]), reset()) : x05 == null ? null : [[x05, y05], [x12, y12]];
16208     };
16209     projection2.scale = function(_2) {
16210       return arguments.length ? (k2 = +_2, reset()) : k2;
16211     };
16212     projection2.translate = function(_2) {
16213       return arguments.length ? (tx = +_2[0], ty = +_2[1], reset()) : [tx, ty];
16214     };
16215     projection2.angle = function(_2) {
16216       return arguments.length ? (alpha = _2 % 360 * radians, sa = sin(alpha), ca = cos(alpha), reset()) : alpha * degrees;
16217     };
16218     projection2.reflectX = function(_2) {
16219       return arguments.length ? (sx = _2 ? -1 : 1, reset()) : sx < 0;
16220     };
16221     projection2.reflectY = function(_2) {
16222       return arguments.length ? (sy = _2 ? -1 : 1, reset()) : sy < 0;
16223     };
16224     projection2.fitExtent = function(extent, object) {
16225       return fitExtent(projection2, extent, object);
16226     };
16227     projection2.fitSize = function(size, object) {
16228       return fitSize(projection2, size, object);
16229     };
16230     projection2.fitWidth = function(width, object) {
16231       return fitWidth(projection2, width, object);
16232     };
16233     projection2.fitHeight = function(height, object) {
16234       return fitHeight(projection2, height, object);
16235     };
16236     return projection2;
16237   }
16238
16239   // modules/geo/geo.js
16240   var TAU = 2 * Math.PI;
16241   var EQUATORIAL_RADIUS = 6378137;
16242   var POLAR_RADIUS = 63567523e-1;
16243   function geoLatToMeters(dLat) {
16244     return dLat * (TAU * POLAR_RADIUS / 360);
16245   }
16246   function geoLonToMeters(dLon, atLat) {
16247     return Math.abs(atLat) >= 90 ? 0 : dLon * (TAU * EQUATORIAL_RADIUS / 360) * Math.abs(Math.cos(atLat * (Math.PI / 180)));
16248   }
16249   function geoMetersToLat(m2) {
16250     return m2 / (TAU * POLAR_RADIUS / 360);
16251   }
16252   function geoMetersToLon(m2, atLat) {
16253     return Math.abs(atLat) >= 90 ? 0 : m2 / (TAU * EQUATORIAL_RADIUS / 360) / Math.abs(Math.cos(atLat * (Math.PI / 180)));
16254   }
16255   function geoMetersToOffset(meters, tileSize) {
16256     tileSize = tileSize || 256;
16257     return [
16258       meters[0] * tileSize / (TAU * EQUATORIAL_RADIUS),
16259       -meters[1] * tileSize / (TAU * POLAR_RADIUS)
16260     ];
16261   }
16262   function geoOffsetToMeters(offset, tileSize) {
16263     tileSize = tileSize || 256;
16264     return [
16265       offset[0] * TAU * EQUATORIAL_RADIUS / tileSize,
16266       -offset[1] * TAU * POLAR_RADIUS / tileSize
16267     ];
16268   }
16269   function geoSphericalDistance(a2, b2) {
16270     var x2 = geoLonToMeters(a2[0] - b2[0], (a2[1] + b2[1]) / 2);
16271     var y2 = geoLatToMeters(a2[1] - b2[1]);
16272     return Math.sqrt(x2 * x2 + y2 * y2);
16273   }
16274   function geoScaleToZoom(k2, tileSize) {
16275     tileSize = tileSize || 256;
16276     var log2ts = Math.log(tileSize) * Math.LOG2E;
16277     return Math.log(k2 * TAU) / Math.LN2 - log2ts;
16278   }
16279   function geoZoomToScale(z2, tileSize) {
16280     tileSize = tileSize || 256;
16281     return tileSize * Math.pow(2, z2) / TAU;
16282   }
16283   function geoSphericalClosestNode(nodes, point) {
16284     var minDistance = Infinity, distance;
16285     var indexOfMin;
16286     for (var i3 in nodes) {
16287       distance = geoSphericalDistance(nodes[i3].loc, point);
16288       if (distance < minDistance) {
16289         minDistance = distance;
16290         indexOfMin = i3;
16291       }
16292     }
16293     if (indexOfMin !== void 0) {
16294       return { index: indexOfMin, distance: minDistance, node: nodes[indexOfMin] };
16295     } else {
16296       return null;
16297     }
16298   }
16299
16300   // modules/geo/extent.js
16301   function geoExtent(min3, max3) {
16302     if (!(this instanceof geoExtent)) {
16303       return new geoExtent(min3, max3);
16304     } else if (min3 instanceof geoExtent) {
16305       return min3;
16306     } else if (min3 && min3.length === 2 && min3[0].length === 2 && min3[1].length === 2) {
16307       this[0] = min3[0];
16308       this[1] = min3[1];
16309     } else {
16310       this[0] = min3 || [Infinity, Infinity];
16311       this[1] = max3 || min3 || [-Infinity, -Infinity];
16312     }
16313   }
16314   geoExtent.prototype = new Array(2);
16315   Object.assign(geoExtent.prototype, {
16316     equals: function(obj) {
16317       return this[0][0] === obj[0][0] && this[0][1] === obj[0][1] && this[1][0] === obj[1][0] && this[1][1] === obj[1][1];
16318     },
16319     extend: function(obj) {
16320       if (!(obj instanceof geoExtent)) obj = new geoExtent(obj);
16321       return geoExtent(
16322         [Math.min(obj[0][0], this[0][0]), Math.min(obj[0][1], this[0][1])],
16323         [Math.max(obj[1][0], this[1][0]), Math.max(obj[1][1], this[1][1])]
16324       );
16325     },
16326     _extend: function(extent) {
16327       this[0][0] = Math.min(extent[0][0], this[0][0]);
16328       this[0][1] = Math.min(extent[0][1], this[0][1]);
16329       this[1][0] = Math.max(extent[1][0], this[1][0]);
16330       this[1][1] = Math.max(extent[1][1], this[1][1]);
16331     },
16332     area: function() {
16333       return Math.abs((this[1][0] - this[0][0]) * (this[1][1] - this[0][1]));
16334     },
16335     center: function() {
16336       return [(this[0][0] + this[1][0]) / 2, (this[0][1] + this[1][1]) / 2];
16337     },
16338     rectangle: function() {
16339       return [this[0][0], this[0][1], this[1][0], this[1][1]];
16340     },
16341     bbox: function() {
16342       return { minX: this[0][0], minY: this[0][1], maxX: this[1][0], maxY: this[1][1] };
16343     },
16344     polygon: function() {
16345       return [
16346         [this[0][0], this[0][1]],
16347         [this[0][0], this[1][1]],
16348         [this[1][0], this[1][1]],
16349         [this[1][0], this[0][1]],
16350         [this[0][0], this[0][1]]
16351       ];
16352     },
16353     contains: function(obj) {
16354       if (!(obj instanceof geoExtent)) obj = new geoExtent(obj);
16355       return obj[0][0] >= this[0][0] && obj[0][1] >= this[0][1] && obj[1][0] <= this[1][0] && obj[1][1] <= this[1][1];
16356     },
16357     intersects: function(obj) {
16358       if (!(obj instanceof geoExtent)) obj = new geoExtent(obj);
16359       return obj[0][0] <= this[1][0] && obj[0][1] <= this[1][1] && obj[1][0] >= this[0][0] && obj[1][1] >= this[0][1];
16360     },
16361     intersection: function(obj) {
16362       if (!this.intersects(obj)) return new geoExtent();
16363       return new geoExtent(
16364         [Math.max(obj[0][0], this[0][0]), Math.max(obj[0][1], this[0][1])],
16365         [Math.min(obj[1][0], this[1][0]), Math.min(obj[1][1], this[1][1])]
16366       );
16367     },
16368     percentContainedIn: function(obj) {
16369       if (!(obj instanceof geoExtent)) obj = new geoExtent(obj);
16370       var a1 = this.intersection(obj).area();
16371       var a2 = this.area();
16372       if (a1 === Infinity || a2 === Infinity) {
16373         return 0;
16374       } else if (a1 === 0 || a2 === 0) {
16375         if (obj.contains(this)) {
16376           return 1;
16377         }
16378         return 0;
16379       } else {
16380         return a1 / a2;
16381       }
16382     },
16383     padByMeters: function(meters) {
16384       var dLat = geoMetersToLat(meters);
16385       var dLon = geoMetersToLon(meters, this.center()[1]);
16386       return geoExtent(
16387         [this[0][0] - dLon, this[0][1] - dLat],
16388         [this[1][0] + dLon, this[1][1] + dLat]
16389       );
16390     },
16391     toParam: function() {
16392       return this.rectangle().join(",");
16393     },
16394     split: function() {
16395       const center = this.center();
16396       return [
16397         geoExtent(this[0], center),
16398         geoExtent([center[0], this[0][1]], [this[1][0], center[1]]),
16399         geoExtent(center, this[1]),
16400         geoExtent([this[0][0], center[1]], [center[0], this[1][1]])
16401       ];
16402     }
16403   });
16404
16405   // node_modules/d3-polygon/src/area.js
16406   function area_default3(polygon2) {
16407     var i3 = -1, n3 = polygon2.length, a2, b2 = polygon2[n3 - 1], area = 0;
16408     while (++i3 < n3) {
16409       a2 = b2;
16410       b2 = polygon2[i3];
16411       area += a2[1] * b2[0] - a2[0] * b2[1];
16412     }
16413     return area / 2;
16414   }
16415
16416   // node_modules/d3-polygon/src/centroid.js
16417   function centroid_default2(polygon2) {
16418     var i3 = -1, n3 = polygon2.length, x2 = 0, y2 = 0, a2, b2 = polygon2[n3 - 1], c2, k2 = 0;
16419     while (++i3 < n3) {
16420       a2 = b2;
16421       b2 = polygon2[i3];
16422       k2 += c2 = a2[0] * b2[1] - b2[0] * a2[1];
16423       x2 += (a2[0] + b2[0]) * c2;
16424       y2 += (a2[1] + b2[1]) * c2;
16425     }
16426     return k2 *= 3, [x2 / k2, y2 / k2];
16427   }
16428
16429   // node_modules/d3-polygon/src/cross.js
16430   function cross_default(a2, b2, c2) {
16431     return (b2[0] - a2[0]) * (c2[1] - a2[1]) - (b2[1] - a2[1]) * (c2[0] - a2[0]);
16432   }
16433
16434   // node_modules/d3-polygon/src/hull.js
16435   function lexicographicOrder(a2, b2) {
16436     return a2[0] - b2[0] || a2[1] - b2[1];
16437   }
16438   function computeUpperHullIndexes(points) {
16439     const n3 = points.length, indexes = [0, 1];
16440     let size = 2, i3;
16441     for (i3 = 2; i3 < n3; ++i3) {
16442       while (size > 1 && cross_default(points[indexes[size - 2]], points[indexes[size - 1]], points[i3]) <= 0) --size;
16443       indexes[size++] = i3;
16444     }
16445     return indexes.slice(0, size);
16446   }
16447   function hull_default(points) {
16448     if ((n3 = points.length) < 3) return null;
16449     var i3, n3, sortedPoints = new Array(n3), flippedPoints = new Array(n3);
16450     for (i3 = 0; i3 < n3; ++i3) sortedPoints[i3] = [+points[i3][0], +points[i3][1], i3];
16451     sortedPoints.sort(lexicographicOrder);
16452     for (i3 = 0; i3 < n3; ++i3) flippedPoints[i3] = [sortedPoints[i3][0], -sortedPoints[i3][1]];
16453     var upperIndexes = computeUpperHullIndexes(sortedPoints), lowerIndexes = computeUpperHullIndexes(flippedPoints);
16454     var skipLeft = lowerIndexes[0] === upperIndexes[0], skipRight = lowerIndexes[lowerIndexes.length - 1] === upperIndexes[upperIndexes.length - 1], hull = [];
16455     for (i3 = upperIndexes.length - 1; i3 >= 0; --i3) hull.push(points[sortedPoints[upperIndexes[i3]][2]]);
16456     for (i3 = +skipLeft; i3 < lowerIndexes.length - skipRight; ++i3) hull.push(points[sortedPoints[lowerIndexes[i3]][2]]);
16457     return hull;
16458   }
16459
16460   // modules/geo/vector.js
16461   function geoVecEqual(a2, b2, epsilon3) {
16462     if (epsilon3) {
16463       return Math.abs(a2[0] - b2[0]) <= epsilon3 && Math.abs(a2[1] - b2[1]) <= epsilon3;
16464     } else {
16465       return a2[0] === b2[0] && a2[1] === b2[1];
16466     }
16467   }
16468   function geoVecAdd(a2, b2) {
16469     return [a2[0] + b2[0], a2[1] + b2[1]];
16470   }
16471   function geoVecSubtract(a2, b2) {
16472     return [a2[0] - b2[0], a2[1] - b2[1]];
16473   }
16474   function geoVecScale(a2, mag) {
16475     return [a2[0] * mag, a2[1] * mag];
16476   }
16477   function geoVecFloor(a2) {
16478     return [Math.floor(a2[0]), Math.floor(a2[1])];
16479   }
16480   function geoVecInterp(a2, b2, t2) {
16481     return [
16482       a2[0] + (b2[0] - a2[0]) * t2,
16483       a2[1] + (b2[1] - a2[1]) * t2
16484     ];
16485   }
16486   function geoVecLength(a2, b2) {
16487     return Math.sqrt(geoVecLengthSquare(a2, b2));
16488   }
16489   function geoVecLengthSquare(a2, b2) {
16490     b2 = b2 || [0, 0];
16491     var x2 = a2[0] - b2[0];
16492     var y2 = a2[1] - b2[1];
16493     return x2 * x2 + y2 * y2;
16494   }
16495   function geoVecNormalize(a2) {
16496     var length2 = Math.sqrt(a2[0] * a2[0] + a2[1] * a2[1]);
16497     if (length2 !== 0) {
16498       return geoVecScale(a2, 1 / length2);
16499     }
16500     return [0, 0];
16501   }
16502   function geoVecAngle(a2, b2) {
16503     return Math.atan2(b2[1] - a2[1], b2[0] - a2[0]);
16504   }
16505   function geoVecDot(a2, b2, origin) {
16506     origin = origin || [0, 0];
16507     var p2 = geoVecSubtract(a2, origin);
16508     var q2 = geoVecSubtract(b2, origin);
16509     return p2[0] * q2[0] + p2[1] * q2[1];
16510   }
16511   function geoVecNormalizedDot(a2, b2, origin) {
16512     origin = origin || [0, 0];
16513     var p2 = geoVecNormalize(geoVecSubtract(a2, origin));
16514     var q2 = geoVecNormalize(geoVecSubtract(b2, origin));
16515     return geoVecDot(p2, q2);
16516   }
16517   function geoVecCross(a2, b2, origin) {
16518     origin = origin || [0, 0];
16519     var p2 = geoVecSubtract(a2, origin);
16520     var q2 = geoVecSubtract(b2, origin);
16521     return p2[0] * q2[1] - p2[1] * q2[0];
16522   }
16523   function geoVecProject(a2, points) {
16524     var min3 = Infinity;
16525     var idx;
16526     var target;
16527     for (var i3 = 0; i3 < points.length - 1; i3++) {
16528       var o2 = points[i3];
16529       var s2 = geoVecSubtract(points[i3 + 1], o2);
16530       var v2 = geoVecSubtract(a2, o2);
16531       var proj = geoVecDot(v2, s2) / geoVecDot(s2, s2);
16532       var p2;
16533       if (proj < 0) {
16534         p2 = o2;
16535       } else if (proj > 1) {
16536         p2 = points[i3 + 1];
16537       } else {
16538         p2 = [o2[0] + proj * s2[0], o2[1] + proj * s2[1]];
16539       }
16540       var dist = geoVecLength(p2, a2);
16541       if (dist < min3) {
16542         min3 = dist;
16543         idx = i3 + 1;
16544         target = p2;
16545       }
16546     }
16547     if (idx !== void 0) {
16548       return { index: idx, distance: min3, target };
16549     } else {
16550       return null;
16551     }
16552   }
16553
16554   // modules/geo/geom.js
16555   function geoAngle(a2, b2, projection2) {
16556     return geoVecAngle(projection2(a2.loc), projection2(b2.loc));
16557   }
16558   function geoEdgeEqual(a2, b2) {
16559     return a2[0] === b2[0] && a2[1] === b2[1] || a2[0] === b2[1] && a2[1] === b2[0];
16560   }
16561   function geoRotate(points, angle2, around) {
16562     return points.map(function(point) {
16563       var radial = geoVecSubtract(point, around);
16564       return [
16565         radial[0] * Math.cos(angle2) - radial[1] * Math.sin(angle2) + around[0],
16566         radial[0] * Math.sin(angle2) + radial[1] * Math.cos(angle2) + around[1]
16567       ];
16568     });
16569   }
16570   function geoChooseEdge(nodes, point, projection2, activeID) {
16571     var dist = geoVecLength;
16572     var points = nodes.map(function(n3) {
16573       return projection2(n3.loc);
16574     });
16575     var ids = nodes.map(function(n3) {
16576       return n3.id;
16577     });
16578     var min3 = Infinity;
16579     var idx;
16580     var loc;
16581     for (var i3 = 0; i3 < points.length - 1; i3++) {
16582       if (ids[i3] === activeID || ids[i3 + 1] === activeID) continue;
16583       var o2 = points[i3];
16584       var s2 = geoVecSubtract(points[i3 + 1], o2);
16585       var v2 = geoVecSubtract(point, o2);
16586       var proj = geoVecDot(v2, s2) / geoVecDot(s2, s2);
16587       var p2;
16588       if (proj < 0) {
16589         p2 = o2;
16590       } else if (proj > 1) {
16591         p2 = points[i3 + 1];
16592       } else {
16593         p2 = [o2[0] + proj * s2[0], o2[1] + proj * s2[1]];
16594       }
16595       var d2 = dist(p2, point);
16596       if (d2 < min3) {
16597         min3 = d2;
16598         idx = i3 + 1;
16599         loc = projection2.invert(p2);
16600       }
16601     }
16602     if (idx !== void 0) {
16603       return { index: idx, distance: min3, loc };
16604     } else {
16605       return null;
16606     }
16607   }
16608   function geoHasLineIntersections(activeNodes, inactiveNodes, activeID) {
16609     var actives = [];
16610     var inactives = [];
16611     var j2, k2, n1, n22, segment;
16612     for (j2 = 0; j2 < activeNodes.length - 1; j2++) {
16613       n1 = activeNodes[j2];
16614       n22 = activeNodes[j2 + 1];
16615       segment = [n1.loc, n22.loc];
16616       if (n1.id === activeID || n22.id === activeID) {
16617         actives.push(segment);
16618       }
16619     }
16620     for (j2 = 0; j2 < inactiveNodes.length - 1; j2++) {
16621       n1 = inactiveNodes[j2];
16622       n22 = inactiveNodes[j2 + 1];
16623       segment = [n1.loc, n22.loc];
16624       inactives.push(segment);
16625     }
16626     for (j2 = 0; j2 < actives.length; j2++) {
16627       for (k2 = 0; k2 < inactives.length; k2++) {
16628         var p2 = actives[j2];
16629         var q2 = inactives[k2];
16630         var hit = geoLineIntersection(p2, q2);
16631         if (hit) {
16632           return true;
16633         }
16634       }
16635     }
16636     return false;
16637   }
16638   function geoHasSelfIntersections(nodes, activeID) {
16639     var actives = [];
16640     var inactives = [];
16641     var j2, k2;
16642     for (j2 = 0; j2 < nodes.length - 1; j2++) {
16643       var n1 = nodes[j2];
16644       var n22 = nodes[j2 + 1];
16645       var segment = [n1.loc, n22.loc];
16646       if (n1.id === activeID || n22.id === activeID) {
16647         actives.push(segment);
16648       } else {
16649         inactives.push(segment);
16650       }
16651     }
16652     for (j2 = 0; j2 < actives.length; j2++) {
16653       for (k2 = 0; k2 < inactives.length; k2++) {
16654         var p2 = actives[j2];
16655         var q2 = inactives[k2];
16656         if (geoVecEqual(p2[1], q2[0]) || geoVecEqual(p2[0], q2[1]) || geoVecEqual(p2[0], q2[0]) || geoVecEqual(p2[1], q2[1])) {
16657           continue;
16658         }
16659         var hit = geoLineIntersection(p2, q2);
16660         if (hit) {
16661           var epsilon3 = 1e-8;
16662           if (geoVecEqual(p2[1], hit, epsilon3) || geoVecEqual(p2[0], hit, epsilon3) || geoVecEqual(q2[1], hit, epsilon3) || geoVecEqual(q2[0], hit, epsilon3)) {
16663             continue;
16664           } else {
16665             return true;
16666           }
16667         }
16668       }
16669     }
16670     return false;
16671   }
16672   function geoLineIntersection(a2, b2) {
16673     var p2 = [a2[0][0], a2[0][1]];
16674     var p22 = [a2[1][0], a2[1][1]];
16675     var q2 = [b2[0][0], b2[0][1]];
16676     var q22 = [b2[1][0], b2[1][1]];
16677     var r2 = geoVecSubtract(p22, p2);
16678     var s2 = geoVecSubtract(q22, q2);
16679     var uNumerator = geoVecCross(geoVecSubtract(q2, p2), r2);
16680     var denominator = geoVecCross(r2, s2);
16681     if (uNumerator && denominator) {
16682       var u2 = uNumerator / denominator;
16683       var t2 = geoVecCross(geoVecSubtract(q2, p2), s2) / denominator;
16684       if (t2 >= 0 && t2 <= 1 && u2 >= 0 && u2 <= 1) {
16685         return geoVecInterp(p2, p22, t2);
16686       }
16687     }
16688     return null;
16689   }
16690   function geoPathIntersections(path1, path2) {
16691     var intersections = [];
16692     for (var i3 = 0; i3 < path1.length - 1; i3++) {
16693       for (var j2 = 0; j2 < path2.length - 1; j2++) {
16694         var a2 = [path1[i3], path1[i3 + 1]];
16695         var b2 = [path2[j2], path2[j2 + 1]];
16696         var hit = geoLineIntersection(a2, b2);
16697         if (hit) {
16698           intersections.push(hit);
16699         }
16700       }
16701     }
16702     return intersections;
16703   }
16704   function geoPathHasIntersections(path1, path2) {
16705     for (var i3 = 0; i3 < path1.length - 1; i3++) {
16706       for (var j2 = 0; j2 < path2.length - 1; j2++) {
16707         var a2 = [path1[i3], path1[i3 + 1]];
16708         var b2 = [path2[j2], path2[j2 + 1]];
16709         var hit = geoLineIntersection(a2, b2);
16710         if (hit) {
16711           return true;
16712         }
16713       }
16714     }
16715     return false;
16716   }
16717   function geoPointInPolygon(point, polygon2) {
16718     var x2 = point[0];
16719     var y2 = point[1];
16720     var inside = false;
16721     for (var i3 = 0, j2 = polygon2.length - 1; i3 < polygon2.length; j2 = i3++) {
16722       var xi = polygon2[i3][0];
16723       var yi = polygon2[i3][1];
16724       var xj = polygon2[j2][0];
16725       var yj = polygon2[j2][1];
16726       var intersect2 = yi > y2 !== yj > y2 && x2 < (xj - xi) * (y2 - yi) / (yj - yi) + xi;
16727       if (intersect2) inside = !inside;
16728     }
16729     return inside;
16730   }
16731   function geoPolygonContainsPolygon(outer, inner) {
16732     return inner.every(function(point) {
16733       return geoPointInPolygon(point, outer);
16734     });
16735   }
16736   function geoPolygonIntersectsPolygon(outer, inner, checkSegments) {
16737     function testPoints(outer2, inner2) {
16738       return inner2.some(function(point) {
16739         return geoPointInPolygon(point, outer2);
16740       });
16741     }
16742     return testPoints(outer, inner) || !!checkSegments && geoPathHasIntersections(outer, inner);
16743   }
16744   function geoGetSmallestSurroundingRectangle(points) {
16745     var hull = hull_default(points);
16746     var centroid = centroid_default2(hull);
16747     var minArea = Infinity;
16748     var ssrExtent = [];
16749     var ssrAngle = 0;
16750     var c1 = hull[0];
16751     for (var i3 = 0; i3 <= hull.length - 1; i3++) {
16752       var c2 = i3 === hull.length - 1 ? hull[0] : hull[i3 + 1];
16753       var angle2 = Math.atan2(c2[1] - c1[1], c2[0] - c1[0]);
16754       var poly = geoRotate(hull, -angle2, centroid);
16755       var extent = poly.reduce(function(extent2, point) {
16756         return extent2.extend(geoExtent(point));
16757       }, geoExtent());
16758       var area = extent.area();
16759       if (area < minArea) {
16760         minArea = area;
16761         ssrExtent = extent;
16762         ssrAngle = angle2;
16763       }
16764       c1 = c2;
16765     }
16766     return {
16767       poly: geoRotate(ssrExtent.polygon(), ssrAngle, centroid),
16768       angle: ssrAngle
16769     };
16770   }
16771   function geoPathLength(path) {
16772     var length2 = 0;
16773     for (var i3 = 0; i3 < path.length - 1; i3++) {
16774       length2 += geoVecLength(path[i3], path[i3 + 1]);
16775     }
16776     return length2;
16777   }
16778   function geoViewportEdge(point, dimensions) {
16779     var pad2 = [80, 20, 50, 20];
16780     var x2 = 0;
16781     var y2 = 0;
16782     if (point[0] > dimensions[0] - pad2[1]) {
16783       x2 = -10;
16784     }
16785     if (point[0] < pad2[3]) {
16786       x2 = 10;
16787     }
16788     if (point[1] > dimensions[1] - pad2[2]) {
16789       y2 = -10;
16790     }
16791     if (point[1] < pad2[0]) {
16792       y2 = 10;
16793     }
16794     if (x2 || y2) {
16795       return [x2, y2];
16796     } else {
16797       return null;
16798     }
16799   }
16800
16801   // node_modules/d3-dispatch/src/dispatch.js
16802   var noop2 = { value: () => {
16803   } };
16804   function dispatch() {
16805     for (var i3 = 0, n3 = arguments.length, _2 = {}, t2; i3 < n3; ++i3) {
16806       if (!(t2 = arguments[i3] + "") || t2 in _2 || /[\s.]/.test(t2)) throw new Error("illegal type: " + t2);
16807       _2[t2] = [];
16808     }
16809     return new Dispatch(_2);
16810   }
16811   function Dispatch(_2) {
16812     this._ = _2;
16813   }
16814   function parseTypenames(typenames, types) {
16815     return typenames.trim().split(/^|\s+/).map(function(t2) {
16816       var name = "", i3 = t2.indexOf(".");
16817       if (i3 >= 0) name = t2.slice(i3 + 1), t2 = t2.slice(0, i3);
16818       if (t2 && !types.hasOwnProperty(t2)) throw new Error("unknown type: " + t2);
16819       return { type: t2, name };
16820     });
16821   }
16822   Dispatch.prototype = dispatch.prototype = {
16823     constructor: Dispatch,
16824     on: function(typename, callback) {
16825       var _2 = this._, T2 = parseTypenames(typename + "", _2), t2, i3 = -1, n3 = T2.length;
16826       if (arguments.length < 2) {
16827         while (++i3 < n3) if ((t2 = (typename = T2[i3]).type) && (t2 = get(_2[t2], typename.name))) return t2;
16828         return;
16829       }
16830       if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback);
16831       while (++i3 < n3) {
16832         if (t2 = (typename = T2[i3]).type) _2[t2] = set(_2[t2], typename.name, callback);
16833         else if (callback == null) for (t2 in _2) _2[t2] = set(_2[t2], typename.name, null);
16834       }
16835       return this;
16836     },
16837     copy: function() {
16838       var copy2 = {}, _2 = this._;
16839       for (var t2 in _2) copy2[t2] = _2[t2].slice();
16840       return new Dispatch(copy2);
16841     },
16842     call: function(type2, that) {
16843       if ((n3 = arguments.length - 2) > 0) for (var args = new Array(n3), i3 = 0, n3, t2; i3 < n3; ++i3) args[i3] = arguments[i3 + 2];
16844       if (!this._.hasOwnProperty(type2)) throw new Error("unknown type: " + type2);
16845       for (t2 = this._[type2], i3 = 0, n3 = t2.length; i3 < n3; ++i3) t2[i3].value.apply(that, args);
16846     },
16847     apply: function(type2, that, args) {
16848       if (!this._.hasOwnProperty(type2)) throw new Error("unknown type: " + type2);
16849       for (var t2 = this._[type2], i3 = 0, n3 = t2.length; i3 < n3; ++i3) t2[i3].value.apply(that, args);
16850     }
16851   };
16852   function get(type2, name) {
16853     for (var i3 = 0, n3 = type2.length, c2; i3 < n3; ++i3) {
16854       if ((c2 = type2[i3]).name === name) {
16855         return c2.value;
16856       }
16857     }
16858   }
16859   function set(type2, name, callback) {
16860     for (var i3 = 0, n3 = type2.length; i3 < n3; ++i3) {
16861       if (type2[i3].name === name) {
16862         type2[i3] = noop2, type2 = type2.slice(0, i3).concat(type2.slice(i3 + 1));
16863         break;
16864       }
16865     }
16866     if (callback != null) type2.push({ name, value: callback });
16867     return type2;
16868   }
16869   var dispatch_default = dispatch;
16870
16871   // node_modules/d3-selection/src/namespaces.js
16872   var xhtml = "http://www.w3.org/1999/xhtml";
16873   var namespaces_default = {
16874     svg: "http://www.w3.org/2000/svg",
16875     xhtml,
16876     xlink: "http://www.w3.org/1999/xlink",
16877     xml: "http://www.w3.org/XML/1998/namespace",
16878     xmlns: "http://www.w3.org/2000/xmlns/"
16879   };
16880
16881   // node_modules/d3-selection/src/namespace.js
16882   function namespace_default(name) {
16883     var prefix = name += "", i3 = prefix.indexOf(":");
16884     if (i3 >= 0 && (prefix = name.slice(0, i3)) !== "xmlns") name = name.slice(i3 + 1);
16885     return namespaces_default.hasOwnProperty(prefix) ? { space: namespaces_default[prefix], local: name } : name;
16886   }
16887
16888   // node_modules/d3-selection/src/creator.js
16889   function creatorInherit(name) {
16890     return function() {
16891       var document2 = this.ownerDocument, uri = this.namespaceURI;
16892       return uri === xhtml && document2.documentElement.namespaceURI === xhtml ? document2.createElement(name) : document2.createElementNS(uri, name);
16893     };
16894   }
16895   function creatorFixed(fullname) {
16896     return function() {
16897       return this.ownerDocument.createElementNS(fullname.space, fullname.local);
16898     };
16899   }
16900   function creator_default(name) {
16901     var fullname = namespace_default(name);
16902     return (fullname.local ? creatorFixed : creatorInherit)(fullname);
16903   }
16904
16905   // node_modules/d3-selection/src/selector.js
16906   function none() {
16907   }
16908   function selector_default(selector) {
16909     return selector == null ? none : function() {
16910       return this.querySelector(selector);
16911     };
16912   }
16913
16914   // node_modules/d3-selection/src/selection/select.js
16915   function select_default(select) {
16916     if (typeof select !== "function") select = selector_default(select);
16917     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
16918       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) {
16919         if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) {
16920           if ("__data__" in node) subnode.__data__ = node.__data__;
16921           subgroup[i3] = subnode;
16922         }
16923       }
16924     }
16925     return new Selection(subgroups, this._parents);
16926   }
16927
16928   // node_modules/d3-selection/src/array.js
16929   function array(x2) {
16930     return x2 == null ? [] : Array.isArray(x2) ? x2 : Array.from(x2);
16931   }
16932
16933   // node_modules/d3-selection/src/selectorAll.js
16934   function empty() {
16935     return [];
16936   }
16937   function selectorAll_default(selector) {
16938     return selector == null ? empty : function() {
16939       return this.querySelectorAll(selector);
16940     };
16941   }
16942
16943   // node_modules/d3-selection/src/selection/selectAll.js
16944   function arrayAll(select) {
16945     return function() {
16946       return array(select.apply(this, arguments));
16947     };
16948   }
16949   function selectAll_default(select) {
16950     if (typeof select === "function") select = arrayAll(select);
16951     else select = selectorAll_default(select);
16952     for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) {
16953       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
16954         if (node = group[i3]) {
16955           subgroups.push(select.call(node, node.__data__, i3, group));
16956           parents.push(node);
16957         }
16958       }
16959     }
16960     return new Selection(subgroups, parents);
16961   }
16962
16963   // node_modules/d3-selection/src/matcher.js
16964   function matcher_default(selector) {
16965     return function() {
16966       return this.matches(selector);
16967     };
16968   }
16969   function childMatcher(selector) {
16970     return function(node) {
16971       return node.matches(selector);
16972     };
16973   }
16974
16975   // node_modules/d3-selection/src/selection/selectChild.js
16976   var find = Array.prototype.find;
16977   function childFind(match) {
16978     return function() {
16979       return find.call(this.children, match);
16980     };
16981   }
16982   function childFirst() {
16983     return this.firstElementChild;
16984   }
16985   function selectChild_default(match) {
16986     return this.select(match == null ? childFirst : childFind(typeof match === "function" ? match : childMatcher(match)));
16987   }
16988
16989   // node_modules/d3-selection/src/selection/selectChildren.js
16990   var filter = Array.prototype.filter;
16991   function children() {
16992     return Array.from(this.children);
16993   }
16994   function childrenFilter(match) {
16995     return function() {
16996       return filter.call(this.children, match);
16997     };
16998   }
16999   function selectChildren_default(match) {
17000     return this.selectAll(match == null ? children : childrenFilter(typeof match === "function" ? match : childMatcher(match)));
17001   }
17002
17003   // node_modules/d3-selection/src/selection/filter.js
17004   function filter_default(match) {
17005     if (typeof match !== "function") match = matcher_default(match);
17006     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
17007       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) {
17008         if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) {
17009           subgroup.push(node);
17010         }
17011       }
17012     }
17013     return new Selection(subgroups, this._parents);
17014   }
17015
17016   // node_modules/d3-selection/src/selection/sparse.js
17017   function sparse_default(update) {
17018     return new Array(update.length);
17019   }
17020
17021   // node_modules/d3-selection/src/selection/enter.js
17022   function enter_default() {
17023     return new Selection(this._enter || this._groups.map(sparse_default), this._parents);
17024   }
17025   function EnterNode(parent, datum2) {
17026     this.ownerDocument = parent.ownerDocument;
17027     this.namespaceURI = parent.namespaceURI;
17028     this._next = null;
17029     this._parent = parent;
17030     this.__data__ = datum2;
17031   }
17032   EnterNode.prototype = {
17033     constructor: EnterNode,
17034     appendChild: function(child) {
17035       return this._parent.insertBefore(child, this._next);
17036     },
17037     insertBefore: function(child, next) {
17038       return this._parent.insertBefore(child, next);
17039     },
17040     querySelector: function(selector) {
17041       return this._parent.querySelector(selector);
17042     },
17043     querySelectorAll: function(selector) {
17044       return this._parent.querySelectorAll(selector);
17045     }
17046   };
17047
17048   // node_modules/d3-selection/src/constant.js
17049   function constant_default(x2) {
17050     return function() {
17051       return x2;
17052     };
17053   }
17054
17055   // node_modules/d3-selection/src/selection/data.js
17056   function bindIndex(parent, group, enter, update, exit, data) {
17057     var i3 = 0, node, groupLength = group.length, dataLength = data.length;
17058     for (; i3 < dataLength; ++i3) {
17059       if (node = group[i3]) {
17060         node.__data__ = data[i3];
17061         update[i3] = node;
17062       } else {
17063         enter[i3] = new EnterNode(parent, data[i3]);
17064       }
17065     }
17066     for (; i3 < groupLength; ++i3) {
17067       if (node = group[i3]) {
17068         exit[i3] = node;
17069       }
17070     }
17071   }
17072   function bindKey(parent, group, enter, update, exit, data, key) {
17073     var i3, node, nodeByKeyValue = /* @__PURE__ */ new Map(), groupLength = group.length, dataLength = data.length, keyValues = new Array(groupLength), keyValue;
17074     for (i3 = 0; i3 < groupLength; ++i3) {
17075       if (node = group[i3]) {
17076         keyValues[i3] = keyValue = key.call(node, node.__data__, i3, group) + "";
17077         if (nodeByKeyValue.has(keyValue)) {
17078           exit[i3] = node;
17079         } else {
17080           nodeByKeyValue.set(keyValue, node);
17081         }
17082       }
17083     }
17084     for (i3 = 0; i3 < dataLength; ++i3) {
17085       keyValue = key.call(parent, data[i3], i3, data) + "";
17086       if (node = nodeByKeyValue.get(keyValue)) {
17087         update[i3] = node;
17088         node.__data__ = data[i3];
17089         nodeByKeyValue.delete(keyValue);
17090       } else {
17091         enter[i3] = new EnterNode(parent, data[i3]);
17092       }
17093     }
17094     for (i3 = 0; i3 < groupLength; ++i3) {
17095       if ((node = group[i3]) && nodeByKeyValue.get(keyValues[i3]) === node) {
17096         exit[i3] = node;
17097       }
17098     }
17099   }
17100   function datum(node) {
17101     return node.__data__;
17102   }
17103   function data_default(value, key) {
17104     if (!arguments.length) return Array.from(this, datum);
17105     var bind = key ? bindKey : bindIndex, parents = this._parents, groups = this._groups;
17106     if (typeof value !== "function") value = constant_default(value);
17107     for (var m2 = groups.length, update = new Array(m2), enter = new Array(m2), exit = new Array(m2), j2 = 0; j2 < m2; ++j2) {
17108       var parent = parents[j2], group = groups[j2], groupLength = group.length, data = arraylike(value.call(parent, parent && parent.__data__, j2, parents)), dataLength = data.length, enterGroup = enter[j2] = new Array(dataLength), updateGroup = update[j2] = new Array(dataLength), exitGroup = exit[j2] = new Array(groupLength);
17109       bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
17110       for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
17111         if (previous = enterGroup[i0]) {
17112           if (i0 >= i1) i1 = i0 + 1;
17113           while (!(next = updateGroup[i1]) && ++i1 < dataLength) ;
17114           previous._next = next || null;
17115         }
17116       }
17117     }
17118     update = new Selection(update, parents);
17119     update._enter = enter;
17120     update._exit = exit;
17121     return update;
17122   }
17123   function arraylike(data) {
17124     return typeof data === "object" && "length" in data ? data : Array.from(data);
17125   }
17126
17127   // node_modules/d3-selection/src/selection/exit.js
17128   function exit_default() {
17129     return new Selection(this._exit || this._groups.map(sparse_default), this._parents);
17130   }
17131
17132   // node_modules/d3-selection/src/selection/join.js
17133   function join_default(onenter, onupdate, onexit) {
17134     var enter = this.enter(), update = this, exit = this.exit();
17135     if (typeof onenter === "function") {
17136       enter = onenter(enter);
17137       if (enter) enter = enter.selection();
17138     } else {
17139       enter = enter.append(onenter + "");
17140     }
17141     if (onupdate != null) {
17142       update = onupdate(update);
17143       if (update) update = update.selection();
17144     }
17145     if (onexit == null) exit.remove();
17146     else onexit(exit);
17147     return enter && update ? enter.merge(update).order() : update;
17148   }
17149
17150   // node_modules/d3-selection/src/selection/merge.js
17151   function merge_default(context) {
17152     var selection2 = context.selection ? context.selection() : context;
17153     for (var groups0 = this._groups, groups1 = selection2._groups, m0 = groups0.length, m1 = groups1.length, m2 = Math.min(m0, m1), merges = new Array(m0), j2 = 0; j2 < m2; ++j2) {
17154       for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge2 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
17155         if (node = group0[i3] || group1[i3]) {
17156           merge2[i3] = node;
17157         }
17158       }
17159     }
17160     for (; j2 < m0; ++j2) {
17161       merges[j2] = groups0[j2];
17162     }
17163     return new Selection(merges, this._parents);
17164   }
17165
17166   // node_modules/d3-selection/src/selection/order.js
17167   function order_default() {
17168     for (var groups = this._groups, j2 = -1, m2 = groups.length; ++j2 < m2; ) {
17169       for (var group = groups[j2], i3 = group.length - 1, next = group[i3], node; --i3 >= 0; ) {
17170         if (node = group[i3]) {
17171           if (next && node.compareDocumentPosition(next) ^ 4) next.parentNode.insertBefore(node, next);
17172           next = node;
17173         }
17174       }
17175     }
17176     return this;
17177   }
17178
17179   // node_modules/d3-selection/src/selection/sort.js
17180   function sort_default(compare2) {
17181     if (!compare2) compare2 = ascending2;
17182     function compareNode(a2, b2) {
17183       return a2 && b2 ? compare2(a2.__data__, b2.__data__) : !a2 - !b2;
17184     }
17185     for (var groups = this._groups, m2 = groups.length, sortgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
17186       for (var group = groups[j2], n3 = group.length, sortgroup = sortgroups[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
17187         if (node = group[i3]) {
17188           sortgroup[i3] = node;
17189         }
17190       }
17191       sortgroup.sort(compareNode);
17192     }
17193     return new Selection(sortgroups, this._parents).order();
17194   }
17195   function ascending2(a2, b2) {
17196     return a2 < b2 ? -1 : a2 > b2 ? 1 : a2 >= b2 ? 0 : NaN;
17197   }
17198
17199   // node_modules/d3-selection/src/selection/call.js
17200   function call_default() {
17201     var callback = arguments[0];
17202     arguments[0] = this;
17203     callback.apply(null, arguments);
17204     return this;
17205   }
17206
17207   // node_modules/d3-selection/src/selection/nodes.js
17208   function nodes_default() {
17209     return Array.from(this);
17210   }
17211
17212   // node_modules/d3-selection/src/selection/node.js
17213   function node_default() {
17214     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
17215       for (var group = groups[j2], i3 = 0, n3 = group.length; i3 < n3; ++i3) {
17216         var node = group[i3];
17217         if (node) return node;
17218       }
17219     }
17220     return null;
17221   }
17222
17223   // node_modules/d3-selection/src/selection/size.js
17224   function size_default() {
17225     let size = 0;
17226     for (const node of this) ++size;
17227     return size;
17228   }
17229
17230   // node_modules/d3-selection/src/selection/empty.js
17231   function empty_default() {
17232     return !this.node();
17233   }
17234
17235   // node_modules/d3-selection/src/selection/each.js
17236   function each_default(callback) {
17237     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
17238       for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) {
17239         if (node = group[i3]) callback.call(node, node.__data__, i3, group);
17240       }
17241     }
17242     return this;
17243   }
17244
17245   // node_modules/d3-selection/src/selection/attr.js
17246   function attrRemove(name) {
17247     return function() {
17248       this.removeAttribute(name);
17249     };
17250   }
17251   function attrRemoveNS(fullname) {
17252     return function() {
17253       this.removeAttributeNS(fullname.space, fullname.local);
17254     };
17255   }
17256   function attrConstant(name, value) {
17257     return function() {
17258       this.setAttribute(name, value);
17259     };
17260   }
17261   function attrConstantNS(fullname, value) {
17262     return function() {
17263       this.setAttributeNS(fullname.space, fullname.local, value);
17264     };
17265   }
17266   function attrFunction(name, value) {
17267     return function() {
17268       var v2 = value.apply(this, arguments);
17269       if (v2 == null) this.removeAttribute(name);
17270       else this.setAttribute(name, v2);
17271     };
17272   }
17273   function attrFunctionNS(fullname, value) {
17274     return function() {
17275       var v2 = value.apply(this, arguments);
17276       if (v2 == null) this.removeAttributeNS(fullname.space, fullname.local);
17277       else this.setAttributeNS(fullname.space, fullname.local, v2);
17278     };
17279   }
17280   function attr_default(name, value) {
17281     var fullname = namespace_default(name);
17282     if (arguments.length < 2) {
17283       var node = this.node();
17284       return fullname.local ? node.getAttributeNS(fullname.space, fullname.local) : node.getAttribute(fullname);
17285     }
17286     return this.each((value == null ? fullname.local ? attrRemoveNS : attrRemove : typeof value === "function" ? fullname.local ? attrFunctionNS : attrFunction : fullname.local ? attrConstantNS : attrConstant)(fullname, value));
17287   }
17288
17289   // node_modules/d3-selection/src/window.js
17290   function window_default(node) {
17291     return node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView;
17292   }
17293
17294   // node_modules/d3-selection/src/selection/style.js
17295   function styleRemove(name) {
17296     return function() {
17297       this.style.removeProperty(name);
17298     };
17299   }
17300   function styleConstant(name, value, priority) {
17301     return function() {
17302       this.style.setProperty(name, value, priority);
17303     };
17304   }
17305   function styleFunction(name, value, priority) {
17306     return function() {
17307       var v2 = value.apply(this, arguments);
17308       if (v2 == null) this.style.removeProperty(name);
17309       else this.style.setProperty(name, v2, priority);
17310     };
17311   }
17312   function style_default(name, value, priority) {
17313     return arguments.length > 1 ? this.each((value == null ? styleRemove : typeof value === "function" ? styleFunction : styleConstant)(name, value, priority == null ? "" : priority)) : styleValue(this.node(), name);
17314   }
17315   function styleValue(node, name) {
17316     return node.style.getPropertyValue(name) || window_default(node).getComputedStyle(node, null).getPropertyValue(name);
17317   }
17318
17319   // node_modules/d3-selection/src/selection/property.js
17320   function propertyRemove(name) {
17321     return function() {
17322       delete this[name];
17323     };
17324   }
17325   function propertyConstant(name, value) {
17326     return function() {
17327       this[name] = value;
17328     };
17329   }
17330   function propertyFunction(name, value) {
17331     return function() {
17332       var v2 = value.apply(this, arguments);
17333       if (v2 == null) delete this[name];
17334       else this[name] = v2;
17335     };
17336   }
17337   function property_default(name, value) {
17338     return arguments.length > 1 ? this.each((value == null ? propertyRemove : typeof value === "function" ? propertyFunction : propertyConstant)(name, value)) : this.node()[name];
17339   }
17340
17341   // node_modules/d3-selection/src/selection/classed.js
17342   function classArray(string) {
17343     return string.trim().split(/^|\s+/);
17344   }
17345   function classList(node) {
17346     return node.classList || new ClassList(node);
17347   }
17348   function ClassList(node) {
17349     this._node = node;
17350     this._names = classArray(node.getAttribute("class") || "");
17351   }
17352   ClassList.prototype = {
17353     add: function(name) {
17354       var i3 = this._names.indexOf(name);
17355       if (i3 < 0) {
17356         this._names.push(name);
17357         this._node.setAttribute("class", this._names.join(" "));
17358       }
17359     },
17360     remove: function(name) {
17361       var i3 = this._names.indexOf(name);
17362       if (i3 >= 0) {
17363         this._names.splice(i3, 1);
17364         this._node.setAttribute("class", this._names.join(" "));
17365       }
17366     },
17367     contains: function(name) {
17368       return this._names.indexOf(name) >= 0;
17369     }
17370   };
17371   function classedAdd(node, names) {
17372     var list2 = classList(node), i3 = -1, n3 = names.length;
17373     while (++i3 < n3) list2.add(names[i3]);
17374   }
17375   function classedRemove(node, names) {
17376     var list2 = classList(node), i3 = -1, n3 = names.length;
17377     while (++i3 < n3) list2.remove(names[i3]);
17378   }
17379   function classedTrue(names) {
17380     return function() {
17381       classedAdd(this, names);
17382     };
17383   }
17384   function classedFalse(names) {
17385     return function() {
17386       classedRemove(this, names);
17387     };
17388   }
17389   function classedFunction(names, value) {
17390     return function() {
17391       (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
17392     };
17393   }
17394   function classed_default(name, value) {
17395     var names = classArray(name + "");
17396     if (arguments.length < 2) {
17397       var list2 = classList(this.node()), i3 = -1, n3 = names.length;
17398       while (++i3 < n3) if (!list2.contains(names[i3])) return false;
17399       return true;
17400     }
17401     return this.each((typeof value === "function" ? classedFunction : value ? classedTrue : classedFalse)(names, value));
17402   }
17403
17404   // node_modules/d3-selection/src/selection/text.js
17405   function textRemove() {
17406     this.textContent = "";
17407   }
17408   function textConstant(value) {
17409     return function() {
17410       this.textContent = value;
17411     };
17412   }
17413   function textFunction(value) {
17414     return function() {
17415       var v2 = value.apply(this, arguments);
17416       this.textContent = v2 == null ? "" : v2;
17417     };
17418   }
17419   function text_default(value) {
17420     return arguments.length ? this.each(value == null ? textRemove : (typeof value === "function" ? textFunction : textConstant)(value)) : this.node().textContent;
17421   }
17422
17423   // node_modules/d3-selection/src/selection/html.js
17424   function htmlRemove() {
17425     this.innerHTML = "";
17426   }
17427   function htmlConstant(value) {
17428     return function() {
17429       this.innerHTML = value;
17430     };
17431   }
17432   function htmlFunction(value) {
17433     return function() {
17434       var v2 = value.apply(this, arguments);
17435       this.innerHTML = v2 == null ? "" : v2;
17436     };
17437   }
17438   function html_default(value) {
17439     return arguments.length ? this.each(value == null ? htmlRemove : (typeof value === "function" ? htmlFunction : htmlConstant)(value)) : this.node().innerHTML;
17440   }
17441
17442   // node_modules/d3-selection/src/selection/raise.js
17443   function raise() {
17444     if (this.nextSibling) this.parentNode.appendChild(this);
17445   }
17446   function raise_default() {
17447     return this.each(raise);
17448   }
17449
17450   // node_modules/d3-selection/src/selection/lower.js
17451   function lower() {
17452     if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild);
17453   }
17454   function lower_default() {
17455     return this.each(lower);
17456   }
17457
17458   // node_modules/d3-selection/src/selection/append.js
17459   function append_default(name) {
17460     var create2 = typeof name === "function" ? name : creator_default(name);
17461     return this.select(function() {
17462       return this.appendChild(create2.apply(this, arguments));
17463     });
17464   }
17465
17466   // node_modules/d3-selection/src/selection/insert.js
17467   function constantNull() {
17468     return null;
17469   }
17470   function insert_default(name, before) {
17471     var create2 = typeof name === "function" ? name : creator_default(name), select = before == null ? constantNull : typeof before === "function" ? before : selector_default(before);
17472     return this.select(function() {
17473       return this.insertBefore(create2.apply(this, arguments), select.apply(this, arguments) || null);
17474     });
17475   }
17476
17477   // node_modules/d3-selection/src/selection/remove.js
17478   function remove() {
17479     var parent = this.parentNode;
17480     if (parent) parent.removeChild(this);
17481   }
17482   function remove_default() {
17483     return this.each(remove);
17484   }
17485
17486   // node_modules/d3-selection/src/selection/clone.js
17487   function selection_cloneShallow() {
17488     var clone2 = this.cloneNode(false), parent = this.parentNode;
17489     return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2;
17490   }
17491   function selection_cloneDeep() {
17492     var clone2 = this.cloneNode(true), parent = this.parentNode;
17493     return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2;
17494   }
17495   function clone_default(deep) {
17496     return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
17497   }
17498
17499   // node_modules/d3-selection/src/selection/datum.js
17500   function datum_default(value) {
17501     return arguments.length ? this.property("__data__", value) : this.node().__data__;
17502   }
17503
17504   // node_modules/d3-selection/src/selection/on.js
17505   function contextListener(listener) {
17506     return function(event) {
17507       listener.call(this, event, this.__data__);
17508     };
17509   }
17510   function parseTypenames2(typenames) {
17511     return typenames.trim().split(/^|\s+/).map(function(t2) {
17512       var name = "", i3 = t2.indexOf(".");
17513       if (i3 >= 0) name = t2.slice(i3 + 1), t2 = t2.slice(0, i3);
17514       return { type: t2, name };
17515     });
17516   }
17517   function onRemove(typename) {
17518     return function() {
17519       var on = this.__on;
17520       if (!on) return;
17521       for (var j2 = 0, i3 = -1, m2 = on.length, o2; j2 < m2; ++j2) {
17522         if (o2 = on[j2], (!typename.type || o2.type === typename.type) && o2.name === typename.name) {
17523           this.removeEventListener(o2.type, o2.listener, o2.options);
17524         } else {
17525           on[++i3] = o2;
17526         }
17527       }
17528       if (++i3) on.length = i3;
17529       else delete this.__on;
17530     };
17531   }
17532   function onAdd(typename, value, options2) {
17533     return function() {
17534       var on = this.__on, o2, listener = contextListener(value);
17535       if (on) for (var j2 = 0, m2 = on.length; j2 < m2; ++j2) {
17536         if ((o2 = on[j2]).type === typename.type && o2.name === typename.name) {
17537           this.removeEventListener(o2.type, o2.listener, o2.options);
17538           this.addEventListener(o2.type, o2.listener = listener, o2.options = options2);
17539           o2.value = value;
17540           return;
17541         }
17542       }
17543       this.addEventListener(typename.type, listener, options2);
17544       o2 = { type: typename.type, name: typename.name, value, listener, options: options2 };
17545       if (!on) this.__on = [o2];
17546       else on.push(o2);
17547     };
17548   }
17549   function on_default(typename, value, options2) {
17550     var typenames = parseTypenames2(typename + ""), i3, n3 = typenames.length, t2;
17551     if (arguments.length < 2) {
17552       var on = this.node().__on;
17553       if (on) for (var j2 = 0, m2 = on.length, o2; j2 < m2; ++j2) {
17554         for (i3 = 0, o2 = on[j2]; i3 < n3; ++i3) {
17555           if ((t2 = typenames[i3]).type === o2.type && t2.name === o2.name) {
17556             return o2.value;
17557           }
17558         }
17559       }
17560       return;
17561     }
17562     on = value ? onAdd : onRemove;
17563     for (i3 = 0; i3 < n3; ++i3) this.each(on(typenames[i3], value, options2));
17564     return this;
17565   }
17566
17567   // node_modules/d3-selection/src/selection/dispatch.js
17568   function dispatchEvent(node, type2, params) {
17569     var window2 = window_default(node), event = window2.CustomEvent;
17570     if (typeof event === "function") {
17571       event = new event(type2, params);
17572     } else {
17573       event = window2.document.createEvent("Event");
17574       if (params) event.initEvent(type2, params.bubbles, params.cancelable), event.detail = params.detail;
17575       else event.initEvent(type2, false, false);
17576     }
17577     node.dispatchEvent(event);
17578   }
17579   function dispatchConstant(type2, params) {
17580     return function() {
17581       return dispatchEvent(this, type2, params);
17582     };
17583   }
17584   function dispatchFunction(type2, params) {
17585     return function() {
17586       return dispatchEvent(this, type2, params.apply(this, arguments));
17587     };
17588   }
17589   function dispatch_default2(type2, params) {
17590     return this.each((typeof params === "function" ? dispatchFunction : dispatchConstant)(type2, params));
17591   }
17592
17593   // node_modules/d3-selection/src/selection/iterator.js
17594   function* iterator_default() {
17595     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
17596       for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) {
17597         if (node = group[i3]) yield node;
17598       }
17599     }
17600   }
17601
17602   // node_modules/d3-selection/src/selection/index.js
17603   var root = [null];
17604   function Selection(groups, parents) {
17605     this._groups = groups;
17606     this._parents = parents;
17607   }
17608   function selection() {
17609     return new Selection([[document.documentElement]], root);
17610   }
17611   function selection_selection() {
17612     return this;
17613   }
17614   Selection.prototype = selection.prototype = {
17615     constructor: Selection,
17616     select: select_default,
17617     selectAll: selectAll_default,
17618     selectChild: selectChild_default,
17619     selectChildren: selectChildren_default,
17620     filter: filter_default,
17621     data: data_default,
17622     enter: enter_default,
17623     exit: exit_default,
17624     join: join_default,
17625     merge: merge_default,
17626     selection: selection_selection,
17627     order: order_default,
17628     sort: sort_default,
17629     call: call_default,
17630     nodes: nodes_default,
17631     node: node_default,
17632     size: size_default,
17633     empty: empty_default,
17634     each: each_default,
17635     attr: attr_default,
17636     style: style_default,
17637     property: property_default,
17638     classed: classed_default,
17639     text: text_default,
17640     html: html_default,
17641     raise: raise_default,
17642     lower: lower_default,
17643     append: append_default,
17644     insert: insert_default,
17645     remove: remove_default,
17646     clone: clone_default,
17647     datum: datum_default,
17648     on: on_default,
17649     dispatch: dispatch_default2,
17650     [Symbol.iterator]: iterator_default
17651   };
17652   var selection_default = selection;
17653
17654   // node_modules/d3-selection/src/select.js
17655   function select_default2(selector) {
17656     return typeof selector === "string" ? new Selection([[document.querySelector(selector)]], [document.documentElement]) : new Selection([[selector]], root);
17657   }
17658
17659   // node_modules/d3-selection/src/sourceEvent.js
17660   function sourceEvent_default(event) {
17661     let sourceEvent;
17662     while (sourceEvent = event.sourceEvent) event = sourceEvent;
17663     return event;
17664   }
17665
17666   // node_modules/d3-selection/src/pointer.js
17667   function pointer_default(event, node) {
17668     event = sourceEvent_default(event);
17669     if (node === void 0) node = event.currentTarget;
17670     if (node) {
17671       var svg2 = node.ownerSVGElement || node;
17672       if (svg2.createSVGPoint) {
17673         var point = svg2.createSVGPoint();
17674         point.x = event.clientX, point.y = event.clientY;
17675         point = point.matrixTransform(node.getScreenCTM().inverse());
17676         return [point.x, point.y];
17677       }
17678       if (node.getBoundingClientRect) {
17679         var rect = node.getBoundingClientRect();
17680         return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
17681       }
17682     }
17683     return [event.pageX, event.pageY];
17684   }
17685
17686   // node_modules/d3-selection/src/selectAll.js
17687   function selectAll_default2(selector) {
17688     return typeof selector === "string" ? new Selection([document.querySelectorAll(selector)], [document.documentElement]) : new Selection([array(selector)], root);
17689   }
17690
17691   // node_modules/d3-drag/src/noevent.js
17692   var nonpassive = { passive: false };
17693   var nonpassivecapture = { capture: true, passive: false };
17694   function nopropagation(event) {
17695     event.stopImmediatePropagation();
17696   }
17697   function noevent_default(event) {
17698     event.preventDefault();
17699     event.stopImmediatePropagation();
17700   }
17701
17702   // node_modules/d3-drag/src/nodrag.js
17703   function nodrag_default(view) {
17704     var root3 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", noevent_default, nonpassivecapture);
17705     if ("onselectstart" in root3) {
17706       selection2.on("selectstart.drag", noevent_default, nonpassivecapture);
17707     } else {
17708       root3.__noselect = root3.style.MozUserSelect;
17709       root3.style.MozUserSelect = "none";
17710     }
17711   }
17712   function yesdrag(view, noclick) {
17713     var root3 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", null);
17714     if (noclick) {
17715       selection2.on("click.drag", noevent_default, nonpassivecapture);
17716       setTimeout(function() {
17717         selection2.on("click.drag", null);
17718       }, 0);
17719     }
17720     if ("onselectstart" in root3) {
17721       selection2.on("selectstart.drag", null);
17722     } else {
17723       root3.style.MozUserSelect = root3.__noselect;
17724       delete root3.__noselect;
17725     }
17726   }
17727
17728   // node_modules/d3-drag/src/constant.js
17729   var constant_default2 = (x2) => () => x2;
17730
17731   // node_modules/d3-drag/src/event.js
17732   function DragEvent(type2, {
17733     sourceEvent,
17734     subject,
17735     target,
17736     identifier,
17737     active,
17738     x: x2,
17739     y: y2,
17740     dx,
17741     dy,
17742     dispatch: dispatch14
17743   }) {
17744     Object.defineProperties(this, {
17745       type: { value: type2, enumerable: true, configurable: true },
17746       sourceEvent: { value: sourceEvent, enumerable: true, configurable: true },
17747       subject: { value: subject, enumerable: true, configurable: true },
17748       target: { value: target, enumerable: true, configurable: true },
17749       identifier: { value: identifier, enumerable: true, configurable: true },
17750       active: { value: active, enumerable: true, configurable: true },
17751       x: { value: x2, enumerable: true, configurable: true },
17752       y: { value: y2, enumerable: true, configurable: true },
17753       dx: { value: dx, enumerable: true, configurable: true },
17754       dy: { value: dy, enumerable: true, configurable: true },
17755       _: { value: dispatch14 }
17756     });
17757   }
17758   DragEvent.prototype.on = function() {
17759     var value = this._.on.apply(this._, arguments);
17760     return value === this._ ? this : value;
17761   };
17762
17763   // node_modules/d3-drag/src/drag.js
17764   function defaultFilter(event) {
17765     return !event.ctrlKey && !event.button;
17766   }
17767   function defaultContainer() {
17768     return this.parentNode;
17769   }
17770   function defaultSubject(event, d2) {
17771     return d2 == null ? { x: event.x, y: event.y } : d2;
17772   }
17773   function defaultTouchable() {
17774     return navigator.maxTouchPoints || "ontouchstart" in this;
17775   }
17776   function drag_default() {
17777     var filter2 = defaultFilter, container = defaultContainer, subject = defaultSubject, touchable = defaultTouchable, gestures = {}, listeners = dispatch_default("start", "drag", "end"), active = 0, mousedownx, mousedowny, mousemoving, touchending, clickDistance2 = 0;
17778     function drag(selection2) {
17779       selection2.on("mousedown.drag", mousedowned).filter(touchable).on("touchstart.drag", touchstarted).on("touchmove.drag", touchmoved, nonpassive).on("touchend.drag touchcancel.drag", touchended).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
17780     }
17781     function mousedowned(event, d2) {
17782       if (touchending || !filter2.call(this, event, d2)) return;
17783       var gesture = beforestart(this, container.call(this, event, d2), event, d2, "mouse");
17784       if (!gesture) return;
17785       select_default2(event.view).on("mousemove.drag", mousemoved, nonpassivecapture).on("mouseup.drag", mouseupped, nonpassivecapture);
17786       nodrag_default(event.view);
17787       nopropagation(event);
17788       mousemoving = false;
17789       mousedownx = event.clientX;
17790       mousedowny = event.clientY;
17791       gesture("start", event);
17792     }
17793     function mousemoved(event) {
17794       noevent_default(event);
17795       if (!mousemoving) {
17796         var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
17797         mousemoving = dx * dx + dy * dy > clickDistance2;
17798       }
17799       gestures.mouse("drag", event);
17800     }
17801     function mouseupped(event) {
17802       select_default2(event.view).on("mousemove.drag mouseup.drag", null);
17803       yesdrag(event.view, mousemoving);
17804       noevent_default(event);
17805       gestures.mouse("end", event);
17806     }
17807     function touchstarted(event, d2) {
17808       if (!filter2.call(this, event, d2)) return;
17809       var touches = event.changedTouches, c2 = container.call(this, event, d2), n3 = touches.length, i3, gesture;
17810       for (i3 = 0; i3 < n3; ++i3) {
17811         if (gesture = beforestart(this, c2, event, d2, touches[i3].identifier, touches[i3])) {
17812           nopropagation(event);
17813           gesture("start", event, touches[i3]);
17814         }
17815       }
17816     }
17817     function touchmoved(event) {
17818       var touches = event.changedTouches, n3 = touches.length, i3, gesture;
17819       for (i3 = 0; i3 < n3; ++i3) {
17820         if (gesture = gestures[touches[i3].identifier]) {
17821           noevent_default(event);
17822           gesture("drag", event, touches[i3]);
17823         }
17824       }
17825     }
17826     function touchended(event) {
17827       var touches = event.changedTouches, n3 = touches.length, i3, gesture;
17828       if (touchending) clearTimeout(touchending);
17829       touchending = setTimeout(function() {
17830         touchending = null;
17831       }, 500);
17832       for (i3 = 0; i3 < n3; ++i3) {
17833         if (gesture = gestures[touches[i3].identifier]) {
17834           nopropagation(event);
17835           gesture("end", event, touches[i3]);
17836         }
17837       }
17838     }
17839     function beforestart(that, container2, event, d2, identifier, touch) {
17840       var dispatch14 = listeners.copy(), p2 = pointer_default(touch || event, container2), dx, dy, s2;
17841       if ((s2 = subject.call(that, new DragEvent("beforestart", {
17842         sourceEvent: event,
17843         target: drag,
17844         identifier,
17845         active,
17846         x: p2[0],
17847         y: p2[1],
17848         dx: 0,
17849         dy: 0,
17850         dispatch: dispatch14
17851       }), d2)) == null) return;
17852       dx = s2.x - p2[0] || 0;
17853       dy = s2.y - p2[1] || 0;
17854       return function gesture(type2, event2, touch2) {
17855         var p02 = p2, n3;
17856         switch (type2) {
17857           case "start":
17858             gestures[identifier] = gesture, n3 = active++;
17859             break;
17860           case "end":
17861             delete gestures[identifier], --active;
17862           // falls through
17863           case "drag":
17864             p2 = pointer_default(touch2 || event2, container2), n3 = active;
17865             break;
17866         }
17867         dispatch14.call(
17868           type2,
17869           that,
17870           new DragEvent(type2, {
17871             sourceEvent: event2,
17872             subject: s2,
17873             target: drag,
17874             identifier,
17875             active: n3,
17876             x: p2[0] + dx,
17877             y: p2[1] + dy,
17878             dx: p2[0] - p02[0],
17879             dy: p2[1] - p02[1],
17880             dispatch: dispatch14
17881           }),
17882           d2
17883         );
17884       };
17885     }
17886     drag.filter = function(_2) {
17887       return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant_default2(!!_2), drag) : filter2;
17888     };
17889     drag.container = function(_2) {
17890       return arguments.length ? (container = typeof _2 === "function" ? _2 : constant_default2(_2), drag) : container;
17891     };
17892     drag.subject = function(_2) {
17893       return arguments.length ? (subject = typeof _2 === "function" ? _2 : constant_default2(_2), drag) : subject;
17894     };
17895     drag.touchable = function(_2) {
17896       return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant_default2(!!_2), drag) : touchable;
17897     };
17898     drag.on = function() {
17899       var value = listeners.on.apply(listeners, arguments);
17900       return value === listeners ? drag : value;
17901     };
17902     drag.clickDistance = function(_2) {
17903       return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, drag) : Math.sqrt(clickDistance2);
17904     };
17905     return drag;
17906   }
17907
17908   // node_modules/d3-color/src/define.js
17909   function define_default(constructor, factory, prototype) {
17910     constructor.prototype = factory.prototype = prototype;
17911     prototype.constructor = constructor;
17912   }
17913   function extend(parent, definition) {
17914     var prototype = Object.create(parent.prototype);
17915     for (var key in definition) prototype[key] = definition[key];
17916     return prototype;
17917   }
17918
17919   // node_modules/d3-color/src/color.js
17920   function Color() {
17921   }
17922   var darker = 0.7;
17923   var brighter = 1 / darker;
17924   var reI = "\\s*([+-]?\\d+)\\s*";
17925   var reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*";
17926   var reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*";
17927   var reHex = /^#([0-9a-f]{3,8})$/;
17928   var reRgbInteger = new RegExp("^rgb\\(".concat(reI, ",").concat(reI, ",").concat(reI, "\\)$"));
17929   var reRgbPercent = new RegExp("^rgb\\(".concat(reP, ",").concat(reP, ",").concat(reP, "\\)$"));
17930   var reRgbaInteger = new RegExp("^rgba\\(".concat(reI, ",").concat(reI, ",").concat(reI, ",").concat(reN, "\\)$"));
17931   var reRgbaPercent = new RegExp("^rgba\\(".concat(reP, ",").concat(reP, ",").concat(reP, ",").concat(reN, "\\)$"));
17932   var reHslPercent = new RegExp("^hsl\\(".concat(reN, ",").concat(reP, ",").concat(reP, "\\)$"));
17933   var reHslaPercent = new RegExp("^hsla\\(".concat(reN, ",").concat(reP, ",").concat(reP, ",").concat(reN, "\\)$"));
17934   var named = {
17935     aliceblue: 15792383,
17936     antiquewhite: 16444375,
17937     aqua: 65535,
17938     aquamarine: 8388564,
17939     azure: 15794175,
17940     beige: 16119260,
17941     bisque: 16770244,
17942     black: 0,
17943     blanchedalmond: 16772045,
17944     blue: 255,
17945     blueviolet: 9055202,
17946     brown: 10824234,
17947     burlywood: 14596231,
17948     cadetblue: 6266528,
17949     chartreuse: 8388352,
17950     chocolate: 13789470,
17951     coral: 16744272,
17952     cornflowerblue: 6591981,
17953     cornsilk: 16775388,
17954     crimson: 14423100,
17955     cyan: 65535,
17956     darkblue: 139,
17957     darkcyan: 35723,
17958     darkgoldenrod: 12092939,
17959     darkgray: 11119017,
17960     darkgreen: 25600,
17961     darkgrey: 11119017,
17962     darkkhaki: 12433259,
17963     darkmagenta: 9109643,
17964     darkolivegreen: 5597999,
17965     darkorange: 16747520,
17966     darkorchid: 10040012,
17967     darkred: 9109504,
17968     darksalmon: 15308410,
17969     darkseagreen: 9419919,
17970     darkslateblue: 4734347,
17971     darkslategray: 3100495,
17972     darkslategrey: 3100495,
17973     darkturquoise: 52945,
17974     darkviolet: 9699539,
17975     deeppink: 16716947,
17976     deepskyblue: 49151,
17977     dimgray: 6908265,
17978     dimgrey: 6908265,
17979     dodgerblue: 2003199,
17980     firebrick: 11674146,
17981     floralwhite: 16775920,
17982     forestgreen: 2263842,
17983     fuchsia: 16711935,
17984     gainsboro: 14474460,
17985     ghostwhite: 16316671,
17986     gold: 16766720,
17987     goldenrod: 14329120,
17988     gray: 8421504,
17989     green: 32768,
17990     greenyellow: 11403055,
17991     grey: 8421504,
17992     honeydew: 15794160,
17993     hotpink: 16738740,
17994     indianred: 13458524,
17995     indigo: 4915330,
17996     ivory: 16777200,
17997     khaki: 15787660,
17998     lavender: 15132410,
17999     lavenderblush: 16773365,
18000     lawngreen: 8190976,
18001     lemonchiffon: 16775885,
18002     lightblue: 11393254,
18003     lightcoral: 15761536,
18004     lightcyan: 14745599,
18005     lightgoldenrodyellow: 16448210,
18006     lightgray: 13882323,
18007     lightgreen: 9498256,
18008     lightgrey: 13882323,
18009     lightpink: 16758465,
18010     lightsalmon: 16752762,
18011     lightseagreen: 2142890,
18012     lightskyblue: 8900346,
18013     lightslategray: 7833753,
18014     lightslategrey: 7833753,
18015     lightsteelblue: 11584734,
18016     lightyellow: 16777184,
18017     lime: 65280,
18018     limegreen: 3329330,
18019     linen: 16445670,
18020     magenta: 16711935,
18021     maroon: 8388608,
18022     mediumaquamarine: 6737322,
18023     mediumblue: 205,
18024     mediumorchid: 12211667,
18025     mediumpurple: 9662683,
18026     mediumseagreen: 3978097,
18027     mediumslateblue: 8087790,
18028     mediumspringgreen: 64154,
18029     mediumturquoise: 4772300,
18030     mediumvioletred: 13047173,
18031     midnightblue: 1644912,
18032     mintcream: 16121850,
18033     mistyrose: 16770273,
18034     moccasin: 16770229,
18035     navajowhite: 16768685,
18036     navy: 128,
18037     oldlace: 16643558,
18038     olive: 8421376,
18039     olivedrab: 7048739,
18040     orange: 16753920,
18041     orangered: 16729344,
18042     orchid: 14315734,
18043     palegoldenrod: 15657130,
18044     palegreen: 10025880,
18045     paleturquoise: 11529966,
18046     palevioletred: 14381203,
18047     papayawhip: 16773077,
18048     peachpuff: 16767673,
18049     peru: 13468991,
18050     pink: 16761035,
18051     plum: 14524637,
18052     powderblue: 11591910,
18053     purple: 8388736,
18054     rebeccapurple: 6697881,
18055     red: 16711680,
18056     rosybrown: 12357519,
18057     royalblue: 4286945,
18058     saddlebrown: 9127187,
18059     salmon: 16416882,
18060     sandybrown: 16032864,
18061     seagreen: 3050327,
18062     seashell: 16774638,
18063     sienna: 10506797,
18064     silver: 12632256,
18065     skyblue: 8900331,
18066     slateblue: 6970061,
18067     slategray: 7372944,
18068     slategrey: 7372944,
18069     snow: 16775930,
18070     springgreen: 65407,
18071     steelblue: 4620980,
18072     tan: 13808780,
18073     teal: 32896,
18074     thistle: 14204888,
18075     tomato: 16737095,
18076     turquoise: 4251856,
18077     violet: 15631086,
18078     wheat: 16113331,
18079     white: 16777215,
18080     whitesmoke: 16119285,
18081     yellow: 16776960,
18082     yellowgreen: 10145074
18083   };
18084   define_default(Color, color, {
18085     copy(channels) {
18086       return Object.assign(new this.constructor(), this, channels);
18087     },
18088     displayable() {
18089       return this.rgb().displayable();
18090     },
18091     hex: color_formatHex,
18092     // Deprecated! Use color.formatHex.
18093     formatHex: color_formatHex,
18094     formatHex8: color_formatHex8,
18095     formatHsl: color_formatHsl,
18096     formatRgb: color_formatRgb,
18097     toString: color_formatRgb
18098   });
18099   function color_formatHex() {
18100     return this.rgb().formatHex();
18101   }
18102   function color_formatHex8() {
18103     return this.rgb().formatHex8();
18104   }
18105   function color_formatHsl() {
18106     return hslConvert(this).formatHsl();
18107   }
18108   function color_formatRgb() {
18109     return this.rgb().formatRgb();
18110   }
18111   function color(format2) {
18112     var m2, l2;
18113     format2 = (format2 + "").trim().toLowerCase();
18114     return (m2 = reHex.exec(format2)) ? (l2 = m2[1].length, m2 = parseInt(m2[1], 16), l2 === 6 ? rgbn(m2) : l2 === 3 ? new Rgb(m2 >> 8 & 15 | m2 >> 4 & 240, m2 >> 4 & 15 | m2 & 240, (m2 & 15) << 4 | m2 & 15, 1) : l2 === 8 ? rgba(m2 >> 24 & 255, m2 >> 16 & 255, m2 >> 8 & 255, (m2 & 255) / 255) : l2 === 4 ? rgba(m2 >> 12 & 15 | m2 >> 8 & 240, m2 >> 8 & 15 | m2 >> 4 & 240, m2 >> 4 & 15 | m2 & 240, ((m2 & 15) << 4 | m2 & 15) / 255) : null) : (m2 = reRgbInteger.exec(format2)) ? new Rgb(m2[1], m2[2], m2[3], 1) : (m2 = reRgbPercent.exec(format2)) ? new Rgb(m2[1] * 255 / 100, m2[2] * 255 / 100, m2[3] * 255 / 100, 1) : (m2 = reRgbaInteger.exec(format2)) ? rgba(m2[1], m2[2], m2[3], m2[4]) : (m2 = reRgbaPercent.exec(format2)) ? rgba(m2[1] * 255 / 100, m2[2] * 255 / 100, m2[3] * 255 / 100, m2[4]) : (m2 = reHslPercent.exec(format2)) ? hsla(m2[1], m2[2] / 100, m2[3] / 100, 1) : (m2 = reHslaPercent.exec(format2)) ? hsla(m2[1], m2[2] / 100, m2[3] / 100, m2[4]) : named.hasOwnProperty(format2) ? rgbn(named[format2]) : format2 === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null;
18115   }
18116   function rgbn(n3) {
18117     return new Rgb(n3 >> 16 & 255, n3 >> 8 & 255, n3 & 255, 1);
18118   }
18119   function rgba(r2, g3, b2, a2) {
18120     if (a2 <= 0) r2 = g3 = b2 = NaN;
18121     return new Rgb(r2, g3, b2, a2);
18122   }
18123   function rgbConvert(o2) {
18124     if (!(o2 instanceof Color)) o2 = color(o2);
18125     if (!o2) return new Rgb();
18126     o2 = o2.rgb();
18127     return new Rgb(o2.r, o2.g, o2.b, o2.opacity);
18128   }
18129   function rgb(r2, g3, b2, opacity) {
18130     return arguments.length === 1 ? rgbConvert(r2) : new Rgb(r2, g3, b2, opacity == null ? 1 : opacity);
18131   }
18132   function Rgb(r2, g3, b2, opacity) {
18133     this.r = +r2;
18134     this.g = +g3;
18135     this.b = +b2;
18136     this.opacity = +opacity;
18137   }
18138   define_default(Rgb, rgb, extend(Color, {
18139     brighter(k2) {
18140       k2 = k2 == null ? brighter : Math.pow(brighter, k2);
18141       return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity);
18142     },
18143     darker(k2) {
18144       k2 = k2 == null ? darker : Math.pow(darker, k2);
18145       return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity);
18146     },
18147     rgb() {
18148       return this;
18149     },
18150     clamp() {
18151       return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
18152     },
18153     displayable() {
18154       return -0.5 <= this.r && this.r < 255.5 && (-0.5 <= this.g && this.g < 255.5) && (-0.5 <= this.b && this.b < 255.5) && (0 <= this.opacity && this.opacity <= 1);
18155     },
18156     hex: rgb_formatHex,
18157     // Deprecated! Use color.formatHex.
18158     formatHex: rgb_formatHex,
18159     formatHex8: rgb_formatHex8,
18160     formatRgb: rgb_formatRgb,
18161     toString: rgb_formatRgb
18162   }));
18163   function rgb_formatHex() {
18164     return "#".concat(hex(this.r)).concat(hex(this.g)).concat(hex(this.b));
18165   }
18166   function rgb_formatHex8() {
18167     return "#".concat(hex(this.r)).concat(hex(this.g)).concat(hex(this.b)).concat(hex((isNaN(this.opacity) ? 1 : this.opacity) * 255));
18168   }
18169   function rgb_formatRgb() {
18170     const a2 = clampa(this.opacity);
18171     return "".concat(a2 === 1 ? "rgb(" : "rgba(").concat(clampi(this.r), ", ").concat(clampi(this.g), ", ").concat(clampi(this.b)).concat(a2 === 1 ? ")" : ", ".concat(a2, ")"));
18172   }
18173   function clampa(opacity) {
18174     return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
18175   }
18176   function clampi(value) {
18177     return Math.max(0, Math.min(255, Math.round(value) || 0));
18178   }
18179   function hex(value) {
18180     value = clampi(value);
18181     return (value < 16 ? "0" : "") + value.toString(16);
18182   }
18183   function hsla(h2, s2, l2, a2) {
18184     if (a2 <= 0) h2 = s2 = l2 = NaN;
18185     else if (l2 <= 0 || l2 >= 1) h2 = s2 = NaN;
18186     else if (s2 <= 0) h2 = NaN;
18187     return new Hsl(h2, s2, l2, a2);
18188   }
18189   function hslConvert(o2) {
18190     if (o2 instanceof Hsl) return new Hsl(o2.h, o2.s, o2.l, o2.opacity);
18191     if (!(o2 instanceof Color)) o2 = color(o2);
18192     if (!o2) return new Hsl();
18193     if (o2 instanceof Hsl) return o2;
18194     o2 = o2.rgb();
18195     var r2 = o2.r / 255, g3 = o2.g / 255, b2 = o2.b / 255, min3 = Math.min(r2, g3, b2), max3 = Math.max(r2, g3, b2), h2 = NaN, s2 = max3 - min3, l2 = (max3 + min3) / 2;
18196     if (s2) {
18197       if (r2 === max3) h2 = (g3 - b2) / s2 + (g3 < b2) * 6;
18198       else if (g3 === max3) h2 = (b2 - r2) / s2 + 2;
18199       else h2 = (r2 - g3) / s2 + 4;
18200       s2 /= l2 < 0.5 ? max3 + min3 : 2 - max3 - min3;
18201       h2 *= 60;
18202     } else {
18203       s2 = l2 > 0 && l2 < 1 ? 0 : h2;
18204     }
18205     return new Hsl(h2, s2, l2, o2.opacity);
18206   }
18207   function hsl(h2, s2, l2, opacity) {
18208     return arguments.length === 1 ? hslConvert(h2) : new Hsl(h2, s2, l2, opacity == null ? 1 : opacity);
18209   }
18210   function Hsl(h2, s2, l2, opacity) {
18211     this.h = +h2;
18212     this.s = +s2;
18213     this.l = +l2;
18214     this.opacity = +opacity;
18215   }
18216   define_default(Hsl, hsl, extend(Color, {
18217     brighter(k2) {
18218       k2 = k2 == null ? brighter : Math.pow(brighter, k2);
18219       return new Hsl(this.h, this.s, this.l * k2, this.opacity);
18220     },
18221     darker(k2) {
18222       k2 = k2 == null ? darker : Math.pow(darker, k2);
18223       return new Hsl(this.h, this.s, this.l * k2, this.opacity);
18224     },
18225     rgb() {
18226       var h2 = this.h % 360 + (this.h < 0) * 360, s2 = isNaN(h2) || isNaN(this.s) ? 0 : this.s, l2 = this.l, m2 = l2 + (l2 < 0.5 ? l2 : 1 - l2) * s2, m1 = 2 * l2 - m2;
18227       return new Rgb(
18228         hsl2rgb(h2 >= 240 ? h2 - 240 : h2 + 120, m1, m2),
18229         hsl2rgb(h2, m1, m2),
18230         hsl2rgb(h2 < 120 ? h2 + 240 : h2 - 120, m1, m2),
18231         this.opacity
18232       );
18233     },
18234     clamp() {
18235       return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
18236     },
18237     displayable() {
18238       return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && (0 <= this.l && this.l <= 1) && (0 <= this.opacity && this.opacity <= 1);
18239     },
18240     formatHsl() {
18241       const a2 = clampa(this.opacity);
18242       return "".concat(a2 === 1 ? "hsl(" : "hsla(").concat(clamph(this.h), ", ").concat(clampt(this.s) * 100, "%, ").concat(clampt(this.l) * 100, "%").concat(a2 === 1 ? ")" : ", ".concat(a2, ")"));
18243     }
18244   }));
18245   function clamph(value) {
18246     value = (value || 0) % 360;
18247     return value < 0 ? value + 360 : value;
18248   }
18249   function clampt(value) {
18250     return Math.max(0, Math.min(1, value || 0));
18251   }
18252   function hsl2rgb(h2, m1, m2) {
18253     return (h2 < 60 ? m1 + (m2 - m1) * h2 / 60 : h2 < 180 ? m2 : h2 < 240 ? m1 + (m2 - m1) * (240 - h2) / 60 : m1) * 255;
18254   }
18255
18256   // node_modules/d3-interpolate/src/basis.js
18257   function basis(t1, v0, v1, v2, v3) {
18258     var t2 = t1 * t1, t3 = t2 * t1;
18259     return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6;
18260   }
18261   function basis_default(values) {
18262     var n3 = values.length - 1;
18263     return function(t2) {
18264       var i3 = t2 <= 0 ? t2 = 0 : t2 >= 1 ? (t2 = 1, n3 - 1) : Math.floor(t2 * n3), v1 = values[i3], v2 = values[i3 + 1], v0 = i3 > 0 ? values[i3 - 1] : 2 * v1 - v2, v3 = i3 < n3 - 1 ? values[i3 + 2] : 2 * v2 - v1;
18265       return basis((t2 - i3 / n3) * n3, v0, v1, v2, v3);
18266     };
18267   }
18268
18269   // node_modules/d3-interpolate/src/basisClosed.js
18270   function basisClosed_default(values) {
18271     var n3 = values.length;
18272     return function(t2) {
18273       var i3 = Math.floor(((t2 %= 1) < 0 ? ++t2 : t2) * n3), v0 = values[(i3 + n3 - 1) % n3], v1 = values[i3 % n3], v2 = values[(i3 + 1) % n3], v3 = values[(i3 + 2) % n3];
18274       return basis((t2 - i3 / n3) * n3, v0, v1, v2, v3);
18275     };
18276   }
18277
18278   // node_modules/d3-interpolate/src/constant.js
18279   var constant_default3 = (x2) => () => x2;
18280
18281   // node_modules/d3-interpolate/src/color.js
18282   function linear(a2, d2) {
18283     return function(t2) {
18284       return a2 + t2 * d2;
18285     };
18286   }
18287   function exponential(a2, b2, y2) {
18288     return a2 = Math.pow(a2, y2), b2 = Math.pow(b2, y2) - a2, y2 = 1 / y2, function(t2) {
18289       return Math.pow(a2 + t2 * b2, y2);
18290     };
18291   }
18292   function gamma(y2) {
18293     return (y2 = +y2) === 1 ? nogamma : function(a2, b2) {
18294       return b2 - a2 ? exponential(a2, b2, y2) : constant_default3(isNaN(a2) ? b2 : a2);
18295     };
18296   }
18297   function nogamma(a2, b2) {
18298     var d2 = b2 - a2;
18299     return d2 ? linear(a2, d2) : constant_default3(isNaN(a2) ? b2 : a2);
18300   }
18301
18302   // node_modules/d3-interpolate/src/rgb.js
18303   var rgb_default = function rgbGamma(y2) {
18304     var color2 = gamma(y2);
18305     function rgb2(start2, end) {
18306       var r2 = color2((start2 = rgb(start2)).r, (end = rgb(end)).r), g3 = color2(start2.g, end.g), b2 = color2(start2.b, end.b), opacity = nogamma(start2.opacity, end.opacity);
18307       return function(t2) {
18308         start2.r = r2(t2);
18309         start2.g = g3(t2);
18310         start2.b = b2(t2);
18311         start2.opacity = opacity(t2);
18312         return start2 + "";
18313       };
18314     }
18315     rgb2.gamma = rgbGamma;
18316     return rgb2;
18317   }(1);
18318   function rgbSpline(spline) {
18319     return function(colors) {
18320       var n3 = colors.length, r2 = new Array(n3), g3 = new Array(n3), b2 = new Array(n3), i3, color2;
18321       for (i3 = 0; i3 < n3; ++i3) {
18322         color2 = rgb(colors[i3]);
18323         r2[i3] = color2.r || 0;
18324         g3[i3] = color2.g || 0;
18325         b2[i3] = color2.b || 0;
18326       }
18327       r2 = spline(r2);
18328       g3 = spline(g3);
18329       b2 = spline(b2);
18330       color2.opacity = 1;
18331       return function(t2) {
18332         color2.r = r2(t2);
18333         color2.g = g3(t2);
18334         color2.b = b2(t2);
18335         return color2 + "";
18336       };
18337     };
18338   }
18339   var rgbBasis = rgbSpline(basis_default);
18340   var rgbBasisClosed = rgbSpline(basisClosed_default);
18341
18342   // node_modules/d3-interpolate/src/numberArray.js
18343   function numberArray_default(a2, b2) {
18344     if (!b2) b2 = [];
18345     var n3 = a2 ? Math.min(b2.length, a2.length) : 0, c2 = b2.slice(), i3;
18346     return function(t2) {
18347       for (i3 = 0; i3 < n3; ++i3) c2[i3] = a2[i3] * (1 - t2) + b2[i3] * t2;
18348       return c2;
18349     };
18350   }
18351   function isNumberArray(x2) {
18352     return ArrayBuffer.isView(x2) && !(x2 instanceof DataView);
18353   }
18354
18355   // node_modules/d3-interpolate/src/array.js
18356   function genericArray(a2, b2) {
18357     var nb = b2 ? b2.length : 0, na = a2 ? Math.min(nb, a2.length) : 0, x2 = new Array(na), c2 = new Array(nb), i3;
18358     for (i3 = 0; i3 < na; ++i3) x2[i3] = value_default(a2[i3], b2[i3]);
18359     for (; i3 < nb; ++i3) c2[i3] = b2[i3];
18360     return function(t2) {
18361       for (i3 = 0; i3 < na; ++i3) c2[i3] = x2[i3](t2);
18362       return c2;
18363     };
18364   }
18365
18366   // node_modules/d3-interpolate/src/date.js
18367   function date_default(a2, b2) {
18368     var d2 = /* @__PURE__ */ new Date();
18369     return a2 = +a2, b2 = +b2, function(t2) {
18370       return d2.setTime(a2 * (1 - t2) + b2 * t2), d2;
18371     };
18372   }
18373
18374   // node_modules/d3-interpolate/src/number.js
18375   function number_default(a2, b2) {
18376     return a2 = +a2, b2 = +b2, function(t2) {
18377       return a2 * (1 - t2) + b2 * t2;
18378     };
18379   }
18380
18381   // node_modules/d3-interpolate/src/object.js
18382   function object_default(a2, b2) {
18383     var i3 = {}, c2 = {}, k2;
18384     if (a2 === null || typeof a2 !== "object") a2 = {};
18385     if (b2 === null || typeof b2 !== "object") b2 = {};
18386     for (k2 in b2) {
18387       if (k2 in a2) {
18388         i3[k2] = value_default(a2[k2], b2[k2]);
18389       } else {
18390         c2[k2] = b2[k2];
18391       }
18392     }
18393     return function(t2) {
18394       for (k2 in i3) c2[k2] = i3[k2](t2);
18395       return c2;
18396     };
18397   }
18398
18399   // node_modules/d3-interpolate/src/string.js
18400   var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
18401   var reB = new RegExp(reA.source, "g");
18402   function zero2(b2) {
18403     return function() {
18404       return b2;
18405     };
18406   }
18407   function one(b2) {
18408     return function(t2) {
18409       return b2(t2) + "";
18410     };
18411   }
18412   function string_default(a2, b2) {
18413     var bi = reA.lastIndex = reB.lastIndex = 0, am, bm, bs, i3 = -1, s2 = [], q2 = [];
18414     a2 = a2 + "", b2 = b2 + "";
18415     while ((am = reA.exec(a2)) && (bm = reB.exec(b2))) {
18416       if ((bs = bm.index) > bi) {
18417         bs = b2.slice(bi, bs);
18418         if (s2[i3]) s2[i3] += bs;
18419         else s2[++i3] = bs;
18420       }
18421       if ((am = am[0]) === (bm = bm[0])) {
18422         if (s2[i3]) s2[i3] += bm;
18423         else s2[++i3] = bm;
18424       } else {
18425         s2[++i3] = null;
18426         q2.push({ i: i3, x: number_default(am, bm) });
18427       }
18428       bi = reB.lastIndex;
18429     }
18430     if (bi < b2.length) {
18431       bs = b2.slice(bi);
18432       if (s2[i3]) s2[i3] += bs;
18433       else s2[++i3] = bs;
18434     }
18435     return s2.length < 2 ? q2[0] ? one(q2[0].x) : zero2(b2) : (b2 = q2.length, function(t2) {
18436       for (var i4 = 0, o2; i4 < b2; ++i4) s2[(o2 = q2[i4]).i] = o2.x(t2);
18437       return s2.join("");
18438     });
18439   }
18440
18441   // node_modules/d3-interpolate/src/value.js
18442   function value_default(a2, b2) {
18443     var t2 = typeof b2, c2;
18444     return b2 == null || t2 === "boolean" ? constant_default3(b2) : (t2 === "number" ? number_default : t2 === "string" ? (c2 = color(b2)) ? (b2 = c2, rgb_default) : string_default : b2 instanceof color ? rgb_default : b2 instanceof Date ? date_default : isNumberArray(b2) ? numberArray_default : Array.isArray(b2) ? genericArray : typeof b2.valueOf !== "function" && typeof b2.toString !== "function" || isNaN(b2) ? object_default : number_default)(a2, b2);
18445   }
18446
18447   // node_modules/d3-interpolate/src/round.js
18448   function round_default(a2, b2) {
18449     return a2 = +a2, b2 = +b2, function(t2) {
18450       return Math.round(a2 * (1 - t2) + b2 * t2);
18451     };
18452   }
18453
18454   // node_modules/d3-interpolate/src/transform/decompose.js
18455   var degrees2 = 180 / Math.PI;
18456   var identity = {
18457     translateX: 0,
18458     translateY: 0,
18459     rotate: 0,
18460     skewX: 0,
18461     scaleX: 1,
18462     scaleY: 1
18463   };
18464   function decompose_default(a2, b2, c2, d2, e3, f2) {
18465     var scaleX, scaleY, skewX;
18466     if (scaleX = Math.sqrt(a2 * a2 + b2 * b2)) a2 /= scaleX, b2 /= scaleX;
18467     if (skewX = a2 * c2 + b2 * d2) c2 -= a2 * skewX, d2 -= b2 * skewX;
18468     if (scaleY = Math.sqrt(c2 * c2 + d2 * d2)) c2 /= scaleY, d2 /= scaleY, skewX /= scaleY;
18469     if (a2 * d2 < b2 * c2) a2 = -a2, b2 = -b2, skewX = -skewX, scaleX = -scaleX;
18470     return {
18471       translateX: e3,
18472       translateY: f2,
18473       rotate: Math.atan2(b2, a2) * degrees2,
18474       skewX: Math.atan(skewX) * degrees2,
18475       scaleX,
18476       scaleY
18477     };
18478   }
18479
18480   // node_modules/d3-interpolate/src/transform/parse.js
18481   var svgNode;
18482   function parseCss(value) {
18483     const m2 = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + "");
18484     return m2.isIdentity ? identity : decompose_default(m2.a, m2.b, m2.c, m2.d, m2.e, m2.f);
18485   }
18486   function parseSvg(value) {
18487     if (value == null) return identity;
18488     if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
18489     svgNode.setAttribute("transform", value);
18490     if (!(value = svgNode.transform.baseVal.consolidate())) return identity;
18491     value = value.matrix;
18492     return decompose_default(value.a, value.b, value.c, value.d, value.e, value.f);
18493   }
18494
18495   // node_modules/d3-interpolate/src/transform/index.js
18496   function interpolateTransform(parse, pxComma, pxParen, degParen) {
18497     function pop(s2) {
18498       return s2.length ? s2.pop() + " " : "";
18499     }
18500     function translate(xa, ya, xb, yb, s2, q2) {
18501       if (xa !== xb || ya !== yb) {
18502         var i3 = s2.push("translate(", null, pxComma, null, pxParen);
18503         q2.push({ i: i3 - 4, x: number_default(xa, xb) }, { i: i3 - 2, x: number_default(ya, yb) });
18504       } else if (xb || yb) {
18505         s2.push("translate(" + xb + pxComma + yb + pxParen);
18506       }
18507     }
18508     function rotate(a2, b2, s2, q2) {
18509       if (a2 !== b2) {
18510         if (a2 - b2 > 180) b2 += 360;
18511         else if (b2 - a2 > 180) a2 += 360;
18512         q2.push({ i: s2.push(pop(s2) + "rotate(", null, degParen) - 2, x: number_default(a2, b2) });
18513       } else if (b2) {
18514         s2.push(pop(s2) + "rotate(" + b2 + degParen);
18515       }
18516     }
18517     function skewX(a2, b2, s2, q2) {
18518       if (a2 !== b2) {
18519         q2.push({ i: s2.push(pop(s2) + "skewX(", null, degParen) - 2, x: number_default(a2, b2) });
18520       } else if (b2) {
18521         s2.push(pop(s2) + "skewX(" + b2 + degParen);
18522       }
18523     }
18524     function scale(xa, ya, xb, yb, s2, q2) {
18525       if (xa !== xb || ya !== yb) {
18526         var i3 = s2.push(pop(s2) + "scale(", null, ",", null, ")");
18527         q2.push({ i: i3 - 4, x: number_default(xa, xb) }, { i: i3 - 2, x: number_default(ya, yb) });
18528       } else if (xb !== 1 || yb !== 1) {
18529         s2.push(pop(s2) + "scale(" + xb + "," + yb + ")");
18530       }
18531     }
18532     return function(a2, b2) {
18533       var s2 = [], q2 = [];
18534       a2 = parse(a2), b2 = parse(b2);
18535       translate(a2.translateX, a2.translateY, b2.translateX, b2.translateY, s2, q2);
18536       rotate(a2.rotate, b2.rotate, s2, q2);
18537       skewX(a2.skewX, b2.skewX, s2, q2);
18538       scale(a2.scaleX, a2.scaleY, b2.scaleX, b2.scaleY, s2, q2);
18539       a2 = b2 = null;
18540       return function(t2) {
18541         var i3 = -1, n3 = q2.length, o2;
18542         while (++i3 < n3) s2[(o2 = q2[i3]).i] = o2.x(t2);
18543         return s2.join("");
18544       };
18545     };
18546   }
18547   var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)");
18548   var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")");
18549
18550   // node_modules/d3-interpolate/src/zoom.js
18551   var epsilon22 = 1e-12;
18552   function cosh(x2) {
18553     return ((x2 = Math.exp(x2)) + 1 / x2) / 2;
18554   }
18555   function sinh(x2) {
18556     return ((x2 = Math.exp(x2)) - 1 / x2) / 2;
18557   }
18558   function tanh(x2) {
18559     return ((x2 = Math.exp(2 * x2)) - 1) / (x2 + 1);
18560   }
18561   var zoom_default = function zoomRho(rho, rho2, rho4) {
18562     function zoom(p02, p1) {
18563       var ux0 = p02[0], uy0 = p02[1], w0 = p02[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i3, S2;
18564       if (d2 < epsilon22) {
18565         S2 = Math.log(w1 / w0) / rho;
18566         i3 = function(t2) {
18567           return [
18568             ux0 + t2 * dx,
18569             uy0 + t2 * dy,
18570             w0 * Math.exp(rho * t2 * S2)
18571           ];
18572         };
18573       } else {
18574         var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1), b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
18575         S2 = (r1 - r0) / rho;
18576         i3 = function(t2) {
18577           var s2 = t2 * S2, coshr0 = cosh(r0), u2 = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s2 + r0) - sinh(r0));
18578           return [
18579             ux0 + u2 * dx,
18580             uy0 + u2 * dy,
18581             w0 * coshr0 / cosh(rho * s2 + r0)
18582           ];
18583         };
18584       }
18585       i3.duration = S2 * 1e3 * rho / Math.SQRT2;
18586       return i3;
18587     }
18588     zoom.rho = function(_2) {
18589       var _1 = Math.max(1e-3, +_2), _22 = _1 * _1, _4 = _22 * _22;
18590       return zoomRho(_1, _22, _4);
18591     };
18592     return zoom;
18593   }(Math.SQRT2, 2, 4);
18594
18595   // node_modules/d3-interpolate/src/quantize.js
18596   function quantize_default(interpolator, n3) {
18597     var samples = new Array(n3);
18598     for (var i3 = 0; i3 < n3; ++i3) samples[i3] = interpolator(i3 / (n3 - 1));
18599     return samples;
18600   }
18601
18602   // node_modules/d3-timer/src/timer.js
18603   var frame = 0;
18604   var timeout = 0;
18605   var interval = 0;
18606   var pokeDelay = 1e3;
18607   var taskHead;
18608   var taskTail;
18609   var clockLast = 0;
18610   var clockNow = 0;
18611   var clockSkew = 0;
18612   var clock = typeof performance === "object" && performance.now ? performance : Date;
18613   var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f2) {
18614     setTimeout(f2, 17);
18615   };
18616   function now() {
18617     return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
18618   }
18619   function clearNow() {
18620     clockNow = 0;
18621   }
18622   function Timer() {
18623     this._call = this._time = this._next = null;
18624   }
18625   Timer.prototype = timer.prototype = {
18626     constructor: Timer,
18627     restart: function(callback, delay, time) {
18628       if (typeof callback !== "function") throw new TypeError("callback is not a function");
18629       time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
18630       if (!this._next && taskTail !== this) {
18631         if (taskTail) taskTail._next = this;
18632         else taskHead = this;
18633         taskTail = this;
18634       }
18635       this._call = callback;
18636       this._time = time;
18637       sleep();
18638     },
18639     stop: function() {
18640       if (this._call) {
18641         this._call = null;
18642         this._time = Infinity;
18643         sleep();
18644       }
18645     }
18646   };
18647   function timer(callback, delay, time) {
18648     var t2 = new Timer();
18649     t2.restart(callback, delay, time);
18650     return t2;
18651   }
18652   function timerFlush() {
18653     now();
18654     ++frame;
18655     var t2 = taskHead, e3;
18656     while (t2) {
18657       if ((e3 = clockNow - t2._time) >= 0) t2._call.call(void 0, e3);
18658       t2 = t2._next;
18659     }
18660     --frame;
18661   }
18662   function wake() {
18663     clockNow = (clockLast = clock.now()) + clockSkew;
18664     frame = timeout = 0;
18665     try {
18666       timerFlush();
18667     } finally {
18668       frame = 0;
18669       nap();
18670       clockNow = 0;
18671     }
18672   }
18673   function poke() {
18674     var now3 = clock.now(), delay = now3 - clockLast;
18675     if (delay > pokeDelay) clockSkew -= delay, clockLast = now3;
18676   }
18677   function nap() {
18678     var t0, t1 = taskHead, t2, time = Infinity;
18679     while (t1) {
18680       if (t1._call) {
18681         if (time > t1._time) time = t1._time;
18682         t0 = t1, t1 = t1._next;
18683       } else {
18684         t2 = t1._next, t1._next = null;
18685         t1 = t0 ? t0._next = t2 : taskHead = t2;
18686       }
18687     }
18688     taskTail = t0;
18689     sleep(time);
18690   }
18691   function sleep(time) {
18692     if (frame) return;
18693     if (timeout) timeout = clearTimeout(timeout);
18694     var delay = time - clockNow;
18695     if (delay > 24) {
18696       if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
18697       if (interval) interval = clearInterval(interval);
18698     } else {
18699       if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
18700       frame = 1, setFrame(wake);
18701     }
18702   }
18703
18704   // node_modules/d3-timer/src/timeout.js
18705   function timeout_default(callback, delay, time) {
18706     var t2 = new Timer();
18707     delay = delay == null ? 0 : +delay;
18708     t2.restart((elapsed) => {
18709       t2.stop();
18710       callback(elapsed + delay);
18711     }, delay, time);
18712     return t2;
18713   }
18714
18715   // node_modules/d3-transition/src/transition/schedule.js
18716   var emptyOn = dispatch_default("start", "end", "cancel", "interrupt");
18717   var emptyTween = [];
18718   var CREATED = 0;
18719   var SCHEDULED = 1;
18720   var STARTING = 2;
18721   var STARTED = 3;
18722   var RUNNING = 4;
18723   var ENDING = 5;
18724   var ENDED = 6;
18725   function schedule_default(node, name, id2, index, group, timing) {
18726     var schedules = node.__transition;
18727     if (!schedules) node.__transition = {};
18728     else if (id2 in schedules) return;
18729     create(node, id2, {
18730       name,
18731       index,
18732       // For context during callback.
18733       group,
18734       // For context during callback.
18735       on: emptyOn,
18736       tween: emptyTween,
18737       time: timing.time,
18738       delay: timing.delay,
18739       duration: timing.duration,
18740       ease: timing.ease,
18741       timer: null,
18742       state: CREATED
18743     });
18744   }
18745   function init(node, id2) {
18746     var schedule = get2(node, id2);
18747     if (schedule.state > CREATED) throw new Error("too late; already scheduled");
18748     return schedule;
18749   }
18750   function set2(node, id2) {
18751     var schedule = get2(node, id2);
18752     if (schedule.state > STARTED) throw new Error("too late; already running");
18753     return schedule;
18754   }
18755   function get2(node, id2) {
18756     var schedule = node.__transition;
18757     if (!schedule || !(schedule = schedule[id2])) throw new Error("transition not found");
18758     return schedule;
18759   }
18760   function create(node, id2, self2) {
18761     var schedules = node.__transition, tween;
18762     schedules[id2] = self2;
18763     self2.timer = timer(schedule, 0, self2.time);
18764     function schedule(elapsed) {
18765       self2.state = SCHEDULED;
18766       self2.timer.restart(start2, self2.delay, self2.time);
18767       if (self2.delay <= elapsed) start2(elapsed - self2.delay);
18768     }
18769     function start2(elapsed) {
18770       var i3, j2, n3, o2;
18771       if (self2.state !== SCHEDULED) return stop();
18772       for (i3 in schedules) {
18773         o2 = schedules[i3];
18774         if (o2.name !== self2.name) continue;
18775         if (o2.state === STARTED) return timeout_default(start2);
18776         if (o2.state === RUNNING) {
18777           o2.state = ENDED;
18778           o2.timer.stop();
18779           o2.on.call("interrupt", node, node.__data__, o2.index, o2.group);
18780           delete schedules[i3];
18781         } else if (+i3 < id2) {
18782           o2.state = ENDED;
18783           o2.timer.stop();
18784           o2.on.call("cancel", node, node.__data__, o2.index, o2.group);
18785           delete schedules[i3];
18786         }
18787       }
18788       timeout_default(function() {
18789         if (self2.state === STARTED) {
18790           self2.state = RUNNING;
18791           self2.timer.restart(tick, self2.delay, self2.time);
18792           tick(elapsed);
18793         }
18794       });
18795       self2.state = STARTING;
18796       self2.on.call("start", node, node.__data__, self2.index, self2.group);
18797       if (self2.state !== STARTING) return;
18798       self2.state = STARTED;
18799       tween = new Array(n3 = self2.tween.length);
18800       for (i3 = 0, j2 = -1; i3 < n3; ++i3) {
18801         if (o2 = self2.tween[i3].value.call(node, node.__data__, self2.index, self2.group)) {
18802           tween[++j2] = o2;
18803         }
18804       }
18805       tween.length = j2 + 1;
18806     }
18807     function tick(elapsed) {
18808       var t2 = elapsed < self2.duration ? self2.ease.call(null, elapsed / self2.duration) : (self2.timer.restart(stop), self2.state = ENDING, 1), i3 = -1, n3 = tween.length;
18809       while (++i3 < n3) {
18810         tween[i3].call(node, t2);
18811       }
18812       if (self2.state === ENDING) {
18813         self2.on.call("end", node, node.__data__, self2.index, self2.group);
18814         stop();
18815       }
18816     }
18817     function stop() {
18818       self2.state = ENDED;
18819       self2.timer.stop();
18820       delete schedules[id2];
18821       for (var i3 in schedules) return;
18822       delete node.__transition;
18823     }
18824   }
18825
18826   // node_modules/d3-transition/src/interrupt.js
18827   function interrupt_default(node, name) {
18828     var schedules = node.__transition, schedule, active, empty2 = true, i3;
18829     if (!schedules) return;
18830     name = name == null ? null : name + "";
18831     for (i3 in schedules) {
18832       if ((schedule = schedules[i3]).name !== name) {
18833         empty2 = false;
18834         continue;
18835       }
18836       active = schedule.state > STARTING && schedule.state < ENDING;
18837       schedule.state = ENDED;
18838       schedule.timer.stop();
18839       schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group);
18840       delete schedules[i3];
18841     }
18842     if (empty2) delete node.__transition;
18843   }
18844
18845   // node_modules/d3-transition/src/selection/interrupt.js
18846   function interrupt_default2(name) {
18847     return this.each(function() {
18848       interrupt_default(this, name);
18849     });
18850   }
18851
18852   // node_modules/d3-transition/src/transition/tween.js
18853   function tweenRemove(id2, name) {
18854     var tween0, tween1;
18855     return function() {
18856       var schedule = set2(this, id2), tween = schedule.tween;
18857       if (tween !== tween0) {
18858         tween1 = tween0 = tween;
18859         for (var i3 = 0, n3 = tween1.length; i3 < n3; ++i3) {
18860           if (tween1[i3].name === name) {
18861             tween1 = tween1.slice();
18862             tween1.splice(i3, 1);
18863             break;
18864           }
18865         }
18866       }
18867       schedule.tween = tween1;
18868     };
18869   }
18870   function tweenFunction(id2, name, value) {
18871     var tween0, tween1;
18872     if (typeof value !== "function") throw new Error();
18873     return function() {
18874       var schedule = set2(this, id2), tween = schedule.tween;
18875       if (tween !== tween0) {
18876         tween1 = (tween0 = tween).slice();
18877         for (var t2 = { name, value }, i3 = 0, n3 = tween1.length; i3 < n3; ++i3) {
18878           if (tween1[i3].name === name) {
18879             tween1[i3] = t2;
18880             break;
18881           }
18882         }
18883         if (i3 === n3) tween1.push(t2);
18884       }
18885       schedule.tween = tween1;
18886     };
18887   }
18888   function tween_default(name, value) {
18889     var id2 = this._id;
18890     name += "";
18891     if (arguments.length < 2) {
18892       var tween = get2(this.node(), id2).tween;
18893       for (var i3 = 0, n3 = tween.length, t2; i3 < n3; ++i3) {
18894         if ((t2 = tween[i3]).name === name) {
18895           return t2.value;
18896         }
18897       }
18898       return null;
18899     }
18900     return this.each((value == null ? tweenRemove : tweenFunction)(id2, name, value));
18901   }
18902   function tweenValue(transition2, name, value) {
18903     var id2 = transition2._id;
18904     transition2.each(function() {
18905       var schedule = set2(this, id2);
18906       (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments);
18907     });
18908     return function(node) {
18909       return get2(node, id2).value[name];
18910     };
18911   }
18912
18913   // node_modules/d3-transition/src/transition/interpolate.js
18914   function interpolate_default(a2, b2) {
18915     var c2;
18916     return (typeof b2 === "number" ? number_default : b2 instanceof color ? rgb_default : (c2 = color(b2)) ? (b2 = c2, rgb_default) : string_default)(a2, b2);
18917   }
18918
18919   // node_modules/d3-transition/src/transition/attr.js
18920   function attrRemove2(name) {
18921     return function() {
18922       this.removeAttribute(name);
18923     };
18924   }
18925   function attrRemoveNS2(fullname) {
18926     return function() {
18927       this.removeAttributeNS(fullname.space, fullname.local);
18928     };
18929   }
18930   function attrConstant2(name, interpolate, value1) {
18931     var string00, string1 = value1 + "", interpolate0;
18932     return function() {
18933       var string0 = this.getAttribute(name);
18934       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
18935     };
18936   }
18937   function attrConstantNS2(fullname, interpolate, value1) {
18938     var string00, string1 = value1 + "", interpolate0;
18939     return function() {
18940       var string0 = this.getAttributeNS(fullname.space, fullname.local);
18941       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
18942     };
18943   }
18944   function attrFunction2(name, interpolate, value) {
18945     var string00, string10, interpolate0;
18946     return function() {
18947       var string0, value1 = value(this), string1;
18948       if (value1 == null) return void this.removeAttribute(name);
18949       string0 = this.getAttribute(name);
18950       string1 = value1 + "";
18951       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
18952     };
18953   }
18954   function attrFunctionNS2(fullname, interpolate, value) {
18955     var string00, string10, interpolate0;
18956     return function() {
18957       var string0, value1 = value(this), string1;
18958       if (value1 == null) return void this.removeAttributeNS(fullname.space, fullname.local);
18959       string0 = this.getAttributeNS(fullname.space, fullname.local);
18960       string1 = value1 + "";
18961       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
18962     };
18963   }
18964   function attr_default2(name, value) {
18965     var fullname = namespace_default(name), i3 = fullname === "transform" ? interpolateTransformSvg : interpolate_default;
18966     return this.attrTween(name, typeof value === "function" ? (fullname.local ? attrFunctionNS2 : attrFunction2)(fullname, i3, tweenValue(this, "attr." + name, value)) : value == null ? (fullname.local ? attrRemoveNS2 : attrRemove2)(fullname) : (fullname.local ? attrConstantNS2 : attrConstant2)(fullname, i3, value));
18967   }
18968
18969   // node_modules/d3-transition/src/transition/attrTween.js
18970   function attrInterpolate(name, i3) {
18971     return function(t2) {
18972       this.setAttribute(name, i3.call(this, t2));
18973     };
18974   }
18975   function attrInterpolateNS(fullname, i3) {
18976     return function(t2) {
18977       this.setAttributeNS(fullname.space, fullname.local, i3.call(this, t2));
18978     };
18979   }
18980   function attrTweenNS(fullname, value) {
18981     var t0, i0;
18982     function tween() {
18983       var i3 = value.apply(this, arguments);
18984       if (i3 !== i0) t0 = (i0 = i3) && attrInterpolateNS(fullname, i3);
18985       return t0;
18986     }
18987     tween._value = value;
18988     return tween;
18989   }
18990   function attrTween(name, value) {
18991     var t0, i0;
18992     function tween() {
18993       var i3 = value.apply(this, arguments);
18994       if (i3 !== i0) t0 = (i0 = i3) && attrInterpolate(name, i3);
18995       return t0;
18996     }
18997     tween._value = value;
18998     return tween;
18999   }
19000   function attrTween_default(name, value) {
19001     var key = "attr." + name;
19002     if (arguments.length < 2) return (key = this.tween(key)) && key._value;
19003     if (value == null) return this.tween(key, null);
19004     if (typeof value !== "function") throw new Error();
19005     var fullname = namespace_default(name);
19006     return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
19007   }
19008
19009   // node_modules/d3-transition/src/transition/delay.js
19010   function delayFunction(id2, value) {
19011     return function() {
19012       init(this, id2).delay = +value.apply(this, arguments);
19013     };
19014   }
19015   function delayConstant(id2, value) {
19016     return value = +value, function() {
19017       init(this, id2).delay = value;
19018     };
19019   }
19020   function delay_default(value) {
19021     var id2 = this._id;
19022     return arguments.length ? this.each((typeof value === "function" ? delayFunction : delayConstant)(id2, value)) : get2(this.node(), id2).delay;
19023   }
19024
19025   // node_modules/d3-transition/src/transition/duration.js
19026   function durationFunction(id2, value) {
19027     return function() {
19028       set2(this, id2).duration = +value.apply(this, arguments);
19029     };
19030   }
19031   function durationConstant(id2, value) {
19032     return value = +value, function() {
19033       set2(this, id2).duration = value;
19034     };
19035   }
19036   function duration_default(value) {
19037     var id2 = this._id;
19038     return arguments.length ? this.each((typeof value === "function" ? durationFunction : durationConstant)(id2, value)) : get2(this.node(), id2).duration;
19039   }
19040
19041   // node_modules/d3-transition/src/transition/ease.js
19042   function easeConstant(id2, value) {
19043     if (typeof value !== "function") throw new Error();
19044     return function() {
19045       set2(this, id2).ease = value;
19046     };
19047   }
19048   function ease_default(value) {
19049     var id2 = this._id;
19050     return arguments.length ? this.each(easeConstant(id2, value)) : get2(this.node(), id2).ease;
19051   }
19052
19053   // node_modules/d3-transition/src/transition/easeVarying.js
19054   function easeVarying(id2, value) {
19055     return function() {
19056       var v2 = value.apply(this, arguments);
19057       if (typeof v2 !== "function") throw new Error();
19058       set2(this, id2).ease = v2;
19059     };
19060   }
19061   function easeVarying_default(value) {
19062     if (typeof value !== "function") throw new Error();
19063     return this.each(easeVarying(this._id, value));
19064   }
19065
19066   // node_modules/d3-transition/src/transition/filter.js
19067   function filter_default2(match) {
19068     if (typeof match !== "function") match = matcher_default(match);
19069     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
19070       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) {
19071         if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) {
19072           subgroup.push(node);
19073         }
19074       }
19075     }
19076     return new Transition(subgroups, this._parents, this._name, this._id);
19077   }
19078
19079   // node_modules/d3-transition/src/transition/merge.js
19080   function merge_default2(transition2) {
19081     if (transition2._id !== this._id) throw new Error();
19082     for (var groups0 = this._groups, groups1 = transition2._groups, m0 = groups0.length, m1 = groups1.length, m2 = Math.min(m0, m1), merges = new Array(m0), j2 = 0; j2 < m2; ++j2) {
19083       for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge2 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
19084         if (node = group0[i3] || group1[i3]) {
19085           merge2[i3] = node;
19086         }
19087       }
19088     }
19089     for (; j2 < m0; ++j2) {
19090       merges[j2] = groups0[j2];
19091     }
19092     return new Transition(merges, this._parents, this._name, this._id);
19093   }
19094
19095   // node_modules/d3-transition/src/transition/on.js
19096   function start(name) {
19097     return (name + "").trim().split(/^|\s+/).every(function(t2) {
19098       var i3 = t2.indexOf(".");
19099       if (i3 >= 0) t2 = t2.slice(0, i3);
19100       return !t2 || t2 === "start";
19101     });
19102   }
19103   function onFunction(id2, name, listener) {
19104     var on0, on1, sit = start(name) ? init : set2;
19105     return function() {
19106       var schedule = sit(this, id2), on = schedule.on;
19107       if (on !== on0) (on1 = (on0 = on).copy()).on(name, listener);
19108       schedule.on = on1;
19109     };
19110   }
19111   function on_default2(name, listener) {
19112     var id2 = this._id;
19113     return arguments.length < 2 ? get2(this.node(), id2).on.on(name) : this.each(onFunction(id2, name, listener));
19114   }
19115
19116   // node_modules/d3-transition/src/transition/remove.js
19117   function removeFunction(id2) {
19118     return function() {
19119       var parent = this.parentNode;
19120       for (var i3 in this.__transition) if (+i3 !== id2) return;
19121       if (parent) parent.removeChild(this);
19122     };
19123   }
19124   function remove_default2() {
19125     return this.on("end.remove", removeFunction(this._id));
19126   }
19127
19128   // node_modules/d3-transition/src/transition/select.js
19129   function select_default3(select) {
19130     var name = this._name, id2 = this._id;
19131     if (typeof select !== "function") select = selector_default(select);
19132     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
19133       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) {
19134         if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) {
19135           if ("__data__" in node) subnode.__data__ = node.__data__;
19136           subgroup[i3] = subnode;
19137           schedule_default(subgroup[i3], name, id2, i3, subgroup, get2(node, id2));
19138         }
19139       }
19140     }
19141     return new Transition(subgroups, this._parents, name, id2);
19142   }
19143
19144   // node_modules/d3-transition/src/transition/selectAll.js
19145   function selectAll_default3(select) {
19146     var name = this._name, id2 = this._id;
19147     if (typeof select !== "function") select = selectorAll_default(select);
19148     for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) {
19149       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
19150         if (node = group[i3]) {
19151           for (var children2 = select.call(node, node.__data__, i3, group), child, inherit2 = get2(node, id2), k2 = 0, l2 = children2.length; k2 < l2; ++k2) {
19152             if (child = children2[k2]) {
19153               schedule_default(child, name, id2, k2, children2, inherit2);
19154             }
19155           }
19156           subgroups.push(children2);
19157           parents.push(node);
19158         }
19159       }
19160     }
19161     return new Transition(subgroups, parents, name, id2);
19162   }
19163
19164   // node_modules/d3-transition/src/transition/selection.js
19165   var Selection2 = selection_default.prototype.constructor;
19166   function selection_default2() {
19167     return new Selection2(this._groups, this._parents);
19168   }
19169
19170   // node_modules/d3-transition/src/transition/style.js
19171   function styleNull(name, interpolate) {
19172     var string00, string10, interpolate0;
19173     return function() {
19174       var string0 = styleValue(this, name), string1 = (this.style.removeProperty(name), styleValue(this, name));
19175       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : interpolate0 = interpolate(string00 = string0, string10 = string1);
19176     };
19177   }
19178   function styleRemove2(name) {
19179     return function() {
19180       this.style.removeProperty(name);
19181     };
19182   }
19183   function styleConstant2(name, interpolate, value1) {
19184     var string00, string1 = value1 + "", interpolate0;
19185     return function() {
19186       var string0 = styleValue(this, name);
19187       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
19188     };
19189   }
19190   function styleFunction2(name, interpolate, value) {
19191     var string00, string10, interpolate0;
19192     return function() {
19193       var string0 = styleValue(this, name), value1 = value(this), string1 = value1 + "";
19194       if (value1 == null) string1 = value1 = (this.style.removeProperty(name), styleValue(this, name));
19195       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
19196     };
19197   }
19198   function styleMaybeRemove(id2, name) {
19199     var on0, on1, listener0, key = "style." + name, event = "end." + key, remove2;
19200     return function() {
19201       var schedule = set2(this, id2), on = schedule.on, listener = schedule.value[key] == null ? remove2 || (remove2 = styleRemove2(name)) : void 0;
19202       if (on !== on0 || listener0 !== listener) (on1 = (on0 = on).copy()).on(event, listener0 = listener);
19203       schedule.on = on1;
19204     };
19205   }
19206   function style_default2(name, value, priority) {
19207     var i3 = (name += "") === "transform" ? interpolateTransformCss : interpolate_default;
19208     return value == null ? this.styleTween(name, styleNull(name, i3)).on("end.style." + name, styleRemove2(name)) : typeof value === "function" ? this.styleTween(name, styleFunction2(name, i3, tweenValue(this, "style." + name, value))).each(styleMaybeRemove(this._id, name)) : this.styleTween(name, styleConstant2(name, i3, value), priority).on("end.style." + name, null);
19209   }
19210
19211   // node_modules/d3-transition/src/transition/styleTween.js
19212   function styleInterpolate(name, i3, priority) {
19213     return function(t2) {
19214       this.style.setProperty(name, i3.call(this, t2), priority);
19215     };
19216   }
19217   function styleTween(name, value, priority) {
19218     var t2, i0;
19219     function tween() {
19220       var i3 = value.apply(this, arguments);
19221       if (i3 !== i0) t2 = (i0 = i3) && styleInterpolate(name, i3, priority);
19222       return t2;
19223     }
19224     tween._value = value;
19225     return tween;
19226   }
19227   function styleTween_default(name, value, priority) {
19228     var key = "style." + (name += "");
19229     if (arguments.length < 2) return (key = this.tween(key)) && key._value;
19230     if (value == null) return this.tween(key, null);
19231     if (typeof value !== "function") throw new Error();
19232     return this.tween(key, styleTween(name, value, priority == null ? "" : priority));
19233   }
19234
19235   // node_modules/d3-transition/src/transition/text.js
19236   function textConstant2(value) {
19237     return function() {
19238       this.textContent = value;
19239     };
19240   }
19241   function textFunction2(value) {
19242     return function() {
19243       var value1 = value(this);
19244       this.textContent = value1 == null ? "" : value1;
19245     };
19246   }
19247   function text_default2(value) {
19248     return this.tween("text", typeof value === "function" ? textFunction2(tweenValue(this, "text", value)) : textConstant2(value == null ? "" : value + ""));
19249   }
19250
19251   // node_modules/d3-transition/src/transition/textTween.js
19252   function textInterpolate(i3) {
19253     return function(t2) {
19254       this.textContent = i3.call(this, t2);
19255     };
19256   }
19257   function textTween(value) {
19258     var t0, i0;
19259     function tween() {
19260       var i3 = value.apply(this, arguments);
19261       if (i3 !== i0) t0 = (i0 = i3) && textInterpolate(i3);
19262       return t0;
19263     }
19264     tween._value = value;
19265     return tween;
19266   }
19267   function textTween_default(value) {
19268     var key = "text";
19269     if (arguments.length < 1) return (key = this.tween(key)) && key._value;
19270     if (value == null) return this.tween(key, null);
19271     if (typeof value !== "function") throw new Error();
19272     return this.tween(key, textTween(value));
19273   }
19274
19275   // node_modules/d3-transition/src/transition/transition.js
19276   function transition_default() {
19277     var name = this._name, id0 = this._id, id1 = newId();
19278     for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) {
19279       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
19280         if (node = group[i3]) {
19281           var inherit2 = get2(node, id0);
19282           schedule_default(node, name, id1, i3, group, {
19283             time: inherit2.time + inherit2.delay + inherit2.duration,
19284             delay: 0,
19285             duration: inherit2.duration,
19286             ease: inherit2.ease
19287           });
19288         }
19289       }
19290     }
19291     return new Transition(groups, this._parents, name, id1);
19292   }
19293
19294   // node_modules/d3-transition/src/transition/end.js
19295   function end_default() {
19296     var on0, on1, that = this, id2 = that._id, size = that.size();
19297     return new Promise(function(resolve, reject) {
19298       var cancel = { value: reject }, end = { value: function() {
19299         if (--size === 0) resolve();
19300       } };
19301       that.each(function() {
19302         var schedule = set2(this, id2), on = schedule.on;
19303         if (on !== on0) {
19304           on1 = (on0 = on).copy();
19305           on1._.cancel.push(cancel);
19306           on1._.interrupt.push(cancel);
19307           on1._.end.push(end);
19308         }
19309         schedule.on = on1;
19310       });
19311       if (size === 0) resolve();
19312     });
19313   }
19314
19315   // node_modules/d3-transition/src/transition/index.js
19316   var id = 0;
19317   function Transition(groups, parents, name, id2) {
19318     this._groups = groups;
19319     this._parents = parents;
19320     this._name = name;
19321     this._id = id2;
19322   }
19323   function transition(name) {
19324     return selection_default().transition(name);
19325   }
19326   function newId() {
19327     return ++id;
19328   }
19329   var selection_prototype = selection_default.prototype;
19330   Transition.prototype = transition.prototype = {
19331     constructor: Transition,
19332     select: select_default3,
19333     selectAll: selectAll_default3,
19334     selectChild: selection_prototype.selectChild,
19335     selectChildren: selection_prototype.selectChildren,
19336     filter: filter_default2,
19337     merge: merge_default2,
19338     selection: selection_default2,
19339     transition: transition_default,
19340     call: selection_prototype.call,
19341     nodes: selection_prototype.nodes,
19342     node: selection_prototype.node,
19343     size: selection_prototype.size,
19344     empty: selection_prototype.empty,
19345     each: selection_prototype.each,
19346     on: on_default2,
19347     attr: attr_default2,
19348     attrTween: attrTween_default,
19349     style: style_default2,
19350     styleTween: styleTween_default,
19351     text: text_default2,
19352     textTween: textTween_default,
19353     remove: remove_default2,
19354     tween: tween_default,
19355     delay: delay_default,
19356     duration: duration_default,
19357     ease: ease_default,
19358     easeVarying: easeVarying_default,
19359     end: end_default,
19360     [Symbol.iterator]: selection_prototype[Symbol.iterator]
19361   };
19362
19363   // node_modules/d3-ease/src/linear.js
19364   var linear2 = (t2) => +t2;
19365
19366   // node_modules/d3-ease/src/cubic.js
19367   function cubicInOut(t2) {
19368     return ((t2 *= 2) <= 1 ? t2 * t2 * t2 : (t2 -= 2) * t2 * t2 + 2) / 2;
19369   }
19370
19371   // node_modules/d3-transition/src/selection/transition.js
19372   var defaultTiming = {
19373     time: null,
19374     // Set on use.
19375     delay: 0,
19376     duration: 250,
19377     ease: cubicInOut
19378   };
19379   function inherit(node, id2) {
19380     var timing;
19381     while (!(timing = node.__transition) || !(timing = timing[id2])) {
19382       if (!(node = node.parentNode)) {
19383         throw new Error("transition ".concat(id2, " not found"));
19384       }
19385     }
19386     return timing;
19387   }
19388   function transition_default2(name) {
19389     var id2, timing;
19390     if (name instanceof Transition) {
19391       id2 = name._id, name = name._name;
19392     } else {
19393       id2 = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + "";
19394     }
19395     for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) {
19396       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
19397         if (node = group[i3]) {
19398           schedule_default(node, name, id2, i3, group, timing || inherit(node, id2));
19399         }
19400       }
19401     }
19402     return new Transition(groups, this._parents, name, id2);
19403   }
19404
19405   // node_modules/d3-transition/src/selection/index.js
19406   selection_default.prototype.interrupt = interrupt_default2;
19407   selection_default.prototype.transition = transition_default2;
19408
19409   // node_modules/d3-zoom/src/constant.js
19410   var constant_default4 = (x2) => () => x2;
19411
19412   // node_modules/d3-zoom/src/event.js
19413   function ZoomEvent(type2, {
19414     sourceEvent,
19415     target,
19416     transform: transform2,
19417     dispatch: dispatch14
19418   }) {
19419     Object.defineProperties(this, {
19420       type: { value: type2, enumerable: true, configurable: true },
19421       sourceEvent: { value: sourceEvent, enumerable: true, configurable: true },
19422       target: { value: target, enumerable: true, configurable: true },
19423       transform: { value: transform2, enumerable: true, configurable: true },
19424       _: { value: dispatch14 }
19425     });
19426   }
19427
19428   // node_modules/d3-zoom/src/transform.js
19429   function Transform(k2, x2, y2) {
19430     this.k = k2;
19431     this.x = x2;
19432     this.y = y2;
19433   }
19434   Transform.prototype = {
19435     constructor: Transform,
19436     scale: function(k2) {
19437       return k2 === 1 ? this : new Transform(this.k * k2, this.x, this.y);
19438     },
19439     translate: function(x2, y2) {
19440       return x2 === 0 & y2 === 0 ? this : new Transform(this.k, this.x + this.k * x2, this.y + this.k * y2);
19441     },
19442     apply: function(point) {
19443       return [point[0] * this.k + this.x, point[1] * this.k + this.y];
19444     },
19445     applyX: function(x2) {
19446       return x2 * this.k + this.x;
19447     },
19448     applyY: function(y2) {
19449       return y2 * this.k + this.y;
19450     },
19451     invert: function(location) {
19452       return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
19453     },
19454     invertX: function(x2) {
19455       return (x2 - this.x) / this.k;
19456     },
19457     invertY: function(y2) {
19458       return (y2 - this.y) / this.k;
19459     },
19460     rescaleX: function(x2) {
19461       return x2.copy().domain(x2.range().map(this.invertX, this).map(x2.invert, x2));
19462     },
19463     rescaleY: function(y2) {
19464       return y2.copy().domain(y2.range().map(this.invertY, this).map(y2.invert, y2));
19465     },
19466     toString: function() {
19467       return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
19468     }
19469   };
19470   var identity2 = new Transform(1, 0, 0);
19471   transform.prototype = Transform.prototype;
19472   function transform(node) {
19473     while (!node.__zoom) if (!(node = node.parentNode)) return identity2;
19474     return node.__zoom;
19475   }
19476
19477   // node_modules/d3-zoom/src/noevent.js
19478   function nopropagation2(event) {
19479     event.stopImmediatePropagation();
19480   }
19481   function noevent_default2(event) {
19482     event.preventDefault();
19483     event.stopImmediatePropagation();
19484   }
19485
19486   // node_modules/d3-zoom/src/zoom.js
19487   function defaultFilter2(event) {
19488     return (!event.ctrlKey || event.type === "wheel") && !event.button;
19489   }
19490   function defaultExtent() {
19491     var e3 = this;
19492     if (e3 instanceof SVGElement) {
19493       e3 = e3.ownerSVGElement || e3;
19494       if (e3.hasAttribute("viewBox")) {
19495         e3 = e3.viewBox.baseVal;
19496         return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]];
19497       }
19498       return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]];
19499     }
19500     return [[0, 0], [e3.clientWidth, e3.clientHeight]];
19501   }
19502   function defaultTransform() {
19503     return this.__zoom || identity2;
19504   }
19505   function defaultWheelDelta(event) {
19506     return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 2e-3) * (event.ctrlKey ? 10 : 1);
19507   }
19508   function defaultTouchable2() {
19509     return navigator.maxTouchPoints || "ontouchstart" in this;
19510   }
19511   function defaultConstrain(transform2, extent, translateExtent) {
19512     var dx0 = transform2.invertX(extent[0][0]) - translateExtent[0][0], dx1 = transform2.invertX(extent[1][0]) - translateExtent[1][0], dy0 = transform2.invertY(extent[0][1]) - translateExtent[0][1], dy1 = transform2.invertY(extent[1][1]) - translateExtent[1][1];
19513     return transform2.translate(
19514       dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
19515       dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
19516     );
19517   }
19518   function zoom_default2() {
19519     var filter2 = defaultFilter2, extent = defaultExtent, constrain = defaultConstrain, wheelDelta = defaultWheelDelta, touchable = defaultTouchable2, scaleExtent = [0, Infinity], translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]], duration = 250, interpolate = zoom_default, listeners = dispatch_default("start", "zoom", "end"), touchstarting, touchfirst, touchending, touchDelay = 500, wheelDelay = 150, clickDistance2 = 0, tapDistance = 10;
19520     function zoom(selection2) {
19521       selection2.property("__zoom", defaultTransform).on("wheel.zoom", wheeled, { passive: false }).on("mousedown.zoom", mousedowned).on("dblclick.zoom", dblclicked).filter(touchable).on("touchstart.zoom", touchstarted).on("touchmove.zoom", touchmoved).on("touchend.zoom touchcancel.zoom", touchended).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
19522     }
19523     zoom.transform = function(collection, transform2, point, event) {
19524       var selection2 = collection.selection ? collection.selection() : collection;
19525       selection2.property("__zoom", defaultTransform);
19526       if (collection !== selection2) {
19527         schedule(collection, transform2, point, event);
19528       } else {
19529         selection2.interrupt().each(function() {
19530           gesture(this, arguments).event(event).start().zoom(null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end();
19531         });
19532       }
19533     };
19534     zoom.scaleBy = function(selection2, k2, p2, event) {
19535       zoom.scaleTo(selection2, function() {
19536         var k0 = this.__zoom.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
19537         return k0 * k1;
19538       }, p2, event);
19539     };
19540     zoom.scaleTo = function(selection2, k2, p2, event) {
19541       zoom.transform(selection2, function() {
19542         var e3 = extent.apply(this, arguments), t0 = this.__zoom, p02 = p2 == null ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2, p1 = t0.invert(p02), k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
19543         return constrain(translate(scale(t0, k1), p02, p1), e3, translateExtent);
19544       }, p2, event);
19545     };
19546     zoom.translateBy = function(selection2, x2, y2, event) {
19547       zoom.transform(selection2, function() {
19548         return constrain(this.__zoom.translate(
19549           typeof x2 === "function" ? x2.apply(this, arguments) : x2,
19550           typeof y2 === "function" ? y2.apply(this, arguments) : y2
19551         ), extent.apply(this, arguments), translateExtent);
19552       }, null, event);
19553     };
19554     zoom.translateTo = function(selection2, x2, y2, p2, event) {
19555       zoom.transform(selection2, function() {
19556         var e3 = extent.apply(this, arguments), t2 = this.__zoom, p02 = p2 == null ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2;
19557         return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate(
19558           typeof x2 === "function" ? -x2.apply(this, arguments) : -x2,
19559           typeof y2 === "function" ? -y2.apply(this, arguments) : -y2
19560         ), e3, translateExtent);
19561       }, p2, event);
19562     };
19563     function scale(transform2, k2) {
19564       k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2));
19565       return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y);
19566     }
19567     function translate(transform2, p02, p1) {
19568       var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k;
19569       return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2);
19570     }
19571     function centroid(extent2) {
19572       return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
19573     }
19574     function schedule(transition2, transform2, point, event) {
19575       transition2.on("start.zoom", function() {
19576         gesture(this, arguments).event(event).start();
19577       }).on("interrupt.zoom end.zoom", function() {
19578         gesture(this, arguments).event(event).end();
19579       }).tween("zoom", function() {
19580         var that = this, args = arguments, g3 = gesture(that, args).event(event), e3 = extent.apply(that, args), p2 = point == null ? centroid(e3) : typeof point === "function" ? point.apply(that, args) : point, w2 = Math.max(e3[1][0] - e3[0][0], e3[1][1] - e3[0][1]), a2 = that.__zoom, b2 = typeof transform2 === "function" ? transform2.apply(that, args) : transform2, i3 = interpolate(a2.invert(p2).concat(w2 / a2.k), b2.invert(p2).concat(w2 / b2.k));
19581         return function(t2) {
19582           if (t2 === 1) t2 = b2;
19583           else {
19584             var l2 = i3(t2), k2 = w2 / l2[2];
19585             t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2);
19586           }
19587           g3.zoom(null, t2);
19588         };
19589       });
19590     }
19591     function gesture(that, args, clean2) {
19592       return !clean2 && that.__zooming || new Gesture(that, args);
19593     }
19594     function Gesture(that, args) {
19595       this.that = that;
19596       this.args = args;
19597       this.active = 0;
19598       this.sourceEvent = null;
19599       this.extent = extent.apply(that, args);
19600       this.taps = 0;
19601     }
19602     Gesture.prototype = {
19603       event: function(event) {
19604         if (event) this.sourceEvent = event;
19605         return this;
19606       },
19607       start: function() {
19608         if (++this.active === 1) {
19609           this.that.__zooming = this;
19610           this.emit("start");
19611         }
19612         return this;
19613       },
19614       zoom: function(key, transform2) {
19615         if (this.mouse && key !== "mouse") this.mouse[1] = transform2.invert(this.mouse[0]);
19616         if (this.touch0 && key !== "touch") this.touch0[1] = transform2.invert(this.touch0[0]);
19617         if (this.touch1 && key !== "touch") this.touch1[1] = transform2.invert(this.touch1[0]);
19618         this.that.__zoom = transform2;
19619         this.emit("zoom");
19620         return this;
19621       },
19622       end: function() {
19623         if (--this.active === 0) {
19624           delete this.that.__zooming;
19625           this.emit("end");
19626         }
19627         return this;
19628       },
19629       emit: function(type2) {
19630         var d2 = select_default2(this.that).datum();
19631         listeners.call(
19632           type2,
19633           this.that,
19634           new ZoomEvent(type2, {
19635             sourceEvent: this.sourceEvent,
19636             target: zoom,
19637             type: type2,
19638             transform: this.that.__zoom,
19639             dispatch: listeners
19640           }),
19641           d2
19642         );
19643       }
19644     };
19645     function wheeled(event, ...args) {
19646       if (!filter2.apply(this, arguments)) return;
19647       var g3 = gesture(this, args).event(event), t2 = this.__zoom, k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t2.k * Math.pow(2, wheelDelta.apply(this, arguments)))), p2 = pointer_default(event);
19648       if (g3.wheel) {
19649         if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) {
19650           g3.mouse[1] = t2.invert(g3.mouse[0] = p2);
19651         }
19652         clearTimeout(g3.wheel);
19653       } else if (t2.k === k2) return;
19654       else {
19655         g3.mouse = [p2, t2.invert(p2)];
19656         interrupt_default(this);
19657         g3.start();
19658       }
19659       noevent_default2(event);
19660       g3.wheel = setTimeout(wheelidled, wheelDelay);
19661       g3.zoom("mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent));
19662       function wheelidled() {
19663         g3.wheel = null;
19664         g3.end();
19665       }
19666     }
19667     function mousedowned(event, ...args) {
19668       if (touchending || !filter2.apply(this, arguments)) return;
19669       var currentTarget = event.currentTarget, g3 = gesture(this, args, true).event(event), v2 = select_default2(event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true), p2 = pointer_default(event, currentTarget), x05 = event.clientX, y05 = event.clientY;
19670       nodrag_default(event.view);
19671       nopropagation2(event);
19672       g3.mouse = [p2, this.__zoom.invert(p2)];
19673       interrupt_default(this);
19674       g3.start();
19675       function mousemoved(event2) {
19676         noevent_default2(event2);
19677         if (!g3.moved) {
19678           var dx = event2.clientX - x05, dy = event2.clientY - y05;
19679           g3.moved = dx * dx + dy * dy > clickDistance2;
19680         }
19681         g3.event(event2).zoom("mouse", constrain(translate(g3.that.__zoom, g3.mouse[0] = pointer_default(event2, currentTarget), g3.mouse[1]), g3.extent, translateExtent));
19682       }
19683       function mouseupped(event2) {
19684         v2.on("mousemove.zoom mouseup.zoom", null);
19685         yesdrag(event2.view, g3.moved);
19686         noevent_default2(event2);
19687         g3.event(event2).end();
19688       }
19689     }
19690     function dblclicked(event, ...args) {
19691       if (!filter2.apply(this, arguments)) return;
19692       var t0 = this.__zoom, p02 = pointer_default(event.changedTouches ? event.changedTouches[0] : event, this), p1 = t0.invert(p02), k1 = t0.k * (event.shiftKey ? 0.5 : 2), t1 = constrain(translate(scale(t0, k1), p02, p1), extent.apply(this, args), translateExtent);
19693       noevent_default2(event);
19694       if (duration > 0) select_default2(this).transition().duration(duration).call(schedule, t1, p02, event);
19695       else select_default2(this).call(zoom.transform, t1, p02, event);
19696     }
19697     function touchstarted(event, ...args) {
19698       if (!filter2.apply(this, arguments)) return;
19699       var touches = event.touches, n3 = touches.length, g3 = gesture(this, args, event.changedTouches.length === n3).event(event), started, i3, t2, p2;
19700       nopropagation2(event);
19701       for (i3 = 0; i3 < n3; ++i3) {
19702         t2 = touches[i3], p2 = pointer_default(t2, this);
19703         p2 = [p2, this.__zoom.invert(p2), t2.identifier];
19704         if (!g3.touch0) g3.touch0 = p2, started = true, g3.taps = 1 + !!touchstarting;
19705         else if (!g3.touch1 && g3.touch0[2] !== p2[2]) g3.touch1 = p2, g3.taps = 0;
19706       }
19707       if (touchstarting) touchstarting = clearTimeout(touchstarting);
19708       if (started) {
19709         if (g3.taps < 2) touchfirst = p2[0], touchstarting = setTimeout(function() {
19710           touchstarting = null;
19711         }, touchDelay);
19712         interrupt_default(this);
19713         g3.start();
19714       }
19715     }
19716     function touchmoved(event, ...args) {
19717       if (!this.__zooming) return;
19718       var g3 = gesture(this, args).event(event), touches = event.changedTouches, n3 = touches.length, i3, t2, p2, l2;
19719       noevent_default2(event);
19720       for (i3 = 0; i3 < n3; ++i3) {
19721         t2 = touches[i3], p2 = pointer_default(t2, this);
19722         if (g3.touch0 && g3.touch0[2] === t2.identifier) g3.touch0[0] = p2;
19723         else if (g3.touch1 && g3.touch1[2] === t2.identifier) g3.touch1[0] = p2;
19724       }
19725       t2 = g3.that.__zoom;
19726       if (g3.touch1) {
19727         var p02 = g3.touch0[0], l0 = g3.touch0[1], p1 = g3.touch1[0], l1 = g3.touch1[1], dp = (dp = p1[0] - p02[0]) * dp + (dp = p1[1] - p02[1]) * dp, dl = (dl = l1[0] - l0[0]) * dl + (dl = l1[1] - l0[1]) * dl;
19728         t2 = scale(t2, Math.sqrt(dp / dl));
19729         p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2];
19730         l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
19731       } else if (g3.touch0) p2 = g3.touch0[0], l2 = g3.touch0[1];
19732       else return;
19733       g3.zoom("touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent));
19734     }
19735     function touchended(event, ...args) {
19736       if (!this.__zooming) return;
19737       var g3 = gesture(this, args).event(event), touches = event.changedTouches, n3 = touches.length, i3, t2;
19738       nopropagation2(event);
19739       if (touchending) clearTimeout(touchending);
19740       touchending = setTimeout(function() {
19741         touchending = null;
19742       }, touchDelay);
19743       for (i3 = 0; i3 < n3; ++i3) {
19744         t2 = touches[i3];
19745         if (g3.touch0 && g3.touch0[2] === t2.identifier) delete g3.touch0;
19746         else if (g3.touch1 && g3.touch1[2] === t2.identifier) delete g3.touch1;
19747       }
19748       if (g3.touch1 && !g3.touch0) g3.touch0 = g3.touch1, delete g3.touch1;
19749       if (g3.touch0) g3.touch0[1] = this.__zoom.invert(g3.touch0[0]);
19750       else {
19751         g3.end();
19752         if (g3.taps === 2) {
19753           t2 = pointer_default(t2, this);
19754           if (Math.hypot(touchfirst[0] - t2[0], touchfirst[1] - t2[1]) < tapDistance) {
19755             var p2 = select_default2(this).on("dblclick.zoom");
19756             if (p2) p2.apply(this, arguments);
19757           }
19758         }
19759       }
19760     }
19761     zoom.wheelDelta = function(_2) {
19762       return arguments.length ? (wheelDelta = typeof _2 === "function" ? _2 : constant_default4(+_2), zoom) : wheelDelta;
19763     };
19764     zoom.filter = function(_2) {
19765       return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant_default4(!!_2), zoom) : filter2;
19766     };
19767     zoom.touchable = function(_2) {
19768       return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant_default4(!!_2), zoom) : touchable;
19769     };
19770     zoom.extent = function(_2) {
19771       return arguments.length ? (extent = typeof _2 === "function" ? _2 : constant_default4([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent;
19772     };
19773     zoom.scaleExtent = function(_2) {
19774       return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]];
19775     };
19776     zoom.translateExtent = function(_2) {
19777       return arguments.length ? (translateExtent[0][0] = +_2[0][0], translateExtent[1][0] = +_2[1][0], translateExtent[0][1] = +_2[0][1], translateExtent[1][1] = +_2[1][1], zoom) : [[translateExtent[0][0], translateExtent[0][1]], [translateExtent[1][0], translateExtent[1][1]]];
19778     };
19779     zoom.constrain = function(_2) {
19780       return arguments.length ? (constrain = _2, zoom) : constrain;
19781     };
19782     zoom.duration = function(_2) {
19783       return arguments.length ? (duration = +_2, zoom) : duration;
19784     };
19785     zoom.interpolate = function(_2) {
19786       return arguments.length ? (interpolate = _2, zoom) : interpolate;
19787     };
19788     zoom.on = function() {
19789       var value = listeners.on.apply(listeners, arguments);
19790       return value === listeners ? zoom : value;
19791     };
19792     zoom.clickDistance = function(_2) {
19793       return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, zoom) : Math.sqrt(clickDistance2);
19794     };
19795     zoom.tapDistance = function(_2) {
19796       return arguments.length ? (tapDistance = +_2, zoom) : tapDistance;
19797     };
19798     return zoom;
19799   }
19800
19801   // modules/geo/raw_mercator.js
19802   function geoRawMercator() {
19803     var project = mercatorRaw;
19804     var k2 = 512 / Math.PI;
19805     var x2 = 0;
19806     var y2 = 0;
19807     var clipExtent = [[0, 0], [0, 0]];
19808     function projection2(point) {
19809       point = project(point[0] * Math.PI / 180, point[1] * Math.PI / 180);
19810       return [point[0] * k2 + x2, y2 - point[1] * k2];
19811     }
19812     projection2.invert = function(point) {
19813       point = project.invert((point[0] - x2) / k2, (y2 - point[1]) / k2);
19814       return point && [point[0] * 180 / Math.PI, point[1] * 180 / Math.PI];
19815     };
19816     projection2.scale = function(_2) {
19817       if (!arguments.length) return k2;
19818       k2 = +_2;
19819       return projection2;
19820     };
19821     projection2.translate = function(_2) {
19822       if (!arguments.length) return [x2, y2];
19823       x2 = +_2[0];
19824       y2 = +_2[1];
19825       return projection2;
19826     };
19827     projection2.clipExtent = function(_2) {
19828       if (!arguments.length) return clipExtent;
19829       clipExtent = _2;
19830       return projection2;
19831     };
19832     projection2.transform = function(obj) {
19833       if (!arguments.length) return identity2.translate(x2, y2).scale(k2);
19834       x2 = +obj.x;
19835       y2 = +obj.y;
19836       k2 = +obj.k;
19837       return projection2;
19838     };
19839     projection2.stream = transform_default({
19840       point: function(x3, y3) {
19841         var vec = projection2([x3, y3]);
19842         this.stream.point(vec[0], vec[1]);
19843       }
19844     }).stream;
19845     return projection2;
19846   }
19847
19848   // modules/geo/ortho.js
19849   function geoOrthoNormalizedDotProduct(a2, b2, origin) {
19850     if (geoVecEqual(origin, a2) || geoVecEqual(origin, b2)) {
19851       return 1;
19852     }
19853     return geoVecNormalizedDot(a2, b2, origin);
19854   }
19855   function geoOrthoFilterDotProduct(dotp, epsilon3, lowerThreshold, upperThreshold, allowStraightAngles) {
19856     var val = Math.abs(dotp);
19857     if (val < epsilon3) {
19858       return 0;
19859     } else if (allowStraightAngles && Math.abs(val - 1) < epsilon3) {
19860       return 0;
19861     } else if (val < lowerThreshold || val > upperThreshold) {
19862       return dotp;
19863     } else {
19864       return null;
19865     }
19866   }
19867   function geoOrthoCalcScore(points, isClosed, epsilon3, threshold) {
19868     var score = 0;
19869     var first = isClosed ? 0 : 1;
19870     var last = isClosed ? points.length : points.length - 1;
19871     var coords = points.map(function(p2) {
19872       return p2.coord;
19873     });
19874     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
19875     var upperThreshold = Math.cos(threshold * Math.PI / 180);
19876     for (var i3 = first; i3 < last; i3++) {
19877       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
19878       var origin = coords[i3];
19879       var b2 = coords[(i3 + 1) % coords.length];
19880       var dotp = geoOrthoFilterDotProduct(geoOrthoNormalizedDotProduct(a2, b2, origin), epsilon3, lowerThreshold, upperThreshold);
19881       if (dotp === null) continue;
19882       score = score + 2 * Math.min(Math.abs(dotp - 1), Math.min(Math.abs(dotp), Math.abs(dotp + 1)));
19883     }
19884     return score;
19885   }
19886   function geoOrthoMaxOffsetAngle(coords, isClosed, lessThan) {
19887     var max3 = -Infinity;
19888     var first = isClosed ? 0 : 1;
19889     var last = isClosed ? coords.length : coords.length - 1;
19890     for (var i3 = first; i3 < last; i3++) {
19891       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
19892       var origin = coords[i3];
19893       var b2 = coords[(i3 + 1) % coords.length];
19894       var normalizedDotP = geoOrthoNormalizedDotProduct(a2, b2, origin);
19895       var angle2 = Math.acos(Math.abs(normalizedDotP)) * 180 / Math.PI;
19896       if (angle2 > 45) angle2 = 90 - angle2;
19897       if (angle2 >= lessThan) continue;
19898       if (angle2 > max3) max3 = angle2;
19899     }
19900     if (max3 === -Infinity) return null;
19901     return max3;
19902   }
19903   function geoOrthoCanOrthogonalize(coords, isClosed, epsilon3, threshold, allowStraightAngles) {
19904     var score = null;
19905     var first = isClosed ? 0 : 1;
19906     var last = isClosed ? coords.length : coords.length - 1;
19907     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
19908     var upperThreshold = Math.cos(threshold * Math.PI / 180);
19909     for (var i3 = first; i3 < last; i3++) {
19910       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
19911       var origin = coords[i3];
19912       var b2 = coords[(i3 + 1) % coords.length];
19913       var dotp = geoOrthoFilterDotProduct(geoOrthoNormalizedDotProduct(a2, b2, origin), epsilon3, lowerThreshold, upperThreshold, allowStraightAngles);
19914       if (dotp === null) continue;
19915       if (Math.abs(dotp) > 0) return 1;
19916       score = 0;
19917     }
19918     return score;
19919   }
19920
19921   // modules/osm/tags.js
19922   function osmIsInterestingTag(key) {
19923     return key !== "attribution" && key !== "created_by" && key !== "source" && key !== "odbl" && key.indexOf("source:") !== 0 && key.indexOf("source_ref") !== 0 && // purposely exclude colon
19924     key.indexOf("tiger:") !== 0;
19925   }
19926   var osmLifecyclePrefixes = {
19927     // nonexistent, might be built
19928     proposed: true,
19929     planned: true,
19930     // under maintenance or between groundbreaking and opening
19931     construction: true,
19932     // existent but not functional
19933     disused: true,
19934     // dilapidated to nonexistent
19935     abandoned: true,
19936     was: true,
19937     // nonexistent, still may appear in imagery
19938     dismantled: true,
19939     razed: true,
19940     demolished: true,
19941     destroyed: true,
19942     removed: true,
19943     obliterated: true,
19944     // existent occasionally, e.g. stormwater drainage basin
19945     intermittent: true
19946   };
19947   function osmRemoveLifecyclePrefix(key) {
19948     const keySegments = key.split(":");
19949     if (keySegments.length === 1) return key;
19950     if (keySegments[0] in osmLifecyclePrefixes) {
19951       return key.slice(keySegments[0].length + 1);
19952     }
19953     return key;
19954   }
19955   var osmAreaKeys = {};
19956   function osmSetAreaKeys(value) {
19957     osmAreaKeys = value;
19958   }
19959   var osmAreaKeysExceptions = {
19960     highway: {
19961       elevator: true,
19962       rest_area: true,
19963       services: true
19964     },
19965     public_transport: {
19966       platform: true
19967     },
19968     railway: {
19969       platform: true,
19970       roundhouse: true,
19971       station: true,
19972       traverser: true,
19973       turntable: true,
19974       wash: true,
19975       ventilation_shaft: true
19976     },
19977     waterway: {
19978       dam: true
19979     },
19980     amenity: {
19981       bicycle_parking: true
19982     }
19983   };
19984   function osmTagSuggestingArea(tags) {
19985     if (tags.area === "yes") return { area: "yes" };
19986     if (tags.area === "no") return null;
19987     var returnTags = {};
19988     for (var realKey in tags) {
19989       const key = osmRemoveLifecyclePrefix(realKey);
19990       if (key in osmAreaKeys && !(tags[realKey] in osmAreaKeys[key])) {
19991         returnTags[realKey] = tags[realKey];
19992         return returnTags;
19993       }
19994       if (key in osmAreaKeysExceptions && tags[realKey] in osmAreaKeysExceptions[key]) {
19995         returnTags[realKey] = tags[realKey];
19996         return returnTags;
19997       }
19998     }
19999     return null;
20000   }
20001   var osmLineTags = {};
20002   function osmSetLineTags(value) {
20003     osmLineTags = value;
20004   }
20005   var osmPointTags = {};
20006   function osmSetPointTags(value) {
20007     osmPointTags = value;
20008   }
20009   var osmVertexTags = {};
20010   function osmSetVertexTags(value) {
20011     osmVertexTags = value;
20012   }
20013   function osmNodeGeometriesForTags(nodeTags) {
20014     var geometries = {};
20015     for (var key in nodeTags) {
20016       if (osmPointTags[key] && (osmPointTags[key]["*"] || osmPointTags[key][nodeTags[key]])) {
20017         geometries.point = true;
20018       }
20019       if (osmVertexTags[key] && (osmVertexTags[key]["*"] || osmVertexTags[key][nodeTags[key]])) {
20020         geometries.vertex = true;
20021       }
20022       if (geometries.point && geometries.vertex) break;
20023     }
20024     return geometries;
20025   }
20026   var osmOneWayTags = {
20027     "aerialway": {
20028       "chair_lift": true,
20029       "drag_lift": true,
20030       "j-bar": true,
20031       "magic_carpet": true,
20032       "mixed_lift": true,
20033       "platter": true,
20034       "rope_tow": true,
20035       "t-bar": true,
20036       "zip_line": true
20037     },
20038     "conveying": {
20039       "forward": true,
20040       "backward": true,
20041       "reversible": true
20042     },
20043     "highway": {
20044       "motorway": true
20045     },
20046     "junction": {
20047       "circular": true,
20048       "roundabout": true
20049     },
20050     "man_made": {
20051       "goods_conveyor": true,
20052       "piste:halfpipe": true
20053     },
20054     "piste:type": {
20055       "downhill": true,
20056       "sled": true,
20057       "yes": true
20058     },
20059     "seamark:type": {
20060       "two-way_route": true,
20061       "recommended_traffic_lane": true,
20062       "separation_lane": true,
20063       "separation_roundabout": true
20064     },
20065     "waterway": {
20066       "canal": true,
20067       "ditch": true,
20068       "drain": true,
20069       "fish_pass": true,
20070       "flowline": true,
20071       "pressurised": true,
20072       "river": true,
20073       "spillway": true,
20074       "stream": true,
20075       "tidal_channel": true
20076     }
20077   };
20078   var osmPavedTags = {
20079     "surface": {
20080       "paved": true,
20081       "asphalt": true,
20082       "concrete": true,
20083       "chipseal": true,
20084       "concrete:lanes": true,
20085       "concrete:plates": true
20086     },
20087     "tracktype": {
20088       "grade1": true
20089     }
20090   };
20091   var osmSemipavedTags = {
20092     "surface": {
20093       "cobblestone": true,
20094       "cobblestone:flattened": true,
20095       "unhewn_cobblestone": true,
20096       "sett": true,
20097       "paving_stones": true,
20098       "metal": true,
20099       "wood": true
20100     }
20101   };
20102   var osmRightSideIsInsideTags = {
20103     "natural": {
20104       "cliff": true,
20105       "coastline": "coastline"
20106     },
20107     "barrier": {
20108       "retaining_wall": true,
20109       "kerb": true,
20110       "guard_rail": true,
20111       "city_wall": true
20112     },
20113     "man_made": {
20114       "embankment": true,
20115       "quay": true
20116     },
20117     "waterway": {
20118       "weir": true
20119     }
20120   };
20121   var osmRoutableHighwayTagValues = {
20122     motorway: true,
20123     trunk: true,
20124     primary: true,
20125     secondary: true,
20126     tertiary: true,
20127     residential: true,
20128     motorway_link: true,
20129     trunk_link: true,
20130     primary_link: true,
20131     secondary_link: true,
20132     tertiary_link: true,
20133     unclassified: true,
20134     road: true,
20135     service: true,
20136     track: true,
20137     living_street: true,
20138     bus_guideway: true,
20139     busway: true,
20140     path: true,
20141     footway: true,
20142     cycleway: true,
20143     bridleway: true,
20144     pedestrian: true,
20145     corridor: true,
20146     steps: true,
20147     ladder: true
20148   };
20149   var osmPathHighwayTagValues = {
20150     path: true,
20151     footway: true,
20152     cycleway: true,
20153     bridleway: true,
20154     pedestrian: true,
20155     corridor: true,
20156     steps: true,
20157     ladder: true
20158   };
20159   var osmRailwayTrackTagValues = {
20160     rail: true,
20161     light_rail: true,
20162     tram: true,
20163     subway: true,
20164     monorail: true,
20165     funicular: true,
20166     miniature: true,
20167     narrow_gauge: true,
20168     disused: true,
20169     preserved: true
20170   };
20171   var osmFlowingWaterwayTagValues = {
20172     canal: true,
20173     ditch: true,
20174     drain: true,
20175     fish_pass: true,
20176     flowline: true,
20177     river: true,
20178     stream: true,
20179     tidal_channel: true
20180   };
20181   var allowUpperCaseTagValues = /network|taxon|genus|species|brand|grape_variety|royal_cypher|listed_status|booth|rating|stars|:output|_hours|_times|_ref|manufacturer|country|target|brewery|cai_scale|traffic_sign/;
20182   function isColourValid(value) {
20183     if (!value.match(/^(#([0-9a-fA-F]{3}){1,2}|\w+)$/)) {
20184       return false;
20185     }
20186     if (!CSS.supports("color", value) || ["unset", "inherit", "initial", "revert"].includes(value)) {
20187       return false;
20188     }
20189     return true;
20190   }
20191   var osmMutuallyExclusiveTagPairs = [
20192     ["noname", "name"],
20193     ["noref", "ref"],
20194     ["nohousenumber", "addr:housenumber"],
20195     ["noaddress", "addr:housenumber"],
20196     ["noaddress", "addr:housename"],
20197     ["noaddress", "addr:unit"],
20198     ["addr:nostreet", "addr:street"]
20199   ];
20200
20201   // modules/util/array.js
20202   function utilArrayIdentical(a2, b2) {
20203     if (a2 === b2) return true;
20204     var i3 = a2.length;
20205     if (i3 !== b2.length) return false;
20206     while (i3--) {
20207       if (a2[i3] !== b2[i3]) return false;
20208     }
20209     return true;
20210   }
20211   function utilArrayDifference(a2, b2) {
20212     var other2 = new Set(b2);
20213     return Array.from(new Set(a2)).filter(function(v2) {
20214       return !other2.has(v2);
20215     });
20216   }
20217   function utilArrayIntersection(a2, b2) {
20218     var other2 = new Set(b2);
20219     return Array.from(new Set(a2)).filter(function(v2) {
20220       return other2.has(v2);
20221     });
20222   }
20223   function utilArrayUnion(a2, b2) {
20224     var result = new Set(a2);
20225     b2.forEach(function(v2) {
20226       result.add(v2);
20227     });
20228     return Array.from(result);
20229   }
20230   function utilArrayUniq(a2) {
20231     return Array.from(new Set(a2));
20232   }
20233   function utilArrayChunk(a2, chunkSize) {
20234     if (!chunkSize || chunkSize < 0) return [a2.slice()];
20235     var result = new Array(Math.ceil(a2.length / chunkSize));
20236     return Array.from(result, function(item, i3) {
20237       return a2.slice(i3 * chunkSize, i3 * chunkSize + chunkSize);
20238     });
20239   }
20240   function utilArrayFlatten(a2) {
20241     return a2.reduce(function(acc, val) {
20242       return acc.concat(val);
20243     }, []);
20244   }
20245   function utilArrayGroupBy(a2, key) {
20246     return a2.reduce(function(acc, item) {
20247       var group = typeof key === "function" ? key(item) : item[key];
20248       (acc[group] = acc[group] || []).push(item);
20249       return acc;
20250     }, {});
20251   }
20252   function utilArrayUniqBy(a2, key) {
20253     var seen = /* @__PURE__ */ new Set();
20254     return a2.reduce(function(acc, item) {
20255       var val = typeof key === "function" ? key(item) : item[key];
20256       if (val && !seen.has(val)) {
20257         seen.add(val);
20258         acc.push(item);
20259       }
20260       return acc;
20261     }, []);
20262   }
20263
20264   // modules/util/util.js
20265   var import_diacritics = __toESM(require_diacritics());
20266
20267   // modules/util/svg_paths_rtl_fix.js
20268   var import_alif_toolkit = __toESM(require_lib());
20269   var rtlRegex = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u07BF\u08A0–\u08BF]/;
20270   function fixRTLTextForSvg(inputText) {
20271     var ret = "", rtlBuffer = [];
20272     var arabicRegex = /[\u0600-\u06FF]/g;
20273     var arabicDiacritics = /[\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06ED]/g;
20274     var arabicMath = /[\u0660-\u066C\u06F0-\u06F9]+/g;
20275     var thaanaVowel = /[\u07A6-\u07B0]/;
20276     var hebrewSign = /[\u0591-\u05bd\u05bf\u05c1-\u05c5\u05c7]/;
20277     if (arabicRegex.test(inputText)) {
20278       inputText = (0, import_alif_toolkit.WordShaper)(inputText);
20279     }
20280     for (var n3 = 0; n3 < inputText.length; n3++) {
20281       var c2 = inputText[n3];
20282       if (arabicMath.test(c2)) {
20283         ret += rtlBuffer.reverse().join("");
20284         rtlBuffer = [c2];
20285       } else {
20286         if (rtlBuffer.length && arabicMath.test(rtlBuffer[rtlBuffer.length - 1])) {
20287           ret += rtlBuffer.reverse().join("");
20288           rtlBuffer = [];
20289         }
20290         if ((thaanaVowel.test(c2) || hebrewSign.test(c2) || arabicDiacritics.test(c2)) && rtlBuffer.length) {
20291           rtlBuffer[rtlBuffer.length - 1] += c2;
20292         } else if (rtlRegex.test(c2) || c2.charCodeAt(0) >= 64336 && c2.charCodeAt(0) <= 65023 || c2.charCodeAt(0) >= 65136 && c2.charCodeAt(0) <= 65279) {
20293           rtlBuffer.push(c2);
20294         } else if (c2 === " " && rtlBuffer.length) {
20295           rtlBuffer = [rtlBuffer.reverse().join("") + " "];
20296         } else {
20297           ret += rtlBuffer.reverse().join("") + c2;
20298           rtlBuffer = [];
20299         }
20300       }
20301     }
20302     ret += rtlBuffer.reverse().join("");
20303     return ret;
20304   }
20305
20306   // node_modules/lodash-es/_freeGlobal.js
20307   var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
20308   var freeGlobal_default = freeGlobal;
20309
20310   // node_modules/lodash-es/_root.js
20311   var freeSelf = typeof self == "object" && self && self.Object === Object && self;
20312   var root2 = freeGlobal_default || freeSelf || Function("return this")();
20313   var root_default = root2;
20314
20315   // node_modules/lodash-es/_Symbol.js
20316   var Symbol2 = root_default.Symbol;
20317   var Symbol_default = Symbol2;
20318
20319   // node_modules/lodash-es/_getRawTag.js
20320   var objectProto = Object.prototype;
20321   var hasOwnProperty = objectProto.hasOwnProperty;
20322   var nativeObjectToString = objectProto.toString;
20323   var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
20324   function getRawTag(value) {
20325     var isOwn = hasOwnProperty.call(value, symToStringTag), tag2 = value[symToStringTag];
20326     try {
20327       value[symToStringTag] = void 0;
20328       var unmasked = true;
20329     } catch (e3) {
20330     }
20331     var result = nativeObjectToString.call(value);
20332     if (unmasked) {
20333       if (isOwn) {
20334         value[symToStringTag] = tag2;
20335       } else {
20336         delete value[symToStringTag];
20337       }
20338     }
20339     return result;
20340   }
20341   var getRawTag_default = getRawTag;
20342
20343   // node_modules/lodash-es/_objectToString.js
20344   var objectProto2 = Object.prototype;
20345   var nativeObjectToString2 = objectProto2.toString;
20346   function objectToString(value) {
20347     return nativeObjectToString2.call(value);
20348   }
20349   var objectToString_default = objectToString;
20350
20351   // node_modules/lodash-es/_baseGetTag.js
20352   var nullTag = "[object Null]";
20353   var undefinedTag = "[object Undefined]";
20354   var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
20355   function baseGetTag(value) {
20356     if (value == null) {
20357       return value === void 0 ? undefinedTag : nullTag;
20358     }
20359     return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
20360   }
20361   var baseGetTag_default = baseGetTag;
20362
20363   // node_modules/lodash-es/isObjectLike.js
20364   function isObjectLike(value) {
20365     return value != null && typeof value == "object";
20366   }
20367   var isObjectLike_default = isObjectLike;
20368
20369   // node_modules/lodash-es/isSymbol.js
20370   var symbolTag = "[object Symbol]";
20371   function isSymbol(value) {
20372     return typeof value == "symbol" || isObjectLike_default(value) && baseGetTag_default(value) == symbolTag;
20373   }
20374   var isSymbol_default = isSymbol;
20375
20376   // node_modules/lodash-es/_arrayMap.js
20377   function arrayMap(array2, iteratee) {
20378     var index = -1, length2 = array2 == null ? 0 : array2.length, result = Array(length2);
20379     while (++index < length2) {
20380       result[index] = iteratee(array2[index], index, array2);
20381     }
20382     return result;
20383   }
20384   var arrayMap_default = arrayMap;
20385
20386   // node_modules/lodash-es/isArray.js
20387   var isArray = Array.isArray;
20388   var isArray_default = isArray;
20389
20390   // node_modules/lodash-es/_baseToString.js
20391   var INFINITY = 1 / 0;
20392   var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
20393   var symbolToString = symbolProto ? symbolProto.toString : void 0;
20394   function baseToString(value) {
20395     if (typeof value == "string") {
20396       return value;
20397     }
20398     if (isArray_default(value)) {
20399       return arrayMap_default(value, baseToString) + "";
20400     }
20401     if (isSymbol_default(value)) {
20402       return symbolToString ? symbolToString.call(value) : "";
20403     }
20404     var result = value + "";
20405     return result == "0" && 1 / value == -INFINITY ? "-0" : result;
20406   }
20407   var baseToString_default = baseToString;
20408
20409   // node_modules/lodash-es/_trimmedEndIndex.js
20410   var reWhitespace = /\s/;
20411   function trimmedEndIndex(string) {
20412     var index = string.length;
20413     while (index-- && reWhitespace.test(string.charAt(index))) {
20414     }
20415     return index;
20416   }
20417   var trimmedEndIndex_default = trimmedEndIndex;
20418
20419   // node_modules/lodash-es/_baseTrim.js
20420   var reTrimStart = /^\s+/;
20421   function baseTrim(string) {
20422     return string ? string.slice(0, trimmedEndIndex_default(string) + 1).replace(reTrimStart, "") : string;
20423   }
20424   var baseTrim_default = baseTrim;
20425
20426   // node_modules/lodash-es/isObject.js
20427   function isObject(value) {
20428     var type2 = typeof value;
20429     return value != null && (type2 == "object" || type2 == "function");
20430   }
20431   var isObject_default = isObject;
20432
20433   // node_modules/lodash-es/toNumber.js
20434   var NAN = 0 / 0;
20435   var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
20436   var reIsBinary = /^0b[01]+$/i;
20437   var reIsOctal = /^0o[0-7]+$/i;
20438   var freeParseInt = parseInt;
20439   function toNumber(value) {
20440     if (typeof value == "number") {
20441       return value;
20442     }
20443     if (isSymbol_default(value)) {
20444       return NAN;
20445     }
20446     if (isObject_default(value)) {
20447       var other2 = typeof value.valueOf == "function" ? value.valueOf() : value;
20448       value = isObject_default(other2) ? other2 + "" : other2;
20449     }
20450     if (typeof value != "string") {
20451       return value === 0 ? value : +value;
20452     }
20453     value = baseTrim_default(value);
20454     var isBinary = reIsBinary.test(value);
20455     return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
20456   }
20457   var toNumber_default = toNumber;
20458
20459   // node_modules/lodash-es/isFunction.js
20460   var asyncTag = "[object AsyncFunction]";
20461   var funcTag = "[object Function]";
20462   var genTag = "[object GeneratorFunction]";
20463   var proxyTag = "[object Proxy]";
20464   function isFunction(value) {
20465     if (!isObject_default(value)) {
20466       return false;
20467     }
20468     var tag2 = baseGetTag_default(value);
20469     return tag2 == funcTag || tag2 == genTag || tag2 == asyncTag || tag2 == proxyTag;
20470   }
20471   var isFunction_default = isFunction;
20472
20473   // node_modules/lodash-es/_coreJsData.js
20474   var coreJsData = root_default["__core-js_shared__"];
20475   var coreJsData_default = coreJsData;
20476
20477   // node_modules/lodash-es/_isMasked.js
20478   var maskSrcKey = function() {
20479     var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
20480     return uid ? "Symbol(src)_1." + uid : "";
20481   }();
20482   function isMasked(func) {
20483     return !!maskSrcKey && maskSrcKey in func;
20484   }
20485   var isMasked_default = isMasked;
20486
20487   // node_modules/lodash-es/_toSource.js
20488   var funcProto = Function.prototype;
20489   var funcToString = funcProto.toString;
20490   function toSource(func) {
20491     if (func != null) {
20492       try {
20493         return funcToString.call(func);
20494       } catch (e3) {
20495       }
20496       try {
20497         return func + "";
20498       } catch (e3) {
20499       }
20500     }
20501     return "";
20502   }
20503   var toSource_default = toSource;
20504
20505   // node_modules/lodash-es/_baseIsNative.js
20506   var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
20507   var reIsHostCtor = /^\[object .+?Constructor\]$/;
20508   var funcProto2 = Function.prototype;
20509   var objectProto3 = Object.prototype;
20510   var funcToString2 = funcProto2.toString;
20511   var hasOwnProperty2 = objectProto3.hasOwnProperty;
20512   var reIsNative = RegExp(
20513     "^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
20514   );
20515   function baseIsNative(value) {
20516     if (!isObject_default(value) || isMasked_default(value)) {
20517       return false;
20518     }
20519     var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
20520     return pattern.test(toSource_default(value));
20521   }
20522   var baseIsNative_default = baseIsNative;
20523
20524   // node_modules/lodash-es/_getValue.js
20525   function getValue(object, key) {
20526     return object == null ? void 0 : object[key];
20527   }
20528   var getValue_default = getValue;
20529
20530   // node_modules/lodash-es/_getNative.js
20531   function getNative(object, key) {
20532     var value = getValue_default(object, key);
20533     return baseIsNative_default(value) ? value : void 0;
20534   }
20535   var getNative_default = getNative;
20536
20537   // node_modules/lodash-es/_WeakMap.js
20538   var WeakMap = getNative_default(root_default, "WeakMap");
20539   var WeakMap_default = WeakMap;
20540
20541   // node_modules/lodash-es/_isIndex.js
20542   var MAX_SAFE_INTEGER = 9007199254740991;
20543   var reIsUint = /^(?:0|[1-9]\d*)$/;
20544   function isIndex(value, length2) {
20545     var type2 = typeof value;
20546     length2 = length2 == null ? MAX_SAFE_INTEGER : length2;
20547     return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length2);
20548   }
20549   var isIndex_default = isIndex;
20550
20551   // node_modules/lodash-es/eq.js
20552   function eq(value, other2) {
20553     return value === other2 || value !== value && other2 !== other2;
20554   }
20555   var eq_default = eq;
20556
20557   // node_modules/lodash-es/isLength.js
20558   var MAX_SAFE_INTEGER2 = 9007199254740991;
20559   function isLength(value) {
20560     return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER2;
20561   }
20562   var isLength_default = isLength;
20563
20564   // node_modules/lodash-es/isArrayLike.js
20565   function isArrayLike(value) {
20566     return value != null && isLength_default(value.length) && !isFunction_default(value);
20567   }
20568   var isArrayLike_default = isArrayLike;
20569
20570   // node_modules/lodash-es/_isPrototype.js
20571   var objectProto4 = Object.prototype;
20572   function isPrototype(value) {
20573     var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto4;
20574     return value === proto;
20575   }
20576   var isPrototype_default = isPrototype;
20577
20578   // node_modules/lodash-es/_baseTimes.js
20579   function baseTimes(n3, iteratee) {
20580     var index = -1, result = Array(n3);
20581     while (++index < n3) {
20582       result[index] = iteratee(index);
20583     }
20584     return result;
20585   }
20586   var baseTimes_default = baseTimes;
20587
20588   // node_modules/lodash-es/_baseIsArguments.js
20589   var argsTag = "[object Arguments]";
20590   function baseIsArguments(value) {
20591     return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
20592   }
20593   var baseIsArguments_default = baseIsArguments;
20594
20595   // node_modules/lodash-es/isArguments.js
20596   var objectProto5 = Object.prototype;
20597   var hasOwnProperty3 = objectProto5.hasOwnProperty;
20598   var propertyIsEnumerable = objectProto5.propertyIsEnumerable;
20599   var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
20600     return arguments;
20601   }()) ? baseIsArguments_default : function(value) {
20602     return isObjectLike_default(value) && hasOwnProperty3.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
20603   };
20604   var isArguments_default = isArguments;
20605
20606   // node_modules/lodash-es/stubFalse.js
20607   function stubFalse() {
20608     return false;
20609   }
20610   var stubFalse_default = stubFalse;
20611
20612   // node_modules/lodash-es/isBuffer.js
20613   var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
20614   var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
20615   var moduleExports = freeModule && freeModule.exports === freeExports;
20616   var Buffer2 = moduleExports ? root_default.Buffer : void 0;
20617   var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
20618   var isBuffer = nativeIsBuffer || stubFalse_default;
20619   var isBuffer_default = isBuffer;
20620
20621   // node_modules/lodash-es/_baseIsTypedArray.js
20622   var argsTag2 = "[object Arguments]";
20623   var arrayTag = "[object Array]";
20624   var boolTag = "[object Boolean]";
20625   var dateTag = "[object Date]";
20626   var errorTag = "[object Error]";
20627   var funcTag2 = "[object Function]";
20628   var mapTag = "[object Map]";
20629   var numberTag = "[object Number]";
20630   var objectTag = "[object Object]";
20631   var regexpTag = "[object RegExp]";
20632   var setTag = "[object Set]";
20633   var stringTag = "[object String]";
20634   var weakMapTag = "[object WeakMap]";
20635   var arrayBufferTag = "[object ArrayBuffer]";
20636   var dataViewTag = "[object DataView]";
20637   var float32Tag = "[object Float32Array]";
20638   var float64Tag = "[object Float64Array]";
20639   var int8Tag = "[object Int8Array]";
20640   var int16Tag = "[object Int16Array]";
20641   var int32Tag = "[object Int32Array]";
20642   var uint8Tag = "[object Uint8Array]";
20643   var uint8ClampedTag = "[object Uint8ClampedArray]";
20644   var uint16Tag = "[object Uint16Array]";
20645   var uint32Tag = "[object Uint32Array]";
20646   var typedArrayTags = {};
20647   typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
20648   typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag2] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
20649   function baseIsTypedArray(value) {
20650     return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
20651   }
20652   var baseIsTypedArray_default = baseIsTypedArray;
20653
20654   // node_modules/lodash-es/_baseUnary.js
20655   function baseUnary(func) {
20656     return function(value) {
20657       return func(value);
20658     };
20659   }
20660   var baseUnary_default = baseUnary;
20661
20662   // node_modules/lodash-es/_nodeUtil.js
20663   var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
20664   var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
20665   var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
20666   var freeProcess = moduleExports2 && freeGlobal_default.process;
20667   var nodeUtil = function() {
20668     try {
20669       var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
20670       if (types) {
20671         return types;
20672       }
20673       return freeProcess && freeProcess.binding && freeProcess.binding("util");
20674     } catch (e3) {
20675     }
20676   }();
20677   var nodeUtil_default = nodeUtil;
20678
20679   // node_modules/lodash-es/isTypedArray.js
20680   var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
20681   var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
20682   var isTypedArray_default = isTypedArray;
20683
20684   // node_modules/lodash-es/_arrayLikeKeys.js
20685   var objectProto6 = Object.prototype;
20686   var hasOwnProperty4 = objectProto6.hasOwnProperty;
20687   function arrayLikeKeys(value, inherited) {
20688     var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value.length, String) : [], length2 = result.length;
20689     for (var key in value) {
20690       if ((inherited || hasOwnProperty4.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
20691       (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
20692       isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
20693       isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
20694       isIndex_default(key, length2)))) {
20695         result.push(key);
20696       }
20697     }
20698     return result;
20699   }
20700   var arrayLikeKeys_default = arrayLikeKeys;
20701
20702   // node_modules/lodash-es/_overArg.js
20703   function overArg(func, transform2) {
20704     return function(arg) {
20705       return func(transform2(arg));
20706     };
20707   }
20708   var overArg_default = overArg;
20709
20710   // node_modules/lodash-es/_nativeKeys.js
20711   var nativeKeys = overArg_default(Object.keys, Object);
20712   var nativeKeys_default = nativeKeys;
20713
20714   // node_modules/lodash-es/_baseKeys.js
20715   var objectProto7 = Object.prototype;
20716   var hasOwnProperty5 = objectProto7.hasOwnProperty;
20717   function baseKeys(object) {
20718     if (!isPrototype_default(object)) {
20719       return nativeKeys_default(object);
20720     }
20721     var result = [];
20722     for (var key in Object(object)) {
20723       if (hasOwnProperty5.call(object, key) && key != "constructor") {
20724         result.push(key);
20725       }
20726     }
20727     return result;
20728   }
20729   var baseKeys_default = baseKeys;
20730
20731   // node_modules/lodash-es/keys.js
20732   function keys(object) {
20733     return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
20734   }
20735   var keys_default = keys;
20736
20737   // node_modules/lodash-es/_nativeCreate.js
20738   var nativeCreate = getNative_default(Object, "create");
20739   var nativeCreate_default = nativeCreate;
20740
20741   // node_modules/lodash-es/_hashClear.js
20742   function hashClear() {
20743     this.__data__ = nativeCreate_default ? nativeCreate_default(null) : {};
20744     this.size = 0;
20745   }
20746   var hashClear_default = hashClear;
20747
20748   // node_modules/lodash-es/_hashDelete.js
20749   function hashDelete(key) {
20750     var result = this.has(key) && delete this.__data__[key];
20751     this.size -= result ? 1 : 0;
20752     return result;
20753   }
20754   var hashDelete_default = hashDelete;
20755
20756   // node_modules/lodash-es/_hashGet.js
20757   var HASH_UNDEFINED = "__lodash_hash_undefined__";
20758   var objectProto8 = Object.prototype;
20759   var hasOwnProperty6 = objectProto8.hasOwnProperty;
20760   function hashGet(key) {
20761     var data = this.__data__;
20762     if (nativeCreate_default) {
20763       var result = data[key];
20764       return result === HASH_UNDEFINED ? void 0 : result;
20765     }
20766     return hasOwnProperty6.call(data, key) ? data[key] : void 0;
20767   }
20768   var hashGet_default = hashGet;
20769
20770   // node_modules/lodash-es/_hashHas.js
20771   var objectProto9 = Object.prototype;
20772   var hasOwnProperty7 = objectProto9.hasOwnProperty;
20773   function hashHas(key) {
20774     var data = this.__data__;
20775     return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty7.call(data, key);
20776   }
20777   var hashHas_default = hashHas;
20778
20779   // node_modules/lodash-es/_hashSet.js
20780   var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
20781   function hashSet(key, value) {
20782     var data = this.__data__;
20783     this.size += this.has(key) ? 0 : 1;
20784     data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value;
20785     return this;
20786   }
20787   var hashSet_default = hashSet;
20788
20789   // node_modules/lodash-es/_Hash.js
20790   function Hash(entries) {
20791     var index = -1, length2 = entries == null ? 0 : entries.length;
20792     this.clear();
20793     while (++index < length2) {
20794       var entry = entries[index];
20795       this.set(entry[0], entry[1]);
20796     }
20797   }
20798   Hash.prototype.clear = hashClear_default;
20799   Hash.prototype["delete"] = hashDelete_default;
20800   Hash.prototype.get = hashGet_default;
20801   Hash.prototype.has = hashHas_default;
20802   Hash.prototype.set = hashSet_default;
20803   var Hash_default = Hash;
20804
20805   // node_modules/lodash-es/_listCacheClear.js
20806   function listCacheClear() {
20807     this.__data__ = [];
20808     this.size = 0;
20809   }
20810   var listCacheClear_default = listCacheClear;
20811
20812   // node_modules/lodash-es/_assocIndexOf.js
20813   function assocIndexOf(array2, key) {
20814     var length2 = array2.length;
20815     while (length2--) {
20816       if (eq_default(array2[length2][0], key)) {
20817         return length2;
20818       }
20819     }
20820     return -1;
20821   }
20822   var assocIndexOf_default = assocIndexOf;
20823
20824   // node_modules/lodash-es/_listCacheDelete.js
20825   var arrayProto = Array.prototype;
20826   var splice = arrayProto.splice;
20827   function listCacheDelete(key) {
20828     var data = this.__data__, index = assocIndexOf_default(data, key);
20829     if (index < 0) {
20830       return false;
20831     }
20832     var lastIndex = data.length - 1;
20833     if (index == lastIndex) {
20834       data.pop();
20835     } else {
20836       splice.call(data, index, 1);
20837     }
20838     --this.size;
20839     return true;
20840   }
20841   var listCacheDelete_default = listCacheDelete;
20842
20843   // node_modules/lodash-es/_listCacheGet.js
20844   function listCacheGet(key) {
20845     var data = this.__data__, index = assocIndexOf_default(data, key);
20846     return index < 0 ? void 0 : data[index][1];
20847   }
20848   var listCacheGet_default = listCacheGet;
20849
20850   // node_modules/lodash-es/_listCacheHas.js
20851   function listCacheHas(key) {
20852     return assocIndexOf_default(this.__data__, key) > -1;
20853   }
20854   var listCacheHas_default = listCacheHas;
20855
20856   // node_modules/lodash-es/_listCacheSet.js
20857   function listCacheSet(key, value) {
20858     var data = this.__data__, index = assocIndexOf_default(data, key);
20859     if (index < 0) {
20860       ++this.size;
20861       data.push([key, value]);
20862     } else {
20863       data[index][1] = value;
20864     }
20865     return this;
20866   }
20867   var listCacheSet_default = listCacheSet;
20868
20869   // node_modules/lodash-es/_ListCache.js
20870   function ListCache(entries) {
20871     var index = -1, length2 = entries == null ? 0 : entries.length;
20872     this.clear();
20873     while (++index < length2) {
20874       var entry = entries[index];
20875       this.set(entry[0], entry[1]);
20876     }
20877   }
20878   ListCache.prototype.clear = listCacheClear_default;
20879   ListCache.prototype["delete"] = listCacheDelete_default;
20880   ListCache.prototype.get = listCacheGet_default;
20881   ListCache.prototype.has = listCacheHas_default;
20882   ListCache.prototype.set = listCacheSet_default;
20883   var ListCache_default = ListCache;
20884
20885   // node_modules/lodash-es/_Map.js
20886   var Map2 = getNative_default(root_default, "Map");
20887   var Map_default = Map2;
20888
20889   // node_modules/lodash-es/_mapCacheClear.js
20890   function mapCacheClear() {
20891     this.size = 0;
20892     this.__data__ = {
20893       "hash": new Hash_default(),
20894       "map": new (Map_default || ListCache_default)(),
20895       "string": new Hash_default()
20896     };
20897   }
20898   var mapCacheClear_default = mapCacheClear;
20899
20900   // node_modules/lodash-es/_isKeyable.js
20901   function isKeyable(value) {
20902     var type2 = typeof value;
20903     return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null;
20904   }
20905   var isKeyable_default = isKeyable;
20906
20907   // node_modules/lodash-es/_getMapData.js
20908   function getMapData(map2, key) {
20909     var data = map2.__data__;
20910     return isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
20911   }
20912   var getMapData_default = getMapData;
20913
20914   // node_modules/lodash-es/_mapCacheDelete.js
20915   function mapCacheDelete(key) {
20916     var result = getMapData_default(this, key)["delete"](key);
20917     this.size -= result ? 1 : 0;
20918     return result;
20919   }
20920   var mapCacheDelete_default = mapCacheDelete;
20921
20922   // node_modules/lodash-es/_mapCacheGet.js
20923   function mapCacheGet(key) {
20924     return getMapData_default(this, key).get(key);
20925   }
20926   var mapCacheGet_default = mapCacheGet;
20927
20928   // node_modules/lodash-es/_mapCacheHas.js
20929   function mapCacheHas(key) {
20930     return getMapData_default(this, key).has(key);
20931   }
20932   var mapCacheHas_default = mapCacheHas;
20933
20934   // node_modules/lodash-es/_mapCacheSet.js
20935   function mapCacheSet(key, value) {
20936     var data = getMapData_default(this, key), size = data.size;
20937     data.set(key, value);
20938     this.size += data.size == size ? 0 : 1;
20939     return this;
20940   }
20941   var mapCacheSet_default = mapCacheSet;
20942
20943   // node_modules/lodash-es/_MapCache.js
20944   function MapCache(entries) {
20945     var index = -1, length2 = entries == null ? 0 : entries.length;
20946     this.clear();
20947     while (++index < length2) {
20948       var entry = entries[index];
20949       this.set(entry[0], entry[1]);
20950     }
20951   }
20952   MapCache.prototype.clear = mapCacheClear_default;
20953   MapCache.prototype["delete"] = mapCacheDelete_default;
20954   MapCache.prototype.get = mapCacheGet_default;
20955   MapCache.prototype.has = mapCacheHas_default;
20956   MapCache.prototype.set = mapCacheSet_default;
20957   var MapCache_default = MapCache;
20958
20959   // node_modules/lodash-es/toString.js
20960   function toString(value) {
20961     return value == null ? "" : baseToString_default(value);
20962   }
20963   var toString_default = toString;
20964
20965   // node_modules/lodash-es/_arrayPush.js
20966   function arrayPush(array2, values) {
20967     var index = -1, length2 = values.length, offset = array2.length;
20968     while (++index < length2) {
20969       array2[offset + index] = values[index];
20970     }
20971     return array2;
20972   }
20973   var arrayPush_default = arrayPush;
20974
20975   // node_modules/lodash-es/_basePropertyOf.js
20976   function basePropertyOf(object) {
20977     return function(key) {
20978       return object == null ? void 0 : object[key];
20979     };
20980   }
20981   var basePropertyOf_default = basePropertyOf;
20982
20983   // node_modules/lodash-es/_stackClear.js
20984   function stackClear() {
20985     this.__data__ = new ListCache_default();
20986     this.size = 0;
20987   }
20988   var stackClear_default = stackClear;
20989
20990   // node_modules/lodash-es/_stackDelete.js
20991   function stackDelete(key) {
20992     var data = this.__data__, result = data["delete"](key);
20993     this.size = data.size;
20994     return result;
20995   }
20996   var stackDelete_default = stackDelete;
20997
20998   // node_modules/lodash-es/_stackGet.js
20999   function stackGet(key) {
21000     return this.__data__.get(key);
21001   }
21002   var stackGet_default = stackGet;
21003
21004   // node_modules/lodash-es/_stackHas.js
21005   function stackHas(key) {
21006     return this.__data__.has(key);
21007   }
21008   var stackHas_default = stackHas;
21009
21010   // node_modules/lodash-es/_stackSet.js
21011   var LARGE_ARRAY_SIZE = 200;
21012   function stackSet(key, value) {
21013     var data = this.__data__;
21014     if (data instanceof ListCache_default) {
21015       var pairs2 = data.__data__;
21016       if (!Map_default || pairs2.length < LARGE_ARRAY_SIZE - 1) {
21017         pairs2.push([key, value]);
21018         this.size = ++data.size;
21019         return this;
21020       }
21021       data = this.__data__ = new MapCache_default(pairs2);
21022     }
21023     data.set(key, value);
21024     this.size = data.size;
21025     return this;
21026   }
21027   var stackSet_default = stackSet;
21028
21029   // node_modules/lodash-es/_Stack.js
21030   function Stack(entries) {
21031     var data = this.__data__ = new ListCache_default(entries);
21032     this.size = data.size;
21033   }
21034   Stack.prototype.clear = stackClear_default;
21035   Stack.prototype["delete"] = stackDelete_default;
21036   Stack.prototype.get = stackGet_default;
21037   Stack.prototype.has = stackHas_default;
21038   Stack.prototype.set = stackSet_default;
21039   var Stack_default = Stack;
21040
21041   // node_modules/lodash-es/_arrayFilter.js
21042   function arrayFilter(array2, predicate) {
21043     var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
21044     while (++index < length2) {
21045       var value = array2[index];
21046       if (predicate(value, index, array2)) {
21047         result[resIndex++] = value;
21048       }
21049     }
21050     return result;
21051   }
21052   var arrayFilter_default = arrayFilter;
21053
21054   // node_modules/lodash-es/stubArray.js
21055   function stubArray() {
21056     return [];
21057   }
21058   var stubArray_default = stubArray;
21059
21060   // node_modules/lodash-es/_getSymbols.js
21061   var objectProto10 = Object.prototype;
21062   var propertyIsEnumerable2 = objectProto10.propertyIsEnumerable;
21063   var nativeGetSymbols = Object.getOwnPropertySymbols;
21064   var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
21065     if (object == null) {
21066       return [];
21067     }
21068     object = Object(object);
21069     return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
21070       return propertyIsEnumerable2.call(object, symbol);
21071     });
21072   };
21073   var getSymbols_default = getSymbols;
21074
21075   // node_modules/lodash-es/_baseGetAllKeys.js
21076   function baseGetAllKeys(object, keysFunc, symbolsFunc) {
21077     var result = keysFunc(object);
21078     return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
21079   }
21080   var baseGetAllKeys_default = baseGetAllKeys;
21081
21082   // node_modules/lodash-es/_getAllKeys.js
21083   function getAllKeys(object) {
21084     return baseGetAllKeys_default(object, keys_default, getSymbols_default);
21085   }
21086   var getAllKeys_default = getAllKeys;
21087
21088   // node_modules/lodash-es/_DataView.js
21089   var DataView2 = getNative_default(root_default, "DataView");
21090   var DataView_default = DataView2;
21091
21092   // node_modules/lodash-es/_Promise.js
21093   var Promise2 = getNative_default(root_default, "Promise");
21094   var Promise_default = Promise2;
21095
21096   // node_modules/lodash-es/_Set.js
21097   var Set2 = getNative_default(root_default, "Set");
21098   var Set_default = Set2;
21099
21100   // node_modules/lodash-es/_getTag.js
21101   var mapTag2 = "[object Map]";
21102   var objectTag2 = "[object Object]";
21103   var promiseTag = "[object Promise]";
21104   var setTag2 = "[object Set]";
21105   var weakMapTag2 = "[object WeakMap]";
21106   var dataViewTag2 = "[object DataView]";
21107   var dataViewCtorString = toSource_default(DataView_default);
21108   var mapCtorString = toSource_default(Map_default);
21109   var promiseCtorString = toSource_default(Promise_default);
21110   var setCtorString = toSource_default(Set_default);
21111   var weakMapCtorString = toSource_default(WeakMap_default);
21112   var getTag = baseGetTag_default;
21113   if (DataView_default && getTag(new DataView_default(new ArrayBuffer(1))) != dataViewTag2 || Map_default && getTag(new Map_default()) != mapTag2 || Promise_default && getTag(Promise_default.resolve()) != promiseTag || Set_default && getTag(new Set_default()) != setTag2 || WeakMap_default && getTag(new WeakMap_default()) != weakMapTag2) {
21114     getTag = function(value) {
21115       var result = baseGetTag_default(value), Ctor = result == objectTag2 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
21116       if (ctorString) {
21117         switch (ctorString) {
21118           case dataViewCtorString:
21119             return dataViewTag2;
21120           case mapCtorString:
21121             return mapTag2;
21122           case promiseCtorString:
21123             return promiseTag;
21124           case setCtorString:
21125             return setTag2;
21126           case weakMapCtorString:
21127             return weakMapTag2;
21128         }
21129       }
21130       return result;
21131     };
21132   }
21133   var getTag_default = getTag;
21134
21135   // node_modules/lodash-es/_Uint8Array.js
21136   var Uint8Array2 = root_default.Uint8Array;
21137   var Uint8Array_default = Uint8Array2;
21138
21139   // node_modules/lodash-es/_setCacheAdd.js
21140   var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
21141   function setCacheAdd(value) {
21142     this.__data__.set(value, HASH_UNDEFINED3);
21143     return this;
21144   }
21145   var setCacheAdd_default = setCacheAdd;
21146
21147   // node_modules/lodash-es/_setCacheHas.js
21148   function setCacheHas(value) {
21149     return this.__data__.has(value);
21150   }
21151   var setCacheHas_default = setCacheHas;
21152
21153   // node_modules/lodash-es/_SetCache.js
21154   function SetCache(values) {
21155     var index = -1, length2 = values == null ? 0 : values.length;
21156     this.__data__ = new MapCache_default();
21157     while (++index < length2) {
21158       this.add(values[index]);
21159     }
21160   }
21161   SetCache.prototype.add = SetCache.prototype.push = setCacheAdd_default;
21162   SetCache.prototype.has = setCacheHas_default;
21163   var SetCache_default = SetCache;
21164
21165   // node_modules/lodash-es/_arraySome.js
21166   function arraySome(array2, predicate) {
21167     var index = -1, length2 = array2 == null ? 0 : array2.length;
21168     while (++index < length2) {
21169       if (predicate(array2[index], index, array2)) {
21170         return true;
21171       }
21172     }
21173     return false;
21174   }
21175   var arraySome_default = arraySome;
21176
21177   // node_modules/lodash-es/_cacheHas.js
21178   function cacheHas(cache, key) {
21179     return cache.has(key);
21180   }
21181   var cacheHas_default = cacheHas;
21182
21183   // node_modules/lodash-es/_equalArrays.js
21184   var COMPARE_PARTIAL_FLAG = 1;
21185   var COMPARE_UNORDERED_FLAG = 2;
21186   function equalArrays(array2, other2, bitmask, customizer, equalFunc, stack) {
21187     var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array2.length, othLength = other2.length;
21188     if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
21189       return false;
21190     }
21191     var arrStacked = stack.get(array2);
21192     var othStacked = stack.get(other2);
21193     if (arrStacked && othStacked) {
21194       return arrStacked == other2 && othStacked == array2;
21195     }
21196     var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache_default() : void 0;
21197     stack.set(array2, other2);
21198     stack.set(other2, array2);
21199     while (++index < arrLength) {
21200       var arrValue = array2[index], othValue = other2[index];
21201       if (customizer) {
21202         var compared = isPartial ? customizer(othValue, arrValue, index, other2, array2, stack) : customizer(arrValue, othValue, index, array2, other2, stack);
21203       }
21204       if (compared !== void 0) {
21205         if (compared) {
21206           continue;
21207         }
21208         result = false;
21209         break;
21210       }
21211       if (seen) {
21212         if (!arraySome_default(other2, function(othValue2, othIndex) {
21213           if (!cacheHas_default(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
21214             return seen.push(othIndex);
21215           }
21216         })) {
21217           result = false;
21218           break;
21219         }
21220       } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
21221         result = false;
21222         break;
21223       }
21224     }
21225     stack["delete"](array2);
21226     stack["delete"](other2);
21227     return result;
21228   }
21229   var equalArrays_default = equalArrays;
21230
21231   // node_modules/lodash-es/_mapToArray.js
21232   function mapToArray(map2) {
21233     var index = -1, result = Array(map2.size);
21234     map2.forEach(function(value, key) {
21235       result[++index] = [key, value];
21236     });
21237     return result;
21238   }
21239   var mapToArray_default = mapToArray;
21240
21241   // node_modules/lodash-es/_setToArray.js
21242   function setToArray(set4) {
21243     var index = -1, result = Array(set4.size);
21244     set4.forEach(function(value) {
21245       result[++index] = value;
21246     });
21247     return result;
21248   }
21249   var setToArray_default = setToArray;
21250
21251   // node_modules/lodash-es/_equalByTag.js
21252   var COMPARE_PARTIAL_FLAG2 = 1;
21253   var COMPARE_UNORDERED_FLAG2 = 2;
21254   var boolTag2 = "[object Boolean]";
21255   var dateTag2 = "[object Date]";
21256   var errorTag2 = "[object Error]";
21257   var mapTag3 = "[object Map]";
21258   var numberTag2 = "[object Number]";
21259   var regexpTag2 = "[object RegExp]";
21260   var setTag3 = "[object Set]";
21261   var stringTag2 = "[object String]";
21262   var symbolTag2 = "[object Symbol]";
21263   var arrayBufferTag2 = "[object ArrayBuffer]";
21264   var dataViewTag3 = "[object DataView]";
21265   var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
21266   var symbolValueOf = symbolProto2 ? symbolProto2.valueOf : void 0;
21267   function equalByTag(object, other2, tag2, bitmask, customizer, equalFunc, stack) {
21268     switch (tag2) {
21269       case dataViewTag3:
21270         if (object.byteLength != other2.byteLength || object.byteOffset != other2.byteOffset) {
21271           return false;
21272         }
21273         object = object.buffer;
21274         other2 = other2.buffer;
21275       case arrayBufferTag2:
21276         if (object.byteLength != other2.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other2))) {
21277           return false;
21278         }
21279         return true;
21280       case boolTag2:
21281       case dateTag2:
21282       case numberTag2:
21283         return eq_default(+object, +other2);
21284       case errorTag2:
21285         return object.name == other2.name && object.message == other2.message;
21286       case regexpTag2:
21287       case stringTag2:
21288         return object == other2 + "";
21289       case mapTag3:
21290         var convert = mapToArray_default;
21291       case setTag3:
21292         var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
21293         convert || (convert = setToArray_default);
21294         if (object.size != other2.size && !isPartial) {
21295           return false;
21296         }
21297         var stacked = stack.get(object);
21298         if (stacked) {
21299           return stacked == other2;
21300         }
21301         bitmask |= COMPARE_UNORDERED_FLAG2;
21302         stack.set(object, other2);
21303         var result = equalArrays_default(convert(object), convert(other2), bitmask, customizer, equalFunc, stack);
21304         stack["delete"](object);
21305         return result;
21306       case symbolTag2:
21307         if (symbolValueOf) {
21308           return symbolValueOf.call(object) == symbolValueOf.call(other2);
21309         }
21310     }
21311     return false;
21312   }
21313   var equalByTag_default = equalByTag;
21314
21315   // node_modules/lodash-es/_equalObjects.js
21316   var COMPARE_PARTIAL_FLAG3 = 1;
21317   var objectProto11 = Object.prototype;
21318   var hasOwnProperty8 = objectProto11.hasOwnProperty;
21319   function equalObjects(object, other2, bitmask, customizer, equalFunc, stack) {
21320     var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other2), othLength = othProps.length;
21321     if (objLength != othLength && !isPartial) {
21322       return false;
21323     }
21324     var index = objLength;
21325     while (index--) {
21326       var key = objProps[index];
21327       if (!(isPartial ? key in other2 : hasOwnProperty8.call(other2, key))) {
21328         return false;
21329       }
21330     }
21331     var objStacked = stack.get(object);
21332     var othStacked = stack.get(other2);
21333     if (objStacked && othStacked) {
21334       return objStacked == other2 && othStacked == object;
21335     }
21336     var result = true;
21337     stack.set(object, other2);
21338     stack.set(other2, object);
21339     var skipCtor = isPartial;
21340     while (++index < objLength) {
21341       key = objProps[index];
21342       var objValue = object[key], othValue = other2[key];
21343       if (customizer) {
21344         var compared = isPartial ? customizer(othValue, objValue, key, other2, object, stack) : customizer(objValue, othValue, key, object, other2, stack);
21345       }
21346       if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
21347         result = false;
21348         break;
21349       }
21350       skipCtor || (skipCtor = key == "constructor");
21351     }
21352     if (result && !skipCtor) {
21353       var objCtor = object.constructor, othCtor = other2.constructor;
21354       if (objCtor != othCtor && ("constructor" in object && "constructor" in other2) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
21355         result = false;
21356       }
21357     }
21358     stack["delete"](object);
21359     stack["delete"](other2);
21360     return result;
21361   }
21362   var equalObjects_default = equalObjects;
21363
21364   // node_modules/lodash-es/_baseIsEqualDeep.js
21365   var COMPARE_PARTIAL_FLAG4 = 1;
21366   var argsTag3 = "[object Arguments]";
21367   var arrayTag2 = "[object Array]";
21368   var objectTag3 = "[object Object]";
21369   var objectProto12 = Object.prototype;
21370   var hasOwnProperty9 = objectProto12.hasOwnProperty;
21371   function baseIsEqualDeep(object, other2, bitmask, customizer, equalFunc, stack) {
21372     var objIsArr = isArray_default(object), othIsArr = isArray_default(other2), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other2);
21373     objTag = objTag == argsTag3 ? objectTag3 : objTag;
21374     othTag = othTag == argsTag3 ? objectTag3 : othTag;
21375     var objIsObj = objTag == objectTag3, othIsObj = othTag == objectTag3, isSameTag = objTag == othTag;
21376     if (isSameTag && isBuffer_default(object)) {
21377       if (!isBuffer_default(other2)) {
21378         return false;
21379       }
21380       objIsArr = true;
21381       objIsObj = false;
21382     }
21383     if (isSameTag && !objIsObj) {
21384       stack || (stack = new Stack_default());
21385       return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other2, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other2, objTag, bitmask, customizer, equalFunc, stack);
21386     }
21387     if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
21388       var objIsWrapped = objIsObj && hasOwnProperty9.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty9.call(other2, "__wrapped__");
21389       if (objIsWrapped || othIsWrapped) {
21390         var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other2.value() : other2;
21391         stack || (stack = new Stack_default());
21392         return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
21393       }
21394     }
21395     if (!isSameTag) {
21396       return false;
21397     }
21398     stack || (stack = new Stack_default());
21399     return equalObjects_default(object, other2, bitmask, customizer, equalFunc, stack);
21400   }
21401   var baseIsEqualDeep_default = baseIsEqualDeep;
21402
21403   // node_modules/lodash-es/_baseIsEqual.js
21404   function baseIsEqual(value, other2, bitmask, customizer, stack) {
21405     if (value === other2) {
21406       return true;
21407     }
21408     if (value == null || other2 == null || !isObjectLike_default(value) && !isObjectLike_default(other2)) {
21409       return value !== value && other2 !== other2;
21410     }
21411     return baseIsEqualDeep_default(value, other2, bitmask, customizer, baseIsEqual, stack);
21412   }
21413   var baseIsEqual_default = baseIsEqual;
21414
21415   // node_modules/lodash-es/now.js
21416   var now2 = function() {
21417     return root_default.Date.now();
21418   };
21419   var now_default = now2;
21420
21421   // node_modules/lodash-es/debounce.js
21422   var FUNC_ERROR_TEXT = "Expected a function";
21423   var nativeMax = Math.max;
21424   var nativeMin = Math.min;
21425   function debounce(func, wait, options2) {
21426     var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
21427     if (typeof func != "function") {
21428       throw new TypeError(FUNC_ERROR_TEXT);
21429     }
21430     wait = toNumber_default(wait) || 0;
21431     if (isObject_default(options2)) {
21432       leading = !!options2.leading;
21433       maxing = "maxWait" in options2;
21434       maxWait = maxing ? nativeMax(toNumber_default(options2.maxWait) || 0, wait) : maxWait;
21435       trailing = "trailing" in options2 ? !!options2.trailing : trailing;
21436     }
21437     function invokeFunc(time) {
21438       var args = lastArgs, thisArg = lastThis;
21439       lastArgs = lastThis = void 0;
21440       lastInvokeTime = time;
21441       result = func.apply(thisArg, args);
21442       return result;
21443     }
21444     function leadingEdge(time) {
21445       lastInvokeTime = time;
21446       timerId = setTimeout(timerExpired, wait);
21447       return leading ? invokeFunc(time) : result;
21448     }
21449     function remainingWait(time) {
21450       var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
21451       return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
21452     }
21453     function shouldInvoke(time) {
21454       var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
21455       return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
21456     }
21457     function timerExpired() {
21458       var time = now_default();
21459       if (shouldInvoke(time)) {
21460         return trailingEdge(time);
21461       }
21462       timerId = setTimeout(timerExpired, remainingWait(time));
21463     }
21464     function trailingEdge(time) {
21465       timerId = void 0;
21466       if (trailing && lastArgs) {
21467         return invokeFunc(time);
21468       }
21469       lastArgs = lastThis = void 0;
21470       return result;
21471     }
21472     function cancel() {
21473       if (timerId !== void 0) {
21474         clearTimeout(timerId);
21475       }
21476       lastInvokeTime = 0;
21477       lastArgs = lastCallTime = lastThis = timerId = void 0;
21478     }
21479     function flush() {
21480       return timerId === void 0 ? result : trailingEdge(now_default());
21481     }
21482     function debounced() {
21483       var time = now_default(), isInvoking = shouldInvoke(time);
21484       lastArgs = arguments;
21485       lastThis = this;
21486       lastCallTime = time;
21487       if (isInvoking) {
21488         if (timerId === void 0) {
21489           return leadingEdge(lastCallTime);
21490         }
21491         if (maxing) {
21492           clearTimeout(timerId);
21493           timerId = setTimeout(timerExpired, wait);
21494           return invokeFunc(lastCallTime);
21495         }
21496       }
21497       if (timerId === void 0) {
21498         timerId = setTimeout(timerExpired, wait);
21499       }
21500       return result;
21501     }
21502     debounced.cancel = cancel;
21503     debounced.flush = flush;
21504     return debounced;
21505   }
21506   var debounce_default = debounce;
21507
21508   // node_modules/lodash-es/_escapeHtmlChar.js
21509   var htmlEscapes = {
21510     "&": "&amp;",
21511     "<": "&lt;",
21512     ">": "&gt;",
21513     '"': "&quot;",
21514     "'": "&#39;"
21515   };
21516   var escapeHtmlChar = basePropertyOf_default(htmlEscapes);
21517   var escapeHtmlChar_default = escapeHtmlChar;
21518
21519   // node_modules/lodash-es/escape.js
21520   var reUnescapedHtml = /[&<>"']/g;
21521   var reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
21522   function escape2(string) {
21523     string = toString_default(string);
21524     return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar_default) : string;
21525   }
21526   var escape_default = escape2;
21527
21528   // node_modules/lodash-es/isEqual.js
21529   function isEqual(value, other2) {
21530     return baseIsEqual_default(value, other2);
21531   }
21532   var isEqual_default = isEqual;
21533
21534   // node_modules/lodash-es/isNumber.js
21535   var numberTag3 = "[object Number]";
21536   function isNumber(value) {
21537     return typeof value == "number" || isObjectLike_default(value) && baseGetTag_default(value) == numberTag3;
21538   }
21539   var isNumber_default = isNumber;
21540
21541   // node_modules/lodash-es/throttle.js
21542   var FUNC_ERROR_TEXT2 = "Expected a function";
21543   function throttle(func, wait, options2) {
21544     var leading = true, trailing = true;
21545     if (typeof func != "function") {
21546       throw new TypeError(FUNC_ERROR_TEXT2);
21547     }
21548     if (isObject_default(options2)) {
21549       leading = "leading" in options2 ? !!options2.leading : leading;
21550       trailing = "trailing" in options2 ? !!options2.trailing : trailing;
21551     }
21552     return debounce_default(func, wait, {
21553       "leading": leading,
21554       "maxWait": wait,
21555       "trailing": trailing
21556     });
21557   }
21558   var throttle_default = throttle;
21559
21560   // node_modules/lodash-es/_unescapeHtmlChar.js
21561   var htmlUnescapes = {
21562     "&amp;": "&",
21563     "&lt;": "<",
21564     "&gt;": ">",
21565     "&quot;": '"',
21566     "&#39;": "'"
21567   };
21568   var unescapeHtmlChar = basePropertyOf_default(htmlUnescapes);
21569   var unescapeHtmlChar_default = unescapeHtmlChar;
21570
21571   // node_modules/lodash-es/unescape.js
21572   var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g;
21573   var reHasEscapedHtml = RegExp(reEscapedHtml.source);
21574   function unescape(string) {
21575     string = toString_default(string);
21576     return string && reHasEscapedHtml.test(string) ? string.replace(reEscapedHtml, unescapeHtmlChar_default) : string;
21577   }
21578   var unescape_default = unescape;
21579
21580   // modules/core/file_fetcher.js
21581   var import_vparse = __toESM(require_vparse());
21582
21583   // config/id.js
21584   var presetsCdnUrl = "https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@{presets_version}/";
21585   var ociCdnUrl = "https://cdn.jsdelivr.net/npm/osm-community-index@{version}/";
21586   var wmfSitematrixCdnUrl = "https://cdn.jsdelivr.net/npm/wmf-sitematrix@{version}/";
21587   var nsiCdnUrl = "https://cdn.jsdelivr.net/npm/name-suggestion-index@{version}/";
21588   var defaultOsmApiConnections = {
21589     live: {
21590       url: "https://www.openstreetmap.org",
21591       apiUrl: "https://api.openstreetmap.org",
21592       client_id: "0tmNTmd0Jo1dQp4AUmMBLtGiD9YpMuXzHefitcuVStc"
21593     },
21594     dev: {
21595       url: "https://api06.dev.openstreetmap.org",
21596       client_id: "Ee1wWJ6UlpERbF6BfTNOpwn0R8k_06mvMXdDUkeHMgw"
21597     }
21598   };
21599   var osmApiConnections = [];
21600   if (false) {
21601     osmApiConnections.push({
21602       url: null,
21603       apiUrl: null,
21604       client_id: null
21605     });
21606   } else if (false) {
21607     osmApiConnections.push(defaultOsmApiConnections[null]);
21608   } else {
21609     osmApiConnections.push(defaultOsmApiConnections.live);
21610     osmApiConnections.push(defaultOsmApiConnections.dev);
21611   }
21612   var taginfoApiUrl = "https://taginfo.openstreetmap.org/api/4/";
21613   var nominatimApiUrl = "https://nominatim.openstreetmap.org/";
21614   var showDonationMessage = true;
21615
21616   // package.json
21617   var package_default = {
21618     name: "iD",
21619     version: "2.31.0",
21620     description: "A friendly editor for OpenStreetMap",
21621     main: "dist/iD.min.js",
21622     repository: "github:openstreetmap/iD",
21623     homepage: "https://github.com/openstreetmap/iD",
21624     bugs: "https://github.com/openstreetmap/iD/issues",
21625     keywords: [
21626       "editor",
21627       "openstreetmap"
21628     ],
21629     license: "ISC",
21630     scripts: {
21631       all: "run-s clean build dist",
21632       build: "run-s build:css build:data build:js",
21633       "build:css": "node scripts/build_css.js",
21634       "build:data": "shx mkdir -p dist/data && node scripts/build_data.js",
21635       "build:stats": "node config/esbuild.config.mjs --stats && esbuild-visualizer --metadata dist/esbuild.json --exclude *.png --filename docs/statistics.html && shx rm dist/esbuild.json",
21636       "build:js": "node config/esbuild.config.mjs",
21637       "build:js:watch": "node config/esbuild.config.mjs --watch",
21638       clean: "shx rm -f dist/esbuild.json dist/*.js dist/*.map dist/*.css dist/img/*.svg",
21639       dist: "run-p dist:**",
21640       "dist:mapillary": "shx mkdir -p dist/mapillary-js && shx cp -R node_modules/mapillary-js/dist/* dist/mapillary-js/",
21641       "dist:pannellum": "shx mkdir -p dist/pannellum && shx cp -R node_modules/pannellum/build/* dist/pannellum/",
21642       "dist:min": "node config/esbuild.config.min.mjs",
21643       "dist:svg:iD": 'svg-sprite --symbol --symbol-dest . --shape-id-generator "iD-%s" --symbol-sprite dist/img/iD-sprite.svg "svg/iD-sprite/**/*.svg"',
21644       "dist:svg:community": 'svg-sprite --symbol --symbol-dest . --shape-id-generator "community-%s" --symbol-sprite dist/img/community-sprite.svg node_modules/osm-community-index/dist/img/*.svg',
21645       "dist:svg:fa": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/fa-sprite.svg svg/fontawesome/*.svg",
21646       "dist:svg:maki": 'svg-sprite --symbol --symbol-dest . --shape-id-generator "maki-%s" --symbol-sprite dist/img/maki-sprite.svg node_modules/@mapbox/maki/icons/*.svg',
21647       "dist:svg:mapillary:signs": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/mapillary-sprite.svg node_modules/@rapideditor/mapillary_sprite_source/package_signs/*.svg",
21648       "dist:svg:mapillary:objects": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/mapillary-object-sprite.svg node_modules/@rapideditor/mapillary_sprite_source/package_objects/*.svg",
21649       "dist:svg:roentgen": 'svg-sprite --shape-id-generator "roentgen-%s" --shape-dim-width 16 --shape-dim-height 16 --symbol --symbol-dest . --symbol-sprite dist/img/roentgen-sprite.svg svg/roentgen/*.svg',
21650       "dist:svg:temaki": 'svg-sprite --symbol --symbol-dest . --shape-id-generator "temaki-%s" --symbol-sprite dist/img/temaki-sprite.svg node_modules/@rapideditor/temaki/icons/*.svg',
21651       imagery: "node scripts/update_imagery.js",
21652       lint: "eslint config scripts test/spec modules",
21653       "lint:fix": "eslint scripts test/spec modules --fix",
21654       start: "run-s start:watch",
21655       "start:single-build": "run-p build:js start:server",
21656       "start:watch": "run-p build:js:watch start:server",
21657       "start:server": "node scripts/server.js",
21658       test: "npm-run-all -s lint build test:spec",
21659       "test:spec": "vitest --no-isolate",
21660       translations: "node scripts/update_locales.js"
21661     },
21662     dependencies: {
21663       "@mapbox/geojson-area": "^0.2.2",
21664       "@mapbox/sexagesimal": "1.2.0",
21665       "@mapbox/vector-tile": "^2.0.3",
21666       "@rapideditor/country-coder": "~5.3.1",
21667       "@rapideditor/location-conflation": "~1.4.1",
21668       "@tmcw/togeojson": "^6.0.1",
21669       "@turf/bbox": "^7.2.0",
21670       "@turf/bbox-clip": "^7.2.0",
21671       "abortcontroller-polyfill": "^1.7.8",
21672       "aes-js": "^3.1.2",
21673       "alif-toolkit": "^1.3.0",
21674       "core-js-bundle": "^3.40.0",
21675       diacritics: "1.3.0",
21676       exifr: "^7.1.3",
21677       "fast-deep-equal": "~3.1.1",
21678       "fast-json-stable-stringify": "2.1.0",
21679       "lodash-es": "~4.17.15",
21680       marked: "~15.0.6",
21681       "node-diff3": "~3.1.0",
21682       "osm-auth": "~2.6.0",
21683       pannellum: "2.5.6",
21684       pbf: "^4.0.1",
21685       "polygon-clipping": "~0.15.7",
21686       rbush: "4.0.1",
21687       vitest: "^3.0.5",
21688       "whatwg-fetch": "^3.6.20",
21689       "which-polygon": "2.2.1"
21690     },
21691     devDependencies: {
21692       "@fortawesome/fontawesome-svg-core": "~6.7.2",
21693       "@fortawesome/free-brands-svg-icons": "~6.7.2",
21694       "@fortawesome/free-regular-svg-icons": "~6.7.2",
21695       "@fortawesome/free-solid-svg-icons": "~6.7.2",
21696       "@mapbox/maki": "^8.0.1",
21697       "@openstreetmap/id-tagging-schema": "^6.8.1",
21698       "@rapideditor/mapillary_sprite_source": "^1.8.0",
21699       "@rapideditor/temaki": "^5.9.0",
21700       "@transifex/api": "^7.1.3",
21701       "@types/chai": "^5.0.1",
21702       "@types/d3": "^7.4.3",
21703       "@types/happen": "^0.3.0",
21704       "@types/sinon": "^17.0.3",
21705       "@types/sinon-chai": "^4.0.0",
21706       autoprefixer: "^10.4.20",
21707       browserslist: "^4.24.4",
21708       "browserslist-to-esbuild": "^2.1.1",
21709       chai: "^5.1.2",
21710       chalk: "^4.1.2",
21711       "cldr-core": "^46.0.0",
21712       "cldr-localenames-full": "^46.1.0",
21713       "concat-files": "^0.1.1",
21714       d3: "~7.9.0",
21715       dotenv: "^16.4.7",
21716       "editor-layer-index": "github:osmlab/editor-layer-index#gh-pages",
21717       esbuild: "^0.24.2",
21718       "esbuild-visualizer": "^0.7.0",
21719       eslint: "^9.19.0",
21720       "fetch-mock": "^11.1.1",
21721       gaze: "^1.1.3",
21722       glob: "^10.4.5",
21723       happen: "^0.3.2",
21724       "js-yaml": "^4.0.0",
21725       jsdom: "^26.0.0",
21726       "json-stringify-pretty-compact": "^3.0.0",
21727       "mapillary-js": "4.1.2",
21728       minimist: "^1.2.8",
21729       "name-suggestion-index": "~6.0",
21730       "npm-run-all": "^4.0.0",
21731       "osm-community-index": "~5.9.1",
21732       postcss: "^8.5.1",
21733       "postcss-selector-prepend": "^0.5.0",
21734       shelljs: "^0.8.0",
21735       shx: "^0.3.0",
21736       sinon: "^11.1.2",
21737       "sinon-chai": "^4.0.0",
21738       smash: "0.0",
21739       "static-server": "^2.2.1",
21740       "svg-sprite": "2.0.4",
21741       vparse: "~1.1.0"
21742     },
21743     engines: {
21744       node: ">=18"
21745     },
21746     browserslist: [
21747       "> 0.3%, last 6 major versions, not dead, Firefox ESR, maintained node versions"
21748     ]
21749   };
21750
21751   // modules/core/file_fetcher.js
21752   var _mainFileFetcher = coreFileFetcher();
21753   function coreFileFetcher() {
21754     const ociVersion = package_default.dependencies["osm-community-index"] || package_default.devDependencies["osm-community-index"];
21755     const v2 = (0, import_vparse.default)(ociVersion);
21756     const ociVersionMinor = "".concat(v2.major, ".").concat(v2.minor);
21757     const presetsVersion = package_default.devDependencies["@openstreetmap/id-tagging-schema"];
21758     let _this = {};
21759     let _inflight4 = {};
21760     let _fileMap = {
21761       "address_formats": "data/address_formats.min.json",
21762       "imagery": "data/imagery.min.json",
21763       "intro_graph": "data/intro_graph.min.json",
21764       "keepRight": "data/keepRight.min.json",
21765       "languages": "data/languages.min.json",
21766       "locales": "locales/index.min.json",
21767       "phone_formats": "data/phone_formats.min.json",
21768       "qa_data": "data/qa_data.min.json",
21769       "shortcuts": "data/shortcuts.min.json",
21770       "territory_languages": "data/territory_languages.min.json",
21771       "oci_defaults": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/defaults.min.json",
21772       "oci_features": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/featureCollection.min.json",
21773       "oci_resources": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/resources.min.json",
21774       "presets_package": presetsCdnUrl.replace("{presets_version}", presetsVersion) + "package.json",
21775       "deprecated": presetsCdnUrl + "dist/deprecated.min.json",
21776       "discarded": presetsCdnUrl + "dist/discarded.min.json",
21777       "preset_categories": presetsCdnUrl + "dist/preset_categories.min.json",
21778       "preset_defaults": presetsCdnUrl + "dist/preset_defaults.min.json",
21779       "preset_fields": presetsCdnUrl + "dist/fields.min.json",
21780       "preset_presets": presetsCdnUrl + "dist/presets.min.json",
21781       "wmf_sitematrix": wmfSitematrixCdnUrl.replace("{version}", "0.2") + "data/wikipedia.min.json"
21782     };
21783     let _cachedData = {};
21784     _this.cache = () => _cachedData;
21785     _this.get = (which) => {
21786       if (_cachedData[which]) {
21787         return Promise.resolve(_cachedData[which]);
21788       }
21789       const file = _fileMap[which];
21790       const url = file && _this.asset(file);
21791       if (!url) {
21792         return Promise.reject('Unknown data file for "'.concat(which, '"'));
21793       }
21794       if (url.includes("{presets_version}")) {
21795         return _this.get("presets_package").then((result) => {
21796           const presetsVersion2 = result.version;
21797           return getUrl(url.replace("{presets_version}", presetsVersion2), which);
21798         });
21799       } else {
21800         return getUrl(url, which);
21801       }
21802     };
21803     function getUrl(url, which) {
21804       let prom = _inflight4[url];
21805       if (!prom) {
21806         _inflight4[url] = prom = (window.VITEST ? import("../".concat(url)) : fetch(url)).then((response) => {
21807           if (window.VITEST) return response.default;
21808           if (!response.ok || !response.json) {
21809             throw new Error(response.status + " " + response.statusText);
21810           }
21811           if (response.status === 204 || response.status === 205) return;
21812           return response.json();
21813         }).then((result) => {
21814           delete _inflight4[url];
21815           if (!result) {
21816             throw new Error('No data loaded for "'.concat(which, '"'));
21817           }
21818           _cachedData[which] = result;
21819           return result;
21820         }).catch((err) => {
21821           delete _inflight4[url];
21822           throw err;
21823         });
21824       }
21825       return prom;
21826     }
21827     _this.fileMap = function(val) {
21828       if (!arguments.length) return _fileMap;
21829       _fileMap = val;
21830       return _this;
21831     };
21832     let _assetPath = "";
21833     _this.assetPath = function(val) {
21834       if (!arguments.length) return _assetPath;
21835       _assetPath = val;
21836       return _this;
21837     };
21838     let _assetMap = {};
21839     _this.assetMap = function(val) {
21840       if (!arguments.length) return _assetMap;
21841       _assetMap = val;
21842       return _this;
21843     };
21844     _this.asset = (val) => {
21845       if (/^http(s)?:\/\//i.test(val)) return val;
21846       const filename = _assetPath + val;
21847       return _assetMap[filename] || filename;
21848     };
21849     return _this;
21850   }
21851
21852   // modules/util/detect.js
21853   var _detected;
21854   function utilDetect(refresh2) {
21855     if (_detected && !refresh2) return _detected;
21856     _detected = {};
21857     const ua = navigator.userAgent;
21858     let m2 = null;
21859     m2 = ua.match(/(edge)\/?\s*(\.?\d+(\.\d+)*)/i);
21860     if (m2 !== null) {
21861       _detected.browser = m2[1];
21862       _detected.version = m2[2];
21863     }
21864     if (!_detected.browser) {
21865       m2 = ua.match(/Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/i);
21866       if (m2 !== null) {
21867         _detected.browser = "msie";
21868         _detected.version = m2[1];
21869       }
21870     }
21871     if (!_detected.browser) {
21872       m2 = ua.match(/(opr)\/?\s*(\.?\d+(\.\d+)*)/i);
21873       if (m2 !== null) {
21874         _detected.browser = "Opera";
21875         _detected.version = m2[2];
21876       }
21877     }
21878     if (!_detected.browser) {
21879       m2 = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
21880       if (m2 !== null) {
21881         _detected.browser = m2[1];
21882         _detected.version = m2[2];
21883         m2 = ua.match(/version\/([\.\d]+)/i);
21884         if (m2 !== null) _detected.version = m2[1];
21885       }
21886     }
21887     if (!_detected.browser) {
21888       _detected.browser = navigator.appName;
21889       _detected.version = navigator.appVersion;
21890     }
21891     _detected.version = _detected.version.split(/\W/).slice(0, 2).join(".");
21892     _detected.opera = _detected.browser.toLowerCase() === "opera" && Number(_detected.version) < 15;
21893     if (_detected.browser.toLowerCase() === "msie") {
21894       _detected.ie = true;
21895       _detected.browser = "Internet Explorer";
21896       _detected.support = false;
21897     } else {
21898       _detected.ie = false;
21899       _detected.support = true;
21900     }
21901     _detected.filedrop = window.FileReader && "ondrop" in window;
21902     if (/Win/.test(ua)) {
21903       _detected.os = "win";
21904       _detected.platform = "Windows";
21905     } else if (/Mac/.test(ua)) {
21906       _detected.os = "mac";
21907       _detected.platform = "Macintosh";
21908     } else if (/X11/.test(ua) || /Linux/.test(ua)) {
21909       _detected.os = "linux";
21910       _detected.platform = "Linux";
21911     } else {
21912       _detected.os = "win";
21913       _detected.platform = "Unknown";
21914     }
21915     _detected.isMobileWebKit = (/\b(iPad|iPhone|iPod)\b/.test(ua) || // HACK: iPadOS 13+ requests desktop sites by default by using a Mac user agent,
21916     // so assume any "mac" with multitouch is actually iOS
21917     navigator.platform === "MacIntel" && "maxTouchPoints" in navigator && navigator.maxTouchPoints > 1) && /WebKit/.test(ua) && !/Edge/.test(ua) && !window.MSStream;
21918     _detected.browserLocales = Array.from(new Set(
21919       // remove duplicates
21920       [navigator.language].concat(navigator.languages || []).concat([
21921         // old property for backwards compatibility
21922         navigator.userLanguage
21923       ]).filter(Boolean)
21924     ));
21925     const loc = window.top.location;
21926     let origin = loc.origin;
21927     if (!origin) {
21928       origin = loc.protocol + "//" + loc.hostname + (loc.port ? ":" + loc.port : "");
21929     }
21930     _detected.host = origin + loc.pathname;
21931     return _detected;
21932   }
21933
21934   // modules/util/aes.js
21935   var import_aes_js = __toESM(require_aes_js());
21936   var DEFAULT_128 = [250, 157, 60, 79, 142, 134, 229, 129, 138, 126, 210, 129, 29, 71, 160, 208];
21937   function utilAesEncrypt(text, key) {
21938     key = key || DEFAULT_128;
21939     const textBytes = import_aes_js.default.utils.utf8.toBytes(text);
21940     const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key);
21941     const encryptedBytes = aesCtr.encrypt(textBytes);
21942     const encryptedHex = import_aes_js.default.utils.hex.fromBytes(encryptedBytes);
21943     return encryptedHex;
21944   }
21945   function utilAesDecrypt(encryptedHex, key) {
21946     key = key || DEFAULT_128;
21947     const encryptedBytes = import_aes_js.default.utils.hex.toBytes(encryptedHex);
21948     const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key);
21949     const decryptedBytes = aesCtr.decrypt(encryptedBytes);
21950     const text = import_aes_js.default.utils.utf8.fromBytes(decryptedBytes);
21951     return text;
21952   }
21953
21954   // modules/util/clean_tags.js
21955   function utilCleanTags(tags) {
21956     var out = {};
21957     for (var k2 in tags) {
21958       if (!k2) continue;
21959       var v2 = tags[k2];
21960       if (v2 !== void 0) {
21961         out[k2] = cleanValue(k2, v2);
21962       }
21963     }
21964     return out;
21965     function cleanValue(k3, v3) {
21966       function keepSpaces(k4) {
21967         return /_hours|_times|:conditional$/.test(k4);
21968       }
21969       function skip(k4) {
21970         return /^(description|note|fixme|inscription)$/.test(k4);
21971       }
21972       if (skip(k3)) return v3;
21973       var cleaned = v3.split(";").map(function(s2) {
21974         return s2.trim();
21975       }).join(keepSpaces(k3) ? "; " : ";");
21976       if (k3.indexOf("website") !== -1 || k3.indexOf("email") !== -1 || cleaned.indexOf("http") === 0) {
21977         cleaned = cleaned.replace(/[\u200B-\u200F\uFEFF]/g, "");
21978       }
21979       return cleaned;
21980     }
21981   }
21982
21983   // modules/util/get_set_value.js
21984   function utilGetSetValue(selection2, value, shouldUpdate) {
21985     function setValue(value2, shouldUpdate2) {
21986       function valueNull() {
21987         delete this.value;
21988       }
21989       function valueConstant() {
21990         if (shouldUpdate2(this.value, value2)) {
21991           this.value = value2;
21992         }
21993       }
21994       function valueFunction() {
21995         var x2 = value2.apply(this, arguments);
21996         if (x2 === null || x2 === void 0) {
21997           delete this.value;
21998         } else if (shouldUpdate2(this.value, x2)) {
21999           this.value = x2;
22000         }
22001       }
22002       return value2 === null || value2 === void 0 ? valueNull : typeof value2 === "function" ? valueFunction : valueConstant;
22003     }
22004     if (arguments.length === 1) {
22005       return selection2.property("value");
22006     }
22007     if (shouldUpdate === void 0) {
22008       shouldUpdate = (a2, b2) => a2 !== b2;
22009     }
22010     return selection2.each(setValue(value, shouldUpdate));
22011   }
22012
22013   // modules/util/keybinding.js
22014   function utilKeybinding(namespace) {
22015     var _keybindings = {};
22016     function testBindings(d3_event, isCapturing) {
22017       var didMatch = false;
22018       var bindings = Object.keys(_keybindings).map(function(id2) {
22019         return _keybindings[id2];
22020       });
22021       var i3, binding;
22022       for (i3 = 0; i3 < bindings.length; i3++) {
22023         binding = bindings[i3];
22024         if (!binding.event.modifiers.shiftKey) continue;
22025         if (!!binding.capture !== isCapturing) continue;
22026         if (matches(d3_event, binding, true)) {
22027           binding.callback(d3_event);
22028           didMatch = true;
22029           break;
22030         }
22031       }
22032       if (didMatch) return;
22033       for (i3 = 0; i3 < bindings.length; i3++) {
22034         binding = bindings[i3];
22035         if (binding.event.modifiers.shiftKey) continue;
22036         if (!!binding.capture !== isCapturing) continue;
22037         if (matches(d3_event, binding, false)) {
22038           binding.callback(d3_event);
22039           break;
22040         }
22041       }
22042       function matches(d3_event2, binding2, testShift) {
22043         var event = d3_event2;
22044         var isMatch = false;
22045         var tryKeyCode = true;
22046         if (event.key !== void 0) {
22047           tryKeyCode = event.key.charCodeAt(0) > 127;
22048           isMatch = true;
22049           if (binding2.event.key === void 0) {
22050             isMatch = false;
22051           } else if (Array.isArray(binding2.event.key)) {
22052             if (binding2.event.key.map(function(s2) {
22053               return s2.toLowerCase();
22054             }).indexOf(event.key.toLowerCase()) === -1) {
22055               isMatch = false;
22056             }
22057           } else {
22058             if (event.key.toLowerCase() !== binding2.event.key.toLowerCase()) {
22059               isMatch = false;
22060             }
22061           }
22062         }
22063         if (!isMatch && (tryKeyCode || binding2.event.modifiers.altKey)) {
22064           isMatch = event.keyCode === binding2.event.keyCode;
22065         }
22066         if (!isMatch) return false;
22067         if (!(event.ctrlKey && event.altKey)) {
22068           if (event.ctrlKey !== binding2.event.modifiers.ctrlKey) return false;
22069           if (event.altKey !== binding2.event.modifiers.altKey) return false;
22070         }
22071         if (event.metaKey !== binding2.event.modifiers.metaKey) return false;
22072         if (testShift && event.shiftKey !== binding2.event.modifiers.shiftKey) return false;
22073         return true;
22074       }
22075     }
22076     function capture(d3_event) {
22077       testBindings(d3_event, true);
22078     }
22079     function bubble(d3_event) {
22080       var tagName = select_default2(d3_event.target).node().tagName;
22081       if (tagName === "INPUT" || tagName === "SELECT" || tagName === "TEXTAREA") {
22082         return;
22083       }
22084       testBindings(d3_event, false);
22085     }
22086     function keybinding(selection2) {
22087       selection2 = selection2 || select_default2(document);
22088       selection2.on("keydown.capture." + namespace, capture, true);
22089       selection2.on("keydown.bubble." + namespace, bubble, false);
22090       return keybinding;
22091     }
22092     keybinding.unbind = function(selection2) {
22093       _keybindings = [];
22094       selection2 = selection2 || select_default2(document);
22095       selection2.on("keydown.capture." + namespace, null);
22096       selection2.on("keydown.bubble." + namespace, null);
22097       return keybinding;
22098     };
22099     keybinding.clear = function() {
22100       _keybindings = {};
22101       return keybinding;
22102     };
22103     keybinding.off = function(codes, capture2) {
22104       var arr = utilArrayUniq([].concat(codes));
22105       for (var i3 = 0; i3 < arr.length; i3++) {
22106         var id2 = arr[i3] + (capture2 ? "-capture" : "-bubble");
22107         delete _keybindings[id2];
22108       }
22109       return keybinding;
22110     };
22111     keybinding.on = function(codes, callback, capture2) {
22112       if (typeof callback !== "function") {
22113         return keybinding.off(codes, capture2);
22114       }
22115       var arr = utilArrayUniq([].concat(codes));
22116       for (var i3 = 0; i3 < arr.length; i3++) {
22117         var id2 = arr[i3] + (capture2 ? "-capture" : "-bubble");
22118         var binding = {
22119           id: id2,
22120           capture: capture2,
22121           callback,
22122           event: {
22123             key: void 0,
22124             // preferred
22125             keyCode: 0,
22126             // fallback
22127             modifiers: {
22128               shiftKey: false,
22129               ctrlKey: false,
22130               altKey: false,
22131               metaKey: false
22132             }
22133           }
22134         };
22135         if (_keybindings[id2]) {
22136           console.warn('warning: duplicate keybinding for "' + id2 + '"');
22137         }
22138         _keybindings[id2] = binding;
22139         var matches = arr[i3].toLowerCase().match(/(?:(?:[^+⇧⌃⌥⌘])+|[⇧⌃⌥⌘]|\+\+|^\+$)/g);
22140         for (var j2 = 0; j2 < matches.length; j2++) {
22141           if (matches[j2] === "++") matches[j2] = "+";
22142           if (matches[j2] in utilKeybinding.modifierCodes) {
22143             var prop = utilKeybinding.modifierProperties[utilKeybinding.modifierCodes[matches[j2]]];
22144             binding.event.modifiers[prop] = true;
22145           } else {
22146             binding.event.key = utilKeybinding.keys[matches[j2]] || matches[j2];
22147             if (matches[j2] in utilKeybinding.keyCodes) {
22148               binding.event.keyCode = utilKeybinding.keyCodes[matches[j2]];
22149             }
22150           }
22151         }
22152       }
22153       return keybinding;
22154     };
22155     return keybinding;
22156   }
22157   utilKeybinding.modifierCodes = {
22158     // Shift key, ⇧
22159     "\u21E7": 16,
22160     shift: 16,
22161     // CTRL key, on Mac: ⌃
22162     "\u2303": 17,
22163     ctrl: 17,
22164     // ALT key, on Mac: ⌥ (Alt)
22165     "\u2325": 18,
22166     alt: 18,
22167     option: 18,
22168     // META, on Mac: ⌘ (CMD), on Windows (Win), on Linux (Super)
22169     "\u2318": 91,
22170     meta: 91,
22171     cmd: 91,
22172     "super": 91,
22173     win: 91
22174   };
22175   utilKeybinding.modifierProperties = {
22176     16: "shiftKey",
22177     17: "ctrlKey",
22178     18: "altKey",
22179     91: "metaKey"
22180   };
22181   utilKeybinding.plusKeys = ["plus", "ffplus", "=", "ffequals", "\u2260", "\xB1"];
22182   utilKeybinding.minusKeys = ["_", "-", "ffminus", "dash", "\u2013", "\u2014"];
22183   utilKeybinding.keys = {
22184     // Backspace key, on Mac: ⌫ (Backspace)
22185     "\u232B": "Backspace",
22186     backspace: "Backspace",
22187     // Tab Key, on Mac: ⇥ (Tab), on Windows ⇥⇥
22188     "\u21E5": "Tab",
22189     "\u21C6": "Tab",
22190     tab: "Tab",
22191     // Return key, ↩
22192     "\u21A9": "Enter",
22193     "\u21B5": "Enter",
22194     "\u23CE": "Enter",
22195     "return": "Enter",
22196     enter: "Enter",
22197     "\u2305": "Enter",
22198     // Pause/Break key
22199     "pause": "Pause",
22200     "pause-break": "Pause",
22201     // Caps Lock key, ⇪
22202     "\u21EA": "CapsLock",
22203     caps: "CapsLock",
22204     "caps-lock": "CapsLock",
22205     // Escape key, on Mac: ⎋, on Windows: Esc
22206     "\u238B": ["Escape", "Esc"],
22207     escape: ["Escape", "Esc"],
22208     esc: ["Escape", "Esc"],
22209     // Space key
22210     space: [" ", "Spacebar"],
22211     // Page-Up key, or pgup, on Mac: ↖
22212     "\u2196": "PageUp",
22213     pgup: "PageUp",
22214     "page-up": "PageUp",
22215     // Page-Down key, or pgdown, on Mac: ↘
22216     "\u2198": "PageDown",
22217     pgdown: "PageDown",
22218     "page-down": "PageDown",
22219     // END key, on Mac: ⇟
22220     "\u21DF": "End",
22221     end: "End",
22222     // HOME key, on Mac: ⇞
22223     "\u21DE": "Home",
22224     home: "Home",
22225     // Insert key, or ins
22226     ins: "Insert",
22227     insert: "Insert",
22228     // Delete key, on Mac: ⌦ (Delete)
22229     "\u2326": ["Delete", "Del"],
22230     del: ["Delete", "Del"],
22231     "delete": ["Delete", "Del"],
22232     // Left Arrow Key, or ←
22233     "\u2190": ["ArrowLeft", "Left"],
22234     left: ["ArrowLeft", "Left"],
22235     "arrow-left": ["ArrowLeft", "Left"],
22236     // Up Arrow Key, or ↑
22237     "\u2191": ["ArrowUp", "Up"],
22238     up: ["ArrowUp", "Up"],
22239     "arrow-up": ["ArrowUp", "Up"],
22240     // Right Arrow Key, or →
22241     "\u2192": ["ArrowRight", "Right"],
22242     right: ["ArrowRight", "Right"],
22243     "arrow-right": ["ArrowRight", "Right"],
22244     // Up Arrow Key, or ↓
22245     "\u2193": ["ArrowDown", "Down"],
22246     down: ["ArrowDown", "Down"],
22247     "arrow-down": ["ArrowDown", "Down"],
22248     // odities, stuff for backward compatibility (browsers and code):
22249     // Num-Multiply, or *
22250     "*": ["*", "Multiply"],
22251     star: ["*", "Multiply"],
22252     asterisk: ["*", "Multiply"],
22253     multiply: ["*", "Multiply"],
22254     // Num-Plus or +
22255     "+": ["+", "Add"],
22256     "plus": ["+", "Add"],
22257     // Num-Subtract, or -
22258     "-": ["-", "Subtract"],
22259     subtract: ["-", "Subtract"],
22260     "dash": ["-", "Subtract"],
22261     // Semicolon
22262     semicolon: ";",
22263     // = or equals
22264     equals: "=",
22265     // Comma, or ,
22266     comma: ",",
22267     // Period, or ., or full-stop
22268     period: ".",
22269     "full-stop": ".",
22270     // Slash, or /, or forward-slash
22271     slash: "/",
22272     "forward-slash": "/",
22273     // Tick, or `, or back-quote
22274     tick: "`",
22275     "back-quote": "`",
22276     // Open bracket, or [
22277     "open-bracket": "[",
22278     // Back slash, or \
22279     "back-slash": "\\",
22280     // Close bracket, or ]
22281     "close-bracket": "]",
22282     // Apostrophe, or Quote, or '
22283     quote: "'",
22284     apostrophe: "'",
22285     // NUMPAD 0-9
22286     "num-0": "0",
22287     "num-1": "1",
22288     "num-2": "2",
22289     "num-3": "3",
22290     "num-4": "4",
22291     "num-5": "5",
22292     "num-6": "6",
22293     "num-7": "7",
22294     "num-8": "8",
22295     "num-9": "9",
22296     // F1-F25
22297     f1: "F1",
22298     f2: "F2",
22299     f3: "F3",
22300     f4: "F4",
22301     f5: "F5",
22302     f6: "F6",
22303     f7: "F7",
22304     f8: "F8",
22305     f9: "F9",
22306     f10: "F10",
22307     f11: "F11",
22308     f12: "F12",
22309     f13: "F13",
22310     f14: "F14",
22311     f15: "F15",
22312     f16: "F16",
22313     f17: "F17",
22314     f18: "F18",
22315     f19: "F19",
22316     f20: "F20",
22317     f21: "F21",
22318     f22: "F22",
22319     f23: "F23",
22320     f24: "F24",
22321     f25: "F25"
22322   };
22323   utilKeybinding.keyCodes = {
22324     // Backspace key, on Mac: ⌫ (Backspace)
22325     "\u232B": 8,
22326     backspace: 8,
22327     // Tab Key, on Mac: ⇥ (Tab), on Windows ⇥⇥
22328     "\u21E5": 9,
22329     "\u21C6": 9,
22330     tab: 9,
22331     // Return key, ↩
22332     "\u21A9": 13,
22333     "\u21B5": 13,
22334     "\u23CE": 13,
22335     "return": 13,
22336     enter: 13,
22337     "\u2305": 13,
22338     // Pause/Break key
22339     "pause": 19,
22340     "pause-break": 19,
22341     // Caps Lock key, ⇪
22342     "\u21EA": 20,
22343     caps: 20,
22344     "caps-lock": 20,
22345     // Escape key, on Mac: ⎋, on Windows: Esc
22346     "\u238B": 27,
22347     escape: 27,
22348     esc: 27,
22349     // Space key
22350     space: 32,
22351     // Page-Up key, or pgup, on Mac: ↖
22352     "\u2196": 33,
22353     pgup: 33,
22354     "page-up": 33,
22355     // Page-Down key, or pgdown, on Mac: ↘
22356     "\u2198": 34,
22357     pgdown: 34,
22358     "page-down": 34,
22359     // END key, on Mac: ⇟
22360     "\u21DF": 35,
22361     end: 35,
22362     // HOME key, on Mac: ⇞
22363     "\u21DE": 36,
22364     home: 36,
22365     // Insert key, or ins
22366     ins: 45,
22367     insert: 45,
22368     // Delete key, on Mac: ⌦ (Delete)
22369     "\u2326": 46,
22370     del: 46,
22371     "delete": 46,
22372     // Left Arrow Key, or ←
22373     "\u2190": 37,
22374     left: 37,
22375     "arrow-left": 37,
22376     // Up Arrow Key, or ↑
22377     "\u2191": 38,
22378     up: 38,
22379     "arrow-up": 38,
22380     // Right Arrow Key, or →
22381     "\u2192": 39,
22382     right: 39,
22383     "arrow-right": 39,
22384     // Up Arrow Key, or ↓
22385     "\u2193": 40,
22386     down: 40,
22387     "arrow-down": 40,
22388     // odities, printing characters that come out wrong:
22389     // Firefox Equals
22390     "ffequals": 61,
22391     // Num-Multiply, or *
22392     "*": 106,
22393     star: 106,
22394     asterisk: 106,
22395     multiply: 106,
22396     // Num-Plus or +
22397     "+": 107,
22398     "plus": 107,
22399     // Num-Subtract, or -
22400     "-": 109,
22401     subtract: 109,
22402     // Vertical Bar / Pipe
22403     "|": 124,
22404     // Firefox Plus
22405     "ffplus": 171,
22406     // Firefox Minus
22407     "ffminus": 173,
22408     // Semicolon
22409     ";": 186,
22410     semicolon: 186,
22411     // = or equals
22412     "=": 187,
22413     "equals": 187,
22414     // Comma, or ,
22415     ",": 188,
22416     comma: 188,
22417     // Dash / Underscore key
22418     "dash": 189,
22419     // Period, or ., or full-stop
22420     ".": 190,
22421     period: 190,
22422     "full-stop": 190,
22423     // Slash, or /, or forward-slash
22424     "/": 191,
22425     slash: 191,
22426     "forward-slash": 191,
22427     // Tick, or `, or back-quote
22428     "`": 192,
22429     tick: 192,
22430     "back-quote": 192,
22431     // Open bracket, or [
22432     "[": 219,
22433     "open-bracket": 219,
22434     // Back slash, or \
22435     "\\": 220,
22436     "back-slash": 220,
22437     // Close bracket, or ]
22438     "]": 221,
22439     "close-bracket": 221,
22440     // Apostrophe, or Quote, or '
22441     "'": 222,
22442     quote: 222,
22443     apostrophe: 222
22444   };
22445   var i = 95;
22446   var n = 0;
22447   while (++i < 106) {
22448     utilKeybinding.keyCodes["num-" + n] = i;
22449     ++n;
22450   }
22451   i = 47;
22452   n = 0;
22453   while (++i < 58) {
22454     utilKeybinding.keyCodes[n] = i;
22455     ++n;
22456   }
22457   i = 111;
22458   n = 1;
22459   while (++i < 136) {
22460     utilKeybinding.keyCodes["f" + n] = i;
22461     ++n;
22462   }
22463   i = 64;
22464   while (++i < 91) {
22465     utilKeybinding.keyCodes[String.fromCharCode(i).toLowerCase()] = i;
22466   }
22467
22468   // modules/util/object.js
22469   function utilObjectOmit(obj, omitKeys) {
22470     return Object.keys(obj).reduce(function(result, key) {
22471       if (omitKeys.indexOf(key) === -1) {
22472         result[key] = obj[key];
22473       }
22474       return result;
22475     }, {});
22476   }
22477
22478   // modules/util/rebind.js
22479   function utilRebind(target, source) {
22480     var i3 = 1, n3 = arguments.length, method;
22481     while (++i3 < n3) {
22482       target[method = arguments[i3]] = d3_rebind(target, source, source[method]);
22483     }
22484     return target;
22485   }
22486   function d3_rebind(target, source, method) {
22487     return function() {
22488       var value = method.apply(source, arguments);
22489       return value === source ? target : value;
22490     };
22491   }
22492
22493   // modules/util/session_mutex.js
22494   function utilSessionMutex(name) {
22495     var mutex = {};
22496     var intervalID;
22497     function renew() {
22498       if (typeof window === "undefined") return;
22499       var expires = /* @__PURE__ */ new Date();
22500       expires.setSeconds(expires.getSeconds() + 5);
22501       document.cookie = name + "=1; expires=" + expires.toUTCString() + "; sameSite=strict";
22502     }
22503     mutex.lock = function() {
22504       if (intervalID) return true;
22505       var cookie = document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + name + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1");
22506       if (cookie) return false;
22507       renew();
22508       intervalID = window.setInterval(renew, 4e3);
22509       return true;
22510     };
22511     mutex.unlock = function() {
22512       if (!intervalID) return;
22513       document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; sameSite=strict";
22514       clearInterval(intervalID);
22515       intervalID = null;
22516     };
22517     mutex.locked = function() {
22518       return !!intervalID;
22519     };
22520     return mutex;
22521   }
22522
22523   // modules/util/tiler.js
22524   function utilTiler() {
22525     var _size = [256, 256];
22526     var _scale = 256;
22527     var _tileSize = 256;
22528     var _zoomExtent = [0, 20];
22529     var _translate = [_size[0] / 2, _size[1] / 2];
22530     var _margin = 0;
22531     var _skipNullIsland = false;
22532     function clamp3(num, min3, max3) {
22533       return Math.max(min3, Math.min(num, max3));
22534     }
22535     function nearNullIsland(tile) {
22536       var x2 = tile[0];
22537       var y2 = tile[1];
22538       var z2 = tile[2];
22539       if (z2 >= 7) {
22540         var center = Math.pow(2, z2 - 1);
22541         var width = Math.pow(2, z2 - 6);
22542         var min3 = center - width / 2;
22543         var max3 = center + width / 2 - 1;
22544         return x2 >= min3 && x2 <= max3 && y2 >= min3 && y2 <= max3;
22545       }
22546       return false;
22547     }
22548     function tiler8() {
22549       var z2 = geoScaleToZoom(_scale / (2 * Math.PI), _tileSize);
22550       var z0 = clamp3(Math.round(z2), _zoomExtent[0], _zoomExtent[1]);
22551       var tileMin = 0;
22552       var tileMax = Math.pow(2, z0) - 1;
22553       var log2ts = Math.log(_tileSize) * Math.LOG2E;
22554       var k2 = Math.pow(2, z2 - z0 + log2ts);
22555       var origin = [
22556         (_translate[0] - _scale / 2) / k2,
22557         (_translate[1] - _scale / 2) / k2
22558       ];
22559       var cols = range(
22560         clamp3(Math.floor(-origin[0]) - _margin, tileMin, tileMax + 1),
22561         clamp3(Math.ceil(_size[0] / k2 - origin[0]) + _margin, tileMin, tileMax + 1)
22562       );
22563       var rows = range(
22564         clamp3(Math.floor(-origin[1]) - _margin, tileMin, tileMax + 1),
22565         clamp3(Math.ceil(_size[1] / k2 - origin[1]) + _margin, tileMin, tileMax + 1)
22566       );
22567       var tiles = [];
22568       for (var i3 = 0; i3 < rows.length; i3++) {
22569         var y2 = rows[i3];
22570         for (var j2 = 0; j2 < cols.length; j2++) {
22571           var x2 = cols[j2];
22572           if (i3 >= _margin && i3 <= rows.length - _margin && j2 >= _margin && j2 <= cols.length - _margin) {
22573             tiles.unshift([x2, y2, z0]);
22574           } else {
22575             tiles.push([x2, y2, z0]);
22576           }
22577         }
22578       }
22579       tiles.translate = origin;
22580       tiles.scale = k2;
22581       return tiles;
22582     }
22583     tiler8.getTiles = function(projection2) {
22584       var origin = [
22585         projection2.scale() * Math.PI - projection2.translate()[0],
22586         projection2.scale() * Math.PI - projection2.translate()[1]
22587       ];
22588       this.size(projection2.clipExtent()[1]).scale(projection2.scale() * 2 * Math.PI).translate(projection2.translate());
22589       var tiles = tiler8();
22590       var ts = tiles.scale;
22591       return tiles.map(function(tile) {
22592         if (_skipNullIsland && nearNullIsland(tile)) {
22593           return false;
22594         }
22595         var x2 = tile[0] * ts - origin[0];
22596         var y2 = tile[1] * ts - origin[1];
22597         return {
22598           id: tile.toString(),
22599           xyz: tile,
22600           extent: geoExtent(
22601             projection2.invert([x2, y2 + ts]),
22602             projection2.invert([x2 + ts, y2])
22603           )
22604         };
22605       }).filter(Boolean);
22606     };
22607     tiler8.getGeoJSON = function(projection2) {
22608       var features = tiler8.getTiles(projection2).map(function(tile) {
22609         return {
22610           type: "Feature",
22611           properties: {
22612             id: tile.id,
22613             name: tile.id
22614           },
22615           geometry: {
22616             type: "Polygon",
22617             coordinates: [tile.extent.polygon()]
22618           }
22619         };
22620       });
22621       return {
22622         type: "FeatureCollection",
22623         features
22624       };
22625     };
22626     tiler8.tileSize = function(val) {
22627       if (!arguments.length) return _tileSize;
22628       _tileSize = val;
22629       return tiler8;
22630     };
22631     tiler8.zoomExtent = function(val) {
22632       if (!arguments.length) return _zoomExtent;
22633       _zoomExtent = val;
22634       return tiler8;
22635     };
22636     tiler8.size = function(val) {
22637       if (!arguments.length) return _size;
22638       _size = val;
22639       return tiler8;
22640     };
22641     tiler8.scale = function(val) {
22642       if (!arguments.length) return _scale;
22643       _scale = val;
22644       return tiler8;
22645     };
22646     tiler8.translate = function(val) {
22647       if (!arguments.length) return _translate;
22648       _translate = val;
22649       return tiler8;
22650     };
22651     tiler8.margin = function(val) {
22652       if (!arguments.length) return _margin;
22653       _margin = +val;
22654       return tiler8;
22655     };
22656     tiler8.skipNullIsland = function(val) {
22657       if (!arguments.length) return _skipNullIsland;
22658       _skipNullIsland = val;
22659       return tiler8;
22660     };
22661     return tiler8;
22662   }
22663
22664   // modules/util/trigger_event.js
22665   function utilTriggerEvent(target, type2, eventProperties) {
22666     target.each(function() {
22667       var evt = document.createEvent("HTMLEvents");
22668       evt.initEvent(type2, true, true);
22669       for (var prop in eventProperties) {
22670         evt[prop] = eventProperties[prop];
22671       }
22672       this.dispatchEvent(evt);
22673     });
22674   }
22675
22676   // modules/util/units.js
22677   var OSM_PRECISION = 7;
22678   function displayLength(m2, isImperial) {
22679     var d2 = m2 * (isImperial ? 3.28084 : 1);
22680     var unit2;
22681     if (isImperial) {
22682       if (d2 >= 5280) {
22683         d2 /= 5280;
22684         unit2 = "miles";
22685       } else {
22686         unit2 = "feet";
22687       }
22688     } else {
22689       if (d2 >= 1e3) {
22690         d2 /= 1e3;
22691         unit2 = "kilometers";
22692       } else {
22693         unit2 = "meters";
22694       }
22695     }
22696     return _t("units." + unit2, {
22697       quantity: d2.toLocaleString(_mainLocalizer.localeCode(), {
22698         maximumSignificantDigits: 4
22699       })
22700     });
22701   }
22702   function displayArea(m2, isImperial) {
22703     var locale2 = _mainLocalizer.localeCode();
22704     var d2 = m2 * (isImperial ? 10.7639111056 : 1);
22705     var d1, d22, area;
22706     var unit1 = "";
22707     var unit2 = "";
22708     if (isImperial) {
22709       if (d2 >= 6969600) {
22710         d1 = d2 / 27878400;
22711         unit1 = "square_miles";
22712       } else {
22713         d1 = d2;
22714         unit1 = "square_feet";
22715       }
22716       if (d2 > 4356 && d2 < 4356e4) {
22717         d22 = d2 / 43560;
22718         unit2 = "acres";
22719       }
22720     } else {
22721       if (d2 >= 25e4) {
22722         d1 = d2 / 1e6;
22723         unit1 = "square_kilometers";
22724       } else {
22725         d1 = d2;
22726         unit1 = "square_meters";
22727       }
22728       if (d2 > 1e3 && d2 < 1e7) {
22729         d22 = d2 / 1e4;
22730         unit2 = "hectares";
22731       }
22732     }
22733     area = _t("units." + unit1, {
22734       quantity: d1.toLocaleString(locale2, {
22735         maximumSignificantDigits: 4
22736       })
22737     });
22738     if (d22) {
22739       return _t("units.area_pair", {
22740         area1: area,
22741         area2: _t("units." + unit2, {
22742           quantity: d22.toLocaleString(locale2, {
22743             maximumSignificantDigits: 2
22744           })
22745         })
22746       });
22747     } else {
22748       return area;
22749     }
22750   }
22751   function wrap(x2, min3, max3) {
22752     var d2 = max3 - min3;
22753     return ((x2 - min3) % d2 + d2) % d2 + min3;
22754   }
22755   function clamp(x2, min3, max3) {
22756     return Math.max(min3, Math.min(x2, max3));
22757   }
22758   function roundToDecimal(target, decimalPlace) {
22759     target = Number(target);
22760     decimalPlace = Number(decimalPlace);
22761     const factor = Math.pow(10, decimalPlace);
22762     return Math.round(target * factor) / factor;
22763   }
22764   function displayCoordinate(deg, pos, neg) {
22765     var displayCoordinate2;
22766     var locale2 = _mainLocalizer.localeCode();
22767     var degreesFloor = Math.floor(Math.abs(deg));
22768     var min3 = (Math.abs(deg) - degreesFloor) * 60;
22769     var minFloor = Math.floor(min3);
22770     var sec = (min3 - minFloor) * 60;
22771     var fix = roundToDecimal(sec, 8);
22772     var secRounded = roundToDecimal(fix, 0);
22773     if (secRounded === 60) {
22774       secRounded = 0;
22775       minFloor += 1;
22776       if (minFloor === 60) {
22777         minFloor = 0;
22778         degreesFloor += 1;
22779       }
22780     }
22781     displayCoordinate2 = _t("units.arcdegrees", {
22782       quantity: degreesFloor.toLocaleString(locale2)
22783     }) + (minFloor !== 0 || secRounded !== 0 ? _t("units.arcminutes", {
22784       quantity: minFloor.toLocaleString(locale2)
22785     }) : "") + (secRounded !== 0 ? _t("units.arcseconds", {
22786       quantity: secRounded.toLocaleString(locale2)
22787     }) : "");
22788     if (deg === 0) {
22789       return displayCoordinate2;
22790     } else {
22791       return _t("units.coordinate", {
22792         coordinate: displayCoordinate2,
22793         direction: _t("units." + (deg > 0 ? pos : neg))
22794       });
22795     }
22796   }
22797   function dmsCoordinatePair(coord2) {
22798     return _t("units.coordinate_pair", {
22799       latitude: displayCoordinate(clamp(coord2[1], -90, 90), "north", "south"),
22800       longitude: displayCoordinate(wrap(coord2[0], -180, 180), "east", "west")
22801     });
22802   }
22803   function decimalCoordinatePair(coord2) {
22804     return _t("units.coordinate_pair", {
22805       latitude: clamp(coord2[1], -90, 90).toFixed(OSM_PRECISION),
22806       longitude: wrap(coord2[0], -180, 180).toFixed(OSM_PRECISION)
22807     });
22808   }
22809   function dmsMatcher(q2) {
22810     const matchers = [
22811       // D M SS , D M SS  ex: 35 11 10.1 , 136 49 53.8
22812       {
22813         condition: /^\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*$/,
22814         parser: function(q3) {
22815           const match = this.condition.exec(q3);
22816           const lat = +match[2] + +match[3] / 60 + +match[4] / 3600;
22817           const lng = +match[6] + +match[7] / 60 + +match[8] / 3600;
22818           const isNegLat = match[1] === "-" ? -lat : lat;
22819           const isNegLng = match[5] === "-" ? -lng : lng;
22820           const d2 = [isNegLat, isNegLng];
22821           return d2;
22822         }
22823       },
22824       // D MM , D MM ex: 35 11.1683 , 136 49.8966
22825       {
22826         condition: /^\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*$/,
22827         parser: function(q3) {
22828           const match = this.condition.exec(q3);
22829           const lat = +match[2] + +match[3] / 60;
22830           const lng = +match[5] + +match[6] / 60;
22831           const isNegLat = match[1] === "-" ? -lat : lat;
22832           const isNegLng = match[4] === "-" ? -lng : lng;
22833           const d2 = [isNegLat, isNegLng];
22834           return d2;
22835         }
22836       }
22837     ];
22838     for (const matcher of matchers) {
22839       if (matcher.condition.test(q2)) {
22840         return matcher.parser(q2);
22841       }
22842     }
22843     return null;
22844   }
22845
22846   // modules/core/localizer.js
22847   var _mainLocalizer = coreLocalizer();
22848   var _t = _mainLocalizer.t;
22849   function coreLocalizer() {
22850     let localizer = {};
22851     let _dataLanguages = {};
22852     let _dataLocales = {};
22853     let _localeStrings = {};
22854     let _localeCode = "en-US";
22855     let _localeCodes = ["en-US", "en"];
22856     let _languageCode = "en";
22857     let _textDirection = "ltr";
22858     let _usesMetric = false;
22859     let _languageNames = {};
22860     let _scriptNames = {};
22861     localizer.localeCode = () => _localeCode;
22862     localizer.localeCodes = () => _localeCodes;
22863     localizer.languageCode = () => _languageCode;
22864     localizer.textDirection = () => _textDirection;
22865     localizer.usesMetric = () => _usesMetric;
22866     localizer.languageNames = () => _languageNames;
22867     localizer.scriptNames = () => _scriptNames;
22868     let _preferredLocaleCodes = [];
22869     localizer.preferredLocaleCodes = function(codes) {
22870       if (!arguments.length) return _preferredLocaleCodes;
22871       if (typeof codes === "string") {
22872         _preferredLocaleCodes = codes.split(/,|;| /gi).filter(Boolean);
22873       } else {
22874         _preferredLocaleCodes = codes;
22875       }
22876       return localizer;
22877     };
22878     var _loadPromise;
22879     localizer.ensureLoaded = () => {
22880       if (_loadPromise) return _loadPromise;
22881       let filesToFetch = [
22882         "languages",
22883         // load the list of languages
22884         "locales"
22885         // load the list of supported locales
22886       ];
22887       const localeDirs = {
22888         general: "locales",
22889         tagging: presetsCdnUrl + "dist/translations"
22890       };
22891       let fileMap = _mainFileFetcher.fileMap();
22892       for (let scopeId in localeDirs) {
22893         const key = "locales_index_".concat(scopeId);
22894         if (!fileMap[key]) {
22895           fileMap[key] = localeDirs[scopeId] + "/index.min.json";
22896         }
22897         filesToFetch.push(key);
22898       }
22899       return _loadPromise = Promise.all(filesToFetch.map((key) => _mainFileFetcher.get(key))).then((results) => {
22900         _dataLanguages = results[0];
22901         _dataLocales = results[1];
22902         let indexes = results.slice(2);
22903         let requestedLocales = (_preferredLocaleCodes || []).concat(utilDetect().browserLocales).concat(["en"]);
22904         _localeCodes = localesToUseFrom(requestedLocales);
22905         _localeCode = _localeCodes[0];
22906         let loadStringsPromises = [];
22907         indexes.forEach((index, i3) => {
22908           const fullCoverageIndex = _localeCodes.findIndex(function(locale2) {
22909             return index[locale2] && index[locale2].pct === 1;
22910           });
22911           _localeCodes.slice(0, fullCoverageIndex + 1).forEach(function(code) {
22912             let scopeId = Object.keys(localeDirs)[i3];
22913             let directory = Object.values(localeDirs)[i3];
22914             if (index[code]) loadStringsPromises.push(localizer.loadLocale(code, scopeId, directory));
22915           });
22916         });
22917         return Promise.all(loadStringsPromises);
22918       }).then(() => {
22919         updateForCurrentLocale();
22920       }).catch((err) => console.error(err));
22921     };
22922     function localesToUseFrom(requestedLocales) {
22923       let supportedLocales = _dataLocales;
22924       let toUse = [];
22925       for (let i3 in requestedLocales) {
22926         let locale2 = requestedLocales[i3];
22927         if (supportedLocales[locale2]) toUse.push(locale2);
22928         if (locale2.includes("-")) {
22929           let langPart = locale2.split("-")[0];
22930           if (supportedLocales[langPart]) toUse.push(langPart);
22931         }
22932       }
22933       return utilArrayUniq(toUse);
22934     }
22935     function updateForCurrentLocale() {
22936       if (!_localeCode) return;
22937       _languageCode = _localeCode.split("-")[0];
22938       const currentData = _dataLocales[_localeCode] || _dataLocales[_languageCode];
22939       const hash2 = utilStringQs(window.location.hash);
22940       if (hash2.rtl === "true") {
22941         _textDirection = "rtl";
22942       } else if (hash2.rtl === "false") {
22943         _textDirection = "ltr";
22944       } else {
22945         _textDirection = currentData && currentData.rtl ? "rtl" : "ltr";
22946       }
22947       let locale2 = _localeCode;
22948       if (locale2.toLowerCase() === "en-us") locale2 = "en";
22949       _languageNames = _localeStrings.general[locale2].languageNames || _localeStrings.general[_languageCode].languageNames;
22950       _scriptNames = _localeStrings.general[locale2].scriptNames || _localeStrings.general[_languageCode].scriptNames;
22951       _usesMetric = _localeCode.slice(-3).toLowerCase() !== "-us";
22952     }
22953     localizer.loadLocale = (locale2, scopeId, directory) => {
22954       if (locale2.toLowerCase() === "en-us") locale2 = "en";
22955       if (_localeStrings[scopeId] && _localeStrings[scopeId][locale2]) {
22956         return Promise.resolve(locale2);
22957       }
22958       let fileMap = _mainFileFetcher.fileMap();
22959       const key = "locale_".concat(scopeId, "_").concat(locale2);
22960       if (!fileMap[key]) {
22961         fileMap[key] = "".concat(directory, "/").concat(locale2, ".min.json");
22962       }
22963       return _mainFileFetcher.get(key).then((d2) => {
22964         if (!_localeStrings[scopeId]) _localeStrings[scopeId] = {};
22965         _localeStrings[scopeId][locale2] = d2[locale2];
22966         return locale2;
22967       });
22968     };
22969     localizer.pluralRule = function(number3) {
22970       return pluralRule(number3, _localeCode);
22971     };
22972     function pluralRule(number3, localeCode) {
22973       const rules = "Intl" in window && Intl.PluralRules && new Intl.PluralRules(localeCode);
22974       if (rules) {
22975         return rules.select(number3);
22976       }
22977       if (number3 === 1) return "one";
22978       return "other";
22979     }
22980     localizer.tInfo = function(origStringId, replacements, locale2) {
22981       let stringId = origStringId.trim();
22982       let scopeId = "general";
22983       if (stringId[0] === "_") {
22984         let split = stringId.split(".");
22985         scopeId = split[0].slice(1);
22986         stringId = split.slice(1).join(".");
22987       }
22988       locale2 = locale2 || _localeCode;
22989       let path = stringId.split(".").map((s2) => s2.replace(/<TX_DOT>/g, ".")).reverse();
22990       let stringsKey = locale2;
22991       if (stringsKey.toLowerCase() === "en-us") stringsKey = "en";
22992       let result = _localeStrings && _localeStrings[scopeId] && _localeStrings[scopeId][stringsKey];
22993       while (result !== void 0 && path.length) {
22994         result = result[path.pop()];
22995       }
22996       if (result !== void 0) {
22997         if (replacements) {
22998           if (typeof result === "object" && Object.keys(result).length) {
22999             const number3 = Object.values(replacements).find(function(value) {
23000               return typeof value === "number";
23001             });
23002             if (number3 !== void 0) {
23003               const rule = pluralRule(number3, locale2);
23004               if (result[rule]) {
23005                 result = result[rule];
23006               } else {
23007                 result = Object.values(result)[0];
23008               }
23009             }
23010           }
23011           if (typeof result === "string") {
23012             for (let key in replacements) {
23013               let value = replacements[key];
23014               if (typeof value === "number") {
23015                 if (value.toLocaleString) {
23016                   value = value.toLocaleString(locale2, {
23017                     style: "decimal",
23018                     useGrouping: true,
23019                     minimumFractionDigits: 0
23020                   });
23021                 } else {
23022                   value = value.toString();
23023                 }
23024               }
23025               const token = "{".concat(key, "}");
23026               const regex = new RegExp(token, "g");
23027               result = result.replace(regex, value);
23028             }
23029           }
23030         }
23031         if (typeof result === "string") {
23032           return {
23033             text: result,
23034             locale: locale2
23035           };
23036         }
23037       }
23038       let index = _localeCodes.indexOf(locale2);
23039       if (index >= 0 && index < _localeCodes.length - 1) {
23040         let fallback = _localeCodes[index + 1];
23041         return localizer.tInfo(origStringId, replacements, fallback);
23042       }
23043       if (replacements && "default" in replacements) {
23044         return {
23045           text: replacements.default,
23046           locale: null
23047         };
23048       }
23049       const missing = "Missing ".concat(locale2, " translation: ").concat(origStringId);
23050       if (typeof console !== "undefined") console.error(missing);
23051       return {
23052         text: missing,
23053         locale: "en"
23054       };
23055     };
23056     localizer.hasTextForStringId = function(stringId) {
23057       return !!localizer.tInfo(stringId, { default: "nothing found" }).locale;
23058     };
23059     localizer.t = function(stringId, replacements, locale2) {
23060       return localizer.tInfo(stringId, replacements, locale2).text;
23061     };
23062     localizer.t.html = function(stringId, replacements, locale2) {
23063       replacements = Object.assign({}, replacements);
23064       for (var k2 in replacements) {
23065         if (typeof replacements[k2] === "string") {
23066           replacements[k2] = escape_default(replacements[k2]);
23067         }
23068         if (typeof replacements[k2] === "object" && typeof replacements[k2].html === "string") {
23069           replacements[k2] = replacements[k2].html;
23070         }
23071       }
23072       const info = localizer.tInfo(stringId, replacements, locale2);
23073       if (info.text) {
23074         return '<span class="localized-text" lang="'.concat(info.locale || "und", '">').concat(info.text, "</span>");
23075       } else {
23076         return "";
23077       }
23078     };
23079     localizer.t.append = function(stringId, replacements, locale2) {
23080       const ret = function(selection2) {
23081         const info = localizer.tInfo(stringId, replacements, locale2);
23082         return selection2.append("span").attr("class", "localized-text").attr("lang", info.locale || "und").text((replacements && replacements.prefix || "") + info.text + (replacements && replacements.suffix || ""));
23083       };
23084       ret.stringId = stringId;
23085       return ret;
23086     };
23087     localizer.t.addOrUpdate = function(stringId, replacements, locale2) {
23088       const ret = function(selection2) {
23089         const info = localizer.tInfo(stringId, replacements, locale2);
23090         const span = selection2.selectAll("span.localized-text").data([info]);
23091         const enter = span.enter().append("span").classed("localized-text", true);
23092         span.merge(enter).attr("lang", info.locale || "und").text((replacements && replacements.prefix || "") + info.text + (replacements && replacements.suffix || ""));
23093       };
23094       ret.stringId = stringId;
23095       return ret;
23096     };
23097     localizer.languageName = (code, options2) => {
23098       if (_languageNames && _languageNames[code]) {
23099         return _languageNames[code];
23100       }
23101       if (options2 && options2.localOnly) return null;
23102       const langInfo = _dataLanguages[code];
23103       if (langInfo) {
23104         if (langInfo.nativeName) {
23105           return localizer.t("translate.language_and_code", { language: langInfo.nativeName, code });
23106         } else if (langInfo.base && langInfo.script) {
23107           const base = langInfo.base;
23108           if (_languageNames && _languageNames[base]) {
23109             const scriptCode = langInfo.script;
23110             const script = _scriptNames && _scriptNames[scriptCode] || scriptCode;
23111             return localizer.t("translate.language_and_code", { language: _languageNames[base], code: script });
23112           } else if (_dataLanguages[base] && _dataLanguages[base].nativeName) {
23113             return localizer.t("translate.language_and_code", { language: _dataLanguages[base].nativeName, code });
23114           }
23115         }
23116       }
23117       return code;
23118     };
23119     localizer.floatFormatter = (locale2) => {
23120       if (!("Intl" in window && "NumberFormat" in Intl && "formatToParts" in Intl.NumberFormat.prototype)) {
23121         return (number3, fractionDigits) => {
23122           return fractionDigits === void 0 ? number3.toString() : number3.toFixed(fractionDigits);
23123         };
23124       } else {
23125         return (number3, fractionDigits) => number3.toLocaleString(locale2, {
23126           minimumFractionDigits: fractionDigits,
23127           maximumFractionDigits: fractionDigits === void 0 ? 20 : fractionDigits
23128         });
23129       }
23130     };
23131     localizer.floatParser = (locale2) => {
23132       const polyfill = (string) => +string.trim();
23133       if (!("Intl" in window && "NumberFormat" in Intl)) return polyfill;
23134       const format2 = new Intl.NumberFormat(locale2, { maximumFractionDigits: 20 });
23135       if (!("formatToParts" in format2)) return polyfill;
23136       const parts = format2.formatToParts(-12345.6);
23137       const numerals = Array.from({ length: 10 }).map((_2, i3) => format2.format(i3));
23138       const index = new Map(numerals.map((d2, i3) => [d2, i3]));
23139       const literalPart = parts.find((d2) => d2.type === "literal");
23140       const literal = literalPart && new RegExp("[".concat(literalPart.value, "]"), "g");
23141       const groupPart = parts.find((d2) => d2.type === "group");
23142       const group = groupPart && new RegExp("[".concat(groupPart.value, "]"), "g");
23143       const decimalPart = parts.find((d2) => d2.type === "decimal");
23144       const decimal = decimalPart && new RegExp("[".concat(decimalPart.value, "]"));
23145       const numeral = new RegExp("[".concat(numerals.join(""), "]"), "g");
23146       const getIndex = (d2) => index.get(d2);
23147       return (string) => {
23148         string = string.trim();
23149         if (literal) string = string.replace(literal, "");
23150         if (group) string = string.replace(group, "");
23151         if (decimal) string = string.replace(decimal, ".");
23152         string = string.replace(numeral, getIndex);
23153         return string ? +string : NaN;
23154       };
23155     };
23156     localizer.decimalPlaceCounter = (locale2) => {
23157       var literal, group, decimal;
23158       if ("Intl" in window && "NumberFormat" in Intl) {
23159         const format2 = new Intl.NumberFormat(locale2, { maximumFractionDigits: 20 });
23160         if ("formatToParts" in format2) {
23161           const parts = format2.formatToParts(-12345.6);
23162           const literalPart = parts.find((d2) => d2.type === "literal");
23163           literal = literalPart && new RegExp("[".concat(literalPart.value, "]"), "g");
23164           const groupPart = parts.find((d2) => d2.type === "group");
23165           group = groupPart && new RegExp("[".concat(groupPart.value, "]"), "g");
23166           const decimalPart = parts.find((d2) => d2.type === "decimal");
23167           decimal = decimalPart && new RegExp("[".concat(decimalPart.value, "]"));
23168         }
23169       }
23170       return (string) => {
23171         string = string.trim();
23172         if (literal) string = string.replace(literal, "");
23173         if (group) string = string.replace(group, "");
23174         const parts = string.split(decimal || ".");
23175         return parts && parts[1] && parts[1].length || 0;
23176       };
23177     };
23178     return localizer;
23179   }
23180
23181   // modules/util/util.js
23182   function utilTagText(entity) {
23183     var obj = entity && entity.tags || {};
23184     return Object.keys(obj).map(function(k2) {
23185       return k2 + "=" + obj[k2];
23186     }).join(", ");
23187   }
23188   function utilTotalExtent(array2, graph) {
23189     var extent = geoExtent();
23190     var val, entity;
23191     for (var i3 = 0; i3 < array2.length; i3++) {
23192       val = array2[i3];
23193       entity = typeof val === "string" ? graph.hasEntity(val) : val;
23194       if (entity) {
23195         extent._extend(entity.extent(graph));
23196       }
23197     }
23198     return extent;
23199   }
23200   function utilTagDiff(oldTags, newTags) {
23201     var tagDiff = [];
23202     var keys2 = utilArrayUnion(Object.keys(oldTags), Object.keys(newTags)).sort();
23203     keys2.forEach(function(k2) {
23204       var oldVal = oldTags[k2];
23205       var newVal = newTags[k2];
23206       if ((oldVal || oldVal === "") && (newVal === void 0 || newVal !== oldVal)) {
23207         tagDiff.push({
23208           type: "-",
23209           key: k2,
23210           oldVal,
23211           newVal,
23212           display: "- " + k2 + "=" + oldVal
23213         });
23214       }
23215       if ((newVal || newVal === "") && (oldVal === void 0 || newVal !== oldVal)) {
23216         tagDiff.push({
23217           type: "+",
23218           key: k2,
23219           oldVal,
23220           newVal,
23221           display: "+ " + k2 + "=" + newVal
23222         });
23223       }
23224     });
23225     return tagDiff;
23226   }
23227   function utilEntitySelector(ids) {
23228     return ids.length ? "." + ids.join(",.") : "nothing";
23229   }
23230   function utilEntityOrMemberSelector(ids, graph) {
23231     var seen = new Set(ids);
23232     ids.forEach(collectShallowDescendants);
23233     return utilEntitySelector(Array.from(seen));
23234     function collectShallowDescendants(id2) {
23235       var entity = graph.hasEntity(id2);
23236       if (!entity || entity.type !== "relation") return;
23237       entity.members.map(function(member) {
23238         return member.id;
23239       }).forEach(function(id3) {
23240         seen.add(id3);
23241       });
23242     }
23243   }
23244   function utilEntityOrDeepMemberSelector(ids, graph) {
23245     return utilEntitySelector(utilEntityAndDeepMemberIDs(ids, graph));
23246   }
23247   function utilEntityAndDeepMemberIDs(ids, graph) {
23248     var seen = /* @__PURE__ */ new Set();
23249     ids.forEach(collectDeepDescendants);
23250     return Array.from(seen);
23251     function collectDeepDescendants(id2) {
23252       if (seen.has(id2)) return;
23253       seen.add(id2);
23254       var entity = graph.hasEntity(id2);
23255       if (!entity || entity.type !== "relation") return;
23256       entity.members.map(function(member) {
23257         return member.id;
23258       }).forEach(collectDeepDescendants);
23259     }
23260   }
23261   function utilDeepMemberSelector(ids, graph, skipMultipolgonMembers) {
23262     var idsSet = new Set(ids);
23263     var seen = /* @__PURE__ */ new Set();
23264     var returners = /* @__PURE__ */ new Set();
23265     ids.forEach(collectDeepDescendants);
23266     return utilEntitySelector(Array.from(returners));
23267     function collectDeepDescendants(id2) {
23268       if (seen.has(id2)) return;
23269       seen.add(id2);
23270       if (!idsSet.has(id2)) {
23271         returners.add(id2);
23272       }
23273       var entity = graph.hasEntity(id2);
23274       if (!entity || entity.type !== "relation") return;
23275       if (skipMultipolgonMembers && entity.isMultipolygon()) return;
23276       entity.members.map(function(member) {
23277         return member.id;
23278       }).forEach(collectDeepDescendants);
23279     }
23280   }
23281   function utilHighlightEntities(ids, highlighted, context) {
23282     context.surface().selectAll(utilEntityOrDeepMemberSelector(ids, context.graph())).classed("highlighted", highlighted);
23283   }
23284   function utilGetAllNodes(ids, graph) {
23285     var seen = /* @__PURE__ */ new Set();
23286     var nodes = /* @__PURE__ */ new Set();
23287     ids.forEach(collectNodes);
23288     return Array.from(nodes);
23289     function collectNodes(id2) {
23290       if (seen.has(id2)) return;
23291       seen.add(id2);
23292       var entity = graph.hasEntity(id2);
23293       if (!entity) return;
23294       if (entity.type === "node") {
23295         nodes.add(entity);
23296       } else if (entity.type === "way") {
23297         entity.nodes.forEach(collectNodes);
23298       } else {
23299         entity.members.map(function(member) {
23300           return member.id;
23301         }).forEach(collectNodes);
23302       }
23303     }
23304   }
23305   function utilDisplayName(entity, hideNetwork) {
23306     var localizedNameKey = "name:" + _mainLocalizer.languageCode().toLowerCase();
23307     var name = entity.tags[localizedNameKey] || entity.tags.name || "";
23308     var tags = {
23309       direction: entity.tags.direction,
23310       from: entity.tags.from,
23311       name,
23312       network: hideNetwork ? void 0 : entity.tags.cycle_network || entity.tags.network,
23313       ref: entity.tags.ref,
23314       to: entity.tags.to,
23315       via: entity.tags.via
23316     };
23317     if (entity.tags.route && entity.tags.name && entity.tags.name.match(/[→⇒↔⇔]|[-=]>/)) {
23318       return entity.tags.name;
23319     }
23320     if (!entity.tags.route && name) {
23321       return name;
23322     }
23323     var keyComponents = [];
23324     if (tags.network) {
23325       keyComponents.push("network");
23326     }
23327     if (tags.ref) {
23328       keyComponents.push("ref");
23329     }
23330     if (tags.name) {
23331       keyComponents.push("name");
23332     }
23333     if (entity.tags.route) {
23334       if (tags.direction) {
23335         keyComponents.push("direction");
23336       } else if (tags.from && tags.to) {
23337         keyComponents.push("from");
23338         keyComponents.push("to");
23339         if (tags.via) {
23340           keyComponents.push("via");
23341         }
23342       }
23343     }
23344     if (keyComponents.length) {
23345       name = _t("inspector.display_name." + keyComponents.join("_"), tags);
23346     }
23347     return name;
23348   }
23349   function utilDisplayNameForPath(entity) {
23350     var name = utilDisplayName(entity);
23351     var isFirefox = utilDetect().browser.toLowerCase().indexOf("firefox") > -1;
23352     var isNewChromium = Number(utilDetect().version.split(".")[0]) >= 96;
23353     if (!isFirefox && !isNewChromium && name && rtlRegex.test(name)) {
23354       name = fixRTLTextForSvg(name);
23355     }
23356     return name;
23357   }
23358   function utilDisplayType(id2) {
23359     return {
23360       n: _t("inspector.node"),
23361       w: _t("inspector.way"),
23362       r: _t("inspector.relation")
23363     }[id2.charAt(0)];
23364   }
23365   function utilEntityRoot(entityType) {
23366     return {
23367       node: "n",
23368       way: "w",
23369       relation: "r"
23370     }[entityType];
23371   }
23372   function utilCombinedTags(entityIDs, graph) {
23373     var tags = {};
23374     var tagCounts = {};
23375     var allKeys = /* @__PURE__ */ new Set();
23376     var entities = entityIDs.map(function(entityID) {
23377       return graph.hasEntity(entityID);
23378     }).filter(Boolean);
23379     entities.forEach(function(entity) {
23380       var keys2 = Object.keys(entity.tags).filter(Boolean);
23381       keys2.forEach(function(key2) {
23382         allKeys.add(key2);
23383       });
23384     });
23385     entities.forEach(function(entity) {
23386       allKeys.forEach(function(key2) {
23387         var value = entity.tags[key2];
23388         if (!tags.hasOwnProperty(key2)) {
23389           tags[key2] = value;
23390         } else {
23391           if (!Array.isArray(tags[key2])) {
23392             if (tags[key2] !== value) {
23393               tags[key2] = [tags[key2], value];
23394             }
23395           } else {
23396             if (tags[key2].indexOf(value) === -1) {
23397               tags[key2].push(value);
23398             }
23399           }
23400         }
23401         var tagHash = key2 + "=" + value;
23402         if (!tagCounts[tagHash]) tagCounts[tagHash] = 0;
23403         tagCounts[tagHash] += 1;
23404       });
23405     });
23406     for (var key in tags) {
23407       if (!Array.isArray(tags[key])) continue;
23408       tags[key] = tags[key].sort(function(val12, val2) {
23409         var key2 = key2;
23410         var count2 = tagCounts[key2 + "=" + val2];
23411         var count1 = tagCounts[key2 + "=" + val12];
23412         if (count2 !== count1) {
23413           return count2 - count1;
23414         }
23415         if (val2 && val12) {
23416           return val12.localeCompare(val2);
23417         }
23418         return val12 ? 1 : -1;
23419       });
23420     }
23421     return tags;
23422   }
23423   function utilStringQs(str) {
23424     var i3 = 0;
23425     while (i3 < str.length && (str[i3] === "?" || str[i3] === "#")) i3++;
23426     str = str.slice(i3);
23427     return str.split("&").reduce(function(obj, pair3) {
23428       var parts = pair3.split("=");
23429       if (parts.length === 2) {
23430         obj[parts[0]] = null === parts[1] ? "" : decodeURIComponent(parts[1]);
23431       }
23432       return obj;
23433     }, {});
23434   }
23435   function utilQsString(obj, noencode) {
23436     function softEncode(s2) {
23437       return encodeURIComponent(s2).replace(/(%2F|%3A|%2C|%7B|%7D)/g, decodeURIComponent);
23438     }
23439     return Object.keys(obj).sort().map(function(key) {
23440       return encodeURIComponent(key) + "=" + (noencode ? softEncode(obj[key]) : encodeURIComponent(obj[key]));
23441     }).join("&");
23442   }
23443   function utilPrefixDOMProperty(property) {
23444     var prefixes2 = ["webkit", "ms", "moz", "o"];
23445     var i3 = -1;
23446     var n3 = prefixes2.length;
23447     var s2 = document.body;
23448     if (property in s2) return property;
23449     property = property.slice(0, 1).toUpperCase() + property.slice(1);
23450     while (++i3 < n3) {
23451       if (prefixes2[i3] + property in s2) {
23452         return prefixes2[i3] + property;
23453       }
23454     }
23455     return false;
23456   }
23457   function utilPrefixCSSProperty(property) {
23458     var prefixes2 = ["webkit", "ms", "Moz", "O"];
23459     var i3 = -1;
23460     var n3 = prefixes2.length;
23461     var s2 = document.body.style;
23462     if (property.toLowerCase() in s2) {
23463       return property.toLowerCase();
23464     }
23465     while (++i3 < n3) {
23466       if (prefixes2[i3] + property in s2) {
23467         return "-" + prefixes2[i3].toLowerCase() + property.replace(/([A-Z])/g, "-$1").toLowerCase();
23468       }
23469     }
23470     return false;
23471   }
23472   var transformProperty;
23473   function utilSetTransform(el, x2, y2, scale) {
23474     var prop = transformProperty = transformProperty || utilPrefixCSSProperty("Transform");
23475     var translate = utilDetect().opera ? "translate(" + x2 + "px," + y2 + "px)" : "translate3d(" + x2 + "px," + y2 + "px,0)";
23476     return el.style(prop, translate + (scale ? " scale(" + scale + ")" : ""));
23477   }
23478   function utilEditDistance(a2, b2) {
23479     a2 = (0, import_diacritics.remove)(a2.toLowerCase());
23480     b2 = (0, import_diacritics.remove)(b2.toLowerCase());
23481     if (a2.length === 0) return b2.length;
23482     if (b2.length === 0) return a2.length;
23483     var matrix = [];
23484     var i3, j2;
23485     for (i3 = 0; i3 <= b2.length; i3++) {
23486       matrix[i3] = [i3];
23487     }
23488     for (j2 = 0; j2 <= a2.length; j2++) {
23489       matrix[0][j2] = j2;
23490     }
23491     for (i3 = 1; i3 <= b2.length; i3++) {
23492       for (j2 = 1; j2 <= a2.length; j2++) {
23493         if (b2.charAt(i3 - 1) === a2.charAt(j2 - 1)) {
23494           matrix[i3][j2] = matrix[i3 - 1][j2 - 1];
23495         } else {
23496           matrix[i3][j2] = Math.min(
23497             matrix[i3 - 1][j2 - 1] + 1,
23498             // substitution
23499             Math.min(
23500               matrix[i3][j2 - 1] + 1,
23501               // insertion
23502               matrix[i3 - 1][j2] + 1
23503             )
23504           );
23505         }
23506       }
23507     }
23508     return matrix[b2.length][a2.length];
23509   }
23510   function utilFastMouse(container) {
23511     var rect = container.getBoundingClientRect();
23512     var rectLeft = rect.left;
23513     var rectTop = rect.top;
23514     var clientLeft = +container.clientLeft;
23515     var clientTop = +container.clientTop;
23516     return function(e3) {
23517       return [
23518         e3.clientX - rectLeft - clientLeft,
23519         e3.clientY - rectTop - clientTop
23520       ];
23521     };
23522   }
23523   function utilAsyncMap(inputs, func, callback) {
23524     var remaining = inputs.length;
23525     var results = [];
23526     var errors = [];
23527     inputs.forEach(function(d2, i3) {
23528       func(d2, function done(err, data) {
23529         errors[i3] = err;
23530         results[i3] = data;
23531         remaining--;
23532         if (!remaining) callback(errors, results);
23533       });
23534     });
23535   }
23536   function utilWrap(index, length2) {
23537     if (index < 0) {
23538       index += Math.ceil(-index / length2) * length2;
23539     }
23540     return index % length2;
23541   }
23542   function utilFunctor(value) {
23543     if (typeof value === "function") return value;
23544     return function() {
23545       return value;
23546     };
23547   }
23548   function utilNoAuto(selection2) {
23549     var isText = selection2.size() && selection2.node().tagName.toLowerCase() === "textarea";
23550     return selection2.attr("autocomplete", "new-password").attr("autocorrect", "off").attr("autocapitalize", "off").attr("data-1p-ignore", "true").attr("data-bwignore", "true").attr("data-form-type", "other").attr("data-lpignore", "true").attr("spellcheck", isText ? "true" : "false");
23551   }
23552   function utilHashcode(str) {
23553     var hash2 = 0;
23554     if (str.length === 0) {
23555       return hash2;
23556     }
23557     for (var i3 = 0; i3 < str.length; i3++) {
23558       var char = str.charCodeAt(i3);
23559       hash2 = (hash2 << 5) - hash2 + char;
23560       hash2 = hash2 & hash2;
23561     }
23562     return hash2;
23563   }
23564   function utilSafeClassName(str) {
23565     return str.toLowerCase().replace(/[^a-z0-9]+/g, "_");
23566   }
23567   function utilUniqueDomId(val) {
23568     return "ideditor-" + utilSafeClassName(val.toString()) + "-" + (/* @__PURE__ */ new Date()).getTime().toString();
23569   }
23570   function utilUnicodeCharsCount(str) {
23571     return Array.from(str).length;
23572   }
23573   function utilUnicodeCharsTruncated(str, limit) {
23574     return Array.from(str).slice(0, limit).join("");
23575   }
23576   function toNumericID(id2) {
23577     var match = id2.match(/^[cnwr](-?\d+)$/);
23578     if (match) {
23579       return parseInt(match[1], 10);
23580     }
23581     return NaN;
23582   }
23583   function compareNumericIDs(left, right) {
23584     if (isNaN(left) && isNaN(right)) return -1;
23585     if (isNaN(left)) return 1;
23586     if (isNaN(right)) return -1;
23587     if (Math.sign(left) !== Math.sign(right)) return -Math.sign(left);
23588     if (Math.sign(left) < 0) return Math.sign(right - left);
23589     return Math.sign(left - right);
23590   }
23591   function utilCompareIDs(left, right) {
23592     return compareNumericIDs(toNumericID(left), toNumericID(right));
23593   }
23594   function utilOldestID(ids) {
23595     if (ids.length === 0) {
23596       return void 0;
23597     }
23598     var oldestIDIndex = 0;
23599     var oldestID = toNumericID(ids[0]);
23600     for (var i3 = 1; i3 < ids.length; i3++) {
23601       var num = toNumericID(ids[i3]);
23602       if (compareNumericIDs(oldestID, num) === 1) {
23603         oldestIDIndex = i3;
23604         oldestID = num;
23605       }
23606     }
23607     return ids[oldestIDIndex];
23608   }
23609   function utilCleanOsmString(val, maxChars) {
23610     if (val === void 0 || val === null) {
23611       val = "";
23612     } else {
23613       val = val.toString();
23614     }
23615     val = val.trim();
23616     if (val.normalize) val = val.normalize("NFC");
23617     return utilUnicodeCharsTruncated(val, maxChars);
23618   }
23619
23620   // modules/osm/entity.js
23621   function osmEntity(attrs) {
23622     if (this instanceof osmEntity) return;
23623     if (attrs && attrs.type) {
23624       return osmEntity[attrs.type].apply(this, arguments);
23625     } else if (attrs && attrs.id) {
23626       return osmEntity[osmEntity.id.type(attrs.id)].apply(this, arguments);
23627     }
23628     return new osmEntity().initialize(arguments);
23629   }
23630   osmEntity.id = function(type2) {
23631     return osmEntity.id.fromOSM(type2, osmEntity.id.next[type2]--);
23632   };
23633   osmEntity.id.next = {
23634     changeset: -1,
23635     node: -1,
23636     way: -1,
23637     relation: -1
23638   };
23639   osmEntity.id.fromOSM = function(type2, id2) {
23640     return type2[0] + id2;
23641   };
23642   osmEntity.id.toOSM = function(id2) {
23643     var match = id2.match(/^[cnwr](-?\d+)$/);
23644     if (match) {
23645       return match[1];
23646     }
23647     return "";
23648   };
23649   osmEntity.id.type = function(id2) {
23650     return { "c": "changeset", "n": "node", "w": "way", "r": "relation" }[id2[0]];
23651   };
23652   osmEntity.key = function(entity) {
23653     return entity.id + "v" + (entity.v || 0);
23654   };
23655   var _deprecatedTagValuesByKey;
23656   osmEntity.deprecatedTagValuesByKey = function(dataDeprecated) {
23657     if (!_deprecatedTagValuesByKey) {
23658       _deprecatedTagValuesByKey = {};
23659       dataDeprecated.forEach(function(d2) {
23660         var oldKeys = Object.keys(d2.old);
23661         if (oldKeys.length === 1) {
23662           var oldKey = oldKeys[0];
23663           var oldValue = d2.old[oldKey];
23664           if (oldValue !== "*") {
23665             if (!_deprecatedTagValuesByKey[oldKey]) {
23666               _deprecatedTagValuesByKey[oldKey] = [oldValue];
23667             } else {
23668               _deprecatedTagValuesByKey[oldKey].push(oldValue);
23669             }
23670           }
23671         }
23672       });
23673     }
23674     return _deprecatedTagValuesByKey;
23675   };
23676   osmEntity.prototype = {
23677     tags: {},
23678     initialize: function(sources) {
23679       for (var i3 = 0; i3 < sources.length; ++i3) {
23680         var source = sources[i3];
23681         for (var prop in source) {
23682           if (Object.prototype.hasOwnProperty.call(source, prop)) {
23683             if (source[prop] === void 0) {
23684               delete this[prop];
23685             } else {
23686               this[prop] = source[prop];
23687             }
23688           }
23689         }
23690       }
23691       if (!this.id && this.type) {
23692         this.id = osmEntity.id(this.type);
23693       }
23694       if (!this.hasOwnProperty("visible")) {
23695         this.visible = true;
23696       }
23697       if (debug) {
23698         Object.freeze(this);
23699         Object.freeze(this.tags);
23700         if (this.loc) Object.freeze(this.loc);
23701         if (this.nodes) Object.freeze(this.nodes);
23702         if (this.members) Object.freeze(this.members);
23703       }
23704       return this;
23705     },
23706     copy: function(resolver, copies) {
23707       if (copies[this.id]) return copies[this.id];
23708       var copy2 = osmEntity(this, { id: void 0, user: void 0, version: void 0 });
23709       copies[this.id] = copy2;
23710       return copy2;
23711     },
23712     osmId: function() {
23713       return osmEntity.id.toOSM(this.id);
23714     },
23715     isNew: function() {
23716       var osmId = osmEntity.id.toOSM(this.id);
23717       return osmId.length === 0 || osmId[0] === "-";
23718     },
23719     update: function(attrs) {
23720       return osmEntity(this, attrs, { v: 1 + (this.v || 0) });
23721     },
23722     mergeTags: function(tags) {
23723       var merged = Object.assign({}, this.tags);
23724       var changed = false;
23725       for (var k2 in tags) {
23726         var t1 = merged[k2];
23727         var t2 = tags[k2];
23728         if (!t1) {
23729           changed = true;
23730           merged[k2] = t2;
23731         } else if (t1 !== t2) {
23732           changed = true;
23733           merged[k2] = utilUnicodeCharsTruncated(
23734             utilArrayUnion(t1.split(/;\s*/), t2.split(/;\s*/)).join(";"),
23735             255
23736             // avoid exceeding character limit; see also context.maxCharsForTagValue()
23737           );
23738         }
23739       }
23740       return changed ? this.update({ tags: merged }) : this;
23741     },
23742     intersects: function(extent, resolver) {
23743       return this.extent(resolver).intersects(extent);
23744     },
23745     hasNonGeometryTags: function() {
23746       return Object.keys(this.tags).some(function(k2) {
23747         return k2 !== "area";
23748       });
23749     },
23750     hasParentRelations: function(resolver) {
23751       return resolver.parentRelations(this).length > 0;
23752     },
23753     hasInterestingTags: function() {
23754       return Object.keys(this.tags).some(osmIsInterestingTag);
23755     },
23756     isHighwayIntersection: function() {
23757       return false;
23758     },
23759     isDegenerate: function() {
23760       return true;
23761     },
23762     deprecatedTags: function(dataDeprecated) {
23763       var tags = this.tags;
23764       if (Object.keys(tags).length === 0) return [];
23765       var deprecated = [];
23766       dataDeprecated.forEach(function(d2) {
23767         var oldKeys = Object.keys(d2.old);
23768         if (d2.replace) {
23769           var hasExistingValues = Object.keys(d2.replace).some(function(replaceKey) {
23770             if (!tags[replaceKey] || d2.old[replaceKey]) return false;
23771             var replaceValue = d2.replace[replaceKey];
23772             if (replaceValue === "*") return false;
23773             if (replaceValue === tags[replaceKey]) return false;
23774             return true;
23775           });
23776           if (hasExistingValues) return;
23777         }
23778         var matchesDeprecatedTags = oldKeys.every(function(oldKey) {
23779           if (!tags[oldKey]) return false;
23780           if (d2.old[oldKey] === "*") return true;
23781           if (d2.old[oldKey] === tags[oldKey]) return true;
23782           var vals = tags[oldKey].split(";").filter(Boolean);
23783           if (vals.length === 0) {
23784             return false;
23785           } else if (vals.length > 1) {
23786             return vals.indexOf(d2.old[oldKey]) !== -1;
23787           } else {
23788             if (tags[oldKey] === d2.old[oldKey]) {
23789               if (d2.replace && d2.old[oldKey] === d2.replace[oldKey]) {
23790                 var replaceKeys = Object.keys(d2.replace);
23791                 return !replaceKeys.every(function(replaceKey) {
23792                   return tags[replaceKey] === d2.replace[replaceKey];
23793                 });
23794               } else {
23795                 return true;
23796               }
23797             }
23798           }
23799           return false;
23800         });
23801         if (matchesDeprecatedTags) {
23802           deprecated.push(d2);
23803         }
23804       });
23805       return deprecated;
23806     }
23807   };
23808
23809   // modules/osm/lanes.js
23810   function osmLanes(entity) {
23811     if (entity.type !== "way") return null;
23812     if (!entity.tags.highway) return null;
23813     var tags = entity.tags;
23814     var isOneWay = entity.isOneWay();
23815     var laneCount = getLaneCount(tags, isOneWay);
23816     var maxspeed = parseMaxspeed(tags);
23817     var laneDirections = parseLaneDirections(tags, isOneWay, laneCount);
23818     var forward = laneDirections.forward;
23819     var backward = laneDirections.backward;
23820     var bothways = laneDirections.bothways;
23821     var turnLanes = {};
23822     turnLanes.unspecified = parseTurnLanes(tags["turn:lanes"]);
23823     turnLanes.forward = parseTurnLanes(tags["turn:lanes:forward"]);
23824     turnLanes.backward = parseTurnLanes(tags["turn:lanes:backward"]);
23825     var maxspeedLanes = {};
23826     maxspeedLanes.unspecified = parseMaxspeedLanes(tags["maxspeed:lanes"], maxspeed);
23827     maxspeedLanes.forward = parseMaxspeedLanes(tags["maxspeed:lanes:forward"], maxspeed);
23828     maxspeedLanes.backward = parseMaxspeedLanes(tags["maxspeed:lanes:backward"], maxspeed);
23829     var psvLanes = {};
23830     psvLanes.unspecified = parseMiscLanes(tags["psv:lanes"]);
23831     psvLanes.forward = parseMiscLanes(tags["psv:lanes:forward"]);
23832     psvLanes.backward = parseMiscLanes(tags["psv:lanes:backward"]);
23833     var busLanes = {};
23834     busLanes.unspecified = parseMiscLanes(tags["bus:lanes"]);
23835     busLanes.forward = parseMiscLanes(tags["bus:lanes:forward"]);
23836     busLanes.backward = parseMiscLanes(tags["bus:lanes:backward"]);
23837     var taxiLanes = {};
23838     taxiLanes.unspecified = parseMiscLanes(tags["taxi:lanes"]);
23839     taxiLanes.forward = parseMiscLanes(tags["taxi:lanes:forward"]);
23840     taxiLanes.backward = parseMiscLanes(tags["taxi:lanes:backward"]);
23841     var hovLanes = {};
23842     hovLanes.unspecified = parseMiscLanes(tags["hov:lanes"]);
23843     hovLanes.forward = parseMiscLanes(tags["hov:lanes:forward"]);
23844     hovLanes.backward = parseMiscLanes(tags["hov:lanes:backward"]);
23845     var hgvLanes = {};
23846     hgvLanes.unspecified = parseMiscLanes(tags["hgv:lanes"]);
23847     hgvLanes.forward = parseMiscLanes(tags["hgv:lanes:forward"]);
23848     hgvLanes.backward = parseMiscLanes(tags["hgv:lanes:backward"]);
23849     var bicyclewayLanes = {};
23850     bicyclewayLanes.unspecified = parseBicycleWay(tags["bicycleway:lanes"]);
23851     bicyclewayLanes.forward = parseBicycleWay(tags["bicycleway:lanes:forward"]);
23852     bicyclewayLanes.backward = parseBicycleWay(tags["bicycleway:lanes:backward"]);
23853     var lanesObj = {
23854       forward: [],
23855       backward: [],
23856       unspecified: []
23857     };
23858     mapToLanesObj(lanesObj, turnLanes, "turnLane");
23859     mapToLanesObj(lanesObj, maxspeedLanes, "maxspeed");
23860     mapToLanesObj(lanesObj, psvLanes, "psv");
23861     mapToLanesObj(lanesObj, busLanes, "bus");
23862     mapToLanesObj(lanesObj, taxiLanes, "taxi");
23863     mapToLanesObj(lanesObj, hovLanes, "hov");
23864     mapToLanesObj(lanesObj, hgvLanes, "hgv");
23865     mapToLanesObj(lanesObj, bicyclewayLanes, "bicycleway");
23866     return {
23867       metadata: {
23868         count: laneCount,
23869         oneway: isOneWay,
23870         forward,
23871         backward,
23872         bothways,
23873         turnLanes,
23874         maxspeed,
23875         maxspeedLanes,
23876         psvLanes,
23877         busLanes,
23878         taxiLanes,
23879         hovLanes,
23880         hgvLanes,
23881         bicyclewayLanes
23882       },
23883       lanes: lanesObj
23884     };
23885   }
23886   function getLaneCount(tags, isOneWay) {
23887     var count;
23888     if (tags.lanes) {
23889       count = parseInt(tags.lanes, 10);
23890       if (count > 0) {
23891         return count;
23892       }
23893     }
23894     switch (tags.highway) {
23895       case "trunk":
23896       case "motorway":
23897         count = isOneWay ? 2 : 4;
23898         break;
23899       default:
23900         count = isOneWay ? 1 : 2;
23901         break;
23902     }
23903     return count;
23904   }
23905   function parseMaxspeed(tags) {
23906     var maxspeed = tags.maxspeed;
23907     if (!maxspeed) return;
23908     var maxspeedRegex = /^([0-9][\.0-9]+?)(?:[ ]?(?:km\/h|kmh|kph|mph|knots))?$/;
23909     if (!maxspeedRegex.test(maxspeed)) return;
23910     return parseInt(maxspeed, 10);
23911   }
23912   function parseLaneDirections(tags, isOneWay, laneCount) {
23913     var forward = parseInt(tags["lanes:forward"], 10);
23914     var backward = parseInt(tags["lanes:backward"], 10);
23915     var bothways = parseInt(tags["lanes:both_ways"], 10) > 0 ? 1 : 0;
23916     if (parseInt(tags.oneway, 10) === -1) {
23917       forward = 0;
23918       bothways = 0;
23919       backward = laneCount;
23920     } else if (isOneWay) {
23921       forward = laneCount;
23922       bothways = 0;
23923       backward = 0;
23924     } else if (isNaN(forward) && isNaN(backward)) {
23925       backward = Math.floor((laneCount - bothways) / 2);
23926       forward = laneCount - bothways - backward;
23927     } else if (isNaN(forward)) {
23928       if (backward > laneCount - bothways) {
23929         backward = laneCount - bothways;
23930       }
23931       forward = laneCount - bothways - backward;
23932     } else if (isNaN(backward)) {
23933       if (forward > laneCount - bothways) {
23934         forward = laneCount - bothways;
23935       }
23936       backward = laneCount - bothways - forward;
23937     }
23938     return {
23939       forward,
23940       backward,
23941       bothways
23942     };
23943   }
23944   function parseTurnLanes(tag2) {
23945     if (!tag2) return;
23946     var validValues = [
23947       "left",
23948       "slight_left",
23949       "sharp_left",
23950       "through",
23951       "right",
23952       "slight_right",
23953       "sharp_right",
23954       "reverse",
23955       "merge_to_left",
23956       "merge_to_right",
23957       "none"
23958     ];
23959     return tag2.split("|").map(function(s2) {
23960       if (s2 === "") s2 = "none";
23961       return s2.split(";").map(function(d2) {
23962         return validValues.indexOf(d2) === -1 ? "unknown" : d2;
23963       });
23964     });
23965   }
23966   function parseMaxspeedLanes(tag2, maxspeed) {
23967     if (!tag2) return;
23968     return tag2.split("|").map(function(s2) {
23969       if (s2 === "none") return s2;
23970       var m2 = parseInt(s2, 10);
23971       if (s2 === "" || m2 === maxspeed) return null;
23972       return isNaN(m2) ? "unknown" : m2;
23973     });
23974   }
23975   function parseMiscLanes(tag2) {
23976     if (!tag2) return;
23977     var validValues = [
23978       "yes",
23979       "no",
23980       "designated"
23981     ];
23982     return tag2.split("|").map(function(s2) {
23983       if (s2 === "") s2 = "no";
23984       return validValues.indexOf(s2) === -1 ? "unknown" : s2;
23985     });
23986   }
23987   function parseBicycleWay(tag2) {
23988     if (!tag2) return;
23989     var validValues = [
23990       "yes",
23991       "no",
23992       "designated",
23993       "lane"
23994     ];
23995     return tag2.split("|").map(function(s2) {
23996       if (s2 === "") s2 = "no";
23997       return validValues.indexOf(s2) === -1 ? "unknown" : s2;
23998     });
23999   }
24000   function mapToLanesObj(lanesObj, data, key) {
24001     if (data.forward) {
24002       data.forward.forEach(function(l2, i3) {
24003         if (!lanesObj.forward[i3]) lanesObj.forward[i3] = {};
24004         lanesObj.forward[i3][key] = l2;
24005       });
24006     }
24007     if (data.backward) {
24008       data.backward.forEach(function(l2, i3) {
24009         if (!lanesObj.backward[i3]) lanesObj.backward[i3] = {};
24010         lanesObj.backward[i3][key] = l2;
24011       });
24012     }
24013     if (data.unspecified) {
24014       data.unspecified.forEach(function(l2, i3) {
24015         if (!lanesObj.unspecified[i3]) lanesObj.unspecified[i3] = {};
24016         lanesObj.unspecified[i3][key] = l2;
24017       });
24018     }
24019   }
24020
24021   // modules/osm/way.js
24022   function osmWay() {
24023     if (!(this instanceof osmWay)) {
24024       return new osmWay().initialize(arguments);
24025     } else if (arguments.length) {
24026       this.initialize(arguments);
24027     }
24028   }
24029   osmEntity.way = osmWay;
24030   osmWay.prototype = Object.create(osmEntity.prototype);
24031   Object.assign(osmWay.prototype, {
24032     type: "way",
24033     nodes: [],
24034     copy: function(resolver, copies) {
24035       if (copies[this.id]) return copies[this.id];
24036       var copy2 = osmEntity.prototype.copy.call(this, resolver, copies);
24037       var nodes = this.nodes.map(function(id2) {
24038         return resolver.entity(id2).copy(resolver, copies).id;
24039       });
24040       copy2 = copy2.update({ nodes });
24041       copies[this.id] = copy2;
24042       return copy2;
24043     },
24044     extent: function(resolver) {
24045       return resolver.transient(this, "extent", function() {
24046         var extent = geoExtent();
24047         for (var i3 = 0; i3 < this.nodes.length; i3++) {
24048           var node = resolver.hasEntity(this.nodes[i3]);
24049           if (node) {
24050             extent._extend(node.extent());
24051           }
24052         }
24053         return extent;
24054       });
24055     },
24056     first: function() {
24057       return this.nodes[0];
24058     },
24059     last: function() {
24060       return this.nodes[this.nodes.length - 1];
24061     },
24062     contains: function(node) {
24063       return this.nodes.indexOf(node) >= 0;
24064     },
24065     affix: function(node) {
24066       if (this.nodes[0] === node) return "prefix";
24067       if (this.nodes[this.nodes.length - 1] === node) return "suffix";
24068     },
24069     layer: function() {
24070       if (isFinite(this.tags.layer)) {
24071         return Math.max(-10, Math.min(+this.tags.layer, 10));
24072       }
24073       if (this.tags.covered === "yes") return -1;
24074       if (this.tags.location === "overground") return 1;
24075       if (this.tags.location === "underground") return -1;
24076       if (this.tags.location === "underwater") return -10;
24077       if (this.tags.power === "line") return 10;
24078       if (this.tags.power === "minor_line") return 10;
24079       if (this.tags.aerialway) return 10;
24080       if (this.tags.bridge) return 1;
24081       if (this.tags.cutting) return -1;
24082       if (this.tags.tunnel) return -1;
24083       if (this.tags.waterway) return -1;
24084       if (this.tags.man_made === "pipeline") return -10;
24085       if (this.tags.boundary) return -10;
24086       return 0;
24087     },
24088     // the approximate width of the line based on its tags except its `width` tag
24089     impliedLineWidthMeters: function() {
24090       var averageWidths = {
24091         highway: {
24092           // width is for single lane
24093           motorway: 5,
24094           motorway_link: 5,
24095           trunk: 4.5,
24096           trunk_link: 4.5,
24097           primary: 4,
24098           secondary: 4,
24099           tertiary: 4,
24100           primary_link: 4,
24101           secondary_link: 4,
24102           tertiary_link: 4,
24103           unclassified: 4,
24104           road: 4,
24105           living_street: 4,
24106           bus_guideway: 4,
24107           busway: 4,
24108           pedestrian: 4,
24109           residential: 3.5,
24110           service: 3.5,
24111           track: 3,
24112           cycleway: 2.5,
24113           bridleway: 2,
24114           corridor: 2,
24115           steps: 2,
24116           path: 1.5,
24117           footway: 1.5,
24118           ladder: 0.5
24119         },
24120         railway: {
24121           // width includes ties and rail bed, not just track gauge
24122           rail: 2.5,
24123           light_rail: 2.5,
24124           tram: 2.5,
24125           subway: 2.5,
24126           monorail: 2.5,
24127           funicular: 2.5,
24128           disused: 2.5,
24129           preserved: 2.5,
24130           miniature: 1.5,
24131           narrow_gauge: 1.5
24132         },
24133         waterway: {
24134           river: 50,
24135           canal: 25,
24136           stream: 5,
24137           tidal_channel: 5,
24138           fish_pass: 2.5,
24139           drain: 2.5,
24140           ditch: 1.5
24141         }
24142       };
24143       for (var key in averageWidths) {
24144         if (this.tags[key] && averageWidths[key][this.tags[key]]) {
24145           var width = averageWidths[key][this.tags[key]];
24146           if (key === "highway") {
24147             var laneCount = this.tags.lanes && parseInt(this.tags.lanes, 10);
24148             if (!laneCount) laneCount = this.isOneWay() ? 1 : 2;
24149             return width * laneCount;
24150           }
24151           return width;
24152         }
24153       }
24154       return null;
24155     },
24156     isOneWay: function() {
24157       var values = {
24158         "yes": true,
24159         "1": true,
24160         "-1": true,
24161         "reversible": true,
24162         "alternating": true,
24163         "no": false,
24164         "0": false
24165       };
24166       if (values[this.tags.oneway] !== void 0) {
24167         return values[this.tags.oneway];
24168       }
24169       for (var key in this.tags) {
24170         if (key in osmOneWayTags && this.tags[key] in osmOneWayTags[key]) {
24171           return true;
24172         }
24173       }
24174       return false;
24175     },
24176     // Some identifier for tag that implies that this way is "sided",
24177     // i.e. the right side is the 'inside' (e.g. the right side of a
24178     // natural=cliff is lower).
24179     sidednessIdentifier: function() {
24180       for (const realKey in this.tags) {
24181         const value = this.tags[realKey];
24182         const key = osmRemoveLifecyclePrefix(realKey);
24183         if (key in osmRightSideIsInsideTags && value in osmRightSideIsInsideTags[key]) {
24184           if (osmRightSideIsInsideTags[key][value] === true) {
24185             return key;
24186           } else {
24187             return osmRightSideIsInsideTags[key][value];
24188           }
24189         }
24190       }
24191       return null;
24192     },
24193     isSided: function() {
24194       if (this.tags.two_sided === "yes") {
24195         return false;
24196       }
24197       return this.sidednessIdentifier() !== null;
24198     },
24199     lanes: function() {
24200       return osmLanes(this);
24201     },
24202     isClosed: function() {
24203       return this.nodes.length > 1 && this.first() === this.last();
24204     },
24205     isConvex: function(resolver) {
24206       if (!this.isClosed() || this.isDegenerate()) return null;
24207       var nodes = utilArrayUniq(resolver.childNodes(this));
24208       var coords = nodes.map(function(n3) {
24209         return n3.loc;
24210       });
24211       var curr = 0;
24212       var prev = 0;
24213       for (var i3 = 0; i3 < coords.length; i3++) {
24214         var o2 = coords[(i3 + 1) % coords.length];
24215         var a2 = coords[i3];
24216         var b2 = coords[(i3 + 2) % coords.length];
24217         var res = geoVecCross(a2, b2, o2);
24218         curr = res > 0 ? 1 : res < 0 ? -1 : 0;
24219         if (curr === 0) {
24220           continue;
24221         } else if (prev && curr !== prev) {
24222           return false;
24223         }
24224         prev = curr;
24225       }
24226       return true;
24227     },
24228     // returns an object with the tag that implies this is an area, if any
24229     tagSuggestingArea: function() {
24230       return osmTagSuggestingArea(this.tags);
24231     },
24232     isArea: function() {
24233       if (this.tags.area === "yes") return true;
24234       if (!this.isClosed() || this.tags.area === "no") return false;
24235       return this.tagSuggestingArea() !== null;
24236     },
24237     isDegenerate: function() {
24238       return new Set(this.nodes).size < (this.isArea() ? 3 : 2);
24239     },
24240     areAdjacent: function(n1, n22) {
24241       for (var i3 = 0; i3 < this.nodes.length; i3++) {
24242         if (this.nodes[i3] === n1) {
24243           if (this.nodes[i3 - 1] === n22) return true;
24244           if (this.nodes[i3 + 1] === n22) return true;
24245         }
24246       }
24247       return false;
24248     },
24249     geometry: function(graph) {
24250       return graph.transient(this, "geometry", function() {
24251         return this.isArea() ? "area" : "line";
24252       });
24253     },
24254     // returns an array of objects representing the segments between the nodes in this way
24255     segments: function(graph) {
24256       function segmentExtent(graph2) {
24257         var n1 = graph2.hasEntity(this.nodes[0]);
24258         var n22 = graph2.hasEntity(this.nodes[1]);
24259         return n1 && n22 && geoExtent([
24260           [
24261             Math.min(n1.loc[0], n22.loc[0]),
24262             Math.min(n1.loc[1], n22.loc[1])
24263           ],
24264           [
24265             Math.max(n1.loc[0], n22.loc[0]),
24266             Math.max(n1.loc[1], n22.loc[1])
24267           ]
24268         ]);
24269       }
24270       return graph.transient(this, "segments", function() {
24271         var segments = [];
24272         for (var i3 = 0; i3 < this.nodes.length - 1; i3++) {
24273           segments.push({
24274             id: this.id + "-" + i3,
24275             wayId: this.id,
24276             index: i3,
24277             nodes: [this.nodes[i3], this.nodes[i3 + 1]],
24278             extent: segmentExtent
24279           });
24280         }
24281         return segments;
24282       });
24283     },
24284     // If this way is not closed, append the beginning node to the end of the nodelist to close it.
24285     close: function() {
24286       if (this.isClosed() || !this.nodes.length) return this;
24287       var nodes = this.nodes.slice();
24288       nodes = nodes.filter(noRepeatNodes);
24289       nodes.push(nodes[0]);
24290       return this.update({ nodes });
24291     },
24292     // If this way is closed, remove any connector nodes from the end of the nodelist to unclose it.
24293     unclose: function() {
24294       if (!this.isClosed()) return this;
24295       var nodes = this.nodes.slice();
24296       var connector = this.first();
24297       var i3 = nodes.length - 1;
24298       while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
24299         nodes.splice(i3, 1);
24300         i3 = nodes.length - 1;
24301       }
24302       nodes = nodes.filter(noRepeatNodes);
24303       return this.update({ nodes });
24304     },
24305     // Adds a node (id) in front of the node which is currently at position index.
24306     // If index is undefined, the node will be added to the end of the way for linear ways,
24307     //   or just before the final connecting node for circular ways.
24308     // Consecutive duplicates are eliminated including existing ones.
24309     // Circularity is always preserved when adding a node.
24310     addNode: function(id2, index) {
24311       var nodes = this.nodes.slice();
24312       var isClosed = this.isClosed();
24313       var max3 = isClosed ? nodes.length - 1 : nodes.length;
24314       if (index === void 0) {
24315         index = max3;
24316       }
24317       if (index < 0 || index > max3) {
24318         throw new RangeError("index " + index + " out of range 0.." + max3);
24319       }
24320       if (isClosed) {
24321         var connector = this.first();
24322         var i3 = 1;
24323         while (i3 < nodes.length && nodes.length > 2 && nodes[i3] === connector) {
24324           nodes.splice(i3, 1);
24325           if (index > i3) index--;
24326         }
24327         i3 = nodes.length - 1;
24328         while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
24329           nodes.splice(i3, 1);
24330           if (index > i3) index--;
24331           i3 = nodes.length - 1;
24332         }
24333       }
24334       nodes.splice(index, 0, id2);
24335       nodes = nodes.filter(noRepeatNodes);
24336       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
24337         nodes.push(nodes[0]);
24338       }
24339       return this.update({ nodes });
24340     },
24341     // Replaces the node which is currently at position index with the given node (id).
24342     // Consecutive duplicates are eliminated including existing ones.
24343     // Circularity is preserved when updating a node.
24344     updateNode: function(id2, index) {
24345       var nodes = this.nodes.slice();
24346       var isClosed = this.isClosed();
24347       var max3 = nodes.length - 1;
24348       if (index === void 0 || index < 0 || index > max3) {
24349         throw new RangeError("index " + index + " out of range 0.." + max3);
24350       }
24351       if (isClosed) {
24352         var connector = this.first();
24353         var i3 = 1;
24354         while (i3 < nodes.length && nodes.length > 2 && nodes[i3] === connector) {
24355           nodes.splice(i3, 1);
24356           if (index > i3) index--;
24357         }
24358         i3 = nodes.length - 1;
24359         while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
24360           nodes.splice(i3, 1);
24361           if (index === i3) index = 0;
24362           i3 = nodes.length - 1;
24363         }
24364       }
24365       nodes.splice(index, 1, id2);
24366       nodes = nodes.filter(noRepeatNodes);
24367       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
24368         nodes.push(nodes[0]);
24369       }
24370       return this.update({ nodes });
24371     },
24372     // Replaces each occurrence of node id needle with replacement.
24373     // Consecutive duplicates are eliminated including existing ones.
24374     // Circularity is preserved.
24375     replaceNode: function(needleID, replacementID) {
24376       var nodes = this.nodes.slice();
24377       var isClosed = this.isClosed();
24378       for (var i3 = 0; i3 < nodes.length; i3++) {
24379         if (nodes[i3] === needleID) {
24380           nodes[i3] = replacementID;
24381         }
24382       }
24383       nodes = nodes.filter(noRepeatNodes);
24384       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
24385         nodes.push(nodes[0]);
24386       }
24387       return this.update({ nodes });
24388     },
24389     // Removes each occurrence of node id.
24390     // Consecutive duplicates are eliminated including existing ones.
24391     // Circularity is preserved.
24392     removeNode: function(id2) {
24393       var nodes = this.nodes.slice();
24394       var isClosed = this.isClosed();
24395       nodes = nodes.filter(function(node) {
24396         return node !== id2;
24397       }).filter(noRepeatNodes);
24398       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
24399         nodes.push(nodes[0]);
24400       }
24401       return this.update({ nodes });
24402     },
24403     asJXON: function(changeset_id) {
24404       var r2 = {
24405         way: {
24406           "@id": this.osmId(),
24407           "@version": this.version || 0,
24408           nd: this.nodes.map(function(id2) {
24409             return { keyAttributes: { ref: osmEntity.id.toOSM(id2) } };
24410           }, this),
24411           tag: Object.keys(this.tags).map(function(k2) {
24412             return { keyAttributes: { k: k2, v: this.tags[k2] } };
24413           }, this)
24414         }
24415       };
24416       if (changeset_id) {
24417         r2.way["@changeset"] = changeset_id;
24418       }
24419       return r2;
24420     },
24421     asGeoJSON: function(resolver) {
24422       return resolver.transient(this, "GeoJSON", function() {
24423         var coordinates = resolver.childNodes(this).map(function(n3) {
24424           return n3.loc;
24425         });
24426         if (this.isArea() && this.isClosed()) {
24427           return {
24428             type: "Polygon",
24429             coordinates: [coordinates]
24430           };
24431         } else {
24432           return {
24433             type: "LineString",
24434             coordinates
24435           };
24436         }
24437       });
24438     },
24439     area: function(resolver) {
24440       return resolver.transient(this, "area", function() {
24441         var nodes = resolver.childNodes(this);
24442         var json = {
24443           type: "Polygon",
24444           coordinates: [nodes.map(function(n3) {
24445             return n3.loc;
24446           })]
24447         };
24448         if (!this.isClosed() && nodes.length) {
24449           json.coordinates[0].push(nodes[0].loc);
24450         }
24451         var area = area_default(json);
24452         if (area > 2 * Math.PI) {
24453           json.coordinates[0] = json.coordinates[0].reverse();
24454           area = area_default(json);
24455         }
24456         return isNaN(area) ? 0 : area;
24457       });
24458     }
24459   });
24460   function noRepeatNodes(node, i3, arr) {
24461     return i3 === 0 || node !== arr[i3 - 1];
24462   }
24463
24464   // modules/osm/multipolygon.js
24465   function osmJoinWays(toJoin, graph) {
24466     function resolve(member) {
24467       return graph.childNodes(graph.entity(member.id));
24468     }
24469     function reverse(item2) {
24470       var action = actionReverse(item2.id, { reverseOneway: true });
24471       sequences.actions.push(action);
24472       return item2 instanceof osmWay ? action(graph).entity(item2.id) : item2;
24473     }
24474     toJoin = toJoin.filter(function(member) {
24475       return member.type === "way" && graph.hasEntity(member.id);
24476     });
24477     var i3;
24478     var joinAsMembers = true;
24479     for (i3 = 0; i3 < toJoin.length; i3++) {
24480       if (toJoin[i3] instanceof osmWay) {
24481         joinAsMembers = false;
24482         break;
24483       }
24484     }
24485     var sequences = [];
24486     sequences.actions = [];
24487     while (toJoin.length) {
24488       var item = toJoin.shift();
24489       var currWays = [item];
24490       var currNodes = resolve(item).slice();
24491       while (toJoin.length) {
24492         var start2 = currNodes[0];
24493         var end = currNodes[currNodes.length - 1];
24494         var fn = null;
24495         var nodes = null;
24496         for (i3 = 0; i3 < toJoin.length; i3++) {
24497           item = toJoin[i3];
24498           nodes = resolve(item);
24499           if (joinAsMembers && currWays.length === 1 && nodes[0] !== end && nodes[nodes.length - 1] !== end && (nodes[nodes.length - 1] === start2 || nodes[0] === start2)) {
24500             currWays[0] = reverse(currWays[0]);
24501             currNodes.reverse();
24502             start2 = currNodes[0];
24503             end = currNodes[currNodes.length - 1];
24504           }
24505           if (nodes[0] === end) {
24506             fn = currNodes.push;
24507             nodes = nodes.slice(1);
24508             break;
24509           } else if (nodes[nodes.length - 1] === end) {
24510             fn = currNodes.push;
24511             nodes = nodes.slice(0, -1).reverse();
24512             item = reverse(item);
24513             break;
24514           } else if (nodes[nodes.length - 1] === start2) {
24515             fn = currNodes.unshift;
24516             nodes = nodes.slice(0, -1);
24517             break;
24518           } else if (nodes[0] === start2) {
24519             fn = currNodes.unshift;
24520             nodes = nodes.slice(1).reverse();
24521             item = reverse(item);
24522             break;
24523           } else {
24524             fn = nodes = null;
24525           }
24526         }
24527         if (!nodes) {
24528           break;
24529         }
24530         fn.apply(currWays, [item]);
24531         fn.apply(currNodes, nodes);
24532         toJoin.splice(i3, 1);
24533       }
24534       currWays.nodes = currNodes;
24535       sequences.push(currWays);
24536     }
24537     return sequences;
24538   }
24539
24540   // modules/actions/add_member.js
24541   function actionAddMember(relationId, member, memberIndex) {
24542     return function action(graph) {
24543       var relation = graph.entity(relationId);
24544       var isPTv2 = /stop|platform/.test(member.role);
24545       if (member.type === "way" && !isPTv2) {
24546         graph = addWayMember(relation, graph);
24547       } else {
24548         if (isPTv2 && isNaN(memberIndex)) {
24549           memberIndex = 0;
24550         }
24551         graph = graph.replace(relation.addMember(member, memberIndex));
24552       }
24553       return graph;
24554     };
24555     function addWayMember(relation, graph) {
24556       var groups, item, i3, j2, k2;
24557       var PTv2members = [];
24558       var members = [];
24559       for (i3 = 0; i3 < relation.members.length; i3++) {
24560         var m2 = relation.members[i3];
24561         if (/stop|platform/.test(m2.role)) {
24562           PTv2members.push(m2);
24563         } else {
24564           members.push(m2);
24565         }
24566       }
24567       relation = relation.update({ members });
24568       groups = utilArrayGroupBy(relation.members, "type");
24569       groups.way = groups.way || [];
24570       groups.way.push(member);
24571       members = withIndex(groups.way);
24572       var joined = osmJoinWays(members, graph);
24573       for (i3 = 0; i3 < joined.length; i3++) {
24574         var segment = joined[i3];
24575         var nodes = segment.nodes.slice();
24576         var startIndex = segment[0].index;
24577         for (j2 = 0; j2 < members.length; j2++) {
24578           if (members[j2].index === startIndex) {
24579             break;
24580           }
24581         }
24582         for (k2 = 0; k2 < segment.length; k2++) {
24583           item = segment[k2];
24584           var way = graph.entity(item.id);
24585           if (k2 > 0) {
24586             if (j2 + k2 >= members.length || item.index !== members[j2 + k2].index) {
24587               moveMember(members, item.index, j2 + k2);
24588             }
24589           }
24590           nodes.splice(0, way.nodes.length - 1);
24591         }
24592       }
24593       var wayMembers = [];
24594       for (i3 = 0; i3 < members.length; i3++) {
24595         item = members[i3];
24596         if (item.index === -1) continue;
24597         wayMembers.push(utilObjectOmit(item, ["index"]));
24598       }
24599       var newMembers = PTv2members.concat(groups.node || [], wayMembers, groups.relation || []);
24600       return graph.replace(relation.update({ members: newMembers }));
24601       function moveMember(arr, findIndex, toIndex) {
24602         var i4;
24603         for (i4 = 0; i4 < arr.length; i4++) {
24604           if (arr[i4].index === findIndex) {
24605             break;
24606           }
24607         }
24608         var item2 = Object.assign({}, arr[i4]);
24609         arr[i4].index = -1;
24610         delete item2.index;
24611         arr.splice(toIndex, 0, item2);
24612       }
24613       function withIndex(arr) {
24614         var result = new Array(arr.length);
24615         for (var i4 = 0; i4 < arr.length; i4++) {
24616           result[i4] = Object.assign({}, arr[i4]);
24617           result[i4].index = i4;
24618         }
24619         return result;
24620       }
24621     }
24622   }
24623
24624   // modules/actions/add_midpoint.js
24625   function actionAddMidpoint(midpoint, node) {
24626     return function(graph) {
24627       graph = graph.replace(node.move(midpoint.loc));
24628       var parents = utilArrayIntersection(
24629         graph.parentWays(graph.entity(midpoint.edge[0])),
24630         graph.parentWays(graph.entity(midpoint.edge[1]))
24631       );
24632       parents.forEach(function(way) {
24633         for (var i3 = 0; i3 < way.nodes.length - 1; i3++) {
24634           if (geoEdgeEqual([way.nodes[i3], way.nodes[i3 + 1]], midpoint.edge)) {
24635             graph = graph.replace(graph.entity(way.id).addNode(node.id, i3 + 1));
24636             return;
24637           }
24638         }
24639       });
24640       return graph;
24641     };
24642   }
24643
24644   // modules/actions/add_vertex.js
24645   function actionAddVertex(wayId, nodeId, index) {
24646     return function(graph) {
24647       return graph.replace(graph.entity(wayId).addNode(nodeId, index));
24648     };
24649   }
24650
24651   // modules/actions/change_member.js
24652   function actionChangeMember(relationId, member, memberIndex) {
24653     return function(graph) {
24654       return graph.replace(graph.entity(relationId).updateMember(member, memberIndex));
24655     };
24656   }
24657
24658   // modules/actions/change_preset.js
24659   function actionChangePreset(entityID, oldPreset, newPreset, skipFieldDefaults) {
24660     return function action(graph) {
24661       var entity = graph.entity(entityID);
24662       var geometry = entity.geometry(graph);
24663       var tags = entity.tags;
24664       const loc = entity.extent(graph).center();
24665       var preserveKeys;
24666       if (newPreset) {
24667         preserveKeys = [];
24668         if (newPreset.addTags) {
24669           preserveKeys = preserveKeys.concat(Object.keys(newPreset.addTags));
24670         }
24671         if (oldPreset && !oldPreset.id.startsWith(newPreset.id)) {
24672           newPreset.fields(loc).concat(newPreset.moreFields(loc)).filter((f2) => f2.matchGeometry(geometry)).map((f2) => f2.key).filter(Boolean).forEach((key) => preserveKeys.push(key));
24673         }
24674       }
24675       if (oldPreset) tags = oldPreset.unsetTags(tags, geometry, preserveKeys, false, loc);
24676       if (newPreset) tags = newPreset.setTags(tags, geometry, skipFieldDefaults, loc);
24677       return graph.replace(entity.update({ tags }));
24678     };
24679   }
24680
24681   // modules/actions/change_tags.js
24682   function actionChangeTags(entityId, tags) {
24683     return function(graph) {
24684       var entity = graph.entity(entityId);
24685       return graph.replace(entity.update({ tags }));
24686     };
24687   }
24688
24689   // modules/osm/node.js
24690   var cardinal = {
24691     north: 0,
24692     n: 0,
24693     northnortheast: 22,
24694     nne: 22,
24695     northeast: 45,
24696     ne: 45,
24697     eastnortheast: 67,
24698     ene: 67,
24699     east: 90,
24700     e: 90,
24701     eastsoutheast: 112,
24702     ese: 112,
24703     southeast: 135,
24704     se: 135,
24705     southsoutheast: 157,
24706     sse: 157,
24707     south: 180,
24708     s: 180,
24709     southsouthwest: 202,
24710     ssw: 202,
24711     southwest: 225,
24712     sw: 225,
24713     westsouthwest: 247,
24714     wsw: 247,
24715     west: 270,
24716     w: 270,
24717     westnorthwest: 292,
24718     wnw: 292,
24719     northwest: 315,
24720     nw: 315,
24721     northnorthwest: 337,
24722     nnw: 337
24723   };
24724   function osmNode() {
24725     if (!(this instanceof osmNode)) {
24726       return new osmNode().initialize(arguments);
24727     } else if (arguments.length) {
24728       this.initialize(arguments);
24729     }
24730   }
24731   osmEntity.node = osmNode;
24732   osmNode.prototype = Object.create(osmEntity.prototype);
24733   Object.assign(osmNode.prototype, {
24734     type: "node",
24735     loc: [9999, 9999],
24736     extent: function() {
24737       return new geoExtent(this.loc);
24738     },
24739     geometry: function(graph) {
24740       return graph.transient(this, "geometry", function() {
24741         return graph.isPoi(this) ? "point" : "vertex";
24742       });
24743     },
24744     move: function(loc) {
24745       return this.update({ loc });
24746     },
24747     isDegenerate: function() {
24748       return !(Array.isArray(this.loc) && this.loc.length === 2 && this.loc[0] >= -180 && this.loc[0] <= 180 && this.loc[1] >= -90 && this.loc[1] <= 90);
24749     },
24750     // Inspect tags and geometry to determine which direction(s) this node/vertex points
24751     directions: function(resolver, projection2) {
24752       var val;
24753       var i3;
24754       if (this.isHighwayIntersection(resolver) && (this.tags.stop || "").toLowerCase() === "all") {
24755         val = "all";
24756       } else {
24757         val = (this.tags.direction || "").toLowerCase();
24758         var re3 = /:direction$/i;
24759         var keys2 = Object.keys(this.tags);
24760         for (i3 = 0; i3 < keys2.length; i3++) {
24761           if (re3.test(keys2[i3])) {
24762             val = this.tags[keys2[i3]].toLowerCase();
24763             break;
24764           }
24765         }
24766       }
24767       if (val === "") return [];
24768       var values = val.split(";");
24769       var results = [];
24770       values.forEach(function(v2) {
24771         if (cardinal[v2] !== void 0) {
24772           v2 = cardinal[v2];
24773         }
24774         if (v2 !== "" && !isNaN(+v2)) {
24775           results.push(+v2);
24776           return;
24777         }
24778         var lookBackward = this.tags["traffic_sign:backward"] || v2 === "backward" || v2 === "both" || v2 === "all";
24779         var lookForward = this.tags["traffic_sign:forward"] || v2 === "forward" || v2 === "both" || v2 === "all";
24780         if (!lookForward && !lookBackward) return;
24781         var nodeIds = {};
24782         resolver.parentWays(this).filter((p2) => this.tags.highway || this.tags.traffic_sign || this.tags.traffic_calming || this.tags.barrier || this.tags.cycleway ? p2.tags.highway : true).filter((p2) => this.tags.railway ? p2.tags.railway : true).filter((p2) => this.tags.waterway ? p2.tags.waterway : true).forEach(function(parent) {
24783           var nodes = parent.nodes;
24784           for (i3 = 0; i3 < nodes.length; i3++) {
24785             if (nodes[i3] === this.id) {
24786               if (lookForward && i3 > 0) {
24787                 nodeIds[nodes[i3 - 1]] = true;
24788               }
24789               if (lookBackward && i3 < nodes.length - 1) {
24790                 nodeIds[nodes[i3 + 1]] = true;
24791               }
24792             }
24793           }
24794         }, this);
24795         Object.keys(nodeIds).forEach(function(nodeId) {
24796           results.push(
24797             geoAngle(this, resolver.entity(nodeId), projection2) * (180 / Math.PI) + 90
24798           );
24799         }, this);
24800       }, this);
24801       return utilArrayUniq(results);
24802     },
24803     isCrossing: function() {
24804       return this.tags.highway === "crossing" || this.tags.railway && this.tags.railway.indexOf("crossing") !== -1;
24805     },
24806     isEndpoint: function(resolver) {
24807       return resolver.transient(this, "isEndpoint", function() {
24808         var id2 = this.id;
24809         return resolver.parentWays(this).filter(function(parent) {
24810           return !parent.isClosed() && !!parent.affix(id2);
24811         }).length > 0;
24812       });
24813     },
24814     isConnected: function(resolver) {
24815       return resolver.transient(this, "isConnected", function() {
24816         var parents = resolver.parentWays(this);
24817         if (parents.length > 1) {
24818           for (var i3 in parents) {
24819             if (parents[i3].geometry(resolver) === "line" && parents[i3].hasInterestingTags()) return true;
24820           }
24821         } else if (parents.length === 1) {
24822           var way = parents[0];
24823           var nodes = way.nodes.slice();
24824           if (way.isClosed()) {
24825             nodes.pop();
24826           }
24827           return nodes.indexOf(this.id) !== nodes.lastIndexOf(this.id);
24828         }
24829         return false;
24830       });
24831     },
24832     parentIntersectionWays: function(resolver) {
24833       return resolver.transient(this, "parentIntersectionWays", function() {
24834         return resolver.parentWays(this).filter(function(parent) {
24835           return (parent.tags.highway || parent.tags.waterway || parent.tags.railway || parent.tags.aeroway) && parent.geometry(resolver) === "line";
24836         });
24837       });
24838     },
24839     isIntersection: function(resolver) {
24840       return this.parentIntersectionWays(resolver).length > 1;
24841     },
24842     isHighwayIntersection: function(resolver) {
24843       return resolver.transient(this, "isHighwayIntersection", function() {
24844         return resolver.parentWays(this).filter(function(parent) {
24845           return parent.tags.highway && parent.geometry(resolver) === "line";
24846         }).length > 1;
24847       });
24848     },
24849     isOnAddressLine: function(resolver) {
24850       return resolver.transient(this, "isOnAddressLine", function() {
24851         return resolver.parentWays(this).filter(function(parent) {
24852           return parent.tags.hasOwnProperty("addr:interpolation") && parent.geometry(resolver) === "line";
24853         }).length > 0;
24854       });
24855     },
24856     asJXON: function(changeset_id) {
24857       var r2 = {
24858         node: {
24859           "@id": this.osmId(),
24860           "@lon": this.loc[0],
24861           "@lat": this.loc[1],
24862           "@version": this.version || 0,
24863           tag: Object.keys(this.tags).map(function(k2) {
24864             return { keyAttributes: { k: k2, v: this.tags[k2] } };
24865           }, this)
24866         }
24867       };
24868       if (changeset_id) r2.node["@changeset"] = changeset_id;
24869       return r2;
24870     },
24871     asGeoJSON: function() {
24872       return {
24873         type: "Point",
24874         coordinates: this.loc
24875       };
24876     }
24877   });
24878
24879   // modules/actions/circularize.js
24880   function actionCircularize(wayId, projection2, maxAngle) {
24881     maxAngle = (maxAngle || 20) * Math.PI / 180;
24882     var action = function(graph, t2) {
24883       if (t2 === null || !isFinite(t2)) t2 = 1;
24884       t2 = Math.min(Math.max(+t2, 0), 1);
24885       var way = graph.entity(wayId);
24886       var origNodes = {};
24887       graph.childNodes(way).forEach(function(node2) {
24888         if (!origNodes[node2.id]) origNodes[node2.id] = node2;
24889       });
24890       if (!way.isConvex(graph)) {
24891         graph = action.makeConvex(graph);
24892       }
24893       var nodes = utilArrayUniq(graph.childNodes(way));
24894       var keyNodes = nodes.filter(function(n3) {
24895         return graph.parentWays(n3).length !== 1;
24896       });
24897       var points = nodes.map(function(n3) {
24898         return projection2(n3.loc);
24899       });
24900       var keyPoints = keyNodes.map(function(n3) {
24901         return projection2(n3.loc);
24902       });
24903       var centroid = points.length === 2 ? geoVecInterp(points[0], points[1], 0.5) : centroid_default2(points);
24904       var radius = median(points, function(p2) {
24905         return geoVecLength(centroid, p2);
24906       });
24907       var sign2 = area_default3(points) > 0 ? 1 : -1;
24908       var ids, i3, j2, k2;
24909       if (!keyNodes.length) {
24910         keyNodes = [nodes[0]];
24911         keyPoints = [points[0]];
24912       }
24913       if (keyNodes.length === 1) {
24914         var index = nodes.indexOf(keyNodes[0]);
24915         var oppositeIndex = Math.floor((index + nodes.length / 2) % nodes.length);
24916         keyNodes.push(nodes[oppositeIndex]);
24917         keyPoints.push(points[oppositeIndex]);
24918       }
24919       for (i3 = 0; i3 < keyPoints.length; i3++) {
24920         var nextKeyNodeIndex = (i3 + 1) % keyNodes.length;
24921         var startNode = keyNodes[i3];
24922         var endNode = keyNodes[nextKeyNodeIndex];
24923         var startNodeIndex = nodes.indexOf(startNode);
24924         var endNodeIndex = nodes.indexOf(endNode);
24925         var numberNewPoints = -1;
24926         var indexRange = endNodeIndex - startNodeIndex;
24927         var nearNodes = {};
24928         var inBetweenNodes = [];
24929         var startAngle, endAngle, totalAngle, eachAngle;
24930         var angle2, loc, node, origNode;
24931         if (indexRange < 0) {
24932           indexRange += nodes.length;
24933         }
24934         var distance = geoVecLength(centroid, keyPoints[i3]) || 1e-4;
24935         keyPoints[i3] = [
24936           centroid[0] + (keyPoints[i3][0] - centroid[0]) / distance * radius,
24937           centroid[1] + (keyPoints[i3][1] - centroid[1]) / distance * radius
24938         ];
24939         loc = projection2.invert(keyPoints[i3]);
24940         node = keyNodes[i3];
24941         origNode = origNodes[node.id];
24942         node = node.move(geoVecInterp(origNode.loc, loc, t2));
24943         graph = graph.replace(node);
24944         startAngle = Math.atan2(keyPoints[i3][1] - centroid[1], keyPoints[i3][0] - centroid[0]);
24945         endAngle = Math.atan2(keyPoints[nextKeyNodeIndex][1] - centroid[1], keyPoints[nextKeyNodeIndex][0] - centroid[0]);
24946         totalAngle = endAngle - startAngle;
24947         if (totalAngle * sign2 > 0) {
24948           totalAngle = -sign2 * (2 * Math.PI - Math.abs(totalAngle));
24949         }
24950         do {
24951           numberNewPoints++;
24952           eachAngle = totalAngle / (indexRange + numberNewPoints);
24953         } while (Math.abs(eachAngle) > maxAngle);
24954         for (j2 = 1; j2 < indexRange; j2++) {
24955           angle2 = startAngle + j2 * eachAngle;
24956           loc = projection2.invert([
24957             centroid[0] + Math.cos(angle2) * radius,
24958             centroid[1] + Math.sin(angle2) * radius
24959           ]);
24960           node = nodes[(j2 + startNodeIndex) % nodes.length];
24961           origNode = origNodes[node.id];
24962           nearNodes[node.id] = angle2;
24963           node = node.move(geoVecInterp(origNode.loc, loc, t2));
24964           graph = graph.replace(node);
24965         }
24966         for (j2 = 0; j2 < numberNewPoints; j2++) {
24967           angle2 = startAngle + (indexRange + j2) * eachAngle;
24968           loc = projection2.invert([
24969             centroid[0] + Math.cos(angle2) * radius,
24970             centroid[1] + Math.sin(angle2) * radius
24971           ]);
24972           var min3 = Infinity;
24973           for (var nodeId in nearNodes) {
24974             var nearAngle = nearNodes[nodeId];
24975             var dist = Math.abs(nearAngle - angle2);
24976             if (dist < min3) {
24977               min3 = dist;
24978               origNode = origNodes[nodeId];
24979             }
24980           }
24981           node = osmNode({ loc: geoVecInterp(origNode.loc, loc, t2) });
24982           graph = graph.replace(node);
24983           nodes.splice(endNodeIndex + j2, 0, node);
24984           inBetweenNodes.push(node.id);
24985         }
24986         if (indexRange === 1 && inBetweenNodes.length) {
24987           var startIndex1 = way.nodes.lastIndexOf(startNode.id);
24988           var endIndex1 = way.nodes.lastIndexOf(endNode.id);
24989           var wayDirection1 = endIndex1 - startIndex1;
24990           if (wayDirection1 < -1) {
24991             wayDirection1 = 1;
24992           }
24993           var parentWays = graph.parentWays(keyNodes[i3]);
24994           for (j2 = 0; j2 < parentWays.length; j2++) {
24995             var sharedWay = parentWays[j2];
24996             if (sharedWay === way) continue;
24997             if (sharedWay.areAdjacent(startNode.id, endNode.id)) {
24998               var startIndex2 = sharedWay.nodes.lastIndexOf(startNode.id);
24999               var endIndex2 = sharedWay.nodes.lastIndexOf(endNode.id);
25000               var wayDirection2 = endIndex2 - startIndex2;
25001               var insertAt = endIndex2;
25002               if (wayDirection2 < -1) {
25003                 wayDirection2 = 1;
25004               }
25005               if (wayDirection1 !== wayDirection2) {
25006                 inBetweenNodes.reverse();
25007                 insertAt = startIndex2;
25008               }
25009               for (k2 = 0; k2 < inBetweenNodes.length; k2++) {
25010                 sharedWay = sharedWay.addNode(inBetweenNodes[k2], insertAt + k2);
25011               }
25012               graph = graph.replace(sharedWay);
25013             }
25014           }
25015         }
25016       }
25017       ids = nodes.map(function(n3) {
25018         return n3.id;
25019       });
25020       ids.push(ids[0]);
25021       way = way.update({ nodes: ids });
25022       graph = graph.replace(way);
25023       return graph;
25024     };
25025     action.makeConvex = function(graph) {
25026       var way = graph.entity(wayId);
25027       var nodes = utilArrayUniq(graph.childNodes(way));
25028       var points = nodes.map(function(n3) {
25029         return projection2(n3.loc);
25030       });
25031       var sign2 = area_default3(points) > 0 ? 1 : -1;
25032       var hull = hull_default(points);
25033       var i3, j2;
25034       if (sign2 === -1) {
25035         nodes.reverse();
25036         points.reverse();
25037       }
25038       for (i3 = 0; i3 < hull.length - 1; i3++) {
25039         var startIndex = points.indexOf(hull[i3]);
25040         var endIndex = points.indexOf(hull[i3 + 1]);
25041         var indexRange = endIndex - startIndex;
25042         if (indexRange < 0) {
25043           indexRange += nodes.length;
25044         }
25045         for (j2 = 1; j2 < indexRange; j2++) {
25046           var point = geoVecInterp(hull[i3], hull[i3 + 1], j2 / indexRange);
25047           var node = nodes[(j2 + startIndex) % nodes.length].move(projection2.invert(point));
25048           graph = graph.replace(node);
25049         }
25050       }
25051       return graph;
25052     };
25053     action.disabled = function(graph) {
25054       if (!graph.entity(wayId).isClosed()) {
25055         return "not_closed";
25056       }
25057       var way = graph.entity(wayId);
25058       var nodes = utilArrayUniq(graph.childNodes(way));
25059       var points = nodes.map(function(n3) {
25060         return projection2(n3.loc);
25061       });
25062       var hull = hull_default(points);
25063       var epsilonAngle = Math.PI / 180;
25064       if (hull.length !== points.length || hull.length < 3) {
25065         return false;
25066       }
25067       var centroid = centroid_default2(points);
25068       var radius = geoVecLengthSquare(centroid, points[0]);
25069       var i3, actualPoint;
25070       for (i3 = 0; i3 < hull.length; i3++) {
25071         actualPoint = hull[i3];
25072         var actualDist = geoVecLengthSquare(actualPoint, centroid);
25073         var diff = Math.abs(actualDist - radius);
25074         if (diff > 0.05 * radius) {
25075           return false;
25076         }
25077       }
25078       for (i3 = 0; i3 < hull.length; i3++) {
25079         actualPoint = hull[i3];
25080         var nextPoint = hull[(i3 + 1) % hull.length];
25081         var startAngle = Math.atan2(actualPoint[1] - centroid[1], actualPoint[0] - centroid[0]);
25082         var endAngle = Math.atan2(nextPoint[1] - centroid[1], nextPoint[0] - centroid[0]);
25083         var angle2 = endAngle - startAngle;
25084         if (angle2 < 0) {
25085           angle2 = -angle2;
25086         }
25087         if (angle2 > Math.PI) {
25088           angle2 = 2 * Math.PI - angle2;
25089         }
25090         if (angle2 > maxAngle + epsilonAngle) {
25091           return false;
25092         }
25093       }
25094       return "already_circular";
25095     };
25096     action.transitionable = true;
25097     return action;
25098   }
25099
25100   // modules/actions/delete_way.js
25101   function actionDeleteWay(wayID) {
25102     function canDeleteNode(node, graph) {
25103       if (graph.parentWays(node).length || graph.parentRelations(node).length) return false;
25104       var geometries = osmNodeGeometriesForTags(node.tags);
25105       if (geometries.point) return false;
25106       if (geometries.vertex) return true;
25107       return !node.hasInterestingTags();
25108     }
25109     var action = function(graph) {
25110       var way = graph.entity(wayID);
25111       graph.parentRelations(way).forEach(function(parent) {
25112         parent = parent.removeMembersWithID(wayID);
25113         graph = graph.replace(parent);
25114         if (parent.isDegenerate()) {
25115           graph = actionDeleteRelation(parent.id)(graph);
25116         }
25117       });
25118       new Set(way.nodes).forEach(function(nodeID) {
25119         graph = graph.replace(way.removeNode(nodeID));
25120         var node = graph.entity(nodeID);
25121         if (canDeleteNode(node, graph)) {
25122           graph = graph.remove(node);
25123         }
25124       });
25125       return graph.remove(way);
25126     };
25127     return action;
25128   }
25129
25130   // modules/actions/delete_multiple.js
25131   function actionDeleteMultiple(ids) {
25132     var actions = {
25133       way: actionDeleteWay,
25134       node: actionDeleteNode,
25135       relation: actionDeleteRelation
25136     };
25137     var action = function(graph) {
25138       ids.forEach(function(id2) {
25139         if (graph.hasEntity(id2)) {
25140           graph = actions[graph.entity(id2).type](id2)(graph);
25141         }
25142       });
25143       return graph;
25144     };
25145     return action;
25146   }
25147
25148   // modules/actions/delete_relation.js
25149   function actionDeleteRelation(relationID, allowUntaggedMembers) {
25150     function canDeleteEntity(entity, graph) {
25151       return !graph.parentWays(entity).length && !graph.parentRelations(entity).length && (!entity.hasInterestingTags() && !allowUntaggedMembers);
25152     }
25153     var action = function(graph) {
25154       var relation = graph.entity(relationID);
25155       graph.parentRelations(relation).forEach(function(parent) {
25156         parent = parent.removeMembersWithID(relationID);
25157         graph = graph.replace(parent);
25158         if (parent.isDegenerate()) {
25159           graph = actionDeleteRelation(parent.id)(graph);
25160         }
25161       });
25162       var memberIDs = utilArrayUniq(relation.members.map(function(m2) {
25163         return m2.id;
25164       }));
25165       memberIDs.forEach(function(memberID) {
25166         graph = graph.replace(relation.removeMembersWithID(memberID));
25167         var entity = graph.entity(memberID);
25168         if (canDeleteEntity(entity, graph)) {
25169           graph = actionDeleteMultiple([memberID])(graph);
25170         }
25171       });
25172       return graph.remove(relation);
25173     };
25174     return action;
25175   }
25176
25177   // modules/actions/delete_node.js
25178   function actionDeleteNode(nodeId) {
25179     var action = function(graph) {
25180       var node = graph.entity(nodeId);
25181       graph.parentWays(node).forEach(function(parent) {
25182         parent = parent.removeNode(nodeId);
25183         graph = graph.replace(parent);
25184         if (parent.isDegenerate()) {
25185           graph = actionDeleteWay(parent.id)(graph);
25186         }
25187       });
25188       graph.parentRelations(node).forEach(function(parent) {
25189         parent = parent.removeMembersWithID(nodeId);
25190         graph = graph.replace(parent);
25191         if (parent.isDegenerate()) {
25192           graph = actionDeleteRelation(parent.id)(graph);
25193         }
25194       });
25195       return graph.remove(node);
25196     };
25197     return action;
25198   }
25199
25200   // modules/actions/connect.js
25201   function actionConnect(nodeIDs) {
25202     var action = function(graph) {
25203       var survivor;
25204       var node;
25205       var parents;
25206       var i3, j2;
25207       nodeIDs.reverse();
25208       var interestingIDs = [];
25209       for (i3 = 0; i3 < nodeIDs.length; i3++) {
25210         node = graph.entity(nodeIDs[i3]);
25211         if (node.hasInterestingTags()) {
25212           if (!node.isNew()) {
25213             interestingIDs.push(node.id);
25214           }
25215         }
25216       }
25217       survivor = graph.entity(utilOldestID(interestingIDs.length > 0 ? interestingIDs : nodeIDs));
25218       for (i3 = 0; i3 < nodeIDs.length; i3++) {
25219         node = graph.entity(nodeIDs[i3]);
25220         if (node.id === survivor.id) continue;
25221         parents = graph.parentWays(node);
25222         for (j2 = 0; j2 < parents.length; j2++) {
25223           graph = graph.replace(parents[j2].replaceNode(node.id, survivor.id));
25224         }
25225         parents = graph.parentRelations(node);
25226         for (j2 = 0; j2 < parents.length; j2++) {
25227           graph = graph.replace(parents[j2].replaceMember(node, survivor));
25228         }
25229         survivor = survivor.mergeTags(node.tags);
25230         graph = actionDeleteNode(node.id)(graph);
25231       }
25232       graph = graph.replace(survivor);
25233       parents = graph.parentWays(survivor);
25234       for (i3 = 0; i3 < parents.length; i3++) {
25235         if (parents[i3].isDegenerate()) {
25236           graph = actionDeleteWay(parents[i3].id)(graph);
25237         }
25238       }
25239       return graph;
25240     };
25241     action.disabled = function(graph) {
25242       var seen = {};
25243       var restrictionIDs = [];
25244       var survivor;
25245       var node, way;
25246       var relations, relation, role;
25247       var i3, j2, k2;
25248       survivor = graph.entity(utilOldestID(nodeIDs));
25249       for (i3 = 0; i3 < nodeIDs.length; i3++) {
25250         node = graph.entity(nodeIDs[i3]);
25251         relations = graph.parentRelations(node);
25252         for (j2 = 0; j2 < relations.length; j2++) {
25253           relation = relations[j2];
25254           role = relation.memberById(node.id).role || "";
25255           if (relation.hasFromViaTo()) {
25256             restrictionIDs.push(relation.id);
25257           }
25258           if (seen[relation.id] !== void 0 && seen[relation.id] !== role) {
25259             return "relation";
25260           } else {
25261             seen[relation.id] = role;
25262           }
25263         }
25264       }
25265       for (i3 = 0; i3 < nodeIDs.length; i3++) {
25266         node = graph.entity(nodeIDs[i3]);
25267         var parents = graph.parentWays(node);
25268         for (j2 = 0; j2 < parents.length; j2++) {
25269           var parent = parents[j2];
25270           relations = graph.parentRelations(parent);
25271           for (k2 = 0; k2 < relations.length; k2++) {
25272             relation = relations[k2];
25273             if (relation.hasFromViaTo()) {
25274               restrictionIDs.push(relation.id);
25275             }
25276           }
25277         }
25278       }
25279       restrictionIDs = utilArrayUniq(restrictionIDs);
25280       for (i3 = 0; i3 < restrictionIDs.length; i3++) {
25281         relation = graph.entity(restrictionIDs[i3]);
25282         if (!relation.isComplete(graph)) continue;
25283         var memberWays = relation.members.filter(function(m2) {
25284           return m2.type === "way";
25285         }).map(function(m2) {
25286           return graph.entity(m2.id);
25287         });
25288         memberWays = utilArrayUniq(memberWays);
25289         var f2 = relation.memberByRole("from");
25290         var t2 = relation.memberByRole("to");
25291         var isUturn = f2.id === t2.id;
25292         var nodes = { from: [], via: [], to: [], keyfrom: [], keyto: [] };
25293         for (j2 = 0; j2 < relation.members.length; j2++) {
25294           collectNodes(relation.members[j2], nodes);
25295         }
25296         nodes.keyfrom = utilArrayUniq(nodes.keyfrom.filter(hasDuplicates));
25297         nodes.keyto = utilArrayUniq(nodes.keyto.filter(hasDuplicates));
25298         var filter2 = keyNodeFilter(nodes.keyfrom, nodes.keyto);
25299         nodes.from = nodes.from.filter(filter2);
25300         nodes.via = nodes.via.filter(filter2);
25301         nodes.to = nodes.to.filter(filter2);
25302         var connectFrom = false;
25303         var connectVia = false;
25304         var connectTo = false;
25305         var connectKeyFrom = false;
25306         var connectKeyTo = false;
25307         for (j2 = 0; j2 < nodeIDs.length; j2++) {
25308           var n3 = nodeIDs[j2];
25309           if (nodes.from.indexOf(n3) !== -1) {
25310             connectFrom = true;
25311           }
25312           if (nodes.via.indexOf(n3) !== -1) {
25313             connectVia = true;
25314           }
25315           if (nodes.to.indexOf(n3) !== -1) {
25316             connectTo = true;
25317           }
25318           if (nodes.keyfrom.indexOf(n3) !== -1) {
25319             connectKeyFrom = true;
25320           }
25321           if (nodes.keyto.indexOf(n3) !== -1) {
25322             connectKeyTo = true;
25323           }
25324         }
25325         if (connectFrom && connectTo && !isUturn) {
25326           return "restriction";
25327         }
25328         if (connectFrom && connectVia) {
25329           return "restriction";
25330         }
25331         if (connectTo && connectVia) {
25332           return "restriction";
25333         }
25334         if (connectKeyFrom || connectKeyTo) {
25335           if (nodeIDs.length !== 2) {
25336             return "restriction";
25337           }
25338           var n0 = null;
25339           var n1 = null;
25340           for (j2 = 0; j2 < memberWays.length; j2++) {
25341             way = memberWays[j2];
25342             if (way.contains(nodeIDs[0])) {
25343               n0 = nodeIDs[0];
25344             }
25345             if (way.contains(nodeIDs[1])) {
25346               n1 = nodeIDs[1];
25347             }
25348           }
25349           if (n0 && n1) {
25350             var ok = false;
25351             for (j2 = 0; j2 < memberWays.length; j2++) {
25352               way = memberWays[j2];
25353               if (way.areAdjacent(n0, n1)) {
25354                 ok = true;
25355                 break;
25356               }
25357             }
25358             if (!ok) {
25359               return "restriction";
25360             }
25361           }
25362         }
25363         for (j2 = 0; j2 < memberWays.length; j2++) {
25364           way = memberWays[j2].update({});
25365           for (k2 = 0; k2 < nodeIDs.length; k2++) {
25366             if (nodeIDs[k2] === survivor.id) continue;
25367             if (way.areAdjacent(nodeIDs[k2], survivor.id)) {
25368               way = way.removeNode(nodeIDs[k2]);
25369             } else {
25370               way = way.replaceNode(nodeIDs[k2], survivor.id);
25371             }
25372           }
25373           if (way.isDegenerate()) {
25374             return "restriction";
25375           }
25376         }
25377       }
25378       return false;
25379       function hasDuplicates(n4, i4, arr) {
25380         return arr.indexOf(n4) !== arr.lastIndexOf(n4);
25381       }
25382       function keyNodeFilter(froms, tos) {
25383         return function(n4) {
25384           return froms.indexOf(n4) === -1 && tos.indexOf(n4) === -1;
25385         };
25386       }
25387       function collectNodes(member, collection) {
25388         var entity = graph.hasEntity(member.id);
25389         if (!entity) return;
25390         var role2 = member.role || "";
25391         if (!collection[role2]) {
25392           collection[role2] = [];
25393         }
25394         if (member.type === "node") {
25395           collection[role2].push(member.id);
25396           if (role2 === "via") {
25397             collection.keyfrom.push(member.id);
25398             collection.keyto.push(member.id);
25399           }
25400         } else if (member.type === "way") {
25401           collection[role2].push.apply(collection[role2], entity.nodes);
25402           if (role2 === "from" || role2 === "via") {
25403             collection.keyfrom.push(entity.first());
25404             collection.keyfrom.push(entity.last());
25405           }
25406           if (role2 === "to" || role2 === "via") {
25407             collection.keyto.push(entity.first());
25408             collection.keyto.push(entity.last());
25409           }
25410         }
25411       }
25412     };
25413     return action;
25414   }
25415
25416   // modules/actions/copy_entities.js
25417   function actionCopyEntities(ids, fromGraph) {
25418     var _copies = {};
25419     var action = function(graph) {
25420       ids.forEach(function(id3) {
25421         fromGraph.entity(id3).copy(fromGraph, _copies);
25422       });
25423       for (var id2 in _copies) {
25424         graph = graph.replace(_copies[id2]);
25425       }
25426       return graph;
25427     };
25428     action.copies = function() {
25429       return _copies;
25430     };
25431     return action;
25432   }
25433
25434   // modules/actions/delete_member.js
25435   function actionDeleteMember(relationId, memberIndex) {
25436     return function(graph) {
25437       var relation = graph.entity(relationId).removeMember(memberIndex);
25438       graph = graph.replace(relation);
25439       if (relation.isDegenerate()) {
25440         graph = actionDeleteRelation(relation.id)(graph);
25441       }
25442       return graph;
25443     };
25444   }
25445
25446   // modules/actions/discard_tags.js
25447   function actionDiscardTags(difference2, discardTags) {
25448     discardTags = discardTags || {};
25449     return (graph) => {
25450       difference2.modified().forEach(checkTags);
25451       difference2.created().forEach(checkTags);
25452       return graph;
25453       function checkTags(entity) {
25454         const keys2 = Object.keys(entity.tags);
25455         let didDiscard = false;
25456         let tags = {};
25457         for (let i3 = 0; i3 < keys2.length; i3++) {
25458           const k2 = keys2[i3];
25459           if (discardTags[k2] || !entity.tags[k2]) {
25460             didDiscard = true;
25461           } else {
25462             tags[k2] = entity.tags[k2];
25463           }
25464         }
25465         if (didDiscard) {
25466           graph = graph.replace(entity.update({ tags }));
25467         }
25468       }
25469     };
25470   }
25471
25472   // modules/actions/disconnect.js
25473   function actionDisconnect(nodeId, newNodeId) {
25474     var wayIds;
25475     var disconnectableRelationTypes = {
25476       "associatedStreet": true,
25477       "enforcement": true,
25478       "site": true
25479     };
25480     var action = function(graph) {
25481       var node = graph.entity(nodeId);
25482       var connections = action.connections(graph);
25483       connections.forEach(function(connection) {
25484         var way = graph.entity(connection.wayID);
25485         var newNode = osmNode({ id: newNodeId, loc: node.loc, tags: node.tags });
25486         graph = graph.replace(newNode);
25487         if (connection.index === 0 && way.isArea()) {
25488           graph = graph.replace(way.replaceNode(way.nodes[0], newNode.id));
25489         } else if (way.isClosed() && connection.index === way.nodes.length - 1) {
25490           graph = graph.replace(way.unclose().addNode(newNode.id));
25491         } else {
25492           graph = graph.replace(way.updateNode(newNode.id, connection.index));
25493         }
25494       });
25495       return graph;
25496     };
25497     action.connections = function(graph) {
25498       var candidates = [];
25499       var keeping = false;
25500       var parentWays = graph.parentWays(graph.entity(nodeId));
25501       var way, waynode;
25502       for (var i3 = 0; i3 < parentWays.length; i3++) {
25503         way = parentWays[i3];
25504         if (wayIds && wayIds.indexOf(way.id) === -1) {
25505           keeping = true;
25506           continue;
25507         }
25508         if (way.isArea() && way.nodes[0] === nodeId) {
25509           candidates.push({ wayID: way.id, index: 0 });
25510         } else {
25511           for (var j2 = 0; j2 < way.nodes.length; j2++) {
25512             waynode = way.nodes[j2];
25513             if (waynode === nodeId) {
25514               if (way.isClosed() && parentWays.length > 1 && wayIds && wayIds.indexOf(way.id) !== -1 && j2 === way.nodes.length - 1) {
25515                 continue;
25516               }
25517               candidates.push({ wayID: way.id, index: j2 });
25518             }
25519           }
25520         }
25521       }
25522       return keeping ? candidates : candidates.slice(1);
25523     };
25524     action.disabled = function(graph) {
25525       var connections = action.connections(graph);
25526       if (connections.length === 0) return "not_connected";
25527       var parentWays = graph.parentWays(graph.entity(nodeId));
25528       var seenRelationIds = {};
25529       var sharedRelation;
25530       parentWays.forEach(function(way) {
25531         var relations = graph.parentRelations(way);
25532         relations.filter((relation) => !disconnectableRelationTypes[relation.tags.type]).forEach(function(relation) {
25533           if (relation.id in seenRelationIds) {
25534             if (wayIds) {
25535               if (wayIds.indexOf(way.id) !== -1 || wayIds.indexOf(seenRelationIds[relation.id]) !== -1) {
25536                 sharedRelation = relation;
25537               }
25538             } else {
25539               sharedRelation = relation;
25540             }
25541           } else {
25542             seenRelationIds[relation.id] = way.id;
25543           }
25544         });
25545       });
25546       if (sharedRelation) return "relation";
25547     };
25548     action.limitWays = function(val) {
25549       if (!arguments.length) return wayIds;
25550       wayIds = val;
25551       return action;
25552     };
25553     return action;
25554   }
25555
25556   // modules/actions/extract.js
25557   function actionExtract(entityID, projection2) {
25558     var extractedNodeID;
25559     var action = function(graph, shiftKeyPressed) {
25560       var entity = graph.entity(entityID);
25561       if (entity.type === "node") {
25562         return extractFromNode(entity, graph, shiftKeyPressed);
25563       }
25564       return extractFromWayOrRelation(entity, graph);
25565     };
25566     function extractFromNode(node, graph, shiftKeyPressed) {
25567       extractedNodeID = node.id;
25568       var replacement = osmNode({ loc: node.loc });
25569       graph = graph.replace(replacement);
25570       graph = graph.parentWays(node).reduce(function(accGraph, parentWay) {
25571         return accGraph.replace(parentWay.replaceNode(entityID, replacement.id));
25572       }, graph);
25573       if (!shiftKeyPressed) return graph;
25574       return graph.parentRelations(node).reduce(function(accGraph, parentRel) {
25575         return accGraph.replace(parentRel.replaceMember(node, replacement));
25576       }, graph);
25577     }
25578     function extractFromWayOrRelation(entity, graph) {
25579       var fromGeometry = entity.geometry(graph);
25580       var keysToCopyAndRetain = ["source", "wheelchair"];
25581       var keysToRetain = ["area"];
25582       var buildingKeysToRetain = ["architect", "building", "height", "layer", "nycdoitt:bin"];
25583       var extractedLoc = path_default(projection2).centroid(entity.asGeoJSON(graph));
25584       extractedLoc = extractedLoc && projection2.invert(extractedLoc);
25585       if (!extractedLoc || !isFinite(extractedLoc[0]) || !isFinite(extractedLoc[1])) {
25586         extractedLoc = entity.extent(graph).center();
25587       }
25588       var indoorAreaValues = {
25589         area: true,
25590         corridor: true,
25591         elevator: true,
25592         level: true,
25593         room: true
25594       };
25595       var isBuilding = entity.tags.building && entity.tags.building !== "no" || entity.tags["building:part"] && entity.tags["building:part"] !== "no";
25596       var isIndoorArea = fromGeometry === "area" && entity.tags.indoor && indoorAreaValues[entity.tags.indoor];
25597       var entityTags = Object.assign({}, entity.tags);
25598       var pointTags = {};
25599       for (var key in entityTags) {
25600         if (entity.type === "relation" && key === "type") {
25601           continue;
25602         }
25603         if (keysToRetain.indexOf(key) !== -1) {
25604           continue;
25605         }
25606         if (isBuilding) {
25607           if (buildingKeysToRetain.indexOf(key) !== -1 || key.match(/^building:.{1,}/) || key.match(/^roof:.{1,}/)) continue;
25608         }
25609         if (isIndoorArea && key === "indoor") {
25610           continue;
25611         }
25612         pointTags[key] = entityTags[key];
25613         if (keysToCopyAndRetain.indexOf(key) !== -1 || key.match(/^addr:.{1,}/)) {
25614           continue;
25615         } else if (isIndoorArea && key === "level") {
25616           continue;
25617         }
25618         delete entityTags[key];
25619       }
25620       if (!isBuilding && !isIndoorArea && fromGeometry === "area") {
25621         entityTags.area = "yes";
25622       }
25623       var replacement = osmNode({ loc: extractedLoc, tags: pointTags });
25624       graph = graph.replace(replacement);
25625       extractedNodeID = replacement.id;
25626       return graph.replace(entity.update({ tags: entityTags }));
25627     }
25628     action.getExtractedNodeID = function() {
25629       return extractedNodeID;
25630     };
25631     return action;
25632   }
25633
25634   // modules/actions/join.js
25635   function actionJoin(ids) {
25636     function groupEntitiesByGeometry(graph) {
25637       var entities = ids.map(function(id2) {
25638         return graph.entity(id2);
25639       });
25640       return Object.assign(
25641         { line: [] },
25642         utilArrayGroupBy(entities, function(entity) {
25643           return entity.geometry(graph);
25644         })
25645       );
25646     }
25647     var action = function(graph) {
25648       var ways = ids.map(graph.entity, graph);
25649       var survivorID = utilOldestID(ways.map((way) => way.id));
25650       ways.sort(function(a2, b2) {
25651         var aSided = a2.isSided();
25652         var bSided = b2.isSided();
25653         return aSided && !bSided ? -1 : bSided && !aSided ? 1 : 0;
25654       });
25655       var sequences = osmJoinWays(ways, graph);
25656       var joined = sequences[0];
25657       graph = sequences.actions.reduce(function(g3, action2) {
25658         return action2(g3);
25659       }, graph);
25660       var survivor = graph.entity(survivorID);
25661       survivor = survivor.update({ nodes: joined.nodes.map(function(n3) {
25662         return n3.id;
25663       }) });
25664       graph = graph.replace(survivor);
25665       joined.forEach(function(way) {
25666         if (way.id === survivorID) return;
25667         graph.parentRelations(way).forEach(function(parent) {
25668           graph = graph.replace(parent.replaceMember(way, survivor));
25669         });
25670         survivor = survivor.mergeTags(way.tags);
25671         graph = graph.replace(survivor);
25672         graph = actionDeleteWay(way.id)(graph);
25673       });
25674       function checkForSimpleMultipolygon() {
25675         if (!survivor.isClosed()) return;
25676         var multipolygons = graph.parentMultipolygons(survivor).filter(function(multipolygon2) {
25677           return multipolygon2.members.length === 1;
25678         });
25679         if (multipolygons.length !== 1) return;
25680         var multipolygon = multipolygons[0];
25681         for (var key in survivor.tags) {
25682           if (multipolygon.tags[key] && // don't collapse if tags cannot be cleanly merged
25683           multipolygon.tags[key] !== survivor.tags[key]) return;
25684         }
25685         survivor = survivor.mergeTags(multipolygon.tags);
25686         graph = graph.replace(survivor);
25687         graph = actionDeleteRelation(
25688           multipolygon.id,
25689           true
25690           /* allow untagged members */
25691         )(graph);
25692         var tags = Object.assign({}, survivor.tags);
25693         if (survivor.geometry(graph) !== "area") {
25694           tags.area = "yes";
25695         }
25696         delete tags.type;
25697         survivor = survivor.update({ tags });
25698         graph = graph.replace(survivor);
25699       }
25700       checkForSimpleMultipolygon();
25701       return graph;
25702     };
25703     action.resultingWayNodesLength = function(graph) {
25704       return ids.reduce(function(count, id2) {
25705         return count + graph.entity(id2).nodes.length;
25706       }, 0) - ids.length - 1;
25707     };
25708     action.disabled = function(graph) {
25709       var geometries = groupEntitiesByGeometry(graph);
25710       if (ids.length < 2 || ids.length !== geometries.line.length) {
25711         return "not_eligible";
25712       }
25713       var joined = osmJoinWays(ids.map(graph.entity, graph), graph);
25714       if (joined.length > 1) {
25715         return "not_adjacent";
25716       }
25717       var i3;
25718       var sortedParentRelations = function(id2) {
25719         return graph.parentRelations(graph.entity(id2)).filter((rel) => !rel.isRestriction() && !rel.isConnectivity()).sort((a2, b2) => a2.id - b2.id);
25720       };
25721       var relsA = sortedParentRelations(ids[0]);
25722       for (i3 = 1; i3 < ids.length; i3++) {
25723         var relsB = sortedParentRelations(ids[i3]);
25724         if (!utilArrayIdentical(relsA, relsB)) {
25725           return "conflicting_relations";
25726         }
25727       }
25728       for (i3 = 0; i3 < ids.length - 1; i3++) {
25729         for (var j2 = i3 + 1; j2 < ids.length; j2++) {
25730           var path1 = graph.childNodes(graph.entity(ids[i3])).map(function(e3) {
25731             return e3.loc;
25732           });
25733           var path2 = graph.childNodes(graph.entity(ids[j2])).map(function(e3) {
25734             return e3.loc;
25735           });
25736           var intersections = geoPathIntersections(path1, path2);
25737           var common = utilArrayIntersection(
25738             joined[0].nodes.map(function(n3) {
25739               return n3.loc.toString();
25740             }),
25741             intersections.map(function(n3) {
25742               return n3.toString();
25743             })
25744           );
25745           if (common.length !== intersections.length) {
25746             return "paths_intersect";
25747           }
25748         }
25749       }
25750       var nodeIds = joined[0].nodes.map(function(n3) {
25751         return n3.id;
25752       }).slice(1, -1);
25753       var relation;
25754       var tags = {};
25755       var conflicting = false;
25756       joined[0].forEach(function(way) {
25757         var parents = graph.parentRelations(way);
25758         parents.forEach(function(parent) {
25759           if ((parent.isRestriction() || parent.isConnectivity()) && parent.members.some(function(m2) {
25760             return nodeIds.indexOf(m2.id) >= 0;
25761           })) {
25762             relation = parent;
25763           }
25764         });
25765         for (var k2 in way.tags) {
25766           if (!(k2 in tags)) {
25767             tags[k2] = way.tags[k2];
25768           } else if (tags[k2] && osmIsInterestingTag(k2) && tags[k2] !== way.tags[k2]) {
25769             conflicting = true;
25770           }
25771         }
25772       });
25773       if (relation) {
25774         return relation.isRestriction() ? "restriction" : "connectivity";
25775       }
25776       if (conflicting) {
25777         return "conflicting_tags";
25778       }
25779     };
25780     return action;
25781   }
25782
25783   // modules/actions/merge.js
25784   function actionMerge(ids) {
25785     function groupEntitiesByGeometry(graph) {
25786       var entities = ids.map(function(id2) {
25787         return graph.entity(id2);
25788       });
25789       return Object.assign(
25790         { point: [], area: [], line: [], relation: [] },
25791         utilArrayGroupBy(entities, function(entity) {
25792           return entity.geometry(graph);
25793         })
25794       );
25795     }
25796     var action = function(graph) {
25797       var geometries = groupEntitiesByGeometry(graph);
25798       var target = geometries.area[0] || geometries.line[0];
25799       var points = geometries.point;
25800       points.forEach(function(point) {
25801         target = target.mergeTags(point.tags);
25802         graph = graph.replace(target);
25803         graph.parentRelations(point).forEach(function(parent) {
25804           graph = graph.replace(parent.replaceMember(point, target));
25805         });
25806         var nodes = utilArrayUniq(graph.childNodes(target));
25807         var removeNode = point;
25808         if (!point.isNew()) {
25809           var inserted = false;
25810           var canBeReplaced = function(node2) {
25811             return !(graph.parentWays(node2).length > 1 || graph.parentRelations(node2).length);
25812           };
25813           var replaceNode = function(node2) {
25814             graph = graph.replace(point.update({ tags: node2.tags, loc: node2.loc }));
25815             target = target.replaceNode(node2.id, point.id);
25816             graph = graph.replace(target);
25817             removeNode = node2;
25818             inserted = true;
25819           };
25820           var i3;
25821           var node;
25822           for (i3 = 0; i3 < nodes.length; i3++) {
25823             node = nodes[i3];
25824             if (canBeReplaced(node) && node.isNew()) {
25825               replaceNode(node);
25826               break;
25827             }
25828           }
25829           if (!inserted && point.hasInterestingTags()) {
25830             for (i3 = 0; i3 < nodes.length; i3++) {
25831               node = nodes[i3];
25832               if (canBeReplaced(node) && !node.hasInterestingTags()) {
25833                 replaceNode(node);
25834                 break;
25835               }
25836             }
25837             if (!inserted) {
25838               for (i3 = 0; i3 < nodes.length; i3++) {
25839                 node = nodes[i3];
25840                 if (canBeReplaced(node) && utilCompareIDs(point.id, node.id) < 0) {
25841                   replaceNode(node);
25842                   break;
25843                 }
25844               }
25845             }
25846           }
25847         }
25848         graph = graph.remove(removeNode);
25849       });
25850       if (target.tags.area === "yes") {
25851         var tags = Object.assign({}, target.tags);
25852         delete tags.area;
25853         if (osmTagSuggestingArea(tags)) {
25854           target = target.update({ tags });
25855           graph = graph.replace(target);
25856         }
25857       }
25858       return graph;
25859     };
25860     action.disabled = function(graph) {
25861       var geometries = groupEntitiesByGeometry(graph);
25862       if (geometries.point.length === 0 || geometries.area.length + geometries.line.length !== 1 || geometries.relation.length !== 0) {
25863         return "not_eligible";
25864       }
25865     };
25866     return action;
25867   }
25868
25869   // modules/actions/merge_nodes.js
25870   function actionMergeNodes(nodeIDs, loc) {
25871     function chooseLoc(graph) {
25872       if (!nodeIDs.length) return null;
25873       var sum = [0, 0];
25874       var interestingCount = 0;
25875       var interestingLoc;
25876       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
25877         var node = graph.entity(nodeIDs[i3]);
25878         if (node.hasInterestingTags()) {
25879           interestingLoc = ++interestingCount === 1 ? node.loc : null;
25880         }
25881         sum = geoVecAdd(sum, node.loc);
25882       }
25883       return interestingLoc || geoVecScale(sum, 1 / nodeIDs.length);
25884     }
25885     var action = function(graph) {
25886       if (nodeIDs.length < 2) return graph;
25887       var toLoc = loc;
25888       if (!toLoc) {
25889         toLoc = chooseLoc(graph);
25890       }
25891       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
25892         var node = graph.entity(nodeIDs[i3]);
25893         if (node.loc !== toLoc) {
25894           graph = graph.replace(node.move(toLoc));
25895         }
25896       }
25897       return actionConnect(nodeIDs)(graph);
25898     };
25899     action.disabled = function(graph) {
25900       if (nodeIDs.length < 2) return "not_eligible";
25901       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
25902         var entity = graph.entity(nodeIDs[i3]);
25903         if (entity.type !== "node") return "not_eligible";
25904       }
25905       return actionConnect(nodeIDs).disabled(graph);
25906     };
25907     return action;
25908   }
25909
25910   // modules/osm/changeset.js
25911   function osmChangeset() {
25912     if (!(this instanceof osmChangeset)) {
25913       return new osmChangeset().initialize(arguments);
25914     } else if (arguments.length) {
25915       this.initialize(arguments);
25916     }
25917   }
25918   osmEntity.changeset = osmChangeset;
25919   osmChangeset.prototype = Object.create(osmEntity.prototype);
25920   Object.assign(osmChangeset.prototype, {
25921     type: "changeset",
25922     extent: function() {
25923       return new geoExtent();
25924     },
25925     geometry: function() {
25926       return "changeset";
25927     },
25928     asJXON: function() {
25929       return {
25930         osm: {
25931           changeset: {
25932             tag: Object.keys(this.tags).map(function(k2) {
25933               return { "@k": k2, "@v": this.tags[k2] };
25934             }, this),
25935             "@version": 0.6,
25936             "@generator": "iD"
25937           }
25938         }
25939       };
25940     },
25941     // Generate [osmChange](http://wiki.openstreetmap.org/wiki/OsmChange)
25942     // XML. Returns a string.
25943     osmChangeJXON: function(changes) {
25944       var changeset_id = this.id;
25945       function nest(x2, order) {
25946         var groups = {};
25947         for (var i3 = 0; i3 < x2.length; i3++) {
25948           var tagName = Object.keys(x2[i3])[0];
25949           if (!groups[tagName]) groups[tagName] = [];
25950           groups[tagName].push(x2[i3][tagName]);
25951         }
25952         var ordered = {};
25953         order.forEach(function(o2) {
25954           if (groups[o2]) ordered[o2] = groups[o2];
25955         });
25956         return ordered;
25957       }
25958       function sort(changes2) {
25959         function resolve(item) {
25960           return relations.find(function(relation2) {
25961             return item.keyAttributes.type === "relation" && item.keyAttributes.ref === relation2["@id"];
25962           });
25963         }
25964         function isNew(item) {
25965           return !sorted[item["@id"]] && !processing.find(function(proc) {
25966             return proc["@id"] === item["@id"];
25967           });
25968         }
25969         var processing = [];
25970         var sorted = {};
25971         var relations = changes2.relation;
25972         if (!relations) return changes2;
25973         for (var i3 = 0; i3 < relations.length; i3++) {
25974           var relation = relations[i3];
25975           if (!sorted[relation["@id"]]) {
25976             processing.push(relation);
25977           }
25978           while (processing.length > 0) {
25979             var next = processing[0], deps = next.member.map(resolve).filter(Boolean).filter(isNew);
25980             if (deps.length === 0) {
25981               sorted[next["@id"]] = next;
25982               processing.shift();
25983             } else {
25984               processing = deps.concat(processing);
25985             }
25986           }
25987         }
25988         changes2.relation = Object.values(sorted);
25989         return changes2;
25990       }
25991       function rep(entity) {
25992         return entity.asJXON(changeset_id);
25993       }
25994       return {
25995         osmChange: {
25996           "@version": 0.6,
25997           "@generator": "iD",
25998           "create": sort(nest(changes.created.map(rep), ["node", "way", "relation"])),
25999           "modify": nest(changes.modified.map(rep), ["node", "way", "relation"]),
26000           "delete": Object.assign(nest(changes.deleted.map(rep), ["relation", "way", "node"]), { "@if-unused": true })
26001         }
26002       };
26003     },
26004     asGeoJSON: function() {
26005       return {};
26006     }
26007   });
26008
26009   // modules/osm/note.js
26010   function osmNote() {
26011     if (!(this instanceof osmNote)) {
26012       return new osmNote().initialize(arguments);
26013     } else if (arguments.length) {
26014       this.initialize(arguments);
26015     }
26016   }
26017   osmNote.id = function() {
26018     return osmNote.id.next--;
26019   };
26020   osmNote.id.next = -1;
26021   Object.assign(osmNote.prototype, {
26022     type: "note",
26023     initialize: function(sources) {
26024       for (var i3 = 0; i3 < sources.length; ++i3) {
26025         var source = sources[i3];
26026         for (var prop in source) {
26027           if (Object.prototype.hasOwnProperty.call(source, prop)) {
26028             if (source[prop] === void 0) {
26029               delete this[prop];
26030             } else {
26031               this[prop] = source[prop];
26032             }
26033           }
26034         }
26035       }
26036       if (!this.id) {
26037         this.id = osmNote.id().toString();
26038       }
26039       return this;
26040     },
26041     extent: function() {
26042       return new geoExtent(this.loc);
26043     },
26044     update: function(attrs) {
26045       return osmNote(this, attrs);
26046     },
26047     isNew: function() {
26048       return this.id < 0;
26049     },
26050     move: function(loc) {
26051       return this.update({ loc });
26052     }
26053   });
26054
26055   // modules/osm/relation.js
26056   function osmRelation() {
26057     if (!(this instanceof osmRelation)) {
26058       return new osmRelation().initialize(arguments);
26059     } else if (arguments.length) {
26060       this.initialize(arguments);
26061     }
26062   }
26063   osmEntity.relation = osmRelation;
26064   osmRelation.prototype = Object.create(osmEntity.prototype);
26065   osmRelation.creationOrder = function(a2, b2) {
26066     var aId = parseInt(osmEntity.id.toOSM(a2.id), 10);
26067     var bId = parseInt(osmEntity.id.toOSM(b2.id), 10);
26068     if (aId < 0 || bId < 0) return aId - bId;
26069     return bId - aId;
26070   };
26071   Object.assign(osmRelation.prototype, {
26072     type: "relation",
26073     members: [],
26074     copy: function(resolver, copies) {
26075       if (copies[this.id]) return copies[this.id];
26076       var copy2 = osmEntity.prototype.copy.call(this, resolver, copies);
26077       var members = this.members.map(function(member) {
26078         return Object.assign({}, member, { id: resolver.entity(member.id).copy(resolver, copies).id });
26079       });
26080       copy2 = copy2.update({ members });
26081       copies[this.id] = copy2;
26082       return copy2;
26083     },
26084     extent: function(resolver, memo) {
26085       return resolver.transient(this, "extent", function() {
26086         if (memo && memo[this.id]) return geoExtent();
26087         memo = memo || {};
26088         memo[this.id] = true;
26089         var extent = geoExtent();
26090         for (var i3 = 0; i3 < this.members.length; i3++) {
26091           var member = resolver.hasEntity(this.members[i3].id);
26092           if (member) {
26093             extent._extend(member.extent(resolver, memo));
26094           }
26095         }
26096         return extent;
26097       });
26098     },
26099     geometry: function(graph) {
26100       return graph.transient(this, "geometry", function() {
26101         return this.isMultipolygon() ? "area" : "relation";
26102       });
26103     },
26104     isDegenerate: function() {
26105       return this.members.length === 0;
26106     },
26107     // Return an array of members, each extended with an 'index' property whose value
26108     // is the member index.
26109     indexedMembers: function() {
26110       var result = new Array(this.members.length);
26111       for (var i3 = 0; i3 < this.members.length; i3++) {
26112         result[i3] = Object.assign({}, this.members[i3], { index: i3 });
26113       }
26114       return result;
26115     },
26116     // Return the first member with the given role. A copy of the member object
26117     // is returned, extended with an 'index' property whose value is the member index.
26118     memberByRole: function(role) {
26119       for (var i3 = 0; i3 < this.members.length; i3++) {
26120         if (this.members[i3].role === role) {
26121           return Object.assign({}, this.members[i3], { index: i3 });
26122         }
26123       }
26124     },
26125     // Same as memberByRole, but returns all members with the given role
26126     membersByRole: function(role) {
26127       var result = [];
26128       for (var i3 = 0; i3 < this.members.length; i3++) {
26129         if (this.members[i3].role === role) {
26130           result.push(Object.assign({}, this.members[i3], { index: i3 }));
26131         }
26132       }
26133       return result;
26134     },
26135     // Return the first member with the given id. A copy of the member object
26136     // is returned, extended with an 'index' property whose value is the member index.
26137     memberById: function(id2) {
26138       for (var i3 = 0; i3 < this.members.length; i3++) {
26139         if (this.members[i3].id === id2) {
26140           return Object.assign({}, this.members[i3], { index: i3 });
26141         }
26142       }
26143     },
26144     // Return the first member with the given id and role. A copy of the member object
26145     // is returned, extended with an 'index' property whose value is the member index.
26146     memberByIdAndRole: function(id2, role) {
26147       for (var i3 = 0; i3 < this.members.length; i3++) {
26148         if (this.members[i3].id === id2 && this.members[i3].role === role) {
26149           return Object.assign({}, this.members[i3], { index: i3 });
26150         }
26151       }
26152     },
26153     addMember: function(member, index) {
26154       var members = this.members.slice();
26155       members.splice(index === void 0 ? members.length : index, 0, member);
26156       return this.update({ members });
26157     },
26158     updateMember: function(member, index) {
26159       var members = this.members.slice();
26160       members.splice(index, 1, Object.assign({}, members[index], member));
26161       return this.update({ members });
26162     },
26163     removeMember: function(index) {
26164       var members = this.members.slice();
26165       members.splice(index, 1);
26166       return this.update({ members });
26167     },
26168     removeMembersWithID: function(id2) {
26169       var members = this.members.filter(function(m2) {
26170         return m2.id !== id2;
26171       });
26172       return this.update({ members });
26173     },
26174     moveMember: function(fromIndex, toIndex) {
26175       var members = this.members.slice();
26176       members.splice(toIndex, 0, members.splice(fromIndex, 1)[0]);
26177       return this.update({ members });
26178     },
26179     // Wherever a member appears with id `needle.id`, replace it with a member
26180     // with id `replacement.id`, type `replacement.type`, and the original role,
26181     // By default, adding a duplicate member (by id and role) is prevented.
26182     // Return an updated relation.
26183     replaceMember: function(needle, replacement, keepDuplicates) {
26184       if (!this.memberById(needle.id)) return this;
26185       var members = [];
26186       for (var i3 = 0; i3 < this.members.length; i3++) {
26187         var member = this.members[i3];
26188         if (member.id !== needle.id) {
26189           members.push(member);
26190         } else if (keepDuplicates || !this.memberByIdAndRole(replacement.id, member.role)) {
26191           members.push({ id: replacement.id, type: replacement.type, role: member.role });
26192         }
26193       }
26194       return this.update({ members });
26195     },
26196     asJXON: function(changeset_id) {
26197       var r2 = {
26198         relation: {
26199           "@id": this.osmId(),
26200           "@version": this.version || 0,
26201           member: this.members.map(function(member) {
26202             return {
26203               keyAttributes: {
26204                 type: member.type,
26205                 role: member.role,
26206                 ref: osmEntity.id.toOSM(member.id)
26207               }
26208             };
26209           }, this),
26210           tag: Object.keys(this.tags).map(function(k2) {
26211             return { keyAttributes: { k: k2, v: this.tags[k2] } };
26212           }, this)
26213         }
26214       };
26215       if (changeset_id) {
26216         r2.relation["@changeset"] = changeset_id;
26217       }
26218       return r2;
26219     },
26220     asGeoJSON: function(resolver) {
26221       return resolver.transient(this, "GeoJSON", function() {
26222         if (this.isMultipolygon()) {
26223           return {
26224             type: "MultiPolygon",
26225             coordinates: this.multipolygon(resolver)
26226           };
26227         } else {
26228           return {
26229             type: "FeatureCollection",
26230             properties: this.tags,
26231             features: this.members.map(function(member) {
26232               return Object.assign({ role: member.role }, resolver.entity(member.id).asGeoJSON(resolver));
26233             })
26234           };
26235         }
26236       });
26237     },
26238     area: function(resolver) {
26239       return resolver.transient(this, "area", function() {
26240         return area_default(this.asGeoJSON(resolver));
26241       });
26242     },
26243     isMultipolygon: function() {
26244       return this.tags.type === "multipolygon";
26245     },
26246     isComplete: function(resolver) {
26247       for (var i3 = 0; i3 < this.members.length; i3++) {
26248         if (!resolver.hasEntity(this.members[i3].id)) {
26249           return false;
26250         }
26251       }
26252       return true;
26253     },
26254     hasFromViaTo: function() {
26255       return this.members.some(function(m2) {
26256         return m2.role === "from";
26257       }) && this.members.some(function(m2) {
26258         return m2.role === "via";
26259       }) && this.members.some(function(m2) {
26260         return m2.role === "to";
26261       });
26262     },
26263     isRestriction: function() {
26264       return !!(this.tags.type && this.tags.type.match(/^restriction:?/));
26265     },
26266     isValidRestriction: function() {
26267       if (!this.isRestriction()) return false;
26268       var froms = this.members.filter(function(m2) {
26269         return m2.role === "from";
26270       });
26271       var vias = this.members.filter(function(m2) {
26272         return m2.role === "via";
26273       });
26274       var tos = this.members.filter(function(m2) {
26275         return m2.role === "to";
26276       });
26277       if (froms.length !== 1 && this.tags.restriction !== "no_entry") return false;
26278       if (froms.some(function(m2) {
26279         return m2.type !== "way";
26280       })) return false;
26281       if (tos.length !== 1 && this.tags.restriction !== "no_exit") return false;
26282       if (tos.some(function(m2) {
26283         return m2.type !== "way";
26284       })) return false;
26285       if (vias.length === 0) return false;
26286       if (vias.length > 1 && vias.some(function(m2) {
26287         return m2.type !== "way";
26288       })) return false;
26289       return true;
26290     },
26291     isConnectivity: function() {
26292       return !!(this.tags.type && this.tags.type.match(/^connectivity:?/));
26293     },
26294     // Returns an array [A0, ... An], each Ai being an array of node arrays [Nds0, ... Ndsm],
26295     // where Nds0 is an outer ring and subsequent Ndsi's (if any i > 0) being inner rings.
26296     //
26297     // This corresponds to the structure needed for rendering a multipolygon path using a
26298     // `evenodd` fill rule, as well as the structure of a GeoJSON MultiPolygon geometry.
26299     //
26300     // In the case of invalid geometries, this function will still return a result which
26301     // includes the nodes of all way members, but some Nds may be unclosed and some inner
26302     // rings not matched with the intended outer ring.
26303     //
26304     multipolygon: function(resolver) {
26305       var outers = this.members.filter(function(m2) {
26306         return "outer" === (m2.role || "outer");
26307       });
26308       var inners = this.members.filter(function(m2) {
26309         return "inner" === m2.role;
26310       });
26311       outers = osmJoinWays(outers, resolver);
26312       inners = osmJoinWays(inners, resolver);
26313       var sequenceToLineString = function(sequence) {
26314         if (sequence.nodes.length > 2 && sequence.nodes[0] !== sequence.nodes[sequence.nodes.length - 1]) {
26315           sequence.nodes.push(sequence.nodes[0]);
26316         }
26317         return sequence.nodes.map(function(node) {
26318           return node.loc;
26319         });
26320       };
26321       outers = outers.map(sequenceToLineString);
26322       inners = inners.map(sequenceToLineString);
26323       var result = outers.map(function(o3) {
26324         return [area_default({ type: "Polygon", coordinates: [o3] }) > 2 * Math.PI ? o3.reverse() : o3];
26325       });
26326       function findOuter(inner2) {
26327         var o3, outer;
26328         for (o3 = 0; o3 < outers.length; o3++) {
26329           outer = outers[o3];
26330           if (geoPolygonContainsPolygon(outer, inner2)) {
26331             return o3;
26332           }
26333         }
26334         for (o3 = 0; o3 < outers.length; o3++) {
26335           outer = outers[o3];
26336           if (geoPolygonIntersectsPolygon(outer, inner2, false)) {
26337             return o3;
26338           }
26339         }
26340       }
26341       for (var i3 = 0; i3 < inners.length; i3++) {
26342         var inner = inners[i3];
26343         if (area_default({ type: "Polygon", coordinates: [inner] }) < 2 * Math.PI) {
26344           inner = inner.reverse();
26345         }
26346         var o2 = findOuter(inners[i3]);
26347         if (o2 !== void 0) {
26348           result[o2].push(inners[i3]);
26349         } else {
26350           result.push([inners[i3]]);
26351         }
26352       }
26353       return result;
26354     }
26355   });
26356
26357   // modules/osm/qa_item.js
26358   var QAItem = class _QAItem {
26359     constructor(loc, service, itemType, id2, props) {
26360       this.loc = loc;
26361       this.service = service.title;
26362       this.itemType = itemType;
26363       this.id = id2 ? id2 : "".concat(_QAItem.id());
26364       this.update(props);
26365       if (service && typeof service.getIcon === "function") {
26366         this.icon = service.getIcon(itemType);
26367       }
26368     }
26369     update(props) {
26370       const { loc, service, itemType, id: id2 } = this;
26371       Object.keys(props).forEach((prop) => this[prop] = props[prop]);
26372       this.loc = loc;
26373       this.service = service;
26374       this.itemType = itemType;
26375       this.id = id2;
26376       return this;
26377     }
26378     // Generic handling for newly created QAItems
26379     static id() {
26380       return this.nextId--;
26381     }
26382   };
26383   QAItem.nextId = -1;
26384
26385   // modules/actions/split.js
26386   function actionSplit(nodeIds, newWayIds) {
26387     if (typeof nodeIds === "string") nodeIds = [nodeIds];
26388     var _wayIDs;
26389     var _keepHistoryOn = "longest";
26390     const circularJunctions = ["roundabout", "circular"];
26391     var _createdWayIDs = [];
26392     function dist(graph, nA, nB) {
26393       var locA = graph.entity(nA).loc;
26394       var locB = graph.entity(nB).loc;
26395       var epsilon3 = 1e-6;
26396       return locA && locB ? geoSphericalDistance(locA, locB) : epsilon3;
26397     }
26398     function splitArea(nodes, idxA, graph) {
26399       var lengths = new Array(nodes.length);
26400       var length2;
26401       var i3;
26402       var best = 0;
26403       var idxB;
26404       function wrap2(index) {
26405         return utilWrap(index, nodes.length);
26406       }
26407       length2 = 0;
26408       for (i3 = wrap2(idxA + 1); i3 !== idxA; i3 = wrap2(i3 + 1)) {
26409         length2 += dist(graph, nodes[i3], nodes[wrap2(i3 - 1)]);
26410         lengths[i3] = length2;
26411       }
26412       length2 = 0;
26413       for (i3 = wrap2(idxA - 1); i3 !== idxA; i3 = wrap2(i3 - 1)) {
26414         length2 += dist(graph, nodes[i3], nodes[wrap2(i3 + 1)]);
26415         if (length2 < lengths[i3]) {
26416           lengths[i3] = length2;
26417         }
26418       }
26419       for (i3 = 0; i3 < nodes.length; i3++) {
26420         var cost = lengths[i3] / dist(graph, nodes[idxA], nodes[i3]);
26421         if (cost > best) {
26422           idxB = i3;
26423           best = cost;
26424         }
26425       }
26426       return idxB;
26427     }
26428     function totalLengthBetweenNodes(graph, nodes) {
26429       var totalLength = 0;
26430       for (var i3 = 0; i3 < nodes.length - 1; i3++) {
26431         totalLength += dist(graph, nodes[i3], nodes[i3 + 1]);
26432       }
26433       return totalLength;
26434     }
26435     function split(graph, nodeId, wayA, newWayId) {
26436       var wayB = osmWay({ id: newWayId, tags: wayA.tags });
26437       var nodesA;
26438       var nodesB;
26439       var isArea = wayA.isArea();
26440       if (wayA.isClosed()) {
26441         var nodes = wayA.nodes.slice(0, -1);
26442         var idxA = nodes.indexOf(nodeId);
26443         var idxB = splitArea(nodes, idxA, graph);
26444         if (idxB < idxA) {
26445           nodesA = nodes.slice(idxA).concat(nodes.slice(0, idxB + 1));
26446           nodesB = nodes.slice(idxB, idxA + 1);
26447         } else {
26448           nodesA = nodes.slice(idxA, idxB + 1);
26449           nodesB = nodes.slice(idxB).concat(nodes.slice(0, idxA + 1));
26450         }
26451       } else {
26452         var idx = wayA.nodes.indexOf(nodeId, 1);
26453         nodesA = wayA.nodes.slice(0, idx + 1);
26454         nodesB = wayA.nodes.slice(idx);
26455       }
26456       var lengthA = totalLengthBetweenNodes(graph, nodesA);
26457       var lengthB = totalLengthBetweenNodes(graph, nodesB);
26458       if (_keepHistoryOn === "longest" && lengthB > lengthA) {
26459         wayA = wayA.update({ nodes: nodesB });
26460         wayB = wayB.update({ nodes: nodesA });
26461         var temp = lengthA;
26462         lengthA = lengthB;
26463         lengthB = temp;
26464       } else {
26465         wayA = wayA.update({ nodes: nodesA });
26466         wayB = wayB.update({ nodes: nodesB });
26467       }
26468       if (wayA.tags.step_count) {
26469         var stepCount = Number(wayA.tags.step_count);
26470         if (stepCount && // ensure a number
26471         isFinite(stepCount) && // ensure positive
26472         stepCount > 0 && // ensure integer
26473         Math.round(stepCount) === stepCount) {
26474           var tagsA = Object.assign({}, wayA.tags);
26475           var tagsB = Object.assign({}, wayB.tags);
26476           var ratioA = lengthA / (lengthA + lengthB);
26477           var countA = Math.round(stepCount * ratioA);
26478           tagsA.step_count = countA.toString();
26479           tagsB.step_count = (stepCount - countA).toString();
26480           wayA = wayA.update({ tags: tagsA });
26481           wayB = wayB.update({ tags: tagsB });
26482         }
26483       }
26484       graph = graph.replace(wayA);
26485       graph = graph.replace(wayB);
26486       graph.parentRelations(wayA).forEach(function(relation) {
26487         if (relation.hasFromViaTo()) {
26488           var f2 = relation.memberByRole("from");
26489           var v2 = relation.membersByRole("via");
26490           var t2 = relation.memberByRole("to");
26491           var i3;
26492           if (f2.id === wayA.id || t2.id === wayA.id) {
26493             var keepB = false;
26494             if (v2.length === 1 && v2[0].type === "node") {
26495               keepB = wayB.contains(v2[0].id);
26496             } else {
26497               for (i3 = 0; i3 < v2.length; i3++) {
26498                 if (v2[i3].type === "way") {
26499                   var wayVia = graph.hasEntity(v2[i3].id);
26500                   if (wayVia && utilArrayIntersection(wayB.nodes, wayVia.nodes).length) {
26501                     keepB = true;
26502                     break;
26503                   }
26504                 }
26505               }
26506             }
26507             if (keepB) {
26508               relation = relation.replaceMember(wayA, wayB);
26509               graph = graph.replace(relation);
26510             }
26511           } else {
26512             for (i3 = 0; i3 < v2.length; i3++) {
26513               if (v2[i3].type === "way" && v2[i3].id === wayA.id) {
26514                 graph = splitWayMember(graph, relation.id, wayA, wayB);
26515               }
26516             }
26517           }
26518         } else {
26519           graph = splitWayMember(graph, relation.id, wayA, wayB);
26520         }
26521       });
26522       if (isArea) {
26523         var multipolygon = osmRelation({
26524           tags: Object.assign({}, wayA.tags, { type: "multipolygon" }),
26525           members: [
26526             { id: wayA.id, role: "outer", type: "way" },
26527             { id: wayB.id, role: "outer", type: "way" }
26528           ]
26529         });
26530         graph = graph.replace(multipolygon);
26531         graph = graph.replace(wayA.update({ tags: {} }));
26532         graph = graph.replace(wayB.update({ tags: {} }));
26533       }
26534       _createdWayIDs.push(wayB.id);
26535       return graph;
26536     }
26537     function splitWayMember(graph, relationId, wayA, wayB) {
26538       function connects(way1, way2) {
26539         if (way1.nodes.length < 2 || way2.nodes.length < 2) return false;
26540         if (circularJunctions.includes(way1.tags.junction) && way1.isClosed()) {
26541           return way1.nodes.some((nodeId) => nodeId === way2.nodes[0] || nodeId === way2.nodes[way2.nodes.length - 1]);
26542         } else if (circularJunctions.includes(way2.tags.junction) && way2.isClosed()) {
26543           return way2.nodes.some((nodeId) => nodeId === way1.nodes[0] || nodeId === way1.nodes[way1.nodes.length - 1]);
26544         }
26545         if (way1.nodes[0] === way2.nodes[0]) return true;
26546         if (way1.nodes[0] === way2.nodes[way2.nodes.length - 1]) return true;
26547         if (way1.nodes[way1.nodes.length - 1] === way2.nodes[way2.nodes.length - 1]) return true;
26548         if (way1.nodes[way1.nodes.length - 1] === way2.nodes[0]) return true;
26549         return false;
26550       }
26551       let relation = graph.entity(relationId);
26552       const insertMembers = [];
26553       const members = relation.members;
26554       for (let i3 = 0; i3 < members.length; i3++) {
26555         const member = members[i3];
26556         if (member.id === wayA.id) {
26557           let wayAconnectsPrev = false;
26558           let wayAconnectsNext = false;
26559           let wayBconnectsPrev = false;
26560           let wayBconnectsNext = false;
26561           if (i3 > 0 && graph.hasEntity(members[i3 - 1].id)) {
26562             const prevEntity = graph.entity(members[i3 - 1].id);
26563             if (prevEntity.type === "way") {
26564               wayAconnectsPrev = connects(prevEntity, wayA);
26565               wayBconnectsPrev = connects(prevEntity, wayB);
26566             }
26567           }
26568           if (i3 < members.length - 1 && graph.hasEntity(members[i3 + 1].id)) {
26569             const nextEntity = graph.entity(members[i3 + 1].id);
26570             if (nextEntity.type === "way") {
26571               wayAconnectsNext = connects(nextEntity, wayA);
26572               wayBconnectsNext = connects(nextEntity, wayB);
26573             }
26574           }
26575           if (wayAconnectsPrev && !wayAconnectsNext || !wayBconnectsPrev && wayBconnectsNext && !(!wayAconnectsPrev && wayAconnectsNext)) {
26576             insertMembers.push({ at: i3 + 1, role: member.role });
26577             continue;
26578           }
26579           if (!wayAconnectsPrev && wayAconnectsNext || wayBconnectsPrev && !wayBconnectsNext && !(wayAconnectsPrev && !wayAconnectsNext)) {
26580             insertMembers.push({ at: i3, role: member.role });
26581             continue;
26582           }
26583           if (wayAconnectsPrev && wayBconnectsPrev && wayAconnectsNext && wayBconnectsNext) {
26584             if (i3 > 2 && graph.hasEntity(members[i3 - 2].id)) {
26585               const prev2Entity = graph.entity(members[i3 - 2].id);
26586               if (connects(prev2Entity, wayA) && !connects(prev2Entity, wayB)) {
26587                 insertMembers.push({ at: i3, role: member.role });
26588                 continue;
26589               }
26590               if (connects(prev2Entity, wayB) && !connects(prev2Entity, wayA)) {
26591                 insertMembers.push({ at: i3 + 1, role: member.role });
26592                 continue;
26593               }
26594             }
26595             if (i3 < members.length - 2 && graph.hasEntity(members[i3 + 2].id)) {
26596               const next2Entity = graph.entity(members[i3 + 2].id);
26597               if (connects(next2Entity, wayA) && !connects(next2Entity, wayB)) {
26598                 insertMembers.push({ at: i3 + 1, role: member.role });
26599                 continue;
26600               }
26601               if (connects(next2Entity, wayB) && !connects(next2Entity, wayA)) {
26602                 insertMembers.push({ at: i3, role: member.role });
26603                 continue;
26604               }
26605             }
26606           }
26607           if (wayA.nodes[wayA.nodes.length - 1] === wayB.nodes[0]) {
26608             insertMembers.push({ at: i3 + 1, role: member.role });
26609           } else {
26610             insertMembers.push({ at: i3, role: member.role });
26611           }
26612         }
26613       }
26614       insertMembers.reverse().forEach((item) => {
26615         graph = graph.replace(relation.addMember({
26616           id: wayB.id,
26617           type: "way",
26618           role: item.role
26619         }, item.at));
26620         relation = graph.entity(relation.id);
26621       });
26622       return graph;
26623     }
26624     var action = function(graph) {
26625       _createdWayIDs = [];
26626       var newWayIndex = 0;
26627       for (var i3 = 0; i3 < nodeIds.length; i3++) {
26628         var nodeId = nodeIds[i3];
26629         var candidates = action.waysForNode(nodeId, graph);
26630         for (var j2 = 0; j2 < candidates.length; j2++) {
26631           graph = split(graph, nodeId, candidates[j2], newWayIds && newWayIds[newWayIndex]);
26632           newWayIndex += 1;
26633         }
26634       }
26635       return graph;
26636     };
26637     action.getCreatedWayIDs = function() {
26638       return _createdWayIDs;
26639     };
26640     action.waysForNode = function(nodeId, graph) {
26641       var node = graph.entity(nodeId);
26642       var splittableParents = graph.parentWays(node).filter(isSplittable);
26643       if (!_wayIDs) {
26644         var hasLine = splittableParents.some(function(parent) {
26645           return parent.geometry(graph) === "line";
26646         });
26647         if (hasLine) {
26648           return splittableParents.filter(function(parent) {
26649             return parent.geometry(graph) === "line";
26650           });
26651         }
26652       }
26653       return splittableParents;
26654       function isSplittable(parent) {
26655         if (_wayIDs && _wayIDs.indexOf(parent.id) === -1) return false;
26656         if (parent.isClosed()) return true;
26657         for (var i3 = 1; i3 < parent.nodes.length - 1; i3++) {
26658           if (parent.nodes[i3] === nodeId) return true;
26659         }
26660         return false;
26661       }
26662     };
26663     action.ways = function(graph) {
26664       return utilArrayUniq([].concat.apply([], nodeIds.map(function(nodeId) {
26665         return action.waysForNode(nodeId, graph);
26666       })));
26667     };
26668     action.disabled = function(graph) {
26669       for (const nodeId of nodeIds) {
26670         const candidates = action.waysForNode(nodeId, graph);
26671         if (candidates.length === 0 || _wayIDs && _wayIDs.length !== candidates.length) {
26672           return "not_eligible";
26673         }
26674         for (const way of candidates) {
26675           const parentRelations = graph.parentRelations(way);
26676           for (const parentRelation of parentRelations) {
26677             if (parentRelation.hasFromViaTo()) {
26678               const vias = parentRelation.membersByRole("via");
26679               if (!vias.every((via) => graph.hasEntity(via.id))) {
26680                 return "parent_incomplete";
26681               }
26682             } else {
26683               for (let i3 = 0; i3 < parentRelation.members.length; i3++) {
26684                 if (parentRelation.members[i3].id === way.id) {
26685                   const memberBeforePresent = i3 > 0 && graph.hasEntity(parentRelation.members[i3 - 1].id);
26686                   const memberAfterPresent = i3 < parentRelation.members.length - 1 && graph.hasEntity(parentRelation.members[i3 + 1].id);
26687                   if (!memberBeforePresent && !memberAfterPresent && parentRelation.members.length > 1) {
26688                     return "parent_incomplete";
26689                   }
26690                 }
26691               }
26692             }
26693             const relTypesExceptions = ["junction", "enforcement"];
26694             if (circularJunctions.includes(way.tags.junction) && way.isClosed() && !relTypesExceptions.includes(parentRelation.tags.type)) {
26695               return "simple_roundabout";
26696             }
26697           }
26698         }
26699       }
26700     };
26701     action.limitWays = function(val) {
26702       if (!arguments.length) return _wayIDs;
26703       _wayIDs = val;
26704       return action;
26705     };
26706     action.keepHistoryOn = function(val) {
26707       if (!arguments.length) return _keepHistoryOn;
26708       _keepHistoryOn = val;
26709       return action;
26710     };
26711     return action;
26712   }
26713
26714   // modules/core/graph.js
26715   function coreGraph(other2, mutable) {
26716     if (!(this instanceof coreGraph)) return new coreGraph(other2, mutable);
26717     if (other2 instanceof coreGraph) {
26718       var base = other2.base();
26719       this.entities = Object.assign(Object.create(base.entities), other2.entities);
26720       this._parentWays = Object.assign(Object.create(base.parentWays), other2._parentWays);
26721       this._parentRels = Object.assign(Object.create(base.parentRels), other2._parentRels);
26722     } else {
26723       this.entities = /* @__PURE__ */ Object.create({});
26724       this._parentWays = /* @__PURE__ */ Object.create({});
26725       this._parentRels = /* @__PURE__ */ Object.create({});
26726       this.rebase(other2 || [], [this]);
26727     }
26728     this.transients = {};
26729     this._childNodes = {};
26730     this.frozen = !mutable;
26731   }
26732   coreGraph.prototype = {
26733     hasEntity: function(id2) {
26734       return this.entities[id2];
26735     },
26736     entity: function(id2) {
26737       var entity = this.entities[id2];
26738       if (!entity) {
26739         entity = this.entities.__proto__[id2];
26740       }
26741       if (!entity) {
26742         throw new Error("entity " + id2 + " not found");
26743       }
26744       return entity;
26745     },
26746     geometry: function(id2) {
26747       return this.entity(id2).geometry(this);
26748     },
26749     transient: function(entity, key, fn) {
26750       var id2 = entity.id;
26751       var transients = this.transients[id2] || (this.transients[id2] = {});
26752       if (transients[key] !== void 0) {
26753         return transients[key];
26754       }
26755       transients[key] = fn.call(entity);
26756       return transients[key];
26757     },
26758     parentWays: function(entity) {
26759       var parents = this._parentWays[entity.id];
26760       var result = [];
26761       if (parents) {
26762         parents.forEach(function(id2) {
26763           result.push(this.entity(id2));
26764         }, this);
26765       }
26766       return result;
26767     },
26768     isPoi: function(entity) {
26769       var parents = this._parentWays[entity.id];
26770       return !parents || parents.size === 0;
26771     },
26772     isShared: function(entity) {
26773       var parents = this._parentWays[entity.id];
26774       return parents && parents.size > 1;
26775     },
26776     parentRelations: function(entity) {
26777       var parents = this._parentRels[entity.id];
26778       var result = [];
26779       if (parents) {
26780         parents.forEach(function(id2) {
26781           result.push(this.entity(id2));
26782         }, this);
26783       }
26784       return result;
26785     },
26786     parentMultipolygons: function(entity) {
26787       return this.parentRelations(entity).filter(function(relation) {
26788         return relation.isMultipolygon();
26789       });
26790     },
26791     childNodes: function(entity) {
26792       if (this._childNodes[entity.id]) return this._childNodes[entity.id];
26793       if (!entity.nodes) return [];
26794       var nodes = [];
26795       for (var i3 = 0; i3 < entity.nodes.length; i3++) {
26796         nodes[i3] = this.entity(entity.nodes[i3]);
26797       }
26798       if (debug) Object.freeze(nodes);
26799       this._childNodes[entity.id] = nodes;
26800       return this._childNodes[entity.id];
26801     },
26802     base: function() {
26803       return {
26804         "entities": Object.getPrototypeOf(this.entities),
26805         "parentWays": Object.getPrototypeOf(this._parentWays),
26806         "parentRels": Object.getPrototypeOf(this._parentRels)
26807       };
26808     },
26809     // Unlike other graph methods, rebase mutates in place. This is because it
26810     // is used only during the history operation that merges newly downloaded
26811     // data into each state. To external consumers, it should appear as if the
26812     // graph always contained the newly downloaded data.
26813     rebase: function(entities, stack, force) {
26814       var base = this.base();
26815       var i3, j2, k2, id2;
26816       for (i3 = 0; i3 < entities.length; i3++) {
26817         var entity = entities[i3];
26818         if (!entity.visible || !force && base.entities[entity.id]) continue;
26819         base.entities[entity.id] = entity;
26820         this._updateCalculated(void 0, entity, base.parentWays, base.parentRels);
26821         if (entity.type === "way") {
26822           for (j2 = 0; j2 < entity.nodes.length; j2++) {
26823             id2 = entity.nodes[j2];
26824             for (k2 = 1; k2 < stack.length; k2++) {
26825               var ents = stack[k2].entities;
26826               if (ents.hasOwnProperty(id2) && ents[id2] === void 0) {
26827                 delete ents[id2];
26828               }
26829             }
26830           }
26831         }
26832       }
26833       for (i3 = 0; i3 < stack.length; i3++) {
26834         stack[i3]._updateRebased();
26835       }
26836     },
26837     _updateRebased: function() {
26838       var base = this.base();
26839       Object.keys(this._parentWays).forEach(function(child) {
26840         if (base.parentWays[child]) {
26841           base.parentWays[child].forEach(function(id2) {
26842             if (!this.entities.hasOwnProperty(id2)) {
26843               this._parentWays[child].add(id2);
26844             }
26845           }, this);
26846         }
26847       }, this);
26848       Object.keys(this._parentRels).forEach(function(child) {
26849         if (base.parentRels[child]) {
26850           base.parentRels[child].forEach(function(id2) {
26851             if (!this.entities.hasOwnProperty(id2)) {
26852               this._parentRels[child].add(id2);
26853             }
26854           }, this);
26855         }
26856       }, this);
26857       this.transients = {};
26858     },
26859     // Updates calculated properties (parentWays, parentRels) for the specified change
26860     _updateCalculated: function(oldentity, entity, parentWays, parentRels) {
26861       parentWays = parentWays || this._parentWays;
26862       parentRels = parentRels || this._parentRels;
26863       var type2 = entity && entity.type || oldentity && oldentity.type;
26864       var removed, added, i3;
26865       if (type2 === "way") {
26866         if (oldentity && entity) {
26867           removed = utilArrayDifference(oldentity.nodes, entity.nodes);
26868           added = utilArrayDifference(entity.nodes, oldentity.nodes);
26869         } else if (oldentity) {
26870           removed = oldentity.nodes;
26871           added = [];
26872         } else if (entity) {
26873           removed = [];
26874           added = entity.nodes;
26875         }
26876         for (i3 = 0; i3 < removed.length; i3++) {
26877           parentWays[removed[i3]] = new Set(parentWays[removed[i3]]);
26878           parentWays[removed[i3]].delete(oldentity.id);
26879         }
26880         for (i3 = 0; i3 < added.length; i3++) {
26881           parentWays[added[i3]] = new Set(parentWays[added[i3]]);
26882           parentWays[added[i3]].add(entity.id);
26883         }
26884       } else if (type2 === "relation") {
26885         var oldentityMemberIDs = oldentity ? oldentity.members.map(function(m2) {
26886           return m2.id;
26887         }) : [];
26888         var entityMemberIDs = entity ? entity.members.map(function(m2) {
26889           return m2.id;
26890         }) : [];
26891         if (oldentity && entity) {
26892           removed = utilArrayDifference(oldentityMemberIDs, entityMemberIDs);
26893           added = utilArrayDifference(entityMemberIDs, oldentityMemberIDs);
26894         } else if (oldentity) {
26895           removed = oldentityMemberIDs;
26896           added = [];
26897         } else if (entity) {
26898           removed = [];
26899           added = entityMemberIDs;
26900         }
26901         for (i3 = 0; i3 < removed.length; i3++) {
26902           parentRels[removed[i3]] = new Set(parentRels[removed[i3]]);
26903           parentRels[removed[i3]].delete(oldentity.id);
26904         }
26905         for (i3 = 0; i3 < added.length; i3++) {
26906           parentRels[added[i3]] = new Set(parentRels[added[i3]]);
26907           parentRels[added[i3]].add(entity.id);
26908         }
26909       }
26910     },
26911     replace: function(entity) {
26912       if (this.entities[entity.id] === entity) return this;
26913       return this.update(function() {
26914         this._updateCalculated(this.entities[entity.id], entity);
26915         this.entities[entity.id] = entity;
26916       });
26917     },
26918     remove: function(entity) {
26919       return this.update(function() {
26920         this._updateCalculated(entity, void 0);
26921         this.entities[entity.id] = void 0;
26922       });
26923     },
26924     revert: function(id2) {
26925       var baseEntity = this.base().entities[id2];
26926       var headEntity = this.entities[id2];
26927       if (headEntity === baseEntity) return this;
26928       return this.update(function() {
26929         this._updateCalculated(headEntity, baseEntity);
26930         delete this.entities[id2];
26931       });
26932     },
26933     update: function() {
26934       var graph = this.frozen ? coreGraph(this, true) : this;
26935       for (var i3 = 0; i3 < arguments.length; i3++) {
26936         arguments[i3].call(graph, graph);
26937       }
26938       if (this.frozen) graph.frozen = true;
26939       return graph;
26940     },
26941     // Obliterates any existing entities
26942     load: function(entities) {
26943       var base = this.base();
26944       this.entities = Object.create(base.entities);
26945       for (var i3 in entities) {
26946         this.entities[i3] = entities[i3];
26947         this._updateCalculated(base.entities[i3], this.entities[i3]);
26948       }
26949       return this;
26950     }
26951   };
26952
26953   // modules/osm/intersection.js
26954   function osmTurn(turn) {
26955     if (!(this instanceof osmTurn)) {
26956       return new osmTurn(turn);
26957     }
26958     Object.assign(this, turn);
26959   }
26960   function osmIntersection(graph, startVertexId, maxDistance) {
26961     maxDistance = maxDistance || 30;
26962     var vgraph = coreGraph();
26963     var i3, j2, k2;
26964     function memberOfRestriction(entity) {
26965       return graph.parentRelations(entity).some(function(r2) {
26966         return r2.isRestriction();
26967       });
26968     }
26969     function isRoad(way2) {
26970       if (way2.isArea() || way2.isDegenerate()) return false;
26971       var roads = {
26972         "motorway": true,
26973         "motorway_link": true,
26974         "trunk": true,
26975         "trunk_link": true,
26976         "primary": true,
26977         "primary_link": true,
26978         "secondary": true,
26979         "secondary_link": true,
26980         "tertiary": true,
26981         "tertiary_link": true,
26982         "residential": true,
26983         "unclassified": true,
26984         "living_street": true,
26985         "service": true,
26986         "busway": true,
26987         "road": true,
26988         "track": true
26989       };
26990       return roads[way2.tags.highway];
26991     }
26992     var startNode = graph.entity(startVertexId);
26993     var checkVertices = [startNode];
26994     var checkWays;
26995     var vertices = [];
26996     var vertexIds = [];
26997     var vertex;
26998     var ways = [];
26999     var wayIds = [];
27000     var way;
27001     var nodes = [];
27002     var node;
27003     var parents = [];
27004     var parent;
27005     var actions = [];
27006     while (checkVertices.length) {
27007       vertex = checkVertices.pop();
27008       checkWays = graph.parentWays(vertex);
27009       var hasWays = false;
27010       for (i3 = 0; i3 < checkWays.length; i3++) {
27011         way = checkWays[i3];
27012         if (!isRoad(way) && !memberOfRestriction(way)) continue;
27013         ways.push(way);
27014         hasWays = true;
27015         nodes = utilArrayUniq(graph.childNodes(way));
27016         for (j2 = 0; j2 < nodes.length; j2++) {
27017           node = nodes[j2];
27018           if (node === vertex) continue;
27019           if (vertices.indexOf(node) !== -1) continue;
27020           if (geoSphericalDistance(node.loc, startNode.loc) > maxDistance) continue;
27021           var hasParents = false;
27022           parents = graph.parentWays(node);
27023           for (k2 = 0; k2 < parents.length; k2++) {
27024             parent = parents[k2];
27025             if (parent === way) continue;
27026             if (ways.indexOf(parent) !== -1) continue;
27027             if (!isRoad(parent)) continue;
27028             hasParents = true;
27029             break;
27030           }
27031           if (hasParents) {
27032             checkVertices.push(node);
27033           }
27034         }
27035       }
27036       if (hasWays) {
27037         vertices.push(vertex);
27038       }
27039     }
27040     vertices = utilArrayUniq(vertices);
27041     ways = utilArrayUniq(ways);
27042     ways.forEach(function(way2) {
27043       graph.childNodes(way2).forEach(function(node2) {
27044         vgraph = vgraph.replace(node2);
27045       });
27046       vgraph = vgraph.replace(way2);
27047       graph.parentRelations(way2).forEach(function(relation) {
27048         if (relation.isRestriction()) {
27049           if (relation.isValidRestriction(graph)) {
27050             vgraph = vgraph.replace(relation);
27051           } else if (relation.isComplete(graph)) {
27052             actions.push(actionDeleteRelation(relation.id));
27053           }
27054         }
27055       });
27056     });
27057     ways.forEach(function(w2) {
27058       var way2 = vgraph.entity(w2.id);
27059       if (way2.tags.oneway === "-1") {
27060         var action = actionReverse(way2.id, { reverseOneway: true });
27061         actions.push(action);
27062         vgraph = action(vgraph);
27063       }
27064     });
27065     var origCount = osmEntity.id.next.way;
27066     vertices.forEach(function(v2) {
27067       var splitAll = actionSplit([v2.id]).keepHistoryOn("first");
27068       if (!splitAll.disabled(vgraph)) {
27069         splitAll.ways(vgraph).forEach(function(way2) {
27070           var splitOne = actionSplit([v2.id]).limitWays([way2.id]).keepHistoryOn("first");
27071           actions.push(splitOne);
27072           vgraph = splitOne(vgraph);
27073         });
27074       }
27075     });
27076     osmEntity.id.next.way = origCount;
27077     vertexIds = vertices.map(function(v2) {
27078       return v2.id;
27079     });
27080     vertices = [];
27081     ways = [];
27082     vertexIds.forEach(function(id2) {
27083       var vertex2 = vgraph.entity(id2);
27084       var parents2 = vgraph.parentWays(vertex2);
27085       vertices.push(vertex2);
27086       ways = ways.concat(parents2);
27087     });
27088     vertices = utilArrayUniq(vertices);
27089     ways = utilArrayUniq(ways);
27090     vertexIds = vertices.map(function(v2) {
27091       return v2.id;
27092     });
27093     wayIds = ways.map(function(w2) {
27094       return w2.id;
27095     });
27096     function withMetadata(way2, vertexIds2) {
27097       var __oneWay = way2.isOneWay();
27098       var __first = vertexIds2.indexOf(way2.first()) !== -1;
27099       var __last = vertexIds2.indexOf(way2.last()) !== -1;
27100       var __via = __first && __last;
27101       var __from = __first && !__oneWay || __last;
27102       var __to = __first || __last && !__oneWay;
27103       return way2.update({
27104         __first,
27105         __last,
27106         __from,
27107         __via,
27108         __to,
27109         __oneWay
27110       });
27111     }
27112     ways = [];
27113     wayIds.forEach(function(id2) {
27114       var way2 = withMetadata(vgraph.entity(id2), vertexIds);
27115       vgraph = vgraph.replace(way2);
27116       ways.push(way2);
27117     });
27118     var keepGoing;
27119     var removeWayIds = [];
27120     var removeVertexIds = [];
27121     do {
27122       keepGoing = false;
27123       checkVertices = vertexIds.slice();
27124       for (i3 = 0; i3 < checkVertices.length; i3++) {
27125         var vertexId = checkVertices[i3];
27126         vertex = vgraph.hasEntity(vertexId);
27127         if (!vertex) {
27128           if (vertexIds.indexOf(vertexId) !== -1) {
27129             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
27130           }
27131           removeVertexIds.push(vertexId);
27132           continue;
27133         }
27134         parents = vgraph.parentWays(vertex);
27135         if (parents.length < 3) {
27136           if (vertexIds.indexOf(vertexId) !== -1) {
27137             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
27138           }
27139         }
27140         if (parents.length === 2) {
27141           var a2 = parents[0];
27142           var b2 = parents[1];
27143           var aIsLeaf = a2 && !a2.__via;
27144           var bIsLeaf = b2 && !b2.__via;
27145           var leaf, survivor;
27146           if (aIsLeaf && !bIsLeaf) {
27147             leaf = a2;
27148             survivor = b2;
27149           } else if (!aIsLeaf && bIsLeaf) {
27150             leaf = b2;
27151             survivor = a2;
27152           }
27153           if (leaf && survivor) {
27154             survivor = withMetadata(survivor, vertexIds);
27155             vgraph = vgraph.replace(survivor).remove(leaf);
27156             removeWayIds.push(leaf.id);
27157             keepGoing = true;
27158           }
27159         }
27160         parents = vgraph.parentWays(vertex);
27161         if (parents.length < 2) {
27162           if (vertexIds.indexOf(vertexId) !== -1) {
27163             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
27164           }
27165           removeVertexIds.push(vertexId);
27166           keepGoing = true;
27167         }
27168         if (parents.length < 1) {
27169           vgraph = vgraph.remove(vertex);
27170         }
27171       }
27172     } while (keepGoing);
27173     vertices = vertices.filter(function(vertex2) {
27174       return removeVertexIds.indexOf(vertex2.id) === -1;
27175     }).map(function(vertex2) {
27176       return vgraph.entity(vertex2.id);
27177     });
27178     ways = ways.filter(function(way2) {
27179       return removeWayIds.indexOf(way2.id) === -1;
27180     }).map(function(way2) {
27181       return vgraph.entity(way2.id);
27182     });
27183     var intersection2 = {
27184       graph: vgraph,
27185       actions,
27186       vertices,
27187       ways
27188     };
27189     intersection2.turns = function(fromWayId, maxViaWay) {
27190       if (!fromWayId) return [];
27191       if (!maxViaWay) maxViaWay = 0;
27192       var vgraph2 = intersection2.graph;
27193       var keyVertexIds = intersection2.vertices.map(function(v2) {
27194         return v2.id;
27195       });
27196       var start2 = vgraph2.entity(fromWayId);
27197       if (!start2 || !(start2.__from || start2.__via)) return [];
27198       var maxPathLength = maxViaWay * 2 + 3;
27199       var turns = [];
27200       step(start2);
27201       return turns;
27202       function step(entity, currPath, currRestrictions, matchedRestriction) {
27203         currPath = (currPath || []).slice();
27204         if (currPath.length >= maxPathLength) return;
27205         currPath.push(entity.id);
27206         currRestrictions = (currRestrictions || []).slice();
27207         if (entity.type === "node") {
27208           stepNode(entity, currPath, currRestrictions);
27209         } else {
27210           stepWay(entity, currPath, currRestrictions, matchedRestriction);
27211         }
27212       }
27213       function stepNode(entity, currPath, currRestrictions) {
27214         var i4, j3;
27215         var parents2 = vgraph2.parentWays(entity);
27216         var nextWays = [];
27217         for (i4 = 0; i4 < parents2.length; i4++) {
27218           var way2 = parents2[i4];
27219           if (way2.__oneWay && way2.nodes[0] !== entity.id) continue;
27220           if (currPath.indexOf(way2.id) !== -1 && currPath.length >= 3) continue;
27221           var restrict = null;
27222           for (j3 = 0; j3 < currRestrictions.length; j3++) {
27223             var restriction = currRestrictions[j3];
27224             var f2 = restriction.memberByRole("from");
27225             var v2 = restriction.membersByRole("via");
27226             var t2 = restriction.memberByRole("to");
27227             var isNo = /^no_/.test(restriction.tags.restriction);
27228             var isOnly = /^only_/.test(restriction.tags.restriction);
27229             if (!(isNo || isOnly)) {
27230               continue;
27231             }
27232             var matchesFrom = f2.id === fromWayId;
27233             var matchesViaTo = false;
27234             var isAlongOnlyPath = false;
27235             if (t2.id === way2.id) {
27236               if (v2.length === 1 && v2[0].type === "node") {
27237                 matchesViaTo = v2[0].id === entity.id && (matchesFrom && currPath.length === 2 || !matchesFrom && currPath.length > 2);
27238               } else {
27239                 var pathVias = [];
27240                 for (k2 = 2; k2 < currPath.length; k2 += 2) {
27241                   pathVias.push(currPath[k2]);
27242                 }
27243                 var restrictionVias = [];
27244                 for (k2 = 0; k2 < v2.length; k2++) {
27245                   if (v2[k2].type === "way") {
27246                     restrictionVias.push(v2[k2].id);
27247                   }
27248                 }
27249                 var diff = utilArrayDifference(pathVias, restrictionVias);
27250                 matchesViaTo = !diff.length;
27251               }
27252             } else if (isOnly) {
27253               for (k2 = 0; k2 < v2.length; k2++) {
27254                 if (v2[k2].type === "way" && v2[k2].id === way2.id) {
27255                   isAlongOnlyPath = true;
27256                   break;
27257                 }
27258               }
27259             }
27260             if (matchesViaTo) {
27261               if (isOnly) {
27262                 restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, only: true, end: true };
27263               } else {
27264                 restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, no: true, end: true };
27265               }
27266             } else {
27267               if (isAlongOnlyPath) {
27268                 restrict = { id: restriction.id, direct: false, from: f2.id, only: true, end: false };
27269               } else if (isOnly) {
27270                 restrict = { id: restriction.id, direct: false, from: f2.id, no: true, end: true };
27271               }
27272             }
27273             if (restrict && restrict.direct) break;
27274           }
27275           nextWays.push({ way: way2, restrict });
27276         }
27277         nextWays.forEach(function(nextWay) {
27278           step(nextWay.way, currPath, currRestrictions, nextWay.restrict);
27279         });
27280       }
27281       function stepWay(entity, currPath, currRestrictions, matchedRestriction) {
27282         var i4;
27283         if (currPath.length >= 3) {
27284           var turnPath = currPath.slice();
27285           if (matchedRestriction && matchedRestriction.direct === false) {
27286             for (i4 = 0; i4 < turnPath.length; i4++) {
27287               if (turnPath[i4] === matchedRestriction.from) {
27288                 turnPath = turnPath.slice(i4);
27289                 break;
27290               }
27291             }
27292           }
27293           var turn = pathToTurn(turnPath);
27294           if (turn) {
27295             if (matchedRestriction) {
27296               turn.restrictionID = matchedRestriction.id;
27297               turn.no = matchedRestriction.no;
27298               turn.only = matchedRestriction.only;
27299               turn.direct = matchedRestriction.direct;
27300             }
27301             turns.push(osmTurn(turn));
27302           }
27303           if (currPath[0] === currPath[2]) return;
27304         }
27305         if (matchedRestriction && matchedRestriction.end) return;
27306         var n1 = vgraph2.entity(entity.first());
27307         var n22 = vgraph2.entity(entity.last());
27308         var dist = geoSphericalDistance(n1.loc, n22.loc);
27309         var nextNodes = [];
27310         if (currPath.length > 1) {
27311           if (dist > maxDistance) return;
27312           if (!entity.__via) return;
27313         }
27314         if (!entity.__oneWay && // bidirectional..
27315         keyVertexIds.indexOf(n1.id) !== -1 && // key vertex..
27316         currPath.indexOf(n1.id) === -1) {
27317           nextNodes.push(n1);
27318         }
27319         if (keyVertexIds.indexOf(n22.id) !== -1 && // key vertex..
27320         currPath.indexOf(n22.id) === -1) {
27321           nextNodes.push(n22);
27322         }
27323         nextNodes.forEach(function(nextNode) {
27324           var fromRestrictions = vgraph2.parentRelations(entity).filter(function(r2) {
27325             if (!r2.isRestriction()) return false;
27326             var f2 = r2.memberByRole("from");
27327             if (!f2 || f2.id !== entity.id) return false;
27328             var isOnly = /^only_/.test(r2.tags.restriction);
27329             if (!isOnly) return true;
27330             var isOnlyVia = false;
27331             var v2 = r2.membersByRole("via");
27332             if (v2.length === 1 && v2[0].type === "node") {
27333               isOnlyVia = v2[0].id === nextNode.id;
27334             } else {
27335               for (var i5 = 0; i5 < v2.length; i5++) {
27336                 if (v2[i5].type !== "way") continue;
27337                 var viaWay = vgraph2.entity(v2[i5].id);
27338                 if (viaWay.first() === nextNode.id || viaWay.last() === nextNode.id) {
27339                   isOnlyVia = true;
27340                   break;
27341                 }
27342               }
27343             }
27344             return isOnlyVia;
27345           });
27346           step(nextNode, currPath, currRestrictions.concat(fromRestrictions), false);
27347         });
27348       }
27349       function pathToTurn(path) {
27350         if (path.length < 3) return;
27351         var fromWayId2, fromNodeId, fromVertexId;
27352         var toWayId, toNodeId, toVertexId;
27353         var viaWayIds, viaNodeId, isUturn;
27354         fromWayId2 = path[0];
27355         toWayId = path[path.length - 1];
27356         if (path.length === 3 && fromWayId2 === toWayId) {
27357           var way2 = vgraph2.entity(fromWayId2);
27358           if (way2.__oneWay) return null;
27359           isUturn = true;
27360           viaNodeId = fromVertexId = toVertexId = path[1];
27361           fromNodeId = toNodeId = adjacentNode(fromWayId2, viaNodeId);
27362         } else {
27363           isUturn = false;
27364           fromVertexId = path[1];
27365           fromNodeId = adjacentNode(fromWayId2, fromVertexId);
27366           toVertexId = path[path.length - 2];
27367           toNodeId = adjacentNode(toWayId, toVertexId);
27368           if (path.length === 3) {
27369             viaNodeId = path[1];
27370           } else {
27371             viaWayIds = path.filter(function(entityId) {
27372               return entityId[0] === "w";
27373             });
27374             viaWayIds = viaWayIds.slice(1, viaWayIds.length - 1);
27375           }
27376         }
27377         return {
27378           key: path.join("_"),
27379           path,
27380           from: { node: fromNodeId, way: fromWayId2, vertex: fromVertexId },
27381           via: { node: viaNodeId, ways: viaWayIds },
27382           to: { node: toNodeId, way: toWayId, vertex: toVertexId },
27383           u: isUturn
27384         };
27385         function adjacentNode(wayId, affixId) {
27386           var nodes2 = vgraph2.entity(wayId).nodes;
27387           return affixId === nodes2[0] ? nodes2[1] : nodes2[nodes2.length - 2];
27388         }
27389       }
27390     };
27391     return intersection2;
27392   }
27393   function osmInferRestriction(graph, turn, projection2) {
27394     var fromWay = graph.entity(turn.from.way);
27395     var fromNode = graph.entity(turn.from.node);
27396     var fromVertex = graph.entity(turn.from.vertex);
27397     var toWay = graph.entity(turn.to.way);
27398     var toNode = graph.entity(turn.to.node);
27399     var toVertex = graph.entity(turn.to.vertex);
27400     var fromOneWay = fromWay.tags.oneway === "yes";
27401     var toOneWay = toWay.tags.oneway === "yes";
27402     var angle2 = (geoAngle(fromVertex, fromNode, projection2) - geoAngle(toVertex, toNode, projection2)) * 180 / Math.PI;
27403     while (angle2 < 0) {
27404       angle2 += 360;
27405     }
27406     if (fromNode === toNode) {
27407       return "no_u_turn";
27408     }
27409     if ((angle2 < 23 || angle2 > 336) && fromOneWay && toOneWay) {
27410       return "no_u_turn";
27411     }
27412     if ((angle2 < 40 || angle2 > 319) && fromOneWay && toOneWay && turn.from.vertex !== turn.to.vertex) {
27413       return "no_u_turn";
27414     }
27415     if (angle2 < 158) {
27416       return "no_right_turn";
27417     }
27418     if (angle2 > 202) {
27419       return "no_left_turn";
27420     }
27421     return "no_straight_on";
27422   }
27423
27424   // modules/actions/merge_polygon.js
27425   function actionMergePolygon(ids, newRelationId) {
27426     function groupEntities(graph) {
27427       var entities = ids.map(function(id2) {
27428         return graph.entity(id2);
27429       });
27430       var geometryGroups = utilArrayGroupBy(entities, function(entity) {
27431         if (entity.type === "way" && entity.isClosed()) {
27432           return "closedWay";
27433         } else if (entity.type === "relation" && entity.isMultipolygon()) {
27434           return "multipolygon";
27435         } else {
27436           return "other";
27437         }
27438       });
27439       return Object.assign(
27440         { closedWay: [], multipolygon: [], other: [] },
27441         geometryGroups
27442       );
27443     }
27444     var action = function(graph) {
27445       var entities = groupEntities(graph);
27446       var polygons = entities.multipolygon.reduce(function(polygons2, m2) {
27447         return polygons2.concat(osmJoinWays(m2.members, graph));
27448       }, []).concat(entities.closedWay.map(function(d2) {
27449         var member = [{ id: d2.id }];
27450         member.nodes = graph.childNodes(d2);
27451         return member;
27452       }));
27453       var contained = polygons.map(function(w2, i3) {
27454         return polygons.map(function(d2, n3) {
27455           if (i3 === n3) return null;
27456           return geoPolygonContainsPolygon(
27457             d2.nodes.map(function(n4) {
27458               return n4.loc;
27459             }),
27460             w2.nodes.map(function(n4) {
27461               return n4.loc;
27462             })
27463           );
27464         });
27465       });
27466       var members = [];
27467       var outer = true;
27468       while (polygons.length) {
27469         extractUncontained(polygons);
27470         polygons = polygons.filter(isContained);
27471         contained = contained.filter(isContained).map(filterContained);
27472       }
27473       function isContained(d2, i3) {
27474         return contained[i3].some(function(val) {
27475           return val;
27476         });
27477       }
27478       function filterContained(d2) {
27479         return d2.filter(isContained);
27480       }
27481       function extractUncontained(polygons2) {
27482         polygons2.forEach(function(d2, i3) {
27483           if (!isContained(d2, i3)) {
27484             d2.forEach(function(member) {
27485               members.push({
27486                 type: "way",
27487                 id: member.id,
27488                 role: outer ? "outer" : "inner"
27489               });
27490             });
27491           }
27492         });
27493         outer = !outer;
27494       }
27495       var relation;
27496       if (entities.multipolygon.length > 0) {
27497         var oldestID = utilOldestID(entities.multipolygon.map((entity) => entity.id));
27498         relation = entities.multipolygon.find((entity) => entity.id === oldestID);
27499       } else {
27500         relation = osmRelation({ id: newRelationId, tags: { type: "multipolygon" } });
27501       }
27502       entities.multipolygon.forEach(function(m2) {
27503         if (m2.id !== relation.id) {
27504           relation = relation.mergeTags(m2.tags);
27505           graph = graph.remove(m2);
27506         }
27507       });
27508       entities.closedWay.forEach(function(way) {
27509         function isThisOuter(m2) {
27510           return m2.id === way.id && m2.role !== "inner";
27511         }
27512         if (members.some(isThisOuter)) {
27513           relation = relation.mergeTags(way.tags);
27514           graph = graph.replace(way.update({ tags: {} }));
27515         }
27516       });
27517       return graph.replace(relation.update({
27518         members,
27519         tags: utilObjectOmit(relation.tags, ["area"])
27520       }));
27521     };
27522     action.disabled = function(graph) {
27523       var entities = groupEntities(graph);
27524       if (entities.other.length > 0 || entities.closedWay.length + entities.multipolygon.length < 2) {
27525         return "not_eligible";
27526       }
27527       if (!entities.multipolygon.every(function(r2) {
27528         return r2.isComplete(graph);
27529       })) {
27530         return "incomplete_relation";
27531       }
27532       if (!entities.multipolygon.length) {
27533         var sharedMultipolygons = [];
27534         entities.closedWay.forEach(function(way, i3) {
27535           if (i3 === 0) {
27536             sharedMultipolygons = graph.parentMultipolygons(way);
27537           } else {
27538             sharedMultipolygons = utilArrayIntersection(sharedMultipolygons, graph.parentMultipolygons(way));
27539           }
27540         });
27541         sharedMultipolygons = sharedMultipolygons.filter(function(relation) {
27542           return relation.members.length === entities.closedWay.length;
27543         });
27544         if (sharedMultipolygons.length) {
27545           return "not_eligible";
27546         }
27547       } else if (entities.closedWay.some(function(way) {
27548         return utilArrayIntersection(graph.parentMultipolygons(way), entities.multipolygon).length;
27549       })) {
27550         return "not_eligible";
27551       }
27552     };
27553     return action;
27554   }
27555
27556   // modules/actions/merge_remote_changes.js
27557   var import_fast_deep_equal = __toESM(require_fast_deep_equal());
27558
27559   // node_modules/node-diff3/index.mjs
27560   function LCS(buffer1, buffer2) {
27561     let equivalenceClasses = {};
27562     for (let j2 = 0; j2 < buffer2.length; j2++) {
27563       const item = buffer2[j2];
27564       if (equivalenceClasses[item]) {
27565         equivalenceClasses[item].push(j2);
27566       } else {
27567         equivalenceClasses[item] = [j2];
27568       }
27569     }
27570     const NULLRESULT = { buffer1index: -1, buffer2index: -1, chain: null };
27571     let candidates = [NULLRESULT];
27572     for (let i3 = 0; i3 < buffer1.length; i3++) {
27573       const item = buffer1[i3];
27574       const buffer2indices = equivalenceClasses[item] || [];
27575       let r2 = 0;
27576       let c2 = candidates[0];
27577       for (let jx = 0; jx < buffer2indices.length; jx++) {
27578         const j2 = buffer2indices[jx];
27579         let s2;
27580         for (s2 = r2; s2 < candidates.length; s2++) {
27581           if (candidates[s2].buffer2index < j2 && (s2 === candidates.length - 1 || candidates[s2 + 1].buffer2index > j2)) {
27582             break;
27583           }
27584         }
27585         if (s2 < candidates.length) {
27586           const newCandidate = { buffer1index: i3, buffer2index: j2, chain: candidates[s2] };
27587           if (r2 === candidates.length) {
27588             candidates.push(c2);
27589           } else {
27590             candidates[r2] = c2;
27591           }
27592           r2 = s2 + 1;
27593           c2 = newCandidate;
27594           if (r2 === candidates.length) {
27595             break;
27596           }
27597         }
27598       }
27599       candidates[r2] = c2;
27600     }
27601     return candidates[candidates.length - 1];
27602   }
27603   function diffIndices(buffer1, buffer2) {
27604     const lcs = LCS(buffer1, buffer2);
27605     let result = [];
27606     let tail1 = buffer1.length;
27607     let tail2 = buffer2.length;
27608     for (let candidate = lcs; candidate !== null; candidate = candidate.chain) {
27609       const mismatchLength1 = tail1 - candidate.buffer1index - 1;
27610       const mismatchLength2 = tail2 - candidate.buffer2index - 1;
27611       tail1 = candidate.buffer1index;
27612       tail2 = candidate.buffer2index;
27613       if (mismatchLength1 || mismatchLength2) {
27614         result.push({
27615           buffer1: [tail1 + 1, mismatchLength1],
27616           buffer1Content: buffer1.slice(tail1 + 1, tail1 + 1 + mismatchLength1),
27617           buffer2: [tail2 + 1, mismatchLength2],
27618           buffer2Content: buffer2.slice(tail2 + 1, tail2 + 1 + mismatchLength2)
27619         });
27620       }
27621     }
27622     result.reverse();
27623     return result;
27624   }
27625   function diff3MergeRegions(a2, o2, b2) {
27626     let hunks = [];
27627     function addHunk(h2, ab) {
27628       hunks.push({
27629         ab,
27630         oStart: h2.buffer1[0],
27631         oLength: h2.buffer1[1],
27632         // length of o to remove
27633         abStart: h2.buffer2[0],
27634         abLength: h2.buffer2[1]
27635         // length of a/b to insert
27636         // abContent: (ab === 'a' ? a : b).slice(h.buffer2[0], h.buffer2[0] + h.buffer2[1])
27637       });
27638     }
27639     diffIndices(o2, a2).forEach((item) => addHunk(item, "a"));
27640     diffIndices(o2, b2).forEach((item) => addHunk(item, "b"));
27641     hunks.sort((x2, y2) => x2.oStart - y2.oStart);
27642     let results = [];
27643     let currOffset = 0;
27644     function advanceTo(endOffset) {
27645       if (endOffset > currOffset) {
27646         results.push({
27647           stable: true,
27648           buffer: "o",
27649           bufferStart: currOffset,
27650           bufferLength: endOffset - currOffset,
27651           bufferContent: o2.slice(currOffset, endOffset)
27652         });
27653         currOffset = endOffset;
27654       }
27655     }
27656     while (hunks.length) {
27657       let hunk = hunks.shift();
27658       let regionStart = hunk.oStart;
27659       let regionEnd = hunk.oStart + hunk.oLength;
27660       let regionHunks = [hunk];
27661       advanceTo(regionStart);
27662       while (hunks.length) {
27663         const nextHunk = hunks[0];
27664         const nextHunkStart = nextHunk.oStart;
27665         if (nextHunkStart > regionEnd) break;
27666         regionEnd = Math.max(regionEnd, nextHunkStart + nextHunk.oLength);
27667         regionHunks.push(hunks.shift());
27668       }
27669       if (regionHunks.length === 1) {
27670         if (hunk.abLength > 0) {
27671           const buffer = hunk.ab === "a" ? a2 : b2;
27672           results.push({
27673             stable: true,
27674             buffer: hunk.ab,
27675             bufferStart: hunk.abStart,
27676             bufferLength: hunk.abLength,
27677             bufferContent: buffer.slice(hunk.abStart, hunk.abStart + hunk.abLength)
27678           });
27679         }
27680       } else {
27681         let bounds = {
27682           a: [a2.length, -1, o2.length, -1],
27683           b: [b2.length, -1, o2.length, -1]
27684         };
27685         while (regionHunks.length) {
27686           hunk = regionHunks.shift();
27687           const oStart = hunk.oStart;
27688           const oEnd = oStart + hunk.oLength;
27689           const abStart = hunk.abStart;
27690           const abEnd = abStart + hunk.abLength;
27691           let b3 = bounds[hunk.ab];
27692           b3[0] = Math.min(abStart, b3[0]);
27693           b3[1] = Math.max(abEnd, b3[1]);
27694           b3[2] = Math.min(oStart, b3[2]);
27695           b3[3] = Math.max(oEnd, b3[3]);
27696         }
27697         const aStart = bounds.a[0] + (regionStart - bounds.a[2]);
27698         const aEnd = bounds.a[1] + (regionEnd - bounds.a[3]);
27699         const bStart = bounds.b[0] + (regionStart - bounds.b[2]);
27700         const bEnd = bounds.b[1] + (regionEnd - bounds.b[3]);
27701         let result = {
27702           stable: false,
27703           aStart,
27704           aLength: aEnd - aStart,
27705           aContent: a2.slice(aStart, aEnd),
27706           oStart: regionStart,
27707           oLength: regionEnd - regionStart,
27708           oContent: o2.slice(regionStart, regionEnd),
27709           bStart,
27710           bLength: bEnd - bStart,
27711           bContent: b2.slice(bStart, bEnd)
27712         };
27713         results.push(result);
27714       }
27715       currOffset = regionEnd;
27716     }
27717     advanceTo(o2.length);
27718     return results;
27719   }
27720   function diff3Merge(a2, o2, b2, options2) {
27721     let defaults = {
27722       excludeFalseConflicts: true,
27723       stringSeparator: /\s+/
27724     };
27725     options2 = Object.assign(defaults, options2);
27726     if (typeof a2 === "string") a2 = a2.split(options2.stringSeparator);
27727     if (typeof o2 === "string") o2 = o2.split(options2.stringSeparator);
27728     if (typeof b2 === "string") b2 = b2.split(options2.stringSeparator);
27729     let results = [];
27730     const regions = diff3MergeRegions(a2, o2, b2);
27731     let okBuffer = [];
27732     function flushOk() {
27733       if (okBuffer.length) {
27734         results.push({ ok: okBuffer });
27735       }
27736       okBuffer = [];
27737     }
27738     function isFalseConflict(a3, b3) {
27739       if (a3.length !== b3.length) return false;
27740       for (let i3 = 0; i3 < a3.length; i3++) {
27741         if (a3[i3] !== b3[i3]) return false;
27742       }
27743       return true;
27744     }
27745     regions.forEach((region) => {
27746       if (region.stable) {
27747         okBuffer.push(...region.bufferContent);
27748       } else {
27749         if (options2.excludeFalseConflicts && isFalseConflict(region.aContent, region.bContent)) {
27750           okBuffer.push(...region.aContent);
27751         } else {
27752           flushOk();
27753           results.push({
27754             conflict: {
27755               a: region.aContent,
27756               aIndex: region.aStart,
27757               o: region.oContent,
27758               oIndex: region.oStart,
27759               b: region.bContent,
27760               bIndex: region.bStart
27761             }
27762           });
27763         }
27764       }
27765     });
27766     flushOk();
27767     return results;
27768   }
27769
27770   // modules/actions/merge_remote_changes.js
27771   var import_lodash = __toESM(require_lodash());
27772   function actionMergeRemoteChanges(id2, localGraph, remoteGraph, discardTags, formatUser) {
27773     discardTags = discardTags || {};
27774     var _option = "safe";
27775     var _conflicts = [];
27776     function user(d2) {
27777       return typeof formatUser === "function" ? formatUser(d2) : (0, import_lodash.escape)(d2);
27778     }
27779     function mergeLocation(remote, target) {
27780       function pointEqual(a2, b2) {
27781         var epsilon3 = 1e-6;
27782         return Math.abs(a2[0] - b2[0]) < epsilon3 && Math.abs(a2[1] - b2[1]) < epsilon3;
27783       }
27784       if (_option === "force_local" || pointEqual(target.loc, remote.loc)) {
27785         return target;
27786       }
27787       if (_option === "force_remote") {
27788         return target.update({ loc: remote.loc });
27789       }
27790       _conflicts.push(_t.html("merge_remote_changes.conflict.location", { user: { html: user(remote.user) } }));
27791       return target;
27792     }
27793     function mergeNodes(base, remote, target) {
27794       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.nodes, remote.nodes)) {
27795         return target;
27796       }
27797       if (_option === "force_remote") {
27798         return target.update({ nodes: remote.nodes });
27799       }
27800       var ccount = _conflicts.length;
27801       var o2 = base.nodes || [];
27802       var a2 = target.nodes || [];
27803       var b2 = remote.nodes || [];
27804       var nodes = [];
27805       var hunks = diff3Merge(a2, o2, b2, { excludeFalseConflicts: true });
27806       for (var i3 = 0; i3 < hunks.length; i3++) {
27807         var hunk = hunks[i3];
27808         if (hunk.ok) {
27809           nodes.push.apply(nodes, hunk.ok);
27810         } else {
27811           var c2 = hunk.conflict;
27812           if ((0, import_fast_deep_equal.default)(c2.o, c2.a)) {
27813             nodes.push.apply(nodes, c2.b);
27814           } else if ((0, import_fast_deep_equal.default)(c2.o, c2.b)) {
27815             nodes.push.apply(nodes, c2.a);
27816           } else {
27817             _conflicts.push(_t.html("merge_remote_changes.conflict.nodelist", { user: { html: user(remote.user) } }));
27818             break;
27819           }
27820         }
27821       }
27822       return _conflicts.length === ccount ? target.update({ nodes }) : target;
27823     }
27824     function mergeChildren(targetWay, children2, updates, graph) {
27825       function isUsed(node2, targetWay2) {
27826         var hasInterestingParent = graph.parentWays(node2).some(function(way) {
27827           return way.id !== targetWay2.id;
27828         });
27829         return node2.hasInterestingTags() || hasInterestingParent || graph.parentRelations(node2).length > 0;
27830       }
27831       var ccount = _conflicts.length;
27832       for (var i3 = 0; i3 < children2.length; i3++) {
27833         var id3 = children2[i3];
27834         var node = graph.hasEntity(id3);
27835         if (targetWay.nodes.indexOf(id3) === -1) {
27836           if (node && !isUsed(node, targetWay)) {
27837             updates.removeIds.push(id3);
27838           }
27839           continue;
27840         }
27841         var local = localGraph.hasEntity(id3);
27842         var remote = remoteGraph.hasEntity(id3);
27843         var target;
27844         if (_option === "force_remote" && remote && remote.visible) {
27845           updates.replacements.push(remote);
27846         } else if (_option === "force_local" && local) {
27847           target = osmEntity(local);
27848           if (remote) {
27849             target = target.update({ version: remote.version });
27850           }
27851           updates.replacements.push(target);
27852         } else if (_option === "safe" && local && remote && local.version !== remote.version) {
27853           target = osmEntity(local, { version: remote.version });
27854           if (remote.visible) {
27855             target = mergeLocation(remote, target);
27856           } else {
27857             _conflicts.push(_t.html("merge_remote_changes.conflict.deleted", { user: { html: user(remote.user) } }));
27858           }
27859           if (_conflicts.length !== ccount) break;
27860           updates.replacements.push(target);
27861         }
27862       }
27863       return targetWay;
27864     }
27865     function updateChildren(updates, graph) {
27866       for (var i3 = 0; i3 < updates.replacements.length; i3++) {
27867         graph = graph.replace(updates.replacements[i3]);
27868       }
27869       if (updates.removeIds.length) {
27870         graph = actionDeleteMultiple(updates.removeIds)(graph);
27871       }
27872       return graph;
27873     }
27874     function mergeMembers(remote, target) {
27875       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.members, remote.members)) {
27876         return target;
27877       }
27878       if (_option === "force_remote") {
27879         return target.update({ members: remote.members });
27880       }
27881       _conflicts.push(_t.html("merge_remote_changes.conflict.memberlist", { user: { html: user(remote.user) } }));
27882       return target;
27883     }
27884     function mergeTags(base, remote, target) {
27885       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.tags, remote.tags)) {
27886         return target;
27887       }
27888       if (_option === "force_remote") {
27889         return target.update({ tags: remote.tags });
27890       }
27891       var ccount = _conflicts.length;
27892       var o2 = base.tags || {};
27893       var a2 = target.tags || {};
27894       var b2 = remote.tags || {};
27895       var keys2 = utilArrayUnion(utilArrayUnion(Object.keys(o2), Object.keys(a2)), Object.keys(b2)).filter(function(k3) {
27896         return !discardTags[k3];
27897       });
27898       var tags = Object.assign({}, a2);
27899       var changed = false;
27900       for (var i3 = 0; i3 < keys2.length; i3++) {
27901         var k2 = keys2[i3];
27902         if (o2[k2] !== b2[k2] && a2[k2] !== b2[k2]) {
27903           if (o2[k2] !== a2[k2]) {
27904             _conflicts.push(_t.html(
27905               "merge_remote_changes.conflict.tags",
27906               { tag: k2, local: a2[k2], remote: b2[k2], user: { html: user(remote.user) } }
27907             ));
27908           } else {
27909             if (b2.hasOwnProperty(k2)) {
27910               tags[k2] = b2[k2];
27911             } else {
27912               delete tags[k2];
27913             }
27914             changed = true;
27915           }
27916         }
27917       }
27918       return changed && _conflicts.length === ccount ? target.update({ tags }) : target;
27919     }
27920     var action = function(graph) {
27921       var updates = { replacements: [], removeIds: [] };
27922       var base = graph.base().entities[id2];
27923       var local = localGraph.entity(id2);
27924       var remote = remoteGraph.entity(id2);
27925       var target = osmEntity(local, { version: remote.version });
27926       if (!remote.visible) {
27927         if (_option === "force_remote") {
27928           return actionDeleteMultiple([id2])(graph);
27929         } else if (_option === "force_local") {
27930           if (target.type === "way") {
27931             target = mergeChildren(target, utilArrayUniq(local.nodes), updates, graph);
27932             graph = updateChildren(updates, graph);
27933           }
27934           return graph.replace(target);
27935         } else {
27936           _conflicts.push(_t.html("merge_remote_changes.conflict.deleted", { user: { html: user(remote.user) } }));
27937           return graph;
27938         }
27939       }
27940       if (target.type === "node") {
27941         target = mergeLocation(remote, target);
27942       } else if (target.type === "way") {
27943         graph.rebase(remoteGraph.childNodes(remote), [graph], false);
27944         target = mergeNodes(base, remote, target);
27945         target = mergeChildren(target, utilArrayUnion(local.nodes, remote.nodes), updates, graph);
27946       } else if (target.type === "relation") {
27947         target = mergeMembers(remote, target);
27948       }
27949       target = mergeTags(base, remote, target);
27950       if (!_conflicts.length) {
27951         graph = updateChildren(updates, graph).replace(target);
27952       }
27953       return graph;
27954     };
27955     action.withOption = function(opt) {
27956       _option = opt;
27957       return action;
27958     };
27959     action.conflicts = function() {
27960       return _conflicts;
27961     };
27962     return action;
27963   }
27964
27965   // modules/actions/move.js
27966   function actionMove(moveIDs, tryDelta, projection2, cache) {
27967     var _delta = tryDelta;
27968     function setupCache(graph) {
27969       function canMove(nodeID) {
27970         if (moveIDs.indexOf(nodeID) !== -1) return true;
27971         var parents = graph.parentWays(graph.entity(nodeID));
27972         if (parents.length < 3) return true;
27973         var parentsMoving = parents.every(function(way) {
27974           return cache.moving[way.id];
27975         });
27976         if (!parentsMoving) delete cache.moving[nodeID];
27977         return parentsMoving;
27978       }
27979       function cacheEntities(ids) {
27980         for (var i3 = 0; i3 < ids.length; i3++) {
27981           var id2 = ids[i3];
27982           if (cache.moving[id2]) continue;
27983           cache.moving[id2] = true;
27984           var entity = graph.hasEntity(id2);
27985           if (!entity) continue;
27986           if (entity.type === "node") {
27987             cache.nodes.push(id2);
27988             cache.startLoc[id2] = entity.loc;
27989           } else if (entity.type === "way") {
27990             cache.ways.push(id2);
27991             cacheEntities(entity.nodes);
27992           } else {
27993             cacheEntities(entity.members.map(function(member) {
27994               return member.id;
27995             }));
27996           }
27997         }
27998       }
27999       function cacheIntersections(ids) {
28000         function isEndpoint(way2, id3) {
28001           return !way2.isClosed() && !!way2.affix(id3);
28002         }
28003         for (var i3 = 0; i3 < ids.length; i3++) {
28004           var id2 = ids[i3];
28005           var childNodes = graph.childNodes(graph.entity(id2));
28006           for (var j2 = 0; j2 < childNodes.length; j2++) {
28007             var node = childNodes[j2];
28008             var parents = graph.parentWays(node);
28009             if (parents.length !== 2) continue;
28010             var moved = graph.entity(id2);
28011             var unmoved = null;
28012             for (var k2 = 0; k2 < parents.length; k2++) {
28013               var way = parents[k2];
28014               if (!cache.moving[way.id]) {
28015                 unmoved = way;
28016                 break;
28017               }
28018             }
28019             if (!unmoved) continue;
28020             if (utilArrayIntersection(moved.nodes, unmoved.nodes).length > 2) continue;
28021             if (moved.isArea() || unmoved.isArea()) continue;
28022             cache.intersections.push({
28023               nodeId: node.id,
28024               movedId: moved.id,
28025               unmovedId: unmoved.id,
28026               movedIsEP: isEndpoint(moved, node.id),
28027               unmovedIsEP: isEndpoint(unmoved, node.id)
28028             });
28029           }
28030         }
28031       }
28032       if (!cache) {
28033         cache = {};
28034       }
28035       if (!cache.ok) {
28036         cache.moving = {};
28037         cache.intersections = [];
28038         cache.replacedVertex = {};
28039         cache.startLoc = {};
28040         cache.nodes = [];
28041         cache.ways = [];
28042         cacheEntities(moveIDs);
28043         cacheIntersections(cache.ways);
28044         cache.nodes = cache.nodes.filter(canMove);
28045         cache.ok = true;
28046       }
28047     }
28048     function replaceMovedVertex(nodeId, wayId, graph, delta) {
28049       var way = graph.entity(wayId);
28050       var moved = graph.entity(nodeId);
28051       var movedIndex = way.nodes.indexOf(nodeId);
28052       var len, prevIndex, nextIndex;
28053       if (way.isClosed()) {
28054         len = way.nodes.length - 1;
28055         prevIndex = (movedIndex + len - 1) % len;
28056         nextIndex = (movedIndex + len + 1) % len;
28057       } else {
28058         len = way.nodes.length;
28059         prevIndex = movedIndex - 1;
28060         nextIndex = movedIndex + 1;
28061       }
28062       var prev = graph.hasEntity(way.nodes[prevIndex]);
28063       var next = graph.hasEntity(way.nodes[nextIndex]);
28064       if (!prev || !next) return graph;
28065       var key = wayId + "_" + nodeId;
28066       var orig = cache.replacedVertex[key];
28067       if (!orig) {
28068         orig = osmNode();
28069         cache.replacedVertex[key] = orig;
28070         cache.startLoc[orig.id] = cache.startLoc[nodeId];
28071       }
28072       var start2, end;
28073       if (delta) {
28074         start2 = projection2(cache.startLoc[nodeId]);
28075         end = projection2.invert(geoVecAdd(start2, delta));
28076       } else {
28077         end = cache.startLoc[nodeId];
28078       }
28079       orig = orig.move(end);
28080       var angle2 = Math.abs(geoAngle(orig, prev, projection2) - geoAngle(orig, next, projection2)) * 180 / Math.PI;
28081       if (angle2 > 175 && angle2 < 185) return graph;
28082       var p1 = [prev.loc, orig.loc, moved.loc, next.loc].map(projection2);
28083       var p2 = [prev.loc, moved.loc, orig.loc, next.loc].map(projection2);
28084       var d1 = geoPathLength(p1);
28085       var d2 = geoPathLength(p2);
28086       var insertAt = d1 <= d2 ? movedIndex : nextIndex;
28087       if (way.isClosed() && insertAt === 0) insertAt = len;
28088       way = way.addNode(orig.id, insertAt);
28089       return graph.replace(orig).replace(way);
28090     }
28091     function removeDuplicateVertices(wayId, graph) {
28092       var way = graph.entity(wayId);
28093       var epsilon3 = 1e-6;
28094       var prev, curr;
28095       function isInteresting(node, graph2) {
28096         return graph2.parentWays(node).length > 1 || graph2.parentRelations(node).length || node.hasInterestingTags();
28097       }
28098       for (var i3 = 0; i3 < way.nodes.length; i3++) {
28099         curr = graph.entity(way.nodes[i3]);
28100         if (prev && curr && geoVecEqual(prev.loc, curr.loc, epsilon3)) {
28101           if (!isInteresting(prev, graph)) {
28102             way = way.removeNode(prev.id);
28103             graph = graph.replace(way).remove(prev);
28104           } else if (!isInteresting(curr, graph)) {
28105             way = way.removeNode(curr.id);
28106             graph = graph.replace(way).remove(curr);
28107           }
28108         }
28109         prev = curr;
28110       }
28111       return graph;
28112     }
28113     function unZorroIntersection(intersection2, graph) {
28114       var vertex = graph.entity(intersection2.nodeId);
28115       var way1 = graph.entity(intersection2.movedId);
28116       var way2 = graph.entity(intersection2.unmovedId);
28117       var isEP1 = intersection2.movedIsEP;
28118       var isEP2 = intersection2.unmovedIsEP;
28119       if (isEP1 && isEP2) return graph;
28120       var nodes1 = graph.childNodes(way1).filter(function(n3) {
28121         return n3 !== vertex;
28122       });
28123       var nodes2 = graph.childNodes(way2).filter(function(n3) {
28124         return n3 !== vertex;
28125       });
28126       if (way1.isClosed() && way1.first() === vertex.id) nodes1.push(nodes1[0]);
28127       if (way2.isClosed() && way2.first() === vertex.id) nodes2.push(nodes2[0]);
28128       var edge1 = !isEP1 && geoChooseEdge(nodes1, projection2(vertex.loc), projection2);
28129       var edge2 = !isEP2 && geoChooseEdge(nodes2, projection2(vertex.loc), projection2);
28130       var loc;
28131       if (!isEP1 && !isEP2) {
28132         var epsilon3 = 1e-6, maxIter = 10;
28133         for (var i3 = 0; i3 < maxIter; i3++) {
28134           loc = geoVecInterp(edge1.loc, edge2.loc, 0.5);
28135           edge1 = geoChooseEdge(nodes1, projection2(loc), projection2);
28136           edge2 = geoChooseEdge(nodes2, projection2(loc), projection2);
28137           if (Math.abs(edge1.distance - edge2.distance) < epsilon3) break;
28138         }
28139       } else if (!isEP1) {
28140         loc = edge1.loc;
28141       } else {
28142         loc = edge2.loc;
28143       }
28144       graph = graph.replace(vertex.move(loc));
28145       if (!isEP1 && edge1.index !== way1.nodes.indexOf(vertex.id)) {
28146         way1 = way1.removeNode(vertex.id).addNode(vertex.id, edge1.index);
28147         graph = graph.replace(way1);
28148       }
28149       if (!isEP2 && edge2.index !== way2.nodes.indexOf(vertex.id)) {
28150         way2 = way2.removeNode(vertex.id).addNode(vertex.id, edge2.index);
28151         graph = graph.replace(way2);
28152       }
28153       return graph;
28154     }
28155     function cleanupIntersections(graph) {
28156       for (var i3 = 0; i3 < cache.intersections.length; i3++) {
28157         var obj = cache.intersections[i3];
28158         graph = replaceMovedVertex(obj.nodeId, obj.movedId, graph, _delta);
28159         graph = replaceMovedVertex(obj.nodeId, obj.unmovedId, graph, null);
28160         graph = unZorroIntersection(obj, graph);
28161         graph = removeDuplicateVertices(obj.movedId, graph);
28162         graph = removeDuplicateVertices(obj.unmovedId, graph);
28163       }
28164       return graph;
28165     }
28166     function limitDelta(graph) {
28167       function moveNode(loc) {
28168         return geoVecAdd(projection2(loc), _delta);
28169       }
28170       for (var i3 = 0; i3 < cache.intersections.length; i3++) {
28171         var obj = cache.intersections[i3];
28172         if (obj.movedIsEP && obj.unmovedIsEP) continue;
28173         if (!obj.movedIsEP) continue;
28174         var node = graph.entity(obj.nodeId);
28175         var start2 = projection2(node.loc);
28176         var end = geoVecAdd(start2, _delta);
28177         var movedNodes = graph.childNodes(graph.entity(obj.movedId));
28178         var movedPath = movedNodes.map(function(n3) {
28179           return moveNode(n3.loc);
28180         });
28181         var unmovedNodes = graph.childNodes(graph.entity(obj.unmovedId));
28182         var unmovedPath = unmovedNodes.map(function(n3) {
28183           return projection2(n3.loc);
28184         });
28185         var hits = geoPathIntersections(movedPath, unmovedPath);
28186         for (var j2 = 0; i3 < hits.length; i3++) {
28187           if (geoVecEqual(hits[j2], end)) continue;
28188           var edge = geoChooseEdge(unmovedNodes, end, projection2);
28189           _delta = geoVecSubtract(projection2(edge.loc), start2);
28190         }
28191       }
28192     }
28193     var action = function(graph) {
28194       if (_delta[0] === 0 && _delta[1] === 0) return graph;
28195       setupCache(graph);
28196       if (cache.intersections.length) {
28197         limitDelta(graph);
28198       }
28199       for (var i3 = 0; i3 < cache.nodes.length; i3++) {
28200         var node = graph.entity(cache.nodes[i3]);
28201         var start2 = projection2(node.loc);
28202         var end = geoVecAdd(start2, _delta);
28203         graph = graph.replace(node.move(projection2.invert(end)));
28204       }
28205       if (cache.intersections.length) {
28206         graph = cleanupIntersections(graph);
28207       }
28208       return graph;
28209     };
28210     action.delta = function() {
28211       return _delta;
28212     };
28213     return action;
28214   }
28215
28216   // modules/actions/move_member.js
28217   function actionMoveMember(relationId, fromIndex, toIndex) {
28218     return function(graph) {
28219       return graph.replace(graph.entity(relationId).moveMember(fromIndex, toIndex));
28220     };
28221   }
28222
28223   // modules/actions/move_node.js
28224   function actionMoveNode(nodeID, toLoc) {
28225     var action = function(graph, t2) {
28226       if (t2 === null || !isFinite(t2)) t2 = 1;
28227       t2 = Math.min(Math.max(+t2, 0), 1);
28228       var node = graph.entity(nodeID);
28229       return graph.replace(
28230         node.move(geoVecInterp(node.loc, toLoc, t2))
28231       );
28232     };
28233     action.transitionable = true;
28234     return action;
28235   }
28236
28237   // modules/actions/noop.js
28238   function actionNoop() {
28239     return function(graph) {
28240       return graph;
28241     };
28242   }
28243
28244   // modules/actions/orthogonalize.js
28245   function actionOrthogonalize(wayID, projection2, vertexID, degThresh, ep) {
28246     var epsilon3 = ep || 1e-4;
28247     var threshold = degThresh || 13;
28248     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
28249     var upperThreshold = Math.cos(threshold * Math.PI / 180);
28250     var action = function(graph, t2) {
28251       if (t2 === null || !isFinite(t2)) t2 = 1;
28252       t2 = Math.min(Math.max(+t2, 0), 1);
28253       var way = graph.entity(wayID);
28254       way = way.removeNode("");
28255       if (way.tags.nonsquare) {
28256         var tags = Object.assign({}, way.tags);
28257         delete tags.nonsquare;
28258         way = way.update({ tags });
28259       }
28260       graph = graph.replace(way);
28261       var isClosed = way.isClosed();
28262       var nodes = graph.childNodes(way).slice();
28263       if (isClosed) nodes.pop();
28264       if (vertexID !== void 0) {
28265         nodes = nodeSubset(nodes, vertexID, isClosed);
28266         if (nodes.length !== 3) return graph;
28267       }
28268       var nodeCount = {};
28269       var points = [];
28270       var corner = { i: 0, dotp: 1 };
28271       var node, point, loc, score, motions, i3, j2;
28272       for (i3 = 0; i3 < nodes.length; i3++) {
28273         node = nodes[i3];
28274         nodeCount[node.id] = (nodeCount[node.id] || 0) + 1;
28275         points.push({ id: node.id, coord: projection2(node.loc) });
28276       }
28277       if (points.length === 3) {
28278         for (i3 = 0; i3 < 1e3; i3++) {
28279           motions = points.map(calcMotion);
28280           points[corner.i].coord = geoVecAdd(points[corner.i].coord, motions[corner.i]);
28281           score = corner.dotp;
28282           if (score < epsilon3) {
28283             break;
28284           }
28285         }
28286         node = graph.entity(nodes[corner.i].id);
28287         loc = projection2.invert(points[corner.i].coord);
28288         graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
28289       } else {
28290         var straights = [];
28291         var simplified = [];
28292         for (i3 = 0; i3 < points.length; i3++) {
28293           point = points[i3];
28294           var dotp = 0;
28295           if (isClosed || i3 > 0 && i3 < points.length - 1) {
28296             var a2 = points[(i3 - 1 + points.length) % points.length];
28297             var b2 = points[(i3 + 1) % points.length];
28298             dotp = Math.abs(geoOrthoNormalizedDotProduct(a2.coord, b2.coord, point.coord));
28299           }
28300           if (dotp > upperThreshold) {
28301             straights.push(point);
28302           } else {
28303             simplified.push(point);
28304           }
28305         }
28306         var bestPoints = clonePoints(simplified);
28307         var originalPoints = clonePoints(simplified);
28308         score = Infinity;
28309         for (i3 = 0; i3 < 1e3; i3++) {
28310           motions = simplified.map(calcMotion);
28311           for (j2 = 0; j2 < motions.length; j2++) {
28312             simplified[j2].coord = geoVecAdd(simplified[j2].coord, motions[j2]);
28313           }
28314           var newScore = geoOrthoCalcScore(simplified, isClosed, epsilon3, threshold);
28315           if (newScore < score) {
28316             bestPoints = clonePoints(simplified);
28317             score = newScore;
28318           }
28319           if (score < epsilon3) {
28320             break;
28321           }
28322         }
28323         var bestCoords = bestPoints.map(function(p2) {
28324           return p2.coord;
28325         });
28326         if (isClosed) bestCoords.push(bestCoords[0]);
28327         for (i3 = 0; i3 < bestPoints.length; i3++) {
28328           point = bestPoints[i3];
28329           if (!geoVecEqual(originalPoints[i3].coord, point.coord)) {
28330             node = graph.entity(point.id);
28331             loc = projection2.invert(point.coord);
28332             graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
28333           }
28334         }
28335         for (i3 = 0; i3 < straights.length; i3++) {
28336           point = straights[i3];
28337           if (nodeCount[point.id] > 1) continue;
28338           node = graph.entity(point.id);
28339           if (t2 === 1 && graph.parentWays(node).length === 1 && graph.parentRelations(node).length === 0 && !node.hasInterestingTags()) {
28340             graph = actionDeleteNode(node.id)(graph);
28341           } else {
28342             var choice = geoVecProject(point.coord, bestCoords);
28343             if (choice) {
28344               loc = projection2.invert(choice.target);
28345               graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
28346             }
28347           }
28348         }
28349       }
28350       return graph;
28351       function clonePoints(array2) {
28352         return array2.map(function(p2) {
28353           return { id: p2.id, coord: [p2.coord[0], p2.coord[1]] };
28354         });
28355       }
28356       function calcMotion(point2, i4, array2) {
28357         if (!isClosed && (i4 === 0 || i4 === array2.length - 1)) return [0, 0];
28358         if (nodeCount[array2[i4].id] > 1) return [0, 0];
28359         var a3 = array2[(i4 - 1 + array2.length) % array2.length].coord;
28360         var origin = point2.coord;
28361         var b3 = array2[(i4 + 1) % array2.length].coord;
28362         var p2 = geoVecSubtract(a3, origin);
28363         var q2 = geoVecSubtract(b3, origin);
28364         var scale = 2 * Math.min(geoVecLength(p2), geoVecLength(q2));
28365         p2 = geoVecNormalize(p2);
28366         q2 = geoVecNormalize(q2);
28367         var dotp2 = p2[0] * q2[0] + p2[1] * q2[1];
28368         var val = Math.abs(dotp2);
28369         if (val < lowerThreshold) {
28370           corner.i = i4;
28371           corner.dotp = val;
28372           var vec = geoVecNormalize(geoVecAdd(p2, q2));
28373           return geoVecScale(vec, 0.1 * dotp2 * scale);
28374         }
28375         return [0, 0];
28376       }
28377     };
28378     function nodeSubset(nodes, vertexID2, isClosed) {
28379       var first = isClosed ? 0 : 1;
28380       var last = isClosed ? nodes.length : nodes.length - 1;
28381       for (var i3 = first; i3 < last; i3++) {
28382         if (nodes[i3].id === vertexID2) {
28383           return [
28384             nodes[(i3 - 1 + nodes.length) % nodes.length],
28385             nodes[i3],
28386             nodes[(i3 + 1) % nodes.length]
28387           ];
28388         }
28389       }
28390       return [];
28391     }
28392     action.disabled = function(graph) {
28393       var way = graph.entity(wayID);
28394       way = way.removeNode("");
28395       graph = graph.replace(way);
28396       var isClosed = way.isClosed();
28397       var nodes = graph.childNodes(way).slice();
28398       if (isClosed) nodes.pop();
28399       var allowStraightAngles = false;
28400       if (vertexID !== void 0) {
28401         allowStraightAngles = true;
28402         nodes = nodeSubset(nodes, vertexID, isClosed);
28403         if (nodes.length !== 3) return "end_vertex";
28404       }
28405       var coords = nodes.map(function(n3) {
28406         return projection2(n3.loc);
28407       });
28408       var score = geoOrthoCanOrthogonalize(coords, isClosed, epsilon3, threshold, allowStraightAngles);
28409       if (score === null) {
28410         return "not_squarish";
28411       } else if (score === 0) {
28412         return "square_enough";
28413       } else {
28414         return false;
28415       }
28416     };
28417     action.transitionable = true;
28418     return action;
28419   }
28420
28421   // modules/actions/restrict_turn.js
28422   function actionRestrictTurn(turn, restrictionType, restrictionID) {
28423     return function(graph) {
28424       var fromWay = graph.entity(turn.from.way);
28425       var toWay = graph.entity(turn.to.way);
28426       var viaNode = turn.via.node && graph.entity(turn.via.node);
28427       var viaWays = turn.via.ways && turn.via.ways.map(function(id2) {
28428         return graph.entity(id2);
28429       });
28430       var members = [];
28431       members.push({ id: fromWay.id, type: "way", role: "from" });
28432       if (viaNode) {
28433         members.push({ id: viaNode.id, type: "node", role: "via" });
28434       } else if (viaWays) {
28435         viaWays.forEach(function(viaWay) {
28436           members.push({ id: viaWay.id, type: "way", role: "via" });
28437         });
28438       }
28439       members.push({ id: toWay.id, type: "way", role: "to" });
28440       return graph.replace(osmRelation({
28441         id: restrictionID,
28442         tags: {
28443           type: "restriction",
28444           restriction: restrictionType
28445         },
28446         members
28447       }));
28448     };
28449   }
28450
28451   // modules/actions/revert.js
28452   function actionRevert(id2) {
28453     var action = function(graph) {
28454       var entity = graph.hasEntity(id2), base = graph.base().entities[id2];
28455       if (entity && !base) {
28456         if (entity.type === "node") {
28457           graph.parentWays(entity).forEach(function(parent) {
28458             parent = parent.removeNode(id2);
28459             graph = graph.replace(parent);
28460             if (parent.isDegenerate()) {
28461               graph = actionDeleteWay(parent.id)(graph);
28462             }
28463           });
28464         }
28465         graph.parentRelations(entity).forEach(function(parent) {
28466           parent = parent.removeMembersWithID(id2);
28467           graph = graph.replace(parent);
28468           if (parent.isDegenerate()) {
28469             graph = actionDeleteRelation(parent.id)(graph);
28470           }
28471         });
28472       }
28473       return graph.revert(id2);
28474     };
28475     return action;
28476   }
28477
28478   // modules/actions/rotate.js
28479   function actionRotate(rotateIds, pivot, angle2, projection2) {
28480     var action = function(graph) {
28481       return graph.update(function(graph2) {
28482         utilGetAllNodes(rotateIds, graph2).forEach(function(node) {
28483           var point = geoRotate([projection2(node.loc)], angle2, pivot)[0];
28484           graph2 = graph2.replace(node.move(projection2.invert(point)));
28485         });
28486       });
28487     };
28488     return action;
28489   }
28490
28491   // modules/actions/scale.js
28492   function actionScale(ids, pivotLoc, scaleFactor, projection2) {
28493     return function(graph) {
28494       return graph.update(function(graph2) {
28495         let point, radial;
28496         utilGetAllNodes(ids, graph2).forEach(function(node) {
28497           point = projection2(node.loc);
28498           radial = [
28499             point[0] - pivotLoc[0],
28500             point[1] - pivotLoc[1]
28501           ];
28502           point = [
28503             pivotLoc[0] + scaleFactor * radial[0],
28504             pivotLoc[1] + scaleFactor * radial[1]
28505           ];
28506           graph2 = graph2.replace(node.move(projection2.invert(point)));
28507         });
28508       });
28509     };
28510   }
28511
28512   // modules/actions/straighten_nodes.js
28513   function actionStraightenNodes(nodeIDs, projection2) {
28514     function positionAlongWay(a2, o2, b2) {
28515       return geoVecDot(a2, b2, o2) / geoVecDot(b2, b2, o2);
28516     }
28517     function getEndpoints(points) {
28518       var ssr = geoGetSmallestSurroundingRectangle(points);
28519       var p1 = [(ssr.poly[0][0] + ssr.poly[1][0]) / 2, (ssr.poly[0][1] + ssr.poly[1][1]) / 2];
28520       var q1 = [(ssr.poly[2][0] + ssr.poly[3][0]) / 2, (ssr.poly[2][1] + ssr.poly[3][1]) / 2];
28521       var p2 = [(ssr.poly[3][0] + ssr.poly[4][0]) / 2, (ssr.poly[3][1] + ssr.poly[4][1]) / 2];
28522       var q2 = [(ssr.poly[1][0] + ssr.poly[2][0]) / 2, (ssr.poly[1][1] + ssr.poly[2][1]) / 2];
28523       var isLong = geoVecLength(p1, q1) > geoVecLength(p2, q2);
28524       if (isLong) {
28525         return [p1, q1];
28526       }
28527       return [p2, q2];
28528     }
28529     var action = function(graph, t2) {
28530       if (t2 === null || !isFinite(t2)) t2 = 1;
28531       t2 = Math.min(Math.max(+t2, 0), 1);
28532       var nodes = nodeIDs.map(function(id2) {
28533         return graph.entity(id2);
28534       });
28535       var points = nodes.map(function(n3) {
28536         return projection2(n3.loc);
28537       });
28538       var endpoints = getEndpoints(points);
28539       var startPoint = endpoints[0];
28540       var endPoint = endpoints[1];
28541       for (var i3 = 0; i3 < points.length; i3++) {
28542         var node = nodes[i3];
28543         var point = points[i3];
28544         var u2 = positionAlongWay(point, startPoint, endPoint);
28545         var point2 = geoVecInterp(startPoint, endPoint, u2);
28546         var loc2 = projection2.invert(point2);
28547         graph = graph.replace(node.move(geoVecInterp(node.loc, loc2, t2)));
28548       }
28549       return graph;
28550     };
28551     action.disabled = function(graph) {
28552       var nodes = nodeIDs.map(function(id2) {
28553         return graph.entity(id2);
28554       });
28555       var points = nodes.map(function(n3) {
28556         return projection2(n3.loc);
28557       });
28558       var endpoints = getEndpoints(points);
28559       var startPoint = endpoints[0];
28560       var endPoint = endpoints[1];
28561       var maxDistance = 0;
28562       for (var i3 = 0; i3 < points.length; i3++) {
28563         var point = points[i3];
28564         var u2 = positionAlongWay(point, startPoint, endPoint);
28565         var p2 = geoVecInterp(startPoint, endPoint, u2);
28566         var dist = geoVecLength(p2, point);
28567         if (!isNaN(dist) && dist > maxDistance) {
28568           maxDistance = dist;
28569         }
28570       }
28571       if (maxDistance < 1e-4) {
28572         return "straight_enough";
28573       }
28574     };
28575     action.transitionable = true;
28576     return action;
28577   }
28578
28579   // modules/actions/straighten_way.js
28580   function actionStraightenWay(selectedIDs, projection2) {
28581     function positionAlongWay(a2, o2, b2) {
28582       return geoVecDot(a2, b2, o2) / geoVecDot(b2, b2, o2);
28583     }
28584     function allNodes(graph) {
28585       var nodes = [];
28586       var startNodes = [];
28587       var endNodes = [];
28588       var remainingWays = [];
28589       var selectedWays = selectedIDs.filter(function(w2) {
28590         return graph.entity(w2).type === "way";
28591       });
28592       var selectedNodes = selectedIDs.filter(function(n3) {
28593         return graph.entity(n3).type === "node";
28594       });
28595       for (var i3 = 0; i3 < selectedWays.length; i3++) {
28596         var way = graph.entity(selectedWays[i3]);
28597         nodes = way.nodes.slice(0);
28598         remainingWays.push(nodes);
28599         startNodes.push(nodes[0]);
28600         endNodes.push(nodes[nodes.length - 1]);
28601       }
28602       startNodes = startNodes.filter(function(n3) {
28603         return startNodes.indexOf(n3) === startNodes.lastIndexOf(n3);
28604       });
28605       endNodes = endNodes.filter(function(n3) {
28606         return endNodes.indexOf(n3) === endNodes.lastIndexOf(n3);
28607       });
28608       var currNode = utilArrayDifference(startNodes, endNodes).concat(utilArrayDifference(endNodes, startNodes))[0];
28609       var nextWay = [];
28610       nodes = [];
28611       var getNextWay = function(currNode2, remainingWays2) {
28612         return remainingWays2.filter(function(way2) {
28613           return way2[0] === currNode2 || way2[way2.length - 1] === currNode2;
28614         })[0];
28615       };
28616       while (remainingWays.length) {
28617         nextWay = getNextWay(currNode, remainingWays);
28618         remainingWays = utilArrayDifference(remainingWays, [nextWay]);
28619         if (nextWay[0] !== currNode) {
28620           nextWay.reverse();
28621         }
28622         nodes = nodes.concat(nextWay);
28623         currNode = nodes[nodes.length - 1];
28624       }
28625       if (selectedNodes.length === 2) {
28626         var startNodeIdx = nodes.indexOf(selectedNodes[0]);
28627         var endNodeIdx = nodes.indexOf(selectedNodes[1]);
28628         var sortedStartEnd = [startNodeIdx, endNodeIdx];
28629         sortedStartEnd.sort(function(a2, b2) {
28630           return a2 - b2;
28631         });
28632         nodes = nodes.slice(sortedStartEnd[0], sortedStartEnd[1] + 1);
28633       }
28634       return nodes.map(function(n3) {
28635         return graph.entity(n3);
28636       });
28637     }
28638     function shouldKeepNode(node, graph) {
28639       return graph.parentWays(node).length > 1 || graph.parentRelations(node).length || node.hasInterestingTags();
28640     }
28641     var action = function(graph, t2) {
28642       if (t2 === null || !isFinite(t2)) t2 = 1;
28643       t2 = Math.min(Math.max(+t2, 0), 1);
28644       var nodes = allNodes(graph);
28645       var points = nodes.map(function(n3) {
28646         return projection2(n3.loc);
28647       });
28648       var startPoint = points[0];
28649       var endPoint = points[points.length - 1];
28650       var toDelete = [];
28651       var i3;
28652       for (i3 = 1; i3 < points.length - 1; i3++) {
28653         var node = nodes[i3];
28654         var point = points[i3];
28655         if (t2 < 1 || shouldKeepNode(node, graph)) {
28656           var u2 = positionAlongWay(point, startPoint, endPoint);
28657           var p2 = geoVecInterp(startPoint, endPoint, u2);
28658           var loc2 = projection2.invert(p2);
28659           graph = graph.replace(node.move(geoVecInterp(node.loc, loc2, t2)));
28660         } else {
28661           if (toDelete.indexOf(node) === -1) {
28662             toDelete.push(node);
28663           }
28664         }
28665       }
28666       for (i3 = 0; i3 < toDelete.length; i3++) {
28667         graph = actionDeleteNode(toDelete[i3].id)(graph);
28668       }
28669       return graph;
28670     };
28671     action.disabled = function(graph) {
28672       var nodes = allNodes(graph);
28673       var points = nodes.map(function(n3) {
28674         return projection2(n3.loc);
28675       });
28676       var startPoint = points[0];
28677       var endPoint = points[points.length - 1];
28678       var threshold = 0.2 * geoVecLength(startPoint, endPoint);
28679       var i3;
28680       if (threshold === 0) {
28681         return "too_bendy";
28682       }
28683       var maxDistance = 0;
28684       for (i3 = 1; i3 < points.length - 1; i3++) {
28685         var point = points[i3];
28686         var u2 = positionAlongWay(point, startPoint, endPoint);
28687         var p2 = geoVecInterp(startPoint, endPoint, u2);
28688         var dist = geoVecLength(p2, point);
28689         if (isNaN(dist) || dist > threshold) {
28690           return "too_bendy";
28691         } else if (dist > maxDistance) {
28692           maxDistance = dist;
28693         }
28694       }
28695       var keepingAllNodes = nodes.every(function(node, i4) {
28696         return i4 === 0 || i4 === nodes.length - 1 || shouldKeepNode(node, graph);
28697       });
28698       if (maxDistance < 1e-4 && // Allow straightening even if already straight in order to remove extraneous nodes
28699       keepingAllNodes) {
28700         return "straight_enough";
28701       }
28702     };
28703     action.transitionable = true;
28704     return action;
28705   }
28706
28707   // modules/actions/unrestrict_turn.js
28708   function actionUnrestrictTurn(turn) {
28709     return function(graph) {
28710       return actionDeleteRelation(turn.restrictionID)(graph);
28711     };
28712   }
28713
28714   // modules/actions/reflect.js
28715   function actionReflect(reflectIds, projection2) {
28716     var _useLongAxis = true;
28717     var action = function(graph, t2) {
28718       if (t2 === null || !isFinite(t2)) t2 = 1;
28719       t2 = Math.min(Math.max(+t2, 0), 1);
28720       var nodes = utilGetAllNodes(reflectIds, graph);
28721       var points = nodes.map(function(n3) {
28722         return projection2(n3.loc);
28723       });
28724       var ssr = geoGetSmallestSurroundingRectangle(points);
28725       var p1 = [(ssr.poly[0][0] + ssr.poly[1][0]) / 2, (ssr.poly[0][1] + ssr.poly[1][1]) / 2];
28726       var q1 = [(ssr.poly[2][0] + ssr.poly[3][0]) / 2, (ssr.poly[2][1] + ssr.poly[3][1]) / 2];
28727       var p2 = [(ssr.poly[3][0] + ssr.poly[4][0]) / 2, (ssr.poly[3][1] + ssr.poly[4][1]) / 2];
28728       var q2 = [(ssr.poly[1][0] + ssr.poly[2][0]) / 2, (ssr.poly[1][1] + ssr.poly[2][1]) / 2];
28729       var p3, q3;
28730       var isLong = geoVecLength(p1, q1) > geoVecLength(p2, q2);
28731       if (_useLongAxis && isLong || !_useLongAxis && !isLong) {
28732         p3 = p1;
28733         q3 = q1;
28734       } else {
28735         p3 = p2;
28736         q3 = q2;
28737       }
28738       var dx = q3[0] - p3[0];
28739       var dy = q3[1] - p3[1];
28740       var a2 = (dx * dx - dy * dy) / (dx * dx + dy * dy);
28741       var b2 = 2 * dx * dy / (dx * dx + dy * dy);
28742       for (var i3 = 0; i3 < nodes.length; i3++) {
28743         var node = nodes[i3];
28744         var c2 = projection2(node.loc);
28745         var c22 = [
28746           a2 * (c2[0] - p3[0]) + b2 * (c2[1] - p3[1]) + p3[0],
28747           b2 * (c2[0] - p3[0]) - a2 * (c2[1] - p3[1]) + p3[1]
28748         ];
28749         var loc2 = projection2.invert(c22);
28750         node = node.move(geoVecInterp(node.loc, loc2, t2));
28751         graph = graph.replace(node);
28752       }
28753       return graph;
28754     };
28755     action.useLongAxis = function(val) {
28756       if (!arguments.length) return _useLongAxis;
28757       _useLongAxis = val;
28758       return action;
28759     };
28760     action.transitionable = true;
28761     return action;
28762   }
28763
28764   // modules/actions/upgrade_tags.js
28765   function actionUpgradeTags(entityId, oldTags, replaceTags) {
28766     return function(graph) {
28767       var entity = graph.entity(entityId);
28768       var tags = Object.assign({}, entity.tags);
28769       var transferValue;
28770       var semiIndex;
28771       for (var oldTagKey in oldTags) {
28772         if (!(oldTagKey in tags)) continue;
28773         if (oldTags[oldTagKey] === "*") {
28774           transferValue = tags[oldTagKey];
28775           delete tags[oldTagKey];
28776         } else if (oldTags[oldTagKey] === tags[oldTagKey]) {
28777           delete tags[oldTagKey];
28778         } else {
28779           var vals = tags[oldTagKey].split(";").filter(Boolean);
28780           var oldIndex = vals.indexOf(oldTags[oldTagKey]);
28781           if (vals.length === 1 || oldIndex === -1) {
28782             delete tags[oldTagKey];
28783           } else {
28784             if (replaceTags && replaceTags[oldTagKey]) {
28785               semiIndex = oldIndex;
28786             }
28787             vals.splice(oldIndex, 1);
28788             tags[oldTagKey] = vals.join(";");
28789           }
28790         }
28791       }
28792       if (replaceTags) {
28793         for (var replaceKey in replaceTags) {
28794           var replaceValue = replaceTags[replaceKey];
28795           if (replaceValue === "*") {
28796             if (tags[replaceKey] && tags[replaceKey] !== "no") {
28797               continue;
28798             } else {
28799               tags[replaceKey] = "yes";
28800             }
28801           } else if (replaceValue === "$1") {
28802             tags[replaceKey] = transferValue;
28803           } else {
28804             if (tags[replaceKey] && oldTags[replaceKey] && semiIndex !== void 0) {
28805               var existingVals = tags[replaceKey].split(";").filter(Boolean);
28806               if (existingVals.indexOf(replaceValue) === -1) {
28807                 existingVals.splice(semiIndex, 0, replaceValue);
28808                 tags[replaceKey] = existingVals.join(";");
28809               }
28810             } else {
28811               tags[replaceKey] = replaceValue;
28812             }
28813           }
28814         }
28815       }
28816       return graph.replace(entity.update({ tags }));
28817     };
28818   }
28819
28820   // modules/core/preferences.js
28821   var _storage;
28822   try {
28823     _storage = localStorage;
28824   } catch (e3) {
28825   }
28826   _storage = _storage || /* @__PURE__ */ (() => {
28827     let s2 = {};
28828     return {
28829       getItem: (k2) => s2[k2],
28830       setItem: (k2, v2) => s2[k2] = v2,
28831       removeItem: (k2) => delete s2[k2]
28832     };
28833   })();
28834   var _listeners = {};
28835   function corePreferences(k2, v2) {
28836     try {
28837       if (v2 === void 0) return _storage.getItem(k2);
28838       else if (v2 === null) _storage.removeItem(k2);
28839       else _storage.setItem(k2, v2);
28840       if (_listeners[k2]) {
28841         _listeners[k2].forEach((handler) => handler(v2));
28842       }
28843       return true;
28844     } catch (e3) {
28845       if (typeof console !== "undefined") {
28846         console.error("localStorage quota exceeded");
28847       }
28848       return false;
28849     }
28850   }
28851   corePreferences.onChange = function(k2, handler) {
28852     _listeners[k2] = _listeners[k2] || [];
28853     _listeners[k2].push(handler);
28854   };
28855
28856   // node_modules/@rapideditor/country-coder/dist/country-coder.mjs
28857   var import_which_polygon = __toESM(require_which_polygon(), 1);
28858   var borders_default = { type: "FeatureCollection", features: [
28859     { type: "Feature", properties: { wikidata: "Q21", nameEn: "England", aliases: ["GB-ENG"], country: "GB", groups: ["Q23666", "Q3336843", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-6.03913, 51.13217], [-7.74976, 48.64773], [1.17405, 50.74239], [2.18458, 51.52087], [2.56575, 51.85301], [0.792, 57.56437], [-2.30613, 55.62698], [-2.17058, 55.45916], [-2.6095, 55.28488], [-2.63532, 55.19452], [-3.02906, 55.04606], [-3.09361, 54.94924], [-3.38407, 54.94278], [-4.1819, 54.57861], [-3.5082, 53.54318], [-3.08228, 53.25526], [-3.03675, 53.25092], [-2.92329, 53.19383], [-2.92022, 53.17685], [-2.98598, 53.15589], [-2.90649, 53.10964], [-2.87469, 53.12337], [-2.89131, 53.09374], [-2.83133, 52.99184], [-2.7251, 52.98389], [-2.72221, 52.92969], [-2.80549, 52.89428], [-2.85897, 52.94487], [-2.92401, 52.93836], [-2.97243, 52.9651], [-3.13576, 52.895], [-3.15744, 52.84947], [-3.16105, 52.79599], [-3.08734, 52.77504], [-3.01001, 52.76636], [-2.95581, 52.71794], [-3.01724, 52.72083], [-3.04398, 52.65435], [-3.13648, 52.58208], [-3.12926, 52.5286], [-3.09746, 52.53077], [-3.08662, 52.54811], [-3.00929, 52.57774], [-2.99701, 52.551], [-3.03603, 52.49969], [-3.13359, 52.49174], [-3.22971, 52.45344], [-3.22754, 52.42526], [-3.04687, 52.34504], [-2.95364, 52.3501], [-2.99701, 52.323], [-3.00785, 52.2753], [-3.09289, 52.20546], [-3.12638, 52.08114], [-2.97111, 51.90456], [-2.8818, 51.93196], [-2.78742, 51.88833], [-2.74277, 51.84367], [-2.66234, 51.83555], [-2.66336, 51.59504], [-3.20563, 51.31615], [-6.03913, 51.13217]]]] } },
28860     { type: "Feature", properties: { wikidata: "Q22", nameEn: "Scotland", aliases: ["GB-SCT"], country: "GB", groups: ["Q23666", "Q3336843", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44"] }, geometry: { type: "MultiPolygon", coordinates: [[[[0.792, 57.56437], [-0.3751, 61.32236], [-14.78497, 57.60709], [-6.82333, 55.83103], [-4.69044, 54.3629], [-3.38407, 54.94278], [-3.09361, 54.94924], [-3.02906, 55.04606], [-2.63532, 55.19452], [-2.6095, 55.28488], [-2.17058, 55.45916], [-2.30613, 55.62698], [0.792, 57.56437]]]] } },
28861     { type: "Feature", properties: { wikidata: "Q25", nameEn: "Wales", aliases: ["GB-WLS"], country: "GB", groups: ["Q23666", "Q3336843", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-3.5082, 53.54318], [-5.37267, 53.63269], [-6.03913, 51.13217], [-3.20563, 51.31615], [-2.66336, 51.59504], [-2.66234, 51.83555], [-2.74277, 51.84367], [-2.78742, 51.88833], [-2.8818, 51.93196], [-2.97111, 51.90456], [-3.12638, 52.08114], [-3.09289, 52.20546], [-3.00785, 52.2753], [-2.99701, 52.323], [-2.95364, 52.3501], [-3.04687, 52.34504], [-3.22754, 52.42526], [-3.22971, 52.45344], [-3.13359, 52.49174], [-3.03603, 52.49969], [-2.99701, 52.551], [-3.00929, 52.57774], [-3.08662, 52.54811], [-3.09746, 52.53077], [-3.12926, 52.5286], [-3.13648, 52.58208], [-3.04398, 52.65435], [-3.01724, 52.72083], [-2.95581, 52.71794], [-3.01001, 52.76636], [-3.08734, 52.77504], [-3.16105, 52.79599], [-3.15744, 52.84947], [-3.13576, 52.895], [-2.97243, 52.9651], [-2.92401, 52.93836], [-2.85897, 52.94487], [-2.80549, 52.89428], [-2.72221, 52.92969], [-2.7251, 52.98389], [-2.83133, 52.99184], [-2.89131, 53.09374], [-2.87469, 53.12337], [-2.90649, 53.10964], [-2.98598, 53.15589], [-2.92022, 53.17685], [-2.92329, 53.19383], [-3.03675, 53.25092], [-3.08228, 53.25526], [-3.5082, 53.54318]]]] } },
28862     { type: "Feature", properties: { wikidata: "Q26", nameEn: "Northern Ireland", aliases: ["GB-NIR"], country: "GB", groups: ["Q22890", "Q3336843", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-6.34755, 55.49206], [-7.2471, 55.06933], [-7.34464, 55.04688], [-7.4033, 55.00391], [-7.40004, 54.94498], [-7.44404, 54.9403], [-7.4473, 54.87003], [-7.47626, 54.83084], [-7.54508, 54.79401], [-7.54671, 54.74606], [-7.64449, 54.75265], [-7.75041, 54.7103], [-7.83352, 54.73854], [-7.93293, 54.66603], [-7.70315, 54.62077], [-7.8596, 54.53671], [-7.99812, 54.54427], [-8.04538, 54.48941], [-8.179, 54.46763], [-8.04555, 54.36292], [-7.87101, 54.29299], [-7.8596, 54.21779], [-7.81397, 54.20159], [-7.69501, 54.20731], [-7.55812, 54.12239], [-7.4799, 54.12239], [-7.44567, 54.1539], [-7.32834, 54.11475], [-7.30553, 54.11869], [-7.34005, 54.14698], [-7.29157, 54.17191], [-7.28017, 54.16714], [-7.29687, 54.1354], [-7.29493, 54.12013], [-7.26316, 54.13863], [-7.25012, 54.20063], [-7.14908, 54.22732], [-7.19145, 54.31296], [-7.02034, 54.4212], [-6.87775, 54.34682], [-6.85179, 54.29176], [-6.81583, 54.22791], [-6.74575, 54.18788], [-6.70175, 54.20218], [-6.6382, 54.17071], [-6.66264, 54.0666], [-6.62842, 54.03503], [-6.47849, 54.06947], [-6.36605, 54.07234], [-6.36279, 54.11248], [-6.32694, 54.09337], [-6.29003, 54.11278], [-6.26218, 54.09785], [-5.83481, 53.87749], [-4.69044, 54.3629], [-6.34755, 55.49206]]]] } },
28863     { type: "Feature", properties: { wikidata: "Q35", nameEn: "Denmark", country: "DK", groups: ["EU", "154", "150", "UN"], callingCodes: ["45"] }, geometry: { type: "MultiPolygon", coordinates: [[[[12.16597, 56.60205], [10.40861, 58.38489], [7.28637, 57.35913], [8.02459, 55.09613], [8.45719, 55.06747], [8.55769, 54.91837], [8.63979, 54.91069], [8.76387, 54.8948], [8.81178, 54.90518], [8.92795, 54.90452], [9.04629, 54.87249], [9.14275, 54.87421], [9.20571, 54.85841], [9.24631, 54.84726], [9.23445, 54.83432], [9.2474, 54.8112], [9.32771, 54.80602], [9.33849, 54.80233], [9.36496, 54.81749], [9.38532, 54.83968], [9.41213, 54.84254], [9.43155, 54.82586], [9.4659, 54.83131], [9.58937, 54.88785], [9.62734, 54.88057], [9.61187, 54.85548], [9.73563, 54.8247], [9.89314, 54.84171], [10.16755, 54.73883], [10.31111, 54.65968], [11.00303, 54.63689], [11.90309, 54.38543], [12.85844, 54.82438], [13.93395, 54.84044], [15.36991, 54.73263], [15.79951, 55.54655], [14.89259, 55.5623], [14.28399, 55.1553], [12.84405, 55.13257], [12.60345, 55.42675], [12.88472, 55.63369], [12.6372, 55.91371], [12.65312, 56.04345], [12.07466, 56.29488], [12.16597, 56.60205]]]] } },
28864     { type: "Feature", properties: { wikidata: "Q55", nameEn: "Netherlands", country: "NL", groups: ["EU", "155", "150", "UN"], callingCodes: ["31"] }, geometry: { type: "MultiPolygon", coordinates: [[[[5.45168, 54.20039], [2.56575, 51.85301], [3.36263, 51.37112], [3.38696, 51.33436], [3.35847, 51.31572], [3.38289, 51.27331], [3.41704, 51.25933], [3.43488, 51.24135], [3.52698, 51.2458], [3.51502, 51.28697], [3.58939, 51.30064], [3.78999, 51.25766], [3.78783, 51.2151], [3.90125, 51.20371], [3.97889, 51.22537], [4.01957, 51.24504], [4.05165, 51.24171], [4.16721, 51.29348], [4.24024, 51.35371], [4.21923, 51.37443], [4.33265, 51.37687], [4.34086, 51.35738], [4.39292, 51.35547], [4.43777, 51.36989], [4.38064, 51.41965], [4.39747, 51.43316], [4.38122, 51.44905], [4.47736, 51.4778], [4.5388, 51.48184], [4.54675, 51.47265], [4.52846, 51.45002], [4.53521, 51.4243], [4.57489, 51.4324], [4.65442, 51.42352], [4.72935, 51.48424], [4.74578, 51.48937], [4.77321, 51.50529], [4.78803, 51.50284], [4.84139, 51.4799], [4.82409, 51.44736], [4.82946, 51.4213], [4.78314, 51.43319], [4.76577, 51.43046], [4.77229, 51.41337], [4.78941, 51.41102], [4.84988, 51.41502], [4.90016, 51.41404], [4.92152, 51.39487], [5.00393, 51.44406], [5.0106, 51.47167], [5.03281, 51.48679], [5.04774, 51.47022], [5.07891, 51.4715], [5.10456, 51.43163], [5.07102, 51.39469], [5.13105, 51.34791], [5.13377, 51.31592], [5.16222, 51.31035], [5.2002, 51.32243], [5.24244, 51.30495], [5.22542, 51.26888], [5.23814, 51.26064], [5.26461, 51.26693], [5.29716, 51.26104], [5.33886, 51.26314], [5.347, 51.27502], [5.41672, 51.26248], [5.4407, 51.28169], [5.46519, 51.2849], [5.48476, 51.30053], [5.515, 51.29462], [5.5569, 51.26544], [5.5603, 51.22249], [5.65145, 51.19788], [5.65528, 51.18736], [5.70344, 51.1829], [5.74617, 51.18928], [5.77735, 51.17845], [5.77697, 51.1522], [5.82564, 51.16753], [5.85508, 51.14445], [5.80798, 51.11661], [5.8109, 51.10861], [5.83226, 51.10585], [5.82921, 51.09328], [5.79903, 51.09371], [5.79835, 51.05834], [5.77258, 51.06196], [5.75961, 51.03113], [5.77688, 51.02483], [5.76242, 50.99703], [5.71864, 50.96092], [5.72875, 50.95428], [5.74752, 50.96202], [5.75927, 50.95601], [5.74644, 50.94723], [5.72545, 50.92312], [5.72644, 50.91167], [5.71626, 50.90796], [5.69858, 50.91046], [5.67886, 50.88142], [5.64504, 50.87107], [5.64009, 50.84742], [5.65259, 50.82309], [5.70118, 50.80764], [5.68995, 50.79641], [5.70107, 50.7827], [5.68091, 50.75804], [5.69469, 50.75529], [5.72216, 50.76398], [5.73904, 50.75674], [5.74356, 50.7691], [5.76533, 50.78159], [5.77513, 50.78308], [5.80673, 50.7558], [5.84548, 50.76542], [5.84888, 50.75448], [5.88734, 50.77092], [5.89129, 50.75125], [5.89132, 50.75124], [5.95942, 50.7622], [5.97545, 50.75441], [6.01976, 50.75398], [6.02624, 50.77453], [5.97497, 50.79992], [5.98404, 50.80988], [6.00462, 50.80065], [6.02328, 50.81694], [6.01921, 50.84435], [6.05623, 50.8572], [6.05702, 50.85179], [6.07431, 50.84674], [6.07693, 50.86025], [6.08805, 50.87223], [6.07486, 50.89307], [6.09297, 50.92066], [6.01615, 50.93367], [6.02697, 50.98303], [5.95282, 50.98728], [5.90296, 50.97356], [5.90493, 51.00198], [5.87849, 51.01969], [5.86735, 51.05182], [5.9134, 51.06736], [5.9541, 51.03496], [5.98292, 51.07469], [6.16706, 51.15677], [6.17384, 51.19589], [6.07889, 51.17038], [6.07889, 51.24432], [6.16977, 51.33169], [6.22674, 51.36135], [6.22641, 51.39948], [6.20654, 51.40049], [6.21724, 51.48568], [6.18017, 51.54096], [6.09055, 51.60564], [6.11759, 51.65609], [6.02767, 51.6742], [6.04091, 51.71821], [5.95003, 51.7493], [5.98665, 51.76944], [5.94568, 51.82786], [5.99848, 51.83195], [6.06705, 51.86136], [6.10337, 51.84829], [6.16902, 51.84094], [6.11551, 51.89769], [6.15349, 51.90439], [6.21443, 51.86801], [6.29872, 51.86801], [6.30593, 51.84998], [6.40704, 51.82771], [6.38815, 51.87257], [6.47179, 51.85395], [6.50231, 51.86313], [6.58556, 51.89386], [6.68386, 51.91861], [6.72319, 51.89518], [6.82357, 51.96711], [6.83035, 51.9905], [6.68128, 52.05052], [6.76117, 52.11895], [6.83984, 52.11728], [6.97189, 52.20329], [6.9897, 52.2271], [7.03729, 52.22695], [7.06365, 52.23789], [7.02703, 52.27941], [7.07044, 52.37805], [7.03417, 52.40237], [6.99041, 52.47235], [6.94293, 52.43597], [6.69507, 52.488], [6.71641, 52.62905], [6.77307, 52.65375], [7.04557, 52.63318], [7.07253, 52.81083], [7.21694, 53.00742], [7.17898, 53.13817], [7.22681, 53.18165], [7.21679, 53.20058], [7.19052, 53.31866], [7.00198, 53.32672], [6.91025, 53.44221], [5.45168, 54.20039]], [[4.93295, 51.44945], [4.95244, 51.45207], [4.9524, 51.45014], [4.93909, 51.44632], [4.93295, 51.44945]], [[4.91493, 51.4353], [4.91935, 51.43634], [4.92227, 51.44252], [4.91811, 51.44621], [4.92287, 51.44741], [4.92811, 51.4437], [4.92566, 51.44273], [4.92815, 51.43856], [4.92879, 51.44161], [4.93544, 51.44634], [4.94025, 51.44193], [4.93416, 51.44185], [4.93471, 51.43861], [4.94265, 51.44003], [4.93986, 51.43064], [4.92952, 51.42984], [4.92652, 51.43329], [4.91493, 51.4353]]]] } },
28865     { type: "Feature", properties: { wikidata: "Q782", nameEn: "Hawaii", aliases: ["US-HI"], country: "US", groups: ["Q35657", "061", "009", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-177.8563, 29.18961], [-179.49839, 27.86265], [-151.6784, 9.55515], [-154.05867, 45.51124], [-177.5224, 27.7635], [-177.8563, 29.18961]]]] } },
28866     { type: "Feature", properties: { wikidata: "Q797", nameEn: "Alaska", aliases: ["US-AK"], country: "US", groups: ["Q35657", "021", "003", "019", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[169.34848, 52.47228], [180, 51.0171], [179.84401, 55.10087], [169.34848, 52.47228]]], [[[-168.95635, 65.98512], [-169.03888, 65.48473], [-172.76104, 63.77445], [-179.55295, 57.62081], [-179.55295, 50.81807], [-133.92876, 54.62289], [-130.61931, 54.70835], [-130.64499, 54.76912], [-130.44184, 54.85377], [-130.27203, 54.97174], [-130.18765, 55.07744], [-130.08035, 55.21556], [-129.97513, 55.28029], [-130.15373, 55.74895], [-130.00857, 55.91344], [-130.00093, 56.00325], [-130.10173, 56.12178], [-130.33965, 56.10849], [-130.77769, 56.36185], [-131.8271, 56.62247], [-133.38523, 58.42773], [-133.84645, 58.73543], [-134.27175, 58.8634], [-134.48059, 59.13231], [-134.55699, 59.1297], [-134.7047, 59.2458], [-135.00267, 59.28745], [-135.03069, 59.56208], [-135.48007, 59.79937], [-136.31566, 59.59083], [-136.22381, 59.55526], [-136.33727, 59.44466], [-136.47323, 59.46617], [-136.52365, 59.16752], [-136.82619, 59.16198], [-137.4925, 58.89415], [-137.60623, 59.24465], [-138.62145, 59.76431], [-138.71149, 59.90728], [-139.05365, 59.99655], [-139.20603, 60.08896], [-139.05831, 60.35205], [-139.68991, 60.33693], [-139.98024, 60.18027], [-140.45648, 60.30919], [-140.5227, 60.22077], [-141.00116, 60.30648], [-140.97446, 84.39275], [-168.25765, 71.99091], [-168.95635, 65.98512]]]] } },
28867     { type: "Feature", properties: { wikidata: "Q3492", nameEn: "Sumatra", aliases: ["ID-SM"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[109.82788, 2.86812], [110.90339, 7.52694], [105.01437, 3.24936], [104.56723, 1.44271], [104.34728, 1.33529], [104.12282, 1.27714], [104.03085, 1.26954], [103.74084, 1.12902], [103.66049, 1.18825], [103.56591, 1.19719], [103.03657, 1.30383], [96.11174, 6.69841], [74.28481, -3.17525], [102.92489, -8.17146], [106.32259, -5.50116], [106.38511, -5.16715], [109.17017, -4.07401], [109.3962, -2.07276], [108.50935, -2.01066], [107.94791, 1.06924], [109.82788, 2.86812]]]] } },
28868     { type: "Feature", properties: { wikidata: "Q3757", nameEn: "Java", aliases: ["ID-JW"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[109.17017, -4.07401], [106.38511, -5.16715], [106.32259, -5.50116], [102.92489, -8.17146], [116.22542, -10.49172], [114.39575, -8.2889], [114.42235, -8.09762], [114.92859, -7.49253], [116.33992, -7.56171], [116.58433, -5.30385], [109.17017, -4.07401]]]] } },
28869     { type: "Feature", properties: { wikidata: "Q3795", nameEn: "Kalimantan", aliases: ["ID-KA"], country: "ID", groups: ["Q36117", "035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[120.02464, 2.83703], [118.06469, 4.16638], [117.67641, 4.16535], [117.47313, 4.18857], [117.25801, 4.35108], [115.90217, 4.37708], [115.58276, 3.93499], [115.53713, 3.14776], [115.11343, 2.82879], [115.1721, 2.49671], [114.80706, 2.21665], [114.80706, 1.92351], [114.57892, 1.5], [114.03788, 1.44787], [113.64677, 1.23933], [113.01448, 1.42832], [113.021, 1.57819], [112.48648, 1.56516], [112.2127, 1.44135], [112.15679, 1.17004], [111.94553, 1.12016], [111.82846, 0.99349], [111.55434, 0.97864], [111.22979, 1.08326], [110.62374, 0.873], [110.49182, 0.88088], [110.35354, 0.98869], [109.66397, 1.60425], [109.66397, 1.79972], [109.57923, 1.80624], [109.53794, 1.91771], [109.62558, 1.99182], [109.82788, 2.86812], [107.94791, 1.06924], [108.50935, -2.01066], [109.3962, -2.07276], [109.17017, -4.07401], [116.58433, -5.30385], [120.02464, 2.83703]]]] } },
28870     { type: "Feature", properties: { wikidata: "Q3803", nameEn: "Lesser Sunda Islands", aliases: ["ID-NU"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[116.96967, -8.01483], [114.92859, -7.49253], [114.42235, -8.09762], [114.39575, -8.2889], [116.22542, -10.49172], [122.14954, -11.52517], [125.68138, -9.85176], [125.09025, -9.46406], [124.97892, -9.19281], [125.04044, -9.17093], [125.09434, -9.19669], [125.18907, -9.16434], [125.18632, -9.03142], [125.11764, -8.96359], [124.97742, -9.08128], [124.94011, -8.85617], [124.46701, -9.13002], [124.45971, -9.30263], [124.38554, -9.3582], [124.35258, -9.43002], [124.3535, -9.48493], [124.28115, -9.50453], [124.28115, -9.42189], [124.21247, -9.36904], [124.14517, -9.42324], [124.10539, -9.41206], [124.04286, -9.34243], [124.04628, -9.22671], [124.33472, -9.11416], [124.92337, -8.75859], [125.87688, -7.49892], [116.96967, -8.01483]]]] } },
28871     { type: "Feature", properties: { wikidata: "Q3812", nameEn: "Sulawesi", aliases: ["ID-SL"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[128.34321, 3.90322], [126.69413, 6.02692], [119.56457, 0.90759], [116.58433, -5.30385], [116.33992, -7.56171], [116.96967, -8.01483], [125.87688, -7.49892], [123.78965, -0.86805], [128.34321, 3.90322]]]] } },
28872     { type: "Feature", properties: { wikidata: "Q3827", nameEn: "Maluku Islands", aliases: ["ID-ML"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[129.63187, 2.21409], [128.34321, 3.90322], [123.78965, -0.86805], [125.87688, -7.49892], [125.58506, -7.95311], [125.87691, -8.31789], [127.42116, -8.22471], [127.55165, -9.05052], [135.49042, -9.2276], [135.35517, -5.01442], [132.8312, -4.70282], [130.8468, -2.61103], [128.40647, -2.30349], [129.71519, -0.24692], [129.63187, 2.21409]]]] } },
28873     { type: "Feature", properties: { wikidata: "Q3845", nameEn: "Western New Guinea", aliases: ["ID-PP"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[135.49042, -9.2276], [141.01842, -9.35091], [141.01763, -6.90181], [140.90448, -6.85033], [140.85295, -6.72996], [140.99813, -6.3233], [141.02352, 0.08993], [129.63187, 2.21409], [129.71519, -0.24692], [128.40647, -2.30349], [130.8468, -2.61103], [132.8312, -4.70282], [135.35517, -5.01442], [135.49042, -9.2276]]]] } },
28874     { type: "Feature", properties: { wikidata: "Q5765", nameEn: "Balearic Islands", aliases: ["ES-IB"], country: "ES", groups: ["EU", "039", "150", "UN"], callingCodes: ["34 971"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.27707, 35.35051], [5.10072, 39.89531], [3.75438, 42.33445], [-2.27707, 35.35051]]]] } },
28875     { type: "Feature", properties: { wikidata: "Q5823", nameEn: "Ceuta", aliases: ["ES-CE"], country: "ES", groups: ["EA", "EU", "015", "002", "UN"], level: "subterritory", callingCodes: ["34"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-5.38491, 35.92591], [-5.37338, 35.88417], [-5.35844, 35.87375], [-5.34379, 35.8711], [-5.21179, 35.90091], [-5.38491, 35.92591]]]] } },
28876     { type: "Feature", properties: { wikidata: "Q5831", nameEn: "Melilla", aliases: ["ES-ML"], country: "ES", groups: ["EA", "EU", "015", "002", "UN"], level: "subterritory", callingCodes: ["34"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.91909, 35.33927], [-2.96038, 35.31609], [-2.96648, 35.30475], [-2.96978, 35.29459], [-2.97035, 35.28852], [-2.96507, 35.28801], [-2.96826, 35.28296], [-2.96516, 35.27967], [-2.95431, 35.2728], [-2.95065, 35.26576], [-2.93893, 35.26737], [-2.92272, 35.27509], [-2.91909, 35.33927]]]] } },
28877     { type: "Feature", properties: { wikidata: "Q7835", nameEn: "Crimea", country: "RU", groups: ["151", "150", "UN"], level: "subterritory", callingCodes: ["7"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.5, 44], [36.4883, 45.0488], [36.475, 45.2411], [36.5049, 45.3136], [36.6545, 45.3417], [36.6645, 45.4514], [35.0498, 45.7683], [34.9601, 45.7563], [34.7991, 45.8101], [34.8015, 45.9005], [34.7548, 45.907], [34.6668, 45.9714], [34.6086, 45.9935], [34.5589, 45.9935], [34.5201, 45.951], [34.4873, 45.9427], [34.4415, 45.9599], [34.4122, 46.0025], [34.3391, 46.0611], [34.2511, 46.0532], [34.181, 46.068], [34.1293, 46.1049], [34.0731, 46.1177], [34.0527, 46.1084], [33.9155, 46.1594], [33.8523, 46.1986], [33.7972, 46.2048], [33.7405, 46.1855], [33.646, 46.2303], [33.6152, 46.2261], [33.6385, 46.1415], [33.6147, 46.1356], [33.5732, 46.1032], [33.5909, 46.0601], [33.5597, 46.0307], [31.5, 45.5], [33.5, 44]]]] } },
28878     { type: "Feature", properties: { wikidata: "Q12837", nameEn: "Iberia", level: "sharedLandform" }, geometry: null },
28879     { type: "Feature", properties: { wikidata: "Q14056", nameEn: "Jan Mayen", aliases: ["NO-22"], country: "NO", groups: ["SJ", "154", "150", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[-9.18243, 72.23144], [-10.71459, 70.09565], [-5.93364, 70.76368], [-9.18243, 72.23144]]]] } },
28880     { type: "Feature", properties: { wikidata: "Q19188", nameEn: "Mainland China", country: "CN", groups: ["030", "142", "UN"], callingCodes: ["86"] }, geometry: { type: "MultiPolygon", coordinates: [[[[125.6131, 53.07229], [125.17522, 53.20225], [124.46078, 53.21881], [123.86158, 53.49391], [123.26989, 53.54843], [122.85966, 53.47395], [122.35063, 53.49565], [121.39213, 53.31888], [120.85633, 53.28499], [120.0451, 52.7359], [120.04049, 52.58773], [120.46454, 52.63811], [120.71673, 52.54099], [120.61346, 52.32447], [120.77337, 52.20805], [120.65907, 51.93544], [120.10963, 51.671], [119.13553, 50.37412], [119.38598, 50.35162], [119.27996, 50.13348], [119.11003, 50.00276], [118.61623, 49.93809], [117.82343, 49.52696], [117.48208, 49.62324], [117.27597, 49.62544], [116.71193, 49.83813], [116.03781, 48.87014], [116.06565, 48.81716], [115.78876, 48.51781], [115.811, 48.25699], [115.52082, 48.15367], [115.57128, 47.91988], [115.94296, 47.67741], [116.21879, 47.88505], [116.4465, 47.83662], [116.67405, 47.89039], [116.9723, 47.87285], [117.37875, 47.63627], [117.50181, 47.77216], [117.80196, 48.01661], [118.03676, 48.00982], [118.11009, 48.04], [118.22677, 48.03853], [118.29654, 48.00246], [118.55766, 47.99277], [118.7564, 47.76947], [119.12343, 47.66458], [119.13995, 47.53997], [119.35892, 47.48104], [119.31964, 47.42617], [119.54918, 47.29505], [119.56019, 47.24874], [119.62403, 47.24575], [119.71209, 47.19192], [119.85518, 46.92196], [119.91242, 46.90091], [119.89261, 46.66423], [119.80455, 46.67631], [119.77373, 46.62947], [119.68127, 46.59015], [119.65265, 46.62342], [119.42827, 46.63783], [119.32827, 46.61433], [119.24978, 46.64761], [119.10448, 46.65516], [119.00541, 46.74273], [118.92616, 46.72765], [118.89974, 46.77139], [118.8337, 46.77742], [118.78747, 46.68689], [118.30534, 46.73519], [117.69554, 46.50991], [117.60748, 46.59771], [117.41782, 46.57862], [117.36609, 46.36335], [116.83166, 46.38637], [116.75551, 46.33083], [116.58612, 46.30211], [116.26678, 45.96479], [116.24012, 45.8778], [116.27366, 45.78637], [116.16989, 45.68603], [115.60329, 45.44717], [114.94546, 45.37377], [114.74612, 45.43585], [114.54801, 45.38337], [114.5166, 45.27189], [113.70918, 44.72891], [112.74662, 44.86297], [112.4164, 45.06858], [111.98695, 45.09074], [111.76275, 44.98032], [111.40498, 44.3461], [111.96289, 43.81596], [111.93776, 43.68709], [111.79758, 43.6637], [111.59087, 43.51207], [111.0149, 43.3289], [110.4327, 42.78293], [110.08401, 42.6411], [109.89402, 42.63111], [109.452, 42.44842], [109.00679, 42.45302], [108.84489, 42.40246], [107.57258, 42.40898], [107.49681, 42.46221], [107.29755, 42.41395], [107.24774, 42.36107], [106.76517, 42.28741], [105.0123, 41.63188], [104.51667, 41.66113], [104.52258, 41.8706], [103.92804, 41.78246], [102.72403, 42.14675], [102.07645, 42.22519], [101.80515, 42.50074], [100.84979, 42.67087], [100.33297, 42.68231], [99.50671, 42.56535], [97.1777, 42.7964], [96.37926, 42.72055], [96.35658, 42.90363], [95.89543, 43.2528], [95.52594, 43.99353], [95.32891, 44.02407], [95.39772, 44.2805], [95.01191, 44.25274], [94.71959, 44.35284], [94.10003, 44.71016], [93.51161, 44.95964], [91.64048, 45.07408], [90.89169, 45.19667], [90.65114, 45.49314], [90.70907, 45.73437], [91.03026, 46.04194], [90.99672, 46.14207], [90.89639, 46.30711], [91.07696, 46.57315], [91.0147, 46.58171], [91.03649, 46.72916], [90.84035, 46.99525], [90.76108, 46.99399], [90.48542, 47.30438], [90.48854, 47.41826], [90.33598, 47.68303], [90.10871, 47.7375], [90.06512, 47.88177], [89.76624, 47.82745], [89.55453, 48.0423], [89.0711, 47.98528], [88.93186, 48.10263], [88.8011, 48.11302], [88.58316, 48.21893], [88.58939, 48.34531], [87.96361, 48.58478], [88.0788, 48.71436], [87.73822, 48.89582], [87.88171, 48.95853], [87.81333, 49.17354], [87.48983, 49.13794], [87.478, 49.07403], [87.28386, 49.11626], [86.87238, 49.12432], [86.73568, 48.99918], [86.75343, 48.70331], [86.38069, 48.46064], [85.73581, 48.3939], [85.5169, 48.05493], [85.61067, 47.49753], [85.69696, 47.2898], [85.54294, 47.06171], [85.22443, 47.04816], [84.93995, 46.87399], [84.73077, 47.01394], [83.92184, 46.98912], [83.04622, 47.19053], [82.21792, 45.56619], [82.58474, 45.40027], [82.51374, 45.1755], [81.73278, 45.3504], [80.11169, 45.03352], [79.8987, 44.89957], [80.38384, 44.63073], [80.40229, 44.23319], [80.40031, 44.10986], [80.75156, 43.44948], [80.69718, 43.32589], [80.77771, 43.30065], [80.78817, 43.14235], [80.62913, 43.141], [80.3735, 43.01557], [80.58999, 42.9011], [80.38169, 42.83142], [80.26886, 42.8366], [80.16892, 42.61137], [80.26841, 42.23797], [80.17807, 42.21166], [80.17842, 42.03211], [79.92977, 42.04113], [78.3732, 41.39603], [78.15757, 41.38565], [78.12873, 41.23091], [77.81287, 41.14307], [77.76206, 41.01574], [77.52723, 41.00227], [77.3693, 41.0375], [77.28004, 41.0033], [76.99302, 41.0696], [76.75681, 40.95354], [76.5261, 40.46114], [76.33659, 40.3482], [75.96168, 40.38064], [75.91361, 40.2948], [75.69663, 40.28642], [75.5854, 40.66874], [75.22834, 40.45382], [75.08243, 40.43945], [74.82013, 40.52197], [74.78168, 40.44886], [74.85996, 40.32857], [74.69875, 40.34668], [74.35063, 40.09742], [74.25533, 40.13191], [73.97049, 40.04378], [73.83006, 39.76136], [73.9051, 39.75073], [73.92354, 39.69565], [73.94683, 39.60733], [73.87018, 39.47879], [73.59831, 39.46425], [73.59241, 39.40843], [73.5004, 39.38402], [73.55396, 39.3543], [73.54572, 39.27567], [73.60638, 39.24534], [73.75823, 39.023], [73.81728, 39.04007], [73.82964, 38.91517], [73.7445, 38.93867], [73.7033, 38.84782], [73.80656, 38.66449], [73.79806, 38.61106], [73.97933, 38.52945], [74.17022, 38.65504], [74.51217, 38.47034], [74.69619, 38.42947], [74.69894, 38.22155], [74.80331, 38.19889], [74.82665, 38.07359], [74.9063, 38.03033], [74.92416, 37.83428], [75.00935, 37.77486], [74.8912, 37.67576], [74.94338, 37.55501], [75.06011, 37.52779], [75.15899, 37.41443], [75.09719, 37.37297], [75.12328, 37.31839], [74.88887, 37.23275], [74.80605, 37.21565], [74.49981, 37.24518], [74.56453, 37.03023], [75.13839, 37.02622], [75.40481, 36.95382], [75.45562, 36.71971], [75.72737, 36.7529], [75.92391, 36.56986], [76.0324, 36.41198], [76.00906, 36.17511], [75.93028, 36.13136], [76.15325, 35.9264], [76.14913, 35.82848], [76.33453, 35.84296], [76.50961, 35.8908], [76.77323, 35.66062], [76.84539, 35.67356], [76.96624, 35.5932], [77.44277, 35.46132], [77.70232, 35.46244], [77.80532, 35.52058], [78.11664, 35.48022], [78.03466, 35.3785], [78.00033, 35.23954], [78.22692, 34.88771], [78.18435, 34.7998], [78.27781, 34.61484], [78.54964, 34.57283], [78.56475, 34.50835], [78.74465, 34.45174], [79.05364, 34.32482], [78.99802, 34.3027], [78.91769, 34.15452], [78.66225, 34.08858], [78.65657, 34.03195], [78.73367, 34.01121], [78.77349, 33.73871], [78.67599, 33.66445], [78.73636, 33.56521], [79.15252, 33.17156], [79.14016, 33.02545], [79.46562, 32.69668], [79.26768, 32.53277], [79.13174, 32.47766], [79.0979, 32.38051], [78.99322, 32.37948], [78.96713, 32.33655], [78.7831, 32.46873], [78.73916, 32.69438], [78.38897, 32.53938], [78.4645, 32.45367], [78.49609, 32.2762], [78.68754, 32.10256], [78.74404, 32.00384], [78.78036, 31.99478], [78.69933, 31.78723], [78.84516, 31.60631], [78.71032, 31.50197], [78.77898, 31.31209], [78.89344, 31.30481], [79.01931, 31.42817], [79.14016, 31.43403], [79.30694, 31.17357], [79.59884, 30.93943], [79.93255, 30.88288], [80.20721, 30.58541], [80.54504, 30.44936], [80.83343, 30.32023], [81.03953, 30.20059], [81.12842, 30.01395], [81.24362, 30.0126], [81.29032, 30.08806], [81.2623, 30.14596], [81.33355, 30.15303], [81.39928, 30.21862], [81.41018, 30.42153], [81.5459, 30.37688], [81.62033, 30.44703], [81.99082, 30.33423], [82.10135, 30.35439], [82.10757, 30.23745], [82.19475, 30.16884], [82.16984, 30.0692], [82.38622, 30.02608], [82.5341, 29.9735], [82.73024, 29.81695], [83.07116, 29.61957], [83.28131, 29.56813], [83.44787, 29.30513], [83.63156, 29.16249], [83.82303, 29.30513], [83.97559, 29.33091], [84.18107, 29.23451], [84.24801, 29.02783], [84.2231, 28.89571], [84.47528, 28.74023], [84.62317, 28.73887], [84.85511, 28.58041], [85.06059, 28.68562], [85.19135, 28.62825], [85.18668, 28.54076], [85.10729, 28.34092], [85.38127, 28.28336], [85.4233, 28.32996], [85.59765, 28.30529], [85.60854, 28.25045], [85.69105, 28.38475], [85.71907, 28.38064], [85.74864, 28.23126], [85.84672, 28.18187], [85.90743, 28.05144], [85.97813, 27.99023], [85.94946, 27.9401], [86.06309, 27.90021], [86.12069, 27.93047], [86.08333, 28.02121], [86.088, 28.09264], [86.18607, 28.17364], [86.22966, 27.9786], [86.42736, 27.91122], [86.51609, 27.96623], [86.56265, 28.09569], [86.74181, 28.10638], [86.75582, 28.04182], [87.03757, 27.94835], [87.11696, 27.84104], [87.56996, 27.84517], [87.72718, 27.80938], [87.82681, 27.95248], [88.13378, 27.88015], [88.1278, 27.95417], [88.25332, 27.9478], [88.54858, 28.06057], [88.63235, 28.12356], [88.83559, 28.01936], [88.88091, 27.85192], [88.77517, 27.45415], [88.82981, 27.38814], [88.91901, 27.32483], [88.93678, 27.33777], [88.96947, 27.30319], [89.00216, 27.32532], [88.95355, 27.4106], [88.97213, 27.51671], [89.0582, 27.60985], [89.12825, 27.62502], [89.59525, 28.16433], [89.79762, 28.23979], [90.13387, 28.19178], [90.58842, 28.02838], [90.69894, 28.07784], [91.20019, 27.98715], [91.25779, 28.07509], [91.46327, 28.0064], [91.48973, 27.93903], [91.5629, 27.84823], [91.6469, 27.76358], [91.84722, 27.76325], [91.87057, 27.7195], [92.27432, 27.89077], [92.32101, 27.79363], [92.42538, 27.80092], [92.7275, 27.98662], [92.73025, 28.05814], [92.65472, 28.07632], [92.67486, 28.15018], [92.93075, 28.25671], [93.14635, 28.37035], [93.18069, 28.50319], [93.44621, 28.67189], [93.72797, 28.68821], [94.35897, 29.01965], [94.2752, 29.11687], [94.69318, 29.31739], [94.81353, 29.17804], [95.0978, 29.14446], [95.11291, 29.09527], [95.2214, 29.10727], [95.26122, 29.07727], [95.3038, 29.13847], [95.41091, 29.13007], [95.50842, 29.13487], [95.72086, 29.20797], [95.75149, 29.32063], [95.84899, 29.31464], [96.05361, 29.38167], [96.31316, 29.18643], [96.18682, 29.11087], [96.20467, 29.02325], [96.3626, 29.10607], [96.61391, 28.72742], [96.40929, 28.51526], [96.48895, 28.42955], [96.6455, 28.61657], [96.85561, 28.4875], [96.88445, 28.39452], [96.98882, 28.32564], [97.1289, 28.3619], [97.34547, 28.21385], [97.41729, 28.29783], [97.47085, 28.2688], [97.50518, 28.49716], [97.56835, 28.55628], [97.70705, 28.5056], [97.79632, 28.33168], [97.90069, 28.3776], [98.15337, 28.12114], [98.13964, 27.9478], [98.32641, 27.51385], [98.42529, 27.55404], [98.43353, 27.67086], [98.69582, 27.56499], [98.7333, 26.85615], [98.77547, 26.61994], [98.72741, 26.36183], [98.67797, 26.24487], [98.7329, 26.17218], [98.66884, 26.09165], [98.63128, 26.15492], [98.57085, 26.11547], [98.60763, 26.01512], [98.70818, 25.86241], [98.63128, 25.79937], [98.54064, 25.85129], [98.40606, 25.61129], [98.31268, 25.55307], [98.25774, 25.6051], [98.16848, 25.62739], [98.18084, 25.56298], [98.12591, 25.50722], [98.14925, 25.41547], [97.92541, 25.20815], [97.83614, 25.2715], [97.77023, 25.11492], [97.72216, 25.08508], [97.72903, 24.91332], [97.79949, 24.85655], [97.76481, 24.8289], [97.73127, 24.83015], [97.70181, 24.84557], [97.64354, 24.79171], [97.56648, 24.76475], [97.56383, 24.75535], [97.5542, 24.74943], [97.54675, 24.74202], [97.56525, 24.72838], [97.56286, 24.54535], [97.52757, 24.43748], [97.60029, 24.4401], [97.66998, 24.45288], [97.7098, 24.35658], [97.65624, 24.33781], [97.66723, 24.30027], [97.71941, 24.29652], [97.76799, 24.26365], [97.72998, 24.2302], [97.72799, 24.18883], [97.75305, 24.16902], [97.72903, 24.12606], [97.62363, 24.00506], [97.5247, 23.94032], [97.64667, 23.84574], [97.72302, 23.89288], [97.79456, 23.94836], [97.79416, 23.95663], [97.84328, 23.97603], [97.86545, 23.97723], [97.88811, 23.97446], [97.8955, 23.97758], [97.89676, 23.97931], [97.89683, 23.98389], [97.88814, 23.98605], [97.88414, 23.99405], [97.88616, 24.00463], [97.90998, 24.02094], [97.93951, 24.01953], [97.98691, 24.03897], [97.99583, 24.04932], [98.04709, 24.07616], [98.05302, 24.07408], [98.05671, 24.07961], [98.0607, 24.07812], [98.06703, 24.08028], [98.07806, 24.07988], [98.20666, 24.11406], [98.54476, 24.13119], [98.59256, 24.08371], [98.85319, 24.13042], [98.87998, 24.15624], [98.89632, 24.10612], [98.67797, 23.9644], [98.68209, 23.80492], [98.79607, 23.77947], [98.82933, 23.72921], [98.81775, 23.694], [98.88396, 23.59555], [98.80294, 23.5345], [98.82877, 23.47908], [98.87683, 23.48995], [98.92104, 23.36946], [98.87573, 23.33038], [98.93958, 23.31414], [98.92515, 23.29535], [98.88597, 23.18656], [99.05975, 23.16382], [99.04601, 23.12215], [99.25741, 23.09025], [99.34127, 23.13099], [99.52214, 23.08218], [99.54218, 22.90014], [99.43537, 22.94086], [99.45654, 22.85726], [99.31243, 22.73893], [99.38247, 22.57544], [99.37972, 22.50188], [99.28771, 22.4105], [99.17318, 22.18025], [99.19176, 22.16983], [99.1552, 22.15874], [99.33166, 22.09656], [99.47585, 22.13345], [99.85351, 22.04183], [99.96612, 22.05965], [99.99084, 21.97053], [99.94003, 21.82782], [99.98654, 21.71064], [100.04956, 21.66843], [100.12679, 21.70539], [100.17486, 21.65306], [100.10757, 21.59945], [100.12542, 21.50365], [100.1625, 21.48704], [100.18447, 21.51898], [100.25863, 21.47043], [100.35201, 21.53176], [100.42892, 21.54325], [100.4811, 21.46148], [100.57861, 21.45637], [100.72143, 21.51898], [100.87265, 21.67396], [101.11744, 21.77659], [101.15156, 21.56129], [101.2124, 21.56422], [101.19349, 21.41959], [101.26912, 21.36482], [101.2229, 21.23271], [101.29326, 21.17254], [101.54563, 21.25668], [101.6068, 21.23329], [101.59491, 21.18621], [101.60886, 21.17947], [101.66977, 21.20004], [101.70548, 21.14911], [101.7622, 21.14813], [101.79266, 21.19025], [101.76745, 21.21571], [101.83887, 21.20983], [101.84412, 21.25291], [101.74014, 21.30967], [101.74224, 21.48276], [101.7727, 21.51794], [101.7475, 21.5873], [101.80001, 21.57461], [101.83257, 21.61562], [101.74555, 21.72852], [101.7791, 21.83019], [101.62566, 21.96574], [101.57525, 22.13026], [101.60675, 22.13513], [101.53638, 22.24794], [101.56789, 22.28876], [101.61306, 22.27515], [101.68973, 22.46843], [101.7685, 22.50337], [101.86828, 22.38397], [101.90714, 22.38688], [101.91344, 22.44417], [101.98487, 22.42766], [102.03633, 22.46164], [102.1245, 22.43372], [102.14099, 22.40092], [102.16621, 22.43336], [102.26428, 22.41321], [102.25339, 22.4607], [102.41061, 22.64184], [102.38415, 22.67919], [102.42618, 22.69212], [102.46665, 22.77108], [102.51802, 22.77969], [102.57095, 22.7036], [102.60675, 22.73376], [102.8636, 22.60735], [102.9321, 22.48659], [103.0722, 22.44775], [103.07843, 22.50097], [103.17961, 22.55705], [103.15782, 22.59873], [103.18895, 22.64471], [103.28079, 22.68063], [103.32282, 22.8127], [103.43179, 22.75816], [103.43646, 22.70648], [103.52675, 22.59155], [103.57812, 22.65764], [103.56255, 22.69499], [103.64506, 22.79979], [103.87904, 22.56683], [103.93286, 22.52703], [103.94513, 22.52553], [103.95191, 22.5134], [103.96352, 22.50584], [103.96783, 22.51173], [103.97384, 22.50634], [103.99247, 22.51958], [104.01088, 22.51823], [104.03734, 22.72945], [104.11384, 22.80363], [104.27084, 22.8457], [104.25683, 22.76534], [104.35593, 22.69353], [104.47225, 22.75813], [104.58122, 22.85571], [104.60457, 22.81841], [104.65283, 22.83419], [104.72755, 22.81984], [104.77114, 22.90017], [104.84942, 22.93631], [104.86765, 22.95178], [104.8334, 23.01484], [104.79478, 23.12934], [104.87382, 23.12854], [104.87992, 23.17141], [104.91435, 23.18666], [104.9486, 23.17235], [104.96532, 23.20463], [104.98712, 23.19176], [105.07002, 23.26248], [105.11672, 23.25247], [105.17276, 23.28679], [105.22569, 23.27249], [105.32376, 23.39684], [105.40782, 23.28107], [105.42805, 23.30824], [105.49966, 23.20669], [105.56037, 23.16806], [105.57594, 23.075], [105.72382, 23.06641], [105.8726, 22.92756], [105.90119, 22.94168], [105.99568, 22.94178], [106.00179, 22.99049], [106.19705, 22.98475], [106.27022, 22.87722], [106.34961, 22.86718], [106.49749, 22.91164], [106.51306, 22.94891], [106.55976, 22.92311], [106.60179, 22.92884], [106.6516, 22.86862], [106.6734, 22.89587], [106.71387, 22.88296], [106.71128, 22.85982], [106.78422, 22.81532], [106.81271, 22.8226], [106.83685, 22.8098], [106.82404, 22.7881], [106.76293, 22.73491], [106.72321, 22.63606], [106.71698, 22.58432], [106.65316, 22.5757], [106.61269, 22.60301], [106.58395, 22.474], [106.55665, 22.46498], [106.57221, 22.37], [106.55976, 22.34841], [106.6516, 22.33977], [106.69986, 22.22309], [106.67495, 22.1885], [106.6983, 22.15102], [106.70142, 22.02409], [106.68274, 21.99811], [106.69276, 21.96013], [106.72551, 21.97923], [106.74345, 22.00965], [106.81038, 21.97934], [106.9178, 21.97357], [106.92714, 21.93459], [106.97228, 21.92592], [106.99252, 21.95191], [107.05634, 21.92303], [107.06101, 21.88982], [107.00964, 21.85948], [107.02615, 21.81981], [107.10771, 21.79879], [107.20734, 21.71493], [107.24625, 21.7077], [107.29296, 21.74674], [107.35834, 21.6672], [107.35989, 21.60063], [107.38636, 21.59774], [107.41593, 21.64839], [107.47197, 21.6672], [107.49532, 21.62958], [107.49065, 21.59774], [107.54047, 21.5934], [107.56537, 21.61945], [107.66967, 21.60787], [107.80355, 21.66141], [107.86114, 21.65128], [107.90006, 21.5905], [107.92652, 21.58906], [107.95232, 21.5388], [107.96774, 21.53601], [107.97074, 21.54072], [107.97383, 21.53961], [107.97932, 21.54503], [108.02926, 21.54997], [108.0569, 21.53604], [108.10003, 21.47338], [108.00365, 17.98159], [111.60491, 13.57105], [118.41371, 24.06775], [118.11703, 24.39734], [118.28244, 24.51231], [118.35291, 24.51645], [118.42453, 24.54644], [118.6333, 24.46259], [119.42295, 25.0886], [119.98511, 25.37624], [119.78816, 26.2348], [120.0693, 26.3959], [120.5128, 26.536], [121.03532, 26.8787], [123.5458, 31.01942], [122.29378, 31.76513], [122.80525, 33.30571], [123.85601, 37.49093], [123.90497, 38.79949], [124.17532, 39.8232], [124.23201, 39.9248], [124.35029, 39.95639], [124.37089, 40.03004], [124.3322, 40.05573], [124.38556, 40.11047], [124.40719, 40.13655], [124.86913, 40.45387], [125.71172, 40.85223], [125.76869, 40.87908], [126.00335, 40.92835], [126.242, 41.15454], [126.53189, 41.35206], [126.60631, 41.65565], [126.90729, 41.79955], [127.17841, 41.59714], [127.29712, 41.49473], [127.92943, 41.44291], [128.02633, 41.42103], [128.03311, 41.39232], [128.12967, 41.37931], [128.18546, 41.41279], [128.20061, 41.40895], [128.30716, 41.60322], [128.15119, 41.74568], [128.04487, 42.01769], [128.94007, 42.03537], [128.96068, 42.06657], [129.15178, 42.17224], [129.22285, 42.26491], [129.22423, 42.3553], [129.28541, 42.41574], [129.42882, 42.44702], [129.54701, 42.37254], [129.60482, 42.44461], [129.72541, 42.43739], [129.75294, 42.59409], [129.77183, 42.69435], [129.7835, 42.76521], [129.80719, 42.79218], [129.83277, 42.86746], [129.85261, 42.96494], [129.8865, 43.00395], [129.95082, 43.01051], [129.96409, 42.97306], [130.12957, 42.98361], [130.09764, 42.91425], [130.26095, 42.9027], [130.23068, 42.80125], [130.2385, 42.71127], [130.41826, 42.6011], [130.44361, 42.54849], [130.50123, 42.61636], [130.55143, 42.52158], [130.62107, 42.58413], [130.56576, 42.68925], [130.40213, 42.70788], [130.44361, 42.76205], [130.66524, 42.84753], [131.02438, 42.86518], [131.02668, 42.91246], [131.135, 42.94114], [131.10274, 43.04734], [131.20414, 43.13654], [131.19031, 43.21385], [131.30324, 43.39498], [131.29402, 43.46695], [131.19492, 43.53047], [131.21105, 43.82383], [131.26176, 43.94011], [131.23583, 43.96085], [131.25484, 44.03131], [131.30365, 44.04262], [131.1108, 44.70266], [130.95639, 44.85154], [131.48415, 44.99513], [131.68466, 45.12374], [131.66852, 45.2196], [131.76532, 45.22609], [131.86903, 45.33636], [131.99417, 45.2567], [132.83978, 45.05916], [132.96373, 45.0212], [133.12293, 45.1332], [133.09279, 45.25693], [133.19419, 45.51913], [133.41083, 45.57723], [133.48457, 45.86203], [133.60442, 45.90053], [133.67569, 45.9759], [133.72695, 46.05576], [133.68047, 46.14697], [133.88097, 46.25066], [133.91496, 46.4274], [133.84104, 46.46681], [134.03538, 46.75668], [134.20016, 47.33458], [134.50898, 47.4812], [134.7671, 47.72051], [134.55508, 47.98651], [134.67098, 48.1564], [134.75328, 48.36763], [134.49516, 48.42884], [132.66989, 47.96491], [132.57309, 47.71741], [131.90448, 47.68011], [131.2635, 47.73325], [131.09871, 47.6852], [130.95985, 47.6957], [130.90915, 47.90623], [130.65103, 48.10052], [130.84462, 48.30942], [130.52147, 48.61745], [130.66946, 48.88251], [130.43232, 48.90844], [130.2355, 48.86741], [129.85416, 49.11067], [129.67598, 49.29596], [129.50685, 49.42398], [129.40398, 49.44194], [129.35317, 49.3481], [129.23232, 49.40353], [129.11153, 49.36813], [128.72896, 49.58676], [127.83476, 49.5748], [127.53516, 49.84306], [127.49299, 50.01251], [127.60515, 50.23503], [127.37384, 50.28393], [127.36009, 50.43787], [127.28765, 50.46585], [127.36335, 50.58306], [127.28165, 50.72075], [127.14586, 50.91152], [126.93135, 51.0841], [126.90369, 51.3238], [126.68349, 51.70607], [126.44606, 51.98254], [126.558, 52.13738], [125.6131, 53.07229]], [[113.56865, 22.20973], [113.57123, 22.20416], [113.60504, 22.20464], [113.63011, 22.10782], [113.57191, 22.07696], [113.54839, 22.10909], [113.54942, 22.14519], [113.54093, 22.15497], [113.52659, 22.18271], [113.53552, 22.20607], [113.53301, 22.21235], [113.53591, 22.21369], [113.54093, 22.21314], [113.54333, 22.21688], [113.5508, 22.21672], [113.56865, 22.20973]], [[114.50148, 22.15017], [113.92195, 22.13873], [113.83338, 22.1826], [113.81621, 22.2163], [113.86771, 22.42972], [114.03113, 22.5065], [114.05438, 22.5026], [114.05729, 22.51104], [114.06272, 22.51617], [114.07267, 22.51855], [114.07817, 22.52997], [114.08606, 22.53276], [114.09048, 22.53716], [114.09692, 22.53435], [114.1034, 22.5352], [114.11181, 22.52878], [114.11656, 22.53415], [114.12665, 22.54003], [114.13823, 22.54319], [114.1482, 22.54091], [114.15123, 22.55163], [114.1597, 22.56041], [114.17247, 22.55944], [114.18338, 22.55444], [114.20655, 22.55706], [114.22185, 22.55343], [114.22888, 22.5436], [114.25154, 22.55977], [114.44998, 22.55977], [114.50148, 22.15017]]]] } },
28881     { type: "Feature", properties: { wikidata: "Q22890", nameEn: "Ireland", level: "sharedLandform" }, geometry: null },
28882     { type: "Feature", properties: { wikidata: "Q23666", nameEn: "Great Britain", country: "GB", level: "sharedLandform" }, geometry: null },
28883     { type: "Feature", properties: { wikidata: "Q23681", nameEn: "Northern Cyprus", groups: ["Q644636", "145", "142"], driveSide: "left", callingCodes: ["90 392"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.67678, 35.03866], [33.67742, 35.05963], [33.68474, 35.06602], [33.69095, 35.06237], [33.70861, 35.07644], [33.7161, 35.07279], [33.70209, 35.04882], [33.71482, 35.03722], [33.73824, 35.05321], [33.76106, 35.04253], [33.78581, 35.05104], [33.82067, 35.07826], [33.84168, 35.06823], [33.8541, 35.07201], [33.87479, 35.08881], [33.87097, 35.09389], [33.87622, 35.10457], [33.87224, 35.12293], [33.88561, 35.12449], [33.88943, 35.12007], [33.88737, 35.11408], [33.89853, 35.11377], [33.91789, 35.08688], [33.90247, 35.07686], [33.92495, 35.06789], [33.94869, 35.07277], [33.99999, 35.07016], [34.23164, 35.1777], [35.51152, 36.10954], [32.82353, 35.70297], [32.46489, 35.48584], [32.60361, 35.16647], [32.64864, 35.19967], [32.70947, 35.18328], [32.70779, 35.14127], [32.85733, 35.07742], [32.86406, 35.1043], [32.94471, 35.09422], [33.01192, 35.15639], [33.08249, 35.17319], [33.11105, 35.15639], [33.15138, 35.19504], [33.27068, 35.16815], [33.3072, 35.16816], [33.31955, 35.18096], [33.35056, 35.18328], [33.34964, 35.17803], [33.35596, 35.17942], [33.35612, 35.17402], [33.36569, 35.17479], [33.3717, 35.1788], [33.37248, 35.18698], [33.38575, 35.2018], [33.4076, 35.20062], [33.41675, 35.16325], [33.46813, 35.10564], [33.48136, 35.0636], [33.47825, 35.04103], [33.45178, 35.02078], [33.45256, 35.00288], [33.47666, 35.00701], [33.48915, 35.06594], [33.53975, 35.08151], [33.57478, 35.06049], [33.567, 35.04803], [33.59658, 35.03635], [33.61215, 35.0527], [33.63765, 35.03869], [33.67678, 35.03866]]]] } },
28884     { type: "Feature", properties: { wikidata: "Q25231", nameEn: "Svalbard", aliases: ["NO-21"], country: "NO", groups: ["SJ", "154", "150", "UN"], level: "subterritory", callingCodes: ["47 79"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-7.49892, 77.24208], [32.07813, 72.01005], [36.85549, 84.09565], [-7.49892, 77.24208]]]] } },
28885     { type: "Feature", properties: { wikidata: "Q25263", nameEn: "Azores", aliases: ["PT-20"], country: "PT", groups: ["Q3320166", "Q2914565", "Q105472", "EU", "039", "150", "UN"], callingCodes: ["351"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-23.12984, 40.26428], [-36.43765, 41.39418], [-22.54767, 33.34416], [-23.12984, 40.26428]]]] } },
28886     { type: "Feature", properties: { wikidata: "Q25359", nameEn: "Navassa Island", aliases: ["UM-76"], country: "US", groups: ["UM", "Q1352230", "029", "003", "419", "019", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft" }, geometry: { type: "MultiPolygon", coordinates: [[[[-74.7289, 18.71009], [-75.71816, 18.46438], [-74.76465, 18.06252], [-74.7289, 18.71009]]]] } },
28887     { type: "Feature", properties: { wikidata: "Q25396", nameEn: "Bonaire", aliases: ["BQ-BO", "NL-BQ1"], country: "NL", groups: ["Q1451600", "BQ", "029", "003", "419", "019", "UN"], level: "subterritory", callingCodes: ["599 7"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-67.89186, 12.4116], [-68.90012, 12.62309], [-68.33524, 11.78151], [-68.01417, 11.77722], [-67.89186, 12.4116]]]] } },
28888     { type: "Feature", properties: { wikidata: "Q25528", nameEn: "Saba", aliases: ["BQ-SA", "NL-BQ2"], country: "NL", groups: ["Q1451600", "BQ", "029", "003", "419", "019", "UN"], level: "subterritory", callingCodes: ["599 4"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.07669, 17.79659], [-63.81314, 17.95045], [-63.22932, 17.32592], [-63.07669, 17.79659]]]] } },
28889     { type: "Feature", properties: { wikidata: "Q26180", nameEn: "Sint Eustatius", aliases: ["BQ-SE", "NL-BQ3"], country: "NL", groups: ["Q1451600", "BQ", "029", "003", "419", "019", "UN"], level: "subterritory", callingCodes: ["599 3"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.07669, 17.79659], [-63.34999, 16.94218], [-62.76692, 17.64353], [-63.07669, 17.79659]]]] } },
28890     { type: "Feature", properties: { wikidata: "Q26253", nameEn: "Madeira", aliases: ["PT-30"], country: "PT", groups: ["Q3320166", "Q2914565", "Q105472", "EU", "039", "150", "UN"], callingCodes: ["351"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-19.30302, 33.65304], [-16.04789, 29.65076], [-11.68307, 33.12333], [-19.30302, 33.65304]]]] } },
28891     { type: "Feature", properties: { wikidata: "Q26927", nameEn: "Lakshadweep", aliases: ["IN-LD"], country: "IN", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["91"] }, geometry: { type: "MultiPolygon", coordinates: [[[[67.64074, 11.57295], [76.59015, 5.591], [72.67494, 13.58102], [67.64074, 11.57295]]]] } },
28892     { type: "Feature", properties: { wikidata: "Q27329", nameEn: "Asian Russia", country: "RU", groups: ["142", "UN"], callingCodes: ["7"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-179.99933, 64.74703], [-172.76104, 63.77445], [-169.03888, 65.48473], [-168.95635, 65.98512], [-168.25765, 71.99091], [-179.9843, 71.90735], [-179.99933, 64.74703]]], [[[59.99809, 51.98263], [60.19925, 51.99173], [60.48915, 52.15175], [60.72581, 52.15538], [60.78201, 52.22067], [61.05417, 52.35096], [60.98021, 52.50068], [60.84709, 52.52228], [60.84118, 52.63912], [60.71693, 52.66245], [60.71989, 52.75923], [61.05842, 52.92217], [61.23462, 53.03227], [62.0422, 52.96105], [62.12799, 52.99133], [62.14574, 53.09626], [61.19024, 53.30536], [61.14291, 53.41481], [61.29082, 53.50992], [61.37957, 53.45887], [61.57185, 53.50112], [61.55706, 53.57144], [60.90626, 53.62937], [61.22574, 53.80268], [61.14283, 53.90063], [60.99796, 53.93699], [61.26863, 53.92797], [61.3706, 54.08464], [61.47603, 54.08048], [61.56941, 53.95703], [61.65318, 54.02445], [62.03913, 53.94768], [62.00966, 54.04134], [62.38535, 54.03961], [62.45931, 53.90737], [62.56876, 53.94047], [62.58651, 54.05871], [63.80604, 54.27079], [63.91224, 54.20013], [64.02715, 54.22679], [63.97686, 54.29763], [64.97216, 54.4212], [65.11033, 54.33028], [65.24663, 54.35721], [65.20174, 54.55216], [68.21308, 54.98645], [68.26661, 55.09226], [68.19206, 55.18823], [68.90865, 55.38148], [69.34224, 55.36344], [69.74917, 55.35545], [70.19179, 55.1476], [70.76493, 55.3027], [70.96009, 55.10558], [71.08288, 54.71253], [71.24185, 54.64965], [71.08706, 54.33376], [71.10379, 54.13326], [71.96141, 54.17736], [72.17477, 54.36303], [72.43415, 53.92685], [72.71026, 54.1161], [73.37963, 53.96132], [73.74778, 54.07194], [73.68921, 53.86522], [73.25412, 53.61532], [73.39218, 53.44623], [75.07405, 53.80831], [75.43398, 53.98652], [75.3668, 54.07439], [76.91052, 54.4677], [76.82266, 54.1798], [76.44076, 54.16017], [76.54243, 53.99329], [77.90383, 53.29807], [79.11255, 52.01171], [80.08138, 50.77658], [80.4127, 50.95581], [80.44819, 51.20855], [80.80318, 51.28262], [81.16999, 51.15662], [81.06091, 50.94833], [81.41248, 50.97524], [81.46581, 50.77658], [81.94999, 50.79307], [82.55443, 50.75412], [83.14607, 51.00796], [83.8442, 50.87375], [84.29385, 50.27257], [84.99198, 50.06793], [85.24047, 49.60239], [86.18709, 49.50259], [86.63674, 49.80136], [86.79056, 49.74787], [86.61307, 49.60239], [86.82606, 49.51796], [87.03071, 49.25142], [87.31465, 49.23603], [87.28386, 49.11626], [87.478, 49.07403], [87.48983, 49.13794], [87.81333, 49.17354], [87.98977, 49.18147], [88.15543, 49.30314], [88.17223, 49.46934], [88.42449, 49.48821], [88.82499, 49.44808], [89.70687, 49.72535], [89.59711, 49.90851], [91.86048, 50.73734], [92.07173, 50.69585], [92.44714, 50.78762], [93.01109, 50.79001], [92.99595, 50.63183], [94.30823, 50.57498], [94.39258, 50.22193], [94.49477, 50.17832], [94.6121, 50.04239], [94.97166, 50.04725], [95.02465, 49.96941], [95.74757, 49.97915], [95.80056, 50.04239], [96.97388, 49.88413], [97.24639, 49.74737], [97.56811, 49.84265], [97.56432, 49.92801], [97.76871, 49.99861], [97.85197, 49.91339], [98.29481, 50.33561], [98.31373, 50.4996], [98.06393, 50.61262], [97.9693, 50.78044], [98.01472, 50.86652], [97.83305, 51.00248], [98.05257, 51.46696], [98.22053, 51.46579], [98.33222, 51.71832], [98.74142, 51.8637], [98.87768, 52.14563], [99.27888, 51.96876], [99.75578, 51.90108], [99.89203, 51.74903], [100.61116, 51.73028], [101.39085, 51.45753], [101.5044, 51.50467], [102.14032, 51.35566], [102.32194, 50.67982], [102.71178, 50.38873], [103.70343, 50.13952], [105.32528, 50.4648], [106.05562, 50.40582], [106.07865, 50.33474], [106.47156, 50.31909], [106.49628, 50.32436], [106.51122, 50.34408], [106.58373, 50.34044], [106.80326, 50.30177], [107.00007, 50.1977], [107.1174, 50.04239], [107.36407, 49.97612], [107.96116, 49.93191], [107.95387, 49.66659], [108.27937, 49.53167], [108.53969, 49.32325], [109.18017, 49.34709], [109.51325, 49.22859], [110.24373, 49.16676], [110.39891, 49.25083], [110.64493, 49.1816], [113.02647, 49.60772], [113.20216, 49.83356], [114.325, 50.28098], [114.9703, 50.19254], [115.26068, 49.97367], [115.73602, 49.87688], [116.22402, 50.04477], [116.62502, 49.92919], [116.71193, 49.83813], [117.27597, 49.62544], [117.48208, 49.62324], [117.82343, 49.52696], [118.61623, 49.93809], [119.11003, 50.00276], [119.27996, 50.13348], [119.38598, 50.35162], [119.13553, 50.37412], [120.10963, 51.671], [120.65907, 51.93544], [120.77337, 52.20805], [120.61346, 52.32447], [120.71673, 52.54099], [120.46454, 52.63811], [120.04049, 52.58773], [120.0451, 52.7359], [120.85633, 53.28499], [121.39213, 53.31888], [122.35063, 53.49565], [122.85966, 53.47395], [123.26989, 53.54843], [123.86158, 53.49391], [124.46078, 53.21881], [125.17522, 53.20225], [125.6131, 53.07229], [126.558, 52.13738], [126.44606, 51.98254], [126.68349, 51.70607], [126.90369, 51.3238], [126.93135, 51.0841], [127.14586, 50.91152], [127.28165, 50.72075], [127.36335, 50.58306], [127.28765, 50.46585], [127.36009, 50.43787], [127.37384, 50.28393], [127.60515, 50.23503], [127.49299, 50.01251], [127.53516, 49.84306], [127.83476, 49.5748], [128.72896, 49.58676], [129.11153, 49.36813], [129.23232, 49.40353], [129.35317, 49.3481], [129.40398, 49.44194], [129.50685, 49.42398], [129.67598, 49.29596], [129.85416, 49.11067], [130.2355, 48.86741], [130.43232, 48.90844], [130.66946, 48.88251], [130.52147, 48.61745], [130.84462, 48.30942], [130.65103, 48.10052], [130.90915, 47.90623], [130.95985, 47.6957], [131.09871, 47.6852], [131.2635, 47.73325], [131.90448, 47.68011], [132.57309, 47.71741], [132.66989, 47.96491], [134.49516, 48.42884], [134.75328, 48.36763], [134.67098, 48.1564], [134.55508, 47.98651], [134.7671, 47.72051], [134.50898, 47.4812], [134.20016, 47.33458], [134.03538, 46.75668], [133.84104, 46.46681], [133.91496, 46.4274], [133.88097, 46.25066], [133.68047, 46.14697], [133.72695, 46.05576], [133.67569, 45.9759], [133.60442, 45.90053], [133.48457, 45.86203], [133.41083, 45.57723], [133.19419, 45.51913], [133.09279, 45.25693], [133.12293, 45.1332], [132.96373, 45.0212], [132.83978, 45.05916], [131.99417, 45.2567], [131.86903, 45.33636], [131.76532, 45.22609], [131.66852, 45.2196], [131.68466, 45.12374], [131.48415, 44.99513], [130.95639, 44.85154], [131.1108, 44.70266], [131.30365, 44.04262], [131.25484, 44.03131], [131.23583, 43.96085], [131.26176, 43.94011], [131.21105, 43.82383], [131.19492, 43.53047], [131.29402, 43.46695], [131.30324, 43.39498], [131.19031, 43.21385], [131.20414, 43.13654], [131.10274, 43.04734], [131.135, 42.94114], [131.02668, 42.91246], [131.02438, 42.86518], [130.66524, 42.84753], [130.44361, 42.76205], [130.40213, 42.70788], [130.56576, 42.68925], [130.62107, 42.58413], [130.55143, 42.52158], [130.56835, 42.43281], [130.60805, 42.4317], [130.64181, 42.41422], [130.66367, 42.38024], [130.65022, 42.32281], [131.95041, 41.5445], [140.9182, 45.92937], [145.82343, 44.571], [145.23667, 43.76813], [153.94307, 38.42848], [180, 62.52334], [180, 71.53642], [155.31937, 81.93282], [76.13964, 83.37843], [64.18965, 69.94255], [66.1708, 67.61252], [61.98014, 65.72191], [60.74386, 64.95767], [59.63945, 64.78384], [59.80579, 64.13948], [59.24834, 63.01859], [59.61398, 62.44915], [59.36223, 61.3882], [59.50685, 60.91162], [58.3853, 59.487], [59.15636, 59.14682], [59.40376, 58.45822], [58.71104, 58.07475], [58.81412, 57.71602], [58.13789, 57.68097], [58.07604, 57.08308], [57.28024, 56.87898], [57.51527, 56.08729], [59.28419, 56.15739], [59.49035, 55.60486], [58.81825, 55.03378], [57.25137, 55.26262], [57.14829, 54.84204], [57.95234, 54.39672], [59.95217, 54.85853], [59.70487, 54.14846], [58.94336, 53.953], [58.79644, 52.43392], [59.22409, 52.28437], [59.25033, 52.46803], [60.17516, 52.39457], [60.17253, 52.25814], [59.91279, 52.06924], [59.99809, 51.98263]]]] } },
28893     { type: "Feature", properties: { wikidata: "Q34366", nameEn: "Tasmania", aliases: ["AU-TAS"], country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[123.64533, -39.13605], [159.69067, -56.28945], [159.74028, -39.1978], [123.64533, -39.13605]]]] } },
28894     { type: "Feature", properties: { wikidata: "Q34497", nameEn: "Saint Helena", aliases: ["SH-HL"], country: "GB", groups: ["SH", "BOTS", "011", "202", "002", "UN"], level: "subterritory", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["290"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-8.3824, -13.9131], [-6.17428, -19.07236], [-3.29308, -15.22647], [-8.3824, -13.9131]]]] } },
28895     { type: "Feature", properties: { wikidata: "Q35657", nameEn: "US States", country: "US", level: "subcountryGroup" }, geometry: null },
28896     { type: "Feature", properties: { wikidata: "Q36117", nameEn: "Borneo", level: "sharedLandform" }, geometry: null },
28897     { type: "Feature", properties: { wikidata: "Q36678", nameEn: "West Bank", country: "PS", groups: ["145", "142"], callingCodes: ["970"] }, geometry: { type: "MultiPolygon", coordinates: [[[[35.47672, 31.49578], [35.55941, 31.76535], [35.52758, 31.9131], [35.54375, 31.96587], [35.52012, 32.04076], [35.57111, 32.21877], [35.55807, 32.38674], [35.42078, 32.41562], [35.41048, 32.43706], [35.41598, 32.45593], [35.42034, 32.46009], [35.40224, 32.50136], [35.35212, 32.52047], [35.30685, 32.51024], [35.29306, 32.50947], [35.25049, 32.52453], [35.2244, 32.55289], [35.15937, 32.50466], [35.10882, 32.4757], [35.10024, 32.47856], [35.09236, 32.47614], [35.08564, 32.46948], [35.07059, 32.4585], [35.05423, 32.41754], [35.05311, 32.4024], [35.0421, 32.38242], [35.05142, 32.3667], [35.04243, 32.35008], [35.01772, 32.33863], [35.01119, 32.28684], [35.02939, 32.2671], [35.01841, 32.23981], [34.98885, 32.20758], [34.95703, 32.19522], [34.96009, 32.17503], [34.99039, 32.14626], [34.98507, 32.12606], [34.99437, 32.10962], [34.9863, 32.09551], [35.00261, 32.027], [34.98682, 31.96935], [35.00124, 31.93264], [35.03489, 31.92448], [35.03978, 31.89276], [35.03489, 31.85919], [34.99712, 31.85569], [34.9724, 31.83352], [35.01978, 31.82944], [35.05617, 31.85685], [35.07677, 31.85627], [35.14174, 31.81325], [35.18603, 31.80901], [35.18169, 31.82542], [35.19461, 31.82687], [35.21469, 31.81835], [35.216, 31.83894], [35.21128, 31.863], [35.20381, 31.86716], [35.20673, 31.88151], [35.20791, 31.8821], [35.20945, 31.8815], [35.21016, 31.88237], [35.21276, 31.88153], [35.2136, 31.88241], [35.22014, 31.88264], [35.22294, 31.87889], [35.22567, 31.86745], [35.22817, 31.8638], [35.2249, 31.85433], [35.2304, 31.84222], [35.24816, 31.8458], [35.25753, 31.8387], [35.251, 31.83085], [35.26404, 31.82567], [35.25573, 31.81362], [35.26058, 31.79064], [35.25225, 31.7678], [35.26319, 31.74846], [35.25182, 31.73945], [35.24981, 31.72543], [35.2438, 31.7201], [35.24315, 31.71244], [35.23972, 31.70896], [35.22392, 31.71899], [35.21937, 31.71578], [35.20538, 31.72388], [35.18023, 31.72067], [35.16478, 31.73242], [35.15474, 31.73352], [35.15119, 31.73634], [35.13931, 31.73012], [35.12933, 31.7325], [35.11895, 31.71454], [35.10782, 31.71594], [35.08226, 31.69107], [35.00879, 31.65426], [34.95249, 31.59813], [34.9415, 31.55601], [34.94356, 31.50743], [34.93258, 31.47816], [34.89756, 31.43891], [34.87833, 31.39321], [34.88932, 31.37093], [34.92571, 31.34337], [35.02459, 31.35979], [35.13033, 31.3551], [35.22921, 31.37445], [35.39675, 31.49572], [35.47672, 31.49578]]]] } },
28898     { type: "Feature", properties: { wikidata: "Q37362", nameEn: "Akrotiri and Dhekelia", aliases: ["SBA"], country: "GB" }, geometry: null },
28899     { type: "Feature", properties: { wikidata: "Q38095", nameEn: "Gal\xE1pagos Islands", aliases: ["EC-W"], country: "EC", groups: ["005", "419", "019", "UN"], callingCodes: ["593"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-93.12365, 2.64343], [-92.46744, -2.52874], [-87.07749, -0.8849], [-93.12365, 2.64343]]]] } },
28900     { type: "Feature", properties: { wikidata: "Q39760", nameEn: "Gaza Strip", country: "PS", groups: ["145", "142"], callingCodes: ["970"] }, geometry: { type: "MultiPolygon", coordinates: [[[[34.052, 31.46619], [34.21853, 31.32363], [34.23572, 31.2966], [34.24012, 31.29591], [34.26742, 31.21998], [34.29417, 31.24194], [34.36523, 31.28963], [34.37381, 31.30598], [34.36505, 31.36404], [34.40077, 31.40926], [34.48892, 31.48365], [34.56797, 31.54197], [34.48681, 31.59711], [34.29262, 31.70393], [34.052, 31.46619]]]] } },
28901     { type: "Feature", properties: { wikidata: "Q40888", nameEn: "Andaman and Nicobar Islands", aliases: ["IN-AN"], country: "IN", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["91"] }, geometry: { type: "MultiPolygon", coordinates: [[[[94.42132, 5.96581], [94.6371, 13.81803], [86.7822, 13.41052], [94.42132, 5.96581]]]] } },
28902     { type: "Feature", properties: { wikidata: "Q41684", nameEn: "Stewart Island", country: "NZ", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[166.59185, -47.61313], [169.70504, -47.56021], [167.52103, -46.41337], [166.59185, -47.61313]]]] } },
28903     { type: "Feature", properties: { wikidata: "Q43296", nameEn: "Wake Island", aliases: ["WK", "WAK", "WKUM", "872", "UM-79"], country: "US", groups: ["UM", "Q1352230", "057", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[167.34779, 18.97692], [166.67967, 20.14834], [165.82549, 18.97692], [167.34779, 18.97692]]]] } },
28904     { type: "Feature", properties: { wikidata: "Q46275", nameEn: "New Zealand Subantarctic Islands", country: "NZ", groups: ["Q851132", "053", "009", "UN"], driveSide: "left" }, geometry: { type: "MultiPolygon", coordinates: [[[[164.30551, -47.88072], [161.96603, -56.07661], [179.49541, -50.04657], [179.49541, -47.2902], [169.91032, -47.66283], [164.30551, -47.88072]]]] } },
28905     { type: "Feature", properties: { wikidata: "Q46395", nameEn: "British Overseas Territories", aliases: ["BOTS", "UKOTS"], country: "GB", level: "subcountryGroup" }, geometry: null },
28906     { type: "Feature", properties: { wikidata: "Q46772", nameEn: "Kerguelen Islands", country: "FR", groups: ["EU", "TF", "Q1451600", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[61.9216, -49.39746], [70.67507, -51.14192], [74.25129, -45.45074], [61.9216, -49.39746]]]] } },
28907     { type: "Feature", properties: { wikidata: "Q46879", nameEn: "Baker Island", aliases: ["UM-81"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft" }, geometry: { type: "MultiPolygon", coordinates: [[[[-175.33482, -1.40631], [-175.31323, 0.5442], [-177.91421, 0.39582], [-175.33482, -1.40631]]]] } },
28908     { type: "Feature", properties: { wikidata: "Q47863", nameEn: "Midway Atoll", aliases: ["MI", "MID", "MIUM", "488", "UM-71"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-176.29741, 29.09786], [-177.77531, 29.29793], [-177.5224, 27.7635], [-176.29741, 29.09786]]]] } },
28909     { type: "Feature", properties: { wikidata: "Q62218", nameEn: "Jarvis Island", aliases: ["UM-86"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft" }, geometry: { type: "MultiPolygon", coordinates: [[[[-160.42921, -1.4364], [-159.12443, 0.19975], [-160.38779, 0.30331], [-160.42921, -1.4364]]]] } },
28910     { type: "Feature", properties: { wikidata: "Q105472", nameEn: "Macaronesia", level: "sharedLandform" }, geometry: null },
28911     { type: "Feature", properties: { wikidata: "Q114935", nameEn: "Kermadec Islands", country: "NZ", groups: ["Q851132", "053", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-174.40891, -29.09438], [-180, -24.21376], [-179.96512, -35.00791], [-174.40891, -29.09438]]]] } },
28912     { type: "Feature", properties: { wikidata: "Q115459", nameEn: "Chatham Islands", aliases: ["NZ-CIT"], country: "NZ", groups: ["Q851132", "053", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-179.93224, -45.18423], [-172.47015, -45.17912], [-176.30998, -41.38382], [-179.93224, -45.18423]]]] } },
28913     { type: "Feature", properties: { wikidata: "Q118863", nameEn: "North Island", country: "NZ", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[179.49541, -47.2902], [179.49541, -36.79303], [174.17679, -32.62487], [170.27492, -36.38133], [174.58663, -40.80446], [174.46634, -41.55028], [179.49541, -47.2902]]]] } },
28914     { type: "Feature", properties: { wikidata: "Q120755", nameEn: "South Island", country: "NZ", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[169.70504, -47.56021], [179.49541, -47.2902], [174.46634, -41.55028], [174.58663, -40.80446], [170.27492, -36.38133], [166.56976, -39.94841], [164.8365, -46.0205], [167.52103, -46.41337], [169.70504, -47.56021]]]] } },
28915     { type: "Feature", properties: { wikidata: "Q123076", nameEn: "Palmyra Atoll", aliases: ["UM-95"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-161.06795, 5.2462], [-161.0731, 7.1291], [-163.24478, 5.24198], [-161.06795, 5.2462]]]] } },
28916     { type: "Feature", properties: { wikidata: "Q130574", nameEn: "Chafarinas Islands", country: "ES", groups: ["EU", "Q191011", "015", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.40316, 35.16893], [-2.43262, 35.20652], [-2.45965, 35.16527], [-2.40316, 35.16893]]]] } },
28917     { type: "Feature", properties: { wikidata: "Q130895", nameEn: "Kingman Reef", aliases: ["UM-89"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft" }, geometry: { type: "MultiPolygon", coordinates: [[[[-161.0731, 7.1291], [-163.16627, 7.15036], [-163.24478, 5.24198], [-161.0731, 7.1291]]]] } },
28918     { type: "Feature", properties: { wikidata: "Q131008", nameEn: "Johnston Atoll", aliases: ["JT", "JTN", "JTUM", "396", "UM-67"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-170.65691, 16.57199], [-168.87689, 16.01159], [-169.2329, 17.4933], [-170.65691, 16.57199]]]] } },
28919     { type: "Feature", properties: { wikidata: "Q131305", nameEn: "Howland Island", aliases: ["UM-84"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft" }, geometry: { type: "MultiPolygon", coordinates: [[[[-177.91421, 0.39582], [-175.31323, 0.5442], [-176.74464, 2.28109], [-177.91421, 0.39582]]]] } },
28920     { type: "Feature", properties: { wikidata: "Q133888", nameEn: "Ashmore and Cartier Islands", country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[123.7463, -11.1783], [120.6877, -13.59408], [125.29076, -12.33139], [123.7463, -11.1783]]]] } },
28921     { type: "Feature", properties: { wikidata: "Q153732", nameEn: "Mariana Islands", level: "sharedLandform" }, geometry: null },
28922     { type: "Feature", properties: { wikidata: "Q172216", nameEn: "Coral Sea Islands", country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[159.77159, -28.41151], [156.73836, -14.50464], [145.2855, -9.62524], [147.69992, -17.5933], [152.93188, -20.92631], [154.02855, -24.43238], [159.77159, -28.41151]]]] } },
28923     { type: "Feature", properties: { wikidata: "Q179313", nameEn: "Alderney", country: "GB", groups: ["GG", "830", "Q185086", "154", "150", "UN"], level: "subterritory", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44 01481"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.36485, 49.48223], [-2.09454, 49.46288], [-2.02963, 49.91866], [-2.49556, 49.79012], [-2.36485, 49.48223]]]] } },
28924     { type: "Feature", properties: { wikidata: "Q185086", nameEn: "Crown Dependencies", country: "GB", level: "subcountryGroup" }, geometry: null },
28925     { type: "Feature", properties: { wikidata: "Q190571", nameEn: "Scattered Islands", country: "FR", groups: ["EU", "TF", "Q1451600", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[53.53458, -16.36909], [54.96649, -16.28353], [54.61476, -15.02273], [53.53458, -16.36909]]], [[[38.55969, -20.75596], [40.68027, -23.38889], [43.52893, -15.62903], [38.55969, -20.75596]]], [[[47.03092, -11.05648], [47.11593, -12.08552], [47.96702, -11.46447], [47.03092, -11.05648]]]] } },
28926     { type: "Feature", properties: { wikidata: "Q191011", nameEn: "Plazas de soberan\xEDa", country: "ES" }, geometry: null },
28927     { type: "Feature", properties: { wikidata: "Q191146", nameEn: "Pe\xF1\xF3n de V\xE9lez de la Gomera", country: "ES", groups: ["EU", "Q191011", "015", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[-4.30191, 35.17419], [-4.30112, 35.17058], [-4.29436, 35.17149], [-4.30191, 35.17419]]]] } },
28928     { type: "Feature", properties: { wikidata: "Q201698", nameEn: "Crozet Islands", country: "FR", groups: ["EU", "TF", "Q1451600", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[55.03425, -43.65017], [46.31615, -46.28749], [54.5587, -47.93013], [55.03425, -43.65017]]]] } },
28929     { type: "Feature", properties: { wikidata: "Q578170", nameEn: "Contiguous United States", aliases: ["CONUS"], country: "US", groups: ["Q35657", "021", "003", "019", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-97.13927, 25.96583], [-96.92418, 25.97377], [-80.57035, 24.0565], [-78.91214, 27.76553], [-61.98255, 37.34815], [-67.16117, 44.20069], [-66.93432, 44.82597], [-66.96824, 44.83078], [-66.98249, 44.87071], [-66.96824, 44.90965], [-67.0216, 44.95333], [-67.11316, 45.11176], [-67.15965, 45.16179], [-67.19603, 45.16771], [-67.20349, 45.1722], [-67.22751, 45.16344], [-67.27039, 45.1934], [-67.29748, 45.18173], [-67.29754, 45.14865], [-67.34927, 45.122], [-67.48201, 45.27351], [-67.42394, 45.37969], [-67.50578, 45.48971], [-67.42144, 45.50584], [-67.43815, 45.59162], [-67.6049, 45.60725], [-67.80705, 45.69528], [-67.80653, 45.80022], [-67.75654, 45.82324], [-67.80961, 45.87531], [-67.75196, 45.91814], [-67.78111, 45.9392], [-67.78578, 47.06473], [-67.87993, 47.10377], [-67.94843, 47.1925], [-68.23244, 47.35712], [-68.37458, 47.35851], [-68.38332, 47.28723], [-68.57914, 47.28431], [-68.60575, 47.24659], [-68.70125, 47.24399], [-68.89222, 47.1807], [-69.05039, 47.2456], [-69.05073, 47.30076], [-69.05148, 47.42012], [-69.22119, 47.46461], [-69.99966, 46.69543], [-70.05812, 46.41768], [-70.18547, 46.35357], [-70.29078, 46.18832], [-70.23855, 46.1453], [-70.31025, 45.96424], [-70.24694, 45.95138], [-70.25976, 45.89675], [-70.41523, 45.79497], [-70.38934, 45.73215], [-70.54019, 45.67291], [-70.68516, 45.56964], [-70.72651, 45.49771], [-70.62518, 45.42286], [-70.65383, 45.37592], [-70.78372, 45.43269], [-70.82638, 45.39828], [-70.80236, 45.37444], [-70.84816, 45.22698], [-70.89864, 45.2398], [-70.91169, 45.29849], [-70.95193, 45.33895], [-71.0107, 45.34819], [-71.01866, 45.31573], [-71.08364, 45.30623], [-71.14568, 45.24128], [-71.19723, 45.25438], [-71.22338, 45.25184], [-71.29371, 45.29996], [-71.37133, 45.24624], [-71.44252, 45.2361], [-71.40364, 45.21382], [-71.42778, 45.12624], [-71.48735, 45.07784], [-71.50067, 45.01357], [-73.35025, 45.00942], [-74.32699, 44.99029], [-74.66689, 45.00646], [-74.8447, 45.00606], [-74.99101, 44.98051], [-75.01363, 44.95608], [-75.2193, 44.87821], [-75.41441, 44.76614], [-75.76813, 44.51537], [-75.8217, 44.43176], [-75.95947, 44.34463], [-76.00018, 44.34896], [-76.16285, 44.28262], [-76.1664, 44.23051], [-76.244, 44.19643], [-76.31222, 44.19894], [-76.35324, 44.13493], [-76.43859, 44.09393], [-76.79706, 43.63099], [-79.25796, 43.54052], [-79.06921, 43.26183], [-79.05512, 43.25375], [-79.05544, 43.21224], [-79.05002, 43.20133], [-79.05384, 43.17418], [-79.04652, 43.16396], [-79.0427, 43.13934], [-79.06881, 43.12029], [-79.05671, 43.10937], [-79.07486, 43.07845], [-79.01055, 43.06659], [-78.99941, 43.05612], [-79.02424, 43.01983], [-79.02074, 42.98444], [-78.98126, 42.97], [-78.96312, 42.95509], [-78.93224, 42.95229], [-78.90905, 42.93022], [-78.90712, 42.89733], [-78.93684, 42.82887], [-82.67862, 41.67615], [-83.11184, 41.95671], [-83.14962, 42.04089], [-83.12724, 42.2376], [-83.09837, 42.28877], [-83.07837, 42.30978], [-83.02253, 42.33045], [-82.82964, 42.37355], [-82.64242, 42.55594], [-82.58873, 42.54984], [-82.57583, 42.5718], [-82.51858, 42.611], [-82.51063, 42.66025], [-82.46613, 42.76615], [-82.4826, 42.8068], [-82.45331, 42.93139], [-82.4253, 42.95423], [-82.4146, 42.97626], [-82.42469, 42.992], [-82.48419, 45.30225], [-83.59589, 45.82131], [-83.43746, 45.99749], [-83.57017, 46.105], [-83.83329, 46.12169], [-83.90453, 46.05922], [-83.95399, 46.05634], [-84.1096, 46.23987], [-84.09756, 46.25512], [-84.11615, 46.2681], [-84.11254, 46.32329], [-84.13451, 46.39218], [-84.11196, 46.50248], [-84.12885, 46.53068], [-84.17723, 46.52753], [-84.1945, 46.54061], [-84.2264, 46.53337], [-84.26351, 46.49508], [-84.29893, 46.49127], [-84.34174, 46.50683], [-84.42101, 46.49853], [-84.4481, 46.48972], [-84.47607, 46.45225], [-84.55635, 46.45974], [-84.85871, 46.88881], [-88.37033, 48.30586], [-89.48837, 48.01412], [-89.57972, 48.00023], [-89.77248, 48.02607], [-89.89974, 47.98109], [-90.07418, 48.11043], [-90.56312, 48.09488], [-90.56444, 48.12184], [-90.75045, 48.09143], [-90.87588, 48.2484], [-91.08016, 48.18096], [-91.25025, 48.08522], [-91.43248, 48.04912], [-91.45829, 48.07454], [-91.58025, 48.04339], [-91.55649, 48.10611], [-91.70451, 48.11805], [-91.71231, 48.19875], [-91.86125, 48.21278], [-91.98929, 48.25409], [-92.05339, 48.35958], [-92.14732, 48.36578], [-92.202, 48.35252], [-92.26662, 48.35651], [-92.30939, 48.31251], [-92.27167, 48.25046], [-92.37185, 48.22259], [-92.48147, 48.36609], [-92.45588, 48.40624], [-92.50712, 48.44921], [-92.65606, 48.43471], [-92.71323, 48.46081], [-92.69927, 48.49573], [-92.62747, 48.50278], [-92.6342, 48.54133], [-92.7287, 48.54005], [-92.94973, 48.60866], [-93.25391, 48.64266], [-93.33946, 48.62787], [-93.3712, 48.60599], [-93.39758, 48.60364], [-93.40693, 48.60948], [-93.44472, 48.59147], [-93.47022, 48.54357], [-93.66382, 48.51845], [-93.79267, 48.51631], [-93.80939, 48.52439], [-93.80676, 48.58232], [-93.83288, 48.62745], [-93.85769, 48.63284], [-94.23215, 48.65202], [-94.25104, 48.65729], [-94.25172, 48.68404], [-94.27153, 48.70232], [-94.4174, 48.71049], [-94.44258, 48.69223], [-94.53826, 48.70216], [-94.54885, 48.71543], [-94.58903, 48.71803], [-94.69335, 48.77883], [-94.69669, 48.80918], [-94.70486, 48.82365], [-94.70087, 48.8339], [-94.687, 48.84077], [-94.75017, 49.09931], [-94.77355, 49.11998], [-94.82487, 49.29483], [-94.8159, 49.32299], [-94.85381, 49.32492], [-94.95681, 49.37035], [-94.99532, 49.36579], [-95.01419, 49.35647], [-95.05825, 49.35311], [-95.12903, 49.37056], [-95.15357, 49.384], [-95.15355, 48.9996], [-123.32163, 49.00419], [-123.0093, 48.83186], [-123.0093, 48.76586], [-123.26565, 48.6959], [-123.15614, 48.35395], [-123.50039, 48.21223], [-125.03842, 48.53282], [-133.98258, 38.06389], [-118.48109, 32.5991], [-117.1243, 32.53427], [-115.88053, 32.63624], [-114.71871, 32.71894], [-114.76736, 32.64094], [-114.80584, 32.62028], [-114.81141, 32.55543], [-114.79524, 32.55731], [-114.82011, 32.49609], [-111.07523, 31.33232], [-108.20979, 31.33316], [-108.20899, 31.78534], [-106.529, 31.784], [-106.52266, 31.77509], [-106.51251, 31.76922], [-106.50962, 31.76155], [-106.50111, 31.75714], [-106.48815, 31.74769], [-106.47298, 31.75054], [-106.46726, 31.75998], [-106.45244, 31.76523], [-106.43419, 31.75478], [-106.41773, 31.75196], [-106.38003, 31.73151], [-106.3718, 31.71165], [-106.34864, 31.69663], [-106.33419, 31.66303], [-106.30305, 31.62154], [-106.28084, 31.56173], [-106.24612, 31.54193], [-106.23711, 31.51262], [-106.20346, 31.46305], [-106.09025, 31.40569], [-106.00363, 31.39181], [-104.77674, 30.4236], [-104.5171, 29.64671], [-104.3969, 29.57105], [-104.39363, 29.55396], [-104.37752, 29.54255], [-103.15787, 28.93865], [-102.60596, 29.8192], [-101.47277, 29.7744], [-101.05686, 29.44738], [-101.01128, 29.36947], [-100.96725, 29.3477], [-100.94579, 29.34523], [-100.94056, 29.33371], [-100.87982, 29.296], [-100.79696, 29.24688], [-100.67294, 29.09744], [-100.63689, 28.90812], [-100.59809, 28.88197], [-100.52313, 28.75598], [-100.5075, 28.74066], [-100.51222, 28.70679], [-100.50029, 28.66117], [-99.55409, 27.61314], [-99.51478, 27.55836], [-99.52955, 27.49747], [-99.50208, 27.50021], [-99.48045, 27.49016], [-99.482, 27.47128], [-99.49744, 27.43746], [-99.53573, 27.30926], [-99.08477, 26.39849], [-99.03053, 26.41249], [-99.00546, 26.3925], [-98.35126, 26.15129], [-98.30491, 26.10475], [-98.27075, 26.09457], [-98.24603, 26.07191], [-97.97017, 26.05232], [-97.95155, 26.0625], [-97.66511, 26.01708], [-97.52025, 25.88518], [-97.49828, 25.89877], [-97.45669, 25.86874], [-97.42511, 25.83969], [-97.37332, 25.83854], [-97.35946, 25.92189], [-97.13927, 25.96583]]]] } },
28930     { type: "Feature", properties: { wikidata: "Q620634", nameEn: "Bir Tawil", groups: ["015", "002"], level: "territory" }, geometry: { type: "MultiPolygon", coordinates: [[[[33.17563, 22.00405], [33.57251, 21.72406], [33.99686, 21.76784], [34.0765, 22.00501], [33.17563, 22.00405]]]] } },
28931     { type: "Feature", properties: { wikidata: "Q639185", nameEn: "Peros Banhos", country: "GB", groups: ["IO", "BOTS", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[72.12587, -4.02588], [70.1848, -6.37445], [72.09518, -5.61768], [72.12587, -4.02588]]]] } },
28932     { type: "Feature", properties: { wikidata: "Q644636", nameEn: "Cyprus", level: "sharedLandform" }, geometry: null },
28933     { type: "Feature", properties: { wikidata: "Q851132", nameEn: "New Zealand Outlying Islands", country: "NZ", level: "subcountryGroup" }, geometry: null },
28934     { type: "Feature", properties: { wikidata: "Q875134", nameEn: "European Russia", country: "RU", groups: ["151", "150", "UN"], callingCodes: ["7"] }, geometry: { type: "MultiPolygon", coordinates: [[[[18.57853, 55.25302], [19.64312, 54.45423], [19.8038, 54.44203], [20.63871, 54.3706], [21.41123, 54.32395], [22.79705, 54.36264], [22.7253, 54.41732], [22.70208, 54.45312], [22.67788, 54.532], [22.71293, 54.56454], [22.68021, 54.58486], [22.7522, 54.63525], [22.74225, 54.64339], [22.75467, 54.6483], [22.73397, 54.66604], [22.73631, 54.72952], [22.87317, 54.79492], [22.85083, 54.88711], [22.76422, 54.92521], [22.68723, 54.9811], [22.65451, 54.97037], [22.60075, 55.01863], [22.58907, 55.07085], [22.47688, 55.04408], [22.31562, 55.0655], [22.14267, 55.05345], [22.11697, 55.02131], [22.06087, 55.02935], [22.02582, 55.05078], [22.03984, 55.07888], [21.99543, 55.08691], [21.96505, 55.07353], [21.85521, 55.09493], [21.64954, 55.1791], [21.55605, 55.20311], [21.51095, 55.18507], [21.46766, 55.21115], [21.38446, 55.29348], [21.35465, 55.28427], [21.26425, 55.24456], [20.95181, 55.27994], [20.60454, 55.40986], [18.57853, 55.25302]]], [[[26.32936, 60.00121], [26.90044, 59.63819], [27.85643, 59.58538], [28.04187, 59.47017], [28.19061, 59.39962], [28.21137, 59.38058], [28.20537, 59.36491], [28.19284, 59.35791], [28.14215, 59.28934], [28.00689, 59.28351], [27.90911, 59.24353], [27.87978, 59.18097], [27.80482, 59.1116], [27.74429, 58.98351], [27.36366, 58.78381], [27.55489, 58.39525], [27.48541, 58.22615], [27.62393, 58.09462], [27.67282, 57.92627], [27.81841, 57.89244], [27.78526, 57.83963], [27.56689, 57.83356], [27.50171, 57.78842], [27.52615, 57.72843], [27.3746, 57.66834], [27.40393, 57.62125], [27.31919, 57.57672], [27.34698, 57.52242], [27.56832, 57.53728], [27.52453, 57.42826], [27.86101, 57.29402], [27.66511, 56.83921], [27.86101, 56.88204], [28.04768, 56.59004], [28.13526, 56.57989], [28.10069, 56.524], [28.19057, 56.44637], [28.16599, 56.37806], [28.23716, 56.27588], [28.15217, 56.16964], [28.30571, 56.06035], [28.36888, 56.05805], [28.37987, 56.11399], [28.43068, 56.09407], [28.5529, 56.11705], [28.68337, 56.10173], [28.63668, 56.07262], [28.73418, 55.97131], [29.08299, 56.03427], [29.21717, 55.98971], [29.44692, 55.95978], [29.3604, 55.75862], [29.51283, 55.70294], [29.61446, 55.77716], [29.80672, 55.79569], [29.97975, 55.87281], [30.12136, 55.8358], [30.27776, 55.86819], [30.30987, 55.83592], [30.48257, 55.81066], [30.51346, 55.78982], [30.51037, 55.76568], [30.63344, 55.73079], [30.67464, 55.64176], [30.72957, 55.66268], [30.7845, 55.58514], [30.86003, 55.63169], [30.93419, 55.6185], [30.95204, 55.50667], [30.90123, 55.46621], [30.93144, 55.3914], [30.8257, 55.3313], [30.81946, 55.27931], [30.87944, 55.28223], [30.97369, 55.17134], [31.02071, 55.06167], [31.00972, 55.02783], [30.94243, 55.03964], [30.9081, 55.02232], [30.95754, 54.98609], [30.93144, 54.9585], [30.81759, 54.94064], [30.8264, 54.90062], [30.75165, 54.80699], [30.95479, 54.74346], [30.97127, 54.71967], [31.0262, 54.70698], [30.98226, 54.68872], [30.99187, 54.67046], [31.19339, 54.66947], [31.21399, 54.63113], [31.08543, 54.50361], [31.22945, 54.46585], [31.3177, 54.34067], [31.30791, 54.25315], [31.57002, 54.14535], [31.89599, 54.0837], [31.88744, 54.03653], [31.85019, 53.91801], [31.77028, 53.80015], [31.89137, 53.78099], [32.12621, 53.81586], [32.36663, 53.7166], [32.45717, 53.74039], [32.50112, 53.68594], [32.40499, 53.6656], [32.47777, 53.5548], [32.74968, 53.45597], [32.73257, 53.33494], [32.51725, 53.28431], [32.40773, 53.18856], [32.15368, 53.07594], [31.82373, 53.10042], [31.787, 53.18033], [31.62496, 53.22886], [31.56316, 53.19432], [31.40523, 53.21406], [31.36403, 53.13504], [31.3915, 53.09712], [31.33519, 53.08805], [31.32283, 53.04101], [31.24147, 53.031], [31.35667, 52.97854], [31.592, 52.79011], [31.57277, 52.71613], [31.50406, 52.69707], [31.63869, 52.55361], [31.56316, 52.51518], [31.61397, 52.48843], [31.62084, 52.33849], [31.57971, 52.32146], [31.70735, 52.26711], [31.6895, 52.1973], [31.77877, 52.18636], [31.7822, 52.11406], [31.81722, 52.09955], [31.85018, 52.11305], [31.96141, 52.08015], [31.92159, 52.05144], [32.08813, 52.03319], [32.23331, 52.08085], [32.2777, 52.10266], [32.34044, 52.1434], [32.33083, 52.23685], [32.38988, 52.24946], [32.3528, 52.32842], [32.54781, 52.32423], [32.69475, 52.25535], [32.85405, 52.27888], [32.89937, 52.2461], [33.18913, 52.3754], [33.51323, 52.35779], [33.48027, 52.31499], [33.55718, 52.30324], [33.78789, 52.37204], [34.05239, 52.20132], [34.11199, 52.14087], [34.09413, 52.00835], [34.41136, 51.82793], [34.42922, 51.72852], [34.07765, 51.67065], [34.17599, 51.63253], [34.30562, 51.5205], [34.22048, 51.4187], [34.33446, 51.363], [34.23009, 51.26429], [34.31661, 51.23936], [34.38802, 51.2746], [34.6613, 51.25053], [34.6874, 51.18], [34.82472, 51.17483], [34.97304, 51.2342], [35.14058, 51.23162], [35.12685, 51.16191], [35.20375, 51.04723], [35.31774, 51.08434], [35.40837, 51.04119], [35.32598, 50.94524], [35.39307, 50.92145], [35.41367, 50.80227], [35.47704, 50.77274], [35.48116, 50.66405], [35.39464, 50.64751], [35.47463, 50.49247], [35.58003, 50.45117], [35.61711, 50.35707], [35.73659, 50.35489], [35.80388, 50.41356], [35.8926, 50.43829], [36.06893, 50.45205], [36.20763, 50.3943], [36.30101, 50.29088], [36.47817, 50.31457], [36.58371, 50.28563], [36.56655, 50.2413], [36.64571, 50.218], [36.69377, 50.26982], [36.91762, 50.34963], [37.08468, 50.34935], [37.48204, 50.46079], [37.47243, 50.36277], [37.62486, 50.29966], [37.62879, 50.24481], [37.61113, 50.21976], [37.75807, 50.07896], [37.79515, 50.08425], [37.90776, 50.04194], [38.02999, 49.94482], [38.02999, 49.90592], [38.21675, 49.98104], [38.18517, 50.08161], [38.32524, 50.08866], [38.35408, 50.00664], [38.65688, 49.97176], [38.68677, 50.00904], [38.73311, 49.90238], [38.90477, 49.86787], [38.9391, 49.79524], [39.1808, 49.88911], [39.27968, 49.75976], [39.44496, 49.76067], [39.59142, 49.73758], [39.65047, 49.61761], [39.84548, 49.56064], [40.13249, 49.61672], [40.16683, 49.56865], [40.03636, 49.52321], [40.03087, 49.45452], [40.1141, 49.38798], [40.14912, 49.37681], [40.18331, 49.34996], [40.22176, 49.25683], [40.01988, 49.1761], [39.93437, 49.05709], [39.6836, 49.05121], [39.6683, 48.99454], [39.71353, 48.98959], [39.72649, 48.9754], [39.74874, 48.98675], [39.78368, 48.91596], [39.98967, 48.86901], [40.03636, 48.91957], [40.08168, 48.87443], [39.97182, 48.79398], [39.79466, 48.83739], [39.73104, 48.7325], [39.71765, 48.68673], [39.67226, 48.59368], [39.79764, 48.58668], [39.84548, 48.57821], [39.86196, 48.46633], [39.88794, 48.44226], [39.94847, 48.35055], [39.84136, 48.33321], [39.84273, 48.30947], [39.90041, 48.3049], [39.91465, 48.26743], [39.95248, 48.29972], [39.9693, 48.29904], [39.97325, 48.31399], [39.99241, 48.31768], [40.00752, 48.22445], [39.94847, 48.22811], [39.83724, 48.06501], [39.88256, 48.04482], [39.77544, 48.04206], [39.82213, 47.96396], [39.73935, 47.82876], [38.87979, 47.87719], [38.79628, 47.81109], [38.76379, 47.69346], [38.35062, 47.61631], [38.28679, 47.53552], [38.28954, 47.39255], [38.22225, 47.30788], [38.33074, 47.30508], [38.32112, 47.2585], [38.23049, 47.2324], [38.22955, 47.12069], [38.3384, 46.98085], [38.12112, 46.86078], [37.62608, 46.82615], [35.23066, 45.79231], [35.04991, 45.76827], [36.6645, 45.4514], [36.6545, 45.3417], [36.5049, 45.3136], [36.475, 45.2411], [36.4883, 45.0488], [33.5943, 44.03313], [39.81147, 43.06294], [40.0078, 43.38551], [40.00853, 43.40578], [40.01552, 43.42025], [40.01007, 43.42411], [40.03312, 43.44262], [40.04445, 43.47776], [40.10657, 43.57344], [40.65957, 43.56212], [41.64935, 43.22331], [42.40563, 43.23226], [42.66667, 43.13917], [42.75889, 43.19651], [43.03322, 43.08883], [43.0419, 43.02413], [43.81453, 42.74297], [43.73119, 42.62043], [43.95517, 42.55396], [44.54202, 42.75699], [44.70002, 42.74679], [44.80941, 42.61277], [44.88754, 42.74934], [45.15318, 42.70598], [45.36501, 42.55268], [45.78692, 42.48358], [45.61676, 42.20768], [46.42738, 41.91323], [46.5332, 41.87389], [46.58924, 41.80547], [46.75269, 41.8623], [46.8134, 41.76252], [47.00955, 41.63583], [46.99554, 41.59743], [47.03757, 41.55434], [47.10762, 41.59044], [47.34579, 41.27884], [47.49004, 41.26366], [47.54504, 41.20275], [47.62288, 41.22969], [47.75831, 41.19455], [47.87973, 41.21798], [48.07587, 41.49957], [48.22064, 41.51472], [48.2878, 41.56221], [48.40277, 41.60441], [48.42301, 41.65444], [48.55078, 41.77917], [48.5867, 41.84306], [48.80971, 41.95365], [49.2134, 44.84989], [49.88945, 46.04554], [49.32259, 46.26944], [49.16518, 46.38542], [48.54988, 46.56267], [48.51142, 46.69268], [49.01136, 46.72716], [48.52326, 47.4102], [48.45173, 47.40818], [48.15348, 47.74545], [47.64973, 47.76559], [47.41689, 47.83687], [47.38731, 47.68176], [47.12107, 47.83687], [47.11516, 48.27188], [46.49011, 48.43019], [46.78392, 48.95352], [47.00857, 49.04921], [47.04658, 49.19834], [46.78398, 49.34026], [46.9078, 49.86707], [47.18319, 49.93721], [47.34589, 50.09308], [47.30448, 50.30894], [47.58551, 50.47867], [48.10044, 50.09242], [48.24519, 49.86099], [48.42564, 49.82283], [48.68352, 49.89546], [48.90782, 50.02281], [48.57946, 50.63278], [48.86936, 50.61589], [49.12673, 50.78639], [49.41959, 50.85927], [49.39001, 51.09396], [49.76866, 51.11067], [49.97277, 51.2405], [50.26859, 51.28677], [50.59695, 51.61859], [51.26254, 51.68466], [51.301, 51.48799], [51.77431, 51.49536], [51.8246, 51.67916], [52.36119, 51.74161], [52.54329, 51.48444], [53.46165, 51.49445], [53.69299, 51.23466], [54.12248, 51.11542], [54.46331, 50.85554], [54.41894, 50.61214], [54.55797, 50.52006], [54.71476, 50.61214], [54.56685, 51.01958], [54.72067, 51.03261], [55.67774, 50.54508], [56.11398, 50.7471], [56.17906, 50.93204], [57.17302, 51.11253], [57.44221, 50.88354], [57.74986, 50.93017], [57.75578, 51.13852], [58.3208, 51.15151], [58.87974, 50.70852], [59.48928, 50.64216], [59.51886, 50.49937], [59.81172, 50.54451], [60.01288, 50.8163], [60.17262, 50.83312], [60.31914, 50.67705], [60.81833, 50.6629], [61.4431, 50.80679], [61.56889, 51.23679], [61.6813, 51.25716], [61.55114, 51.32746], [61.50677, 51.40687], [60.95655, 51.48615], [60.92401, 51.61124], [60.5424, 51.61675], [60.36787, 51.66815], [60.50986, 51.7964], [60.09867, 51.87135], [59.99809, 51.98263], [59.91279, 52.06924], [60.17253, 52.25814], [60.17516, 52.39457], [59.25033, 52.46803], [59.22409, 52.28437], [58.79644, 52.43392], [58.94336, 53.953], [59.70487, 54.14846], [59.95217, 54.85853], [57.95234, 54.39672], [57.14829, 54.84204], [57.25137, 55.26262], [58.81825, 55.03378], [59.49035, 55.60486], [59.28419, 56.15739], [57.51527, 56.08729], [57.28024, 56.87898], [58.07604, 57.08308], [58.13789, 57.68097], [58.81412, 57.71602], [58.71104, 58.07475], [59.40376, 58.45822], [59.15636, 59.14682], [58.3853, 59.487], [59.50685, 60.91162], [59.36223, 61.3882], [59.61398, 62.44915], [59.24834, 63.01859], [59.80579, 64.13948], [59.63945, 64.78384], [60.74386, 64.95767], [61.98014, 65.72191], [66.1708, 67.61252], [64.18965, 69.94255], [76.13964, 83.37843], [36.85549, 84.09565], [32.07813, 72.01005], [31.59909, 70.16571], [30.84095, 69.80584], [30.95011, 69.54699], [30.52662, 69.54699], [30.16363, 69.65244], [29.97205, 69.41623], [29.27631, 69.2811], [29.26623, 69.13794], [29.0444, 69.0119], [28.91738, 69.04774], [28.45957, 68.91417], [28.78224, 68.86696], [28.43941, 68.53366], [28.62982, 68.19816], [29.34179, 68.06655], [29.66955, 67.79872], [30.02041, 67.67523], [29.91155, 67.51507], [28.9839, 66.94139], [29.91155, 66.13863], [30.16363, 65.66935], [29.97205, 65.70256], [29.74013, 65.64025], [29.84096, 65.56945], [29.68972, 65.31803], [29.61914, 65.23791], [29.8813, 65.22101], [29.84096, 65.1109], [29.61914, 65.05993], [29.68972, 64.80789], [30.05271, 64.79072], [30.12329, 64.64862], [30.01238, 64.57513], [30.06279, 64.35782], [30.4762, 64.25728], [30.55687, 64.09036], [30.25437, 63.83364], [29.98213, 63.75795], [30.49637, 63.46666], [31.23244, 63.22239], [31.29294, 63.09035], [31.58535, 62.91642], [31.38369, 62.66284], [31.10136, 62.43042], [29.01829, 61.17448], [28.82816, 61.1233], [28.47974, 60.93365], [27.77352, 60.52722], [27.71177, 60.3893], [27.44953, 60.22766], [26.32936, 60.00121]]]] } },
28935     { type: "Feature", properties: { wikidata: "Q1083368", nameEn: "Mainland Finland", country: "FI", groups: ["EU", "154", "150", "UN"], callingCodes: ["358"] }, geometry: { type: "MultiPolygon", coordinates: [[[[29.12697, 69.69193], [28.36883, 69.81658], [28.32849, 69.88605], [27.97558, 69.99671], [27.95542, 70.0965], [27.57226, 70.06215], [27.05802, 69.92069], [26.64461, 69.96565], [26.40261, 69.91377], [25.96904, 69.68397], [25.69679, 69.27039], [25.75729, 68.99383], [25.61613, 68.89602], [25.42455, 68.90328], [25.12206, 68.78684], [25.10189, 68.63307], [24.93048, 68.61102], [24.90023, 68.55579], [24.74898, 68.65143], [24.18432, 68.73936], [24.02299, 68.81601], [23.781, 68.84514], [23.68017, 68.70276], [23.13064, 68.64684], [22.53321, 68.74393], [22.38367, 68.71561], [22.27276, 68.89514], [21.63833, 69.27485], [21.27827, 69.31281], [21.00732, 69.22755], [20.98641, 69.18809], [21.11099, 69.10291], [21.05775, 69.0356], [20.72171, 69.11874], [20.55258, 69.06069], [20.78802, 69.03087], [20.91658, 68.96764], [20.85104, 68.93142], [20.90649, 68.89696], [21.03001, 68.88969], [22.00429, 68.50692], [22.73028, 68.40881], [23.10336, 68.26551], [23.15377, 68.14759], [23.26469, 68.15134], [23.40081, 68.05545], [23.65793, 67.9497], [23.45627, 67.85297], [23.54701, 67.59306], [23.39577, 67.46974], [23.75372, 67.43688], [23.75372, 67.29914], [23.54701, 67.25435], [23.58735, 67.20752], [23.56214, 67.17038], [23.98563, 66.84149], [23.98059, 66.79585], [23.89488, 66.772], [23.85959, 66.56434], [23.63776, 66.43568], [23.67591, 66.3862], [23.64982, 66.30603], [23.71339, 66.21299], [23.90497, 66.15802], [24.15791, 65.85385], [24.14798, 65.83466], [24.15107, 65.81427], [24.14112, 65.39731], [20.15877, 63.06556], [19.23413, 60.61414], [20.96741, 60.71528], [21.15143, 60.54555], [21.08159, 60.20167], [21.02509, 60.12142], [21.35468, 59.67511], [20.5104, 59.15546], [26.32936, 60.00121], [27.44953, 60.22766], [27.71177, 60.3893], [27.77352, 60.52722], [28.47974, 60.93365], [28.82816, 61.1233], [29.01829, 61.17448], [31.10136, 62.43042], [31.38369, 62.66284], [31.58535, 62.91642], [31.29294, 63.09035], [31.23244, 63.22239], [30.49637, 63.46666], [29.98213, 63.75795], [30.25437, 63.83364], [30.55687, 64.09036], [30.4762, 64.25728], [30.06279, 64.35782], [30.01238, 64.57513], [30.12329, 64.64862], [30.05271, 64.79072], [29.68972, 64.80789], [29.61914, 65.05993], [29.84096, 65.1109], [29.8813, 65.22101], [29.61914, 65.23791], [29.68972, 65.31803], [29.84096, 65.56945], [29.74013, 65.64025], [29.97205, 65.70256], [30.16363, 65.66935], [29.91155, 66.13863], [28.9839, 66.94139], [29.91155, 67.51507], [30.02041, 67.67523], [29.66955, 67.79872], [29.34179, 68.06655], [28.62982, 68.19816], [28.43941, 68.53366], [28.78224, 68.86696], [28.45957, 68.91417], [28.91738, 69.04774], [28.81248, 69.11997], [28.8629, 69.22395], [29.31664, 69.47994], [29.12697, 69.69193]]]] } },
28936     { type: "Feature", properties: { wikidata: "Q1184963", nameEn: "Alhucemas Islands", country: "ES", groups: ["EU", "Q191011", "015", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[-3.90602, 35.21494], [-3.88372, 35.20767], [-3.89343, 35.22728], [-3.90602, 35.21494]]]] } },
28937     { type: "Feature", properties: { wikidata: "Q1298289", nameEn: "Egmont Islands", country: "GB", groups: ["IO", "BOTS", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[70.1848, -6.37445], [70.67958, -8.2663], [72.17991, -6.68509], [70.1848, -6.37445]]]] } },
28938     { type: "Feature", properties: { wikidata: "Q1352230", nameEn: "US Territories", country: "US", level: "subcountryGroup" }, geometry: null },
28939     { type: "Feature", properties: { wikidata: "Q1451600", nameEn: "Overseas Countries and Territories of the EU", aliases: ["OCT"], level: "subunion" }, geometry: null },
28940     { type: "Feature", properties: { wikidata: "Q1544253", nameEn: "Great Chagos Bank", country: "GB", groups: ["IO", "BOTS", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[70.1848, -6.37445], [72.17991, -6.68509], [73.20573, -5.20727], [70.1848, -6.37445]]]] } },
28941     { type: "Feature", properties: { wikidata: "Q1585511", nameEn: "Salomon Atoll", country: "GB", groups: ["IO", "BOTS", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[72.09518, -5.61768], [73.20573, -5.20727], [72.12587, -4.02588], [72.09518, -5.61768]]]] } },
28942     { type: "Feature", properties: { wikidata: "Q1681727", nameEn: "Saint-Paul and Amsterdam", country: "FR", groups: ["EU", "TF", "Q1451600", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[76.31747, -42.16264], [80.15867, -36.04977], [71.22311, -38.75287], [76.31747, -42.16264]]]] } },
28943     { type: "Feature", properties: { wikidata: "Q1901211", nameEn: "East Malaysia", country: "MY", groups: ["Q36117", "035", "142", "UN"], driveSide: "left", callingCodes: ["60"] }, geometry: { type: "MultiPolygon", coordinates: [[[[110.90339, 7.52694], [109.82788, 2.86812], [109.62558, 1.99182], [109.53794, 1.91771], [109.57923, 1.80624], [109.66397, 1.79972], [109.66397, 1.60425], [110.35354, 0.98869], [110.49182, 0.88088], [110.62374, 0.873], [111.22979, 1.08326], [111.55434, 0.97864], [111.82846, 0.99349], [111.94553, 1.12016], [112.15679, 1.17004], [112.2127, 1.44135], [112.48648, 1.56516], [113.021, 1.57819], [113.01448, 1.42832], [113.64677, 1.23933], [114.03788, 1.44787], [114.57892, 1.5], [114.80706, 1.92351], [114.80706, 2.21665], [115.1721, 2.49671], [115.11343, 2.82879], [115.53713, 3.14776], [115.58276, 3.93499], [115.90217, 4.37708], [117.25801, 4.35108], [117.47313, 4.18857], [117.67641, 4.16535], [118.06469, 4.16638], [118.93936, 4.09009], [119.52945, 5.35672], [117.98544, 6.27477], [117.93857, 6.89845], [117.17735, 7.52841], [116.79524, 7.43869], [115.02521, 5.35005], [115.16236, 5.01011], [115.15092, 4.87604], [115.20737, 4.8256], [115.27819, 4.63661], [115.2851, 4.42295], [115.36346, 4.33563], [115.31275, 4.30806], [115.09978, 4.39123], [115.07737, 4.53418], [115.04064, 4.63706], [115.02278, 4.74137], [115.02955, 4.82087], [115.05038, 4.90275], [114.99417, 4.88201], [114.96982, 4.81146], [114.88841, 4.81905], [114.8266, 4.75062], [114.77303, 4.72871], [114.83189, 4.42387], [114.88039, 4.4257], [114.78539, 4.12205], [114.64211, 4.00694], [114.49922, 4.13108], [114.4416, 4.27588], [114.32176, 4.2552], [114.32176, 4.34942], [114.26876, 4.49878], [114.15813, 4.57], [114.07448, 4.58441], [114.10166, 4.76112], [110.90339, 7.52694]]]] } },
28944     { type: "Feature", properties: { wikidata: "Q1973345", nameEn: "Peninsular Malaysia", country: "MY", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["60"] }, geometry: { type: "MultiPolygon", coordinates: [[[[102.46318, 7.22462], [102.09086, 6.23546], [102.08127, 6.22679], [102.07732, 6.193], [102.09182, 6.14161], [102.01835, 6.05407], [101.99209, 6.04075], [101.97114, 6.01992], [101.9714, 6.00575], [101.94712, 5.98421], [101.92819, 5.85511], [101.91776, 5.84269], [101.89188, 5.8386], [101.80144, 5.74505], [101.75074, 5.79091], [101.69773, 5.75881], [101.58019, 5.93534], [101.25524, 5.78633], [101.25755, 5.71065], [101.14062, 5.61613], [100.98815, 5.79464], [101.02708, 5.91013], [101.087, 5.9193], [101.12388, 6.11411], [101.06165, 6.14161], [101.12618, 6.19431], [101.10313, 6.25617], [100.85884, 6.24929], [100.81045, 6.45086], [100.74822, 6.46231], [100.74361, 6.50811], [100.66986, 6.45086], [100.43027, 6.52389], [100.42351, 6.51762], [100.41791, 6.5189], [100.41152, 6.52299], [100.35413, 6.54932], [100.31929, 6.65413], [100.32607, 6.65933], [100.32671, 6.66526], [100.31884, 6.66423], [100.31618, 6.66781], [100.30828, 6.66462], [100.29651, 6.68439], [100.19511, 6.72559], [100.12, 6.42105], [100.0756, 6.4045], [99.91873, 6.50233], [99.50117, 6.44501], [99.31854, 5.99868], [99.75778, 3.86466], [103.03657, 1.30383], [103.56591, 1.19719], [103.62738, 1.35255], [103.67468, 1.43166], [103.7219, 1.46108], [103.74161, 1.4502], [103.76395, 1.45183], [103.81181, 1.47953], [103.86383, 1.46288], [103.89565, 1.42841], [103.93384, 1.42926], [104.00131, 1.42405], [104.02277, 1.4438], [104.04622, 1.44691], [104.07348, 1.43322], [104.08871, 1.42015], [104.09162, 1.39694], [104.08072, 1.35998], [104.12282, 1.27714], [104.34728, 1.33529], [104.56723, 1.44271], [105.01437, 3.24936], [102.46318, 7.22462]]]] } },
28945     { type: "Feature", properties: { wikidata: "Q2093907", nameEn: "Three Kings Islands", country: "NZ", groups: ["Q851132", "053", "009", "UN"], driveSide: "left" }, geometry: { type: "MultiPolygon", coordinates: [[[[174.17679, -32.62487], [170.93268, -32.97889], [171.97383, -34.64644], [174.17679, -32.62487]]]] } },
28946     { type: "Feature", properties: { wikidata: "Q2298216", nameEn: "Solander Islands", country: "NZ", groups: ["Q851132", "053", "009", "UN"], driveSide: "left" }, geometry: { type: "MultiPolygon", coordinates: [[[[167.39068, -46.49187], [166.5534, -46.39484], [166.84561, -46.84889], [167.39068, -46.49187]]]] } },
28947     { type: "Feature", properties: { wikidata: "Q2872203", nameEn: "Mainland Australia", country: "AU", groups: ["053", "009", "UN"], level: "subcountryGroup", driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[88.16419, -23.49578], [123.64533, -39.13605], [159.74028, -39.1978], [159.76765, -29.76946], [154.02855, -24.43238], [152.93188, -20.92631], [147.69992, -17.5933], [145.2855, -9.62524], [143.87386, -9.02382], [143.29772, -9.33993], [142.48658, -9.36754], [142.19246, -9.15378], [141.88934, -9.36111], [141.01842, -9.35091], [135.49042, -9.2276], [127.55165, -9.05052], [125.29076, -12.33139], [88.16419, -23.49578]]]] } },
28948     { type: "Feature", properties: { wikidata: "Q2914565", nameEn: "Autonomous Regions of Portugal", country: "PT", level: "subcountryGroup" }, geometry: null },
28949     { type: "Feature", properties: { wikidata: "Q2915956", nameEn: "Mainland Portugal", country: "PT", groups: ["Q12837", "EU", "039", "150", "UN"], level: "subcountryGroup", callingCodes: ["351"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-10.39881, 36.12218], [-7.37282, 36.96896], [-7.39769, 37.16868], [-7.41133, 37.20314], [-7.41854, 37.23813], [-7.43227, 37.25152], [-7.43974, 37.38913], [-7.46878, 37.47127], [-7.51759, 37.56119], [-7.41981, 37.75729], [-7.33441, 37.81193], [-7.27314, 37.90145], [-7.24544, 37.98884], [-7.12648, 38.00296], [-7.10366, 38.04404], [-7.05966, 38.01966], [-7.00375, 38.01914], [-6.93418, 38.21454], [-7.09389, 38.17227], [-7.15581, 38.27597], [-7.32529, 38.44336], [-7.265, 38.61674], [-7.26174, 38.72107], [-7.03848, 38.87221], [-7.051, 38.907], [-6.95211, 39.0243], [-6.97004, 39.07619], [-7.04011, 39.11919], [-7.10692, 39.10275], [-7.14929, 39.11287], [-7.12811, 39.17101], [-7.23566, 39.20132], [-7.23403, 39.27579], [-7.3149, 39.34857], [-7.2927, 39.45847], [-7.49477, 39.58794], [-7.54121, 39.66717], [-7.33507, 39.64569], [-7.24707, 39.66576], [-7.01613, 39.66877], [-6.97492, 39.81488], [-6.91463, 39.86618], [-6.86737, 40.01986], [-6.94233, 40.10716], [-7.00589, 40.12087], [-7.02544, 40.18564], [-7.00426, 40.23169], [-6.86085, 40.26776], [-6.86085, 40.2976], [-6.80218, 40.33239], [-6.78426, 40.36468], [-6.84618, 40.42177], [-6.84944, 40.46394], [-6.7973, 40.51723], [-6.80218, 40.55067], [-6.84292, 40.56801], [-6.79567, 40.65955], [-6.82826, 40.74603], [-6.82337, 40.84472], [-6.79892, 40.84842], [-6.80707, 40.88047], [-6.84292, 40.89771], [-6.8527, 40.93958], [-6.9357, 41.02888], [-6.913, 41.03922], [-6.88843, 41.03027], [-6.84781, 41.02692], [-6.80942, 41.03629], [-6.79241, 41.05397], [-6.75655, 41.10187], [-6.77319, 41.13049], [-6.69711, 41.1858], [-6.68286, 41.21641], [-6.65046, 41.24725], [-6.55937, 41.24417], [-6.38551, 41.35274], [-6.38553, 41.38655], [-6.3306, 41.37677], [-6.26777, 41.48796], [-6.19128, 41.57638], [-6.29863, 41.66432], [-6.44204, 41.68258], [-6.49907, 41.65823], [-6.54633, 41.68623], [-6.56426, 41.74219], [-6.51374, 41.8758], [-6.56752, 41.88429], [-6.5447, 41.94371], [-6.58544, 41.96674], [-6.61967, 41.94008], [-6.75004, 41.94129], [-6.76959, 41.98734], [-6.81196, 41.99097], [-6.82174, 41.94493], [-6.94396, 41.94403], [-6.95537, 41.96553], [-6.98144, 41.9728], [-7.01078, 41.94977], [-7.07596, 41.94977], [-7.08574, 41.97401], [-7.14115, 41.98855], [-7.18549, 41.97515], [-7.18677, 41.88793], [-7.32366, 41.8406], [-7.37092, 41.85031], [-7.42864, 41.80589], [-7.42854, 41.83262], [-7.44759, 41.84451], [-7.45566, 41.86488], [-7.49803, 41.87095], [-7.52737, 41.83939], [-7.62188, 41.83089], [-7.58603, 41.87944], [-7.65774, 41.88308], [-7.69848, 41.90977], [-7.84188, 41.88065], [-7.88055, 41.84571], [-7.88751, 41.92553], [-7.90707, 41.92432], [-7.92336, 41.8758], [-7.9804, 41.87337], [-8.01136, 41.83453], [-8.0961, 41.81024], [-8.16455, 41.81753], [-8.16944, 41.87944], [-8.19551, 41.87459], [-8.2185, 41.91237], [-8.16232, 41.9828], [-8.08796, 42.01398], [-8.08847, 42.05767], [-8.11729, 42.08537], [-8.18178, 42.06436], [-8.19406, 42.12141], [-8.18947, 42.13853], [-8.1986, 42.15402], [-8.22406, 42.1328], [-8.24681, 42.13993], [-8.2732, 42.12396], [-8.29809, 42.106], [-8.32161, 42.10218], [-8.33912, 42.08358], [-8.36353, 42.09065], [-8.38323, 42.07683], [-8.40143, 42.08052], [-8.42512, 42.07199], [-8.44123, 42.08218], [-8.48185, 42.0811], [-8.52837, 42.07658], [-8.5252, 42.06264], [-8.54563, 42.0537], [-8.58086, 42.05147], [-8.59493, 42.05708], [-8.63791, 42.04691], [-8.64626, 42.03668], [-8.65832, 42.02972], [-8.6681, 41.99703], [-8.69071, 41.98862], [-8.7478, 41.96282], [-8.74606, 41.9469], [-8.75712, 41.92833], [-8.81794, 41.90375], [-8.87157, 41.86488], [-11.19304, 41.83075], [-10.39881, 36.12218]]]] } },
28950     { type: "Feature", properties: { wikidata: "Q3311985", nameEn: "Guernsey", country: "GB", groups: ["GG", "830", "Q185086", "154", "150", "UN"], level: "subterritory", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44 01481"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.49556, 49.79012], [-3.28154, 49.57329], [-2.65349, 49.15373], [-2.36485, 49.48223], [-2.49556, 49.79012]]]] } },
28951     { type: "Feature", properties: { wikidata: "Q3320166", nameEn: "Outermost Regions of the EU", aliases: ["OMR"], level: "subunion" }, geometry: null },
28952     { type: "Feature", properties: { wikidata: "Q3336843", nameEn: "Countries of the United Kingdom", aliases: ["GB-UKM"], country: "GB", level: "subcountryGroup" }, geometry: null },
28953     { type: "Feature", properties: { wikidata: "Q6736667", nameEn: "Mainland India", country: "IN", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["91"] }, geometry: { type: "MultiPolygon", coordinates: [[[[89.08044, 21.41871], [89.07114, 22.15335], [88.9367, 22.58527], [88.94614, 22.66941], [88.9151, 22.75228], [88.96713, 22.83346], [88.87063, 22.95235], [88.88327, 23.03885], [88.86377, 23.08759], [88.99148, 23.21134], [88.71133, 23.2492], [88.79254, 23.46028], [88.79351, 23.50535], [88.74841, 23.47361], [88.56507, 23.64044], [88.58087, 23.87105], [88.66189, 23.87607], [88.73743, 23.91751], [88.6976, 24.14703], [88.74841, 24.1959], [88.68801, 24.31464], [88.50934, 24.32474], [88.12296, 24.51301], [88.08786, 24.63232], [88.00683, 24.66477], [88.15515, 24.85806], [88.14004, 24.93529], [88.21832, 24.96642], [88.27325, 24.88796], [88.33917, 24.86803], [88.46277, 25.07468], [88.44766, 25.20149], [88.94067, 25.18534], [89.00463, 25.26583], [89.01105, 25.30303], [88.85278, 25.34679], [88.81296, 25.51546], [88.677, 25.46959], [88.4559, 25.59227], [88.45103, 25.66245], [88.242, 25.80811], [88.13138, 25.78773], [88.08804, 25.91334], [88.16581, 26.0238], [88.1844, 26.14417], [88.34757, 26.22216], [88.35153, 26.29123], [88.51649, 26.35923], [88.48749, 26.45855], [88.36938, 26.48683], [88.35153, 26.45241], [88.33093, 26.48929], [88.41196, 26.63837], [88.4298, 26.54489], [88.62144, 26.46783], [88.69485, 26.38353], [88.67837, 26.26291], [88.78961, 26.31093], [88.85004, 26.23211], [89.05328, 26.2469], [88.91321, 26.37984], [88.92357, 26.40711], [88.95612, 26.4564], [89.08899, 26.38845], [89.15869, 26.13708], [89.35953, 26.0077], [89.53515, 26.00382], [89.57101, 25.9682], [89.63968, 26.22595], [89.70201, 26.15138], [89.73581, 26.15818], [89.77865, 26.08387], [89.77728, 26.04254], [89.86592, 25.93115], [89.80585, 25.82489], [89.84388, 25.70042], [89.86129, 25.61714], [89.81208, 25.37244], [89.84086, 25.31854], [89.83371, 25.29548], [89.87629, 25.28337], [89.90478, 25.31038], [90.1155, 25.22686], [90.40034, 25.1534], [90.65042, 25.17788], [90.87427, 25.15799], [91.25517, 25.20677], [91.63648, 25.12846], [92.0316, 25.1834], [92.33957, 25.07593], [92.39147, 25.01471], [92.49887, 24.88796], [92.38626, 24.86055], [92.25854, 24.9191], [92.15796, 24.54435], [92.11662, 24.38997], [91.96603, 24.3799], [91.89258, 24.14674], [91.82596, 24.22345], [91.76004, 24.23848], [91.73257, 24.14703], [91.65292, 24.22095], [91.63782, 24.1132], [91.55542, 24.08687], [91.37414, 24.10693], [91.35741, 23.99072], [91.29587, 24.0041], [91.22308, 23.89616], [91.25192, 23.83463], [91.15579, 23.6599], [91.28293, 23.37538], [91.36453, 23.06612], [91.40848, 23.07117], [91.4035, 23.27522], [91.46615, 23.2328], [91.54993, 23.01051], [91.61571, 22.93929], [91.7324, 23.00043], [91.81634, 23.08001], [91.76417, 23.26619], [91.84789, 23.42235], [91.95642, 23.47361], [91.95093, 23.73284], [92.04706, 23.64229], [92.15417, 23.73409], [92.26541, 23.70392], [92.38214, 23.28705], [92.37665, 22.9435], [92.5181, 22.71441], [92.60029, 22.1522], [92.56616, 22.13554], [92.60949, 21.97638], [92.67532, 22.03547], [92.70416, 22.16017], [92.86208, 22.05456], [92.89504, 21.95143], [92.93899, 22.02656], [92.99804, 21.98964], [92.99255, 22.05965], [93.04885, 22.20595], [93.15734, 22.18687], [93.14224, 22.24535], [93.19991, 22.25425], [93.18206, 22.43716], [93.13537, 22.45873], [93.11477, 22.54374], [93.134, 22.59573], [93.09417, 22.69459], [93.134, 22.92498], [93.12988, 23.05772], [93.2878, 23.00464], [93.38478, 23.13698], [93.36862, 23.35426], [93.38781, 23.36139], [93.39981, 23.38828], [93.38805, 23.4728], [93.43475, 23.68299], [93.3908, 23.7622], [93.3908, 23.92925], [93.36059, 23.93176], [93.32351, 24.04468], [93.34735, 24.10151], [93.41415, 24.07854], [93.46633, 23.97067], [93.50616, 23.94432], [93.62871, 24.00922], [93.75952, 24.0003], [93.80279, 23.92549], [93.92089, 23.95812], [94.14081, 23.83333], [94.30215, 24.23752], [94.32362, 24.27692], [94.45279, 24.56656], [94.50729, 24.59281], [94.5526, 24.70764], [94.60204, 24.70889], [94.73937, 25.00545], [94.74212, 25.13606], [94.57458, 25.20318], [94.68032, 25.47003], [94.80117, 25.49359], [95.18556, 26.07338], [95.11428, 26.1019], [95.12801, 26.38397], [95.05798, 26.45408], [95.23513, 26.68499], [95.30339, 26.65372], [95.437, 26.7083], [95.81603, 27.01335], [95.93002, 27.04149], [96.04949, 27.19428], [96.15591, 27.24572], [96.40779, 27.29818], [96.55761, 27.29928], [96.73888, 27.36638], [96.88445, 27.25046], [96.85287, 27.2065], [96.89132, 27.17474], [97.14675, 27.09041], [97.17422, 27.14052], [96.91431, 27.45752], [96.90112, 27.62149], [97.29919, 27.92233], [97.35824, 27.87256], [97.38845, 28.01329], [97.35412, 28.06663], [97.31292, 28.06784], [97.34547, 28.21385], [97.1289, 28.3619], [96.98882, 28.32564], [96.88445, 28.39452], [96.85561, 28.4875], [96.6455, 28.61657], [96.48895, 28.42955], [96.40929, 28.51526], [96.61391, 28.72742], [96.3626, 29.10607], [96.20467, 29.02325], [96.18682, 29.11087], [96.31316, 29.18643], [96.05361, 29.38167], [95.84899, 29.31464], [95.75149, 29.32063], [95.72086, 29.20797], [95.50842, 29.13487], [95.41091, 29.13007], [95.3038, 29.13847], [95.26122, 29.07727], [95.2214, 29.10727], [95.11291, 29.09527], [95.0978, 29.14446], [94.81353, 29.17804], [94.69318, 29.31739], [94.2752, 29.11687], [94.35897, 29.01965], [93.72797, 28.68821], [93.44621, 28.67189], [93.18069, 28.50319], [93.14635, 28.37035], [92.93075, 28.25671], [92.67486, 28.15018], [92.65472, 28.07632], [92.73025, 28.05814], [92.7275, 27.98662], [92.42538, 27.80092], [92.32101, 27.79363], [92.27432, 27.89077], [91.87057, 27.7195], [91.84722, 27.76325], [91.6469, 27.76358], [91.55819, 27.6144], [91.65007, 27.48287], [92.01132, 27.47352], [92.12019, 27.27829], [92.04702, 27.26861], [92.03457, 27.07334], [92.11863, 26.893], [92.05523, 26.8692], [91.83181, 26.87318], [91.50067, 26.79223], [90.67715, 26.77215], [90.48504, 26.8594], [90.39271, 26.90704], [90.30402, 26.85098], [90.04535, 26.72422], [89.86124, 26.73307], [89.63369, 26.74402], [89.42349, 26.83727], [89.3901, 26.84225], [89.38319, 26.85963], [89.37913, 26.86224], [89.1926, 26.81329], [89.12825, 26.81661], [89.09554, 26.89089], [88.95807, 26.92668], [88.92301, 26.99286], [88.8714, 26.97488], [88.86984, 27.10937], [88.74219, 27.144], [88.91901, 27.32483], [88.82981, 27.38814], [88.77517, 27.45415], [88.88091, 27.85192], [88.83559, 28.01936], [88.63235, 28.12356], [88.54858, 28.06057], [88.25332, 27.9478], [88.1278, 27.95417], [88.13378, 27.88015], [88.1973, 27.85067], [88.19107, 27.79285], [88.04008, 27.49223], [88.07277, 27.43007], [88.01646, 27.21612], [88.01587, 27.21388], [87.9887, 27.11045], [88.11719, 26.98758], [88.13422, 26.98705], [88.12302, 26.95324], [88.19107, 26.75516], [88.1659, 26.68177], [88.16452, 26.64111], [88.09963, 26.54195], [88.09414, 26.43732], [88.00895, 26.36029], [87.90115, 26.44923], [87.89085, 26.48565], [87.84193, 26.43663], [87.7918, 26.46737], [87.76004, 26.40711], [87.67893, 26.43501], [87.66803, 26.40294], [87.59175, 26.38342], [87.55274, 26.40596], [87.51571, 26.43106], [87.46566, 26.44058], [87.37314, 26.40815], [87.34568, 26.34787], [87.26568, 26.37294], [87.26587, 26.40592], [87.24682, 26.4143], [87.18863, 26.40558], [87.14751, 26.40542], [87.09147, 26.45039], [87.0707, 26.58571], [87.04691, 26.58685], [87.01559, 26.53228], [86.95912, 26.52076], [86.94543, 26.52076], [86.82898, 26.43919], [86.76797, 26.45892], [86.74025, 26.42386], [86.69124, 26.45169], [86.62686, 26.46891], [86.61313, 26.48658], [86.57073, 26.49825], [86.54258, 26.53819], [86.49726, 26.54218], [86.31564, 26.61925], [86.26235, 26.61886], [86.22513, 26.58863], [86.13596, 26.60651], [86.02729, 26.66756], [85.8492, 26.56667], [85.85126, 26.60866], [85.83126, 26.61134], [85.76907, 26.63076], [85.72315, 26.67471], [85.73483, 26.79613], [85.66239, 26.84822], [85.61621, 26.86721], [85.59461, 26.85161], [85.5757, 26.85955], [85.56471, 26.84133], [85.47752, 26.79292], [85.34302, 26.74954], [85.21159, 26.75933], [85.18046, 26.80519], [85.19291, 26.86909], [85.15883, 26.86966], [85.02635, 26.85381], [85.05592, 26.88991], [85.00536, 26.89523], [84.97186, 26.9149], [84.96687, 26.95599], [84.85754, 26.98984], [84.82913, 27.01989], [84.793, 26.9968], [84.64496, 27.04669], [84.69166, 27.21294], [84.62161, 27.33885], [84.29315, 27.39], [84.25735, 27.44941], [84.21376, 27.45218], [84.10791, 27.52399], [84.02229, 27.43836], [83.93306, 27.44939], [83.86182, 27.4241], [83.85595, 27.35797], [83.61288, 27.47013], [83.39495, 27.4798], [83.38872, 27.39276], [83.35136, 27.33885], [83.29999, 27.32778], [83.2673, 27.36235], [83.27197, 27.38309], [83.19413, 27.45632], [82.94938, 27.46036], [82.93261, 27.50328], [82.74119, 27.49838], [82.70378, 27.72122], [82.46405, 27.6716], [82.06554, 27.92222], [81.97214, 27.93322], [81.91223, 27.84995], [81.47867, 28.08303], [81.48179, 28.12148], [81.38683, 28.17638], [81.32923, 28.13521], [81.19847, 28.36284], [81.03471, 28.40054], [80.55142, 28.69182], [80.50575, 28.6706], [80.52443, 28.54897], [80.44504, 28.63098], [80.37188, 28.63371], [80.12125, 28.82346], [80.06957, 28.82763], [80.05743, 28.91479], [80.18085, 29.13649], [80.23178, 29.11626], [80.26602, 29.13938], [80.24112, 29.21414], [80.28626, 29.20327], [80.31428, 29.30784], [80.24322, 29.44299], [80.37939, 29.57098], [80.41858, 29.63581], [80.38428, 29.68513], [80.36803, 29.73865], [80.41554, 29.79451], [80.43458, 29.80466], [80.48997, 29.79566], [80.56247, 29.86661], [80.57179, 29.91422], [80.60226, 29.95732], [80.67076, 29.95732], [80.8778, 30.13384], [80.86673, 30.17321], [80.91143, 30.22173], [80.92547, 30.17193], [81.03953, 30.20059], [80.83343, 30.32023], [80.54504, 30.44936], [80.20721, 30.58541], [79.93255, 30.88288], [79.59884, 30.93943], [79.30694, 31.17357], [79.14016, 31.43403], [79.01931, 31.42817], [78.89344, 31.30481], [78.77898, 31.31209], [78.71032, 31.50197], [78.84516, 31.60631], [78.69933, 31.78723], [78.78036, 31.99478], [78.74404, 32.00384], [78.68754, 32.10256], [78.49609, 32.2762], [78.4645, 32.45367], [78.38897, 32.53938], [78.73916, 32.69438], [78.7831, 32.46873], [78.96713, 32.33655], [78.99322, 32.37948], [79.0979, 32.38051], [79.13174, 32.47766], [79.26768, 32.53277], [79.46562, 32.69668], [79.14016, 33.02545], [79.15252, 33.17156], [78.73636, 33.56521], [78.67599, 33.66445], [78.77349, 33.73871], [78.73367, 34.01121], [78.65657, 34.03195], [78.66225, 34.08858], [78.91769, 34.15452], [78.99802, 34.3027], [79.05364, 34.32482], [78.74465, 34.45174], [78.56475, 34.50835], [78.54964, 34.57283], [78.27781, 34.61484], [78.18435, 34.7998], [78.22692, 34.88771], [78.00033, 35.23954], [78.03466, 35.3785], [78.11664, 35.48022], [77.80532, 35.52058], [77.70232, 35.46244], [77.44277, 35.46132], [76.96624, 35.5932], [76.84539, 35.67356], [76.77323, 35.66062], [76.75475, 35.52617], [76.85088, 35.39754], [76.93465, 35.39866], [77.11796, 35.05419], [76.99251, 34.93349], [76.87193, 34.96906], [76.74514, 34.92488], [76.74377, 34.84039], [76.67648, 34.76371], [76.47186, 34.78965], [76.15463, 34.6429], [76.04614, 34.67566], [75.75438, 34.51827], [75.38009, 34.55021], [75.01479, 34.64629], [74.6663, 34.703], [74.58083, 34.77386], [74.31239, 34.79626], [74.12897, 34.70073], [73.96423, 34.68244], [73.93401, 34.63386], [73.93951, 34.57169], [73.89419, 34.54568], [73.88732, 34.48911], [73.74999, 34.3781], [73.74862, 34.34183], [73.8475, 34.32935], [73.90517, 34.35317], [73.98208, 34.2522], [73.90677, 34.10504], [73.88732, 34.05105], [73.91341, 34.01235], [74.21554, 34.03853], [74.25262, 34.01577], [74.26086, 33.92237], [74.14001, 33.83002], [74.05898, 33.82089], [74.00891, 33.75437], [73.96423, 33.73071], [73.98968, 33.66155], [73.97367, 33.64061], [74.03576, 33.56718], [74.10115, 33.56392], [74.18121, 33.4745], [74.17983, 33.3679], [74.08782, 33.26232], [74.01366, 33.25199], [74.02144, 33.18908], [74.15374, 33.13477], [74.17571, 33.07495], [74.31854, 33.02891], [74.34875, 32.97823], [74.31227, 32.92795], [74.41467, 32.90563], [74.45312, 32.77755], [74.6289, 32.75561], [74.64675, 32.82604], [74.7113, 32.84219], [74.65345, 32.71225], [74.69542, 32.66792], [74.64424, 32.60985], [74.65251, 32.56416], [74.67431, 32.56676], [74.68362, 32.49298], [74.84725, 32.49075], [74.97634, 32.45367], [75.03265, 32.49538], [75.28259, 32.36556], [75.38046, 32.26836], [75.25649, 32.10187], [75.00793, 32.03786], [74.9269, 32.0658], [74.86236, 32.04485], [74.79919, 31.95983], [74.58907, 31.87824], [74.47771, 31.72227], [74.57498, 31.60382], [74.61517, 31.55698], [74.59319, 31.50197], [74.64713, 31.45605], [74.59773, 31.4136], [74.53223, 31.30321], [74.51629, 31.13829], [74.56023, 31.08303], [74.60281, 31.10419], [74.60006, 31.13711], [74.6852, 31.12771], [74.67971, 31.05479], [74.5616, 31.04153], [73.88993, 30.36305], [73.95736, 30.28466], [73.97225, 30.19829], [73.80299, 30.06969], [73.58665, 30.01848], [73.3962, 29.94707], [73.28094, 29.56646], [73.05886, 29.1878], [73.01337, 29.16422], [72.94272, 29.02487], [72.40402, 28.78283], [72.29495, 28.66367], [72.20329, 28.3869], [71.9244, 28.11555], [71.89921, 27.96035], [70.79054, 27.68423], [70.60927, 28.02178], [70.37307, 28.01208], [70.12502, 27.8057], [70.03136, 27.56627], [69.58519, 27.18109], [69.50904, 26.74892], [69.88555, 26.56836], [70.05584, 26.60398], [70.17532, 26.55362], [70.17532, 26.24118], [70.08193, 26.08094], [70.0985, 25.93238], [70.2687, 25.71156], [70.37444, 25.67443], [70.53649, 25.68928], [70.60378, 25.71898], [70.67382, 25.68186], [70.66695, 25.39314], [70.89148, 25.15064], [70.94002, 24.92843], [71.09405, 24.69017], [70.97594, 24.60904], [71.00341, 24.46038], [71.12838, 24.42662], [71.04461, 24.34657], [70.94985, 24.3791], [70.85784, 24.30903], [70.88393, 24.27398], [70.71502, 24.23517], [70.57906, 24.27774], [70.5667, 24.43787], [70.11712, 24.30915], [70.03428, 24.172], [69.73335, 24.17007], [69.59579, 24.29777], [69.29778, 24.28712], [69.19341, 24.25646], [69.07806, 24.29777], [68.97781, 24.26021], [68.90914, 24.33156], [68.7416, 24.31904], [68.74643, 23.97027], [68.39339, 23.96838], [68.20763, 23.85849], [68.11329, 23.53945], [76.59015, 5.591], [79.50447, 8.91876], [79.42124, 9.80115], [80.48418, 10.20786], [89.08044, 21.41871]]]] } },
28954     { type: "Feature", properties: { wikidata: "Q9143535", nameEn: "Akrotiri", country: "GB", groups: ["Q644636", "Q37362", "BOTS", "145", "142", "UN"], level: "subterritory", driveSide: "left", callingCodes: ["357"] }, geometry: { type: "MultiPolygon", coordinates: [[[[32.86014, 34.70585], [32.82717, 34.70622], [32.79433, 34.67883], [32.76136, 34.68318], [32.75515, 34.64985], [32.74412, 34.43926], [33.26744, 34.49942], [33.0138, 34.64424], [32.96968, 34.64046], [32.96718, 34.63446], [32.96312, 34.63236], [32.95516, 34.63541], [32.95323, 34.64075], [32.95471, 34.64528], [32.95277, 34.65104], [32.96154, 34.65587], [32.9639, 34.65866], [32.969, 34.6549], [32.98046, 34.65336], [32.99014, 34.65518], [32.98668, 34.67268], [32.98967, 34.67981], [32.95567, 34.6839], [32.94127, 34.67426], [32.93989, 34.67034], [32.93756, 34.67072], [32.93535, 34.66317], [32.92824, 34.66821], [32.93043, 34.67091], [32.91398, 34.67343], [32.9068, 34.66102], [32.86167, 34.68734], [32.86014, 34.70585]]]] } },
28955     { type: "Feature", properties: { wikidata: "Q9206745", nameEn: "Dhekelia", country: "GB", groups: ["Q644636", "Q37362", "BOTS", "145", "142", "UN"], level: "subterritory", driveSide: "left", callingCodes: ["357"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.70575, 34.97947], [33.83531, 34.73974], [33.98684, 34.76642], [33.90146, 34.96458], [33.86018, 34.97381], [33.84741, 34.97167], [33.84028, 34.97179], [33.83459, 34.97448], [33.84616, 34.98511], [33.85488, 34.98462], [33.85891, 35.001], [33.85216, 35.00579], [33.84045, 35.00616], [33.82875, 35.01685], [33.83055, 35.02865], [33.81524, 35.04192], [33.8012, 35.04786], [33.82051, 35.0667], [33.8355, 35.05777], [33.85261, 35.0574], [33.87438, 35.08118], [33.89322, 35.06789], [33.90247, 35.07686], [33.91789, 35.08688], [33.89853, 35.11377], [33.88737, 35.11408], [33.88943, 35.12007], [33.88561, 35.12449], [33.87224, 35.12293], [33.87622, 35.10457], [33.87097, 35.09389], [33.87479, 35.08881], [33.8541, 35.07201], [33.84168, 35.06823], [33.82067, 35.07826], [33.78581, 35.05104], [33.76106, 35.04253], [33.73824, 35.05321], [33.71482, 35.03722], [33.70209, 35.04882], [33.7161, 35.07279], [33.70861, 35.07644], [33.69095, 35.06237], [33.68474, 35.06602], [33.67742, 35.05963], [33.67678, 35.03866], [33.69938, 35.03123], [33.69731, 35.01754], [33.71514, 35.00294], [33.70639, 34.99303], [33.70575, 34.97947]], [[33.77312, 34.9976], [33.77553, 34.99518], [33.78516, 34.99582], [33.79191, 34.98914], [33.78917, 34.98854], [33.78571, 34.98951], [33.78318, 34.98699], [33.78149, 34.98854], [33.77843, 34.988], [33.7778, 34.98981], [33.76738, 34.99188], [33.76605, 34.99543], [33.75682, 34.99916], [33.75994, 35.00113], [33.77312, 34.9976]], [[33.74144, 35.01053], [33.7343, 35.01178], [33.73781, 35.02181], [33.74265, 35.02329], [33.74983, 35.02274], [33.7492, 35.01319], [33.74144, 35.01053]]]] } },
28956     { type: "Feature", properties: { wikidata: "Q16390686", nameEn: "Peninsular Spain", country: "ES", groups: ["Q12837", "EU", "039", "150", "UN"], callingCodes: ["34"] }, geometry: { type: "MultiPolygon", coordinates: [[[[3.75438, 42.33445], [3.17156, 42.43545], [3.11379, 42.43646], [3.10027, 42.42621], [3.08167, 42.42748], [3.03734, 42.47363], [2.96518, 42.46692], [2.94283, 42.48174], [2.92107, 42.4573], [2.88413, 42.45938], [2.86983, 42.46843], [2.85675, 42.45444], [2.84335, 42.45724], [2.77464, 42.41046], [2.75497, 42.42578], [2.72056, 42.42298], [2.65311, 42.38771], [2.6747, 42.33974], [2.57934, 42.35808], [2.55516, 42.35351], [2.54382, 42.33406], [2.48457, 42.33933], [2.43508, 42.37568], [2.43299, 42.39423], [2.38504, 42.39977], [2.25551, 42.43757], [2.20578, 42.41633], [2.16599, 42.42314], [2.12789, 42.41291], [2.11621, 42.38393], [2.06241, 42.35906], [2.00488, 42.35399], [1.96482, 42.37787], [1.9574, 42.42401], [1.94084, 42.43039], [1.94061, 42.43333], [1.94292, 42.44316], [1.93663, 42.45439], [1.88853, 42.4501], [1.83037, 42.48395], [1.76335, 42.48863], [1.72515, 42.50338], [1.70571, 42.48867], [1.66826, 42.50779], [1.65674, 42.47125], [1.58933, 42.46275], [1.57953, 42.44957], [1.55937, 42.45808], [1.55073, 42.43299], [1.5127, 42.42959], [1.44529, 42.43724], [1.43838, 42.47848], [1.41648, 42.48315], [1.46661, 42.50949], [1.44759, 42.54431], [1.41245, 42.53539], [1.4234, 42.55959], [1.44529, 42.56722], [1.42512, 42.58292], [1.44197, 42.60217], [1.35562, 42.71944], [1.15928, 42.71407], [1.0804, 42.78569], [0.98292, 42.78754], [0.96166, 42.80629], [0.93089, 42.79154], [0.711, 42.86372], [0.66121, 42.84021], [0.65421, 42.75872], [0.67873, 42.69458], [0.40214, 42.69779], [0.36251, 42.72282], [0.29407, 42.67431], [0.25336, 42.7174], [0.17569, 42.73424], [-0.02468, 42.68513], [-0.10519, 42.72761], [-0.16141, 42.79535], [-0.17939, 42.78974], [-0.3122, 42.84788], [-0.38833, 42.80132], [-0.41319, 42.80776], [-0.44334, 42.79939], [-0.50863, 42.82713], [-0.55497, 42.77846], [-0.67637, 42.88303], [-0.69837, 42.87945], [-0.72608, 42.89318], [-0.73422, 42.91228], [-0.72037, 42.92541], [-0.75478, 42.96916], [-0.81652, 42.95166], [-0.97133, 42.96239], [-1.00963, 42.99279], [-1.10333, 43.0059], [-1.22881, 43.05534], [-1.25244, 43.04164], [-1.30531, 43.06859], [-1.30052, 43.09581], [-1.27118, 43.11961], [-1.32209, 43.1127], [-1.34419, 43.09665], [-1.35272, 43.02658], [-1.44067, 43.047], [-1.47555, 43.08372], [-1.41562, 43.12815], [-1.3758, 43.24511], [-1.40942, 43.27272], [-1.45289, 43.27049], [-1.50992, 43.29481], [-1.55963, 43.28828], [-1.57674, 43.25269], [-1.61341, 43.25269], [-1.63052, 43.28591], [-1.62481, 43.30726], [-1.69407, 43.31378], [-1.73074, 43.29481], [-1.7397, 43.32979], [-1.75079, 43.3317], [-1.75334, 43.34107], [-1.77068, 43.34396], [-1.78714, 43.35476], [-1.78332, 43.36399], [-1.79319, 43.37497], [-1.77289, 43.38957], [-1.81005, 43.59738], [-10.14298, 44.17365], [-11.19304, 41.83075], [-8.87157, 41.86488], [-8.81794, 41.90375], [-8.75712, 41.92833], [-8.74606, 41.9469], [-8.7478, 41.96282], [-8.69071, 41.98862], [-8.6681, 41.99703], [-8.65832, 42.02972], [-8.64626, 42.03668], [-8.63791, 42.04691], [-8.59493, 42.05708], [-8.58086, 42.05147], [-8.54563, 42.0537], [-8.5252, 42.06264], [-8.52837, 42.07658], [-8.48185, 42.0811], [-8.44123, 42.08218], [-8.42512, 42.07199], [-8.40143, 42.08052], [-8.38323, 42.07683], [-8.36353, 42.09065], [-8.33912, 42.08358], [-8.32161, 42.10218], [-8.29809, 42.106], [-8.2732, 42.12396], [-8.24681, 42.13993], [-8.22406, 42.1328], [-8.1986, 42.15402], [-8.18947, 42.13853], [-8.19406, 42.12141], [-8.18178, 42.06436], [-8.11729, 42.08537], [-8.08847, 42.05767], [-8.08796, 42.01398], [-8.16232, 41.9828], [-8.2185, 41.91237], [-8.19551, 41.87459], [-8.16944, 41.87944], [-8.16455, 41.81753], [-8.0961, 41.81024], [-8.01136, 41.83453], [-7.9804, 41.87337], [-7.92336, 41.8758], [-7.90707, 41.92432], [-7.88751, 41.92553], [-7.88055, 41.84571], [-7.84188, 41.88065], [-7.69848, 41.90977], [-7.65774, 41.88308], [-7.58603, 41.87944], [-7.62188, 41.83089], [-7.52737, 41.83939], [-7.49803, 41.87095], [-7.45566, 41.86488], [-7.44759, 41.84451], [-7.42854, 41.83262], [-7.42864, 41.80589], [-7.37092, 41.85031], [-7.32366, 41.8406], [-7.18677, 41.88793], [-7.18549, 41.97515], [-7.14115, 41.98855], [-7.08574, 41.97401], [-7.07596, 41.94977], [-7.01078, 41.94977], [-6.98144, 41.9728], [-6.95537, 41.96553], [-6.94396, 41.94403], [-6.82174, 41.94493], [-6.81196, 41.99097], [-6.76959, 41.98734], [-6.75004, 41.94129], [-6.61967, 41.94008], [-6.58544, 41.96674], [-6.5447, 41.94371], [-6.56752, 41.88429], [-6.51374, 41.8758], [-6.56426, 41.74219], [-6.54633, 41.68623], [-6.49907, 41.65823], [-6.44204, 41.68258], [-6.29863, 41.66432], [-6.19128, 41.57638], [-6.26777, 41.48796], [-6.3306, 41.37677], [-6.38553, 41.38655], [-6.38551, 41.35274], [-6.55937, 41.24417], [-6.65046, 41.24725], [-6.68286, 41.21641], [-6.69711, 41.1858], [-6.77319, 41.13049], [-6.75655, 41.10187], [-6.79241, 41.05397], [-6.80942, 41.03629], [-6.84781, 41.02692], [-6.88843, 41.03027], [-6.913, 41.03922], [-6.9357, 41.02888], [-6.8527, 40.93958], [-6.84292, 40.89771], [-6.80707, 40.88047], [-6.79892, 40.84842], [-6.82337, 40.84472], [-6.82826, 40.74603], [-6.79567, 40.65955], [-6.84292, 40.56801], [-6.80218, 40.55067], [-6.7973, 40.51723], [-6.84944, 40.46394], [-6.84618, 40.42177], [-6.78426, 40.36468], [-6.80218, 40.33239], [-6.86085, 40.2976], [-6.86085, 40.26776], [-7.00426, 40.23169], [-7.02544, 40.18564], [-7.00589, 40.12087], [-6.94233, 40.10716], [-6.86737, 40.01986], [-6.91463, 39.86618], [-6.97492, 39.81488], [-7.01613, 39.66877], [-7.24707, 39.66576], [-7.33507, 39.64569], [-7.54121, 39.66717], [-7.49477, 39.58794], [-7.2927, 39.45847], [-7.3149, 39.34857], [-7.23403, 39.27579], [-7.23566, 39.20132], [-7.12811, 39.17101], [-7.14929, 39.11287], [-7.10692, 39.10275], [-7.04011, 39.11919], [-6.97004, 39.07619], [-6.95211, 39.0243], [-7.051, 38.907], [-7.03848, 38.87221], [-7.26174, 38.72107], [-7.265, 38.61674], [-7.32529, 38.44336], [-7.15581, 38.27597], [-7.09389, 38.17227], [-6.93418, 38.21454], [-7.00375, 38.01914], [-7.05966, 38.01966], [-7.10366, 38.04404], [-7.12648, 38.00296], [-7.24544, 37.98884], [-7.27314, 37.90145], [-7.33441, 37.81193], [-7.41981, 37.75729], [-7.51759, 37.56119], [-7.46878, 37.47127], [-7.43974, 37.38913], [-7.43227, 37.25152], [-7.41854, 37.23813], [-7.41133, 37.20314], [-7.39769, 37.16868], [-7.37282, 36.96896], [-7.2725, 35.73269], [-5.10878, 36.05227], [-2.27707, 35.35051], [3.75438, 42.33445]], [[-5.27801, 36.14942], [-5.34064, 36.03744], [-5.40526, 36.15488], [-5.34536, 36.15501], [-5.33822, 36.15272], [-5.27801, 36.14942]]], [[[1.99838, 42.44682], [2.01564, 42.45171], [1.99216, 42.46208], [1.98579, 42.47486], [1.99766, 42.4858], [1.98916, 42.49351], [1.98022, 42.49569], [1.97697, 42.48568], [1.97227, 42.48487], [1.97003, 42.48081], [1.96215, 42.47854], [1.95606, 42.45785], [1.96125, 42.45364], [1.98378, 42.44697], [1.99838, 42.44682]]]] } },
28957     { type: "Feature", properties: { wikidata: "Q98059339", nameEn: "Mainland Norway", country: "NO", groups: ["154", "150", "UN"], callingCodes: ["47"] }, geometry: { type: "MultiPolygon", coordinates: [[[[10.40861, 58.38489], [10.64958, 58.89391], [11.08911, 58.98745], [11.15367, 59.07862], [11.34459, 59.11672], [11.4601, 58.99022], [11.45199, 58.89604], [11.65732, 58.90177], [11.8213, 59.24985], [11.69297, 59.59442], [11.92112, 59.69531], [11.87121, 59.86039], [12.15641, 59.8926], [12.36317, 59.99259], [12.52003, 60.13846], [12.59133, 60.50559], [12.2277, 61.02442], [12.69115, 61.06584], [12.86939, 61.35427], [12.57707, 61.56547], [12.40595, 61.57226], [12.14746, 61.7147], [12.29187, 62.25699], [12.07085, 62.6297], [12.19919, 63.00104], [11.98529, 63.27487], [12.19919, 63.47935], [12.14928, 63.59373], [12.74105, 64.02171], [13.23411, 64.09087], [13.98222, 64.00953], [14.16051, 64.18725], [14.11117, 64.46674], [13.64276, 64.58402], [14.50926, 65.31786], [14.53778, 66.12399], [15.05113, 66.15572], [15.49318, 66.28509], [15.37197, 66.48217], [16.35589, 67.06419], [16.39154, 67.21653], [16.09922, 67.4364], [16.12774, 67.52106], [16.38441, 67.52923], [16.7409, 67.91037], [17.30416, 68.11591], [17.90787, 67.96537], [18.13836, 68.20874], [18.1241, 68.53721], [18.39503, 68.58672], [18.63032, 68.50849], [18.97255, 68.52416], [19.93508, 68.35911], [20.22027, 68.48759], [19.95647, 68.55546], [20.22027, 68.67246], [20.33435, 68.80174], [20.28444, 68.93283], [20.0695, 69.04469], [20.55258, 69.06069], [20.72171, 69.11874], [21.05775, 69.0356], [21.11099, 69.10291], [20.98641, 69.18809], [21.00732, 69.22755], [21.27827, 69.31281], [21.63833, 69.27485], [22.27276, 68.89514], [22.38367, 68.71561], [22.53321, 68.74393], [23.13064, 68.64684], [23.68017, 68.70276], [23.781, 68.84514], [24.02299, 68.81601], [24.18432, 68.73936], [24.74898, 68.65143], [24.90023, 68.55579], [24.93048, 68.61102], [25.10189, 68.63307], [25.12206, 68.78684], [25.42455, 68.90328], [25.61613, 68.89602], [25.75729, 68.99383], [25.69679, 69.27039], [25.96904, 69.68397], [26.40261, 69.91377], [26.64461, 69.96565], [27.05802, 69.92069], [27.57226, 70.06215], [27.95542, 70.0965], [27.97558, 69.99671], [28.32849, 69.88605], [28.36883, 69.81658], [29.12697, 69.69193], [29.31664, 69.47994], [28.8629, 69.22395], [28.81248, 69.11997], [28.91738, 69.04774], [29.0444, 69.0119], [29.26623, 69.13794], [29.27631, 69.2811], [29.97205, 69.41623], [30.16363, 69.65244], [30.52662, 69.54699], [30.95011, 69.54699], [30.84095, 69.80584], [31.59909, 70.16571], [32.07813, 72.01005], [-11.60274, 67.73467], [7.28637, 57.35913], [10.40861, 58.38489]]]] } },
28958     { type: "Feature", properties: { wikidata: "Q98543636", nameEn: "Mainland Ecuador", country: "EC", groups: ["005", "419", "019", "UN"], callingCodes: ["593"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-84.52388, -3.36941], [-80.30602, -3.39149], [-80.20647, -3.431], [-80.24123, -3.46124], [-80.24586, -3.48677], [-80.23651, -3.48652], [-80.22629, -3.501], [-80.20535, -3.51667], [-80.21642, -3.5888], [-80.19848, -3.59249], [-80.18741, -3.63994], [-80.19926, -3.68894], [-80.13232, -3.90317], [-80.46386, -4.01342], [-80.4822, -4.05477], [-80.45023, -4.20938], [-80.32114, -4.21323], [-80.46386, -4.41516], [-80.39256, -4.48269], [-80.13945, -4.29786], [-79.79722, -4.47558], [-79.59402, -4.46848], [-79.26248, -4.95167], [-79.1162, -4.97774], [-79.01659, -5.01481], [-78.85149, -4.66795], [-78.68394, -4.60754], [-78.34362, -3.38633], [-78.24589, -3.39907], [-78.22642, -3.51113], [-78.14324, -3.47653], [-78.19369, -3.36431], [-77.94147, -3.05454], [-76.6324, -2.58397], [-76.05203, -2.12179], [-75.57429, -1.55961], [-75.3872, -0.9374], [-75.22862, -0.95588], [-75.22862, -0.60048], [-75.53615, -0.19213], [-75.60169, -0.18708], [-75.61997, -0.10012], [-75.40192, -0.17196], [-75.25764, -0.11943], [-75.82927, 0.09578], [-76.23441, 0.42294], [-76.41215, 0.38228], [-76.4094, 0.24015], [-76.89177, 0.24736], [-77.52001, 0.40782], [-77.49984, 0.64476], [-77.67815, 0.73863], [-77.66416, 0.81604], [-77.68613, 0.83029], [-77.7148, 0.85003], [-77.85677, 0.80197], [-78.42749, 1.15389], [-78.87137, 1.47457], [-82.12561, 4.00341], [-84.52388, -3.36941]]]] } },
28959     { type: "Feature", properties: { m49: "001", wikidata: "Q2", nameEn: "World", aliases: ["Earth", "Planet"], level: "world" }, geometry: null },
28960     { type: "Feature", properties: { m49: "002", wikidata: "Q15", nameEn: "Africa", level: "region" }, geometry: null },
28961     { type: "Feature", properties: { m49: "003", wikidata: "Q49", nameEn: "North America", level: "subregion" }, geometry: null },
28962     { type: "Feature", properties: { m49: "005", wikidata: "Q18", nameEn: "South America", level: "intermediateRegion" }, geometry: null },
28963     { type: "Feature", properties: { m49: "009", wikidata: "Q538", nameEn: "Oceania", level: "region" }, geometry: null },
28964     { type: "Feature", properties: { m49: "011", wikidata: "Q4412", nameEn: "Western Africa", level: "intermediateRegion" }, geometry: null },
28965     { type: "Feature", properties: { m49: "013", wikidata: "Q27611", nameEn: "Central America", level: "intermediateRegion" }, geometry: null },
28966     { type: "Feature", properties: { m49: "014", wikidata: "Q27407", nameEn: "Eastern Africa", level: "intermediateRegion" }, geometry: null },
28967     { type: "Feature", properties: { m49: "015", wikidata: "Q27381", nameEn: "Northern Africa", level: "subregion" }, geometry: null },
28968     { type: "Feature", properties: { m49: "017", wikidata: "Q27433", nameEn: "Middle Africa", level: "intermediateRegion" }, geometry: null },
28969     { type: "Feature", properties: { m49: "018", wikidata: "Q27394", nameEn: "Southern Africa", level: "intermediateRegion" }, geometry: null },
28970     { type: "Feature", properties: { m49: "019", wikidata: "Q828", nameEn: "Americas", level: "region" }, geometry: null },
28971     { type: "Feature", properties: { m49: "021", wikidata: "Q2017699", nameEn: "Northern America", level: "subregion" }, geometry: null },
28972     { type: "Feature", properties: { m49: "029", wikidata: "Q664609", nameEn: "Caribbean", level: "intermediateRegion" }, geometry: null },
28973     { type: "Feature", properties: { m49: "030", wikidata: "Q27231", nameEn: "Eastern Asia", level: "subregion" }, geometry: null },
28974     { type: "Feature", properties: { m49: "034", wikidata: "Q771405", nameEn: "Southern Asia", level: "subregion" }, geometry: null },
28975     { type: "Feature", properties: { m49: "035", wikidata: "Q11708", nameEn: "South-eastern Asia", level: "subregion" }, geometry: null },
28976     { type: "Feature", properties: { m49: "039", wikidata: "Q27449", nameEn: "Southern Europe", level: "subregion" }, geometry: null },
28977     { type: "Feature", properties: { m49: "053", wikidata: "Q45256", nameEn: "Australia and New Zealand", aliases: ["Australasia"], level: "subregion" }, geometry: null },
28978     { type: "Feature", properties: { m49: "054", wikidata: "Q37394", nameEn: "Melanesia", level: "subregion" }, geometry: null },
28979     { type: "Feature", properties: { m49: "057", wikidata: "Q3359409", nameEn: "Micronesia", level: "subregion" }, geometry: null },
28980     { type: "Feature", properties: { m49: "061", wikidata: "Q35942", nameEn: "Polynesia", level: "subregion" }, geometry: null },
28981     { type: "Feature", properties: { m49: "142", wikidata: "Q48", nameEn: "Asia", level: "region" }, geometry: null },
28982     { type: "Feature", properties: { m49: "143", wikidata: "Q27275", nameEn: "Central Asia", level: "subregion" }, geometry: null },
28983     { type: "Feature", properties: { m49: "145", wikidata: "Q27293", nameEn: "Western Asia", level: "subregion" }, geometry: null },
28984     { type: "Feature", properties: { m49: "150", wikidata: "Q46", nameEn: "Europe", level: "region" }, geometry: null },
28985     { type: "Feature", properties: { m49: "151", wikidata: "Q27468", nameEn: "Eastern Europe", level: "subregion" }, geometry: null },
28986     { type: "Feature", properties: { m49: "154", wikidata: "Q27479", nameEn: "Northern Europe", level: "subregion" }, geometry: null },
28987     { type: "Feature", properties: { m49: "155", wikidata: "Q27496", nameEn: "Western Europe", level: "subregion" }, geometry: null },
28988     { type: "Feature", properties: { m49: "202", wikidata: "Q132959", nameEn: "Sub-Saharan Africa", level: "subregion" }, geometry: null },
28989     { type: "Feature", properties: { m49: "419", wikidata: "Q72829598", nameEn: "Latin America and the Caribbean", level: "subregion" }, geometry: null },
28990     { type: "Feature", properties: { m49: "830", wikidata: "Q42314", nameEn: "Channel Islands", level: "intermediateRegion" }, geometry: null },
28991     { type: "Feature", properties: { iso1A2: "AC", iso1A3: "ASC", wikidata: "Q46197", nameEn: "Ascension Island", aliases: ["SH-AC"], country: "GB", groups: ["SH", "BOTS", "011", "202", "002", "UN"], isoStatus: "excRes", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["247"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-14.82771, -8.70814], [-13.33271, -8.07391], [-14.91926, -6.63386], [-14.82771, -8.70814]]]] } },
28992     { type: "Feature", properties: { iso1A2: "AD", iso1A3: "AND", iso1N3: "020", wikidata: "Q228", nameEn: "Andorra", groups: ["Q12837", "039", "150", "UN"], callingCodes: ["376"] }, geometry: { type: "MultiPolygon", coordinates: [[[[1.72515, 42.50338], [1.73683, 42.55492], [1.7858, 42.57698], [1.72588, 42.59098], [1.73452, 42.61515], [1.68267, 42.62533], [1.6625, 42.61982], [1.63485, 42.62957], [1.60085, 42.62703], [1.55418, 42.65669], [1.50867, 42.64483], [1.48043, 42.65203], [1.46718, 42.63296], [1.47986, 42.61346], [1.44197, 42.60217], [1.42512, 42.58292], [1.44529, 42.56722], [1.4234, 42.55959], [1.41245, 42.53539], [1.44759, 42.54431], [1.46661, 42.50949], [1.41648, 42.48315], [1.43838, 42.47848], [1.44529, 42.43724], [1.5127, 42.42959], [1.55073, 42.43299], [1.55937, 42.45808], [1.57953, 42.44957], [1.58933, 42.46275], [1.65674, 42.47125], [1.66826, 42.50779], [1.70571, 42.48867], [1.72515, 42.50338]]]] } },
28993     { type: "Feature", properties: { iso1A2: "AE", iso1A3: "ARE", iso1N3: "784", wikidata: "Q878", nameEn: "United Arab Emirates", groups: ["145", "142", "UN"], callingCodes: ["971"] }, geometry: { type: "MultiPolygon", coordinates: [[[[56.26534, 25.62825], [56.25341, 25.61443], [56.26636, 25.60643], [56.25365, 25.60211], [56.20473, 25.61119], [56.18363, 25.65508], [56.14826, 25.66351], [56.13579, 25.73524], [56.17416, 25.77239], [56.13963, 25.82765], [56.19334, 25.9795], [56.15498, 26.06828], [56.08666, 26.05038], [55.81777, 26.18798], [55.14145, 25.62624], [53.97892, 24.64436], [52.82259, 25.51697], [52.35509, 25.00368], [52.02277, 24.75635], [51.83108, 24.71675], [51.58834, 24.66608], [51.41644, 24.39615], [51.58871, 24.27256], [51.59617, 24.12041], [52.56622, 22.94341], [55.13599, 22.63334], [55.2137, 22.71065], [55.22634, 23.10378], [55.57358, 23.669], [55.48677, 23.94946], [55.73301, 24.05994], [55.8308, 24.01633], [56.01799, 24.07426], [55.95472, 24.2172], [55.83367, 24.20193], [55.77658, 24.23476], [55.76558, 24.23227], [55.75257, 24.23466], [55.75382, 24.2466], [55.75939, 24.26114], [55.76781, 24.26209], [55.79145, 24.27914], [55.80747, 24.31069], [55.83395, 24.32776], [55.83271, 24.41521], [55.76461, 24.5287], [55.83271, 24.68567], [55.83408, 24.77858], [55.81348, 24.80102], [55.81116, 24.9116], [55.85094, 24.96858], [55.90849, 24.96771], [55.96316, 25.00857], [56.05715, 24.95727], [56.05106, 24.87461], [55.97467, 24.89639], [55.97836, 24.87673], [56.03535, 24.81161], [56.06128, 24.74457], [56.13684, 24.73699], [56.20062, 24.78565], [56.20568, 24.85063], [56.30269, 24.88334], [56.34873, 24.93205], [56.3227, 24.97284], [56.86325, 25.03856], [56.82555, 25.7713], [56.26534, 25.62825]], [[56.26062, 25.33108], [56.3005, 25.31815], [56.3111, 25.30107], [56.35172, 25.30681], [56.34438, 25.26653], [56.27628, 25.23404], [56.24341, 25.22867], [56.20872, 25.24104], [56.20838, 25.25668], [56.24465, 25.27505], [56.25008, 25.28843], [56.23362, 25.31253], [56.26062, 25.33108]]], [[[56.28423, 25.26344], [56.29379, 25.2754], [56.28102, 25.28486], [56.2716, 25.27916], [56.27086, 25.26128], [56.28423, 25.26344]]]] } },
28994     { type: "Feature", properties: { iso1A2: "AF", iso1A3: "AFG", iso1N3: "004", wikidata: "Q889", nameEn: "Afghanistan", groups: ["034", "142", "UN"], callingCodes: ["93"] }, geometry: { type: "MultiPolygon", coordinates: [[[[70.61526, 38.34774], [70.60407, 38.28046], [70.54673, 38.24541], [70.4898, 38.12546], [70.17206, 37.93276], [70.1863, 37.84296], [70.27694, 37.81258], [70.28243, 37.66706], [70.15015, 37.52519], [69.95971, 37.5659], [69.93362, 37.61378], [69.84435, 37.60616], [69.80041, 37.5746], [69.51888, 37.5844], [69.44954, 37.4869], [69.36645, 37.40462], [69.45022, 37.23315], [69.39529, 37.16752], [69.25152, 37.09426], [69.03274, 37.25174], [68.96407, 37.32603], [68.88168, 37.33368], [68.91189, 37.26704], [68.80889, 37.32494], [68.81438, 37.23862], [68.6798, 37.27906], [68.61851, 37.19815], [68.41888, 37.13906], [68.41201, 37.10402], [68.29253, 37.10621], [68.27605, 37.00977], [68.18542, 37.02074], [68.02194, 36.91923], [67.87917, 37.0591], [67.7803, 37.08978], [67.78329, 37.1834], [67.51868, 37.26102], [67.2581, 37.17216], [67.2224, 37.24545], [67.13039, 37.27168], [67.08232, 37.35469], [66.95598, 37.40162], [66.64699, 37.32958], [66.55743, 37.35409], [66.30993, 37.32409], [65.72274, 37.55438], [65.64137, 37.45061], [65.64263, 37.34388], [65.51778, 37.23881], [64.97945, 37.21913], [64.61141, 36.6351], [64.62514, 36.44311], [64.57295, 36.34362], [64.43288, 36.24401], [64.05385, 36.10433], [63.98519, 36.03773], [63.56496, 35.95106], [63.53475, 35.90881], [63.29579, 35.85985], [63.12276, 35.86208], [63.10318, 35.81782], [63.23262, 35.67487], [63.10079, 35.63024], [63.12276, 35.53196], [63.0898, 35.43131], [62.90853, 35.37086], [62.74098, 35.25432], [62.62288, 35.22067], [62.48006, 35.28796], [62.29878, 35.13312], [62.29191, 35.25964], [62.15871, 35.33278], [62.05709, 35.43803], [61.97743, 35.4604], [61.77693, 35.41341], [61.58742, 35.43803], [61.27371, 35.61482], [61.18187, 35.30249], [61.0991, 35.27845], [61.12831, 35.09938], [61.06926, 34.82139], [61.00197, 34.70631], [60.99922, 34.63064], [60.72316, 34.52857], [60.91321, 34.30411], [60.66502, 34.31539], [60.50209, 34.13992], [60.5838, 33.80793], [60.5485, 33.73422], [60.57762, 33.59772], [60.69573, 33.56054], [60.91133, 33.55596], [60.88908, 33.50219], [60.56485, 33.12944], [60.86191, 32.22565], [60.84541, 31.49561], [61.70929, 31.37391], [61.80569, 31.16167], [61.80957, 31.12576], [61.83257, 31.0452], [61.8335, 30.97669], [61.78268, 30.92724], [61.80829, 30.84224], [60.87231, 29.86514], [62.47751, 29.40782], [63.5876, 29.50456], [64.12966, 29.39157], [64.19796, 29.50407], [64.62116, 29.58903], [65.04005, 29.53957], [66.24175, 29.85181], [66.36042, 29.9583], [66.23609, 30.06321], [66.34869, 30.404], [66.28413, 30.57001], [66.39194, 30.9408], [66.42645, 30.95309], [66.58175, 30.97532], [66.68166, 31.07597], [66.72561, 31.20526], [66.83273, 31.26867], [67.04147, 31.31561], [67.03323, 31.24519], [67.29964, 31.19586], [67.78854, 31.33203], [67.7748, 31.4188], [67.62374, 31.40473], [67.58323, 31.52772], [67.72056, 31.52304], [67.86887, 31.63536], [68.00071, 31.6564], [68.1655, 31.82691], [68.25614, 31.80357], [68.27605, 31.75863], [68.44222, 31.76446], [68.57475, 31.83158], [68.6956, 31.75687], [68.79997, 31.61665], [68.91078, 31.59687], [68.95995, 31.64822], [69.00939, 31.62249], [69.11514, 31.70782], [69.20577, 31.85957], [69.3225, 31.93186], [69.27032, 32.14141], [69.27932, 32.29119], [69.23599, 32.45946], [69.2868, 32.53938], [69.38155, 32.56601], [69.44747, 32.6678], [69.43649, 32.7302], [69.38018, 32.76601], [69.47082, 32.85834], [69.5436, 32.8768], [69.49854, 32.88843], [69.49004, 33.01509], [69.57656, 33.09911], [69.71526, 33.09911], [69.79766, 33.13247], [69.85259, 33.09451], [70.02563, 33.14282], [70.07369, 33.22557], [70.13686, 33.21064], [70.32775, 33.34496], [70.17062, 33.53535], [70.20141, 33.64387], [70.14785, 33.6553], [70.14236, 33.71701], [70.00503, 33.73528], [69.85671, 33.93719], [69.87307, 33.9689], [69.90203, 34.04194], [70.54336, 33.9463], [70.88119, 33.97933], [71.07345, 34.06242], [71.06933, 34.10564], [71.09307, 34.11961], [71.09453, 34.13524], [71.13078, 34.16503], [71.12815, 34.26619], [71.17662, 34.36769], [71.02401, 34.44835], [71.0089, 34.54568], [71.11602, 34.63047], [71.08718, 34.69034], [71.28356, 34.80882], [71.29472, 34.87728], [71.50329, 34.97328], [71.49917, 35.00478], [71.55273, 35.02615], [71.52938, 35.09023], [71.67495, 35.21262], [71.5541, 35.28776], [71.54294, 35.31037], [71.65435, 35.4479], [71.49917, 35.6267], [71.55273, 35.71483], [71.37969, 35.95865], [71.19505, 36.04134], [71.60491, 36.39429], [71.80267, 36.49924], [72.18135, 36.71838], [72.6323, 36.84601], [73.82685, 36.91421], [74.04856, 36.82648], [74.43389, 37.00977], [74.53739, 36.96224], [74.56453, 37.03023], [74.49981, 37.24518], [74.80605, 37.21565], [74.88887, 37.23275], [74.8294, 37.3435], [74.68383, 37.3948], [74.56161, 37.37734], [74.41055, 37.3948], [74.23339, 37.41116], [74.20308, 37.34208], [73.8564, 37.26158], [73.82552, 37.22659], [73.64974, 37.23643], [73.61129, 37.27469], [73.76647, 37.33913], [73.77197, 37.4417], [73.29633, 37.46495], [73.06884, 37.31729], [72.79693, 37.22222], [72.66381, 37.02014], [72.54095, 37.00007], [72.31676, 36.98115], [71.83229, 36.68084], [71.67083, 36.67346], [71.57195, 36.74943], [71.51502, 36.89128], [71.48481, 36.93218], [71.46923, 36.99925], [71.45578, 37.03094], [71.43097, 37.05855], [71.44127, 37.11856], [71.4494, 37.18137], [71.4555, 37.21418], [71.47386, 37.2269], [71.48339, 37.23937], [71.4824, 37.24921], [71.48536, 37.26017], [71.50674, 37.31502], [71.49821, 37.31975], [71.4862, 37.33405], [71.47685, 37.40281], [71.49612, 37.4279], [71.5256, 37.47971], [71.50616, 37.50733], [71.49693, 37.53527], [71.5065, 37.60912], [71.51972, 37.61945], [71.54186, 37.69691], [71.55234, 37.73209], [71.53053, 37.76534], [71.54324, 37.77104], [71.55752, 37.78677], [71.59255, 37.79956], [71.58843, 37.92425], [71.51565, 37.95349], [71.32871, 37.88564], [71.296, 37.93403], [71.2809, 37.91995], [71.24969, 37.93031], [71.27278, 37.96496], [71.27622, 37.99946], [71.28922, 38.01272], [71.29878, 38.04429], [71.36444, 38.15358], [71.37803, 38.25641], [71.33869, 38.27335], [71.33114, 38.30339], [71.21291, 38.32797], [71.1451, 38.40106], [71.10957, 38.40671], [71.10592, 38.42077], [71.09542, 38.42517], [71.0556, 38.40176], [71.03545, 38.44779], [70.98693, 38.48862], [70.92728, 38.43021], [70.88719, 38.46826], [70.84376, 38.44688], [70.82538, 38.45394], [70.81697, 38.44507], [70.80521, 38.44447], [70.79766, 38.44944], [70.78702, 38.45031], [70.78581, 38.45502], [70.77132, 38.45548], [70.75455, 38.4252], [70.72485, 38.4131], [70.69807, 38.41861], [70.67438, 38.40597], [70.6761, 38.39144], [70.69189, 38.37031], [70.64966, 38.34999], [70.61526, 38.34774]]]] } },
28995     { type: "Feature", properties: { iso1A2: "AG", iso1A3: "ATG", iso1N3: "028", wikidata: "Q781", nameEn: "Antigua and Barbuda", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 268"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-61.66959, 18.6782], [-62.58307, 16.68909], [-62.1023, 16.97277], [-61.23098, 16.62484], [-61.66959, 18.6782]]]] } },
28996     { type: "Feature", properties: { iso1A2: "AI", iso1A3: "AIA", iso1N3: "660", wikidata: "Q25228", nameEn: "Anguilla", country: "GB", groups: ["BOTS", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 264"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.79029, 19.11219], [-63.35989, 18.06012], [-62.62718, 18.26185], [-63.79029, 19.11219]]]] } },
28997     { type: "Feature", properties: { iso1A2: "AL", iso1A3: "ALB", iso1N3: "008", wikidata: "Q222", nameEn: "Albania", groups: ["039", "150", "UN"], callingCodes: ["355"] }, geometry: { type: "MultiPolygon", coordinates: [[[[20.07761, 42.55582], [20.01834, 42.54622], [20.00842, 42.5109], [19.9324, 42.51699], [19.82333, 42.46581], [19.76549, 42.50237], [19.74731, 42.57422], [19.77375, 42.58517], [19.73244, 42.66299], [19.65972, 42.62774], [19.4836, 42.40831], [19.42352, 42.36546], [19.42, 42.33019], [19.28623, 42.17745], [19.40687, 42.10024], [19.37548, 42.06835], [19.36867, 42.02564], [19.37691, 41.96977], [19.34601, 41.95675], [19.33812, 41.90669], [19.37451, 41.8842], [19.37597, 41.84849], [19.26406, 41.74971], [19.0384, 40.35325], [19.95905, 39.82857], [19.97622, 39.78684], [19.92466, 39.69533], [19.98042, 39.6504], [20.00957, 39.69227], [20.05189, 39.69112], [20.12956, 39.65805], [20.15988, 39.652], [20.22376, 39.64532], [20.22707, 39.67459], [20.27412, 39.69884], [20.31961, 39.72799], [20.29152, 39.80421], [20.30804, 39.81563], [20.38572, 39.78516], [20.41475, 39.81437], [20.41546, 39.82832], [20.31135, 39.99438], [20.37911, 39.99058], [20.42373, 40.06777], [20.48487, 40.06271], [20.51297, 40.08168], [20.55593, 40.06524], [20.61081, 40.07866], [20.62566, 40.0897], [20.67162, 40.09433], [20.71789, 40.27739], [20.78234, 40.35803], [20.7906, 40.42726], [20.83688, 40.47882], [20.94925, 40.46625], [20.96908, 40.51526], [21.03932, 40.56299], [21.05833, 40.66586], [20.98134, 40.76046], [20.95752, 40.76982], [20.98396, 40.79109], [20.97887, 40.85475], [20.97693, 40.90103], [20.94305, 40.92399], [20.83671, 40.92752], [20.81567, 40.89662], [20.73504, 40.9081], [20.71634, 40.91781], [20.65558, 41.08009], [20.63454, 41.0889], [20.59832, 41.09066], [20.58546, 41.11179], [20.59715, 41.13644], [20.51068, 41.2323], [20.49432, 41.33679], [20.52119, 41.34381], [20.55976, 41.4087], [20.51301, 41.442], [20.49039, 41.49277], [20.45331, 41.51436], [20.45809, 41.5549], [20.52103, 41.56473], [20.55508, 41.58113], [20.51769, 41.65975], [20.52937, 41.69292], [20.51301, 41.72433], [20.53405, 41.78099], [20.57144, 41.7897], [20.55976, 41.87068], [20.59524, 41.8818], [20.57946, 41.91593], [20.63069, 41.94913], [20.59434, 42.03879], [20.55633, 42.08173], [20.56955, 42.12097], [20.48857, 42.25444], [20.3819, 42.3029], [20.34479, 42.32656], [20.24399, 42.32168], [20.21797, 42.41237], [20.17127, 42.50469], [20.07761, 42.55582]]]] } },
28998     { type: "Feature", properties: { iso1A2: "AM", iso1A3: "ARM", iso1N3: "051", wikidata: "Q399", nameEn: "Armenia", groups: ["145", "142", "UN"], callingCodes: ["374"] }, geometry: { type: "MultiPolygon", coordinates: [[[[45.0133, 41.29747], [44.93493, 41.25685], [44.81437, 41.30371], [44.80053, 41.25949], [44.81749, 41.23488], [44.84358, 41.23088], [44.89911, 41.21366], [44.87887, 41.20195], [44.82084, 41.21513], [44.72814, 41.20338], [44.61462, 41.24018], [44.59322, 41.1933], [44.46791, 41.18204], [44.34417, 41.2382], [44.34337, 41.20312], [44.32139, 41.2079], [44.18148, 41.24644], [44.16591, 41.19141], [43.84835, 41.16329], [43.74717, 41.1117], [43.67712, 41.13398], [43.4717, 41.12611], [43.44984, 41.0988], [43.47319, 41.02251], [43.58683, 40.98961], [43.67712, 40.93084], [43.67712, 40.84846], [43.74872, 40.7365], [43.7425, 40.66805], [43.63664, 40.54159], [43.54791, 40.47413], [43.60862, 40.43267], [43.59928, 40.34019], [43.71136, 40.16673], [43.65221, 40.14889], [43.65688, 40.11199], [43.92307, 40.01787], [44.1057, 40.03555], [44.1778, 40.02845], [44.26973, 40.04866], [44.46635, 39.97733], [44.61845, 39.8281], [44.75779, 39.7148], [44.88354, 39.74432], [44.92869, 39.72157], [45.06604, 39.79277], [45.18554, 39.67846], [45.17464, 39.58614], [45.21784, 39.58074], [45.23535, 39.61373], [45.30385, 39.61373], [45.29606, 39.57654], [45.46992, 39.49888], [45.70547, 39.60174], [45.80804, 39.56716], [45.83, 39.46487], [45.79225, 39.3695], [45.99774, 39.28931], [46.02303, 39.09978], [46.06973, 39.0744], [46.14785, 38.84206], [46.20601, 38.85262], [46.34059, 38.92076], [46.53497, 38.86548], [46.51805, 38.94982], [46.54296, 39.07078], [46.44022, 39.19636], [46.52584, 39.18912], [46.54141, 39.15895], [46.58032, 39.21204], [46.63481, 39.23013], [46.56476, 39.24942], [46.50093, 39.33736], [46.43244, 39.35181], [46.37795, 39.42039], [46.4013, 39.45405], [46.53051, 39.47809], [46.51027, 39.52373], [46.57721, 39.54414], [46.57098, 39.56694], [46.52117, 39.58734], [46.42465, 39.57534], [46.40286, 39.63651], [46.18493, 39.60533], [45.96543, 39.78859], [45.82533, 39.82925], [45.7833, 39.9475], [45.60895, 39.97733], [45.59806, 40.0131], [45.78642, 40.03218], [45.83779, 39.98925], [45.97944, 40.181], [45.95609, 40.27846], [45.65098, 40.37696], [45.42994, 40.53804], [45.45484, 40.57707], [45.35366, 40.65979], [45.4206, 40.7424], [45.55914, 40.78366], [45.60584, 40.87436], [45.40814, 40.97904], [45.44083, 41.01663], [45.39725, 41.02603], [45.35677, 40.99784], [45.28859, 41.03757], [45.26162, 41.0228], [45.25897, 41.0027], [45.1994, 41.04518], [45.16493, 41.05068], [45.1634, 41.08082], [45.1313, 41.09369], [45.12923, 41.06059], [45.06784, 41.05379], [45.08028, 41.10917], [45.19942, 41.13299], [45.1969, 41.168], [45.11811, 41.19967], [45.05201, 41.19211], [45.02932, 41.2101], [45.05497, 41.2464], [45.0133, 41.29747]], [[45.21324, 40.9817], [45.21219, 40.99001], [45.20518, 40.99348], [45.19312, 40.98998], [45.18382, 41.0066], [45.20625, 41.01484], [45.23487, 41.00226], [45.23095, 40.97828], [45.21324, 40.9817]], [[45.00864, 41.03411], [44.9903, 41.05657], [44.96031, 41.06345], [44.95383, 41.07553], [44.97169, 41.09176], [45.00864, 41.09407], [45.03406, 41.07931], [45.04517, 41.06653], [45.03792, 41.03938], [45.00864, 41.03411]]], [[[45.50279, 40.58424], [45.56071, 40.64765], [45.51825, 40.67382], [45.47927, 40.65023], [45.50279, 40.58424]]]] } },
28999     { type: "Feature", properties: { iso1A2: "AO", iso1A3: "AGO", iso1N3: "024", wikidata: "Q916", nameEn: "Angola", groups: ["017", "202", "002", "UN"], callingCodes: ["244"] }, geometry: { type: "MultiPolygon", coordinates: [[[[16.55507, -5.85631], [13.04371, -5.87078], [12.42245, -6.07585], [11.95767, -5.94705], [12.20376, -5.76338], [12.26557, -5.74031], [12.52318, -5.74353], [12.52301, -5.17481], [12.53599, -5.1618], [12.53586, -5.14658], [12.51589, -5.1332], [12.49815, -5.14058], [12.46297, -5.09408], [12.60251, -5.01715], [12.63465, -4.94632], [12.70868, -4.95505], [12.8733, -4.74346], [13.11195, -4.67745], [13.09648, -4.63739], [12.91489, -4.47907], [12.87096, -4.40315], [12.76844, -4.38709], [12.64835, -4.55937], [12.40964, -4.60609], [12.32324, -4.78415], [12.25587, -4.79437], [12.20901, -4.75642], [12.16068, -4.90089], [12.00924, -5.02627], [11.50888, -5.33417], [10.5065, -17.25284], [11.75063, -17.25013], [12.07076, -17.15165], [12.52111, -17.24495], [12.97145, -16.98567], [13.36212, -16.98048], [13.95896, -17.43141], [14.28743, -17.38814], [18.39229, -17.38927], [18.84226, -17.80375], [21.14283, -17.94318], [21.42741, -18.02787], [23.47474, -17.62877], [23.20038, -17.47563], [22.17217, -16.50269], [22.00323, -16.18028], [21.97988, -13.00148], [24.03339, -12.99091], [23.90937, -12.844], [24.06672, -12.29058], [23.98804, -12.13149], [24.02603, -11.15368], [24.00027, -10.89356], [23.86868, -11.02856], [23.45631, -10.946], [23.16602, -11.10577], [22.54205, -11.05784], [22.25951, -11.24911], [22.17954, -10.85884], [22.32604, -10.76291], [22.19039, -9.94628], [21.84856, -9.59871], [21.79824, -7.29628], [20.56263, -7.28566], [20.61689, -6.90876], [20.31846, -6.91953], [20.30218, -6.98955], [19.5469, -7.00195], [19.33698, -7.99743], [18.33635, -8.00126], [17.5828, -8.13784], [16.96282, -7.21787], [16.55507, -5.85631]]]] } },
29000     { type: "Feature", properties: { iso1A2: "AQ", iso1A3: "ATA", iso1N3: "010", wikidata: "Q51", nameEn: "Antarctica", level: "region", callingCodes: ["672"] }, geometry: { type: "MultiPolygon", coordinates: [[[[180, -60], [-180, -60], [-180, -90], [180, -90], [180, -60]]]] } },
29001     { type: "Feature", properties: { iso1A2: "AR", iso1A3: "ARG", iso1N3: "032", wikidata: "Q414", nameEn: "Argentina", aliases: ["RA"], groups: ["005", "419", "019", "UN"], callingCodes: ["54"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-72.31343, -50.58411], [-72.33873, -51.59954], [-71.99889, -51.98018], [-69.97824, -52.00845], [-68.41683, -52.33516], [-68.60702, -52.65781], [-68.60733, -54.9125], [-68.01394, -54.8753], [-67.46182, -54.92205], [-67.11046, -54.94199], [-66.07313, -55.19618], [-63.67376, -55.11859], [-54.78916, -36.21945], [-57.83001, -34.69099], [-58.34425, -34.15035], [-58.44442, -33.84033], [-58.40475, -33.11777], [-58.1224, -32.98842], [-58.22362, -32.52416], [-58.10036, -32.25338], [-58.20252, -31.86966], [-58.00076, -31.65016], [-58.0023, -31.53084], [-58.07569, -31.44916], [-57.98127, -31.3872], [-57.9908, -31.34924], [-57.86729, -31.06352], [-57.89476, -30.95994], [-57.8024, -30.77193], [-57.89115, -30.49572], [-57.64859, -30.35095], [-57.61478, -30.25165], [-57.65132, -30.19229], [-57.09386, -29.74211], [-56.81251, -29.48154], [-56.62789, -29.18073], [-56.57295, -29.11357], [-56.54171, -29.11447], [-56.05265, -28.62651], [-56.00458, -28.60421], [-56.01729, -28.51223], [-55.65418, -28.18304], [-55.6262, -28.17124], [-55.33303, -27.94661], [-55.16872, -27.86224], [-55.1349, -27.89759], [-54.90805, -27.73149], [-54.90159, -27.63132], [-54.67657, -27.57214], [-54.50416, -27.48232], [-54.41888, -27.40882], [-54.19268, -27.30751], [-54.19062, -27.27639], [-54.15978, -27.2889], [-53.80144, -27.09844], [-53.73372, -26.6131], [-53.68269, -26.33359], [-53.64505, -26.28089], [-53.64186, -26.25976], [-53.64632, -26.24798], [-53.63881, -26.25075], [-53.63739, -26.2496], [-53.65237, -26.23289], [-53.65018, -26.19501], [-53.73968, -26.10012], [-53.73391, -26.07006], [-53.7264, -26.0664], [-53.73086, -26.05842], [-53.73511, -26.04211], [-53.83691, -25.94849], [-53.90831, -25.55513], [-54.52926, -25.62846], [-54.5502, -25.58915], [-54.59398, -25.59224], [-54.62063, -25.91213], [-54.60664, -25.9691], [-54.67359, -25.98607], [-54.69333, -26.37705], [-54.70732, -26.45099], [-54.80868, -26.55669], [-55.00584, -26.78754], [-55.06351, -26.80195], [-55.16948, -26.96068], [-55.25243, -26.93808], [-55.39611, -26.97679], [-55.62322, -27.1941], [-55.59094, -27.32444], [-55.74475, -27.44485], [-55.89195, -27.3467], [-56.18313, -27.29851], [-56.85337, -27.5165], [-58.04205, -27.2387], [-58.59549, -27.29973], [-58.65321, -27.14028], [-58.3198, -26.83443], [-58.1188, -26.16704], [-57.87176, -25.93604], [-57.57431, -25.47269], [-57.80821, -25.13863], [-58.25492, -24.92528], [-58.33055, -24.97099], [-59.33886, -24.49935], [-59.45482, -24.34787], [-60.03367, -24.00701], [-60.28163, -24.04436], [-60.99754, -23.80934], [-61.0782, -23.62932], [-61.9756, -23.0507], [-62.22768, -22.55807], [-62.51761, -22.37684], [-62.64455, -22.25091], [-62.8078, -22.12534], [-62.81124, -21.9987], [-63.66482, -21.99918], [-63.68113, -22.0544], [-63.70963, -21.99934], [-63.93287, -21.99934], [-64.22918, -22.55807], [-64.31489, -22.88824], [-64.35108, -22.73282], [-64.4176, -22.67692], [-64.58888, -22.25035], [-64.67174, -22.18957], [-64.90014, -22.12136], [-64.99524, -22.08255], [-65.47435, -22.08908], [-65.57743, -22.07675], [-65.58694, -22.09794], [-65.61166, -22.09504], [-65.7467, -22.10105], [-65.9261, -21.93335], [-66.04832, -21.9187], [-66.03836, -21.84829], [-66.24077, -21.77837], [-66.29714, -22.08741], [-66.7298, -22.23644], [-67.18382, -22.81525], [-66.99632, -22.99839], [-67.33563, -24.04237], [-68.24825, -24.42596], [-68.56909, -24.69831], [-68.38372, -25.08636], [-68.57622, -25.32505], [-68.38372, -26.15353], [-68.56909, -26.28146], [-68.59048, -26.49861], [-68.27677, -26.90626], [-68.43363, -27.08414], [-68.77586, -27.16029], [-69.22504, -27.95042], [-69.66709, -28.44055], [-69.80969, -29.07185], [-69.99507, -29.28351], [-69.8596, -30.26131], [-70.14479, -30.36595], [-70.55832, -31.51559], [-69.88099, -33.34489], [-69.87386, -34.13344], [-70.49416, -35.24145], [-70.38008, -36.02375], [-70.95047, -36.4321], [-71.24279, -37.20264], [-70.89532, -38.6923], [-71.37826, -38.91474], [-71.92726, -40.72714], [-71.74901, -42.11711], [-72.15541, -42.15941], [-72.14828, -42.85321], [-71.64206, -43.64774], [-71.81318, -44.38097], [-71.16436, -44.46244], [-71.26418, -44.75684], [-72.06985, -44.81756], [-71.35687, -45.22075], [-71.75614, -45.61611], [-71.68577, -46.55385], [-71.94152, -47.13595], [-72.50478, -47.80586], [-72.27662, -48.28727], [-72.54042, -48.52392], [-72.56894, -48.81116], [-73.09655, -49.14342], [-73.45156, -49.79461], [-73.55259, -49.92488], [-73.15765, -50.78337], [-72.31343, -50.58411]]]] } },
29002     { type: "Feature", properties: { iso1A2: "AS", iso1A3: "ASM", iso1N3: "016", wikidata: "Q16641", nameEn: "American Samoa", aliases: ["US-AS"], country: "US", groups: ["Q1352230", "061", "009", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 684"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-171.39864, -10.21587], [-170.99605, -15.1275], [-166.32598, -15.26169], [-171.39864, -10.21587]]]] } },
29003     { type: "Feature", properties: { iso1A2: "AT", iso1A3: "AUT", iso1N3: "040", wikidata: "Q40", nameEn: "Austria", groups: ["EU", "155", "150", "UN"], callingCodes: ["43"] }, geometry: { type: "MultiPolygon", coordinates: [[[[15.34823, 48.98444], [15.28305, 48.98831], [15.26177, 48.95766], [15.16358, 48.94278], [15.15534, 48.99056], [14.99878, 49.01444], [14.97612, 48.96983], [14.98917, 48.90082], [14.95072, 48.79101], [14.98032, 48.77959], [14.9782, 48.7766], [14.98112, 48.77524], [14.9758, 48.76857], [14.95641, 48.75915], [14.94773, 48.76268], [14.81545, 48.7874], [14.80821, 48.77711], [14.80584, 48.73489], [14.72756, 48.69502], [14.71794, 48.59794], [14.66762, 48.58215], [14.60808, 48.62881], [14.56139, 48.60429], [14.4587, 48.64695], [14.43076, 48.58855], [14.33909, 48.55852], [14.20691, 48.5898], [14.09104, 48.5943], [14.01482, 48.63788], [14.06151, 48.66873], [13.84023, 48.76988], [13.82266, 48.75544], [13.81863, 48.73257], [13.79337, 48.71375], [13.81791, 48.69832], [13.81283, 48.68426], [13.81901, 48.6761], [13.82609, 48.62345], [13.80038, 48.59487], [13.80519, 48.58026], [13.76921, 48.55324], [13.7513, 48.5624], [13.74816, 48.53058], [13.72802, 48.51208], [13.66113, 48.53558], [13.65186, 48.55092], [13.62508, 48.55501], [13.59705, 48.57013], [13.57535, 48.55912], [13.51291, 48.59023], [13.50131, 48.58091], [13.50663, 48.57506], [13.46967, 48.55157], [13.45214, 48.56472], [13.43695, 48.55776], [13.45727, 48.51092], [13.42527, 48.45711], [13.43929, 48.43386], [13.40709, 48.37292], [13.30897, 48.31575], [13.26039, 48.29422], [13.18093, 48.29577], [13.126, 48.27867], [13.0851, 48.27711], [13.02083, 48.25689], [12.95306, 48.20629], [12.87126, 48.20318], [12.84475, 48.16556], [12.836, 48.1647], [12.8362, 48.15876], [12.82673, 48.15245], [12.80676, 48.14979], [12.78595, 48.12445], [12.7617, 48.12796], [12.74973, 48.10885], [12.76141, 48.07373], [12.8549, 48.01122], [12.87476, 47.96195], [12.91683, 47.95647], [12.9211, 47.95135], [12.91985, 47.94069], [12.92668, 47.93879], [12.93419, 47.94063], [12.93642, 47.94436], [12.93886, 47.94046], [12.94163, 47.92927], [13.00588, 47.84374], [12.98543, 47.82896], [12.96311, 47.79957], [12.93202, 47.77302], [12.94371, 47.76281], [12.9353, 47.74788], [12.91711, 47.74026], [12.90274, 47.72513], [12.91333, 47.7178], [12.92969, 47.71094], [12.98578, 47.7078], [13.01382, 47.72116], [13.07692, 47.68814], [13.09562, 47.63304], [13.06407, 47.60075], [13.06641, 47.58577], [13.04537, 47.58183], [13.05355, 47.56291], [13.03252, 47.53373], [13.04537, 47.49426], [12.9998, 47.46267], [12.98344, 47.48716], [12.9624, 47.47452], [12.85256, 47.52741], [12.84672, 47.54556], [12.80699, 47.54477], [12.77427, 47.58025], [12.82101, 47.61493], [12.76492, 47.64485], [12.77777, 47.66689], [12.7357, 47.6787], [12.6071, 47.6741], [12.57438, 47.63238], [12.53816, 47.63553], [12.50076, 47.62293], [12.44117, 47.6741], [12.43883, 47.6977], [12.37222, 47.68433], [12.336, 47.69534], [12.27991, 47.68827], [12.26004, 47.67725], [12.24017, 47.69534], [12.26238, 47.73544], [12.2542, 47.7433], [12.22571, 47.71776], [12.18303, 47.70065], [12.16217, 47.70105], [12.16769, 47.68167], [12.18347, 47.66663], [12.18507, 47.65984], [12.19895, 47.64085], [12.20801, 47.61082], [12.20398, 47.60667], [12.18568, 47.6049], [12.17737, 47.60121], [12.18145, 47.61019], [12.17824, 47.61506], [12.13734, 47.60639], [12.05788, 47.61742], [12.02282, 47.61033], [12.0088, 47.62451], [11.85572, 47.60166], [11.84052, 47.58354], [11.63934, 47.59202], [11.60681, 47.57881], [11.58811, 47.55515], [11.58578, 47.52281], [11.52618, 47.50939], [11.4362, 47.51413], [11.38128, 47.47465], [11.4175, 47.44621], [11.33804, 47.44937], [11.29597, 47.42566], [11.27844, 47.39956], [11.22002, 47.3964], [11.25157, 47.43277], [11.20482, 47.43198], [11.12536, 47.41222], [11.11835, 47.39719], [10.97111, 47.39561], [10.97111, 47.41617], [10.98513, 47.42882], [10.92437, 47.46991], [10.93839, 47.48018], [10.90918, 47.48571], [10.87061, 47.4786], [10.86945, 47.5015], [10.91268, 47.51334], [10.88814, 47.53701], [10.77596, 47.51729], [10.7596, 47.53228], [10.6965, 47.54253], [10.68832, 47.55752], [10.63456, 47.5591], [10.60337, 47.56755], [10.56912, 47.53584], [10.48849, 47.54057], [10.47329, 47.58552], [10.43473, 47.58394], [10.44992, 47.5524], [10.4324, 47.50111], [10.44291, 47.48453], [10.46278, 47.47901], [10.47446, 47.43318], [10.4359, 47.41183], [10.4324, 47.38494], [10.39851, 47.37623], [10.33424, 47.30813], [10.23257, 47.27088], [10.17531, 47.27167], [10.17648, 47.29149], [10.2147, 47.31014], [10.19998, 47.32832], [10.23757, 47.37609], [10.22774, 47.38904], [10.2127, 47.38019], [10.17648, 47.38889], [10.16362, 47.36674], [10.11805, 47.37228], [10.09819, 47.35724], [10.06897, 47.40709], [10.1052, 47.4316], [10.09001, 47.46005], [10.07131, 47.45531], [10.03859, 47.48927], [10.00003, 47.48216], [9.96029, 47.53899], [9.92407, 47.53111], [9.87733, 47.54688], [9.87499, 47.52953], [9.8189, 47.54688], [9.82591, 47.58158], [9.80254, 47.59419], [9.76748, 47.5934], [9.72736, 47.53457], [9.55125, 47.53629], [9.56312, 47.49495], [9.58208, 47.48344], [9.59482, 47.46305], [9.60205, 47.46165], [9.60484, 47.46358], [9.60841, 47.47178], [9.62158, 47.45858], [9.62475, 47.45685], [9.6423, 47.45599], [9.65728, 47.45383], [9.65863, 47.44847], [9.64483, 47.43842], [9.6446, 47.43233], [9.65043, 47.41937], [9.65136, 47.40504], [9.6629, 47.39591], [9.67334, 47.39191], [9.67445, 47.38429], [9.6711, 47.37824], [9.66243, 47.37136], [9.65427, 47.36824], [9.62476, 47.36639], [9.59978, 47.34671], [9.58513, 47.31334], [9.55857, 47.29919], [9.54773, 47.2809], [9.53116, 47.27029], [9.56766, 47.24281], [9.55176, 47.22585], [9.56981, 47.21926], [9.58264, 47.20673], [9.56539, 47.17124], [9.62623, 47.14685], [9.63395, 47.08443], [9.61216, 47.07732], [9.60717, 47.06091], [9.87935, 47.01337], [9.88266, 46.93343], [9.98058, 46.91434], [10.10715, 46.84296], [10.22675, 46.86942], [10.24128, 46.93147], [10.30031, 46.92093], [10.36933, 47.00212], [10.48376, 46.93891], [10.47197, 46.85698], [10.54783, 46.84505], [10.66405, 46.87614], [10.75753, 46.82258], [10.72974, 46.78972], [11.00764, 46.76896], [11.10618, 46.92966], [11.33355, 46.99862], [11.50739, 47.00644], [11.74789, 46.98484], [12.19254, 47.09331], [12.21781, 47.03996], [12.11675, 47.01241], [12.2006, 46.88854], [12.27591, 46.88651], [12.38708, 46.71529], [12.59992, 46.6595], [12.94445, 46.60401], [13.27627, 46.56059], [13.64088, 46.53438], [13.7148, 46.5222], [13.89837, 46.52331], [14.00422, 46.48474], [14.04002, 46.49117], [14.12097, 46.47724], [14.15989, 46.43327], [14.28326, 46.44315], [14.314, 46.43327], [14.42608, 46.44614], [14.45877, 46.41717], [14.52176, 46.42617], [14.56463, 46.37208], [14.5942, 46.43434], [14.66892, 46.44936], [14.72185, 46.49974], [14.81836, 46.51046], [14.83549, 46.56614], [14.86419, 46.59411], [14.87129, 46.61], [14.92283, 46.60848], [14.96002, 46.63459], [14.98024, 46.6009], [15.01451, 46.641], [15.14215, 46.66131], [15.23711, 46.63994], [15.41235, 46.65556], [15.45514, 46.63697], [15.46906, 46.61321], [15.54431, 46.6312], [15.55333, 46.64988], [15.54533, 46.66985], [15.59826, 46.68908], [15.62317, 46.67947], [15.63255, 46.68069], [15.6365, 46.6894], [15.6543, 46.69228], [15.6543, 46.70616], [15.67411, 46.70735], [15.69523, 46.69823], [15.72279, 46.69548], [15.73823, 46.70011], [15.76771, 46.69863], [15.78518, 46.70712], [15.8162, 46.71897], [15.87691, 46.7211], [15.94864, 46.68769], [15.98512, 46.68463], [15.99988, 46.67947], [16.04036, 46.6549], [16.04347, 46.68694], [16.02808, 46.71094], [15.99769, 46.7266], [15.98432, 46.74991], [15.99126, 46.78199], [15.99054, 46.82772], [16.05786, 46.83927], [16.10983, 46.867], [16.19904, 46.94134], [16.22403, 46.939], [16.27594, 46.9643], [16.28202, 47.00159], [16.51369, 47.00084], [16.43936, 47.03548], [16.52176, 47.05747], [16.46134, 47.09395], [16.52863, 47.13974], [16.44932, 47.14418], [16.46442, 47.16845], [16.4523, 47.18812], [16.42801, 47.18422], [16.41739, 47.20649], [16.43663, 47.21127], [16.44142, 47.25079], [16.47782, 47.25918], [16.45104, 47.41181], [16.49908, 47.39416], [16.52414, 47.41007], [16.57152, 47.40868], [16.6718, 47.46139], [16.64821, 47.50155], [16.71059, 47.52692], [16.64193, 47.63114], [16.58699, 47.61772], [16.4222, 47.66537], [16.55129, 47.72268], [16.53514, 47.73837], [16.54779, 47.75074], [16.61183, 47.76171], [16.65679, 47.74197], [16.72089, 47.73469], [16.7511, 47.67878], [16.82938, 47.68432], [16.86509, 47.72268], [16.87538, 47.68895], [17.08893, 47.70928], [17.05048, 47.79377], [17.07039, 47.81129], [17.00997, 47.86245], [17.08275, 47.87719], [17.11022, 47.92461], [17.09786, 47.97336], [17.16001, 48.00636], [17.07039, 48.0317], [17.09168, 48.09366], [17.05735, 48.14179], [17.02919, 48.13996], [16.97701, 48.17385], [16.89461, 48.31332], [16.90903, 48.32519], [16.84243, 48.35258], [16.83317, 48.38138], [16.83588, 48.3844], [16.8497, 48.38321], [16.85204, 48.44968], [16.94611, 48.53614], [16.93955, 48.60371], [16.90354, 48.71541], [16.79779, 48.70998], [16.71883, 48.73806], [16.68518, 48.7281], [16.67008, 48.77699], [16.46134, 48.80865], [16.40915, 48.74576], [16.37345, 48.729], [16.06034, 48.75436], [15.84404, 48.86921], [15.78087, 48.87644], [15.75341, 48.8516], [15.6921, 48.85973], [15.61622, 48.89541], [15.51357, 48.91549], [15.48027, 48.94481], [15.34823, 48.98444]]]] } },
29004     { type: "Feature", properties: { iso1A2: "AU", iso1A3: "AUS", iso1N3: "036", wikidata: "Q408", nameEn: "Australia" }, geometry: null },
29005     { type: "Feature", properties: { iso1A2: "AW", iso1A3: "ABW", iso1N3: "533", wikidata: "Q21203", nameEn: "Aruba", aliases: ["NL-AW"], country: "NL", groups: ["Q1451600", "029", "003", "419", "019", "UN"], callingCodes: ["297"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-70.00823, 12.98375], [-70.35625, 12.58277], [-69.60231, 12.17], [-70.00823, 12.98375]]]] } },
29006     { type: "Feature", properties: { iso1A2: "AX", iso1A3: "ALA", iso1N3: "248", wikidata: "Q5689", nameEn: "\xC5land Islands", country: "FI", groups: ["EU", "154", "150", "UN"], callingCodes: ["358 18", "358 457"] }, geometry: { type: "MultiPolygon", coordinates: [[[[19.08191, 60.19152], [20.5104, 59.15546], [21.35468, 59.67511], [21.02509, 60.12142], [21.08159, 60.20167], [21.15143, 60.54555], [20.96741, 60.71528], [19.23413, 60.61414], [19.08191, 60.19152]]]] } },
29007     { type: "Feature", properties: { iso1A2: "AZ", iso1A3: "AZE", iso1N3: "031", wikidata: "Q227", nameEn: "Azerbaijan", groups: ["145", "142", "UN"], callingCodes: ["994"] }, geometry: { type: "MultiPolygon", coordinates: [[[[46.42738, 41.91323], [46.3984, 41.84399], [46.30863, 41.79133], [46.23962, 41.75811], [46.20538, 41.77205], [46.17891, 41.72094], [46.19759, 41.62327], [46.24429, 41.59883], [46.26531, 41.63339], [46.28182, 41.60089], [46.3253, 41.60912], [46.34039, 41.5947], [46.34126, 41.57454], [46.29794, 41.5724], [46.33925, 41.4963], [46.40307, 41.48464], [46.4669, 41.43331], [46.63658, 41.37727], [46.72375, 41.28609], [46.66148, 41.20533], [46.63969, 41.09515], [46.55096, 41.1104], [46.48558, 41.0576], [46.456, 41.09984], [46.37661, 41.10805], [46.27698, 41.19011], [46.13221, 41.19479], [45.95786, 41.17956], [45.80842, 41.2229], [45.69946, 41.29545], [45.75705, 41.35157], [45.71035, 41.36208], [45.68389, 41.3539], [45.45973, 41.45898], [45.4006, 41.42402], [45.31352, 41.47168], [45.26285, 41.46433], [45.1797, 41.42231], [45.09867, 41.34065], [45.0133, 41.29747], [45.05497, 41.2464], [45.02932, 41.2101], [45.05201, 41.19211], [45.11811, 41.19967], [45.1969, 41.168], [45.19942, 41.13299], [45.08028, 41.10917], [45.06784, 41.05379], [45.12923, 41.06059], [45.1313, 41.09369], [45.1634, 41.08082], [45.16493, 41.05068], [45.1994, 41.04518], [45.25897, 41.0027], [45.26162, 41.0228], [45.28859, 41.03757], [45.35677, 40.99784], [45.39725, 41.02603], [45.44083, 41.01663], [45.40814, 40.97904], [45.60584, 40.87436], [45.55914, 40.78366], [45.4206, 40.7424], [45.35366, 40.65979], [45.45484, 40.57707], [45.42994, 40.53804], [45.65098, 40.37696], [45.95609, 40.27846], [45.97944, 40.181], [45.83779, 39.98925], [45.78642, 40.03218], [45.59806, 40.0131], [45.60895, 39.97733], [45.7833, 39.9475], [45.82533, 39.82925], [45.96543, 39.78859], [46.18493, 39.60533], [46.40286, 39.63651], [46.42465, 39.57534], [46.52117, 39.58734], [46.57098, 39.56694], [46.57721, 39.54414], [46.51027, 39.52373], [46.53051, 39.47809], [46.4013, 39.45405], [46.37795, 39.42039], [46.43244, 39.35181], [46.50093, 39.33736], [46.56476, 39.24942], [46.63481, 39.23013], [46.58032, 39.21204], [46.54141, 39.15895], [46.52584, 39.18912], [46.44022, 39.19636], [46.54296, 39.07078], [46.51805, 38.94982], [46.53497, 38.86548], [46.75752, 39.03231], [46.83822, 39.13143], [46.92539, 39.16644], [46.95341, 39.13505], [47.05771, 39.20143], [47.05927, 39.24846], [47.31301, 39.37492], [47.38978, 39.45999], [47.50099, 39.49615], [47.84774, 39.66285], [47.98977, 39.70999], [48.34264, 39.42935], [48.37385, 39.37584], [48.15984, 39.30028], [48.12404, 39.25208], [48.15361, 39.19419], [48.31239, 39.09278], [48.33884, 39.03022], [48.28437, 38.97186], [48.08627, 38.94434], [48.07734, 38.91616], [48.01409, 38.90333], [48.02581, 38.82705], [48.24773, 38.71883], [48.3146, 38.59958], [48.45084, 38.61013], [48.58793, 38.45076], [48.62217, 38.40198], [48.70001, 38.40564], [48.78979, 38.45026], [48.81072, 38.44853], [48.84969, 38.45015], [48.88288, 38.43975], [52.39847, 39.43556], [48.80971, 41.95365], [48.5867, 41.84306], [48.55078, 41.77917], [48.42301, 41.65444], [48.40277, 41.60441], [48.2878, 41.56221], [48.22064, 41.51472], [48.07587, 41.49957], [47.87973, 41.21798], [47.75831, 41.19455], [47.62288, 41.22969], [47.54504, 41.20275], [47.49004, 41.26366], [47.34579, 41.27884], [47.10762, 41.59044], [47.03757, 41.55434], [46.99554, 41.59743], [47.00955, 41.63583], [46.8134, 41.76252], [46.75269, 41.8623], [46.58924, 41.80547], [46.5332, 41.87389], [46.42738, 41.91323]], [[45.50279, 40.58424], [45.47927, 40.65023], [45.51825, 40.67382], [45.56071, 40.64765], [45.50279, 40.58424]]], [[[45.00864, 41.03411], [45.03792, 41.03938], [45.04517, 41.06653], [45.03406, 41.07931], [45.00864, 41.09407], [44.97169, 41.09176], [44.95383, 41.07553], [44.96031, 41.06345], [44.9903, 41.05657], [45.00864, 41.03411]]], [[[45.21324, 40.9817], [45.23095, 40.97828], [45.23487, 41.00226], [45.20625, 41.01484], [45.18382, 41.0066], [45.19312, 40.98998], [45.20518, 40.99348], [45.21219, 40.99001], [45.21324, 40.9817]]], [[[45.46992, 39.49888], [45.29606, 39.57654], [45.30385, 39.61373], [45.23535, 39.61373], [45.21784, 39.58074], [45.17464, 39.58614], [45.18554, 39.67846], [45.06604, 39.79277], [44.92869, 39.72157], [44.88354, 39.74432], [44.75779, 39.7148], [44.80977, 39.65768], [44.81043, 39.62677], [44.88916, 39.59653], [44.96746, 39.42998], [45.05932, 39.36435], [45.08751, 39.35052], [45.16168, 39.21952], [45.30489, 39.18333], [45.40148, 39.09007], [45.40452, 39.07224], [45.44811, 39.04927], [45.44966, 38.99243], [45.6131, 38.964], [45.6155, 38.94304], [45.65172, 38.95199], [45.83883, 38.90768], [45.90266, 38.87739], [45.94624, 38.89072], [46.00228, 38.87376], [46.06766, 38.87861], [46.14785, 38.84206], [46.06973, 39.0744], [46.02303, 39.09978], [45.99774, 39.28931], [45.79225, 39.3695], [45.83, 39.46487], [45.80804, 39.56716], [45.70547, 39.60174], [45.46992, 39.49888]]]] } },
29008     { type: "Feature", properties: { iso1A2: "BA", iso1A3: "BIH", iso1N3: "070", wikidata: "Q225", nameEn: "Bosnia and Herzegovina", groups: ["039", "150", "UN"], callingCodes: ["387"] }, geometry: { type: "MultiPolygon", coordinates: [[[[17.84826, 45.04489], [17.66571, 45.13408], [17.59104, 45.10816], [17.51469, 45.10791], [17.47589, 45.12656], [17.45615, 45.12523], [17.4498, 45.16119], [17.41229, 45.13335], [17.33573, 45.14521], [17.32092, 45.16246], [17.26815, 45.18444], [17.25131, 45.14957], [17.24325, 45.146], [17.18438, 45.14764], [17.0415, 45.20759], [16.9385, 45.22742], [16.92405, 45.27607], [16.83804, 45.18951], [16.81137, 45.18434], [16.78219, 45.19002], [16.74845, 45.20393], [16.64962, 45.20714], [16.60194, 45.23042], [16.56559, 45.22307], [16.5501, 45.2212], [16.52982, 45.22713], [16.49155, 45.21153], [16.4634, 45.14522], [16.40023, 45.1147], [16.38309, 45.05955], [16.38219, 45.05139], [16.3749, 45.05206], [16.35863, 45.03529], [16.35404, 45.00241], [16.29036, 44.99732], [16.12153, 45.09616], [15.98412, 45.23088], [15.83512, 45.22459], [15.76371, 45.16508], [15.78842, 45.11519], [15.74585, 45.0638], [15.78568, 44.97401], [15.74723, 44.96818], [15.76096, 44.87045], [15.79472, 44.8455], [15.72584, 44.82334], [15.8255, 44.71501], [15.89348, 44.74964], [16.05828, 44.61538], [16.00884, 44.58605], [16.03012, 44.55572], [16.10566, 44.52586], [16.16814, 44.40679], [16.12969, 44.38275], [16.21346, 44.35231], [16.18688, 44.27012], [16.36864, 44.08263], [16.43662, 44.07523], [16.43629, 44.02826], [16.50528, 44.0244], [16.55472, 43.95326], [16.70922, 43.84887], [16.75316, 43.77157], [16.80736, 43.76011], [17.00585, 43.58037], [17.15828, 43.49376], [17.24411, 43.49376], [17.29699, 43.44542], [17.25579, 43.40353], [17.286, 43.33065], [17.46986, 43.16559], [17.64268, 43.08595], [17.70879, 42.97223], [17.5392, 42.92787], [17.6444, 42.88641], [17.68151, 42.92725], [17.7948, 42.89556], [17.80854, 42.9182], [17.88201, 42.83668], [18.24318, 42.6112], [18.36197, 42.61423], [18.43735, 42.55921], [18.49778, 42.58409], [18.53751, 42.57376], [18.55504, 42.58409], [18.52232, 42.62279], [18.57373, 42.64429], [18.54841, 42.68328], [18.54603, 42.69171], [18.55221, 42.69045], [18.56789, 42.72074], [18.47324, 42.74992], [18.45921, 42.81682], [18.47633, 42.85829], [18.4935, 42.86433], [18.49661, 42.89306], [18.49076, 42.95553], [18.52232, 43.01451], [18.66254, 43.03928], [18.64735, 43.14766], [18.66605, 43.2056], [18.71747, 43.2286], [18.6976, 43.25243], [18.76538, 43.29838], [18.85342, 43.32426], [18.84794, 43.33735], [18.83912, 43.34795], [18.90911, 43.36383], [18.95819, 43.32899], [18.95001, 43.29327], [19.00844, 43.24988], [19.04233, 43.30008], [19.08206, 43.29668], [19.08673, 43.31453], [19.04071, 43.397], [19.01078, 43.43854], [18.96053, 43.45042], [18.95469, 43.49367], [18.91379, 43.50299], [19.01078, 43.55806], [19.04934, 43.50384], [19.13933, 43.5282], [19.15685, 43.53943], [19.22807, 43.5264], [19.24774, 43.53061], [19.2553, 43.5938], [19.33426, 43.58833], [19.36653, 43.60921], [19.41941, 43.54056], [19.42696, 43.57987], [19.50455, 43.58385], [19.5176, 43.71403], [19.3986, 43.79668], [19.23465, 43.98764], [19.24363, 44.01502], [19.38439, 43.96611], [19.52515, 43.95573], [19.56498, 43.99922], [19.61836, 44.01464], [19.61991, 44.05254], [19.57467, 44.04716], [19.55999, 44.06894], [19.51167, 44.08158], [19.47321, 44.1193], [19.48386, 44.14332], [19.47338, 44.15034], [19.43905, 44.13088], [19.40927, 44.16722], [19.3588, 44.18353], [19.34773, 44.23244], [19.32464, 44.27185], [19.26945, 44.26957], [19.23306, 44.26097], [19.20508, 44.2917], [19.18328, 44.28383], [19.16741, 44.28648], [19.13332, 44.31492], [19.13556, 44.338], [19.11547, 44.34218], [19.1083, 44.3558], [19.11865, 44.36712], [19.10298, 44.36924], [19.10365, 44.37795], [19.10704, 44.38249], [19.10749, 44.39421], [19.11785, 44.40313], [19.14681, 44.41463], [19.14837, 44.45253], [19.12278, 44.50132], [19.13369, 44.52521], [19.16699, 44.52197], [19.26388, 44.65412], [19.32543, 44.74058], [19.36722, 44.88164], [19.18183, 44.92055], [19.01994, 44.85493], [18.8704, 44.85097], [18.76347, 44.90669], [18.76369, 44.93707], [18.80661, 44.93561], [18.78357, 44.97741], [18.65723, 45.07544], [18.47939, 45.05871], [18.41896, 45.11083], [18.32077, 45.1021], [18.24387, 45.13699], [18.1624, 45.07654], [18.03121, 45.12632], [18.01594, 45.15163], [17.99479, 45.14958], [17.97834, 45.13831], [17.97336, 45.12245], [17.93706, 45.08016], [17.87148, 45.04645], [17.84826, 45.04489]]]] } },
29009     { type: "Feature", properties: { iso1A2: "BB", iso1A3: "BRB", iso1N3: "052", wikidata: "Q244", nameEn: "Barbados", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", callingCodes: ["1 246"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-58.56442, 13.24471], [-59.80731, 13.87556], [-59.82929, 12.70644], [-58.56442, 13.24471]]]] } },
29010     { type: "Feature", properties: { iso1A2: "BD", iso1A3: "BGD", iso1N3: "050", wikidata: "Q902", nameEn: "Bangladesh", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["880"] }, geometry: { type: "MultiPolygon", coordinates: [[[[89.15869, 26.13708], [89.08899, 26.38845], [88.95612, 26.4564], [88.92357, 26.40711], [88.91321, 26.37984], [89.05328, 26.2469], [88.85004, 26.23211], [88.78961, 26.31093], [88.67837, 26.26291], [88.69485, 26.38353], [88.62144, 26.46783], [88.4298, 26.54489], [88.41196, 26.63837], [88.33093, 26.48929], [88.35153, 26.45241], [88.36938, 26.48683], [88.48749, 26.45855], [88.51649, 26.35923], [88.35153, 26.29123], [88.34757, 26.22216], [88.1844, 26.14417], [88.16581, 26.0238], [88.08804, 25.91334], [88.13138, 25.78773], [88.242, 25.80811], [88.45103, 25.66245], [88.4559, 25.59227], [88.677, 25.46959], [88.81296, 25.51546], [88.85278, 25.34679], [89.01105, 25.30303], [89.00463, 25.26583], [88.94067, 25.18534], [88.44766, 25.20149], [88.46277, 25.07468], [88.33917, 24.86803], [88.27325, 24.88796], [88.21832, 24.96642], [88.14004, 24.93529], [88.15515, 24.85806], [88.00683, 24.66477], [88.08786, 24.63232], [88.12296, 24.51301], [88.50934, 24.32474], [88.68801, 24.31464], [88.74841, 24.1959], [88.6976, 24.14703], [88.73743, 23.91751], [88.66189, 23.87607], [88.58087, 23.87105], [88.56507, 23.64044], [88.74841, 23.47361], [88.79351, 23.50535], [88.79254, 23.46028], [88.71133, 23.2492], [88.99148, 23.21134], [88.86377, 23.08759], [88.88327, 23.03885], [88.87063, 22.95235], [88.96713, 22.83346], [88.9151, 22.75228], [88.94614, 22.66941], [88.9367, 22.58527], [89.07114, 22.15335], [89.08044, 21.41871], [92.47409, 20.38654], [92.26071, 21.05697], [92.17752, 21.17445], [92.20087, 21.337], [92.37939, 21.47764], [92.43158, 21.37025], [92.55105, 21.3856], [92.60187, 21.24615], [92.68152, 21.28454], [92.59775, 21.6092], [92.62187, 21.87037], [92.60949, 21.97638], [92.56616, 22.13554], [92.60029, 22.1522], [92.5181, 22.71441], [92.37665, 22.9435], [92.38214, 23.28705], [92.26541, 23.70392], [92.15417, 23.73409], [92.04706, 23.64229], [91.95093, 23.73284], [91.95642, 23.47361], [91.84789, 23.42235], [91.76417, 23.26619], [91.81634, 23.08001], [91.7324, 23.00043], [91.61571, 22.93929], [91.54993, 23.01051], [91.46615, 23.2328], [91.4035, 23.27522], [91.40848, 23.07117], [91.36453, 23.06612], [91.28293, 23.37538], [91.15579, 23.6599], [91.25192, 23.83463], [91.22308, 23.89616], [91.29587, 24.0041], [91.35741, 23.99072], [91.37414, 24.10693], [91.55542, 24.08687], [91.63782, 24.1132], [91.65292, 24.22095], [91.73257, 24.14703], [91.76004, 24.23848], [91.82596, 24.22345], [91.89258, 24.14674], [91.96603, 24.3799], [92.11662, 24.38997], [92.15796, 24.54435], [92.25854, 24.9191], [92.38626, 24.86055], [92.49887, 24.88796], [92.39147, 25.01471], [92.33957, 25.07593], [92.0316, 25.1834], [91.63648, 25.12846], [91.25517, 25.20677], [90.87427, 25.15799], [90.65042, 25.17788], [90.40034, 25.1534], [90.1155, 25.22686], [89.90478, 25.31038], [89.87629, 25.28337], [89.83371, 25.29548], [89.84086, 25.31854], [89.81208, 25.37244], [89.86129, 25.61714], [89.84388, 25.70042], [89.80585, 25.82489], [89.86592, 25.93115], [89.77728, 26.04254], [89.77865, 26.08387], [89.73581, 26.15818], [89.70201, 26.15138], [89.63968, 26.22595], [89.57101, 25.9682], [89.53515, 26.00382], [89.35953, 26.0077], [89.15869, 26.13708]]]] } },
29011     { type: "Feature", properties: { iso1A2: "BE", iso1A3: "BEL", iso1N3: "056", wikidata: "Q31", nameEn: "Belgium", groups: ["EU", "155", "150", "UN"], callingCodes: ["32"] }, geometry: { type: "MultiPolygon", coordinates: [[[[4.93295, 51.44945], [4.93909, 51.44632], [4.9524, 51.45014], [4.95244, 51.45207], [4.93295, 51.44945]]], [[[4.91493, 51.4353], [4.92652, 51.43329], [4.92952, 51.42984], [4.93986, 51.43064], [4.94265, 51.44003], [4.93471, 51.43861], [4.93416, 51.44185], [4.94025, 51.44193], [4.93544, 51.44634], [4.92879, 51.44161], [4.92815, 51.43856], [4.92566, 51.44273], [4.92811, 51.4437], [4.92287, 51.44741], [4.91811, 51.44621], [4.92227, 51.44252], [4.91935, 51.43634], [4.91493, 51.4353]]], [[[4.82946, 51.4213], [4.82409, 51.44736], [4.84139, 51.4799], [4.78803, 51.50284], [4.77321, 51.50529], [4.74578, 51.48937], [4.72935, 51.48424], [4.65442, 51.42352], [4.57489, 51.4324], [4.53521, 51.4243], [4.52846, 51.45002], [4.54675, 51.47265], [4.5388, 51.48184], [4.47736, 51.4778], [4.38122, 51.44905], [4.39747, 51.43316], [4.38064, 51.41965], [4.43777, 51.36989], [4.39292, 51.35547], [4.34086, 51.35738], [4.33265, 51.37687], [4.21923, 51.37443], [4.24024, 51.35371], [4.16721, 51.29348], [4.05165, 51.24171], [4.01957, 51.24504], [3.97889, 51.22537], [3.90125, 51.20371], [3.78783, 51.2151], [3.78999, 51.25766], [3.58939, 51.30064], [3.51502, 51.28697], [3.52698, 51.2458], [3.43488, 51.24135], [3.41704, 51.25933], [3.38289, 51.27331], [3.35847, 51.31572], [3.38696, 51.33436], [3.36263, 51.37112], [2.56575, 51.85301], [2.18458, 51.52087], [2.55904, 51.07014], [2.57551, 51.00326], [2.63074, 50.94746], [2.59093, 50.91751], [2.63331, 50.81457], [2.71165, 50.81295], [2.81056, 50.71773], [2.8483, 50.72276], [2.86985, 50.7033], [2.87937, 50.70298], [2.88504, 50.70656], [2.90069, 50.69263], [2.91036, 50.6939], [2.90873, 50.702], [2.95019, 50.75138], [2.96778, 50.75242], [3.00537, 50.76588], [3.04314, 50.77674], [3.09163, 50.77717], [3.10614, 50.78303], [3.11206, 50.79416], [3.11987, 50.79188], [3.1257, 50.78603], [3.15017, 50.79031], [3.16476, 50.76843], [3.18339, 50.74981], [3.18811, 50.74025], [3.20064, 50.73547], [3.19017, 50.72569], [3.20845, 50.71662], [3.22042, 50.71019], [3.24593, 50.71389], [3.26063, 50.70086], [3.26141, 50.69151], [3.2536, 50.68977], [3.264, 50.67668], [3.23951, 50.6585], [3.2729, 50.60718], [3.28575, 50.52724], [3.37693, 50.49538], [3.44629, 50.51009], [3.47385, 50.53397], [3.51564, 50.5256], [3.49509, 50.48885], [3.5683, 50.50192], [3.58361, 50.49049], [3.61014, 50.49568], [3.64426, 50.46275], [3.66153, 50.45165], [3.67494, 50.40239], [3.67262, 50.38663], [3.65709, 50.36873], [3.66976, 50.34563], [3.71009, 50.30305], [3.70987, 50.3191], [3.73911, 50.34809], [3.84314, 50.35219], [3.90781, 50.32814], [3.96771, 50.34989], [4.0268, 50.35793], [4.0689, 50.3254], [4.10237, 50.31247], [4.10957, 50.30234], [4.11954, 50.30425], [4.13665, 50.25609], [4.16808, 50.25786], [4.15524, 50.2833], [4.17347, 50.28838], [4.17861, 50.27443], [4.20651, 50.27333], [4.21945, 50.25539], [4.15524, 50.21103], [4.16014, 50.19239], [4.13561, 50.13078], [4.20147, 50.13535], [4.23101, 50.06945], [4.16294, 50.04719], [4.13508, 50.01976], [4.14239, 49.98034], [4.20532, 49.95803], [4.31963, 49.97043], [4.35051, 49.95315], [4.43488, 49.94122], [4.51098, 49.94659], [4.5414, 49.96911], [4.68695, 49.99685], [4.70064, 50.09384], [4.75237, 50.11314], [4.82438, 50.16878], [4.83279, 50.15331], [4.88602, 50.15182], [4.8382, 50.06738], [4.78827, 49.95609], [4.88529, 49.9236], [4.85134, 49.86457], [4.86965, 49.82271], [4.85464, 49.78995], [4.96714, 49.79872], [5.09249, 49.76193], [5.14545, 49.70287], [5.26232, 49.69456], [5.31465, 49.66846], [5.33039, 49.6555], [5.30214, 49.63055], [5.3137, 49.61225], [5.33851, 49.61599], [5.34837, 49.62889], [5.3974, 49.61596], [5.43713, 49.5707], [5.46734, 49.52648], [5.46541, 49.49825], [5.55001, 49.52729], [5.60909, 49.51228], [5.64505, 49.55146], [5.75649, 49.54321], [5.7577, 49.55915], [5.77435, 49.56298], [5.79195, 49.55228], [5.81838, 49.54777], [5.84143, 49.5533], [5.84692, 49.55663], [5.8424, 49.56082], [5.87256, 49.57539], [5.86986, 49.58756], [5.84971, 49.58674], [5.84826, 49.5969], [5.8762, 49.60898], [5.87609, 49.62047], [5.88393, 49.62802], [5.88552, 49.63507], [5.90599, 49.63853], [5.90164, 49.6511], [5.9069, 49.66377], [5.86175, 49.67862], [5.86527, 49.69291], [5.88677, 49.70951], [5.86503, 49.72739], [5.84193, 49.72161], [5.82562, 49.72395], [5.83149, 49.74729], [5.82245, 49.75048], [5.78871, 49.7962], [5.75409, 49.79239], [5.74953, 49.81428], [5.74364, 49.82058], [5.74844, 49.82435], [5.7404, 49.83452], [5.74076, 49.83823], [5.74975, 49.83933], [5.74953, 49.84709], [5.75884, 49.84811], [5.74567, 49.85368], [5.75861, 49.85631], [5.75269, 49.8711], [5.78415, 49.87922], [5.73621, 49.89796], [5.77314, 49.93646], [5.77291, 49.96056], [5.80833, 49.96451], [5.81163, 49.97142], [5.83467, 49.97823], [5.83968, 49.9892], [5.82331, 49.99662], [5.81866, 50.01286], [5.8551, 50.02683], [5.86904, 50.04614], [5.85474, 50.06342], [5.8857, 50.07824], [5.89488, 50.11476], [5.95929, 50.13295], [5.96453, 50.17259], [6.02488, 50.18283], [6.03093, 50.16362], [6.06406, 50.15344], [6.08577, 50.17246], [6.12028, 50.16374], [6.1137, 50.13668], [6.1379, 50.12964], [6.15298, 50.14126], [6.14132, 50.14971], [6.14588, 50.17106], [6.18739, 50.1822], [6.18364, 50.20815], [6.16853, 50.2234], [6.208, 50.25179], [6.28797, 50.27458], [6.29949, 50.30887], [6.32488, 50.32333], [6.35701, 50.31139], [6.40641, 50.32425], [6.40785, 50.33557], [6.3688, 50.35898], [6.34406, 50.37994], [6.36852, 50.40776], [6.37219, 50.45397], [6.34005, 50.46083], [6.3465, 50.48833], [6.30809, 50.50058], [6.26637, 50.50272], [6.22335, 50.49578], [6.20599, 50.52089], [6.19193, 50.5212], [6.18716, 50.52653], [6.19579, 50.5313], [6.19735, 50.53576], [6.17802, 50.54179], [6.17739, 50.55875], [6.20281, 50.56952], [6.22581, 50.5907], [6.24005, 50.58732], [6.24888, 50.59869], [6.2476, 50.60392], [6.26957, 50.62444], [6.17852, 50.6245], [6.11707, 50.72231], [6.04428, 50.72861], [6.0406, 50.71848], [6.0326, 50.72647], [6.03889, 50.74618], [6.01976, 50.75398], [5.97545, 50.75441], [5.95942, 50.7622], [5.89132, 50.75124], [5.89129, 50.75125], [5.88734, 50.77092], [5.84888, 50.75448], [5.84548, 50.76542], [5.80673, 50.7558], [5.77513, 50.78308], [5.76533, 50.78159], [5.74356, 50.7691], [5.73904, 50.75674], [5.72216, 50.76398], [5.69469, 50.75529], [5.68091, 50.75804], [5.70107, 50.7827], [5.68995, 50.79641], [5.70118, 50.80764], [5.65259, 50.82309], [5.64009, 50.84742], [5.64504, 50.87107], [5.67886, 50.88142], [5.69858, 50.91046], [5.71626, 50.90796], [5.72644, 50.91167], [5.72545, 50.92312], [5.74644, 50.94723], [5.75927, 50.95601], [5.74752, 50.96202], [5.72875, 50.95428], [5.71864, 50.96092], [5.76242, 50.99703], [5.77688, 51.02483], [5.75961, 51.03113], [5.77258, 51.06196], [5.79835, 51.05834], [5.79903, 51.09371], [5.82921, 51.09328], [5.83226, 51.10585], [5.8109, 51.10861], [5.80798, 51.11661], [5.85508, 51.14445], [5.82564, 51.16753], [5.77697, 51.1522], [5.77735, 51.17845], [5.74617, 51.18928], [5.70344, 51.1829], [5.65528, 51.18736], [5.65145, 51.19788], [5.5603, 51.22249], [5.5569, 51.26544], [5.515, 51.29462], [5.48476, 51.30053], [5.46519, 51.2849], [5.4407, 51.28169], [5.41672, 51.26248], [5.347, 51.27502], [5.33886, 51.26314], [5.29716, 51.26104], [5.26461, 51.26693], [5.23814, 51.26064], [5.22542, 51.26888], [5.24244, 51.30495], [5.2002, 51.32243], [5.16222, 51.31035], [5.13377, 51.31592], [5.13105, 51.34791], [5.07102, 51.39469], [5.10456, 51.43163], [5.07891, 51.4715], [5.04774, 51.47022], [5.03281, 51.48679], [5.0106, 51.47167], [5.00393, 51.44406], [4.92152, 51.39487], [4.90016, 51.41404], [4.84988, 51.41502], [4.78941, 51.41102], [4.77229, 51.41337], [4.76577, 51.43046], [4.78314, 51.43319], [4.82946, 51.4213]]]] } },
29012     { type: "Feature", properties: { iso1A2: "BF", iso1A3: "BFA", iso1N3: "854", wikidata: "Q965", nameEn: "Burkina Faso", groups: ["011", "202", "002", "UN"], callingCodes: ["226"] }, geometry: { type: "MultiPolygon", coordinates: [[[[0.23859, 15.00135], [0.06588, 14.96961], [-0.24673, 15.07805], [-0.72004, 15.08655], [-1.05875, 14.7921], [-1.32166, 14.72774], [-1.68083, 14.50023], [-1.97945, 14.47709], [-1.9992, 14.19011], [-2.10223, 14.14878], [-2.47587, 14.29671], [-2.66175, 14.14713], [-2.84667, 14.05532], [-2.90831, 13.81174], [-2.88189, 13.64921], [-3.26407, 13.70699], [-3.28396, 13.5422], [-3.23599, 13.29035], [-3.43507, 13.27272], [-3.4313, 13.1588], [-3.54454, 13.1781], [-3.7911, 13.36665], [-3.96282, 13.38164], [-3.90558, 13.44375], [-3.96501, 13.49778], [-4.34477, 13.12927], [-4.21819, 12.95722], [-4.238, 12.71467], [-4.47356, 12.71252], [-4.41412, 12.31922], [-4.57703, 12.19875], [-4.54841, 12.1385], [-4.62546, 12.13204], [-4.62987, 12.06531], [-4.70692, 12.06746], [-4.72893, 12.01579], [-5.07897, 11.97918], [-5.26389, 11.84778], [-5.40258, 11.8327], [-5.26389, 11.75728], [-5.29251, 11.61715], [-5.22867, 11.60421], [-5.20665, 11.43811], [-5.25509, 11.36905], [-5.25949, 11.24816], [-5.32553, 11.21578], [-5.32994, 11.13371], [-5.49284, 11.07538], [-5.41579, 10.84628], [-5.47083, 10.75329], [-5.46643, 10.56074], [-5.51058, 10.43177], [-5.39602, 10.2929], [-5.12465, 10.29788], [-4.96453, 9.99923], [-4.96621, 9.89132], [-4.6426, 9.70696], [-4.31392, 9.60062], [-4.25999, 9.76012], [-3.69703, 9.94279], [-3.31779, 9.91125], [-3.27228, 9.84981], [-3.19306, 9.93781], [-3.16609, 9.85147], [-3.00765, 9.74019], [-2.93012, 9.57403], [-2.76494, 9.40778], [-2.68802, 9.49343], [-2.76534, 9.56589], [-2.74174, 9.83172], [-2.83108, 10.40252], [-2.94232, 10.64281], [-2.83373, 11.0067], [-0.67143, 10.99811], [-0.61937, 10.91305], [-0.44298, 11.04292], [-0.42391, 11.11661], [-0.38219, 11.12596], [-0.35955, 11.07801], [-0.28566, 11.12713], [-0.27374, 11.17157], [-0.13493, 11.14075], [0.50388, 11.01011], [0.48852, 10.98561], [0.50521, 10.98035], [0.4958, 10.93269], [0.66104, 10.99964], [0.91245, 10.99597], [0.9813, 11.08876], [1.03409, 11.04719], [1.42823, 11.46822], [2.00988, 11.42227], [2.29983, 11.68254], [2.39723, 11.89473], [2.05785, 12.35539], [2.26349, 12.41915], [0.99167, 13.10727], [0.99253, 13.37515], [1.18873, 13.31771], [1.21217, 13.37853], [1.24516, 13.33968], [1.28509, 13.35488], [1.24429, 13.39373], [1.20088, 13.38951], [1.02813, 13.46635], [0.99514, 13.5668], [0.77637, 13.64442], [0.77377, 13.6866], [0.61924, 13.68491], [0.38051, 14.05575], [0.16936, 14.51654], [0.23859, 15.00135]]]] } },
29013     { type: "Feature", properties: { iso1A2: "BG", iso1A3: "BGR", iso1N3: "100", wikidata: "Q219", nameEn: "Bulgaria", groups: ["EU", "151", "150", "UN"], callingCodes: ["359"] }, geometry: { type: "MultiPolygon", coordinates: [[[[23.05288, 43.79494], [22.85314, 43.84452], [22.83753, 43.88055], [22.87873, 43.9844], [23.01674, 44.01946], [23.04988, 44.07694], [22.67173, 44.21564], [22.61711, 44.16938], [22.61688, 44.06534], [22.41449, 44.00514], [22.35558, 43.81281], [22.41043, 43.69566], [22.47582, 43.6558], [22.53397, 43.47225], [22.82036, 43.33665], [22.89727, 43.22417], [23.00806, 43.19279], [22.98104, 43.11199], [22.89521, 43.03625], [22.78397, 42.98253], [22.74826, 42.88701], [22.54302, 42.87774], [22.43309, 42.82057], [22.4997, 42.74144], [22.43983, 42.56851], [22.55669, 42.50144], [22.51961, 42.3991], [22.47498, 42.3915], [22.45919, 42.33822], [22.34773, 42.31725], [22.38136, 42.30339], [22.47251, 42.20393], [22.50289, 42.19527], [22.51224, 42.15457], [22.67701, 42.06614], [22.86749, 42.02275], [22.90254, 41.87587], [22.96682, 41.77137], [23.01239, 41.76527], [23.03342, 41.71034], [22.95513, 41.63265], [22.96331, 41.35782], [22.93334, 41.34104], [23.1833, 41.31755], [23.21953, 41.33773], [23.22771, 41.37106], [23.31301, 41.40525], [23.33639, 41.36317], [23.40416, 41.39999], [23.52453, 41.40262], [23.63203, 41.37632], [23.67644, 41.41139], [23.76525, 41.40175], [23.80148, 41.43943], [23.89613, 41.45257], [23.91483, 41.47971], [23.96975, 41.44118], [24.06908, 41.46132], [24.06323, 41.53222], [24.10063, 41.54796], [24.18126, 41.51735], [24.27124, 41.57682], [24.30513, 41.51297], [24.52599, 41.56808], [24.61129, 41.42278], [24.71529, 41.41928], [24.8041, 41.34913], [24.82514, 41.4035], [24.86136, 41.39298], [24.90928, 41.40876], [24.942, 41.38685], [25.11611, 41.34212], [25.28322, 41.23411], [25.48187, 41.28506], [25.52394, 41.2798], [25.55082, 41.31667], [25.61042, 41.30614], [25.66183, 41.31316], [25.70507, 41.29209], [25.8266, 41.34563], [25.87919, 41.30526], [26.12926, 41.35878], [26.16548, 41.42278], [26.20288, 41.43943], [26.14796, 41.47533], [26.176, 41.50072], [26.17951, 41.55409], [26.14328, 41.55496], [26.15146, 41.60828], [26.07083, 41.64584], [26.06148, 41.70345], [26.16841, 41.74858], [26.21325, 41.73223], [26.22888, 41.74139], [26.2654, 41.71544], [26.30255, 41.70925], [26.35957, 41.71149], [26.32952, 41.73637], [26.33589, 41.76802], [26.36952, 41.82265], [26.53968, 41.82653], [26.57961, 41.90024], [26.56051, 41.92995], [26.62996, 41.97644], [26.79143, 41.97386], [26.95638, 42.00741], [27.03277, 42.0809], [27.08486, 42.08735], [27.19251, 42.06028], [27.22376, 42.10152], [27.27411, 42.10409], [27.45478, 41.96591], [27.52379, 41.93756], [27.55191, 41.90928], [27.69949, 41.97515], [27.81235, 41.94803], [27.83492, 41.99709], [27.91479, 41.97902], [28.02971, 41.98066], [28.32297, 41.98371], [29.24336, 43.70874], [28.23293, 43.76], [27.99558, 43.84193], [27.92008, 44.00761], [27.73468, 43.95326], [27.64542, 44.04958], [27.60834, 44.01206], [27.39757, 44.0141], [27.26845, 44.12602], [26.95141, 44.13555], [26.62712, 44.05698], [26.38764, 44.04356], [26.10115, 43.96908], [26.05584, 43.90925], [25.94911, 43.85745], [25.72792, 43.69263], [25.39528, 43.61866], [25.17144, 43.70261], [25.10718, 43.6831], [24.96682, 43.72693], [24.73542, 43.68523], [24.62281, 43.74082], [24.50264, 43.76314], [24.35364, 43.70211], [24.18149, 43.68218], [23.73978, 43.80627], [23.61687, 43.79289], [23.4507, 43.84936], [23.26772, 43.84843], [23.05288, 43.79494]]]] } },
29014     { type: "Feature", properties: { iso1A2: "BH", iso1A3: "BHR", iso1N3: "048", wikidata: "Q398", nameEn: "Bahrain", groups: ["145", "142", "UN"], callingCodes: ["973"] }, geometry: { type: "MultiPolygon", coordinates: [[[[50.93865, 26.30758], [50.71771, 26.73086], [50.38162, 26.53976], [50.26923, 26.08243], [50.302, 25.87592], [50.57069, 25.57887], [50.80824, 25.54641], [50.7801, 25.595], [50.86149, 25.6965], [50.81266, 25.88946], [50.93865, 26.30758]]]] } },
29015     { type: "Feature", properties: { iso1A2: "BI", iso1A3: "BDI", iso1N3: "108", wikidata: "Q967", nameEn: "Burundi", groups: ["014", "202", "002", "UN"], callingCodes: ["257"] }, geometry: { type: "MultiPolygon", coordinates: [[[[30.54501, -2.41404], [30.42933, -2.31064], [30.14034, -2.43626], [29.95911, -2.33348], [29.88237, -2.75105], [29.36805, -2.82933], [29.32234, -2.6483], [29.0562, -2.58632], [29.04081, -2.7416], [29.00167, -2.78523], [29.00404, -2.81978], [29.0505, -2.81774], [29.09119, -2.87871], [29.09797, -2.91935], [29.16037, -2.95457], [29.17258, -2.99385], [29.25633, -3.05471], [29.21463, -3.3514], [29.23708, -3.75856], [29.43673, -4.44845], [29.63827, -4.44681], [29.75109, -4.45836], [29.77289, -4.41733], [29.82885, -4.36153], [29.88172, -4.35743], [30.03323, -4.26631], [30.22042, -4.01738], [30.45915, -3.56532], [30.84165, -3.25152], [30.83823, -2.97837], [30.6675, -2.98987], [30.57926, -2.89791], [30.4987, -2.9573], [30.40662, -2.86151], [30.52747, -2.65841], [30.41789, -2.66266], [30.54501, -2.41404]]]] } },
29016     { type: "Feature", properties: { iso1A2: "BJ", iso1A3: "BEN", iso1N3: "204", wikidata: "Q962", nameEn: "Benin", aliases: ["DY"], groups: ["011", "202", "002", "UN"], callingCodes: ["229"] }, geometry: { type: "MultiPolygon", coordinates: [[[[3.59375, 11.70269], [3.48187, 11.86092], [3.31613, 11.88495], [3.25352, 12.01467], [2.83978, 12.40585], [2.6593, 12.30631], [2.37783, 12.24804], [2.39657, 12.10952], [2.45824, 11.98672], [2.39723, 11.89473], [2.29983, 11.68254], [2.00988, 11.42227], [1.42823, 11.46822], [1.03409, 11.04719], [0.9813, 11.08876], [0.91245, 10.99597], [0.8804, 10.803], [0.80358, 10.71459], [0.77666, 10.37665], [1.35507, 9.99525], [1.36624, 9.5951], [1.33675, 9.54765], [1.41746, 9.3226], [1.5649, 9.16941], [1.61838, 9.0527], [1.64249, 6.99562], [1.55877, 6.99737], [1.61812, 6.74843], [1.58105, 6.68619], [1.76906, 6.43189], [1.79826, 6.28221], [1.62913, 6.24075], [1.67336, 6.02702], [2.74181, 6.13349], [2.70566, 6.38038], [2.70464, 6.50831], [2.74334, 6.57291], [2.7325, 6.64057], [2.78204, 6.70514], [2.78823, 6.76356], [2.73405, 6.78508], [2.74024, 6.92802], [2.71702, 6.95722], [2.76965, 7.13543], [2.74489, 7.42565], [2.79442, 7.43486], [2.78668, 7.5116], [2.73405, 7.5423], [2.73095, 7.7755], [2.67523, 7.87825], [2.77907, 9.06924], [3.08017, 9.10006], [3.14147, 9.28375], [3.13928, 9.47167], [3.25093, 9.61632], [3.34726, 9.70696], [3.32099, 9.78032], [3.35383, 9.83641], [3.54429, 9.87739], [3.66908, 10.18136], [3.57275, 10.27185], [3.6844, 10.46351], [3.78292, 10.40538], [3.84243, 10.59316], [3.71505, 11.13015], [3.49175, 11.29765], [3.59375, 11.70269]]]] } },
29017     { type: "Feature", properties: { iso1A2: "BL", iso1A3: "BLM", iso1N3: "652", wikidata: "Q25362", nameEn: "Saint-Barth\xE9lemy", country: "FR", groups: ["EU", "Q1451600", "029", "003", "419", "019", "UN"], callingCodes: ["590"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-62.62718, 18.26185], [-63.1055, 17.86651], [-62.34423, 17.49165], [-62.62718, 18.26185]]]] } },
29018     { type: "Feature", properties: { iso1A2: "BM", iso1A3: "BMU", iso1N3: "060", wikidata: "Q23635", nameEn: "Bermuda", country: "GB", groups: ["BOTS", "021", "003", "019", "UN"], driveSide: "left", callingCodes: ["1 441"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.20987, 32.6953], [-65.31453, 32.68437], [-65.63955, 31.43417], [-63.20987, 32.6953]]]] } },
29019     { type: "Feature", properties: { iso1A2: "BN", iso1A3: "BRN", iso1N3: "096", wikidata: "Q921", nameEn: "Brunei", groups: ["Q36117", "035", "142", "UN"], driveSide: "left", callingCodes: ["673"] }, geometry: { type: "MultiPolygon", coordinates: [[[[115.16236, 5.01011], [115.02521, 5.35005], [114.10166, 4.76112], [114.07448, 4.58441], [114.15813, 4.57], [114.26876, 4.49878], [114.32176, 4.34942], [114.32176, 4.2552], [114.4416, 4.27588], [114.49922, 4.13108], [114.64211, 4.00694], [114.78539, 4.12205], [114.88039, 4.4257], [114.83189, 4.42387], [114.77303, 4.72871], [114.8266, 4.75062], [114.88841, 4.81905], [114.96982, 4.81146], [114.99417, 4.88201], [115.05038, 4.90275], [115.02955, 4.82087], [115.02278, 4.74137], [115.04064, 4.63706], [115.07737, 4.53418], [115.09978, 4.39123], [115.31275, 4.30806], [115.36346, 4.33563], [115.2851, 4.42295], [115.27819, 4.63661], [115.20737, 4.8256], [115.15092, 4.87604], [115.16236, 5.01011]]]] } },
29020     { type: "Feature", properties: { iso1A2: "BO", iso1A3: "BOL", iso1N3: "068", wikidata: "Q750", nameEn: "Bolivia", groups: ["005", "419", "019", "UN"], callingCodes: ["591"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.90248, -12.52544], [-64.22539, -12.45267], [-64.30708, -12.46398], [-64.99778, -11.98604], [-65.30027, -11.48749], [-65.28141, -10.86289], [-65.35402, -10.78685], [-65.37923, -10.35141], [-65.29019, -9.86253], [-65.40615, -9.63894], [-65.56244, -9.84266], [-65.68343, -9.75323], [-67.17784, -10.34016], [-68.71533, -11.14749], [-68.7651, -11.0496], [-68.75179, -11.03688], [-68.75265, -11.02383], [-68.74802, -11.00891], [-69.42792, -10.93451], [-69.47839, -10.95254], [-69.57156, -10.94555], [-68.98115, -11.8979], [-68.65044, -12.50689], [-68.85615, -12.87769], [-68.8864, -13.40792], [-69.05265, -13.68546], [-68.88135, -14.18639], [-69.36254, -14.94634], [-69.14856, -15.23478], [-69.40336, -15.61358], [-69.20291, -16.16668], [-69.09986, -16.22693], [-68.96238, -16.194], [-68.79464, -16.33272], [-68.98358, -16.42165], [-69.04027, -16.57214], [-69.00853, -16.66769], [-69.16896, -16.72233], [-69.62883, -17.28142], [-69.46863, -17.37466], [-69.46897, -17.4988], [-69.46623, -17.60518], [-69.34126, -17.72753], [-69.28671, -17.94844], [-69.07496, -18.03715], [-69.14807, -18.16893], [-69.07432, -18.28259], [-68.94987, -18.93302], [-68.87082, -19.06003], [-68.80602, -19.08355], [-68.61989, -19.27584], [-68.41218, -19.40499], [-68.66761, -19.72118], [-68.54611, -19.84651], [-68.57132, -20.03134], [-68.74273, -20.08817], [-68.7276, -20.46178], [-68.44023, -20.62701], [-68.55383, -20.7355], [-68.53957, -20.91542], [-68.40403, -20.94562], [-68.18816, -21.28614], [-67.85114, -22.87076], [-67.54284, -22.89771], [-67.18382, -22.81525], [-66.7298, -22.23644], [-66.29714, -22.08741], [-66.24077, -21.77837], [-66.03836, -21.84829], [-66.04832, -21.9187], [-65.9261, -21.93335], [-65.7467, -22.10105], [-65.61166, -22.09504], [-65.58694, -22.09794], [-65.57743, -22.07675], [-65.47435, -22.08908], [-64.99524, -22.08255], [-64.90014, -22.12136], [-64.67174, -22.18957], [-64.58888, -22.25035], [-64.4176, -22.67692], [-64.35108, -22.73282], [-64.31489, -22.88824], [-64.22918, -22.55807], [-63.93287, -21.99934], [-63.70963, -21.99934], [-63.68113, -22.0544], [-63.66482, -21.99918], [-62.81124, -21.9987], [-62.8078, -22.12534], [-62.64455, -22.25091], [-62.2757, -21.06657], [-62.26883, -20.55311], [-61.93912, -20.10053], [-61.73723, -19.63958], [-60.00638, -19.2981], [-59.06965, -19.29148], [-58.23216, -19.80058], [-58.16225, -20.16193], [-57.8496, -19.98346], [-58.14215, -19.76276], [-57.78463, -19.03259], [-57.71113, -19.03161], [-57.69134, -19.00544], [-57.71995, -18.97546], [-57.71995, -18.89573], [-57.76764, -18.90087], [-57.56807, -18.25655], [-57.48237, -18.24219], [-57.69877, -17.8431], [-57.73949, -17.56095], [-57.90082, -17.44555], [-57.99661, -17.5273], [-58.32935, -17.28195], [-58.5058, -16.80958], [-58.30918, -16.3699], [-58.32431, -16.25861], [-58.41506, -16.32636], [-60.16069, -16.26479], [-60.23797, -15.50267], [-60.58224, -15.09887], [-60.23968, -15.09515], [-60.27887, -14.63021], [-60.46037, -14.22496], [-60.48053, -13.77981], [-61.05527, -13.50054], [-61.81151, -13.49564], [-63.76259, -12.42952], [-63.90248, -12.52544]]]] } },
29021     { type: "Feature", properties: { iso1A2: "BQ", iso1A3: "BES", iso1N3: "535", wikidata: "Q27561", nameEn: "Caribbean Netherlands", country: "NL" }, geometry: null },
29022     { type: "Feature", properties: { iso1A2: "BR", iso1A3: "BRA", iso1N3: "076", wikidata: "Q155", nameEn: "Brazil", groups: ["005", "419", "019", "UN"], callingCodes: ["55"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-59.69361, 4.34069], [-59.78878, 4.45637], [-60.15953, 4.53456], [-60.04189, 4.69801], [-59.98129, 5.07097], [-60.20944, 5.28754], [-60.32352, 5.21299], [-60.73204, 5.20931], [-60.5802, 4.94312], [-60.86539, 4.70512], [-60.98303, 4.54167], [-61.15703, 4.49839], [-61.31457, 4.54167], [-61.29675, 4.44216], [-61.48569, 4.43149], [-61.54629, 4.2822], [-62.13094, 4.08309], [-62.44822, 4.18621], [-62.57656, 4.04754], [-62.74411, 4.03331], [-62.7655, 3.73099], [-62.98296, 3.59935], [-63.21111, 3.96219], [-63.4464, 3.9693], [-63.42233, 3.89995], [-63.50611, 3.83592], [-63.67099, 4.01731], [-63.70218, 3.91417], [-63.86082, 3.94796], [-63.99183, 3.90172], [-64.14512, 4.12932], [-64.57648, 4.12576], [-64.72977, 4.28931], [-64.84028, 4.24665], [-64.48379, 3.7879], [-64.02908, 2.79797], [-64.0257, 2.48156], [-63.39114, 2.4317], [-63.39827, 2.16098], [-64.06135, 1.94722], [-64.08274, 1.64792], [-64.34654, 1.35569], [-64.38932, 1.5125], [-65.11657, 1.12046], [-65.57288, 0.62856], [-65.50158, 0.92086], [-65.6727, 1.01353], [-66.28507, 0.74585], [-66.85795, 1.22998], [-67.08222, 1.17441], [-67.15784, 1.80439], [-67.299, 1.87494], [-67.40488, 2.22258], [-67.9292, 1.82455], [-68.18632, 2.00091], [-68.26699, 1.83463], [-68.18128, 1.72881], [-69.38621, 1.70865], [-69.53746, 1.76408], [-69.83491, 1.69353], [-69.82987, 1.07864], [-69.26017, 1.06856], [-69.14422, 0.84172], [-69.20976, 0.57958], [-69.47696, 0.71065], [-70.04162, 0.55437], [-70.03658, -0.19681], [-69.603, -0.51947], [-69.59796, -0.75136], [-69.4215, -1.01853], [-69.43395, -1.42219], [-69.94708, -4.2431], [-70.00888, -4.37833], [-70.11305, -4.27281], [-70.19582, -4.3607], [-70.33236, -4.15214], [-70.77601, -4.15717], [-70.96814, -4.36915], [-71.87003, -4.51661], [-72.64391, -5.0391], [-72.83973, -5.14765], [-73.24579, -6.05764], [-73.12983, -6.43852], [-73.73986, -6.87919], [-73.77011, -7.28944], [-73.96938, -7.58465], [-73.65485, -7.77897], [-73.76576, -7.89884], [-72.92886, -9.04074], [-73.21498, -9.40904], [-72.72216, -9.41397], [-72.31883, -9.5184], [-72.14742, -9.98049], [-71.23394, -9.9668], [-70.53373, -9.42628], [-70.58453, -9.58303], [-70.55429, -9.76692], [-70.62487, -9.80666], [-70.64134, -11.0108], [-70.51395, -10.92249], [-70.38791, -11.07096], [-69.90896, -10.92744], [-69.57835, -10.94051], [-69.57156, -10.94555], [-69.47839, -10.95254], [-69.42792, -10.93451], [-68.74802, -11.00891], [-68.75265, -11.02383], [-68.75179, -11.03688], [-68.7651, -11.0496], [-68.71533, -11.14749], [-67.17784, -10.34016], [-65.68343, -9.75323], [-65.56244, -9.84266], [-65.40615, -9.63894], [-65.29019, -9.86253], [-65.37923, -10.35141], [-65.35402, -10.78685], [-65.28141, -10.86289], [-65.30027, -11.48749], [-64.99778, -11.98604], [-64.30708, -12.46398], [-64.22539, -12.45267], [-63.90248, -12.52544], [-63.76259, -12.42952], [-61.81151, -13.49564], [-61.05527, -13.50054], [-60.48053, -13.77981], [-60.46037, -14.22496], [-60.27887, -14.63021], [-60.23968, -15.09515], [-60.58224, -15.09887], [-60.23797, -15.50267], [-60.16069, -16.26479], [-58.41506, -16.32636], [-58.32431, -16.25861], [-58.30918, -16.3699], [-58.5058, -16.80958], [-58.32935, -17.28195], [-57.99661, -17.5273], [-57.90082, -17.44555], [-57.73949, -17.56095], [-57.69877, -17.8431], [-57.48237, -18.24219], [-57.56807, -18.25655], [-57.76764, -18.90087], [-57.71995, -18.89573], [-57.71995, -18.97546], [-57.69134, -19.00544], [-57.71113, -19.03161], [-57.78463, -19.03259], [-58.14215, -19.76276], [-57.8496, -19.98346], [-58.16225, -20.16193], [-57.84536, -20.93155], [-57.93492, -21.65505], [-57.88239, -21.6868], [-57.94642, -21.73799], [-57.98625, -22.09157], [-56.6508, -22.28387], [-56.5212, -22.11556], [-56.45893, -22.08072], [-56.23206, -22.25347], [-55.8331, -22.29008], [-55.74941, -22.46436], [-55.741, -22.52018], [-55.72366, -22.5519], [-55.6986, -22.56268], [-55.68742, -22.58407], [-55.62493, -22.62765], [-55.63849, -22.95122], [-55.5446, -23.22811], [-55.52288, -23.2595], [-55.5555, -23.28237], [-55.43585, -23.87157], [-55.44117, -23.9185], [-55.41784, -23.9657], [-55.12292, -23.99669], [-55.0518, -23.98666], [-55.02691, -23.97317], [-54.6238, -23.83078], [-54.32807, -24.01865], [-54.28207, -24.07305], [-54.4423, -25.13381], [-54.62033, -25.46026], [-54.60196, -25.48397], [-54.59509, -25.53696], [-54.59398, -25.59224], [-54.5502, -25.58915], [-54.52926, -25.62846], [-53.90831, -25.55513], [-53.83691, -25.94849], [-53.73511, -26.04211], [-53.73086, -26.05842], [-53.7264, -26.0664], [-53.73391, -26.07006], [-53.73968, -26.10012], [-53.65018, -26.19501], [-53.65237, -26.23289], [-53.63739, -26.2496], [-53.63881, -26.25075], [-53.64632, -26.24798], [-53.64186, -26.25976], [-53.64505, -26.28089], [-53.68269, -26.33359], [-53.73372, -26.6131], [-53.80144, -27.09844], [-54.15978, -27.2889], [-54.19062, -27.27639], [-54.19268, -27.30751], [-54.41888, -27.40882], [-54.50416, -27.48232], [-54.67657, -27.57214], [-54.90159, -27.63132], [-54.90805, -27.73149], [-55.1349, -27.89759], [-55.16872, -27.86224], [-55.33303, -27.94661], [-55.6262, -28.17124], [-55.65418, -28.18304], [-56.01729, -28.51223], [-56.00458, -28.60421], [-56.05265, -28.62651], [-56.54171, -29.11447], [-56.57295, -29.11357], [-56.62789, -29.18073], [-56.81251, -29.48154], [-57.09386, -29.74211], [-57.65132, -30.19229], [-57.22502, -30.26121], [-56.90236, -30.02578], [-56.49267, -30.39471], [-56.4795, -30.3899], [-56.4619, -30.38457], [-55.87388, -31.05053], [-55.58866, -30.84117], [-55.5634, -30.8686], [-55.55373, -30.8732], [-55.55218, -30.88193], [-55.54572, -30.89051], [-55.53431, -30.89714], [-55.53276, -30.90218], [-55.52712, -30.89997], [-55.51862, -30.89828], [-55.50841, -30.9027], [-55.50821, -30.91349], [-54.17384, -31.86168], [-53.76024, -32.0751], [-53.39572, -32.58596], [-53.37671, -32.57005], [-53.1111, -32.71147], [-53.53459, -33.16843], [-53.52794, -33.68908], [-53.44031, -33.69344], [-53.39593, -33.75169], [-53.37138, -33.74313], [-52.83257, -34.01481], [-28.34015, -20.99094], [-28.99601, 1.86593], [-51.35485, 4.8383], [-51.63798, 4.51394], [-51.61983, 4.14596], [-51.79599, 3.89336], [-51.82312, 3.85825], [-51.85573, 3.83427], [-52.31787, 3.17896], [-52.6906, 2.37298], [-52.96539, 2.1881], [-53.78743, 2.34412], [-54.16286, 2.10779], [-54.6084, 2.32856], [-55.01919, 2.564], [-55.71493, 2.40342], [-55.96292, 2.53188], [-56.13054, 2.27723], [-55.92159, 2.05236], [-55.89863, 1.89861], [-55.99278, 1.83137], [-56.47045, 1.95135], [-56.7659, 1.89509], [-57.07092, 1.95304], [-57.09109, 2.01854], [-57.23981, 1.95808], [-57.35073, 1.98327], [-57.55743, 1.69605], [-57.77281, 1.73344], [-57.97336, 1.64566], [-58.01873, 1.51966], [-58.33887, 1.58014], [-58.4858, 1.48399], [-58.53571, 1.29154], [-58.84229, 1.17749], [-58.92072, 1.31293], [-59.25583, 1.40559], [-59.74066, 1.87596], [-59.7264, 2.27497], [-59.91177, 2.36759], [-59.99733, 2.92312], [-59.79769, 3.37162], [-59.86899, 3.57089], [-59.51963, 3.91951], [-59.73353, 4.20399], [-59.69361, 4.34069]]]] } },
29023     { type: "Feature", properties: { iso1A2: "BS", iso1A3: "BHS", iso1N3: "044", wikidata: "Q778", nameEn: "The Bahamas", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 242"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-72.98446, 20.4801], [-71.70065, 25.7637], [-78.91214, 27.76553], [-80.65727, 23.71953], [-72.98446, 20.4801]]]] } },
29024     { type: "Feature", properties: { iso1A2: "BT", iso1A3: "BTN", iso1N3: "064", wikidata: "Q917", nameEn: "Bhutan", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["975"] }, geometry: { type: "MultiPolygon", coordinates: [[[[91.6469, 27.76358], [91.5629, 27.84823], [91.48973, 27.93903], [91.46327, 28.0064], [91.25779, 28.07509], [91.20019, 27.98715], [90.69894, 28.07784], [90.58842, 28.02838], [90.13387, 28.19178], [89.79762, 28.23979], [89.59525, 28.16433], [89.12825, 27.62502], [89.0582, 27.60985], [88.97213, 27.51671], [88.95355, 27.4106], [89.00216, 27.32532], [88.96947, 27.30319], [88.93678, 27.33777], [88.91901, 27.32483], [88.74219, 27.144], [88.86984, 27.10937], [88.8714, 26.97488], [88.92301, 26.99286], [88.95807, 26.92668], [89.09554, 26.89089], [89.12825, 26.81661], [89.1926, 26.81329], [89.37913, 26.86224], [89.38319, 26.85963], [89.3901, 26.84225], [89.42349, 26.83727], [89.63369, 26.74402], [89.86124, 26.73307], [90.04535, 26.72422], [90.30402, 26.85098], [90.39271, 26.90704], [90.48504, 26.8594], [90.67715, 26.77215], [91.50067, 26.79223], [91.83181, 26.87318], [92.05523, 26.8692], [92.11863, 26.893], [92.03457, 27.07334], [92.04702, 27.26861], [92.12019, 27.27829], [92.01132, 27.47352], [91.65007, 27.48287], [91.55819, 27.6144], [91.6469, 27.76358]]]] } },
29025     { type: "Feature", properties: { iso1A2: "BV", iso1A3: "BVT", iso1N3: "074", wikidata: "Q23408", nameEn: "Bouvet Island", country: "NO", groups: ["005", "419", "019", "UN"] }, geometry: { type: "MultiPolygon", coordinates: [[[[4.54042, -54.0949], [2.28941, -54.13089], [3.35353, -55.17558], [4.54042, -54.0949]]]] } },
29026     { type: "Feature", properties: { iso1A2: "BW", iso1A3: "BWA", iso1N3: "072", wikidata: "Q963", nameEn: "Botswana", groups: ["018", "202", "002", "UN"], driveSide: "left", callingCodes: ["267"] }, geometry: { type: "MultiPolygon", coordinates: [[[[25.26433, -17.79571], [25.16882, -17.78253], [25.05895, -17.84452], [24.95586, -17.79674], [24.73364, -17.89338], [24.71887, -17.9218], [24.6303, -17.9863], [24.57485, -18.07151], [24.40577, -17.95726], [24.19416, -18.01919], [23.61088, -18.4881], [23.29618, -17.99855], [23.0996, -18.00075], [21.45556, -18.31795], [20.99904, -18.31743], [20.99751, -22.00026], [19.99912, -21.99991], [19.99817, -24.76768], [20.02809, -24.78725], [20.03678, -24.81004], [20.29826, -24.94869], [20.64795, -25.47827], [20.86081, -26.14892], [20.61754, -26.4692], [20.63275, -26.78181], [20.68596, -26.9039], [20.87031, -26.80047], [21.13353, -26.86661], [21.37869, -26.82083], [21.69322, -26.86152], [21.7854, -26.79199], [21.77114, -26.69015], [21.83291, -26.65959], [21.90703, -26.66808], [22.06192, -26.61882], [22.21206, -26.3773], [22.41921, -26.23078], [22.56365, -26.19668], [22.70808, -25.99186], [22.86012, -25.50572], [23.03497, -25.29971], [23.47588, -25.29971], [23.9244, -25.64286], [24.18287, -25.62916], [24.36531, -25.773], [24.44703, -25.73021], [24.67319, -25.81749], [24.8946, -25.80723], [25.01718, -25.72507], [25.12266, -25.75931], [25.33076, -25.76616], [25.58543, -25.6343], [25.6643, -25.4491], [25.69661, -25.29284], [25.72702, -25.25503], [25.88571, -24.87802], [25.84295, -24.78661], [25.8515, -24.75727], [26.39409, -24.63468], [26.46346, -24.60358], [26.51667, -24.47219], [26.84165, -24.24885], [26.99749, -23.65486], [27.33768, -23.40917], [27.52393, -23.37952], [27.6066, -23.21894], [27.74154, -23.2137], [27.93539, -23.04941], [27.93729, -22.96194], [28.04752, -22.90243], [28.04562, -22.8394], [28.34874, -22.5694], [28.63287, -22.55887], [28.91889, -22.44299], [29.0151, -22.22907], [29.10881, -22.21202], [29.15268, -22.21399], [29.18974, -22.18599], [29.21955, -22.17771], [29.37703, -22.19581], [29.3533, -22.18363], [29.24648, -22.05967], [29.1974, -22.07472], [29.14501, -22.07275], [29.08495, -22.04867], [29.04108, -22.00563], [29.02191, -21.95665], [29.02191, -21.90647], [29.04023, -21.85864], [29.07763, -21.81877], [28.58114, -21.63455], [28.49942, -21.66634], [28.29416, -21.59037], [28.01669, -21.57624], [27.91407, -21.31621], [27.69171, -21.08409], [27.72972, -20.51735], [27.69361, -20.48531], [27.28865, -20.49873], [27.29831, -20.28935], [27.21278, -20.08244], [26.72246, -19.92707], [26.17227, -19.53709], [25.96226, -19.08152], [25.99837, -19.02943], [25.94326, -18.90362], [25.82353, -18.82808], [25.79217, -18.6355], [25.68859, -18.56165], [25.53465, -18.39041], [25.39972, -18.12691], [25.31799, -18.07091], [25.23909, -17.90832], [25.26433, -17.79571]]]] } },
29027     { type: "Feature", properties: { iso1A2: "BY", iso1A3: "BLR", iso1N3: "112", wikidata: "Q184", nameEn: "Belarus", groups: ["151", "150", "UN"], callingCodes: ["375"] }, geometry: { type: "MultiPolygon", coordinates: [[[[28.15217, 56.16964], [27.97865, 56.11849], [27.63065, 55.89687], [27.61683, 55.78558], [27.3541, 55.8089], [27.27804, 55.78299], [27.1559, 55.85032], [26.97153, 55.8102], [26.87448, 55.7172], [26.76872, 55.67658], [26.71802, 55.70645], [26.64888, 55.70515], [26.63231, 55.67968], [26.63167, 55.57887], [26.55094, 55.5093], [26.5522, 55.40277], [26.44937, 55.34832], [26.5709, 55.32572], [26.6714, 55.33902], [26.80929, 55.31642], [26.83266, 55.30444], [26.835, 55.28182], [26.73017, 55.24226], [26.72983, 55.21788], [26.68075, 55.19787], [26.69243, 55.16718], [26.54753, 55.14181], [26.51481, 55.16051], [26.46249, 55.12814], [26.35121, 55.1525], [26.30628, 55.12536], [26.23202, 55.10439], [26.26941, 55.08032], [26.20397, 54.99729], [26.13386, 54.98924], [26.05907, 54.94631], [25.99129, 54.95705], [25.89462, 54.93438], [25.74122, 54.80108], [25.75977, 54.57252], [25.68045, 54.5321], [25.64813, 54.48704], [25.62203, 54.4656], [25.63371, 54.42075], [25.5376, 54.33158], [25.55425, 54.31591], [25.68513, 54.31727], [25.78553, 54.23327], [25.78563, 54.15747], [25.71084, 54.16704], [25.64875, 54.1259], [25.54724, 54.14925], [25.51452, 54.17799], [25.56823, 54.25212], [25.509, 54.30267], [25.35559, 54.26544], [25.22705, 54.26271], [25.19199, 54.219], [25.0728, 54.13419], [24.991, 54.14241], [24.96894, 54.17589], [24.77131, 54.11091], [24.85311, 54.02862], [24.74279, 53.96663], [24.69185, 53.96543], [24.69652, 54.01901], [24.62275, 54.00217], [24.44411, 53.90076], [24.34128, 53.90076], [24.19638, 53.96405], [23.98837, 53.92554], [23.95098, 53.9613], [23.81309, 53.94205], [23.80543, 53.89558], [23.71726, 53.93379], [23.61677, 53.92691], [23.51284, 53.95052], [23.62004, 53.60942], [23.81995, 53.24131], [23.85657, 53.22923], [23.91393, 53.16469], [23.87548, 53.0831], [23.92184, 53.02079], [23.94689, 52.95919], [23.91805, 52.94016], [23.93763, 52.71332], [23.73615, 52.6149], [23.58296, 52.59868], [23.45112, 52.53774], [23.34141, 52.44845], [23.18196, 52.28812], [23.20071, 52.22848], [23.47859, 52.18215], [23.54314, 52.12148], [23.61, 52.11264], [23.64066, 52.07626], [23.68733, 51.9906], [23.61523, 51.92066], [23.62691, 51.78208], [23.53198, 51.74298], [23.57053, 51.55938], [23.56236, 51.53673], [23.62751, 51.50512], [23.6736, 51.50255], [23.60906, 51.62122], [23.7766, 51.66809], [23.91118, 51.63316], [23.8741, 51.59734], [23.99907, 51.58369], [24.13075, 51.66979], [24.3163, 51.75063], [24.29021, 51.80841], [24.37123, 51.88222], [24.98784, 51.91273], [25.20228, 51.97143], [25.46163, 51.92205], [25.73673, 51.91973], [25.80574, 51.94556], [25.83217, 51.92587], [26.00408, 51.92967], [26.19084, 51.86781], [26.39367, 51.87315], [26.46962, 51.80501], [26.69759, 51.82284], [26.80043, 51.75777], [26.9489, 51.73788], [26.99422, 51.76933], [27.20602, 51.77291], [27.20948, 51.66713], [27.26613, 51.65957], [27.24828, 51.60161], [27.47212, 51.61184], [27.51058, 51.5854], [27.55727, 51.63486], [27.71932, 51.60672], [27.67125, 51.50854], [27.76052, 51.47604], [27.85253, 51.62293], [27.91844, 51.61952], [27.95827, 51.56065], [28.10658, 51.57857], [28.23452, 51.66988], [28.37592, 51.54505], [28.47051, 51.59734], [28.64429, 51.5664], [28.69161, 51.44695], [28.73143, 51.46236], [28.75615, 51.41442], [28.78224, 51.45294], [28.76027, 51.48802], [28.81795, 51.55552], [28.95528, 51.59222], [28.99098, 51.56833], [29.1187, 51.65872], [29.16402, 51.64679], [29.20659, 51.56918], [29.25603, 51.57089], [29.25191, 51.49828], [29.32881, 51.37843], [29.42357, 51.4187], [29.49773, 51.39814], [29.54372, 51.48372], [29.7408, 51.53417], [29.77376, 51.4461], [30.17888, 51.51025], [30.34642, 51.42555], [30.36153, 51.33984], [30.56203, 51.25655], [30.64992, 51.35014], [30.51946, 51.59649], [30.68804, 51.82806], [30.76443, 51.89739], [30.90897, 52.00699], [30.95589, 52.07775], [31.13332, 52.1004], [31.25142, 52.04131], [31.38326, 52.12991], [31.7822, 52.11406], [31.77877, 52.18636], [31.6895, 52.1973], [31.70735, 52.26711], [31.57971, 52.32146], [31.62084, 52.33849], [31.61397, 52.48843], [31.56316, 52.51518], [31.63869, 52.55361], [31.50406, 52.69707], [31.57277, 52.71613], [31.592, 52.79011], [31.35667, 52.97854], [31.24147, 53.031], [31.32283, 53.04101], [31.33519, 53.08805], [31.3915, 53.09712], [31.36403, 53.13504], [31.40523, 53.21406], [31.56316, 53.19432], [31.62496, 53.22886], [31.787, 53.18033], [31.82373, 53.10042], [32.15368, 53.07594], [32.40773, 53.18856], [32.51725, 53.28431], [32.73257, 53.33494], [32.74968, 53.45597], [32.47777, 53.5548], [32.40499, 53.6656], [32.50112, 53.68594], [32.45717, 53.74039], [32.36663, 53.7166], [32.12621, 53.81586], [31.89137, 53.78099], [31.77028, 53.80015], [31.85019, 53.91801], [31.88744, 54.03653], [31.89599, 54.0837], [31.57002, 54.14535], [31.30791, 54.25315], [31.3177, 54.34067], [31.22945, 54.46585], [31.08543, 54.50361], [31.21399, 54.63113], [31.19339, 54.66947], [30.99187, 54.67046], [30.98226, 54.68872], [31.0262, 54.70698], [30.97127, 54.71967], [30.95479, 54.74346], [30.75165, 54.80699], [30.8264, 54.90062], [30.81759, 54.94064], [30.93144, 54.9585], [30.95754, 54.98609], [30.9081, 55.02232], [30.94243, 55.03964], [31.00972, 55.02783], [31.02071, 55.06167], [30.97369, 55.17134], [30.87944, 55.28223], [30.81946, 55.27931], [30.8257, 55.3313], [30.93144, 55.3914], [30.90123, 55.46621], [30.95204, 55.50667], [30.93419, 55.6185], [30.86003, 55.63169], [30.7845, 55.58514], [30.72957, 55.66268], [30.67464, 55.64176], [30.63344, 55.73079], [30.51037, 55.76568], [30.51346, 55.78982], [30.48257, 55.81066], [30.30987, 55.83592], [30.27776, 55.86819], [30.12136, 55.8358], [29.97975, 55.87281], [29.80672, 55.79569], [29.61446, 55.77716], [29.51283, 55.70294], [29.3604, 55.75862], [29.44692, 55.95978], [29.21717, 55.98971], [29.08299, 56.03427], [28.73418, 55.97131], [28.63668, 56.07262], [28.68337, 56.10173], [28.5529, 56.11705], [28.43068, 56.09407], [28.37987, 56.11399], [28.36888, 56.05805], [28.30571, 56.06035], [28.15217, 56.16964]]]] } },
29028     { type: "Feature", properties: { iso1A2: "BZ", iso1A3: "BLZ", iso1N3: "084", wikidata: "Q242", nameEn: "Belize", groups: ["013", "003", "419", "019", "UN"], roadSpeedUnit: "mph", callingCodes: ["501"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-88.3268, 18.49048], [-88.48242, 18.49164], [-88.71505, 18.0707], [-88.8716, 17.89535], [-89.03839, 18.0067], [-89.15105, 17.95104], [-89.14985, 17.81563], [-89.15025, 17.04813], [-89.22683, 15.88619], [-89.17418, 15.90898], [-89.02415, 15.9063], [-88.95358, 15.88698], [-88.40779, 16.09624], [-86.92368, 17.61462], [-87.84815, 18.18511], [-87.85693, 18.18266], [-87.86657, 18.19971], [-87.87604, 18.18313], [-87.90671, 18.15213], [-88.03165, 18.16657], [-88.03238, 18.41778], [-88.26593, 18.47617], [-88.29909, 18.47591], [-88.3268, 18.49048]]]] } },
29029     { type: "Feature", properties: { iso1A2: "CA", iso1A3: "CAN", iso1N3: "124", wikidata: "Q16", nameEn: "Canada", groups: ["021", "003", "019", "UN"], callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-67.20349, 45.1722], [-67.19603, 45.16771], [-67.15965, 45.16179], [-67.11316, 45.11176], [-67.0216, 44.95333], [-66.96824, 44.90965], [-66.98249, 44.87071], [-66.96824, 44.83078], [-66.93432, 44.82597], [-67.16117, 44.20069], [-61.98255, 37.34815], [-56.27503, 47.39728], [-53.12387, 41.40385], [-46.37635, 57.3249], [-77.52957, 77.23408], [-68.21821, 80.48551], [-49.33696, 84.57952], [-140.97446, 84.39275], [-141.00116, 60.30648], [-140.5227, 60.22077], [-140.45648, 60.30919], [-139.98024, 60.18027], [-139.68991, 60.33693], [-139.05831, 60.35205], [-139.20603, 60.08896], [-139.05365, 59.99655], [-138.71149, 59.90728], [-138.62145, 59.76431], [-137.60623, 59.24465], [-137.4925, 58.89415], [-136.82619, 59.16198], [-136.52365, 59.16752], [-136.47323, 59.46617], [-136.33727, 59.44466], [-136.22381, 59.55526], [-136.31566, 59.59083], [-135.48007, 59.79937], [-135.03069, 59.56208], [-135.00267, 59.28745], [-134.7047, 59.2458], [-134.55699, 59.1297], [-134.48059, 59.13231], [-134.27175, 58.8634], [-133.84645, 58.73543], [-133.38523, 58.42773], [-131.8271, 56.62247], [-130.77769, 56.36185], [-130.33965, 56.10849], [-130.10173, 56.12178], [-130.00093, 56.00325], [-130.00857, 55.91344], [-130.15373, 55.74895], [-129.97513, 55.28029], [-130.08035, 55.21556], [-130.18765, 55.07744], [-130.27203, 54.97174], [-130.44184, 54.85377], [-130.64499, 54.76912], [-130.61931, 54.70835], [-133.92876, 54.62289], [-133.36909, 48.51151], [-125.03842, 48.53282], [-123.50039, 48.21223], [-123.15614, 48.35395], [-123.26565, 48.6959], [-123.0093, 48.76586], [-123.0093, 48.83186], [-123.32163, 49.00419], [-95.15355, 48.9996], [-95.15357, 49.384], [-95.12903, 49.37056], [-95.05825, 49.35311], [-95.01419, 49.35647], [-94.99532, 49.36579], [-94.95681, 49.37035], [-94.85381, 49.32492], [-94.8159, 49.32299], [-94.82487, 49.29483], [-94.77355, 49.11998], [-94.75017, 49.09931], [-94.687, 48.84077], [-94.70087, 48.8339], [-94.70486, 48.82365], [-94.69669, 48.80918], [-94.69335, 48.77883], [-94.58903, 48.71803], [-94.54885, 48.71543], [-94.53826, 48.70216], [-94.44258, 48.69223], [-94.4174, 48.71049], [-94.27153, 48.70232], [-94.25172, 48.68404], [-94.25104, 48.65729], [-94.23215, 48.65202], [-93.85769, 48.63284], [-93.83288, 48.62745], [-93.80676, 48.58232], [-93.80939, 48.52439], [-93.79267, 48.51631], [-93.66382, 48.51845], [-93.47022, 48.54357], [-93.44472, 48.59147], [-93.40693, 48.60948], [-93.39758, 48.60364], [-93.3712, 48.60599], [-93.33946, 48.62787], [-93.25391, 48.64266], [-92.94973, 48.60866], [-92.7287, 48.54005], [-92.6342, 48.54133], [-92.62747, 48.50278], [-92.69927, 48.49573], [-92.71323, 48.46081], [-92.65606, 48.43471], [-92.50712, 48.44921], [-92.45588, 48.40624], [-92.48147, 48.36609], [-92.37185, 48.22259], [-92.27167, 48.25046], [-92.30939, 48.31251], [-92.26662, 48.35651], [-92.202, 48.35252], [-92.14732, 48.36578], [-92.05339, 48.35958], [-91.98929, 48.25409], [-91.86125, 48.21278], [-91.71231, 48.19875], [-91.70451, 48.11805], [-91.55649, 48.10611], [-91.58025, 48.04339], [-91.45829, 48.07454], [-91.43248, 48.04912], [-91.25025, 48.08522], [-91.08016, 48.18096], [-90.87588, 48.2484], [-90.75045, 48.09143], [-90.56444, 48.12184], [-90.56312, 48.09488], [-90.07418, 48.11043], [-89.89974, 47.98109], [-89.77248, 48.02607], [-89.57972, 48.00023], [-89.48837, 48.01412], [-88.37033, 48.30586], [-84.85871, 46.88881], [-84.55635, 46.45974], [-84.47607, 46.45225], [-84.4481, 46.48972], [-84.42101, 46.49853], [-84.34174, 46.50683], [-84.29893, 46.49127], [-84.26351, 46.49508], [-84.2264, 46.53337], [-84.1945, 46.54061], [-84.17723, 46.52753], [-84.12885, 46.53068], [-84.11196, 46.50248], [-84.13451, 46.39218], [-84.11254, 46.32329], [-84.11615, 46.2681], [-84.09756, 46.25512], [-84.1096, 46.23987], [-83.95399, 46.05634], [-83.90453, 46.05922], [-83.83329, 46.12169], [-83.57017, 46.105], [-83.43746, 45.99749], [-83.59589, 45.82131], [-82.48419, 45.30225], [-82.42469, 42.992], [-82.4146, 42.97626], [-82.4253, 42.95423], [-82.45331, 42.93139], [-82.4826, 42.8068], [-82.46613, 42.76615], [-82.51063, 42.66025], [-82.51858, 42.611], [-82.57583, 42.5718], [-82.58873, 42.54984], [-82.64242, 42.55594], [-82.82964, 42.37355], [-83.02253, 42.33045], [-83.07837, 42.30978], [-83.09837, 42.28877], [-83.12724, 42.2376], [-83.14962, 42.04089], [-83.11184, 41.95671], [-82.67862, 41.67615], [-78.93684, 42.82887], [-78.90712, 42.89733], [-78.90905, 42.93022], [-78.93224, 42.95229], [-78.96312, 42.95509], [-78.98126, 42.97], [-79.02074, 42.98444], [-79.02424, 43.01983], [-78.99941, 43.05612], [-79.01055, 43.06659], [-79.07486, 43.07845], [-79.05671, 43.10937], [-79.06881, 43.12029], [-79.0427, 43.13934], [-79.04652, 43.16396], [-79.05384, 43.17418], [-79.05002, 43.20133], [-79.05544, 43.21224], [-79.05512, 43.25375], [-79.06921, 43.26183], [-79.25796, 43.54052], [-76.79706, 43.63099], [-76.43859, 44.09393], [-76.35324, 44.13493], [-76.31222, 44.19894], [-76.244, 44.19643], [-76.1664, 44.23051], [-76.16285, 44.28262], [-76.00018, 44.34896], [-75.95947, 44.34463], [-75.8217, 44.43176], [-75.76813, 44.51537], [-75.41441, 44.76614], [-75.2193, 44.87821], [-75.01363, 44.95608], [-74.99101, 44.98051], [-74.8447, 45.00606], [-74.66689, 45.00646], [-74.32699, 44.99029], [-73.35025, 45.00942], [-71.50067, 45.01357], [-71.48735, 45.07784], [-71.42778, 45.12624], [-71.40364, 45.21382], [-71.44252, 45.2361], [-71.37133, 45.24624], [-71.29371, 45.29996], [-71.22338, 45.25184], [-71.19723, 45.25438], [-71.14568, 45.24128], [-71.08364, 45.30623], [-71.01866, 45.31573], [-71.0107, 45.34819], [-70.95193, 45.33895], [-70.91169, 45.29849], [-70.89864, 45.2398], [-70.84816, 45.22698], [-70.80236, 45.37444], [-70.82638, 45.39828], [-70.78372, 45.43269], [-70.65383, 45.37592], [-70.62518, 45.42286], [-70.72651, 45.49771], [-70.68516, 45.56964], [-70.54019, 45.67291], [-70.38934, 45.73215], [-70.41523, 45.79497], [-70.25976, 45.89675], [-70.24694, 45.95138], [-70.31025, 45.96424], [-70.23855, 46.1453], [-70.29078, 46.18832], [-70.18547, 46.35357], [-70.05812, 46.41768], [-69.99966, 46.69543], [-69.22119, 47.46461], [-69.05148, 47.42012], [-69.05073, 47.30076], [-69.05039, 47.2456], [-68.89222, 47.1807], [-68.70125, 47.24399], [-68.60575, 47.24659], [-68.57914, 47.28431], [-68.38332, 47.28723], [-68.37458, 47.35851], [-68.23244, 47.35712], [-67.94843, 47.1925], [-67.87993, 47.10377], [-67.78578, 47.06473], [-67.78111, 45.9392], [-67.75196, 45.91814], [-67.80961, 45.87531], [-67.75654, 45.82324], [-67.80653, 45.80022], [-67.80705, 45.69528], [-67.6049, 45.60725], [-67.43815, 45.59162], [-67.42144, 45.50584], [-67.50578, 45.48971], [-67.42394, 45.37969], [-67.48201, 45.27351], [-67.34927, 45.122], [-67.29754, 45.14865], [-67.29748, 45.18173], [-67.27039, 45.1934], [-67.22751, 45.16344], [-67.20349, 45.1722]]]] } },
29030     { type: "Feature", properties: { iso1A2: "CC", iso1A3: "CCK", iso1N3: "166", wikidata: "Q36004", nameEn: "Cocos (Keeling) Islands", country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[96.61846, -10.82438], [96.02343, -12.68334], [97.93979, -12.33309], [96.61846, -10.82438]]]] } },
29031     { type: "Feature", properties: { iso1A2: "CD", iso1A3: "COD", iso1N3: "180", wikidata: "Q974", nameEn: "Democratic Republic of the Congo", aliases: ["ZR"], groups: ["017", "202", "002", "UN"], callingCodes: ["243"] }, geometry: { type: "MultiPolygon", coordinates: [[[[27.44012, 5.07349], [27.09575, 5.22305], [26.93064, 5.13535], [26.85579, 5.03887], [26.74572, 5.10685], [26.48595, 5.04984], [26.13371, 5.25594], [25.86073, 5.19455], [25.53271, 5.37431], [25.34558, 5.29101], [25.31256, 5.03668], [24.71816, 4.90509], [24.46719, 5.0915], [23.38847, 4.60013], [22.94817, 4.82392], [22.89094, 4.79321], [22.84691, 4.69887], [22.78526, 4.71423], [22.6928, 4.47285], [22.60915, 4.48821], [22.5431, 4.22041], [22.45504, 4.13039], [22.27682, 4.11347], [22.10721, 4.20723], [21.6405, 4.317], [21.55904, 4.25553], [21.25744, 4.33676], [21.21341, 4.29285], [21.11214, 4.33895], [21.08793, 4.39603], [20.90383, 4.44877], [20.60184, 4.42394], [18.62755, 3.47564], [18.63857, 3.19342], [18.10683, 2.26876], [18.08034, 1.58553], [17.85887, 1.04327], [17.86989, 0.58873], [17.95255, 0.48128], [17.93877, 0.32424], [17.81204, 0.23884], [17.66051, -0.26535], [17.72112, -0.52707], [17.32438, -0.99265], [16.97999, -1.12762], [16.70724, -1.45815], [16.50336, -1.8795], [16.16173, -2.16586], [16.22785, -2.59528], [16.1755, -3.25014], [16.21407, -3.2969], [15.89448, -3.9513], [15.53081, -4.042], [15.48121, -4.22062], [15.41785, -4.28381], [15.32693, -4.27282], [15.25411, -4.31121], [15.1978, -4.32388], [14.83101, -4.80838], [14.67948, -4.92093], [14.5059, -4.84956], [14.41499, -4.8825], [14.37366, -4.56125], [14.47284, -4.42941], [14.3957, -4.36623], [14.40672, -4.28381], [13.9108, -4.50906], [13.81162, -4.41842], [13.71794, -4.44864], [13.70417, -4.72601], [13.50305, -4.77818], [13.41764, -4.89897], [13.11182, -4.5942], [13.09648, -4.63739], [13.11195, -4.67745], [12.8733, -4.74346], [12.70868, -4.95505], [12.63465, -4.94632], [12.60251, -5.01715], [12.46297, -5.09408], [12.49815, -5.14058], [12.51589, -5.1332], [12.53586, -5.14658], [12.53599, -5.1618], [12.52301, -5.17481], [12.52318, -5.74353], [12.26557, -5.74031], [12.20376, -5.76338], [11.95767, -5.94705], [12.42245, -6.07585], [13.04371, -5.87078], [16.55507, -5.85631], [16.96282, -7.21787], [17.5828, -8.13784], [18.33635, -8.00126], [19.33698, -7.99743], [19.5469, -7.00195], [20.30218, -6.98955], [20.31846, -6.91953], [20.61689, -6.90876], [20.56263, -7.28566], [21.79824, -7.29628], [21.84856, -9.59871], [22.19039, -9.94628], [22.32604, -10.76291], [22.17954, -10.85884], [22.25951, -11.24911], [22.54205, -11.05784], [23.16602, -11.10577], [23.45631, -10.946], [23.86868, -11.02856], [24.00027, -10.89356], [24.34528, -11.06816], [24.42612, -11.44975], [25.34069, -11.19707], [25.33058, -11.65767], [26.01777, -11.91488], [26.88687, -12.01868], [27.04351, -11.61312], [27.22541, -11.60323], [27.21025, -11.76157], [27.59932, -12.22123], [28.33199, -12.41375], [29.01918, -13.41353], [29.60531, -13.21685], [29.65078, -13.41844], [29.81551, -13.44683], [29.8139, -12.14898], [29.48404, -12.23604], [29.4992, -12.43843], [29.18592, -12.37921], [28.48357, -11.87532], [28.37241, -11.57848], [28.65032, -10.65133], [28.62795, -9.92942], [28.68532, -9.78], [28.56208, -9.49122], [28.51627, -9.44726], [28.52636, -9.35379], [28.36562, -9.30091], [28.38526, -9.23393], [28.9711, -8.66935], [28.88917, -8.4831], [30.79243, -8.27382], [30.2567, -7.14121], [29.52552, -6.2731], [29.43673, -4.44845], [29.23708, -3.75856], [29.21463, -3.3514], [29.25633, -3.05471], [29.17258, -2.99385], [29.16037, -2.95457], [29.09797, -2.91935], [29.09119, -2.87871], [29.0505, -2.81774], [29.00404, -2.81978], [29.00167, -2.78523], [29.04081, -2.7416], [29.00357, -2.70596], [28.94346, -2.69124], [28.89793, -2.66111], [28.90226, -2.62385], [28.89288, -2.55848], [28.87943, -2.55165], [28.86193, -2.53185], [28.86209, -2.5231], [28.87497, -2.50887], [28.88846, -2.50493], [28.89342, -2.49017], [28.89132, -2.47557], [28.86846, -2.44866], [28.86826, -2.41888], [28.89601, -2.37321], [28.95642, -2.37321], [29.00051, -2.29001], [29.105, -2.27043], [29.17562, -2.12278], [29.11847, -1.90576], [29.24458, -1.69663], [29.24323, -1.66826], [29.36322, -1.50887], [29.45038, -1.5054], [29.53062, -1.40499], [29.59061, -1.39016], [29.58388, -0.89821], [29.63006, -0.8997], [29.62708, -0.71055], [29.67176, -0.55714], [29.67474, -0.47969], [29.65091, -0.46777], [29.72687, -0.08051], [29.7224, 0.07291], [29.77454, 0.16675], [29.81922, 0.16824], [29.87284, 0.39166], [29.97413, 0.52124], [29.95477, 0.64486], [29.98307, 0.84295], [30.1484, 0.89805], [30.22139, 0.99635], [30.24671, 1.14974], [30.48503, 1.21675], [31.30127, 2.11006], [31.28042, 2.17853], [31.20148, 2.2217], [31.1985, 2.29462], [31.12104, 2.27676], [31.07934, 2.30207], [31.06593, 2.35862], [30.96911, 2.41071], [30.91102, 2.33332], [30.83059, 2.42559], [30.74271, 2.43601], [30.75612, 2.5863], [30.8857, 2.83923], [30.8574, 2.9508], [30.77101, 3.04897], [30.84251, 3.26908], [30.93486, 3.40737], [30.94081, 3.50847], [30.85153, 3.48867], [30.85997, 3.5743], [30.80713, 3.60506], [30.78512, 3.67097], [30.56277, 3.62703], [30.57378, 3.74567], [30.55396, 3.84451], [30.47691, 3.83353], [30.27658, 3.95653], [30.22374, 3.93896], [30.1621, 4.10586], [30.06964, 4.13221], [29.79666, 4.37809], [29.82087, 4.56246], [29.49726, 4.7007], [29.43341, 4.50101], [29.22207, 4.34297], [29.03054, 4.48784], [28.8126, 4.48784], [28.6651, 4.42638], [28.20719, 4.35614], [27.79551, 4.59976], [27.76469, 4.79284], [27.65462, 4.89375], [27.56656, 4.89375], [27.44012, 5.07349]]]] } },
29032     { type: "Feature", properties: { iso1A2: "CF", iso1A3: "CAF", iso1N3: "140", wikidata: "Q929", nameEn: "Central African Republic", groups: ["017", "202", "002", "UN"], callingCodes: ["236"] }, geometry: { type: "MultiPolygon", coordinates: [[[[22.87758, 10.91915], [22.45889, 11.00246], [21.72139, 10.64136], [21.71479, 10.29932], [21.63553, 10.217], [21.52766, 10.2105], [21.34934, 9.95907], [21.26348, 9.97642], [20.82979, 9.44696], [20.36748, 9.11019], [19.06421, 9.00367], [18.86388, 8.87971], [19.11044, 8.68172], [18.79783, 8.25929], [18.67455, 8.22226], [18.62612, 8.14163], [18.64153, 8.08714], [18.6085, 8.05009], [18.02731, 8.01085], [17.93926, 7.95853], [17.67288, 7.98905], [16.8143, 7.53971], [16.6668, 7.67281], [16.658, 7.75353], [16.59415, 7.76444], [16.58315, 7.88657], [16.41583, 7.77971], [16.40703, 7.68809], [15.79942, 7.44149], [15.73118, 7.52006], [15.49743, 7.52179], [15.23397, 7.25135], [15.04717, 6.77085], [14.96311, 6.75693], [14.79966, 6.39043], [14.80122, 6.34866], [14.74206, 6.26356], [14.56149, 6.18928], [14.43073, 6.08867], [14.42917, 6.00508], [14.49455, 5.91683], [14.60974, 5.91838], [14.62375, 5.70466], [14.58951, 5.59777], [14.62531, 5.51411], [14.52724, 5.28319], [14.57083, 5.23979], [14.65489, 5.21343], [14.73383, 4.6135], [15.00825, 4.41458], [15.08609, 4.30282], [15.10644, 4.1362], [15.17482, 4.05131], [15.07686, 4.01805], [15.73522, 3.24348], [15.77725, 3.26835], [16.05449, 3.02306], [16.08252, 2.45708], [16.19357, 2.21537], [16.50126, 2.84739], [16.46701, 2.92512], [16.57598, 3.47999], [16.68283, 3.54257], [17.01746, 3.55136], [17.35649, 3.63045], [17.46876, 3.70515], [17.60966, 3.63705], [17.83421, 3.61068], [17.85842, 3.53378], [18.05656, 3.56893], [18.14902, 3.54476], [18.17323, 3.47665], [18.24148, 3.50302], [18.2723, 3.57992], [18.39558, 3.58212], [18.49245, 3.63924], [18.58711, 3.49423], [18.62755, 3.47564], [20.60184, 4.42394], [20.90383, 4.44877], [21.08793, 4.39603], [21.11214, 4.33895], [21.21341, 4.29285], [21.25744, 4.33676], [21.55904, 4.25553], [21.6405, 4.317], [22.10721, 4.20723], [22.27682, 4.11347], [22.45504, 4.13039], [22.5431, 4.22041], [22.60915, 4.48821], [22.6928, 4.47285], [22.78526, 4.71423], [22.84691, 4.69887], [22.89094, 4.79321], [22.94817, 4.82392], [23.38847, 4.60013], [24.46719, 5.0915], [24.71816, 4.90509], [25.31256, 5.03668], [25.34558, 5.29101], [25.53271, 5.37431], [25.86073, 5.19455], [26.13371, 5.25594], [26.48595, 5.04984], [26.74572, 5.10685], [26.85579, 5.03887], [26.93064, 5.13535], [27.09575, 5.22305], [27.44012, 5.07349], [27.26886, 5.25876], [27.23017, 5.37167], [27.28621, 5.56382], [27.22705, 5.62889], [27.22705, 5.71254], [26.51721, 6.09655], [26.58259, 6.1987], [26.32729, 6.36272], [26.38022, 6.63493], [25.90076, 7.09549], [25.37461, 7.33024], [25.35281, 7.42595], [25.20337, 7.50312], [25.20649, 7.61115], [25.29214, 7.66675], [25.25319, 7.8487], [24.98855, 7.96588], [24.85156, 8.16933], [24.35965, 8.26177], [24.13238, 8.36959], [24.25691, 8.69288], [23.51905, 8.71749], [23.59065, 8.99743], [23.44744, 8.99128], [23.4848, 9.16959], [23.56263, 9.19418], [23.64358, 9.28637], [23.64981, 9.44303], [23.62179, 9.53823], [23.69155, 9.67566], [23.67164, 9.86923], [23.3128, 10.45214], [23.02221, 10.69235], [22.87758, 10.91915]]]] } },
29033     { type: "Feature", properties: { iso1A2: "CG", iso1A3: "COG", iso1N3: "178", wikidata: "Q971", nameEn: "Republic of the Congo", groups: ["017", "202", "002", "UN"], callingCodes: ["242"] }, geometry: { type: "MultiPolygon", coordinates: [[[[18.62755, 3.47564], [18.58711, 3.49423], [18.49245, 3.63924], [18.39558, 3.58212], [18.2723, 3.57992], [18.24148, 3.50302], [18.17323, 3.47665], [18.14902, 3.54476], [18.05656, 3.56893], [17.85842, 3.53378], [17.83421, 3.61068], [17.60966, 3.63705], [17.46876, 3.70515], [17.35649, 3.63045], [17.01746, 3.55136], [16.68283, 3.54257], [16.57598, 3.47999], [16.46701, 2.92512], [16.50126, 2.84739], [16.19357, 2.21537], [16.15568, 2.18955], [16.08563, 2.19733], [16.05294, 1.9811], [16.14634, 1.70259], [16.02647, 1.65591], [16.02959, 1.76483], [15.48942, 1.98265], [15.34776, 1.91264], [15.22634, 2.03243], [15.00996, 1.98887], [14.61145, 2.17866], [13.29457, 2.16106], [13.13461, 1.57238], [13.25447, 1.32339], [13.15519, 1.23368], [13.89582, 1.4261], [14.25186, 1.39842], [14.48179, 0.9152], [14.26066, 0.57255], [14.10909, 0.58563], [13.88648, 0.26652], [13.90632, -0.2287], [14.06862, -0.20826], [14.2165, -0.38261], [14.41887, -0.44799], [14.52569, -0.57818], [14.41838, -1.89412], [14.25932, -1.97624], [14.23518, -2.15671], [14.16202, -2.23916], [14.23829, -2.33715], [14.10442, -2.49268], [13.85846, -2.46935], [13.92073, -2.35581], [13.75884, -2.09293], [13.47977, -2.43224], [13.02759, -2.33098], [12.82172, -1.91091], [12.61312, -1.8129], [12.44656, -1.92025], [12.47925, -2.32626], [12.04895, -2.41704], [11.96866, -2.33559], [11.74605, -2.39936], [11.57637, -2.33379], [11.64487, -2.61865], [11.5359, -2.85654], [11.64798, -2.81146], [11.80365, -3.00424], [11.70558, -3.0773], [11.70227, -3.17465], [11.96554, -3.30267], [11.8318, -3.5812], [11.92719, -3.62768], [11.87083, -3.71571], [11.68608, -3.68942], [11.57949, -3.52798], [11.48764, -3.51089], [11.22301, -3.69888], [11.12647, -3.94169], [10.75913, -4.39519], [11.50888, -5.33417], [12.00924, -5.02627], [12.16068, -4.90089], [12.20901, -4.75642], [12.25587, -4.79437], [12.32324, -4.78415], [12.40964, -4.60609], [12.64835, -4.55937], [12.76844, -4.38709], [12.87096, -4.40315], [12.91489, -4.47907], [13.09648, -4.63739], [13.11182, -4.5942], [13.41764, -4.89897], [13.50305, -4.77818], [13.70417, -4.72601], [13.71794, -4.44864], [13.81162, -4.41842], [13.9108, -4.50906], [14.40672, -4.28381], [14.3957, -4.36623], [14.47284, -4.42941], [14.37366, -4.56125], [14.41499, -4.8825], [14.5059, -4.84956], [14.67948, -4.92093], [14.83101, -4.80838], [15.1978, -4.32388], [15.25411, -4.31121], [15.32693, -4.27282], [15.41785, -4.28381], [15.48121, -4.22062], [15.53081, -4.042], [15.89448, -3.9513], [16.21407, -3.2969], [16.1755, -3.25014], [16.22785, -2.59528], [16.16173, -2.16586], [16.50336, -1.8795], [16.70724, -1.45815], [16.97999, -1.12762], [17.32438, -0.99265], [17.72112, -0.52707], [17.66051, -0.26535], [17.81204, 0.23884], [17.93877, 0.32424], [17.95255, 0.48128], [17.86989, 0.58873], [17.85887, 1.04327], [18.08034, 1.58553], [18.10683, 2.26876], [18.63857, 3.19342], [18.62755, 3.47564]]]] } },
29034     { type: "Feature", properties: { iso1A2: "CH", iso1A3: "CHE", iso1N3: "756", wikidata: "Q39", nameEn: "Switzerland", groups: ["155", "150", "UN"], callingCodes: ["41"] }, geometry: { type: "MultiPolygon", coordinates: [[[[8.72809, 47.69282], [8.72617, 47.69651], [8.73671, 47.7169], [8.70543, 47.73121], [8.74251, 47.75168], [8.71778, 47.76571], [8.68985, 47.75686], [8.68022, 47.78599], [8.65292, 47.80066], [8.64425, 47.76398], [8.62408, 47.7626], [8.61657, 47.79998], [8.56415, 47.80633], [8.56814, 47.78001], [8.48868, 47.77215], [8.45771, 47.7493], [8.44807, 47.72426], [8.40569, 47.69855], [8.4211, 47.68407], [8.40473, 47.67499], [8.41346, 47.66676], [8.42264, 47.66667], [8.44711, 47.65379], [8.4667, 47.65747], [8.46605, 47.64103], [8.49656, 47.64709], [8.5322, 47.64687], [8.52801, 47.66059], [8.56141, 47.67088], [8.57683, 47.66158], [8.6052, 47.67258], [8.61113, 47.66332], [8.62884, 47.65098], [8.62049, 47.63757], [8.60412, 47.63735], [8.61471, 47.64514], [8.60701, 47.65271], [8.59545, 47.64298], [8.60348, 47.61204], [8.57586, 47.59537], [8.55756, 47.62394], [8.51686, 47.63476], [8.50747, 47.61897], [8.45578, 47.60121], [8.46637, 47.58389], [8.48949, 47.588], [8.49431, 47.58107], [8.43235, 47.56617], [8.39477, 47.57826], [8.38273, 47.56608], [8.35512, 47.57014], [8.32735, 47.57133], [8.30277, 47.58607], [8.29524, 47.5919], [8.29722, 47.60603], [8.2824, 47.61225], [8.26313, 47.6103], [8.25863, 47.61571], [8.23809, 47.61204], [8.22577, 47.60385], [8.22011, 47.6181], [8.20617, 47.62141], [8.19378, 47.61636], [8.1652, 47.5945], [8.14947, 47.59558], [8.13823, 47.59147], [8.13662, 47.58432], [8.11543, 47.5841], [8.10395, 47.57918], [8.10002, 47.56504], [8.08557, 47.55768], [8.06663, 47.56374], [8.04383, 47.55443], [8.02136, 47.55096], [8.00113, 47.55616], [7.97581, 47.55493], [7.95682, 47.55789], [7.94494, 47.54511], [7.91251, 47.55031], [7.90673, 47.57674], [7.88664, 47.58854], [7.84412, 47.5841], [7.81901, 47.58798], [7.79486, 47.55691], [7.75261, 47.54599], [7.71961, 47.54219], [7.69642, 47.53297], [7.68101, 47.53232], [7.6656, 47.53752], [7.66174, 47.54554], [7.65083, 47.54662], [7.63338, 47.56256], [7.67655, 47.56435], [7.68904, 47.57133], [7.67115, 47.5871], [7.68486, 47.59601], [7.69385, 47.60099], [7.68229, 47.59905], [7.67395, 47.59212], [7.64599, 47.59695], [7.64213, 47.5944], [7.64309, 47.59151], [7.61929, 47.57683], [7.60459, 47.57869], [7.60523, 47.58519], [7.58945, 47.59017], [7.58386, 47.57536], [7.56684, 47.57785], [7.56548, 47.57617], [7.55689, 47.57232], [7.55652, 47.56779], [7.53634, 47.55553], [7.52831, 47.55347], [7.51723, 47.54578], [7.50873, 47.54546], [7.49691, 47.53821], [7.50588, 47.52856], [7.51904, 47.53515], [7.53199, 47.5284], [7.5229, 47.51644], [7.49804, 47.51798], [7.51076, 47.49651], [7.47534, 47.47932], [7.43356, 47.49712], [7.42923, 47.48628], [7.4583, 47.47216], [7.4462, 47.46264], [7.43088, 47.45846], [7.40308, 47.43638], [7.35603, 47.43432], [7.33526, 47.44186], [7.24669, 47.4205], [7.17026, 47.44312], [7.19583, 47.49455], [7.16249, 47.49025], [7.12781, 47.50371], [7.07425, 47.48863], [7.0231, 47.50522], [6.98425, 47.49432], [7.0024, 47.45264], [6.93953, 47.43388], [6.93744, 47.40714], [6.88542, 47.37262], [6.87959, 47.35335], [7.03125, 47.36996], [7.0564, 47.35134], [7.05305, 47.33304], [6.94316, 47.28747], [6.95108, 47.26428], [6.9508, 47.24338], [6.8489, 47.15933], [6.76788, 47.1208], [6.68823, 47.06616], [6.71531, 47.0494], [6.43341, 46.92703], [6.46456, 46.88865], [6.43216, 46.80336], [6.45209, 46.77502], [6.38351, 46.73171], [6.27135, 46.68251], [6.11084, 46.57649], [6.1567, 46.54402], [6.07269, 46.46244], [6.08427, 46.44305], [6.06407, 46.41676], [6.09926, 46.40768], [6.15016, 46.3778], [6.15985, 46.37721], [6.16987, 46.36759], [6.15738, 46.3491], [6.13876, 46.33844], [6.1198, 46.31157], [6.11697, 46.29547], [6.1013, 46.28512], [6.11926, 46.2634], [6.12446, 46.25059], [6.10071, 46.23772], [6.08563, 46.24651], [6.07072, 46.24085], [6.0633, 46.24583], [6.05029, 46.23518], [6.04602, 46.23127], [6.03342, 46.2383], [6.02461, 46.23313], [5.97542, 46.21525], [5.96515, 46.19638], [5.99573, 46.18587], [5.98846, 46.17046], [5.98188, 46.17392], [5.97508, 46.15863], [5.9641, 46.14412], [5.95781, 46.12925], [5.97893, 46.13303], [5.9871, 46.14499], [6.01791, 46.14228], [6.03614, 46.13712], [6.04564, 46.14031], [6.05203, 46.15191], [6.07491, 46.14879], [6.09199, 46.15191], [6.09926, 46.14373], [6.13397, 46.1406], [6.15305, 46.15194], [6.18116, 46.16187], [6.18871, 46.16644], [6.18707, 46.17999], [6.19552, 46.18401], [6.19807, 46.18369], [6.20539, 46.19163], [6.21114, 46.1927], [6.21273, 46.19409], [6.21603, 46.19507], [6.21844, 46.19837], [6.22222, 46.19888], [6.22175, 46.20045], [6.23544, 46.20714], [6.23913, 46.20511], [6.24821, 46.20531], [6.26007, 46.21165], [6.27694, 46.21566], [6.29663, 46.22688], [6.31041, 46.24417], [6.29474, 46.26221], [6.26749, 46.24745], [6.24952, 46.26255], [6.23775, 46.27822], [6.25137, 46.29014], [6.24826, 46.30175], [6.21981, 46.31304], [6.25432, 46.3632], [6.53358, 46.45431], [6.82312, 46.42661], [6.8024, 46.39171], [6.77152, 46.34784], [6.86052, 46.28512], [6.78968, 46.14058], [6.89321, 46.12548], [6.87868, 46.03855], [6.93862, 46.06502], [7.00946, 45.9944], [7.04151, 45.92435], [7.10685, 45.85653], [7.56343, 45.97421], [7.85949, 45.91485], [7.9049, 45.99945], [7.98881, 45.99867], [8.02906, 46.10331], [8.11383, 46.11577], [8.16866, 46.17817], [8.08814, 46.26692], [8.31162, 46.38044], [8.30648, 46.41587], [8.42464, 46.46367], [8.46317, 46.43712], [8.45032, 46.26869], [8.62242, 46.12112], [8.75697, 46.10395], [8.80778, 46.10085], [8.85617, 46.0748], [8.79414, 46.00913], [8.78585, 45.98973], [8.79362, 45.99207], [8.8319, 45.9879], [8.85121, 45.97239], [8.86688, 45.96135], [8.88904, 45.95465], [8.93649, 45.86775], [8.94372, 45.86587], [8.93504, 45.86245], [8.91129, 45.8388], [8.94737, 45.84285], [8.9621, 45.83707], [8.99663, 45.83466], [9.00324, 45.82055], [9.0298, 45.82127], [9.03279, 45.82865], [9.03793, 45.83548], [9.03505, 45.83976], [9.04059, 45.8464], [9.04546, 45.84968], [9.06642, 45.8761], [9.09065, 45.89906], [8.99257, 45.9698], [9.01618, 46.04928], [9.24503, 46.23616], [9.29226, 46.32717], [9.25502, 46.43743], [9.28136, 46.49685], [9.36128, 46.5081], [9.40487, 46.46621], [9.45936, 46.50873], [9.46117, 46.37481], [9.57015, 46.2958], [9.71273, 46.29266], [9.73086, 46.35071], [9.95249, 46.38045], [10.07055, 46.21668], [10.14439, 46.22992], [10.17862, 46.25626], [10.10506, 46.3372], [10.165, 46.41051], [10.03715, 46.44479], [10.10307, 46.61003], [10.23674, 46.63484], [10.25309, 46.57432], [10.46136, 46.53164], [10.49375, 46.62049], [10.44686, 46.64162], [10.40475, 46.63671], [10.38659, 46.67847], [10.47197, 46.85698], [10.48376, 46.93891], [10.36933, 47.00212], [10.30031, 46.92093], [10.24128, 46.93147], [10.22675, 46.86942], [10.10715, 46.84296], [9.98058, 46.91434], [9.88266, 46.93343], [9.87935, 47.01337], [9.60717, 47.06091], [9.55721, 47.04762], [9.54041, 47.06495], [9.47548, 47.05257], [9.47139, 47.06402], [9.51362, 47.08505], [9.52089, 47.10019], [9.51044, 47.13727], [9.48774, 47.17402], [9.4891, 47.19346], [9.50318, 47.22153], [9.52406, 47.24959], [9.53116, 47.27029], [9.54773, 47.2809], [9.55857, 47.29919], [9.58513, 47.31334], [9.59978, 47.34671], [9.62476, 47.36639], [9.65427, 47.36824], [9.66243, 47.37136], [9.6711, 47.37824], [9.67445, 47.38429], [9.67334, 47.39191], [9.6629, 47.39591], [9.65136, 47.40504], [9.65043, 47.41937], [9.6446, 47.43233], [9.64483, 47.43842], [9.65863, 47.44847], [9.65728, 47.45383], [9.6423, 47.45599], [9.62475, 47.45685], [9.62158, 47.45858], [9.60841, 47.47178], [9.60484, 47.46358], [9.60205, 47.46165], [9.59482, 47.46305], [9.58208, 47.48344], [9.56312, 47.49495], [9.55125, 47.53629], [9.25619, 47.65939], [9.18203, 47.65598], [9.17593, 47.65399], [9.1755, 47.65584], [9.1705, 47.65513], [9.15181, 47.66904], [9.13845, 47.66389], [9.09891, 47.67801], [9.02093, 47.6868], [8.94093, 47.65596], [8.89946, 47.64769], [8.87625, 47.65441], [8.87383, 47.67045], [8.85065, 47.68209], [8.86989, 47.70504], [8.82002, 47.71458], [8.80663, 47.73821], [8.77309, 47.72059], [8.76965, 47.7075], [8.79966, 47.70222], [8.79511, 47.67462], [8.75856, 47.68969], [8.72809, 47.69282]], [[8.95861, 45.96485], [8.96668, 45.98436], [8.97741, 45.98317], [8.97604, 45.96151], [8.95861, 45.96485]], [[8.70847, 47.68904], [8.68985, 47.69552], [8.66837, 47.68437], [8.65769, 47.68928], [8.67508, 47.6979], [8.66416, 47.71367], [8.70237, 47.71453], [8.71773, 47.69088], [8.70847, 47.68904]]]] } },
29035     { type: "Feature", properties: { iso1A2: "CI", iso1A3: "CIV", iso1N3: "384", wikidata: "Q1008", nameEn: "C\xF4te d'Ivoire", groups: ["011", "202", "002", "UN"], callingCodes: ["225"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-7.52774, 3.7105], [-3.34019, 4.17519], [-3.10675, 5.08515], [-3.11073, 5.12675], [-3.063, 5.13665], [-2.96554, 5.10397], [-2.95261, 5.12477], [-2.75502, 5.10657], [-2.73074, 5.1364], [-2.77625, 5.34621], [-2.72737, 5.34789], [-2.76614, 5.60963], [-2.85378, 5.65156], [-2.93132, 5.62137], [-2.96671, 5.6415], [-2.95323, 5.71865], [-3.01896, 5.71697], [-3.25999, 6.62521], [-3.21954, 6.74407], [-3.23327, 6.81744], [-2.95438, 7.23737], [-2.97822, 7.27165], [-2.92339, 7.60847], [-2.79467, 7.86002], [-2.78395, 7.94974], [-2.74819, 7.92613], [-2.67787, 8.02055], [-2.61232, 8.02645], [-2.62901, 8.11495], [-2.49037, 8.20872], [-2.58243, 8.7789], [-2.66357, 9.01771], [-2.77799, 9.04949], [-2.69814, 9.22717], [-2.68802, 9.49343], [-2.76494, 9.40778], [-2.93012, 9.57403], [-3.00765, 9.74019], [-3.16609, 9.85147], [-3.19306, 9.93781], [-3.27228, 9.84981], [-3.31779, 9.91125], [-3.69703, 9.94279], [-4.25999, 9.76012], [-4.31392, 9.60062], [-4.6426, 9.70696], [-4.96621, 9.89132], [-4.96453, 9.99923], [-5.12465, 10.29788], [-5.39602, 10.2929], [-5.51058, 10.43177], [-5.65135, 10.46767], [-5.78124, 10.43952], [-5.99478, 10.19694], [-6.18851, 10.24244], [-6.1731, 10.46983], [-6.24795, 10.74248], [-6.325, 10.68624], [-6.40646, 10.69922], [-6.42847, 10.5694], [-6.52974, 10.59104], [-6.63541, 10.66893], [-6.68164, 10.35074], [-6.93921, 10.35291], [-7.01186, 10.25111], [-6.97444, 10.21644], [-7.00966, 10.15794], [-7.0603, 10.14711], [-7.13331, 10.24877], [-7.3707, 10.24677], [-7.44555, 10.44602], [-7.52261, 10.4655], [-7.54462, 10.40921], [-7.63048, 10.46334], [-7.92107, 10.15577], [-7.97971, 10.17117], [-8.01225, 10.1021], [-8.11921, 10.04577], [-8.15652, 9.94288], [-8.09434, 9.86936], [-8.14657, 9.55062], [-8.03463, 9.39604], [-7.85056, 9.41812], [-7.90777, 9.20456], [-7.73862, 9.08422], [-7.92518, 8.99332], [-7.95503, 8.81146], [-7.69882, 8.66148], [-7.65653, 8.36873], [-7.92518, 8.50652], [-8.22991, 8.48438], [-8.2411, 8.24196], [-8.062, 8.16071], [-7.98675, 8.20134], [-7.99919, 8.11023], [-7.94695, 8.00925], [-8.06449, 8.04989], [-8.13414, 7.87991], [-8.09931, 7.78626], [-8.21374, 7.54466], [-8.4003, 7.6285], [-8.47114, 7.55676], [-8.41935, 7.51203], [-8.37458, 7.25794], [-8.29249, 7.1691], [-8.31736, 6.82837], [-8.59456, 6.50612], [-8.48652, 6.43797], [-8.45666, 6.49977], [-8.38453, 6.35887], [-8.3298, 6.36381], [-8.17557, 6.28222], [-8.00642, 6.31684], [-7.90692, 6.27728], [-7.83478, 6.20309], [-7.8497, 6.08932], [-7.79747, 6.07696], [-7.78254, 5.99037], [-7.70294, 5.90625], [-7.67309, 5.94337], [-7.48155, 5.80974], [-7.46165, 5.84934], [-7.43677, 5.84687], [-7.43926, 5.74787], [-7.37209, 5.61173], [-7.43428, 5.42355], [-7.36463, 5.32944], [-7.46165, 5.26256], [-7.48901, 5.14118], [-7.55369, 5.08667], [-7.53876, 4.94294], [-7.59349, 4.8909], [-7.53259, 4.35145], [-7.52774, 3.7105]]]] } },
29036     { type: "Feature", properties: { iso1A2: "CK", iso1A3: "COK", iso1N3: "184", wikidata: "Q26988", nameEn: "Cook Islands", country: "NZ", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["682"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-168.15106, -10.26955], [-156.45576, -31.75456], [-156.48634, -15.52824], [-156.50903, -7.4975], [-168.15106, -10.26955]]]] } },
29037     { type: "Feature", properties: { iso1A2: "CL", iso1A3: "CHL", iso1N3: "152", wikidata: "Q298", nameEn: "Chile", groups: ["005", "419", "019", "UN"], callingCodes: ["56"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-68.60702, -52.65781], [-68.41683, -52.33516], [-69.97824, -52.00845], [-71.99889, -51.98018], [-72.33873, -51.59954], [-72.31343, -50.58411], [-73.15765, -50.78337], [-73.55259, -49.92488], [-73.45156, -49.79461], [-73.09655, -49.14342], [-72.56894, -48.81116], [-72.54042, -48.52392], [-72.27662, -48.28727], [-72.50478, -47.80586], [-71.94152, -47.13595], [-71.68577, -46.55385], [-71.75614, -45.61611], [-71.35687, -45.22075], [-72.06985, -44.81756], [-71.26418, -44.75684], [-71.16436, -44.46244], [-71.81318, -44.38097], [-71.64206, -43.64774], [-72.14828, -42.85321], [-72.15541, -42.15941], [-71.74901, -42.11711], [-71.92726, -40.72714], [-71.37826, -38.91474], [-70.89532, -38.6923], [-71.24279, -37.20264], [-70.95047, -36.4321], [-70.38008, -36.02375], [-70.49416, -35.24145], [-69.87386, -34.13344], [-69.88099, -33.34489], [-70.55832, -31.51559], [-70.14479, -30.36595], [-69.8596, -30.26131], [-69.99507, -29.28351], [-69.80969, -29.07185], [-69.66709, -28.44055], [-69.22504, -27.95042], [-68.77586, -27.16029], [-68.43363, -27.08414], [-68.27677, -26.90626], [-68.59048, -26.49861], [-68.56909, -26.28146], [-68.38372, -26.15353], [-68.57622, -25.32505], [-68.38372, -25.08636], [-68.56909, -24.69831], [-68.24825, -24.42596], [-67.33563, -24.04237], [-66.99632, -22.99839], [-67.18382, -22.81525], [-67.54284, -22.89771], [-67.85114, -22.87076], [-68.18816, -21.28614], [-68.40403, -20.94562], [-68.53957, -20.91542], [-68.55383, -20.7355], [-68.44023, -20.62701], [-68.7276, -20.46178], [-68.74273, -20.08817], [-68.57132, -20.03134], [-68.54611, -19.84651], [-68.66761, -19.72118], [-68.41218, -19.40499], [-68.61989, -19.27584], [-68.80602, -19.08355], [-68.87082, -19.06003], [-68.94987, -18.93302], [-69.07432, -18.28259], [-69.14807, -18.16893], [-69.07496, -18.03715], [-69.28671, -17.94844], [-69.34126, -17.72753], [-69.46623, -17.60518], [-69.46897, -17.4988], [-69.66483, -17.65083], [-69.79087, -17.65563], [-69.82868, -17.72048], [-69.75305, -17.94605], [-69.81607, -18.12582], [-69.96732, -18.25992], [-70.16394, -18.31737], [-70.31267, -18.31258], [-70.378, -18.3495], [-70.59118, -18.35072], [-113.52687, -26.52828], [-68.11646, -58.14883], [-66.07313, -55.19618], [-67.11046, -54.94199], [-67.46182, -54.92205], [-68.01394, -54.8753], [-68.60733, -54.9125], [-68.60702, -52.65781]]]] } },
29038     { type: "Feature", properties: { iso1A2: "CM", iso1A3: "CMR", iso1N3: "120", wikidata: "Q1009", nameEn: "Cameroon", groups: ["017", "202", "002", "UN"], callingCodes: ["237"] }, geometry: { type: "MultiPolygon", coordinates: [[[[14.83314, 12.62963], [14.55058, 12.78256], [14.56101, 12.91036], [14.46881, 13.08259], [14.08251, 13.0797], [14.20204, 12.53405], [14.17523, 12.41916], [14.22215, 12.36533], [14.4843, 12.35223], [14.6474, 12.17466], [14.61612, 11.7798], [14.55207, 11.72001], [14.64591, 11.66166], [14.6124, 11.51283], [14.17821, 11.23831], [13.97489, 11.30258], [13.78945, 11.00154], [13.7403, 11.00593], [13.70753, 10.94451], [13.73434, 10.9255], [13.54964, 10.61236], [13.5705, 10.53183], [13.43644, 10.13326], [13.34111, 10.12299], [13.25025, 10.03647], [13.25323, 10.00127], [13.286, 9.9822], [13.27409, 9.93232], [13.24132, 9.91031], [13.25025, 9.86042], [13.29941, 9.8296], [13.25472, 9.76795], [13.22642, 9.57266], [13.02385, 9.49334], [12.85628, 9.36698], [12.91958, 9.33905], [12.90022, 9.11411], [12.81085, 8.91992], [12.79, 8.75361], [12.71701, 8.7595], [12.68722, 8.65938], [12.44146, 8.6152], [12.4489, 8.52536], [12.26123, 8.43696], [12.24782, 8.17904], [12.19271, 8.10826], [12.20909, 7.97553], [11.99908, 7.67302], [12.01844, 7.52981], [11.93205, 7.47812], [11.84864, 7.26098], [11.87396, 7.09398], [11.63117, 6.9905], [11.55818, 6.86186], [11.57755, 6.74059], [11.51499, 6.60892], [11.42264, 6.5882], [11.42041, 6.53789], [11.09495, 6.51717], [11.09644, 6.68437], [10.94302, 6.69325], [10.8179, 6.83377], [10.83727, 6.9358], [10.60789, 7.06885], [10.59746, 7.14719], [10.57214, 7.16345], [10.53639, 6.93432], [10.21466, 6.88996], [10.15135, 7.03781], [9.86314, 6.77756], [9.77824, 6.79088], [9.70674, 6.51717], [9.51757, 6.43874], [8.84209, 5.82562], [8.88156, 5.78857], [8.83687, 5.68483], [8.92029, 5.58403], [8.78027, 5.1243], [8.60302, 4.87353], [8.34397, 4.30689], [9.22018, 3.72052], [9.81162, 2.33797], [9.82123, 2.35097], [9.83754, 2.32428], [9.83238, 2.29079], [9.84716, 2.24676], [9.89012, 2.20457], [9.90749, 2.20049], [9.991, 2.16561], [11.3561, 2.17217], [11.37116, 2.29975], [13.28534, 2.25716], [13.29457, 2.16106], [14.61145, 2.17866], [15.00996, 1.98887], [15.22634, 2.03243], [15.34776, 1.91264], [15.48942, 1.98265], [16.02959, 1.76483], [16.02647, 1.65591], [16.14634, 1.70259], [16.05294, 1.9811], [16.08563, 2.19733], [16.15568, 2.18955], [16.19357, 2.21537], [16.08252, 2.45708], [16.05449, 3.02306], [15.77725, 3.26835], [15.73522, 3.24348], [15.07686, 4.01805], [15.17482, 4.05131], [15.10644, 4.1362], [15.08609, 4.30282], [15.00825, 4.41458], [14.73383, 4.6135], [14.65489, 5.21343], [14.57083, 5.23979], [14.52724, 5.28319], [14.62531, 5.51411], [14.58951, 5.59777], [14.62375, 5.70466], [14.60974, 5.91838], [14.49455, 5.91683], [14.42917, 6.00508], [14.43073, 6.08867], [14.56149, 6.18928], [14.74206, 6.26356], [14.80122, 6.34866], [14.79966, 6.39043], [14.96311, 6.75693], [15.04717, 6.77085], [15.23397, 7.25135], [15.49743, 7.52179], [15.56964, 7.58936], [15.59272, 7.7696], [15.50743, 7.79302], [15.20426, 8.50892], [15.09484, 8.65982], [14.83566, 8.80557], [14.35707, 9.19611], [14.37094, 9.2954], [13.97544, 9.6365], [14.01793, 9.73169], [14.1317, 9.82413], [14.20411, 10.00055], [14.4673, 10.00264], [14.80082, 9.93818], [14.95722, 9.97926], [15.05999, 9.94845], [15.14043, 9.99246], [15.24618, 9.99246], [15.41408, 9.92876], [15.68761, 9.99344], [15.50535, 10.1098], [15.30874, 10.31063], [15.23724, 10.47764], [15.14936, 10.53915], [15.15532, 10.62846], [15.06737, 10.80921], [15.09127, 10.87431], [15.04957, 11.02347], [15.10021, 11.04101], [15.0585, 11.40481], [15.13149, 11.5537], [15.06595, 11.71126], [15.11579, 11.79313], [15.04808, 11.8731], [15.05786, 12.0608], [15.0349, 12.10698], [15.00146, 12.1223], [14.96952, 12.0925], [14.89019, 12.16593], [14.90827, 12.3269], [14.83314, 12.62963]]]] } },
29039     { type: "Feature", properties: { iso1A2: "CN", iso1A3: "CHN", iso1N3: "156", wikidata: "Q148", nameEn: "People's Republic of China" }, geometry: null },
29040     { type: "Feature", properties: { iso1A2: "CO", iso1A3: "COL", iso1N3: "170", wikidata: "Q739", nameEn: "Colombia", groups: ["005", "419", "019", "UN"], callingCodes: ["57"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-71.19849, 12.65801], [-81.58685, 18.0025], [-82.06974, 14.49418], [-82.56142, 11.91792], [-78.79327, 9.93766], [-77.58292, 9.22278], [-77.32389, 8.81247], [-77.45064, 8.49991], [-77.17257, 7.97422], [-77.57185, 7.51147], [-77.72514, 7.72348], [-77.72157, 7.47612], [-77.81426, 7.48319], [-77.89178, 7.22681], [-78.06168, 7.07793], [-82.12561, 4.00341], [-78.87137, 1.47457], [-78.42749, 1.15389], [-77.85677, 0.80197], [-77.7148, 0.85003], [-77.68613, 0.83029], [-77.66416, 0.81604], [-77.67815, 0.73863], [-77.49984, 0.64476], [-77.52001, 0.40782], [-76.89177, 0.24736], [-76.4094, 0.24015], [-76.41215, 0.38228], [-76.23441, 0.42294], [-75.82927, 0.09578], [-75.25764, -0.11943], [-75.18513, -0.0308], [-74.42701, -0.50218], [-74.26675, -0.97229], [-73.65312, -1.26222], [-72.92587, -2.44514], [-71.75223, -2.15058], [-70.94377, -2.23142], [-70.04609, -2.73906], [-70.71396, -3.7921], [-70.52393, -3.87553], [-70.3374, -3.79505], [-69.94708, -4.2431], [-69.43395, -1.42219], [-69.4215, -1.01853], [-69.59796, -0.75136], [-69.603, -0.51947], [-70.03658, -0.19681], [-70.04162, 0.55437], [-69.47696, 0.71065], [-69.20976, 0.57958], [-69.14422, 0.84172], [-69.26017, 1.06856], [-69.82987, 1.07864], [-69.83491, 1.69353], [-69.53746, 1.76408], [-69.38621, 1.70865], [-68.18128, 1.72881], [-68.26699, 1.83463], [-68.18632, 2.00091], [-67.9292, 1.82455], [-67.40488, 2.22258], [-67.299, 1.87494], [-67.15784, 1.80439], [-67.08222, 1.17441], [-66.85795, 1.22998], [-67.21967, 2.35778], [-67.65696, 2.81691], [-67.85862, 2.79173], [-67.85862, 2.86727], [-67.30945, 3.38393], [-67.50067, 3.75812], [-67.62671, 3.74303], [-67.85358, 4.53249], [-67.83341, 5.31104], [-67.59141, 5.5369], [-67.63914, 5.64963], [-67.58558, 5.84537], [-67.43513, 5.98835], [-67.4625, 6.20625], [-67.60654, 6.2891], [-69.41843, 6.1072], [-70.10716, 6.96516], [-70.7596, 7.09799], [-71.03941, 6.98163], [-71.37234, 7.01588], [-71.42212, 7.03854], [-71.44118, 7.02116], [-71.82441, 7.04314], [-72.04895, 7.03837], [-72.19437, 7.37034], [-72.43132, 7.40034], [-72.47415, 7.48928], [-72.45321, 7.57232], [-72.47827, 7.65604], [-72.46763, 7.79518], [-72.44454, 7.86031], [-72.46183, 7.90682], [-72.45806, 7.91141], [-72.47042, 7.92306], [-72.48183, 7.92909], [-72.48801, 7.94329], [-72.47213, 7.96106], [-72.39137, 8.03534], [-72.35163, 8.01163], [-72.36987, 8.19976], [-72.4042, 8.36513], [-72.65474, 8.61428], [-72.77415, 9.10165], [-72.94052, 9.10663], [-73.02119, 9.27584], [-73.36905, 9.16636], [-72.98085, 9.85253], [-72.88002, 10.44309], [-72.4767, 11.1117], [-72.24983, 11.14138], [-71.9675, 11.65536], [-71.3275, 11.85], [-70.92579, 11.96275], [-71.19849, 12.65801]]]] } },
29041     { type: "Feature", properties: { iso1A2: "CP", iso1A3: "CPT", wikidata: "Q161258", nameEn: "Clipperton Island", country: "FR", groups: ["EU", "013", "003", "019", "UN"], isoStatus: "excRes" }, geometry: { type: "MultiPolygon", coordinates: [[[[-110.36279, 9.79626], [-108.755, 9.84085], [-109.04145, 11.13245], [-110.36279, 9.79626]]]] } },
29042     { type: "Feature", properties: { iso1A2: "CQ", iso1A3: "CRQ", iso1N3: "680", m49: "680", wikidata: "Q3405693", ccTLD: null, nameEn: "Sark", country: "GB", groups: ["GG", "830", "Q185086", "154", "150", "UN"], level: "subterritory", isoStatus: "excRes", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44 01481"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.36485, 49.48223], [-2.65349, 49.15373], [-2.09454, 49.46288], [-2.36485, 49.48223]]]] } },
29043     { type: "Feature", properties: { iso1A2: "CR", iso1A3: "CRI", iso1N3: "188", wikidata: "Q800", nameEn: "Costa Rica", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["506"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-83.68276, 11.01562], [-83.66597, 10.79916], [-83.90838, 10.71161], [-84.68197, 11.07568], [-84.92439, 10.9497], [-85.60529, 11.22607], [-85.71223, 11.06868], [-86.14524, 11.09059], [-87.41779, 5.02401], [-82.94503, 7.93865], [-82.89978, 8.04083], [-82.89137, 8.05755], [-82.88641, 8.10219], [-82.9388, 8.26634], [-83.05209, 8.33394], [-82.93056, 8.43465], [-82.8679, 8.44042], [-82.8382, 8.48117], [-82.83322, 8.52464], [-82.83975, 8.54755], [-82.82739, 8.60153], [-82.8794, 8.6981], [-82.92068, 8.74832], [-82.91377, 8.774], [-82.88253, 8.83331], [-82.72126, 8.97125], [-82.93516, 9.07687], [-82.93516, 9.46741], [-82.84871, 9.4973], [-82.87919, 9.62645], [-82.77206, 9.59573], [-82.66667, 9.49746], [-82.61345, 9.49881], [-82.56507, 9.57279], [-82.51044, 9.65379], [-83.54024, 10.96805], [-83.68276, 11.01562]]]] } },
29044     { type: "Feature", properties: { iso1A2: "CU", iso1A3: "CUB", iso1N3: "192", wikidata: "Q241", nameEn: "Cuba", groups: ["029", "003", "419", "019", "UN"], callingCodes: ["53"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-73.62304, 20.6935], [-82.02215, 24.23074], [-85.77883, 21.92705], [-74.81171, 18.82201], [-73.62304, 20.6935]]]] } },
29045     { type: "Feature", properties: { iso1A2: "CV", iso1A3: "CPV", iso1N3: "132", wikidata: "Q1011", nameEn: "Cape Verde", groups: ["Q105472", "011", "202", "002", "UN"], callingCodes: ["238"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-28.81604, 14.57305], [-20.39702, 14.12816], [-23.37101, 19.134], [-28.81604, 14.57305]]]] } },
29046     { type: "Feature", properties: { iso1A2: "CW", iso1A3: "CUW", iso1N3: "531", wikidata: "Q25279", nameEn: "Cura\xE7ao", aliases: ["NL-CW"], country: "NL", groups: ["Q1451600", "029", "003", "419", "019", "UN"], callingCodes: ["599"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-68.90012, 12.62309], [-69.59009, 12.46019], [-68.99639, 11.79035], [-68.33524, 11.78151], [-68.90012, 12.62309]]]] } },
29047     { type: "Feature", properties: { iso1A2: "CX", iso1A3: "CXR", iso1N3: "162", wikidata: "Q31063", nameEn: "Christmas Island", country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[105.66835, -9.31927], [104.67494, -11.2566], [106.66176, -11.14349], [105.66835, -9.31927]]]] } },
29048     { type: "Feature", properties: { iso1A2: "CY", iso1A3: "CYP", iso1N3: "196", wikidata: "Q229", nameEn: "Republic of Cyprus", groups: ["Q644636", "EU", "145", "142", "UN"], driveSide: "left", callingCodes: ["357"] }, geometry: { type: "MultiPolygon", coordinates: [[[[32.60361, 35.16647], [32.46489, 35.48584], [30.15137, 34.08517], [32.74412, 34.43926], [32.75515, 34.64985], [32.76136, 34.68318], [32.79433, 34.67883], [32.82717, 34.70622], [32.86014, 34.70585], [32.86167, 34.68734], [32.9068, 34.66102], [32.91398, 34.67343], [32.93043, 34.67091], [32.92824, 34.66821], [32.93535, 34.66317], [32.93756, 34.67072], [32.93989, 34.67034], [32.94127, 34.67426], [32.95567, 34.6839], [32.98967, 34.67981], [32.98668, 34.67268], [32.99014, 34.65518], [32.98046, 34.65336], [32.969, 34.6549], [32.9639, 34.65866], [32.96154, 34.65587], [32.95277, 34.65104], [32.95471, 34.64528], [32.95323, 34.64075], [32.95516, 34.63541], [32.96312, 34.63236], [32.96718, 34.63446], [32.96968, 34.64046], [33.0138, 34.64424], [33.26744, 34.49942], [33.83531, 34.73974], [33.70575, 34.97947], [33.70639, 34.99303], [33.71514, 35.00294], [33.69731, 35.01754], [33.69938, 35.03123], [33.67678, 35.03866], [33.63765, 35.03869], [33.61215, 35.0527], [33.59658, 35.03635], [33.567, 35.04803], [33.57478, 35.06049], [33.53975, 35.08151], [33.48915, 35.06594], [33.47666, 35.00701], [33.45256, 35.00288], [33.45178, 35.02078], [33.47825, 35.04103], [33.48136, 35.0636], [33.46813, 35.10564], [33.41675, 35.16325], [33.4076, 35.20062], [33.38575, 35.2018], [33.37248, 35.18698], [33.3717, 35.1788], [33.36569, 35.17479], [33.35612, 35.17402], [33.35596, 35.17942], [33.34964, 35.17803], [33.35056, 35.18328], [33.31955, 35.18096], [33.3072, 35.16816], [33.27068, 35.16815], [33.15138, 35.19504], [33.11105, 35.15639], [33.08249, 35.17319], [33.01192, 35.15639], [32.94471, 35.09422], [32.86406, 35.1043], [32.85733, 35.07742], [32.70779, 35.14127], [32.70947, 35.18328], [32.64864, 35.19967], [32.60361, 35.16647]]], [[[33.7343, 35.01178], [33.74144, 35.01053], [33.7492, 35.01319], [33.74983, 35.02274], [33.74265, 35.02329], [33.73781, 35.02181], [33.7343, 35.01178]]], [[[33.77553, 34.99518], [33.77312, 34.9976], [33.75994, 35.00113], [33.75682, 34.99916], [33.76605, 34.99543], [33.76738, 34.99188], [33.7778, 34.98981], [33.77843, 34.988], [33.78149, 34.98854], [33.78318, 34.98699], [33.78571, 34.98951], [33.78917, 34.98854], [33.79191, 34.98914], [33.78516, 34.99582], [33.77553, 34.99518]]], [[[33.82051, 35.0667], [33.8012, 35.04786], [33.81524, 35.04192], [33.83055, 35.02865], [33.82875, 35.01685], [33.84045, 35.00616], [33.85216, 35.00579], [33.85891, 35.001], [33.85488, 34.98462], [33.84616, 34.98511], [33.83459, 34.97448], [33.84028, 34.97179], [33.84741, 34.97167], [33.86018, 34.97381], [33.90146, 34.96458], [33.98684, 34.76642], [35.48515, 34.70851], [35.51152, 36.10954], [34.23164, 35.1777], [33.99999, 35.07016], [33.94869, 35.07277], [33.92495, 35.06789], [33.90247, 35.07686], [33.89322, 35.06789], [33.87438, 35.08118], [33.85261, 35.0574], [33.8355, 35.05777], [33.82051, 35.0667]]]] } },
29049     { type: "Feature", properties: { iso1A2: "CZ", iso1A3: "CZE", iso1N3: "203", wikidata: "Q213", nameEn: "Czechia", groups: ["EU", "151", "150", "UN"], callingCodes: ["420"] }, geometry: { type: "MultiPolygon", coordinates: [[[[14.82803, 50.86966], [14.79139, 50.81438], [14.70661, 50.84096], [14.61993, 50.86049], [14.63434, 50.8883], [14.65259, 50.90513], [14.64802, 50.93241], [14.58024, 50.91443], [14.56374, 50.922], [14.59702, 50.96148], [14.59908, 50.98685], [14.58215, 50.99306], [14.56432, 51.01008], [14.53438, 51.00374], [14.53321, 51.01679], [14.49873, 51.02242], [14.50809, 51.0427], [14.49991, 51.04692], [14.49154, 51.04382], [14.49202, 51.02286], [14.45827, 51.03712], [14.41335, 51.02086], [14.30098, 51.05515], [14.25665, 50.98935], [14.28776, 50.97718], [14.32353, 50.98556], [14.32793, 50.97379], [14.30251, 50.96606], [14.31422, 50.95243], [14.39848, 50.93866], [14.38691, 50.89907], [14.30098, 50.88448], [14.27123, 50.89386], [14.24314, 50.88761], [14.22331, 50.86049], [14.02982, 50.80662], [13.98864, 50.8177], [13.89113, 50.78533], [13.89444, 50.74142], [13.82942, 50.7251], [13.76316, 50.73487], [13.70204, 50.71771], [13.65977, 50.73096], [13.52474, 50.70394], [13.53748, 50.67654], [13.5226, 50.64721], [13.49742, 50.63133], [13.46413, 50.60102], [13.42189, 50.61243], [13.37485, 50.64931], [13.37805, 50.627], [13.32264, 50.60317], [13.32594, 50.58009], [13.29454, 50.57904], [13.25158, 50.59268], [13.19043, 50.50237], [13.13424, 50.51709], [13.08301, 50.50132], [13.0312, 50.50944], [13.02038, 50.4734], [13.02147, 50.44763], [12.98433, 50.42016], [12.94058, 50.40944], [12.82465, 50.45738], [12.73476, 50.43237], [12.73044, 50.42268], [12.70731, 50.39948], [12.67261, 50.41949], [12.51356, 50.39694], [12.48747, 50.37278], [12.49214, 50.35228], [12.48256, 50.34784], [12.46643, 50.35527], [12.43722, 50.33774], [12.43371, 50.32506], [12.39924, 50.32302], [12.40158, 50.29521], [12.36594, 50.28289], [12.35425, 50.23993], [12.33263, 50.24367], [12.32445, 50.20442], [12.33847, 50.19432], [12.32596, 50.17146], [12.29232, 50.17524], [12.28063, 50.19544], [12.28755, 50.22429], [12.23943, 50.24594], [12.24791, 50.25525], [12.26953, 50.25189], [12.25119, 50.27079], [12.20823, 50.2729], [12.18013, 50.32146], [12.10907, 50.32041], [12.13716, 50.27396], [12.09287, 50.25032], [12.19335, 50.19997], [12.21484, 50.16399], [12.1917, 50.13434], [12.2073, 50.10315], [12.23709, 50.10213], [12.27433, 50.0771], [12.26111, 50.06331], [12.30798, 50.05719], [12.49908, 49.97305], [12.47264, 49.94222], [12.55197, 49.92094], [12.48256, 49.83575], [12.46603, 49.78882], [12.40489, 49.76321], [12.4462, 49.70233], [12.52553, 49.68415], [12.53544, 49.61888], [12.56188, 49.6146], [12.60155, 49.52887], [12.64782, 49.52565], [12.64121, 49.47628], [12.669, 49.42935], [12.71227, 49.42363], [12.75854, 49.3989], [12.78168, 49.34618], [12.88414, 49.33541], [12.88249, 49.35479], [12.94859, 49.34079], [13.03618, 49.30417], [13.02957, 49.27399], [13.05883, 49.26259], [13.17665, 49.16713], [13.17019, 49.14339], [13.20405, 49.12303], [13.23689, 49.11412], [13.28242, 49.1228], [13.39479, 49.04812], [13.40802, 48.98851], [13.50221, 48.93752], [13.50552, 48.97441], [13.58319, 48.96899], [13.61624, 48.9462], [13.67739, 48.87886], [13.73854, 48.88538], [13.76994, 48.83537], [13.78977, 48.83319], [13.8096, 48.77877], [13.84023, 48.76988], [14.06151, 48.66873], [14.01482, 48.63788], [14.09104, 48.5943], [14.20691, 48.5898], [14.33909, 48.55852], [14.43076, 48.58855], [14.4587, 48.64695], [14.56139, 48.60429], [14.60808, 48.62881], [14.66762, 48.58215], [14.71794, 48.59794], [14.72756, 48.69502], [14.80584, 48.73489], [14.80821, 48.77711], [14.81545, 48.7874], [14.94773, 48.76268], [14.95641, 48.75915], [14.9758, 48.76857], [14.98112, 48.77524], [14.9782, 48.7766], [14.98032, 48.77959], [14.95072, 48.79101], [14.98917, 48.90082], [14.97612, 48.96983], [14.99878, 49.01444], [15.15534, 48.99056], [15.16358, 48.94278], [15.26177, 48.95766], [15.28305, 48.98831], [15.34823, 48.98444], [15.48027, 48.94481], [15.51357, 48.91549], [15.61622, 48.89541], [15.6921, 48.85973], [15.75341, 48.8516], [15.78087, 48.87644], [15.84404, 48.86921], [16.06034, 48.75436], [16.37345, 48.729], [16.40915, 48.74576], [16.46134, 48.80865], [16.67008, 48.77699], [16.68518, 48.7281], [16.71883, 48.73806], [16.79779, 48.70998], [16.90354, 48.71541], [16.93955, 48.60371], [17.00215, 48.70887], [17.11202, 48.82925], [17.19355, 48.87602], [17.29054, 48.85546], [17.3853, 48.80936], [17.45671, 48.85004], [17.5295, 48.81117], [17.7094, 48.86721], [17.73126, 48.87885], [17.77944, 48.92318], [17.87831, 48.92679], [17.91814, 49.01784], [18.06885, 49.03157], [18.1104, 49.08624], [18.15022, 49.24518], [18.18456, 49.28909], [18.36446, 49.3267], [18.4139, 49.36517], [18.4084, 49.40003], [18.44686, 49.39467], [18.54848, 49.47059], [18.53063, 49.49022], [18.57183, 49.51162], [18.6144, 49.49824], [18.67757, 49.50895], [18.74761, 49.492], [18.84521, 49.51672], [18.84786, 49.5446], [18.80479, 49.6815], [18.72838, 49.68163], [18.69817, 49.70473], [18.62676, 49.71983], [18.62943, 49.74603], [18.62645, 49.75002], [18.61368, 49.75426], [18.61278, 49.7618], [18.57183, 49.83334], [18.60341, 49.86256], [18.57045, 49.87849], [18.57697, 49.91565], [18.54299, 49.92537], [18.54495, 49.9079], [18.53423, 49.89906], [18.41604, 49.93498], [18.33562, 49.94747], [18.33278, 49.92415], [18.31914, 49.91565], [18.27794, 49.93863], [18.27107, 49.96779], [18.21752, 49.97309], [18.20241, 49.99958], [18.10628, 50.00223], [18.07898, 50.04535], [18.03212, 50.06574], [18.00396, 50.04954], [18.04585, 50.03311], [18.04585, 50.01194], [18.00191, 50.01723], [17.86886, 49.97452], [17.77669, 50.02253], [17.7506, 50.07896], [17.6888, 50.12037], [17.66683, 50.10275], [17.59404, 50.16437], [17.70528, 50.18812], [17.76296, 50.23382], [17.72176, 50.25665], [17.74648, 50.29966], [17.69292, 50.32859], [17.67764, 50.28977], [17.58889, 50.27837], [17.3702, 50.28123], [17.34548, 50.2628], [17.34273, 50.32947], [17.27681, 50.32246], [17.19991, 50.3654], [17.19579, 50.38817], [17.14498, 50.38117], [17.1224, 50.39494], [16.89229, 50.45117], [16.85933, 50.41093], [16.90877, 50.38642], [16.94448, 50.31281], [16.99803, 50.30316], [17.02138, 50.27772], [16.99803, 50.25753], [17.02825, 50.23118], [17.00353, 50.21449], [16.98018, 50.24172], [16.8456, 50.20834], [16.7014, 50.09659], [16.63137, 50.1142], [16.55446, 50.16613], [16.56407, 50.21009], [16.42674, 50.32509], [16.39379, 50.3207], [16.3622, 50.34875], [16.36495, 50.37679], [16.30289, 50.38292], [16.28118, 50.36891], [16.22821, 50.41054], [16.21585, 50.40627], [16.19526, 50.43291], [16.31413, 50.50274], [16.34572, 50.49575], [16.44597, 50.58041], [16.33611, 50.66579], [16.23174, 50.67101], [16.20839, 50.63096], [16.10265, 50.66405], [16.02437, 50.60046], [15.98317, 50.61528], [16.0175, 50.63009], [15.97219, 50.69799], [15.87331, 50.67188], [15.81683, 50.75666], [15.73186, 50.73885], [15.43798, 50.80833], [15.3803, 50.77187], [15.36656, 50.83956], [15.2773, 50.8907], [15.27043, 50.97724], [15.2361, 50.99886], [15.1743, 50.9833], [15.16744, 51.01959], [15.11937, 50.99021], [15.10152, 51.01095], [15.06218, 51.02269], [15.03895, 51.0123], [15.02433, 51.0242], [14.96419, 50.99108], [15.01088, 50.97984], [14.99852, 50.86817], [14.82803, 50.86966]]]] } },
29050     { type: "Feature", properties: { iso1A2: "DE", iso1A3: "DEU", iso1N3: "276", wikidata: "Q183", nameEn: "Germany", groups: ["EU", "155", "150", "UN"], callingCodes: ["49"] }, geometry: { type: "MultiPolygon", coordinates: [[[[8.70847, 47.68904], [8.71773, 47.69088], [8.70237, 47.71453], [8.66416, 47.71367], [8.67508, 47.6979], [8.65769, 47.68928], [8.66837, 47.68437], [8.68985, 47.69552], [8.70847, 47.68904]]], [[[8.72617, 47.69651], [8.72809, 47.69282], [8.75856, 47.68969], [8.79511, 47.67462], [8.79966, 47.70222], [8.76965, 47.7075], [8.77309, 47.72059], [8.80663, 47.73821], [8.82002, 47.71458], [8.86989, 47.70504], [8.85065, 47.68209], [8.87383, 47.67045], [8.87625, 47.65441], [8.89946, 47.64769], [8.94093, 47.65596], [9.02093, 47.6868], [9.09891, 47.67801], [9.13845, 47.66389], [9.15181, 47.66904], [9.1705, 47.65513], [9.1755, 47.65584], [9.17593, 47.65399], [9.18203, 47.65598], [9.25619, 47.65939], [9.55125, 47.53629], [9.72736, 47.53457], [9.76748, 47.5934], [9.80254, 47.59419], [9.82591, 47.58158], [9.8189, 47.54688], [9.87499, 47.52953], [9.87733, 47.54688], [9.92407, 47.53111], [9.96029, 47.53899], [10.00003, 47.48216], [10.03859, 47.48927], [10.07131, 47.45531], [10.09001, 47.46005], [10.1052, 47.4316], [10.06897, 47.40709], [10.09819, 47.35724], [10.11805, 47.37228], [10.16362, 47.36674], [10.17648, 47.38889], [10.2127, 47.38019], [10.22774, 47.38904], [10.23757, 47.37609], [10.19998, 47.32832], [10.2147, 47.31014], [10.17648, 47.29149], [10.17531, 47.27167], [10.23257, 47.27088], [10.33424, 47.30813], [10.39851, 47.37623], [10.4324, 47.38494], [10.4359, 47.41183], [10.47446, 47.43318], [10.46278, 47.47901], [10.44291, 47.48453], [10.4324, 47.50111], [10.44992, 47.5524], [10.43473, 47.58394], [10.47329, 47.58552], [10.48849, 47.54057], [10.56912, 47.53584], [10.60337, 47.56755], [10.63456, 47.5591], [10.68832, 47.55752], [10.6965, 47.54253], [10.7596, 47.53228], [10.77596, 47.51729], [10.88814, 47.53701], [10.91268, 47.51334], [10.86945, 47.5015], [10.87061, 47.4786], [10.90918, 47.48571], [10.93839, 47.48018], [10.92437, 47.46991], [10.98513, 47.42882], [10.97111, 47.41617], [10.97111, 47.39561], [11.11835, 47.39719], [11.12536, 47.41222], [11.20482, 47.43198], [11.25157, 47.43277], [11.22002, 47.3964], [11.27844, 47.39956], [11.29597, 47.42566], [11.33804, 47.44937], [11.4175, 47.44621], [11.38128, 47.47465], [11.4362, 47.51413], [11.52618, 47.50939], [11.58578, 47.52281], [11.58811, 47.55515], [11.60681, 47.57881], [11.63934, 47.59202], [11.84052, 47.58354], [11.85572, 47.60166], [12.0088, 47.62451], [12.02282, 47.61033], [12.05788, 47.61742], [12.13734, 47.60639], [12.17824, 47.61506], [12.18145, 47.61019], [12.17737, 47.60121], [12.18568, 47.6049], [12.20398, 47.60667], [12.20801, 47.61082], [12.19895, 47.64085], [12.18507, 47.65984], [12.18347, 47.66663], [12.16769, 47.68167], [12.16217, 47.70105], [12.18303, 47.70065], [12.22571, 47.71776], [12.2542, 47.7433], [12.26238, 47.73544], [12.24017, 47.69534], [12.26004, 47.67725], [12.27991, 47.68827], [12.336, 47.69534], [12.37222, 47.68433], [12.43883, 47.6977], [12.44117, 47.6741], [12.50076, 47.62293], [12.53816, 47.63553], [12.57438, 47.63238], [12.6071, 47.6741], [12.7357, 47.6787], [12.77777, 47.66689], [12.76492, 47.64485], [12.82101, 47.61493], [12.77427, 47.58025], [12.80699, 47.54477], [12.84672, 47.54556], [12.85256, 47.52741], [12.9624, 47.47452], [12.98344, 47.48716], [12.9998, 47.46267], [13.04537, 47.49426], [13.03252, 47.53373], [13.05355, 47.56291], [13.04537, 47.58183], [13.06641, 47.58577], [13.06407, 47.60075], [13.09562, 47.63304], [13.07692, 47.68814], [13.01382, 47.72116], [12.98578, 47.7078], [12.92969, 47.71094], [12.91333, 47.7178], [12.90274, 47.72513], [12.91711, 47.74026], [12.9353, 47.74788], [12.94371, 47.76281], [12.93202, 47.77302], [12.96311, 47.79957], [12.98543, 47.82896], [13.00588, 47.84374], [12.94163, 47.92927], [12.93886, 47.94046], [12.93642, 47.94436], [12.93419, 47.94063], [12.92668, 47.93879], [12.91985, 47.94069], [12.9211, 47.95135], [12.91683, 47.95647], [12.87476, 47.96195], [12.8549, 48.01122], [12.76141, 48.07373], [12.74973, 48.10885], [12.7617, 48.12796], [12.78595, 48.12445], [12.80676, 48.14979], [12.82673, 48.15245], [12.8362, 48.15876], [12.836, 48.1647], [12.84475, 48.16556], [12.87126, 48.20318], [12.95306, 48.20629], [13.02083, 48.25689], [13.0851, 48.27711], [13.126, 48.27867], [13.18093, 48.29577], [13.26039, 48.29422], [13.30897, 48.31575], [13.40709, 48.37292], [13.43929, 48.43386], [13.42527, 48.45711], [13.45727, 48.51092], [13.43695, 48.55776], [13.45214, 48.56472], [13.46967, 48.55157], [13.50663, 48.57506], [13.50131, 48.58091], [13.51291, 48.59023], [13.57535, 48.55912], [13.59705, 48.57013], [13.62508, 48.55501], [13.65186, 48.55092], [13.66113, 48.53558], [13.72802, 48.51208], [13.74816, 48.53058], [13.7513, 48.5624], [13.76921, 48.55324], [13.80519, 48.58026], [13.80038, 48.59487], [13.82609, 48.62345], [13.81901, 48.6761], [13.81283, 48.68426], [13.81791, 48.69832], [13.79337, 48.71375], [13.81863, 48.73257], [13.82266, 48.75544], [13.84023, 48.76988], [13.8096, 48.77877], [13.78977, 48.83319], [13.76994, 48.83537], [13.73854, 48.88538], [13.67739, 48.87886], [13.61624, 48.9462], [13.58319, 48.96899], [13.50552, 48.97441], [13.50221, 48.93752], [13.40802, 48.98851], [13.39479, 49.04812], [13.28242, 49.1228], [13.23689, 49.11412], [13.20405, 49.12303], [13.17019, 49.14339], [13.17665, 49.16713], [13.05883, 49.26259], [13.02957, 49.27399], [13.03618, 49.30417], [12.94859, 49.34079], [12.88249, 49.35479], [12.88414, 49.33541], [12.78168, 49.34618], [12.75854, 49.3989], [12.71227, 49.42363], [12.669, 49.42935], [12.64121, 49.47628], [12.64782, 49.52565], [12.60155, 49.52887], [12.56188, 49.6146], [12.53544, 49.61888], [12.52553, 49.68415], [12.4462, 49.70233], [12.40489, 49.76321], [12.46603, 49.78882], [12.48256, 49.83575], [12.55197, 49.92094], [12.47264, 49.94222], [12.49908, 49.97305], [12.30798, 50.05719], [12.26111, 50.06331], [12.27433, 50.0771], [12.23709, 50.10213], [12.2073, 50.10315], [12.1917, 50.13434], [12.21484, 50.16399], [12.19335, 50.19997], [12.09287, 50.25032], [12.13716, 50.27396], [12.10907, 50.32041], [12.18013, 50.32146], [12.20823, 50.2729], [12.25119, 50.27079], [12.26953, 50.25189], [12.24791, 50.25525], [12.23943, 50.24594], [12.28755, 50.22429], [12.28063, 50.19544], [12.29232, 50.17524], [12.32596, 50.17146], [12.33847, 50.19432], [12.32445, 50.20442], [12.33263, 50.24367], [12.35425, 50.23993], [12.36594, 50.28289], [12.40158, 50.29521], [12.39924, 50.32302], [12.43371, 50.32506], [12.43722, 50.33774], [12.46643, 50.35527], [12.48256, 50.34784], [12.49214, 50.35228], [12.48747, 50.37278], [12.51356, 50.39694], [12.67261, 50.41949], [12.70731, 50.39948], [12.73044, 50.42268], [12.73476, 50.43237], [12.82465, 50.45738], [12.94058, 50.40944], [12.98433, 50.42016], [13.02147, 50.44763], [13.02038, 50.4734], [13.0312, 50.50944], [13.08301, 50.50132], [13.13424, 50.51709], [13.19043, 50.50237], [13.25158, 50.59268], [13.29454, 50.57904], [13.32594, 50.58009], [13.32264, 50.60317], [13.37805, 50.627], [13.37485, 50.64931], [13.42189, 50.61243], [13.46413, 50.60102], [13.49742, 50.63133], [13.5226, 50.64721], [13.53748, 50.67654], [13.52474, 50.70394], [13.65977, 50.73096], [13.70204, 50.71771], [13.76316, 50.73487], [13.82942, 50.7251], [13.89444, 50.74142], [13.89113, 50.78533], [13.98864, 50.8177], [14.02982, 50.80662], [14.22331, 50.86049], [14.24314, 50.88761], [14.27123, 50.89386], [14.30098, 50.88448], [14.38691, 50.89907], [14.39848, 50.93866], [14.31422, 50.95243], [14.30251, 50.96606], [14.32793, 50.97379], [14.32353, 50.98556], [14.28776, 50.97718], [14.25665, 50.98935], [14.30098, 51.05515], [14.41335, 51.02086], [14.45827, 51.03712], [14.49202, 51.02286], [14.49154, 51.04382], [14.49991, 51.04692], [14.50809, 51.0427], [14.49873, 51.02242], [14.53321, 51.01679], [14.53438, 51.00374], [14.56432, 51.01008], [14.58215, 50.99306], [14.59908, 50.98685], [14.59702, 50.96148], [14.56374, 50.922], [14.58024, 50.91443], [14.64802, 50.93241], [14.65259, 50.90513], [14.63434, 50.8883], [14.61993, 50.86049], [14.70661, 50.84096], [14.79139, 50.81438], [14.82803, 50.86966], [14.81664, 50.88148], [14.89681, 50.9422], [14.89252, 50.94999], [14.92942, 50.99744], [14.95529, 51.04552], [14.97938, 51.07742], [14.98229, 51.11354], [14.99689, 51.12205], [14.99079, 51.14284], [14.99646, 51.14365], [15.00083, 51.14974], [14.99414, 51.15813], [14.99311, 51.16249], [15.0047, 51.16874], [15.01242, 51.21285], [15.04288, 51.28387], [14.98008, 51.33449], [14.96899, 51.38367], [14.9652, 51.44793], [14.94749, 51.47155], [14.73219, 51.52922], [14.72652, 51.53902], [14.73047, 51.54606], [14.71125, 51.56209], [14.7727, 51.61263], [14.75759, 51.62318], [14.75392, 51.67445], [14.69065, 51.70842], [14.66386, 51.73282], [14.64625, 51.79472], [14.60493, 51.80473], [14.59089, 51.83302], [14.6588, 51.88359], [14.6933, 51.9044], [14.70601, 51.92944], [14.7177, 51.94048], [14.72163, 51.95188], [14.71836, 51.95606], [14.7139, 51.95643], [14.70488, 51.97679], [14.71339, 52.00337], [14.76026, 52.06624], [14.72971, 52.09167], [14.6917, 52.10283], [14.67683, 52.13936], [14.70616, 52.16927], [14.68344, 52.19612], [14.71319, 52.22144], [14.70139, 52.25038], [14.58149, 52.28007], [14.56378, 52.33838], [14.55228, 52.35264], [14.54423, 52.42568], [14.63056, 52.48993], [14.60081, 52.53116], [14.6289, 52.57136], [14.61073, 52.59847], [14.22071, 52.81175], [14.13806, 52.82392], [14.12256, 52.84311], [14.15873, 52.87715], [14.14056, 52.95786], [14.25954, 53.00264], [14.35044, 53.05829], [14.38679, 53.13669], [14.36696, 53.16444], [14.37853, 53.20405], [14.40662, 53.21098], [14.45125, 53.26241], [14.44133, 53.27427], [14.4215, 53.27724], [14.35209, 53.49506], [14.3273, 53.50587], [14.30416, 53.55499], [14.31904, 53.61581], [14.2853, 53.63392], [14.28477, 53.65955], [14.27133, 53.66613], [14.2836, 53.67721], [14.26782, 53.69866], [14.27249, 53.74464], [14.21323, 53.8664], [14.20823, 53.90776], [14.18544, 53.91258], [14.20647, 53.91671], [14.22634, 53.9291], [14.20811, 54.12784], [13.93395, 54.84044], [12.85844, 54.82438], [11.90309, 54.38543], [11.00303, 54.63689], [10.31111, 54.65968], [10.16755, 54.73883], [9.89314, 54.84171], [9.73563, 54.8247], [9.61187, 54.85548], [9.62734, 54.88057], [9.58937, 54.88785], [9.4659, 54.83131], [9.43155, 54.82586], [9.41213, 54.84254], [9.38532, 54.83968], [9.36496, 54.81749], [9.33849, 54.80233], [9.32771, 54.80602], [9.2474, 54.8112], [9.23445, 54.83432], [9.24631, 54.84726], [9.20571, 54.85841], [9.14275, 54.87421], [9.04629, 54.87249], [8.92795, 54.90452], [8.81178, 54.90518], [8.76387, 54.8948], [8.63979, 54.91069], [8.55769, 54.91837], [8.45719, 55.06747], [8.02459, 55.09613], [5.45168, 54.20039], [6.91025, 53.44221], [7.00198, 53.32672], [7.19052, 53.31866], [7.21679, 53.20058], [7.22681, 53.18165], [7.17898, 53.13817], [7.21694, 53.00742], [7.07253, 52.81083], [7.04557, 52.63318], [6.77307, 52.65375], [6.71641, 52.62905], [6.69507, 52.488], [6.94293, 52.43597], [6.99041, 52.47235], [7.03417, 52.40237], [7.07044, 52.37805], [7.02703, 52.27941], [7.06365, 52.23789], [7.03729, 52.22695], [6.9897, 52.2271], [6.97189, 52.20329], [6.83984, 52.11728], [6.76117, 52.11895], [6.68128, 52.05052], [6.83035, 51.9905], [6.82357, 51.96711], [6.72319, 51.89518], [6.68386, 51.91861], [6.58556, 51.89386], [6.50231, 51.86313], [6.47179, 51.85395], [6.38815, 51.87257], [6.40704, 51.82771], [6.30593, 51.84998], [6.29872, 51.86801], [6.21443, 51.86801], [6.15349, 51.90439], [6.11551, 51.89769], [6.16902, 51.84094], [6.10337, 51.84829], [6.06705, 51.86136], [5.99848, 51.83195], [5.94568, 51.82786], [5.98665, 51.76944], [5.95003, 51.7493], [6.04091, 51.71821], [6.02767, 51.6742], [6.11759, 51.65609], [6.09055, 51.60564], [6.18017, 51.54096], [6.21724, 51.48568], [6.20654, 51.40049], [6.22641, 51.39948], [6.22674, 51.36135], [6.16977, 51.33169], [6.07889, 51.24432], [6.07889, 51.17038], [6.17384, 51.19589], [6.16706, 51.15677], [5.98292, 51.07469], [5.9541, 51.03496], [5.9134, 51.06736], [5.86735, 51.05182], [5.87849, 51.01969], [5.90493, 51.00198], [5.90296, 50.97356], [5.95282, 50.98728], [6.02697, 50.98303], [6.01615, 50.93367], [6.09297, 50.92066], [6.07486, 50.89307], [6.08805, 50.87223], [6.07693, 50.86025], [6.07431, 50.84674], [6.05702, 50.85179], [6.05623, 50.8572], [6.01921, 50.84435], [6.02328, 50.81694], [6.00462, 50.80065], [5.98404, 50.80988], [5.97497, 50.79992], [6.02624, 50.77453], [6.01976, 50.75398], [6.03889, 50.74618], [6.0326, 50.72647], [6.0406, 50.71848], [6.04428, 50.72861], [6.11707, 50.72231], [6.17852, 50.6245], [6.26957, 50.62444], [6.2476, 50.60392], [6.24888, 50.59869], [6.24005, 50.58732], [6.22581, 50.5907], [6.20281, 50.56952], [6.17739, 50.55875], [6.17802, 50.54179], [6.19735, 50.53576], [6.19579, 50.5313], [6.18716, 50.52653], [6.19193, 50.5212], [6.20599, 50.52089], [6.22335, 50.49578], [6.26637, 50.50272], [6.30809, 50.50058], [6.3465, 50.48833], [6.34005, 50.46083], [6.37219, 50.45397], [6.36852, 50.40776], [6.34406, 50.37994], [6.3688, 50.35898], [6.40785, 50.33557], [6.40641, 50.32425], [6.35701, 50.31139], [6.32488, 50.32333], [6.29949, 50.30887], [6.28797, 50.27458], [6.208, 50.25179], [6.16853, 50.2234], [6.18364, 50.20815], [6.18739, 50.1822], [6.14588, 50.17106], [6.14132, 50.14971], [6.15298, 50.14126], [6.1379, 50.12964], [6.12055, 50.09171], [6.11274, 50.05916], [6.13458, 50.04141], [6.13044, 50.02929], [6.14666, 50.02207], [6.13794, 50.01466], [6.13273, 50.02019], [6.1295, 50.01849], [6.13806, 50.01056], [6.14948, 50.00908], [6.14147, 49.99563], [6.1701, 49.98518], [6.16466, 49.97086], [6.17872, 49.9537], [6.18554, 49.95622], [6.18045, 49.96611], [6.19089, 49.96991], [6.19856, 49.95053], [6.22094, 49.94955], [6.22608, 49.929], [6.21882, 49.92403], [6.22926, 49.92096], [6.23496, 49.89972], [6.26146, 49.88203], [6.28874, 49.87592], [6.29692, 49.86685], [6.30963, 49.87021], [6.32303, 49.85133], [6.32098, 49.83728], [6.33585, 49.83785], [6.34267, 49.84974], [6.36576, 49.85032], [6.40022, 49.82029], [6.42521, 49.81591], [6.42905, 49.81091], [6.44131, 49.81443], [6.45425, 49.81164], [6.47111, 49.82263], [6.48718, 49.81267], [6.50647, 49.80916], [6.51215, 49.80124], [6.52121, 49.81338], [6.53122, 49.80666], [6.52169, 49.79787], [6.50534, 49.78952], [6.51669, 49.78336], [6.51056, 49.77515], [6.51828, 49.76855], [6.51646, 49.75961], [6.50174, 49.75292], [6.50193, 49.73291], [6.51805, 49.72425], [6.51397, 49.72058], [6.50261, 49.72718], [6.49535, 49.72645], [6.49694, 49.72205], [6.5042, 49.71808], [6.50647, 49.71353], [6.49785, 49.71118], [6.48014, 49.69767], [6.46048, 49.69092], [6.44654, 49.67799], [6.42937, 49.66857], [6.42726, 49.66078], [6.43768, 49.66021], [6.4413, 49.65722], [6.41861, 49.61723], [6.39822, 49.60081], [6.385, 49.59946], [6.37464, 49.58886], [6.38342, 49.5799], [6.38024, 49.57593], [6.36676, 49.57813], [6.35825, 49.57053], [6.38228, 49.55855], [6.38072, 49.55171], [6.35666, 49.52931], [6.36788, 49.50377], [6.36907, 49.48931], [6.36778, 49.46937], [6.38352, 49.46463], [6.39168, 49.4667], [6.40274, 49.46546], [6.42432, 49.47683], [6.55404, 49.42464], [6.533, 49.40748], [6.60091, 49.36864], [6.58807, 49.35358], [6.572, 49.35027], [6.60186, 49.31055], [6.66583, 49.28065], [6.69274, 49.21661], [6.71843, 49.2208], [6.73256, 49.20486], [6.71137, 49.18808], [6.73765, 49.16375], [6.78265, 49.16793], [6.83385, 49.15162], [6.84703, 49.15734], [6.86225, 49.18185], [6.85016, 49.19354], [6.85119, 49.20038], [6.83555, 49.21249], [6.85939, 49.22376], [6.89298, 49.20863], [6.91875, 49.22261], [6.93831, 49.2223], [6.94028, 49.21641], [6.95963, 49.203], [6.97273, 49.2099], [7.01318, 49.19018], [7.03459, 49.19096], [7.0274, 49.17042], [7.03178, 49.15734], [7.04662, 49.13724], [7.04409, 49.12123], [7.04843, 49.11422], [7.05548, 49.11185], [7.06642, 49.11415], [7.07162, 49.1255], [7.09007, 49.13094], [7.07859, 49.15031], [7.10715, 49.15631], [7.10384, 49.13787], [7.12504, 49.14253], [7.1358, 49.1282], [7.1593, 49.1204], [7.23473, 49.12971], [7.29514, 49.11426], [7.3195, 49.14231], [7.35995, 49.14399], [7.3662, 49.17308], [7.44052, 49.18354], [7.44455, 49.16765], [7.49473, 49.17], [7.49172, 49.13915], [7.53012, 49.09818], [7.56416, 49.08136], [7.62575, 49.07654], [7.63618, 49.05428], [7.75948, 49.04562], [7.79557, 49.06583], [7.86386, 49.03499], [7.93641, 49.05544], [7.97783, 49.03161], [8.14189, 48.97833], [8.22604, 48.97352], [8.20031, 48.95856], [8.19989, 48.95825], [8.12813, 48.87985], [8.10253, 48.81829], [8.06802, 48.78957], [8.0326, 48.79017], [8.01534, 48.76085], [7.96994, 48.75606], [7.96812, 48.72491], [7.89002, 48.66317], [7.84098, 48.64217], [7.80057, 48.5857], [7.80167, 48.54758], [7.80647, 48.51239], [7.76833, 48.48945], [7.73109, 48.39192], [7.74562, 48.32736], [7.69022, 48.30018], [7.6648, 48.22219], [7.57137, 48.12292], [7.56966, 48.03265], [7.62302, 47.97898], [7.55673, 47.87371], [7.52921, 47.77747], [7.54761, 47.72912], [7.53722, 47.71635], [7.51266, 47.70197], [7.51915, 47.68335], [7.52067, 47.66437], [7.53384, 47.65115], [7.5591, 47.63849], [7.57423, 47.61628], [7.58851, 47.60794], [7.59301, 47.60058], [7.58945, 47.59017], [7.60523, 47.58519], [7.60459, 47.57869], [7.61929, 47.57683], [7.64309, 47.59151], [7.64213, 47.5944], [7.64599, 47.59695], [7.67395, 47.59212], [7.68229, 47.59905], [7.69385, 47.60099], [7.68486, 47.59601], [7.67115, 47.5871], [7.68904, 47.57133], [7.67655, 47.56435], [7.63338, 47.56256], [7.65083, 47.54662], [7.66174, 47.54554], [7.6656, 47.53752], [7.68101, 47.53232], [7.69642, 47.53297], [7.71961, 47.54219], [7.75261, 47.54599], [7.79486, 47.55691], [7.81901, 47.58798], [7.84412, 47.5841], [7.88664, 47.58854], [7.90673, 47.57674], [7.91251, 47.55031], [7.94494, 47.54511], [7.95682, 47.55789], [7.97581, 47.55493], [8.00113, 47.55616], [8.02136, 47.55096], [8.04383, 47.55443], [8.06663, 47.56374], [8.08557, 47.55768], [8.10002, 47.56504], [8.10395, 47.57918], [8.11543, 47.5841], [8.13662, 47.58432], [8.13823, 47.59147], [8.14947, 47.59558], [8.1652, 47.5945], [8.19378, 47.61636], [8.20617, 47.62141], [8.22011, 47.6181], [8.22577, 47.60385], [8.23809, 47.61204], [8.25863, 47.61571], [8.26313, 47.6103], [8.2824, 47.61225], [8.29722, 47.60603], [8.29524, 47.5919], [8.30277, 47.58607], [8.32735, 47.57133], [8.35512, 47.57014], [8.38273, 47.56608], [8.39477, 47.57826], [8.43235, 47.56617], [8.49431, 47.58107], [8.48949, 47.588], [8.46637, 47.58389], [8.45578, 47.60121], [8.50747, 47.61897], [8.51686, 47.63476], [8.55756, 47.62394], [8.57586, 47.59537], [8.60348, 47.61204], [8.59545, 47.64298], [8.60701, 47.65271], [8.61471, 47.64514], [8.60412, 47.63735], [8.62049, 47.63757], [8.62884, 47.65098], [8.61113, 47.66332], [8.6052, 47.67258], [8.57683, 47.66158], [8.56141, 47.67088], [8.52801, 47.66059], [8.5322, 47.64687], [8.49656, 47.64709], [8.46605, 47.64103], [8.4667, 47.65747], [8.44711, 47.65379], [8.42264, 47.66667], [8.41346, 47.66676], [8.40473, 47.67499], [8.4211, 47.68407], [8.40569, 47.69855], [8.44807, 47.72426], [8.45771, 47.7493], [8.48868, 47.77215], [8.56814, 47.78001], [8.56415, 47.80633], [8.61657, 47.79998], [8.62408, 47.7626], [8.64425, 47.76398], [8.65292, 47.80066], [8.68022, 47.78599], [8.68985, 47.75686], [8.71778, 47.76571], [8.74251, 47.75168], [8.70543, 47.73121], [8.73671, 47.7169], [8.72617, 47.69651]]]] } },
29051     { type: "Feature", properties: { iso1A2: "DG", iso1A3: "DGA", wikidata: "Q184851", nameEn: "Diego Garcia", country: "GB", groups: ["IO", "BOTS", "014", "202", "002", "UN"], isoStatus: "excRes", callingCodes: ["246"] }, geometry: { type: "MultiPolygon", coordinates: [[[[73.14823, -7.76302], [73.09982, -6.07324], [71.43792, -7.73904], [73.14823, -7.76302]]]] } },
29052     { type: "Feature", properties: { iso1A2: "DJ", iso1A3: "DJI", iso1N3: "262", wikidata: "Q977", nameEn: "Djibouti", groups: ["014", "202", "002", "UN"], callingCodes: ["253"] }, geometry: { type: "MultiPolygon", coordinates: [[[[43.90659, 12.3823], [43.90659, 12.3823], [43.32909, 12.59711], [43.29075, 12.79154], [42.86195, 12.58747], [42.7996, 12.42629], [42.6957, 12.36201], [42.46941, 12.52661], [42.4037, 12.46478], [41.95461, 11.81157], [41.82878, 11.72361], [41.77727, 11.49902], [41.8096, 11.33606], [41.80056, 10.97127], [42.06302, 10.92599], [42.13691, 10.97586], [42.42669, 10.98493], [42.62989, 11.09711], [42.75111, 11.06992], [42.79037, 10.98493], [42.95776, 10.98533], [43.90659, 12.3823]]]] } },
29053     { type: "Feature", properties: { iso1A2: "DK", iso1A3: "DNK", iso1N3: "208", wikidata: "Q756617", nameEn: "Kingdom of Denmark" }, geometry: null },
29054     { type: "Feature", properties: { iso1A2: "DM", iso1A3: "DMA", iso1N3: "212", wikidata: "Q784", nameEn: "Dominica", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 767"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-61.32485, 14.91445], [-60.86656, 15.82603], [-61.95646, 15.5094], [-61.32485, 14.91445]]]] } },
29055     { type: "Feature", properties: { iso1A2: "DO", iso1A3: "DOM", iso1N3: "214", wikidata: "Q786", nameEn: "Dominican Republic", groups: ["029", "003", "419", "019", "UN"], callingCodes: ["1 809", "1 829", "1 849"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-67.87844, 21.7938], [-72.38946, 20.27111], [-71.77419, 19.73128], [-71.75865, 19.70231], [-71.7429, 19.58445], [-71.71449, 19.55364], [-71.71268, 19.53374], [-71.6802, 19.45008], [-71.69448, 19.37866], [-71.77766, 19.33823], [-71.73229, 19.26686], [-71.62642, 19.21212], [-71.65337, 19.11759], [-71.69938, 19.10916], [-71.71088, 19.08353], [-71.74088, 19.0437], [-71.88102, 18.95007], [-71.77766, 18.95007], [-71.72624, 18.87802], [-71.71885, 18.78423], [-71.82556, 18.62551], [-71.95412, 18.64939], [-72.00201, 18.62312], [-71.88102, 18.50125], [-71.90875, 18.45821], [-71.69952, 18.34101], [-71.78271, 18.18302], [-71.75465, 18.14405], [-71.74994, 18.11115], [-71.73783, 18.07177], [-71.75671, 18.03456], [-72.29523, 17.48026], [-68.39466, 16.14167], [-67.87844, 21.7938]]]] } },
29056     { type: "Feature", properties: { iso1A2: "DZ", iso1A3: "DZA", iso1N3: "012", wikidata: "Q262", nameEn: "Algeria", groups: ["015", "002", "UN"], callingCodes: ["213"] }, geometry: { type: "MultiPolygon", coordinates: [[[[8.59123, 37.14286], [5.10072, 39.89531], [-2.27707, 35.35051], [-2.21248, 35.08532], [-2.21445, 35.04378], [-2.04734, 34.93218], [-1.97833, 34.93218], [-1.97469, 34.886], [-1.73707, 34.74226], [-1.84569, 34.61907], [-1.69788, 34.48056], [-1.78042, 34.39018], [-1.64666, 34.10405], [-1.73494, 33.71721], [-1.59508, 33.59929], [-1.67067, 33.27084], [-1.46249, 33.0499], [-1.54244, 32.95499], [-1.37794, 32.73628], [-0.9912, 32.52467], [-1.24998, 32.32993], [-1.24453, 32.1917], [-1.15735, 32.12096], [-1.22829, 32.07832], [-2.46166, 32.16603], [-2.93873, 32.06557], [-2.82784, 31.79459], [-3.66314, 31.6339], [-3.66386, 31.39202], [-3.77647, 31.31912], [-3.77103, 31.14984], [-3.54944, 31.0503], [-3.65418, 30.85566], [-3.64735, 30.67539], [-4.31774, 30.53229], [-4.6058, 30.28343], [-5.21671, 29.95253], [-5.58831, 29.48103], [-5.72121, 29.52322], [-5.75616, 29.61407], [-6.69965, 29.51623], [-6.78351, 29.44634], [-6.95824, 29.50924], [-7.61585, 29.36252], [-8.6715, 28.71194], [-8.66879, 27.6666], [-8.66674, 27.31569], [-4.83423, 24.99935], [1.15698, 21.12843], [1.20992, 20.73533], [3.24648, 19.81703], [3.12501, 19.1366], [3.36082, 18.9745], [4.26651, 19.14224], [5.8153, 19.45101], [7.38361, 20.79165], [7.48273, 20.87258], [11.96886, 23.51735], [11.62498, 24.26669], [11.41061, 24.21456], [10.85323, 24.5595], [10.33159, 24.5465], [10.02432, 24.98124], [10.03146, 25.35635], [9.38834, 26.19288], [9.51696, 26.39148], [9.89569, 26.57696], [9.78136, 29.40961], [9.3876, 30.16738], [9.55544, 30.23971], [9.07483, 32.07865], [8.35999, 32.50101], [8.31895, 32.83483], [8.1179, 33.05086], [8.11433, 33.10175], [7.83028, 33.18851], [7.73687, 33.42114], [7.54088, 33.7726], [7.52851, 34.06493], [7.66174, 34.20167], [7.74207, 34.16492], [7.81242, 34.21841], [7.86264, 34.3987], [8.20482, 34.57575], [8.29655, 34.72798], [8.25189, 34.92009], [8.30727, 34.95378], [8.3555, 35.10007], [8.47318, 35.23376], [8.30329, 35.29884], [8.36086, 35.47774], [8.35371, 35.66373], [8.26472, 35.73669], [8.2626, 35.91733], [8.40731, 36.42208], [8.18936, 36.44939], [8.16167, 36.48817], [8.47609, 36.66607], [8.46537, 36.7706], [8.57613, 36.78062], [8.67706, 36.8364], [8.62972, 36.86499], [8.64044, 36.9401], [8.59123, 37.14286]]]] } },
29057     { type: "Feature", properties: { iso1A2: "EA", wikidata: "Q28868874", nameEn: "Ceuta, Melilla", country: "ES", level: "territory", isoStatus: "excRes" }, geometry: null },
29058     { type: "Feature", properties: { iso1A2: "EC", iso1A3: "ECU", iso1N3: "218", wikidata: "Q736", nameEn: "Ecuador" }, geometry: null },
29059     { type: "Feature", properties: { iso1A2: "EE", iso1A3: "EST", iso1N3: "233", wikidata: "Q191", nameEn: "Estonia", aliases: ["EW"], groups: ["EU", "154", "150", "UN"], callingCodes: ["372"] }, geometry: { type: "MultiPolygon", coordinates: [[[[26.32936, 60.00121], [20.5104, 59.15546], [19.84909, 57.57876], [22.80496, 57.87798], [23.20055, 57.56697], [24.26221, 57.91787], [24.3579, 57.87471], [25.19484, 58.0831], [25.28237, 57.98539], [25.29581, 58.08288], [25.73499, 57.90193], [26.05949, 57.84744], [26.0324, 57.79037], [26.02456, 57.78342], [26.027, 57.78158], [26.0266, 57.77441], [26.02069, 57.77169], [26.02415, 57.76865], [26.03332, 57.7718], [26.0543, 57.76105], [26.08098, 57.76619], [26.2029, 57.7206], [26.1866, 57.6849], [26.29253, 57.59244], [26.46527, 57.56885], [26.54675, 57.51813], [26.90364, 57.62823], [27.34698, 57.52242], [27.31919, 57.57672], [27.40393, 57.62125], [27.3746, 57.66834], [27.52615, 57.72843], [27.50171, 57.78842], [27.56689, 57.83356], [27.78526, 57.83963], [27.81841, 57.89244], [27.67282, 57.92627], [27.62393, 58.09462], [27.48541, 58.22615], [27.55489, 58.39525], [27.36366, 58.78381], [27.74429, 58.98351], [27.80482, 59.1116], [27.87978, 59.18097], [27.90911, 59.24353], [28.00689, 59.28351], [28.14215, 59.28934], [28.19284, 59.35791], [28.20537, 59.36491], [28.21137, 59.38058], [28.19061, 59.39962], [28.04187, 59.47017], [27.85643, 59.58538], [26.90044, 59.63819], [26.32936, 60.00121]]]] } },
29060     { type: "Feature", properties: { iso1A2: "EG", iso1A3: "EGY", iso1N3: "818", wikidata: "Q79", nameEn: "Egypt", groups: ["015", "002", "UN"], callingCodes: ["20"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.62659, 31.82938], [26.92891, 33.39516], [24.8458, 31.39877], [25.01077, 30.73861], [24.71117, 30.17441], [24.99968, 29.24574], [24.99885, 21.99535], [33.17563, 22.00405], [34.0765, 22.00501], [37.8565, 22.00903], [34.4454, 27.91479], [34.8812, 29.36878], [34.92298, 29.45305], [34.26742, 31.21998], [34.24012, 31.29591], [34.23572, 31.2966], [34.21853, 31.32363], [34.052, 31.46619], [33.62659, 31.82938]]]] } },
29061     { type: "Feature", properties: { iso1A2: "EH", iso1A3: "ESH", iso1N3: "732", wikidata: "Q6250", nameEn: "Western Sahara", groups: ["015", "002"], callingCodes: ["212"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-8.66879, 27.6666], [-8.77527, 27.66663], [-8.71787, 26.9898], [-9.08698, 26.98639], [-9.56957, 26.90042], [-9.81998, 26.71379], [-10.68417, 26.90984], [-11.35695, 26.8505], [-11.23622, 26.72023], [-11.38635, 26.611], [-11.62052, 26.05229], [-12.06001, 26.04442], [-12.12281, 25.13682], [-12.92147, 24.39502], [-13.00628, 24.01923], [-13.75627, 23.77231], [-14.10361, 22.75501], [-14.1291, 22.41636], [-14.48112, 22.00886], [-14.47329, 21.63839], [-14.78487, 21.36587], [-16.44269, 21.39745], [-16.9978, 21.36239], [-17.02707, 21.34022], [-17.21511, 21.34226], [-17.35589, 20.80492], [-17.0471, 20.76408], [-17.0695, 20.85742], [-17.06781, 20.92697], [-17.0396, 20.9961], [-17.0357, 21.05368], [-16.99806, 21.12142], [-16.95474, 21.33997], [-13.01525, 21.33343], [-13.08438, 22.53866], [-13.15313, 22.75649], [-13.10753, 22.89493], [-13.00412, 23.02297], [-12.5741, 23.28975], [-12.36213, 23.3187], [-12.14969, 23.41935], [-12.00251, 23.4538], [-12.0002, 25.9986], [-8.66721, 25.99918], [-8.66674, 27.31569], [-8.66879, 27.6666]]]] } },
29062     { type: "Feature", properties: { iso1A2: "ER", iso1A3: "ERI", iso1N3: "232", wikidata: "Q986", nameEn: "Eritrea", groups: ["014", "202", "002", "UN"], callingCodes: ["291"] }, geometry: { type: "MultiPolygon", coordinates: [[[[40.99158, 15.81743], [39.63762, 18.37348], [38.57727, 17.98125], [38.45916, 17.87167], [38.37133, 17.66269], [38.13362, 17.53906], [37.50967, 17.32199], [37.42694, 17.04041], [36.99777, 17.07172], [36.92193, 16.23451], [36.76371, 15.80831], [36.69761, 15.75323], [36.54276, 15.23478], [36.44337, 15.14963], [36.54376, 14.25597], [36.56536, 14.26177], [36.55659, 14.28237], [36.63364, 14.31172], [36.85787, 14.32201], [37.01622, 14.2561], [37.09486, 14.27155], [37.13206, 14.40746], [37.3106, 14.44657], [37.47319, 14.2149], [37.528, 14.18413], [37.91287, 14.89447], [38.0364, 14.72745], [38.25562, 14.67287], [38.3533, 14.51323], [38.45748, 14.41445], [38.78306, 14.4754], [38.98058, 14.54895], [39.02834, 14.63717], [39.16074, 14.65187], [39.14772, 14.61827], [39.19547, 14.56996], [39.23888, 14.56365], [39.26927, 14.48801], [39.2302, 14.44598], [39.2519, 14.40393], [39.37685, 14.54402], [39.52756, 14.49011], [39.50585, 14.55735], [39.58182, 14.60987], [39.76632, 14.54264], [39.9443, 14.41024], [40.07236, 14.54264], [40.14649, 14.53969], [40.21128, 14.39342], [40.25686, 14.41445], [40.9167, 14.11152], [41.25097, 13.60787], [41.62864, 13.38626], [42.05841, 12.80912], [42.21469, 12.75832], [42.2798, 12.6355], [42.4037, 12.46478], [42.46941, 12.52661], [42.6957, 12.36201], [42.7996, 12.42629], [42.86195, 12.58747], [43.29075, 12.79154], [40.99158, 15.81743]]]] } },
29063     { type: "Feature", properties: { iso1A2: "ES", iso1A3: "ESP", iso1N3: "724", wikidata: "Q29", nameEn: "Spain" }, geometry: null },
29064     { type: "Feature", properties: { iso1A2: "ET", iso1A3: "ETH", iso1N3: "231", wikidata: "Q115", nameEn: "Ethiopia", groups: ["014", "202", "002", "UN"], callingCodes: ["251"] }, geometry: { type: "MultiPolygon", coordinates: [[[[42.4037, 12.46478], [42.2798, 12.6355], [42.21469, 12.75832], [42.05841, 12.80912], [41.62864, 13.38626], [41.25097, 13.60787], [40.9167, 14.11152], [40.25686, 14.41445], [40.21128, 14.39342], [40.14649, 14.53969], [40.07236, 14.54264], [39.9443, 14.41024], [39.76632, 14.54264], [39.58182, 14.60987], [39.50585, 14.55735], [39.52756, 14.49011], [39.37685, 14.54402], [39.2519, 14.40393], [39.2302, 14.44598], [39.26927, 14.48801], [39.23888, 14.56365], [39.19547, 14.56996], [39.14772, 14.61827], [39.16074, 14.65187], [39.02834, 14.63717], [38.98058, 14.54895], [38.78306, 14.4754], [38.45748, 14.41445], [38.3533, 14.51323], [38.25562, 14.67287], [38.0364, 14.72745], [37.91287, 14.89447], [37.528, 14.18413], [37.47319, 14.2149], [37.3106, 14.44657], [37.13206, 14.40746], [37.09486, 14.27155], [37.01622, 14.2561], [36.85787, 14.32201], [36.63364, 14.31172], [36.55659, 14.28237], [36.56536, 14.26177], [36.54376, 14.25597], [36.44653, 13.95666], [36.48824, 13.83954], [36.38993, 13.56459], [36.24545, 13.36759], [36.13374, 12.92665], [36.16651, 12.88019], [36.14268, 12.70879], [36.01458, 12.72478], [35.70476, 12.67101], [35.24302, 11.91132], [35.11492, 11.85156], [35.05832, 11.71158], [35.09556, 11.56278], [34.95704, 11.24448], [35.01215, 11.19626], [34.93172, 10.95946], [34.97789, 10.91559], [34.97491, 10.86147], [34.86916, 10.78832], [34.86618, 10.74588], [34.77532, 10.69027], [34.77383, 10.74588], [34.59062, 10.89072], [34.4372, 10.781], [34.2823, 10.53508], [34.34783, 10.23914], [34.32102, 10.11599], [34.22718, 10.02506], [34.20484, 9.9033], [34.13186, 9.7492], [34.08717, 9.55243], [34.10229, 9.50238], [34.14304, 9.04654], [34.14453, 8.60204], [34.01346, 8.50041], [33.89579, 8.4842], [33.87195, 8.41938], [33.71407, 8.3678], [33.66938, 8.44442], [33.54575, 8.47094], [33.3119, 8.45474], [33.19721, 8.40317], [33.1853, 8.29264], [33.18083, 8.13047], [33.08401, 8.05822], [33.0006, 7.90333], [33.04944, 7.78989], [33.24637, 7.77939], [33.32531, 7.71297], [33.44745, 7.7543], [33.71407, 7.65983], [33.87642, 7.5491], [34.02984, 7.36449], [34.03878, 7.27437], [34.01495, 7.25664], [34.19369, 7.12807], [34.19369, 7.04382], [34.35753, 6.91963], [34.47669, 6.91076], [34.53925, 6.82794], [34.53776, 6.74808], [34.65096, 6.72589], [34.77459, 6.5957], [34.87736, 6.60161], [35.01738, 6.46991], [34.96227, 6.26415], [35.00546, 5.89387], [35.12611, 5.68937], [35.13058, 5.62118], [35.31188, 5.50106], [35.29938, 5.34042], [35.50792, 5.42431], [35.8576, 5.33413], [35.81968, 5.10757], [35.82118, 4.77382], [35.9419, 4.61933], [35.95449, 4.53244], [36.03924, 4.44406], [36.84474, 4.44518], [37.07724, 4.33503], [38.14168, 3.62487], [38.45812, 3.60445], [38.52336, 3.62551], [38.91938, 3.51198], [39.07736, 3.5267], [39.19954, 3.47834], [39.49444, 3.45521], [39.51551, 3.40895], [39.55132, 3.39634], [39.58339, 3.47434], [39.76808, 3.67058], [39.86043, 3.86974], [40.77498, 4.27683], [41.1754, 3.94079], [41.89488, 3.97375], [42.07619, 4.17667], [42.55853, 4.20518], [42.84526, 4.28357], [42.97746, 4.44032], [43.04177, 4.57923], [43.40263, 4.79289], [44.02436, 4.9451], [44.98104, 4.91821], [47.97917, 8.00124], [47.92477, 8.00111], [46.99339, 7.9989], [44.19222, 8.93028], [43.32613, 9.59205], [43.23518, 9.84605], [43.0937, 9.90579], [42.87643, 10.18441], [42.69452, 10.62672], [42.95776, 10.98533], [42.79037, 10.98493], [42.75111, 11.06992], [42.62989, 11.09711], [42.42669, 10.98493], [42.13691, 10.97586], [42.06302, 10.92599], [41.80056, 10.97127], [41.8096, 11.33606], [41.77727, 11.49902], [41.82878, 11.72361], [41.95461, 11.81157], [42.4037, 12.46478]]]] } },
29065     { type: "Feature", properties: { iso1A2: "EU", iso1A3: "EUE", wikidata: "Q458", nameEn: "European Union", level: "union", isoStatus: "excRes" }, geometry: null },
29066     { type: "Feature", properties: { iso1A2: "FI", iso1A3: "FIN", iso1N3: "246", wikidata: "Q33", nameEn: "Finland", aliases: ["SF"] }, geometry: null },
29067     { type: "Feature", properties: { iso1A2: "FJ", iso1A3: "FJI", iso1N3: "242", wikidata: "Q712", nameEn: "Fiji", groups: ["054", "009", "UN"], driveSide: "left", callingCodes: ["679"] }, geometry: { type: "MultiPolygon", coordinates: [[[[174.245, -23.1974], [179.99999, -22.5], [179.99999, -11.5], [174, -11.5], [174.245, -23.1974]]], [[[-176.76826, -14.95183], [-180, -14.96041], [-180, -22.90585], [-176.74538, -22.89767], [-176.76826, -14.95183]]]] } },
29068     { type: "Feature", properties: { iso1A2: "FK", iso1A3: "FLK", iso1N3: "238", wikidata: "Q9648", nameEn: "Falkland Islands", country: "GB", groups: ["BOTS", "005", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["500"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.67376, -55.11859], [-54.56126, -51.26248], [-61.26735, -50.63919], [-63.67376, -55.11859]]]] } },
29069     { type: "Feature", properties: { iso1A2: "FM", iso1A3: "FSM", iso1N3: "583", wikidata: "Q702", nameEn: "Federated States of Micronesia", groups: ["057", "009", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["691"] }, geometry: { type: "MultiPolygon", coordinates: [[[[138.20583, 13.3783], [136.27107, 6.73747], [156.88247, -1.39237], [165.19726, 6.22546], [138.20583, 13.3783]]]] } },
29070     { type: "Feature", properties: { iso1A2: "FO", iso1A3: "FRO", iso1N3: "234", wikidata: "Q4628", nameEn: "Faroe Islands", country: "DK", groups: ["154", "150", "UN"], callingCodes: ["298"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-8.51774, 62.35338], [-6.51083, 60.95272], [-5.70102, 62.77194], [-8.51774, 62.35338]]]] } },
29071     { type: "Feature", properties: { iso1A2: "FR", iso1A3: "FRA", iso1N3: "250", wikidata: "Q142", nameEn: "France" }, geometry: null },
29072     { type: "Feature", properties: { iso1A2: "FX", iso1A3: "FXX", iso1N3: "249", wikidata: "Q212429", nameEn: "Metropolitan France", country: "FR", groups: ["EU", "155", "150", "UN"], isoStatus: "excRes", callingCodes: ["33"] }, geometry: { type: "MultiPolygon", coordinates: [[[[2.55904, 51.07014], [2.18458, 51.52087], [1.17405, 50.74239], [-2.02963, 49.91866], [-2.09454, 49.46288], [-1.83944, 49.23037], [-2.00491, 48.86706], [-2.65349, 49.15373], [-6.28985, 48.93406], [-1.81005, 43.59738], [-1.77289, 43.38957], [-1.79319, 43.37497], [-1.78332, 43.36399], [-1.78714, 43.35476], [-1.77068, 43.34396], [-1.75334, 43.34107], [-1.75079, 43.3317], [-1.7397, 43.32979], [-1.73074, 43.29481], [-1.69407, 43.31378], [-1.62481, 43.30726], [-1.63052, 43.28591], [-1.61341, 43.25269], [-1.57674, 43.25269], [-1.55963, 43.28828], [-1.50992, 43.29481], [-1.45289, 43.27049], [-1.40942, 43.27272], [-1.3758, 43.24511], [-1.41562, 43.12815], [-1.47555, 43.08372], [-1.44067, 43.047], [-1.35272, 43.02658], [-1.34419, 43.09665], [-1.32209, 43.1127], [-1.27118, 43.11961], [-1.30052, 43.09581], [-1.30531, 43.06859], [-1.25244, 43.04164], [-1.22881, 43.05534], [-1.10333, 43.0059], [-1.00963, 42.99279], [-0.97133, 42.96239], [-0.81652, 42.95166], [-0.75478, 42.96916], [-0.72037, 42.92541], [-0.73422, 42.91228], [-0.72608, 42.89318], [-0.69837, 42.87945], [-0.67637, 42.88303], [-0.55497, 42.77846], [-0.50863, 42.82713], [-0.44334, 42.79939], [-0.41319, 42.80776], [-0.38833, 42.80132], [-0.3122, 42.84788], [-0.17939, 42.78974], [-0.16141, 42.79535], [-0.10519, 42.72761], [-0.02468, 42.68513], [0.17569, 42.73424], [0.25336, 42.7174], [0.29407, 42.67431], [0.36251, 42.72282], [0.40214, 42.69779], [0.67873, 42.69458], [0.65421, 42.75872], [0.66121, 42.84021], [0.711, 42.86372], [0.93089, 42.79154], [0.96166, 42.80629], [0.98292, 42.78754], [1.0804, 42.78569], [1.15928, 42.71407], [1.35562, 42.71944], [1.44197, 42.60217], [1.47986, 42.61346], [1.46718, 42.63296], [1.48043, 42.65203], [1.50867, 42.64483], [1.55418, 42.65669], [1.60085, 42.62703], [1.63485, 42.62957], [1.6625, 42.61982], [1.68267, 42.62533], [1.73452, 42.61515], [1.72588, 42.59098], [1.7858, 42.57698], [1.73683, 42.55492], [1.72515, 42.50338], [1.76335, 42.48863], [1.83037, 42.48395], [1.88853, 42.4501], [1.93663, 42.45439], [1.94292, 42.44316], [1.94061, 42.43333], [1.94084, 42.43039], [1.9574, 42.42401], [1.96482, 42.37787], [2.00488, 42.35399], [2.06241, 42.35906], [2.11621, 42.38393], [2.12789, 42.41291], [2.16599, 42.42314], [2.20578, 42.41633], [2.25551, 42.43757], [2.38504, 42.39977], [2.43299, 42.39423], [2.43508, 42.37568], [2.48457, 42.33933], [2.54382, 42.33406], [2.55516, 42.35351], [2.57934, 42.35808], [2.6747, 42.33974], [2.65311, 42.38771], [2.72056, 42.42298], [2.75497, 42.42578], [2.77464, 42.41046], [2.84335, 42.45724], [2.85675, 42.45444], [2.86983, 42.46843], [2.88413, 42.45938], [2.92107, 42.4573], [2.94283, 42.48174], [2.96518, 42.46692], [3.03734, 42.47363], [3.08167, 42.42748], [3.10027, 42.42621], [3.11379, 42.43646], [3.17156, 42.43545], [3.75438, 42.33445], [7.60802, 41.05927], [10.09675, 41.44089], [9.56115, 43.20816], [7.50102, 43.51859], [7.42422, 43.72209], [7.40903, 43.7296], [7.41113, 43.73156], [7.41291, 43.73168], [7.41298, 43.73311], [7.41233, 43.73439], [7.42062, 43.73977], [7.42299, 43.74176], [7.42443, 43.74087], [7.42809, 43.74396], [7.43013, 43.74895], [7.43624, 43.75014], [7.43708, 43.75197], [7.4389, 43.75151], [7.4379, 43.74963], [7.47823, 43.73341], [7.53006, 43.78405], [7.50423, 43.84345], [7.49355, 43.86551], [7.51162, 43.88301], [7.56075, 43.89932], [7.56858, 43.94506], [7.60771, 43.95772], [7.65266, 43.9763], [7.66848, 43.99943], [7.6597, 44.03009], [7.72508, 44.07578], [7.66878, 44.12795], [7.68694, 44.17487], [7.63245, 44.17877], [7.62155, 44.14881], [7.36364, 44.11882], [7.34547, 44.14359], [7.27827, 44.1462], [7.16929, 44.20352], [7.00764, 44.23736], [6.98221, 44.28289], [6.89171, 44.36637], [6.88784, 44.42043], [6.94504, 44.43112], [6.86233, 44.49834], [6.85507, 44.53072], [6.96042, 44.62129], [6.95133, 44.66264], [7.00582, 44.69364], [7.07484, 44.68073], [7.00401, 44.78782], [7.02217, 44.82519], [6.93499, 44.8664], [6.90774, 44.84322], [6.75518, 44.89915], [6.74519, 44.93661], [6.74791, 45.01939], [6.66981, 45.02324], [6.62803, 45.11175], [6.7697, 45.16044], [6.85144, 45.13226], [6.96706, 45.20841], [7.07074, 45.21228], [7.13115, 45.25386], [7.10572, 45.32924], [7.18019, 45.40071], [7.00037, 45.509], [6.98948, 45.63869], [6.80785, 45.71864], [6.80785, 45.83265], [6.95315, 45.85163], [7.04151, 45.92435], [7.00946, 45.9944], [6.93862, 46.06502], [6.87868, 46.03855], [6.89321, 46.12548], [6.78968, 46.14058], [6.86052, 46.28512], [6.77152, 46.34784], [6.8024, 46.39171], [6.82312, 46.42661], [6.53358, 46.45431], [6.25432, 46.3632], [6.21981, 46.31304], [6.24826, 46.30175], [6.25137, 46.29014], [6.23775, 46.27822], [6.24952, 46.26255], [6.26749, 46.24745], [6.29474, 46.26221], [6.31041, 46.24417], [6.29663, 46.22688], [6.27694, 46.21566], [6.26007, 46.21165], [6.24821, 46.20531], [6.23913, 46.20511], [6.23544, 46.20714], [6.22175, 46.20045], [6.22222, 46.19888], [6.21844, 46.19837], [6.21603, 46.19507], [6.21273, 46.19409], [6.21114, 46.1927], [6.20539, 46.19163], [6.19807, 46.18369], [6.19552, 46.18401], [6.18707, 46.17999], [6.18871, 46.16644], [6.18116, 46.16187], [6.15305, 46.15194], [6.13397, 46.1406], [6.09926, 46.14373], [6.09199, 46.15191], [6.07491, 46.14879], [6.05203, 46.15191], [6.04564, 46.14031], [6.03614, 46.13712], [6.01791, 46.14228], [5.9871, 46.14499], [5.97893, 46.13303], [5.95781, 46.12925], [5.9641, 46.14412], [5.97508, 46.15863], [5.98188, 46.17392], [5.98846, 46.17046], [5.99573, 46.18587], [5.96515, 46.19638], [5.97542, 46.21525], [6.02461, 46.23313], [6.03342, 46.2383], [6.04602, 46.23127], [6.05029, 46.23518], [6.0633, 46.24583], [6.07072, 46.24085], [6.08563, 46.24651], [6.10071, 46.23772], [6.12446, 46.25059], [6.11926, 46.2634], [6.1013, 46.28512], [6.11697, 46.29547], [6.1198, 46.31157], [6.13876, 46.33844], [6.15738, 46.3491], [6.16987, 46.36759], [6.15985, 46.37721], [6.15016, 46.3778], [6.09926, 46.40768], [6.06407, 46.41676], [6.08427, 46.44305], [6.07269, 46.46244], [6.1567, 46.54402], [6.11084, 46.57649], [6.27135, 46.68251], [6.38351, 46.73171], [6.45209, 46.77502], [6.43216, 46.80336], [6.46456, 46.88865], [6.43341, 46.92703], [6.71531, 47.0494], [6.68823, 47.06616], [6.76788, 47.1208], [6.8489, 47.15933], [6.9508, 47.24338], [6.95108, 47.26428], [6.94316, 47.28747], [7.05305, 47.33304], [7.0564, 47.35134], [7.03125, 47.36996], [6.87959, 47.35335], [6.88542, 47.37262], [6.93744, 47.40714], [6.93953, 47.43388], [7.0024, 47.45264], [6.98425, 47.49432], [7.0231, 47.50522], [7.07425, 47.48863], [7.12781, 47.50371], [7.16249, 47.49025], [7.19583, 47.49455], [7.17026, 47.44312], [7.24669, 47.4205], [7.33526, 47.44186], [7.35603, 47.43432], [7.40308, 47.43638], [7.43088, 47.45846], [7.4462, 47.46264], [7.4583, 47.47216], [7.42923, 47.48628], [7.43356, 47.49712], [7.47534, 47.47932], [7.51076, 47.49651], [7.49804, 47.51798], [7.5229, 47.51644], [7.53199, 47.5284], [7.51904, 47.53515], [7.50588, 47.52856], [7.49691, 47.53821], [7.50873, 47.54546], [7.51723, 47.54578], [7.52831, 47.55347], [7.53634, 47.55553], [7.55652, 47.56779], [7.55689, 47.57232], [7.56548, 47.57617], [7.56684, 47.57785], [7.58386, 47.57536], [7.58945, 47.59017], [7.59301, 47.60058], [7.58851, 47.60794], [7.57423, 47.61628], [7.5591, 47.63849], [7.53384, 47.65115], [7.52067, 47.66437], [7.51915, 47.68335], [7.51266, 47.70197], [7.53722, 47.71635], [7.54761, 47.72912], [7.52921, 47.77747], [7.55673, 47.87371], [7.62302, 47.97898], [7.56966, 48.03265], [7.57137, 48.12292], [7.6648, 48.22219], [7.69022, 48.30018], [7.74562, 48.32736], [7.73109, 48.39192], [7.76833, 48.48945], [7.80647, 48.51239], [7.80167, 48.54758], [7.80057, 48.5857], [7.84098, 48.64217], [7.89002, 48.66317], [7.96812, 48.72491], [7.96994, 48.75606], [8.01534, 48.76085], [8.0326, 48.79017], [8.06802, 48.78957], [8.10253, 48.81829], [8.12813, 48.87985], [8.19989, 48.95825], [8.20031, 48.95856], [8.22604, 48.97352], [8.14189, 48.97833], [7.97783, 49.03161], [7.93641, 49.05544], [7.86386, 49.03499], [7.79557, 49.06583], [7.75948, 49.04562], [7.63618, 49.05428], [7.62575, 49.07654], [7.56416, 49.08136], [7.53012, 49.09818], [7.49172, 49.13915], [7.49473, 49.17], [7.44455, 49.16765], [7.44052, 49.18354], [7.3662, 49.17308], [7.35995, 49.14399], [7.3195, 49.14231], [7.29514, 49.11426], [7.23473, 49.12971], [7.1593, 49.1204], [7.1358, 49.1282], [7.12504, 49.14253], [7.10384, 49.13787], [7.10715, 49.15631], [7.07859, 49.15031], [7.09007, 49.13094], [7.07162, 49.1255], [7.06642, 49.11415], [7.05548, 49.11185], [7.04843, 49.11422], [7.04409, 49.12123], [7.04662, 49.13724], [7.03178, 49.15734], [7.0274, 49.17042], [7.03459, 49.19096], [7.01318, 49.19018], [6.97273, 49.2099], [6.95963, 49.203], [6.94028, 49.21641], [6.93831, 49.2223], [6.91875, 49.22261], [6.89298, 49.20863], [6.85939, 49.22376], [6.83555, 49.21249], [6.85119, 49.20038], [6.85016, 49.19354], [6.86225, 49.18185], [6.84703, 49.15734], [6.83385, 49.15162], [6.78265, 49.16793], [6.73765, 49.16375], [6.71137, 49.18808], [6.73256, 49.20486], [6.71843, 49.2208], [6.69274, 49.21661], [6.66583, 49.28065], [6.60186, 49.31055], [6.572, 49.35027], [6.58807, 49.35358], [6.60091, 49.36864], [6.533, 49.40748], [6.55404, 49.42464], [6.42432, 49.47683], [6.40274, 49.46546], [6.39168, 49.4667], [6.38352, 49.46463], [6.36778, 49.46937], [6.3687, 49.4593], [6.28818, 49.48465], [6.27875, 49.503], [6.25029, 49.50609], [6.2409, 49.51408], [6.19543, 49.50536], [6.17386, 49.50934], [6.15366, 49.50226], [6.16115, 49.49297], [6.14321, 49.48796], [6.12814, 49.49365], [6.12346, 49.4735], [6.10325, 49.4707], [6.09845, 49.46351], [6.10072, 49.45268], [6.08373, 49.45594], [6.07887, 49.46399], [6.05553, 49.46663], [6.04176, 49.44801], [6.02743, 49.44845], [6.02648, 49.45451], [5.97693, 49.45513], [5.96876, 49.49053], [5.94224, 49.49608], [5.94128, 49.50034], [5.86571, 49.50015], [5.83389, 49.52152], [5.83467, 49.52717], [5.84466, 49.53027], [5.83648, 49.5425], [5.81664, 49.53775], [5.80871, 49.5425], [5.81838, 49.54777], [5.79195, 49.55228], [5.77435, 49.56298], [5.7577, 49.55915], [5.75649, 49.54321], [5.64505, 49.55146], [5.60909, 49.51228], [5.55001, 49.52729], [5.46541, 49.49825], [5.46734, 49.52648], [5.43713, 49.5707], [5.3974, 49.61596], [5.34837, 49.62889], [5.33851, 49.61599], [5.3137, 49.61225], [5.30214, 49.63055], [5.33039, 49.6555], [5.31465, 49.66846], [5.26232, 49.69456], [5.14545, 49.70287], [5.09249, 49.76193], [4.96714, 49.79872], [4.85464, 49.78995], [4.86965, 49.82271], [4.85134, 49.86457], [4.88529, 49.9236], [4.78827, 49.95609], [4.8382, 50.06738], [4.88602, 50.15182], [4.83279, 50.15331], [4.82438, 50.16878], [4.75237, 50.11314], [4.70064, 50.09384], [4.68695, 49.99685], [4.5414, 49.96911], [4.51098, 49.94659], [4.43488, 49.94122], [4.35051, 49.95315], [4.31963, 49.97043], [4.20532, 49.95803], [4.14239, 49.98034], [4.13508, 50.01976], [4.16294, 50.04719], [4.23101, 50.06945], [4.20147, 50.13535], [4.13561, 50.13078], [4.16014, 50.19239], [4.15524, 50.21103], [4.21945, 50.25539], [4.20651, 50.27333], [4.17861, 50.27443], [4.17347, 50.28838], [4.15524, 50.2833], [4.16808, 50.25786], [4.13665, 50.25609], [4.11954, 50.30425], [4.10957, 50.30234], [4.10237, 50.31247], [4.0689, 50.3254], [4.0268, 50.35793], [3.96771, 50.34989], [3.90781, 50.32814], [3.84314, 50.35219], [3.73911, 50.34809], [3.70987, 50.3191], [3.71009, 50.30305], [3.66976, 50.34563], [3.65709, 50.36873], [3.67262, 50.38663], [3.67494, 50.40239], [3.66153, 50.45165], [3.64426, 50.46275], [3.61014, 50.49568], [3.58361, 50.49049], [3.5683, 50.50192], [3.49509, 50.48885], [3.51564, 50.5256], [3.47385, 50.53397], [3.44629, 50.51009], [3.37693, 50.49538], [3.28575, 50.52724], [3.2729, 50.60718], [3.23951, 50.6585], [3.264, 50.67668], [3.2536, 50.68977], [3.26141, 50.69151], [3.26063, 50.70086], [3.24593, 50.71389], [3.22042, 50.71019], [3.20845, 50.71662], [3.19017, 50.72569], [3.20064, 50.73547], [3.18811, 50.74025], [3.18339, 50.74981], [3.16476, 50.76843], [3.15017, 50.79031], [3.1257, 50.78603], [3.11987, 50.79188], [3.11206, 50.79416], [3.10614, 50.78303], [3.09163, 50.77717], [3.04314, 50.77674], [3.00537, 50.76588], [2.96778, 50.75242], [2.95019, 50.75138], [2.90873, 50.702], [2.91036, 50.6939], [2.90069, 50.69263], [2.88504, 50.70656], [2.87937, 50.70298], [2.86985, 50.7033], [2.8483, 50.72276], [2.81056, 50.71773], [2.71165, 50.81295], [2.63331, 50.81457], [2.59093, 50.91751], [2.63074, 50.94746], [2.57551, 51.00326], [2.55904, 51.07014]], [[1.99838, 42.44682], [1.98378, 42.44697], [1.96125, 42.45364], [1.95606, 42.45785], [1.96215, 42.47854], [1.97003, 42.48081], [1.97227, 42.48487], [1.97697, 42.48568], [1.98022, 42.49569], [1.98916, 42.49351], [1.99766, 42.4858], [1.98579, 42.47486], [1.99216, 42.46208], [2.01564, 42.45171], [1.99838, 42.44682]]]] } },
29073     { type: "Feature", properties: { iso1A2: "GA", iso1A3: "GAB", iso1N3: "266", wikidata: "Q1000", nameEn: "Gabon", groups: ["017", "202", "002", "UN"], callingCodes: ["241"] }, geometry: { type: "MultiPolygon", coordinates: [[[[13.29457, 2.16106], [13.28534, 2.25716], [11.37116, 2.29975], [11.3561, 2.17217], [11.35307, 1.00251], [9.79648, 1.0019], [9.75065, 1.06753], [9.66433, 1.06723], [7.24416, -0.64092], [10.75913, -4.39519], [11.12647, -3.94169], [11.22301, -3.69888], [11.48764, -3.51089], [11.57949, -3.52798], [11.68608, -3.68942], [11.87083, -3.71571], [11.92719, -3.62768], [11.8318, -3.5812], [11.96554, -3.30267], [11.70227, -3.17465], [11.70558, -3.0773], [11.80365, -3.00424], [11.64798, -2.81146], [11.5359, -2.85654], [11.64487, -2.61865], [11.57637, -2.33379], [11.74605, -2.39936], [11.96866, -2.33559], [12.04895, -2.41704], [12.47925, -2.32626], [12.44656, -1.92025], [12.61312, -1.8129], [12.82172, -1.91091], [13.02759, -2.33098], [13.47977, -2.43224], [13.75884, -2.09293], [13.92073, -2.35581], [13.85846, -2.46935], [14.10442, -2.49268], [14.23829, -2.33715], [14.16202, -2.23916], [14.23518, -2.15671], [14.25932, -1.97624], [14.41838, -1.89412], [14.52569, -0.57818], [14.41887, -0.44799], [14.2165, -0.38261], [14.06862, -0.20826], [13.90632, -0.2287], [13.88648, 0.26652], [14.10909, 0.58563], [14.26066, 0.57255], [14.48179, 0.9152], [14.25186, 1.39842], [13.89582, 1.4261], [13.15519, 1.23368], [13.25447, 1.32339], [13.13461, 1.57238], [13.29457, 2.16106]]]] } },
29074     { type: "Feature", properties: { iso1A2: "GB", iso1A3: "GBR", iso1N3: "826", wikidata: "Q145", ccTLD: ".uk", nameEn: "United Kingdom", aliases: ["UK"] }, geometry: null },
29075     { type: "Feature", properties: { iso1A2: "GD", iso1A3: "GRD", iso1N3: "308", wikidata: "Q769", nameEn: "Grenada", aliases: ["WG"], groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 473"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-62.64026, 12.69984], [-61.77886, 11.36496], [-59.94058, 12.34011], [-62.64026, 12.69984]]]] } },
29076     { type: "Feature", properties: { iso1A2: "GE", iso1A3: "GEO", iso1N3: "268", wikidata: "Q230", nameEn: "Georgia", groups: ["145", "142", "UN"], callingCodes: ["995"] }, geometry: { type: "MultiPolygon", coordinates: [[[[46.42738, 41.91323], [45.61676, 42.20768], [45.78692, 42.48358], [45.36501, 42.55268], [45.15318, 42.70598], [44.88754, 42.74934], [44.80941, 42.61277], [44.70002, 42.74679], [44.54202, 42.75699], [43.95517, 42.55396], [43.73119, 42.62043], [43.81453, 42.74297], [43.0419, 43.02413], [43.03322, 43.08883], [42.75889, 43.19651], [42.66667, 43.13917], [42.40563, 43.23226], [41.64935, 43.22331], [40.65957, 43.56212], [40.10657, 43.57344], [40.04445, 43.47776], [40.03312, 43.44262], [40.01007, 43.42411], [40.01552, 43.42025], [40.00853, 43.40578], [40.0078, 43.38551], [39.81147, 43.06294], [40.89217, 41.72528], [41.54366, 41.52185], [41.7148, 41.4932], [41.7124, 41.47417], [41.81939, 41.43621], [41.95134, 41.52466], [42.26387, 41.49346], [42.51772, 41.43606], [42.59202, 41.58183], [42.72794, 41.59714], [42.84471, 41.58912], [42.78995, 41.50126], [42.84899, 41.47265], [42.8785, 41.50516], [43.02956, 41.37891], [43.21707, 41.30331], [43.13373, 41.25503], [43.1945, 41.25242], [43.23096, 41.17536], [43.36118, 41.2028], [43.44973, 41.17666], [43.4717, 41.12611], [43.67712, 41.13398], [43.74717, 41.1117], [43.84835, 41.16329], [44.16591, 41.19141], [44.18148, 41.24644], [44.32139, 41.2079], [44.34337, 41.20312], [44.34417, 41.2382], [44.46791, 41.18204], [44.59322, 41.1933], [44.61462, 41.24018], [44.72814, 41.20338], [44.82084, 41.21513], [44.87887, 41.20195], [44.89911, 41.21366], [44.84358, 41.23088], [44.81749, 41.23488], [44.80053, 41.25949], [44.81437, 41.30371], [44.93493, 41.25685], [45.0133, 41.29747], [45.09867, 41.34065], [45.1797, 41.42231], [45.26285, 41.46433], [45.31352, 41.47168], [45.4006, 41.42402], [45.45973, 41.45898], [45.68389, 41.3539], [45.71035, 41.36208], [45.75705, 41.35157], [45.69946, 41.29545], [45.80842, 41.2229], [45.95786, 41.17956], [46.13221, 41.19479], [46.27698, 41.19011], [46.37661, 41.10805], [46.456, 41.09984], [46.48558, 41.0576], [46.55096, 41.1104], [46.63969, 41.09515], [46.66148, 41.20533], [46.72375, 41.28609], [46.63658, 41.37727], [46.4669, 41.43331], [46.40307, 41.48464], [46.33925, 41.4963], [46.29794, 41.5724], [46.34126, 41.57454], [46.34039, 41.5947], [46.3253, 41.60912], [46.28182, 41.60089], [46.26531, 41.63339], [46.24429, 41.59883], [46.19759, 41.62327], [46.17891, 41.72094], [46.20538, 41.77205], [46.23962, 41.75811], [46.30863, 41.79133], [46.3984, 41.84399], [46.42738, 41.91323]]]] } },
29077     { type: "Feature", properties: { iso1A2: "GF", iso1A3: "GUF", iso1N3: "254", wikidata: "Q3769", nameEn: "French Guiana", country: "FR", groups: ["Q3320166", "EU", "005", "419", "019", "UN"], callingCodes: ["594"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-51.35485, 4.8383], [-53.7094, 6.2264], [-54.01074, 5.68785], [-54.01877, 5.52789], [-54.26916, 5.26909], [-54.4717, 4.91964], [-54.38444, 4.13222], [-54.19367, 3.84387], [-54.05128, 3.63557], [-53.98914, 3.627], [-53.9849, 3.58697], [-54.28534, 2.67798], [-54.42864, 2.42442], [-54.6084, 2.32856], [-54.16286, 2.10779], [-53.78743, 2.34412], [-52.96539, 2.1881], [-52.6906, 2.37298], [-52.31787, 3.17896], [-51.85573, 3.83427], [-51.82312, 3.85825], [-51.79599, 3.89336], [-51.61983, 4.14596], [-51.63798, 4.51394], [-51.35485, 4.8383]]]] } },
29078     { type: "Feature", properties: { iso1A2: "GG", iso1A3: "GGY", iso1N3: "831", wikidata: "Q25230", nameEn: "Bailiwick of Guernsey", country: "GB" }, geometry: null },
29079     { type: "Feature", properties: { iso1A2: "GH", iso1A3: "GHA", iso1N3: "288", wikidata: "Q117", nameEn: "Ghana", groups: ["011", "202", "002", "UN"], callingCodes: ["233"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-0.13493, 11.14075], [-0.27374, 11.17157], [-0.28566, 11.12713], [-0.35955, 11.07801], [-0.38219, 11.12596], [-0.42391, 11.11661], [-0.44298, 11.04292], [-0.61937, 10.91305], [-0.67143, 10.99811], [-2.83373, 11.0067], [-2.94232, 10.64281], [-2.83108, 10.40252], [-2.74174, 9.83172], [-2.76534, 9.56589], [-2.68802, 9.49343], [-2.69814, 9.22717], [-2.77799, 9.04949], [-2.66357, 9.01771], [-2.58243, 8.7789], [-2.49037, 8.20872], [-2.62901, 8.11495], [-2.61232, 8.02645], [-2.67787, 8.02055], [-2.74819, 7.92613], [-2.78395, 7.94974], [-2.79467, 7.86002], [-2.92339, 7.60847], [-2.97822, 7.27165], [-2.95438, 7.23737], [-3.23327, 6.81744], [-3.21954, 6.74407], [-3.25999, 6.62521], [-3.01896, 5.71697], [-2.95323, 5.71865], [-2.96671, 5.6415], [-2.93132, 5.62137], [-2.85378, 5.65156], [-2.76614, 5.60963], [-2.72737, 5.34789], [-2.77625, 5.34621], [-2.73074, 5.1364], [-2.75502, 5.10657], [-2.95261, 5.12477], [-2.96554, 5.10397], [-3.063, 5.13665], [-3.11073, 5.12675], [-3.10675, 5.08515], [-3.34019, 4.17519], [1.07031, 5.15655], [1.27574, 5.93551], [1.19771, 6.11522], [1.19966, 6.17069], [1.09187, 6.17074], [1.05969, 6.22998], [1.03108, 6.24064], [0.99652, 6.33779], [0.89283, 6.33779], [0.71048, 6.53083], [0.74862, 6.56517], [0.63659, 6.63857], [0.6497, 6.73682], [0.58176, 6.76049], [0.57406, 6.80348], [0.52853, 6.82921], [0.56508, 6.92971], [0.52098, 6.94391], [0.52217, 6.9723], [0.59606, 7.01252], [0.65327, 7.31643], [0.62943, 7.41099], [0.57223, 7.39326], [0.52455, 7.45354], [0.51979, 7.58706], [0.58295, 7.62368], [0.62943, 7.85751], [0.58891, 8.12779], [0.6056, 8.13959], [0.61156, 8.18324], [0.5913, 8.19622], [0.63897, 8.25873], [0.73432, 8.29529], [0.64731, 8.48866], [0.47211, 8.59945], [0.37319, 8.75262], [0.52455, 8.87746], [0.45424, 9.04581], [0.56388, 9.40697], [0.49118, 9.48339], [0.36485, 9.49749], [0.33148, 9.44812], [0.25758, 9.42696], [0.2254, 9.47869], [0.31241, 9.50337], [0.30406, 9.521], [0.2409, 9.52335], [0.23851, 9.57389], [0.38153, 9.58682], [0.36008, 9.6256], [0.29334, 9.59387], [0.26712, 9.66437], [0.28261, 9.69022], [0.32313, 9.6491], [0.34816, 9.66907], [0.34816, 9.71607], [0.32075, 9.72781], [0.36366, 10.03309], [0.41252, 10.02018], [0.41371, 10.06361], [0.35293, 10.09412], [0.39584, 10.31112], [0.33028, 10.30408], [0.29453, 10.41546], [0.18846, 10.4096], [0.12886, 10.53149], [-0.05945, 10.63458], [-0.09141, 10.7147], [-0.07327, 10.71845], [-0.07183, 10.76794], [-0.0228, 10.81916], [-0.02685, 10.8783], [-908e-5, 10.91644], [-63e-4, 10.96417], [0.03355, 10.9807], [0.02395, 11.06229], [342e-5, 11.08317], [-514e-5, 11.10763], [-0.0275, 11.11202], [-0.05733, 11.08628], [-0.14462, 11.10811], [-0.13493, 11.14075]]]] } },
29080     { type: "Feature", properties: { iso1A2: "GI", iso1A3: "GIB", iso1N3: "292", wikidata: "Q1410", nameEn: "Gibraltar", country: "GB", groups: ["Q12837", "BOTS", "039", "150", "UN"], callingCodes: ["350"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-5.34064, 36.03744], [-5.27801, 36.14942], [-5.33822, 36.15272], [-5.34536, 36.15501], [-5.40526, 36.15488], [-5.34064, 36.03744]]]] } },
29081     { type: "Feature", properties: { iso1A2: "GL", iso1A3: "GRL", iso1N3: "304", wikidata: "Q223", nameEn: "Greenland", country: "DK", groups: ["Q1451600", "021", "003", "019", "UN"], callingCodes: ["299"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-49.33696, 84.57952], [-68.21821, 80.48551], [-77.52957, 77.23408], [-46.37635, 57.3249], [-9.68082, 72.73731], [-5.7106, 84.28058], [-49.33696, 84.57952]]]] } },
29082     { type: "Feature", properties: { iso1A2: "GM", iso1A3: "GMB", iso1N3: "270", wikidata: "Q1005", nameEn: "The Gambia", groups: ["011", "202", "002", "UN"], callingCodes: ["220"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-15.14917, 13.57989], [-14.36795, 13.23033], [-13.79409, 13.34472], [-13.8955, 13.59126], [-14.34721, 13.46578], [-14.93719, 13.80173], [-15.36504, 13.79313], [-15.47902, 13.58758], [-17.43598, 13.59273], [-17.43966, 13.04579], [-16.74676, 13.06025], [-16.69343, 13.16791], [-15.80355, 13.16729], [-15.80478, 13.34832], [-15.26908, 13.37768], [-15.14917, 13.57989]]]] } },
29083     { type: "Feature", properties: { iso1A2: "GN", iso1A3: "GIN", iso1N3: "324", wikidata: "Q1006", nameEn: "Guinea", groups: ["011", "202", "002", "UN"], callingCodes: ["224"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-11.37536, 12.40788], [-11.46267, 12.44559], [-11.91331, 12.42008], [-12.35415, 12.32758], [-12.87336, 12.51892], [-13.06603, 12.49342], [-13.05296, 12.64003], [-13.70523, 12.68013], [-13.7039, 12.60313], [-13.65089, 12.49515], [-13.64168, 12.42764], [-13.70851, 12.24978], [-13.92745, 12.24077], [-13.94589, 12.16869], [-13.7039, 12.00869], [-13.7039, 11.70195], [-14.09799, 11.63649], [-14.26623, 11.67486], [-14.31513, 11.60713], [-14.51173, 11.49708], [-14.66677, 11.51188], [-14.77786, 11.36323], [-14.95993, 10.99244], [-15.07174, 10.89557], [-15.96748, 10.162], [-14.36218, 8.64107], [-13.29911, 9.04245], [-13.18586, 9.0925], [-13.08953, 9.0409], [-12.94095, 9.26335], [-12.76788, 9.3133], [-12.47254, 9.86834], [-12.24262, 9.92386], [-12.12634, 9.87203], [-11.91023, 9.93927], [-11.89624, 9.99763], [-11.2118, 10.00098], [-10.6534, 9.29919], [-10.74484, 9.07998], [-10.5783, 9.06386], [-10.56197, 8.81225], [-10.47707, 8.67669], [-10.61422, 8.5314], [-10.70565, 8.29235], [-10.63934, 8.35326], [-10.54891, 8.31174], [-10.37257, 8.48941], [-10.27575, 8.48711], [-10.203, 8.47991], [-10.14579, 8.52665], [-10.05375, 8.50697], [-10.05873, 8.42578], [-9.77763, 8.54633], [-9.47415, 8.35195], [-9.50898, 8.18455], [-9.41445, 8.02448], [-9.44928, 7.9284], [-9.35724, 7.74111], [-9.37465, 7.62032], [-9.48161, 7.37122], [-9.41943, 7.41809], [-9.305, 7.42056], [-9.20798, 7.38109], [-9.18311, 7.30461], [-9.09107, 7.1985], [-8.93435, 7.2824], [-8.85724, 7.26019], [-8.8448, 7.35149], [-8.72789, 7.51429], [-8.67814, 7.69428], [-8.55874, 7.70167], [-8.55874, 7.62525], [-8.47114, 7.55676], [-8.4003, 7.6285], [-8.21374, 7.54466], [-8.09931, 7.78626], [-8.13414, 7.87991], [-8.06449, 8.04989], [-7.94695, 8.00925], [-7.99919, 8.11023], [-7.98675, 8.20134], [-8.062, 8.16071], [-8.2411, 8.24196], [-8.22991, 8.48438], [-7.92518, 8.50652], [-7.65653, 8.36873], [-7.69882, 8.66148], [-7.95503, 8.81146], [-7.92518, 8.99332], [-7.73862, 9.08422], [-7.90777, 9.20456], [-7.85056, 9.41812], [-8.03463, 9.39604], [-8.14657, 9.55062], [-8.09434, 9.86936], [-8.15652, 9.94288], [-8.11921, 10.04577], [-8.01225, 10.1021], [-7.97971, 10.17117], [-7.9578, 10.2703], [-8.10207, 10.44649], [-8.22711, 10.41722], [-8.32614, 10.69273], [-8.2667, 10.91762], [-8.35083, 11.06234], [-8.66923, 10.99397], [-8.40058, 11.37466], [-8.80854, 11.66715], [-8.94784, 12.34842], [-9.13689, 12.50875], [-9.38067, 12.48446], [-9.32097, 12.29009], [-9.63938, 12.18312], [-9.714, 12.0226], [-10.30604, 12.24634], [-10.71897, 11.91552], [-10.80355, 12.1053], [-10.99758, 12.24634], [-11.24136, 12.01286], [-11.50006, 12.17826], [-11.37536, 12.40788]]]] } },
29084     { type: "Feature", properties: { iso1A2: "GP", iso1A3: "GLP", iso1N3: "312", wikidata: "Q17012", nameEn: "Guadeloupe", country: "FR", groups: ["Q3320166", "EU", "029", "003", "419", "019", "UN"], callingCodes: ["590"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-60.03183, 16.1129], [-61.60296, 16.73066], [-63.00549, 15.26166], [-60.03183, 16.1129]]]] } },
29085     { type: "Feature", properties: { iso1A2: "GQ", iso1A3: "GNQ", iso1N3: "226", wikidata: "Q983", nameEn: "Equatorial Guinea", groups: ["017", "202", "002", "UN"], callingCodes: ["240"] }, geometry: { type: "MultiPolygon", coordinates: [[[[9.22018, 3.72052], [8.34397, 4.30689], [7.71762, 0.6674], [3.35016, -3.29031], [9.66433, 1.06723], [9.75065, 1.06753], [9.79648, 1.0019], [11.35307, 1.00251], [11.3561, 2.17217], [9.991, 2.16561], [9.90749, 2.20049], [9.89012, 2.20457], [9.84716, 2.24676], [9.83238, 2.29079], [9.83754, 2.32428], [9.82123, 2.35097], [9.81162, 2.33797], [9.22018, 3.72052]]]] } },
29086     { type: "Feature", properties: { iso1A2: "GR", iso1A3: "GRC", iso1N3: "300", wikidata: "Q41", nameEn: "Greece", aliases: ["EL"], groups: ["EU", "039", "150", "UN"], callingCodes: ["30"] }, geometry: { type: "MultiPolygon", coordinates: [[[[26.03489, 40.73051], [26.0754, 40.72772], [26.08638, 40.73214], [26.12495, 40.74283], [26.12854, 40.77339], [26.15685, 40.80709], [26.21351, 40.83298], [26.20856, 40.86048], [26.26169, 40.9168], [26.29441, 40.89119], [26.28623, 40.93005], [26.32259, 40.94042], [26.35894, 40.94292], [26.33297, 40.98388], [26.3606, 41.02027], [26.31928, 41.07386], [26.32259, 41.24929], [26.39861, 41.25053], [26.5209, 41.33993], [26.5837, 41.32131], [26.62997, 41.34613], [26.61767, 41.42281], [26.59742, 41.48058], [26.59196, 41.60491], [26.5209, 41.62592], [26.47958, 41.67037], [26.35957, 41.71149], [26.30255, 41.70925], [26.2654, 41.71544], [26.22888, 41.74139], [26.21325, 41.73223], [26.16841, 41.74858], [26.06148, 41.70345], [26.07083, 41.64584], [26.15146, 41.60828], [26.14328, 41.55496], [26.17951, 41.55409], [26.176, 41.50072], [26.14796, 41.47533], [26.20288, 41.43943], [26.16548, 41.42278], [26.12926, 41.35878], [25.87919, 41.30526], [25.8266, 41.34563], [25.70507, 41.29209], [25.66183, 41.31316], [25.61042, 41.30614], [25.55082, 41.31667], [25.52394, 41.2798], [25.48187, 41.28506], [25.28322, 41.23411], [25.11611, 41.34212], [24.942, 41.38685], [24.90928, 41.40876], [24.86136, 41.39298], [24.82514, 41.4035], [24.8041, 41.34913], [24.71529, 41.41928], [24.61129, 41.42278], [24.52599, 41.56808], [24.30513, 41.51297], [24.27124, 41.57682], [24.18126, 41.51735], [24.10063, 41.54796], [24.06323, 41.53222], [24.06908, 41.46132], [23.96975, 41.44118], [23.91483, 41.47971], [23.89613, 41.45257], [23.80148, 41.43943], [23.76525, 41.40175], [23.67644, 41.41139], [23.63203, 41.37632], [23.52453, 41.40262], [23.40416, 41.39999], [23.33639, 41.36317], [23.31301, 41.40525], [23.22771, 41.37106], [23.21953, 41.33773], [23.1833, 41.31755], [22.93334, 41.34104], [22.81199, 41.3398], [22.76408, 41.32225], [22.74538, 41.16321], [22.71266, 41.13945], [22.65306, 41.18168], [22.62852, 41.14385], [22.58295, 41.11568], [22.5549, 41.13065], [22.42285, 41.11921], [22.26744, 41.16409], [22.17629, 41.15969], [22.1424, 41.12449], [22.06527, 41.15617], [21.90869, 41.09191], [21.91102, 41.04786], [21.7556, 40.92525], [21.69601, 40.9429], [21.57448, 40.86076], [21.53007, 40.90759], [21.41555, 40.9173], [21.35595, 40.87578], [21.25779, 40.86165], [21.21105, 40.8855], [21.15262, 40.85546], [20.97887, 40.85475], [20.98396, 40.79109], [20.95752, 40.76982], [20.98134, 40.76046], [21.05833, 40.66586], [21.03932, 40.56299], [20.96908, 40.51526], [20.94925, 40.46625], [20.83688, 40.47882], [20.7906, 40.42726], [20.78234, 40.35803], [20.71789, 40.27739], [20.67162, 40.09433], [20.62566, 40.0897], [20.61081, 40.07866], [20.55593, 40.06524], [20.51297, 40.08168], [20.48487, 40.06271], [20.42373, 40.06777], [20.37911, 39.99058], [20.31135, 39.99438], [20.41546, 39.82832], [20.41475, 39.81437], [20.38572, 39.78516], [20.30804, 39.81563], [20.29152, 39.80421], [20.31961, 39.72799], [20.27412, 39.69884], [20.22707, 39.67459], [20.22376, 39.64532], [20.15988, 39.652], [20.12956, 39.65805], [20.05189, 39.69112], [20.00957, 39.69227], [19.98042, 39.6504], [19.92466, 39.69533], [19.97622, 39.78684], [19.95905, 39.82857], [19.0384, 40.35325], [19.20409, 39.7532], [22.5213, 33.45682], [29.73302, 35.92555], [29.69611, 36.10365], [29.61805, 36.14179], [29.61002, 36.1731], [29.48192, 36.18377], [29.30783, 36.01033], [28.23708, 36.56812], [27.95037, 36.46155], [27.89482, 36.69898], [27.46117, 36.53789], [27.24613, 36.71622], [27.45627, 36.9008], [27.20312, 36.94571], [27.14757, 37.32], [26.95583, 37.64989], [26.99377, 37.69034], [27.16428, 37.72343], [27.05537, 37.9131], [26.21136, 38.17558], [26.24183, 38.44695], [26.32173, 38.48731], [26.21136, 38.65436], [26.61814, 38.81372], [26.70773, 39.0312], [26.43357, 39.43096], [25.94257, 39.39358], [25.61285, 40.17161], [26.04292, 40.3958], [25.94795, 40.72797], [26.03489, 40.73051]]]] } },
29087     { type: "Feature", properties: { iso1A2: "GS", iso1A3: "SGS", iso1N3: "239", wikidata: "Q35086", nameEn: "South Georgia and South Sandwich Islands", country: "GB", groups: ["BOTS", "005", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["500"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-35.26394, -43.68272], [-53.39656, -59.87088], [-22.31757, -59.85974], [-35.26394, -43.68272]]]] } },
29088     { type: "Feature", properties: { iso1A2: "GT", iso1A3: "GTM", iso1N3: "320", wikidata: "Q774", nameEn: "Guatemala", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["502"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-89.14985, 17.81563], [-90.98678, 17.81655], [-90.99199, 17.25192], [-91.43809, 17.25373], [-91.04436, 16.92175], [-90.69064, 16.70697], [-90.61212, 16.49832], [-90.40499, 16.40524], [-90.44567, 16.07573], [-91.73182, 16.07371], [-92.20983, 15.26077], [-92.0621, 15.07406], [-92.1454, 14.98143], [-92.1423, 14.88647], [-92.18161, 14.84147], [-92.1454, 14.6804], [-92.2261, 14.53423], [-92.37213, 14.39277], [-90.55276, 12.8866], [-90.11344, 13.73679], [-90.10505, 13.85104], [-89.88937, 14.0396], [-89.81807, 14.07073], [-89.76103, 14.02923], [-89.73251, 14.04133], [-89.75569, 14.07073], [-89.70756, 14.1537], [-89.61844, 14.21937], [-89.52397, 14.22628], [-89.50614, 14.26084], [-89.58814, 14.33165], [-89.57441, 14.41637], [-89.39028, 14.44561], [-89.34776, 14.43013], [-89.35189, 14.47553], [-89.23719, 14.58046], [-89.15653, 14.57802], [-89.13132, 14.71582], [-89.23467, 14.85596], [-89.15149, 14.97775], [-89.18048, 14.99967], [-89.15149, 15.07392], [-88.97343, 15.14039], [-88.32467, 15.63665], [-88.31459, 15.66942], [-88.24022, 15.69247], [-88.22552, 15.72294], [-88.20359, 16.03858], [-88.40779, 16.09624], [-88.95358, 15.88698], [-89.02415, 15.9063], [-89.17418, 15.90898], [-89.22683, 15.88619], [-89.15025, 17.04813], [-89.14985, 17.81563]]]] } },
29089     { type: "Feature", properties: { iso1A2: "GU", iso1A3: "GUM", iso1N3: "316", wikidata: "Q16635", nameEn: "Guam", aliases: ["US-GU"], country: "US", groups: ["Q1352230", "Q153732", "057", "009", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 671"] }, geometry: { type: "MultiPolygon", coordinates: [[[[146.25931, 13.85876], [143.82485, 13.92273], [144.61642, 12.82462], [146.25931, 13.85876]]]] } },
29090     { type: "Feature", properties: { iso1A2: "GW", iso1A3: "GNB", iso1N3: "624", wikidata: "Q1007", nameEn: "Guinea-Bissau", groups: ["011", "202", "002", "UN"], callingCodes: ["245"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-14.31513, 11.60713], [-14.26623, 11.67486], [-14.09799, 11.63649], [-13.7039, 11.70195], [-13.7039, 12.00869], [-13.94589, 12.16869], [-13.92745, 12.24077], [-13.70851, 12.24978], [-13.64168, 12.42764], [-13.65089, 12.49515], [-13.7039, 12.60313], [-13.70523, 12.68013], [-15.17582, 12.6847], [-15.67302, 12.42974], [-16.20591, 12.46157], [-16.38191, 12.36449], [-16.70562, 12.34803], [-17.4623, 11.92379], [-15.96748, 10.162], [-15.07174, 10.89557], [-14.95993, 10.99244], [-14.77786, 11.36323], [-14.66677, 11.51188], [-14.51173, 11.49708], [-14.31513, 11.60713]]]] } },
29091     { type: "Feature", properties: { iso1A2: "GY", iso1A3: "GUY", iso1N3: "328", wikidata: "Q734", nameEn: "Guyana", groups: ["005", "419", "019", "UN"], driveSide: "left", callingCodes: ["592"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-56.84822, 6.73257], [-59.54058, 8.6862], [-59.98508, 8.53046], [-59.85562, 8.35213], [-59.80661, 8.28906], [-59.83156, 8.23261], [-59.97059, 8.20791], [-60.02407, 8.04557], [-60.38056, 7.8302], [-60.51959, 7.83373], [-60.64793, 7.56877], [-60.71923, 7.55817], [-60.59802, 7.33194], [-60.63367, 7.25061], [-60.54098, 7.14804], [-60.44116, 7.20817], [-60.28074, 7.1162], [-60.39419, 6.94847], [-60.54873, 6.8631], [-61.13632, 6.70922], [-61.20762, 6.58174], [-61.15058, 6.19558], [-61.4041, 5.95304], [-60.73204, 5.20931], [-60.32352, 5.21299], [-60.20944, 5.28754], [-59.98129, 5.07097], [-60.04189, 4.69801], [-60.15953, 4.53456], [-59.78878, 4.45637], [-59.69361, 4.34069], [-59.73353, 4.20399], [-59.51963, 3.91951], [-59.86899, 3.57089], [-59.79769, 3.37162], [-59.99733, 2.92312], [-59.91177, 2.36759], [-59.7264, 2.27497], [-59.74066, 1.87596], [-59.25583, 1.40559], [-58.92072, 1.31293], [-58.84229, 1.17749], [-58.53571, 1.29154], [-58.4858, 1.48399], [-58.33887, 1.58014], [-58.01873, 1.51966], [-57.97336, 1.64566], [-57.77281, 1.73344], [-57.55743, 1.69605], [-57.35073, 1.98327], [-57.23981, 1.95808], [-57.09109, 2.01854], [-57.07092, 1.95304], [-56.7659, 1.89509], [-56.47045, 1.95135], [-56.55439, 2.02003], [-56.70519, 2.02964], [-57.35891, 3.32121], [-58.0307, 3.95513], [-57.8699, 4.89394], [-57.37442, 5.0208], [-57.22536, 5.15605], [-57.31629, 5.33714], [-56.84822, 6.73257]]]] } },
29092     { type: "Feature", properties: { iso1A2: "HK", iso1A3: "HKG", iso1N3: "344", wikidata: "Q8646", nameEn: "Hong Kong", country: "CN", groups: ["030", "142", "UN"], driveSide: "left", callingCodes: ["852"] }, geometry: { type: "MultiPolygon", coordinates: [[[[113.92195, 22.13873], [114.50148, 22.15017], [114.44998, 22.55977], [114.25154, 22.55977], [114.22888, 22.5436], [114.22185, 22.55343], [114.20655, 22.55706], [114.18338, 22.55444], [114.17247, 22.55944], [114.1597, 22.56041], [114.15123, 22.55163], [114.1482, 22.54091], [114.13823, 22.54319], [114.12665, 22.54003], [114.11656, 22.53415], [114.11181, 22.52878], [114.1034, 22.5352], [114.09692, 22.53435], [114.09048, 22.53716], [114.08606, 22.53276], [114.07817, 22.52997], [114.07267, 22.51855], [114.06272, 22.51617], [114.05729, 22.51104], [114.05438, 22.5026], [114.03113, 22.5065], [113.86771, 22.42972], [113.81621, 22.2163], [113.83338, 22.1826], [113.92195, 22.13873]]]] } },
29093     { type: "Feature", properties: { iso1A2: "HM", iso1A3: "HMD", iso1N3: "334", wikidata: "Q131198", nameEn: "Heard Island and McDonald Islands", country: "AU", groups: ["053", "009", "UN"], driveSide: "left" }, geometry: { type: "MultiPolygon", coordinates: [[[[71.08716, -53.87687], [75.44182, -53.99822], [72.87012, -51.48322], [71.08716, -53.87687]]]] } },
29094     { type: "Feature", properties: { iso1A2: "HN", iso1A3: "HND", iso1N3: "340", wikidata: "Q783", nameEn: "Honduras", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["504"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-83.86109, 17.73736], [-88.20359, 16.03858], [-88.22552, 15.72294], [-88.24022, 15.69247], [-88.31459, 15.66942], [-88.32467, 15.63665], [-88.97343, 15.14039], [-89.15149, 15.07392], [-89.18048, 14.99967], [-89.15149, 14.97775], [-89.23467, 14.85596], [-89.13132, 14.71582], [-89.15653, 14.57802], [-89.23719, 14.58046], [-89.35189, 14.47553], [-89.34776, 14.43013], [-89.04187, 14.33644], [-88.94608, 14.20207], [-88.85785, 14.17763], [-88.815, 14.11652], [-88.73182, 14.10919], [-88.70661, 14.04317], [-88.49738, 13.97224], [-88.48982, 13.86458], [-88.25791, 13.91108], [-88.23018, 13.99915], [-88.07641, 13.98447], [-88.00331, 13.86948], [-87.7966, 13.91353], [-87.68821, 13.80829], [-87.73106, 13.75443], [-87.78148, 13.52906], [-87.71657, 13.50577], [-87.72115, 13.46083], [-87.73841, 13.44169], [-87.77354, 13.45767], [-87.83467, 13.44655], [-87.84675, 13.41078], [-87.80177, 13.35689], [-87.73714, 13.32715], [-87.69751, 13.25228], [-87.55124, 13.12523], [-87.37107, 12.98646], [-87.06306, 13.00892], [-87.03785, 12.98682], [-86.93197, 13.05313], [-86.93383, 13.18677], [-86.87066, 13.30641], [-86.71267, 13.30348], [-86.76812, 13.79605], [-86.35219, 13.77157], [-86.14801, 14.04317], [-86.00685, 14.08474], [-86.03458, 13.99181], [-85.75477, 13.8499], [-85.73964, 13.9698], [-85.45762, 14.11304], [-85.32149, 14.2562], [-85.18602, 14.24929], [-85.1575, 14.53934], [-84.90082, 14.80489], [-84.82596, 14.82212], [-84.70119, 14.68078], [-84.48373, 14.63249], [-84.10584, 14.76353], [-83.89551, 14.76697], [-83.62101, 14.89448], [-83.49268, 15.01158], [-83.13724, 15.00002], [-83.04763, 15.03256], [-82.06974, 14.49418], [-81.58685, 18.0025], [-83.86109, 17.73736]]]] } },
29095     { type: "Feature", properties: { iso1A2: "HR", iso1A3: "HRV", iso1N3: "191", wikidata: "Q224", nameEn: "Croatia", groups: ["EU", "039", "150", "UN"], callingCodes: ["385"] }, geometry: { type: "MultiPolygon", coordinates: [[[[17.6444, 42.88641], [17.5392, 42.92787], [17.70879, 42.97223], [17.64268, 43.08595], [17.46986, 43.16559], [17.286, 43.33065], [17.25579, 43.40353], [17.29699, 43.44542], [17.24411, 43.49376], [17.15828, 43.49376], [17.00585, 43.58037], [16.80736, 43.76011], [16.75316, 43.77157], [16.70922, 43.84887], [16.55472, 43.95326], [16.50528, 44.0244], [16.43629, 44.02826], [16.43662, 44.07523], [16.36864, 44.08263], [16.18688, 44.27012], [16.21346, 44.35231], [16.12969, 44.38275], [16.16814, 44.40679], [16.10566, 44.52586], [16.03012, 44.55572], [16.00884, 44.58605], [16.05828, 44.61538], [15.89348, 44.74964], [15.8255, 44.71501], [15.72584, 44.82334], [15.79472, 44.8455], [15.76096, 44.87045], [15.74723, 44.96818], [15.78568, 44.97401], [15.74585, 45.0638], [15.78842, 45.11519], [15.76371, 45.16508], [15.83512, 45.22459], [15.98412, 45.23088], [16.12153, 45.09616], [16.29036, 44.99732], [16.35404, 45.00241], [16.35863, 45.03529], [16.3749, 45.05206], [16.38219, 45.05139], [16.38309, 45.05955], [16.40023, 45.1147], [16.4634, 45.14522], [16.49155, 45.21153], [16.52982, 45.22713], [16.5501, 45.2212], [16.56559, 45.22307], [16.60194, 45.23042], [16.64962, 45.20714], [16.74845, 45.20393], [16.78219, 45.19002], [16.81137, 45.18434], [16.83804, 45.18951], [16.92405, 45.27607], [16.9385, 45.22742], [17.0415, 45.20759], [17.18438, 45.14764], [17.24325, 45.146], [17.25131, 45.14957], [17.26815, 45.18444], [17.32092, 45.16246], [17.33573, 45.14521], [17.41229, 45.13335], [17.4498, 45.16119], [17.45615, 45.12523], [17.47589, 45.12656], [17.51469, 45.10791], [17.59104, 45.10816], [17.66571, 45.13408], [17.84826, 45.04489], [17.87148, 45.04645], [17.93706, 45.08016], [17.97336, 45.12245], [17.97834, 45.13831], [17.99479, 45.14958], [18.01594, 45.15163], [18.03121, 45.12632], [18.1624, 45.07654], [18.24387, 45.13699], [18.32077, 45.1021], [18.41896, 45.11083], [18.47939, 45.05871], [18.65723, 45.07544], [18.78357, 44.97741], [18.80661, 44.93561], [18.76369, 44.93707], [18.76347, 44.90669], [18.8704, 44.85097], [19.01994, 44.85493], [18.98957, 44.90645], [19.02871, 44.92541], [19.06853, 44.89915], [19.15573, 44.95409], [19.05205, 44.97692], [19.1011, 45.01191], [19.07952, 45.14668], [19.14063, 45.12972], [19.19144, 45.17863], [19.43589, 45.17137], [19.41941, 45.23475], [19.28208, 45.23813], [19.10774, 45.29547], [18.97446, 45.37528], [18.99918, 45.49333], [19.08364, 45.48804], [19.07471, 45.53086], [18.94562, 45.53712], [18.88776, 45.57253], [18.96691, 45.66731], [18.90305, 45.71863], [18.85783, 45.85493], [18.81394, 45.91329], [18.80211, 45.87995], [18.6792, 45.92057], [18.57483, 45.80772], [18.44368, 45.73972], [18.12439, 45.78905], [18.08869, 45.76511], [17.99805, 45.79671], [17.87377, 45.78522], [17.66545, 45.84207], [17.56821, 45.93728], [17.35672, 45.95209], [17.14592, 46.16697], [16.8903, 46.28122], [16.8541, 46.36255], [16.7154, 46.39523], [16.6639, 46.45203], [16.59527, 46.47524], [16.52604, 46.47831], [16.5007, 46.49644], [16.44036, 46.5171], [16.38771, 46.53608], [16.37193, 46.55008], [16.29793, 46.5121], [16.26733, 46.51505], [16.26759, 46.50566], [16.23961, 46.49653], [16.25124, 46.48067], [16.27398, 46.42875], [16.27329, 46.41467], [16.30162, 46.40437], [16.30233, 46.37837], [16.18824, 46.38282], [16.14859, 46.40547], [16.05281, 46.39141], [16.05065, 46.3833], [16.07314, 46.36458], [16.07616, 46.3463], [15.97965, 46.30652], [15.79284, 46.25811], [15.78817, 46.21719], [15.75479, 46.20336], [15.75436, 46.21969], [15.67395, 46.22478], [15.6434, 46.21396], [15.64904, 46.19229], [15.59909, 46.14761], [15.6083, 46.11992], [15.62317, 46.09103], [15.72977, 46.04682], [15.71246, 46.01196], [15.70327, 46.00015], [15.70636, 45.92116], [15.67967, 45.90455], [15.68383, 45.88867], [15.68232, 45.86819], [15.70411, 45.8465], [15.66662, 45.84085], [15.64185, 45.82915], [15.57952, 45.84953], [15.52234, 45.82195], [15.47325, 45.8253], [15.47531, 45.79802], [15.40836, 45.79491], [15.25423, 45.72275], [15.30872, 45.69014], [15.34919, 45.71623], [15.4057, 45.64727], [15.38952, 45.63682], [15.34214, 45.64702], [15.34695, 45.63382], [15.31027, 45.6303], [15.27747, 45.60504], [15.29837, 45.5841], [15.30249, 45.53224], [15.38188, 45.48752], [15.33051, 45.45258], [15.27758, 45.46678], [15.16862, 45.42309], [15.05187, 45.49079], [15.02385, 45.48533], [14.92266, 45.52788], [14.90554, 45.47769], [14.81992, 45.45913], [14.80124, 45.49515], [14.71718, 45.53442], [14.68605, 45.53006], [14.69694, 45.57366], [14.59576, 45.62812], [14.60977, 45.66403], [14.57397, 45.67165], [14.53816, 45.6205], [14.5008, 45.60852], [14.49769, 45.54424], [14.36693, 45.48642], [14.32487, 45.47142], [14.27681, 45.4902], [14.26611, 45.48239], [14.24239, 45.50607], [14.22371, 45.50388], [14.20348, 45.46896], [14.07116, 45.48752], [14.00578, 45.52352], [13.96063, 45.50825], [13.99488, 45.47551], [13.97309, 45.45258], [13.90771, 45.45149], [13.88124, 45.42637], [13.81742, 45.43729], [13.7785, 45.46787], [13.67398, 45.4436], [13.62902, 45.45898], [13.56979, 45.4895], [13.45644, 45.59464], [13.05142, 45.33128], [13.12821, 44.48877], [16.15283, 42.18525], [18.45131, 42.21682], [18.54128, 42.39171], [18.52152, 42.42302], [18.43588, 42.48556], [18.44307, 42.51077], [18.43735, 42.55921], [18.36197, 42.61423], [18.24318, 42.6112], [17.88201, 42.83668], [17.80854, 42.9182], [17.7948, 42.89556], [17.68151, 42.92725], [17.6444, 42.88641]]]] } },
29096     { type: "Feature", properties: { iso1A2: "HT", iso1A3: "HTI", iso1N3: "332", wikidata: "Q790", nameEn: "Haiti", aliases: ["RH"], groups: ["029", "003", "419", "019", "UN"], callingCodes: ["509"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-71.71885, 18.78423], [-71.72624, 18.87802], [-71.77766, 18.95007], [-71.88102, 18.95007], [-71.74088, 19.0437], [-71.71088, 19.08353], [-71.69938, 19.10916], [-71.65337, 19.11759], [-71.62642, 19.21212], [-71.73229, 19.26686], [-71.77766, 19.33823], [-71.69448, 19.37866], [-71.6802, 19.45008], [-71.71268, 19.53374], [-71.71449, 19.55364], [-71.7429, 19.58445], [-71.75865, 19.70231], [-71.77419, 19.73128], [-72.38946, 20.27111], [-73.37289, 20.43199], [-74.7289, 18.71009], [-74.76465, 18.06252], [-72.29523, 17.48026], [-71.75671, 18.03456], [-71.73783, 18.07177], [-71.74994, 18.11115], [-71.75465, 18.14405], [-71.78271, 18.18302], [-71.69952, 18.34101], [-71.90875, 18.45821], [-71.88102, 18.50125], [-72.00201, 18.62312], [-71.95412, 18.64939], [-71.82556, 18.62551], [-71.71885, 18.78423]]]] } },
29097     { type: "Feature", properties: { iso1A2: "HU", iso1A3: "HUN", iso1N3: "348", wikidata: "Q28", nameEn: "Hungary", groups: ["EU", "151", "150", "UN"], callingCodes: ["36"] }, geometry: { type: "MultiPolygon", coordinates: [[[[21.72525, 48.34628], [21.67134, 48.3989], [21.6068, 48.50365], [21.44063, 48.58456], [21.11516, 48.49546], [20.83248, 48.5824], [20.5215, 48.53336], [20.29943, 48.26104], [20.24312, 48.2784], [19.92452, 48.1283], [19.63338, 48.25006], [19.52489, 48.19791], [19.47957, 48.09437], [19.28182, 48.08336], [19.23924, 48.0595], [19.01952, 48.07052], [18.82176, 48.04206], [18.76134, 47.97499], [18.76821, 47.87469], [18.8506, 47.82308], [18.74074, 47.8157], [18.66521, 47.76772], [18.56496, 47.76588], [18.29305, 47.73541], [18.02938, 47.75665], [17.71215, 47.7548], [17.23699, 48.02094], [17.16001, 48.00636], [17.09786, 47.97336], [17.11022, 47.92461], [17.08275, 47.87719], [17.00997, 47.86245], [17.07039, 47.81129], [17.05048, 47.79377], [17.08893, 47.70928], [16.87538, 47.68895], [16.86509, 47.72268], [16.82938, 47.68432], [16.7511, 47.67878], [16.72089, 47.73469], [16.65679, 47.74197], [16.61183, 47.76171], [16.54779, 47.75074], [16.53514, 47.73837], [16.55129, 47.72268], [16.4222, 47.66537], [16.58699, 47.61772], [16.64193, 47.63114], [16.71059, 47.52692], [16.64821, 47.50155], [16.6718, 47.46139], [16.57152, 47.40868], [16.52414, 47.41007], [16.49908, 47.39416], [16.45104, 47.41181], [16.47782, 47.25918], [16.44142, 47.25079], [16.43663, 47.21127], [16.41739, 47.20649], [16.42801, 47.18422], [16.4523, 47.18812], [16.46442, 47.16845], [16.44932, 47.14418], [16.52863, 47.13974], [16.46134, 47.09395], [16.52176, 47.05747], [16.43936, 47.03548], [16.51369, 47.00084], [16.28202, 47.00159], [16.27594, 46.9643], [16.22403, 46.939], [16.19904, 46.94134], [16.10983, 46.867], [16.14365, 46.8547], [16.15711, 46.85434], [16.21892, 46.86961], [16.2365, 46.87775], [16.2941, 46.87137], [16.34547, 46.83836], [16.3408, 46.80641], [16.31303, 46.79838], [16.30966, 46.7787], [16.37816, 46.69975], [16.42641, 46.69228], [16.41863, 46.66238], [16.38594, 46.6549], [16.39217, 46.63673], [16.50139, 46.56684], [16.52885, 46.53303], [16.52604, 46.5051], [16.59527, 46.47524], [16.6639, 46.45203], [16.7154, 46.39523], [16.8541, 46.36255], [16.8903, 46.28122], [17.14592, 46.16697], [17.35672, 45.95209], [17.56821, 45.93728], [17.66545, 45.84207], [17.87377, 45.78522], [17.99805, 45.79671], [18.08869, 45.76511], [18.12439, 45.78905], [18.44368, 45.73972], [18.57483, 45.80772], [18.6792, 45.92057], [18.80211, 45.87995], [18.81394, 45.91329], [18.99712, 45.93537], [19.01284, 45.96529], [19.0791, 45.96458], [19.10388, 46.04015], [19.14543, 45.9998], [19.28826, 45.99694], [19.52473, 46.1171], [19.56113, 46.16824], [19.66007, 46.19005], [19.81491, 46.1313], [19.93508, 46.17553], [20.01816, 46.17696], [20.03533, 46.14509], [20.09713, 46.17315], [20.26068, 46.12332], [20.28324, 46.1438], [20.35573, 46.16629], [20.45377, 46.14405], [20.49718, 46.18721], [20.63863, 46.12728], [20.76085, 46.21002], [20.74574, 46.25467], [20.86797, 46.28884], [21.06572, 46.24897], [21.16872, 46.30118], [21.28061, 46.44941], [21.26929, 46.4993], [21.33214, 46.63035], [21.43926, 46.65109], [21.5151, 46.72147], [21.48935, 46.7577], [21.52028, 46.84118], [21.59307, 46.86935], [21.59581, 46.91628], [21.68645, 46.99595], [21.648, 47.03902], [21.78395, 47.11104], [21.94463, 47.38046], [22.01055, 47.37767], [22.03389, 47.42508], [22.00917, 47.50492], [22.31816, 47.76126], [22.41979, 47.7391], [22.46559, 47.76583], [22.67247, 47.7871], [22.76617, 47.8417], [22.77991, 47.87211], [22.89849, 47.95851], [22.84276, 47.98602], [22.87847, 48.04665], [22.81804, 48.11363], [22.73427, 48.12005], [22.66835, 48.09162], [22.58733, 48.10813], [22.59007, 48.15121], [22.49806, 48.25189], [22.38133, 48.23726], [22.2083, 48.42534], [22.14689, 48.4005], [21.83339, 48.36242], [21.8279, 48.33321], [21.72525, 48.34628]]]] } },
29098     { type: "Feature", properties: { iso1A2: "IC", wikidata: "Q5813", nameEn: "Canary Islands", country: "ES", groups: ["Q3320166", "Q105472", "EU", "039", "150", "UN"], isoStatus: "excRes", callingCodes: ["34"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-12.00985, 30.24121], [-25.3475, 27.87574], [-14.43883, 27.02969], [-12.00985, 30.24121]]]] } },
29099     { type: "Feature", properties: { iso1A2: "ID", iso1A3: "IDN", iso1N3: "360", wikidata: "Q252", nameEn: "Indonesia", aliases: ["RI"] }, geometry: null },
29100     { type: "Feature", properties: { iso1A2: "IE", iso1A3: "IRL", iso1N3: "372", wikidata: "Q27", nameEn: "Republic of Ireland", groups: ["EU", "Q22890", "154", "150", "UN"], driveSide: "left", callingCodes: ["353"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-6.26218, 54.09785], [-6.29003, 54.11278], [-6.32694, 54.09337], [-6.36279, 54.11248], [-6.36605, 54.07234], [-6.47849, 54.06947], [-6.62842, 54.03503], [-6.66264, 54.0666], [-6.6382, 54.17071], [-6.70175, 54.20218], [-6.74575, 54.18788], [-6.81583, 54.22791], [-6.85179, 54.29176], [-6.87775, 54.34682], [-7.02034, 54.4212], [-7.19145, 54.31296], [-7.14908, 54.22732], [-7.25012, 54.20063], [-7.26316, 54.13863], [-7.29493, 54.12013], [-7.29687, 54.1354], [-7.28017, 54.16714], [-7.29157, 54.17191], [-7.34005, 54.14698], [-7.30553, 54.11869], [-7.32834, 54.11475], [-7.44567, 54.1539], [-7.4799, 54.12239], [-7.55812, 54.12239], [-7.69501, 54.20731], [-7.81397, 54.20159], [-7.8596, 54.21779], [-7.87101, 54.29299], [-8.04555, 54.36292], [-8.179, 54.46763], [-8.04538, 54.48941], [-7.99812, 54.54427], [-7.8596, 54.53671], [-7.70315, 54.62077], [-7.93293, 54.66603], [-7.83352, 54.73854], [-7.75041, 54.7103], [-7.64449, 54.75265], [-7.54671, 54.74606], [-7.54508, 54.79401], [-7.47626, 54.83084], [-7.4473, 54.87003], [-7.44404, 54.9403], [-7.40004, 54.94498], [-7.4033, 55.00391], [-7.34464, 55.04688], [-7.2471, 55.06933], [-6.34755, 55.49206], [-7.75229, 55.93854], [-11.75, 54], [-11, 51], [-6.03913, 51.13217], [-5.37267, 53.63269], [-6.26218, 54.09785]]]] } },
29101     { type: "Feature", properties: { iso1A2: "IL", iso1A3: "ISR", iso1N3: "376", wikidata: "Q801", nameEn: "Israel", groups: ["145", "142", "UN"], callingCodes: ["972"] }, geometry: { type: "MultiPolygon", coordinates: [[[[34.052, 31.46619], [34.29262, 31.70393], [34.48681, 31.59711], [34.56797, 31.54197], [34.48892, 31.48365], [34.40077, 31.40926], [34.36505, 31.36404], [34.37381, 31.30598], [34.36523, 31.28963], [34.29417, 31.24194], [34.26742, 31.21998], [34.92298, 29.45305], [34.97718, 29.54294], [34.98207, 29.58147], [35.02147, 29.66343], [35.14108, 30.07374], [35.19183, 30.34636], [35.16218, 30.43535], [35.19595, 30.50297], [35.21379, 30.60401], [35.29311, 30.71365], [35.33456, 30.81224], [35.33984, 30.8802], [35.41371, 30.95565], [35.43658, 31.12444], [35.40316, 31.25535], [35.47672, 31.49578], [35.39675, 31.49572], [35.22921, 31.37445], [35.13033, 31.3551], [35.02459, 31.35979], [34.92571, 31.34337], [34.88932, 31.37093], [34.87833, 31.39321], [34.89756, 31.43891], [34.93258, 31.47816], [34.94356, 31.50743], [34.9415, 31.55601], [34.95249, 31.59813], [35.00879, 31.65426], [35.08226, 31.69107], [35.10782, 31.71594], [35.11895, 31.71454], [35.12933, 31.7325], [35.13931, 31.73012], [35.15119, 31.73634], [35.15474, 31.73352], [35.16478, 31.73242], [35.18023, 31.72067], [35.20538, 31.72388], [35.21937, 31.71578], [35.22392, 31.71899], [35.23972, 31.70896], [35.24315, 31.71244], [35.2438, 31.7201], [35.24981, 31.72543], [35.25182, 31.73945], [35.26319, 31.74846], [35.25225, 31.7678], [35.26058, 31.79064], [35.25573, 31.81362], [35.26404, 31.82567], [35.251, 31.83085], [35.25753, 31.8387], [35.24816, 31.8458], [35.2304, 31.84222], [35.2249, 31.85433], [35.22817, 31.8638], [35.22567, 31.86745], [35.22294, 31.87889], [35.22014, 31.88264], [35.2136, 31.88241], [35.21276, 31.88153], [35.21016, 31.88237], [35.20945, 31.8815], [35.20791, 31.8821], [35.20673, 31.88151], [35.20381, 31.86716], [35.21128, 31.863], [35.216, 31.83894], [35.21469, 31.81835], [35.19461, 31.82687], [35.18169, 31.82542], [35.18603, 31.80901], [35.14174, 31.81325], [35.07677, 31.85627], [35.05617, 31.85685], [35.01978, 31.82944], [34.9724, 31.83352], [34.99712, 31.85569], [35.03489, 31.85919], [35.03978, 31.89276], [35.03489, 31.92448], [35.00124, 31.93264], [34.98682, 31.96935], [35.00261, 32.027], [34.9863, 32.09551], [34.99437, 32.10962], [34.98507, 32.12606], [34.99039, 32.14626], [34.96009, 32.17503], [34.95703, 32.19522], [34.98885, 32.20758], [35.01841, 32.23981], [35.02939, 32.2671], [35.01119, 32.28684], [35.01772, 32.33863], [35.04243, 32.35008], [35.05142, 32.3667], [35.0421, 32.38242], [35.05311, 32.4024], [35.05423, 32.41754], [35.07059, 32.4585], [35.08564, 32.46948], [35.09236, 32.47614], [35.10024, 32.47856], [35.10882, 32.4757], [35.15937, 32.50466], [35.2244, 32.55289], [35.25049, 32.52453], [35.29306, 32.50947], [35.30685, 32.51024], [35.35212, 32.52047], [35.40224, 32.50136], [35.42034, 32.46009], [35.41598, 32.45593], [35.41048, 32.43706], [35.42078, 32.41562], [35.55807, 32.38674], [35.55494, 32.42687], [35.57485, 32.48669], [35.56614, 32.64393], [35.59813, 32.65159], [35.61669, 32.67999], [35.66527, 32.681], [35.68467, 32.70715], [35.75983, 32.74803], [35.78745, 32.77938], [35.83758, 32.82817], [35.84021, 32.8725], [35.87012, 32.91976], [35.89298, 32.9456], [35.87188, 32.98028], [35.84802, 33.1031], [35.81911, 33.11077], [35.81911, 33.1336], [35.84285, 33.16673], [35.83846, 33.19397], [35.81647, 33.2028], [35.81295, 33.24841], [35.77513, 33.27342], [35.813, 33.3172], [35.77477, 33.33609], [35.62019, 33.27278], [35.62283, 33.24226], [35.58502, 33.26653], [35.58326, 33.28381], [35.56523, 33.28969], [35.55555, 33.25844], [35.54544, 33.25513], [35.54808, 33.236], [35.5362, 33.23196], [35.54228, 33.19865], [35.52573, 33.11921], [35.50335, 33.114], [35.50272, 33.09056], [35.448, 33.09264], [35.43059, 33.06659], [35.35223, 33.05617], [35.31429, 33.10515], [35.1924, 33.08743], [35.10645, 33.09318], [34.78515, 33.20368], [33.62659, 31.82938], [34.052, 31.46619]]]] } },
29102     { type: "Feature", properties: { iso1A2: "IM", iso1A3: "IMN", iso1N3: "833", wikidata: "Q9676", nameEn: "Isle of Man", country: "GB", groups: ["Q185086", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44 01624", "44 07624", "44 07524", "44 07924"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-3.98763, 54.07351], [-4.1819, 54.57861], [-5.6384, 53.81157], [-3.98763, 54.07351]]]] } },
29103     { type: "Feature", properties: { iso1A2: "IN", iso1A3: "IND", iso1N3: "356", wikidata: "Q668", nameEn: "India" }, geometry: null },
29104     { type: "Feature", properties: { iso1A2: "IO", iso1A3: "IOT", iso1N3: "086", wikidata: "Q43448", nameEn: "British Indian Ocean Territory", country: "GB" }, geometry: null },
29105     { type: "Feature", properties: { iso1A2: "IQ", iso1A3: "IRQ", iso1N3: "368", wikidata: "Q796", nameEn: "Iraq", groups: ["145", "142", "UN"], callingCodes: ["964"] }, geometry: { type: "MultiPolygon", coordinates: [[[[42.78887, 37.38615], [42.56725, 37.14878], [42.35724, 37.10998], [42.36697, 37.0627], [41.81736, 36.58782], [41.40058, 36.52502], [41.28864, 36.35368], [41.2564, 36.06012], [41.37027, 35.84095], [41.38184, 35.62502], [41.26569, 35.42708], [41.21654, 35.1508], [41.2345, 34.80049], [41.12388, 34.65742], [40.97676, 34.39788], [40.64314, 34.31604], [38.79171, 33.37328], [39.08202, 32.50304], [38.98762, 32.47694], [39.04251, 32.30203], [39.26157, 32.35555], [39.29903, 32.23259], [40.01521, 32.05667], [42.97601, 30.72204], [42.97796, 30.48295], [44.72255, 29.19736], [46.42415, 29.05947], [46.5527, 29.10283], [46.89695, 29.50584], [47.15166, 30.01044], [47.37192, 30.10421], [47.7095, 30.10453], [48.01114, 29.98906], [48.06782, 30.02906], [48.17332, 30.02448], [48.40479, 29.85763], [48.59531, 29.66815], [48.83867, 29.78572], [48.61441, 29.93675], [48.51011, 29.96238], [48.44785, 30.00148], [48.4494, 30.04456], [48.43384, 30.08233], [48.38869, 30.11062], [48.38714, 30.13485], [48.41671, 30.17254], [48.41117, 30.19846], [48.26393, 30.3408], [48.24385, 30.33846], [48.21279, 30.31644], [48.19425, 30.32796], [48.18321, 30.39703], [48.14585, 30.44133], [48.02443, 30.4789], [48.03221, 30.9967], [47.68219, 31.00004], [47.6804, 31.39086], [47.86337, 31.78422], [47.64771, 32.07666], [47.52474, 32.15972], [47.57144, 32.20583], [47.37529, 32.47808], [47.17218, 32.45393], [46.46788, 32.91992], [46.32298, 32.9731], [46.17198, 32.95612], [46.09103, 32.98354], [46.15175, 33.07229], [46.03966, 33.09577], [46.05367, 33.13097], [46.11905, 33.11924], [46.20623, 33.20395], [45.99919, 33.5082], [45.86687, 33.49263], [45.96183, 33.55751], [45.89801, 33.63661], [45.77814, 33.60938], [45.50261, 33.94968], [45.42789, 33.9458], [45.41077, 33.97421], [45.47264, 34.03099], [45.56176, 34.15088], [45.58667, 34.30147], [45.53552, 34.35148], [45.49171, 34.3439], [45.46697, 34.38221], [45.43879, 34.45949], [45.51883, 34.47692], [45.53219, 34.60441], [45.59074, 34.55558], [45.60224, 34.55057], [45.73923, 34.54416], [45.70031, 34.69277], [45.65672, 34.7222], [45.68284, 34.76624], [45.70031, 34.82322], [45.73641, 34.83975], [45.79682, 34.85133], [45.78904, 34.91135], [45.86532, 34.89858], [45.89477, 34.95805], [45.87864, 35.03441], [45.92173, 35.0465], [45.92203, 35.09538], [45.93108, 35.08148], [45.94756, 35.09188], [46.06508, 35.03699], [46.07747, 35.0838], [46.11763, 35.07551], [46.19116, 35.11097], [46.15642, 35.1268], [46.16229, 35.16984], [46.19738, 35.18536], [46.18457, 35.22561], [46.11367, 35.23729], [46.15474, 35.2883], [46.13152, 35.32548], [46.05358, 35.38568], [45.98453, 35.49848], [46.01518, 35.52012], [45.97584, 35.58132], [46.03028, 35.57416], [46.01307, 35.59756], [46.0165, 35.61501], [45.99452, 35.63574], [46.0117, 35.65059], [46.01631, 35.69139], [46.23736, 35.71414], [46.34166, 35.78363], [46.32921, 35.82655], [46.17198, 35.8013], [46.08325, 35.8581], [45.94711, 35.82218], [45.89784, 35.83708], [45.81442, 35.82107], [45.76145, 35.79898], [45.6645, 35.92872], [45.60018, 35.96069], [45.55245, 35.99943], [45.46594, 36.00042], [45.38275, 35.97156], [45.33916, 35.99424], [45.37652, 36.06222], [45.37312, 36.09917], [45.32235, 36.17383], [45.30038, 36.27769], [45.26261, 36.3001], [45.27394, 36.35846], [45.23953, 36.43257], [45.11811, 36.40751], [45.00759, 36.5402], [45.06985, 36.62645], [45.06985, 36.6814], [45.01537, 36.75128], [44.84725, 36.77622], [44.83479, 36.81362], [44.90173, 36.86096], [44.91199, 36.91468], [44.89862, 37.01897], [44.81611, 37.04383], [44.75229, 37.11958], [44.78319, 37.1431], [44.76698, 37.16162], [44.63179, 37.19229], [44.42631, 37.05825], [44.38117, 37.05825], [44.35315, 37.04955], [44.35937, 37.02843], [44.30645, 36.97373], [44.25975, 36.98119], [44.18503, 37.09551], [44.22239, 37.15756], [44.27998, 37.16501], [44.2613, 37.25055], [44.13521, 37.32486], [44.02002, 37.33229], [43.90949, 37.22453], [43.84878, 37.22205], [43.82699, 37.19477], [43.8052, 37.22825], [43.7009, 37.23692], [43.63085, 37.21957], [43.56702, 37.25675], [43.50787, 37.24436], [43.33508, 37.33105], [43.30083, 37.30629], [43.11403, 37.37436], [42.93705, 37.32015], [42.78887, 37.38615]]]] } },
29106     { type: "Feature", properties: { iso1A2: "IR", iso1A3: "IRN", iso1N3: "364", wikidata: "Q794", nameEn: "Iran", groups: ["034", "142", "UN"], callingCodes: ["98"] }, geometry: { type: "MultiPolygon", coordinates: [[[[44.96746, 39.42998], [44.88916, 39.59653], [44.81043, 39.62677], [44.71806, 39.71124], [44.65422, 39.72163], [44.6137, 39.78393], [44.47298, 39.68788], [44.48111, 39.61579], [44.41849, 39.56659], [44.42832, 39.4131], [44.37921, 39.4131], [44.29818, 39.378], [44.22452, 39.4169], [44.03667, 39.39223], [44.1043, 39.19842], [44.20946, 39.13975], [44.18863, 38.93881], [44.30322, 38.81581], [44.26155, 38.71427], [44.28065, 38.6465], [44.32058, 38.62752], [44.3207, 38.49799], [44.3119, 38.37887], [44.38309, 38.36117], [44.44386, 38.38295], [44.50115, 38.33939], [44.42476, 38.25763], [44.22509, 37.88859], [44.3883, 37.85433], [44.45948, 37.77065], [44.55498, 37.783], [44.62096, 37.71985], [44.56887, 37.6429], [44.61401, 37.60165], [44.58449, 37.45018], [44.81021, 37.2915], [44.75986, 37.21549], [44.7868, 37.16644], [44.78319, 37.1431], [44.75229, 37.11958], [44.81611, 37.04383], [44.89862, 37.01897], [44.91199, 36.91468], [44.90173, 36.86096], [44.83479, 36.81362], [44.84725, 36.77622], [45.01537, 36.75128], [45.06985, 36.6814], [45.06985, 36.62645], [45.00759, 36.5402], [45.11811, 36.40751], [45.23953, 36.43257], [45.27394, 36.35846], [45.26261, 36.3001], [45.30038, 36.27769], [45.32235, 36.17383], [45.37312, 36.09917], [45.37652, 36.06222], [45.33916, 35.99424], [45.38275, 35.97156], [45.46594, 36.00042], [45.55245, 35.99943], [45.60018, 35.96069], [45.6645, 35.92872], [45.76145, 35.79898], [45.81442, 35.82107], [45.89784, 35.83708], [45.94711, 35.82218], [46.08325, 35.8581], [46.17198, 35.8013], [46.32921, 35.82655], [46.34166, 35.78363], [46.23736, 35.71414], [46.01631, 35.69139], [46.0117, 35.65059], [45.99452, 35.63574], [46.0165, 35.61501], [46.01307, 35.59756], [46.03028, 35.57416], [45.97584, 35.58132], [46.01518, 35.52012], [45.98453, 35.49848], [46.05358, 35.38568], [46.13152, 35.32548], [46.15474, 35.2883], [46.11367, 35.23729], [46.18457, 35.22561], [46.19738, 35.18536], [46.16229, 35.16984], [46.15642, 35.1268], [46.19116, 35.11097], [46.11763, 35.07551], [46.07747, 35.0838], [46.06508, 35.03699], [45.94756, 35.09188], [45.93108, 35.08148], [45.92203, 35.09538], [45.92173, 35.0465], [45.87864, 35.03441], [45.89477, 34.95805], [45.86532, 34.89858], [45.78904, 34.91135], [45.79682, 34.85133], [45.73641, 34.83975], [45.70031, 34.82322], [45.68284, 34.76624], [45.65672, 34.7222], [45.70031, 34.69277], [45.73923, 34.54416], [45.60224, 34.55057], [45.59074, 34.55558], [45.53219, 34.60441], [45.51883, 34.47692], [45.43879, 34.45949], [45.46697, 34.38221], [45.49171, 34.3439], [45.53552, 34.35148], [45.58667, 34.30147], [45.56176, 34.15088], [45.47264, 34.03099], [45.41077, 33.97421], [45.42789, 33.9458], [45.50261, 33.94968], [45.77814, 33.60938], [45.89801, 33.63661], [45.96183, 33.55751], [45.86687, 33.49263], [45.99919, 33.5082], [46.20623, 33.20395], [46.11905, 33.11924], [46.05367, 33.13097], [46.03966, 33.09577], [46.15175, 33.07229], [46.09103, 32.98354], [46.17198, 32.95612], [46.32298, 32.9731], [46.46788, 32.91992], [47.17218, 32.45393], [47.37529, 32.47808], [47.57144, 32.20583], [47.52474, 32.15972], [47.64771, 32.07666], [47.86337, 31.78422], [47.6804, 31.39086], [47.68219, 31.00004], [48.03221, 30.9967], [48.02443, 30.4789], [48.14585, 30.44133], [48.18321, 30.39703], [48.19425, 30.32796], [48.21279, 30.31644], [48.24385, 30.33846], [48.26393, 30.3408], [48.41117, 30.19846], [48.41671, 30.17254], [48.38714, 30.13485], [48.38869, 30.11062], [48.43384, 30.08233], [48.4494, 30.04456], [48.44785, 30.00148], [48.51011, 29.96238], [48.61441, 29.93675], [48.83867, 29.78572], [49.98877, 27.87827], [50.37726, 27.89227], [54.39838, 25.68383], [55.14145, 25.62624], [55.81777, 26.18798], [56.2644, 26.58649], [56.68954, 26.76645], [56.79239, 26.41236], [56.82555, 25.7713], [56.86325, 25.03856], [61.46682, 24.57869], [61.6433, 25.27541], [61.683, 25.66638], [61.83968, 25.7538], [61.83831, 26.07249], [61.89391, 26.26251], [62.05117, 26.31647], [62.21304, 26.26601], [62.31484, 26.528], [62.77352, 26.64099], [63.1889, 26.65072], [63.18688, 26.83844], [63.25005, 26.84212], [63.25005, 27.08692], [63.32283, 27.14437], [63.19649, 27.25674], [62.80604, 27.22412], [62.79684, 27.34381], [62.84905, 27.47627], [62.7638, 28.02992], [62.79412, 28.28108], [62.59499, 28.24842], [62.40259, 28.42703], [61.93581, 28.55284], [61.65978, 28.77937], [61.53765, 29.00507], [61.31508, 29.38903], [60.87231, 29.86514], [61.80829, 30.84224], [61.78268, 30.92724], [61.8335, 30.97669], [61.83257, 31.0452], [61.80957, 31.12576], [61.80569, 31.16167], [61.70929, 31.37391], [60.84541, 31.49561], [60.86191, 32.22565], [60.56485, 33.12944], [60.88908, 33.50219], [60.91133, 33.55596], [60.69573, 33.56054], [60.57762, 33.59772], [60.5485, 33.73422], [60.5838, 33.80793], [60.50209, 34.13992], [60.66502, 34.31539], [60.91321, 34.30411], [60.72316, 34.52857], [60.99922, 34.63064], [61.00197, 34.70631], [61.06926, 34.82139], [61.12831, 35.09938], [61.0991, 35.27845], [61.18187, 35.30249], [61.27371, 35.61482], [61.22719, 35.67038], [61.26152, 35.80749], [61.22444, 35.92879], [61.12007, 35.95992], [61.22719, 36.12759], [61.1393, 36.38782], [61.18187, 36.55348], [61.14516, 36.64644], [60.34767, 36.63214], [60.00768, 37.04102], [59.74678, 37.12499], [59.55178, 37.13594], [59.39385, 37.34257], [59.39797, 37.47892], [59.33507, 37.53146], [59.22905, 37.51161], [58.9338, 37.67374], [58.6921, 37.64548], [58.5479, 37.70526], [58.47786, 37.6433], [58.39959, 37.63134], [58.22999, 37.6856], [58.21399, 37.77281], [57.79534, 37.89299], [57.35042, 37.98546], [57.37236, 38.09321], [57.21169, 38.28965], [57.03453, 38.18717], [56.73928, 38.27887], [56.62255, 38.24005], [56.43303, 38.26054], [56.32454, 38.18502], [56.33278, 38.08132], [55.97847, 38.08024], [55.76561, 38.12238], [55.44152, 38.08564], [55.13412, 37.94705], [54.851, 37.75739], [54.77684, 37.62264], [54.81804, 37.61285], [54.77822, 37.51597], [54.67247, 37.43532], [54.58664, 37.45809], [54.36211, 37.34912], [54.24565, 37.32047], [53.89734, 37.3464], [48.88288, 38.43975], [48.84969, 38.45015], [48.81072, 38.44853], [48.78979, 38.45026], [48.70001, 38.40564], [48.62217, 38.40198], [48.58793, 38.45076], [48.45084, 38.61013], [48.3146, 38.59958], [48.24773, 38.71883], [48.02581, 38.82705], [48.01409, 38.90333], [48.07734, 38.91616], [48.08627, 38.94434], [48.28437, 38.97186], [48.33884, 39.03022], [48.31239, 39.09278], [48.15361, 39.19419], [48.12404, 39.25208], [48.15984, 39.30028], [48.37385, 39.37584], [48.34264, 39.42935], [47.98977, 39.70999], [47.84774, 39.66285], [47.50099, 39.49615], [47.38978, 39.45999], [47.31301, 39.37492], [47.05927, 39.24846], [47.05771, 39.20143], [46.95341, 39.13505], [46.92539, 39.16644], [46.83822, 39.13143], [46.75752, 39.03231], [46.53497, 38.86548], [46.34059, 38.92076], [46.20601, 38.85262], [46.14785, 38.84206], [46.06766, 38.87861], [46.00228, 38.87376], [45.94624, 38.89072], [45.90266, 38.87739], [45.83883, 38.90768], [45.65172, 38.95199], [45.6155, 38.94304], [45.6131, 38.964], [45.44966, 38.99243], [45.44811, 39.04927], [45.40452, 39.07224], [45.40148, 39.09007], [45.30489, 39.18333], [45.16168, 39.21952], [45.08751, 39.35052], [45.05932, 39.36435], [44.96746, 39.42998]]]] } },
29107     { type: "Feature", properties: { iso1A2: "IS", iso1A3: "ISL", iso1N3: "352", wikidata: "Q189", nameEn: "Iceland", groups: ["154", "150", "UN"], callingCodes: ["354"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-33.15676, 62.62995], [-8.25539, 63.0423], [-15.70914, 69.67442], [-33.15676, 62.62995]]]] } },
29108     { type: "Feature", properties: { iso1A2: "IT", iso1A3: "ITA", iso1N3: "380", wikidata: "Q38", nameEn: "Italy", groups: ["EU", "039", "150", "UN"], callingCodes: ["39"] }, geometry: { type: "MultiPolygon", coordinates: [[[[8.95861, 45.96485], [8.97604, 45.96151], [8.97741, 45.98317], [8.96668, 45.98436], [8.95861, 45.96485]]], [[[7.63035, 43.57419], [9.56115, 43.20816], [10.09675, 41.44089], [7.60802, 41.05927], [7.89009, 38.19924], [11.2718, 37.6713], [12.13667, 34.20326], [14.02721, 36.53141], [17.67657, 35.68918], [18.83516, 40.36999], [16.15283, 42.18525], [13.12821, 44.48877], [13.05142, 45.33128], [13.45644, 45.59464], [13.6076, 45.64761], [13.7198, 45.59352], [13.74587, 45.59811], [13.78445, 45.5825], [13.84106, 45.58185], [13.86771, 45.59898], [13.8695, 45.60835], [13.9191, 45.6322], [13.87933, 45.65207], [13.83422, 45.68703], [13.83332, 45.70855], [13.8235, 45.7176], [13.66986, 45.79955], [13.59784, 45.8072], [13.58858, 45.83503], [13.57563, 45.8425], [13.58644, 45.88173], [13.59565, 45.89446], [13.60857, 45.89907], [13.61931, 45.91782], [13.63815, 45.93607], [13.6329, 45.94894], [13.64307, 45.98326], [13.63458, 45.98947], [13.62074, 45.98388], [13.58903, 45.99009], [13.56759, 45.96991], [13.52963, 45.96588], [13.50104, 45.98078], [13.47474, 46.00546], [13.49702, 46.01832], [13.50998, 46.04498], [13.49568, 46.04839], [13.50104, 46.05986], [13.57072, 46.09022], [13.64053, 46.13587], [13.66472, 46.17392], [13.64451, 46.18966], [13.56682, 46.18703], [13.56114, 46.2054], [13.47587, 46.22725], [13.42218, 46.20758], [13.37671, 46.29668], [13.44808, 46.33507], [13.43418, 46.35992], [13.47019, 46.3621], [13.5763, 46.40915], [13.5763, 46.42613], [13.59777, 46.44137], [13.68684, 46.43881], [13.7148, 46.5222], [13.64088, 46.53438], [13.27627, 46.56059], [12.94445, 46.60401], [12.59992, 46.6595], [12.38708, 46.71529], [12.27591, 46.88651], [12.2006, 46.88854], [12.11675, 47.01241], [12.21781, 47.03996], [12.19254, 47.09331], [11.74789, 46.98484], [11.50739, 47.00644], [11.33355, 46.99862], [11.10618, 46.92966], [11.00764, 46.76896], [10.72974, 46.78972], [10.75753, 46.82258], [10.66405, 46.87614], [10.54783, 46.84505], [10.47197, 46.85698], [10.38659, 46.67847], [10.40475, 46.63671], [10.44686, 46.64162], [10.49375, 46.62049], [10.46136, 46.53164], [10.25309, 46.57432], [10.23674, 46.63484], [10.10307, 46.61003], [10.03715, 46.44479], [10.165, 46.41051], [10.10506, 46.3372], [10.17862, 46.25626], [10.14439, 46.22992], [10.07055, 46.21668], [9.95249, 46.38045], [9.73086, 46.35071], [9.71273, 46.29266], [9.57015, 46.2958], [9.46117, 46.37481], [9.45936, 46.50873], [9.40487, 46.46621], [9.36128, 46.5081], [9.28136, 46.49685], [9.25502, 46.43743], [9.29226, 46.32717], [9.24503, 46.23616], [9.01618, 46.04928], [8.99257, 45.9698], [9.09065, 45.89906], [9.06642, 45.8761], [9.04546, 45.84968], [9.04059, 45.8464], [9.03505, 45.83976], [9.03793, 45.83548], [9.03279, 45.82865], [9.0298, 45.82127], [9.00324, 45.82055], [8.99663, 45.83466], [8.9621, 45.83707], [8.94737, 45.84285], [8.91129, 45.8388], [8.93504, 45.86245], [8.94372, 45.86587], [8.93649, 45.86775], [8.88904, 45.95465], [8.86688, 45.96135], [8.85121, 45.97239], [8.8319, 45.9879], [8.79362, 45.99207], [8.78585, 45.98973], [8.79414, 46.00913], [8.85617, 46.0748], [8.80778, 46.10085], [8.75697, 46.10395], [8.62242, 46.12112], [8.45032, 46.26869], [8.46317, 46.43712], [8.42464, 46.46367], [8.30648, 46.41587], [8.31162, 46.38044], [8.08814, 46.26692], [8.16866, 46.17817], [8.11383, 46.11577], [8.02906, 46.10331], [7.98881, 45.99867], [7.9049, 45.99945], [7.85949, 45.91485], [7.56343, 45.97421], [7.10685, 45.85653], [7.04151, 45.92435], [6.95315, 45.85163], [6.80785, 45.83265], [6.80785, 45.71864], [6.98948, 45.63869], [7.00037, 45.509], [7.18019, 45.40071], [7.10572, 45.32924], [7.13115, 45.25386], [7.07074, 45.21228], [6.96706, 45.20841], [6.85144, 45.13226], [6.7697, 45.16044], [6.62803, 45.11175], [6.66981, 45.02324], [6.74791, 45.01939], [6.74519, 44.93661], [6.75518, 44.89915], [6.90774, 44.84322], [6.93499, 44.8664], [7.02217, 44.82519], [7.00401, 44.78782], [7.07484, 44.68073], [7.00582, 44.69364], [6.95133, 44.66264], [6.96042, 44.62129], [6.85507, 44.53072], [6.86233, 44.49834], [6.94504, 44.43112], [6.88784, 44.42043], [6.89171, 44.36637], [6.98221, 44.28289], [7.00764, 44.23736], [7.16929, 44.20352], [7.27827, 44.1462], [7.34547, 44.14359], [7.36364, 44.11882], [7.62155, 44.14881], [7.63245, 44.17877], [7.68694, 44.17487], [7.66878, 44.12795], [7.72508, 44.07578], [7.6597, 44.03009], [7.66848, 43.99943], [7.65266, 43.9763], [7.60771, 43.95772], [7.56858, 43.94506], [7.56075, 43.89932], [7.51162, 43.88301], [7.49355, 43.86551], [7.50423, 43.84345], [7.53006, 43.78405], [7.63035, 43.57419]], [[12.45181, 41.90056], [12.44834, 41.90095], [12.44582, 41.90194], [12.44815, 41.90326], [12.44984, 41.90545], [12.45091, 41.90625], [12.45543, 41.90738], [12.45561, 41.90629], [12.45762, 41.9058], [12.45755, 41.9033], [12.45826, 41.90281], [12.45834, 41.90174], [12.4577, 41.90115], [12.45691, 41.90125], [12.45626, 41.90172], [12.45435, 41.90143], [12.45446, 41.90028], [12.45181, 41.90056]], [[12.45648, 43.89369], [12.44184, 43.90498], [12.41641, 43.89991], [12.40935, 43.9024], [12.41233, 43.90956], [12.40733, 43.92379], [12.41551, 43.92984], [12.41165, 43.93769], [12.40506, 43.94325], [12.40415, 43.95485], [12.41414, 43.95273], [12.42005, 43.9578], [12.43662, 43.95698], [12.44684, 43.96597], [12.46205, 43.97463], [12.47853, 43.98052], [12.49406, 43.98492], [12.50678, 43.99113], [12.51463, 43.99122], [12.5154, 43.98508], [12.51064, 43.98165], [12.51109, 43.97201], [12.50622, 43.97131], [12.50875, 43.96198], [12.50655, 43.95796], [12.51427, 43.94897], [12.51553, 43.94096], [12.50496, 43.93017], [12.50269, 43.92363], [12.49724, 43.92248], [12.49247, 43.91774], [12.49429, 43.90973], [12.48771, 43.89706], [12.45648, 43.89369]]]] } },
29109     { type: "Feature", properties: { iso1A2: "JE", iso1A3: "JEY", iso1N3: "832", wikidata: "Q785", nameEn: "Bailiwick of Jersey", country: "GB", groups: ["830", "Q185086", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44 01534"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.00491, 48.86706], [-1.83944, 49.23037], [-2.09454, 49.46288], [-2.65349, 49.15373], [-2.00491, 48.86706]]]] } },
29110     { type: "Feature", properties: { iso1A2: "JM", iso1A3: "JAM", iso1N3: "388", wikidata: "Q766", nameEn: "Jamaica", aliases: ["JA"], groups: ["029", "003", "419", "019", "UN"], driveSide: "left", callingCodes: ["1 876", "1 658"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-74.09729, 17.36817], [-78.9741, 19.59515], [-78.34606, 16.57862], [-74.09729, 17.36817]]]] } },
29111     { type: "Feature", properties: { iso1A2: "JO", iso1A3: "JOR", iso1N3: "400", wikidata: "Q810", nameEn: "Jordan", groups: ["145", "142", "UN"], callingCodes: ["962"] }, geometry: { type: "MultiPolygon", coordinates: [[[[39.04251, 32.30203], [38.98762, 32.47694], [39.08202, 32.50304], [38.79171, 33.37328], [36.83946, 32.31293], [36.40959, 32.37908], [36.23948, 32.50108], [36.20875, 32.49529], [36.20379, 32.52751], [36.08074, 32.51463], [36.02239, 32.65911], [35.96633, 32.66237], [35.93307, 32.71966], [35.88405, 32.71321], [35.75983, 32.74803], [35.68467, 32.70715], [35.66527, 32.681], [35.61669, 32.67999], [35.59813, 32.65159], [35.56614, 32.64393], [35.57485, 32.48669], [35.55494, 32.42687], [35.55807, 32.38674], [35.57111, 32.21877], [35.52012, 32.04076], [35.54375, 31.96587], [35.52758, 31.9131], [35.55941, 31.76535], [35.47672, 31.49578], [35.40316, 31.25535], [35.43658, 31.12444], [35.41371, 30.95565], [35.33984, 30.8802], [35.33456, 30.81224], [35.29311, 30.71365], [35.21379, 30.60401], [35.19595, 30.50297], [35.16218, 30.43535], [35.19183, 30.34636], [35.14108, 30.07374], [35.02147, 29.66343], [34.98207, 29.58147], [34.97718, 29.54294], [34.92298, 29.45305], [34.8812, 29.36878], [36.07081, 29.18469], [36.50005, 29.49696], [36.75083, 29.86903], [37.4971, 29.99949], [37.66395, 30.33245], [37.99354, 30.49998], [36.99791, 31.50081], [38.99233, 31.99721], [39.29903, 32.23259], [39.26157, 32.35555], [39.04251, 32.30203]]]] } },
29112     { type: "Feature", properties: { iso1A2: "JP", iso1A3: "JPN", iso1N3: "392", wikidata: "Q17", nameEn: "Japan", groups: ["030", "142", "UN"], driveSide: "left", callingCodes: ["81"] }, geometry: { type: "MultiPolygon", coordinates: [[[[145.82361, 43.38904], [145.23667, 43.76813], [145.82343, 44.571], [140.9182, 45.92937], [133.61399, 37.41], [129.2669, 34.87122], [122.26612, 25.98197], [123.92912, 17.8782], [155.16731, 23.60141], [145.82361, 43.38904]]]] } },
29113     { type: "Feature", properties: { iso1A2: "KE", iso1A3: "KEN", iso1N3: "404", wikidata: "Q114", nameEn: "Kenya", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["254"] }, geometry: { type: "MultiPolygon", coordinates: [[[[35.9419, 4.61933], [35.51424, 4.61643], [35.42366, 4.76969], [35.47843, 4.91872], [35.30992, 4.90402], [35.34151, 5.02364], [34.47601, 4.72162], [33.9873, 4.23316], [34.06046, 4.15235], [34.15429, 3.80464], [34.45815, 3.67385], [34.44922, 3.51627], [34.39112, 3.48802], [34.41794, 3.44342], [34.40006, 3.37949], [34.45815, 3.18319], [34.56242, 3.11478], [34.60114, 2.93034], [34.65774, 2.8753], [34.73967, 2.85447], [34.78137, 2.76223], [34.77244, 2.70272], [34.95267, 2.47209], [34.90947, 2.42447], [34.98692, 1.97348], [34.9899, 1.6668], [34.92734, 1.56109], [34.87819, 1.5596], [34.7918, 1.36752], [34.82606, 1.30944], [34.82606, 1.26626], [34.80223, 1.22754], [34.67562, 1.21265], [34.58029, 1.14712], [34.57427, 1.09868], [34.52369, 1.10692], [34.43349, 0.85254], [34.40041, 0.80266], [34.31516, 0.75693], [34.27345, 0.63182], [34.20196, 0.62289], [34.13493, 0.58118], [34.11408, 0.48884], [34.08727, 0.44713], [34.10067, 0.36372], [33.90936, 0.10581], [33.98449, -0.13079], [33.9264, -0.54188], [33.93107, -0.99298], [34.02286, -1.00779], [34.03084, -1.05101], [34.0824, -1.02264], [37.67199, -3.06222], [37.71745, -3.304], [37.5903, -3.42735], [37.63099, -3.50723], [37.75036, -3.54243], [37.81321, -3.69179], [39.21631, -4.67835], [39.44306, -4.93877], [39.62121, -4.68136], [41.75542, -1.85308], [41.56362, -1.66375], [41.56, -1.59812], [41.00099, -0.83068], [40.98767, 2.82959], [41.31368, 3.14314], [41.89488, 3.97375], [41.1754, 3.94079], [40.77498, 4.27683], [39.86043, 3.86974], [39.76808, 3.67058], [39.58339, 3.47434], [39.55132, 3.39634], [39.51551, 3.40895], [39.49444, 3.45521], [39.19954, 3.47834], [39.07736, 3.5267], [38.91938, 3.51198], [38.52336, 3.62551], [38.45812, 3.60445], [38.14168, 3.62487], [37.07724, 4.33503], [36.84474, 4.44518], [36.03924, 4.44406], [35.95449, 4.53244], [35.9419, 4.61933]]]] } },
29114     { type: "Feature", properties: { iso1A2: "KG", iso1A3: "KGZ", iso1N3: "417", wikidata: "Q813", nameEn: "Kyrgyzstan", groups: ["143", "142", "UN"], callingCodes: ["996"] }, geometry: { type: "MultiPolygon", coordinates: [[[[74.88756, 42.98612], [74.75, 42.99029], [74.70331, 43.02519], [74.64615, 43.05881], [74.57491, 43.13702], [74.22489, 43.24657], [73.55634, 43.03071], [73.50992, 42.82356], [73.44393, 42.43098], [71.88792, 42.83578], [71.62405, 42.76613], [71.53272, 42.8014], [71.2724, 42.77853], [71.22785, 42.69248], [71.17807, 42.67381], [71.15232, 42.60486], [70.97717, 42.50147], [70.85973, 42.30188], [70.94483, 42.26238], [71.13263, 42.28356], [71.28719, 42.18033], [70.69777, 41.92554], [70.17682, 41.5455], [70.48909, 41.40335], [70.67586, 41.47953], [70.78572, 41.36419], [70.77885, 41.24813], [70.86263, 41.23833], [70.9615, 41.16393], [71.02193, 41.19494], [71.11806, 41.15359], [71.25813, 41.18796], [71.27187, 41.11015], [71.34877, 41.16807], [71.40198, 41.09436], [71.46148, 41.13958], [71.43814, 41.19644], [71.46688, 41.31883], [71.57227, 41.29175], [71.6787, 41.42111], [71.65914, 41.49599], [71.73054, 41.54713], [71.71132, 41.43012], [71.76625, 41.4466], [71.83914, 41.3546], [71.91457, 41.2982], [71.85964, 41.19081], [72.07249, 41.11739], [72.10745, 41.15483], [72.16433, 41.16483], [72.17594, 41.15522], [72.14864, 41.13363], [72.1792, 41.10621], [72.21061, 41.05607], [72.17594, 41.02377], [72.18339, 40.99571], [72.324, 41.03381], [72.34026, 41.04539], [72.34757, 41.06104], [72.36138, 41.04384], [72.38511, 41.02785], [72.45206, 41.03018], [72.48742, 40.97136], [72.55109, 40.96046], [72.59136, 40.86947], [72.68157, 40.84942], [72.84291, 40.85512], [72.94454, 40.8094], [73.01869, 40.84681], [73.13267, 40.83512], [73.13412, 40.79122], [73.0612, 40.76678], [72.99133, 40.76457], [72.93296, 40.73089], [72.8722, 40.71111], [72.85372, 40.7116], [72.84754, 40.67229], [72.80137, 40.67856], [72.74866, 40.60873], [72.74894, 40.59592], [72.75982, 40.57273], [72.74862, 40.57131], [72.74768, 40.58051], [72.73995, 40.58409], [72.69579, 40.59778], [72.66713, 40.59076], [72.66713, 40.5219], [72.47795, 40.5532], [72.40517, 40.61917], [72.34406, 40.60144], [72.41714, 40.55736], [72.38384, 40.51535], [72.41513, 40.50856], [72.44191, 40.48222], [72.40346, 40.4007], [72.24368, 40.46091], [72.18648, 40.49893], [71.96401, 40.31907], [72.05464, 40.27586], [71.85002, 40.25647], [71.82646, 40.21872], [71.73054, 40.14818], [71.71719, 40.17886], [71.69621, 40.18492], [71.70569, 40.20391], [71.68386, 40.26984], [71.61931, 40.26775], [71.61725, 40.20615], [71.51549, 40.22986], [71.51215, 40.26943], [71.4246, 40.28619], [71.36663, 40.31593], [71.13042, 40.34106], [71.05901, 40.28765], [70.95789, 40.28761], [70.9818, 40.22392], [70.80495, 40.16813], [70.7928, 40.12797], [70.65827, 40.0981], [70.65946, 39.9878], [70.58912, 39.95211], [70.55033, 39.96619], [70.47557, 39.93216], [70.57384, 39.99394], [70.58297, 40.00891], [70.01283, 40.23288], [69.67001, 40.10639], [69.64704, 40.12165], [69.57615, 40.10524], [69.55555, 40.12296], [69.53794, 40.11833], [69.53855, 40.0887], [69.5057, 40.03277], [69.53615, 39.93991], [69.43557, 39.92877], [69.43134, 39.98431], [69.35649, 40.01994], [69.26938, 39.8127], [69.3594, 39.52516], [69.68677, 39.59281], [69.87491, 39.53882], [70.11111, 39.58223], [70.2869, 39.53141], [70.44757, 39.60128], [70.64087, 39.58792], [70.7854, 39.38933], [71.06418, 39.41586], [71.08752, 39.50704], [71.49814, 39.61397], [71.55856, 39.57588], [71.5517, 39.45722], [71.62688, 39.44056], [71.76816, 39.45456], [71.80164, 39.40631], [71.7522, 39.32031], [71.79202, 39.27355], [71.90601, 39.27674], [72.04059, 39.36704], [72.09689, 39.26823], [72.17242, 39.2661], [72.23834, 39.17248], [72.33173, 39.33093], [72.62027, 39.39696], [72.85934, 39.35116], [73.18454, 39.35536], [73.31912, 39.38615], [73.45096, 39.46677], [73.59831, 39.46425], [73.87018, 39.47879], [73.94683, 39.60733], [73.92354, 39.69565], [73.9051, 39.75073], [73.83006, 39.76136], [73.97049, 40.04378], [74.25533, 40.13191], [74.35063, 40.09742], [74.69875, 40.34668], [74.85996, 40.32857], [74.78168, 40.44886], [74.82013, 40.52197], [75.08243, 40.43945], [75.22834, 40.45382], [75.5854, 40.66874], [75.69663, 40.28642], [75.91361, 40.2948], [75.96168, 40.38064], [76.33659, 40.3482], [76.5261, 40.46114], [76.75681, 40.95354], [76.99302, 41.0696], [77.28004, 41.0033], [77.3693, 41.0375], [77.52723, 41.00227], [77.76206, 41.01574], [77.81287, 41.14307], [78.12873, 41.23091], [78.15757, 41.38565], [78.3732, 41.39603], [79.92977, 42.04113], [80.17842, 42.03211], [80.17807, 42.21166], [79.97364, 42.42816], [79.52921, 42.44778], [79.19763, 42.804], [78.91502, 42.76839], [78.48469, 42.89649], [75.82823, 42.94848], [75.72174, 42.79672], [75.29966, 42.86183], [75.22619, 42.85528], [74.88756, 42.98612]], [[70.74189, 39.86319], [70.63105, 39.77923], [70.59667, 39.83542], [70.54998, 39.85137], [70.52631, 39.86989], [70.53651, 39.89155], [70.74189, 39.86319]], [[71.86463, 39.98598], [71.84316, 39.95582], [71.7504, 39.93701], [71.71511, 39.96348], [71.78838, 40.01404], [71.86463, 39.98598]], [[71.21139, 40.03369], [71.1427, 39.95026], [71.23067, 39.93581], [71.16101, 39.88423], [71.10531, 39.91354], [71.04979, 39.89808], [71.10501, 39.95568], [71.09063, 39.99], [71.11668, 39.99291], [71.11037, 40.01984], [71.01035, 40.05481], [71.00236, 40.18154], [71.06305, 40.1771], [71.12218, 40.03052], [71.21139, 40.03369]]]] } },
29115     { type: "Feature", properties: { iso1A2: "KH", iso1A3: "KHM", iso1N3: "116", wikidata: "Q424", nameEn: "Cambodia", groups: ["035", "142", "UN"], callingCodes: ["855"] }, geometry: { type: "MultiPolygon", coordinates: [[[[105.87328, 11.55953], [105.81645, 11.56876], [105.80867, 11.60536], [105.8507, 11.66635], [105.88962, 11.67854], [105.95188, 11.63738], [106.00792, 11.7197], [106.02038, 11.77457], [106.06708, 11.77761], [106.13158, 11.73283], [106.18539, 11.75171], [106.26478, 11.72122], [106.30525, 11.67549], [106.37219, 11.69836], [106.44691, 11.66787], [106.45158, 11.68616], [106.41577, 11.76999], [106.44535, 11.8279], [106.44068, 11.86294], [106.4687, 11.86751], [106.4111, 11.97413], [106.70687, 11.96956], [106.79405, 12.0807], [106.92325, 12.06548], [106.99953, 12.08983], [107.15831, 12.27547], [107.34511, 12.33327], [107.42917, 12.24657], [107.4463, 12.29373], [107.55059, 12.36824], [107.5755, 12.52177], [107.55993, 12.7982], [107.49611, 12.88926], [107.49144, 13.01215], [107.62843, 13.3668], [107.61909, 13.52577], [107.53503, 13.73908], [107.45252, 13.78897], [107.46498, 13.91593], [107.44318, 13.99751], [107.38247, 13.99147], [107.35757, 14.02319], [107.37158, 14.07906], [107.33577, 14.11832], [107.40427, 14.24509], [107.39493, 14.32655], [107.44941, 14.41552], [107.48521, 14.40346], [107.52569, 14.54665], [107.52102, 14.59034], [107.55371, 14.628], [107.54361, 14.69092], [107.47238, 14.61523], [107.44435, 14.52785], [107.37897, 14.54443], [107.3276, 14.58812], [107.29803, 14.58963], [107.26534, 14.54292], [107.256, 14.48716], [107.21241, 14.48716], [107.17038, 14.41782], [107.09722, 14.3937], [107.03962, 14.45099], [107.04585, 14.41782], [106.98825, 14.36806], [106.9649, 14.3198], [106.90574, 14.33639], [106.8497, 14.29416], [106.80767, 14.31226], [106.73762, 14.42687], [106.63333, 14.44194], [106.59908, 14.50977], [106.57106, 14.50525], [106.54148, 14.59565], [106.50723, 14.58963], [106.45898, 14.55045], [106.47766, 14.50977], [106.43874, 14.52032], [106.40916, 14.45249], [106.32355, 14.44043], [106.25194, 14.48415], [106.21302, 14.36203], [106.00131, 14.36957], [105.99509, 14.32734], [106.02311, 14.30623], [106.04801, 14.20363], [106.10872, 14.18401], [106.11962, 14.11307], [106.18656, 14.06324], [106.16632, 14.01794], [106.10094, 13.98471], [106.10405, 13.9137], [105.90791, 13.92881], [105.78182, 14.02247], [105.78338, 14.08438], [105.5561, 14.15684], [105.44869, 14.10703], [105.36775, 14.09948], [105.2759, 14.17496], [105.20894, 14.34967], [105.17748, 14.34432], [105.14012, 14.23873], [105.08408, 14.20402], [105.02804, 14.23722], [104.97667, 14.38806], [104.69335, 14.42726], [104.55014, 14.36091], [104.27616, 14.39861], [103.93836, 14.3398], [103.70175, 14.38052], [103.71109, 14.4348], [103.53518, 14.42575], [103.39353, 14.35639], [103.16469, 14.33075], [102.93275, 14.19044], [102.91251, 14.01531], [102.77864, 13.93374], [102.72727, 13.77806], [102.56848, 13.69366], [102.5481, 13.6589], [102.58635, 13.6286], [102.62483, 13.60883], [102.57573, 13.60461], [102.5358, 13.56933], [102.44601, 13.5637], [102.36859, 13.57488], [102.33828, 13.55613], [102.361, 13.50551], [102.35563, 13.47307], [102.35692, 13.38274], [102.34611, 13.35618], [102.36001, 13.31142], [102.36146, 13.26006], [102.43422, 13.09061], [102.46011, 13.08057], [102.52275, 12.99813], [102.48694, 12.97537], [102.49335, 12.92711], [102.53053, 12.77506], [102.4994, 12.71736], [102.51963, 12.66117], [102.57567, 12.65358], [102.7796, 12.43781], [102.78116, 12.40284], [102.73134, 12.37091], [102.70176, 12.1686], [102.77026, 12.06815], [102.78427, 11.98746], [102.83957, 11.8519], [102.90973, 11.75613], [102.91449, 11.65512], [102.52395, 11.25257], [102.47649, 9.66162], [103.99198, 10.48391], [104.43778, 10.42386], [104.47963, 10.43046], [104.49869, 10.4057], [104.59018, 10.53073], [104.87933, 10.52833], [104.95094, 10.64003], [105.09571, 10.72722], [105.02722, 10.89236], [105.08326, 10.95656], [105.11449, 10.96332], [105.34011, 10.86179], [105.42884, 10.96878], [105.50045, 10.94586], [105.77751, 11.03671], [105.86376, 10.89839], [105.84603, 10.85873], [105.93403, 10.83853], [105.94535, 10.9168], [106.06708, 10.8098], [106.18539, 10.79451], [106.14301, 10.98176], [106.20095, 10.97795], [106.1757, 11.07301], [106.1527, 11.10476], [106.10444, 11.07879], [105.86782, 11.28343], [105.88962, 11.43605], [105.87328, 11.55953]]]] } },
29116     { type: "Feature", properties: { iso1A2: "KI", iso1A3: "KIR", iso1N3: "296", wikidata: "Q710", nameEn: "Kiribati", groups: ["057", "009", "UN"], driveSide: "left", callingCodes: ["686"] }, geometry: { type: "MultiPolygon", coordinates: [[[[169, 3.9], [169, -3.5], [178, -3.5], [178, 3.9], [169, 3.9]]], [[[-161.06795, 5.2462], [-158.12991, -1.86122], [-175.33482, -1.40631], [-175.31804, -7.54825], [-156.50903, -7.4975], [-156.48634, -15.52824], [-135.59706, -4.70473], [-161.06795, 5.2462]]]] } },
29117     { type: "Feature", properties: { iso1A2: "KM", iso1A3: "COM", iso1N3: "174", wikidata: "Q970", nameEn: "Comoros", groups: ["014", "202", "002", "UN"], callingCodes: ["269"] }, geometry: { type: "MultiPolygon", coordinates: [[[[42.63904, -10.02522], [43.28731, -13.97126], [45.4971, -11.75965], [42.63904, -10.02522]]]] } },
29118     { type: "Feature", properties: { iso1A2: "KN", iso1A3: "KNA", iso1N3: "659", wikidata: "Q763", nameEn: "St. Kitts and Nevis", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 869"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-62.29333, 17.43155], [-62.76692, 17.64353], [-63.09677, 17.21372], [-62.63813, 16.65446], [-62.29333, 17.43155]]]] } },
29119     { type: "Feature", properties: { iso1A2: "KP", iso1A3: "PRK", iso1N3: "408", wikidata: "Q423", nameEn: "North Korea", groups: ["030", "142", "UN"], callingCodes: ["850"] }, geometry: { type: "MultiPolygon", coordinates: [[[[130.26095, 42.9027], [130.09764, 42.91425], [130.12957, 42.98361], [129.96409, 42.97306], [129.95082, 43.01051], [129.8865, 43.00395], [129.85261, 42.96494], [129.83277, 42.86746], [129.80719, 42.79218], [129.7835, 42.76521], [129.77183, 42.69435], [129.75294, 42.59409], [129.72541, 42.43739], [129.60482, 42.44461], [129.54701, 42.37254], [129.42882, 42.44702], [129.28541, 42.41574], [129.22423, 42.3553], [129.22285, 42.26491], [129.15178, 42.17224], [128.96068, 42.06657], [128.94007, 42.03537], [128.04487, 42.01769], [128.15119, 41.74568], [128.30716, 41.60322], [128.20061, 41.40895], [128.18546, 41.41279], [128.12967, 41.37931], [128.03311, 41.39232], [128.02633, 41.42103], [127.92943, 41.44291], [127.29712, 41.49473], [127.17841, 41.59714], [126.90729, 41.79955], [126.60631, 41.65565], [126.53189, 41.35206], [126.242, 41.15454], [126.00335, 40.92835], [125.76869, 40.87908], [125.71172, 40.85223], [124.86913, 40.45387], [124.40719, 40.13655], [124.38556, 40.11047], [124.3322, 40.05573], [124.37089, 40.03004], [124.35029, 39.95639], [124.23201, 39.9248], [124.17532, 39.8232], [123.90497, 38.79949], [123.85601, 37.49093], [124.67666, 38.05679], [124.84224, 37.977], [124.87921, 37.80827], [125.06408, 37.66334], [125.37112, 37.62643], [125.81159, 37.72949], [126.13074, 37.70512], [126.18776, 37.74728], [126.19097, 37.81462], [126.24402, 37.83113], [126.43239, 37.84095], [126.46818, 37.80873], [126.56709, 37.76857], [126.59918, 37.76364], [126.66067, 37.7897], [126.68793, 37.83728], [126.68793, 37.9175], [126.67023, 37.95852], [126.84961, 38.0344], [126.88106, 38.10246], [126.95887, 38.1347], [126.95338, 38.17735], [127.04479, 38.25518], [127.15749, 38.30722], [127.38727, 38.33227], [127.49672, 38.30647], [127.55013, 38.32257], [128.02917, 38.31861], [128.27652, 38.41657], [128.31105, 38.58462], [128.37487, 38.62345], [128.65655, 38.61914], [131.95041, 41.5445], [130.65022, 42.32281], [130.66367, 42.38024], [130.64181, 42.41422], [130.60805, 42.4317], [130.56835, 42.43281], [130.55143, 42.52158], [130.50123, 42.61636], [130.44361, 42.54849], [130.41826, 42.6011], [130.2385, 42.71127], [130.23068, 42.80125], [130.26095, 42.9027]]]] } },
29120     { type: "Feature", properties: { iso1A2: "KR", iso1A3: "KOR", iso1N3: "410", wikidata: "Q884", nameEn: "South Korea", groups: ["030", "142", "UN"], callingCodes: ["82"] }, geometry: { type: "MultiPolygon", coordinates: [[[[133.11729, 37.53115], [128.65655, 38.61914], [128.37487, 38.62345], [128.31105, 38.58462], [128.27652, 38.41657], [128.02917, 38.31861], [127.55013, 38.32257], [127.49672, 38.30647], [127.38727, 38.33227], [127.15749, 38.30722], [127.04479, 38.25518], [126.95338, 38.17735], [126.95887, 38.1347], [126.88106, 38.10246], [126.84961, 38.0344], [126.67023, 37.95852], [126.68793, 37.9175], [126.68793, 37.83728], [126.66067, 37.7897], [126.59918, 37.76364], [126.56709, 37.76857], [126.46818, 37.80873], [126.43239, 37.84095], [126.24402, 37.83113], [126.19097, 37.81462], [126.18776, 37.74728], [126.13074, 37.70512], [125.81159, 37.72949], [125.37112, 37.62643], [125.06408, 37.66334], [124.87921, 37.80827], [124.84224, 37.977], [124.67666, 38.05679], [123.85601, 37.49093], [122.80525, 33.30571], [125.99728, 32.63328], [129.2669, 34.87122], [133.11729, 37.53115]]]] } },
29121     { type: "Feature", properties: { iso1A2: "KW", iso1A3: "KWT", iso1N3: "414", wikidata: "Q817", nameEn: "Kuwait", groups: ["145", "142", "UN"], callingCodes: ["965"] }, geometry: { type: "MultiPolygon", coordinates: [[[[49.00421, 28.81495], [48.59531, 29.66815], [48.40479, 29.85763], [48.17332, 30.02448], [48.06782, 30.02906], [48.01114, 29.98906], [47.7095, 30.10453], [47.37192, 30.10421], [47.15166, 30.01044], [46.89695, 29.50584], [46.5527, 29.10283], [47.46202, 29.0014], [47.58376, 28.83382], [47.59863, 28.66798], [47.70561, 28.5221], [48.42991, 28.53628], [49.00421, 28.81495]]]] } },
29122     { type: "Feature", properties: { iso1A2: "KY", iso1A3: "CYM", iso1N3: "136", wikidata: "Q5785", nameEn: "Cayman Islands", country: "GB", groups: ["BOTS", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 345"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-82.11509, 19.60401], [-80.36068, 18.11751], [-79.32727, 20.06742], [-82.11509, 19.60401]]]] } },
29123     { type: "Feature", properties: { iso1A2: "KZ", iso1A3: "KAZ", iso1N3: "398", wikidata: "Q232", nameEn: "Kazakhstan", groups: ["143", "142", "UN"], callingCodes: ["7"] }, geometry: { type: "MultiPolygon", coordinates: [[[[68.90865, 55.38148], [68.19206, 55.18823], [68.26661, 55.09226], [68.21308, 54.98645], [65.20174, 54.55216], [65.24663, 54.35721], [65.11033, 54.33028], [64.97216, 54.4212], [63.97686, 54.29763], [64.02715, 54.22679], [63.91224, 54.20013], [63.80604, 54.27079], [62.58651, 54.05871], [62.56876, 53.94047], [62.45931, 53.90737], [62.38535, 54.03961], [62.00966, 54.04134], [62.03913, 53.94768], [61.65318, 54.02445], [61.56941, 53.95703], [61.47603, 54.08048], [61.3706, 54.08464], [61.26863, 53.92797], [60.99796, 53.93699], [61.14283, 53.90063], [61.22574, 53.80268], [60.90626, 53.62937], [61.55706, 53.57144], [61.57185, 53.50112], [61.37957, 53.45887], [61.29082, 53.50992], [61.14291, 53.41481], [61.19024, 53.30536], [62.14574, 53.09626], [62.12799, 52.99133], [62.0422, 52.96105], [61.23462, 53.03227], [61.05842, 52.92217], [60.71989, 52.75923], [60.71693, 52.66245], [60.84118, 52.63912], [60.84709, 52.52228], [60.98021, 52.50068], [61.05417, 52.35096], [60.78201, 52.22067], [60.72581, 52.15538], [60.48915, 52.15175], [60.19925, 51.99173], [59.99809, 51.98263], [60.09867, 51.87135], [60.50986, 51.7964], [60.36787, 51.66815], [60.5424, 51.61675], [60.92401, 51.61124], [60.95655, 51.48615], [61.50677, 51.40687], [61.55114, 51.32746], [61.6813, 51.25716], [61.56889, 51.23679], [61.4431, 50.80679], [60.81833, 50.6629], [60.31914, 50.67705], [60.17262, 50.83312], [60.01288, 50.8163], [59.81172, 50.54451], [59.51886, 50.49937], [59.48928, 50.64216], [58.87974, 50.70852], [58.3208, 51.15151], [57.75578, 51.13852], [57.74986, 50.93017], [57.44221, 50.88354], [57.17302, 51.11253], [56.17906, 50.93204], [56.11398, 50.7471], [55.67774, 50.54508], [54.72067, 51.03261], [54.56685, 51.01958], [54.71476, 50.61214], [54.55797, 50.52006], [54.41894, 50.61214], [54.46331, 50.85554], [54.12248, 51.11542], [53.69299, 51.23466], [53.46165, 51.49445], [52.54329, 51.48444], [52.36119, 51.74161], [51.8246, 51.67916], [51.77431, 51.49536], [51.301, 51.48799], [51.26254, 51.68466], [50.59695, 51.61859], [50.26859, 51.28677], [49.97277, 51.2405], [49.76866, 51.11067], [49.39001, 51.09396], [49.41959, 50.85927], [49.12673, 50.78639], [48.86936, 50.61589], [48.57946, 50.63278], [48.90782, 50.02281], [48.68352, 49.89546], [48.42564, 49.82283], [48.24519, 49.86099], [48.10044, 50.09242], [47.58551, 50.47867], [47.30448, 50.30894], [47.34589, 50.09308], [47.18319, 49.93721], [46.9078, 49.86707], [46.78398, 49.34026], [47.04658, 49.19834], [47.00857, 49.04921], [46.78392, 48.95352], [46.49011, 48.43019], [47.11516, 48.27188], [47.12107, 47.83687], [47.38731, 47.68176], [47.41689, 47.83687], [47.64973, 47.76559], [48.15348, 47.74545], [48.45173, 47.40818], [48.52326, 47.4102], [49.01136, 46.72716], [48.51142, 46.69268], [48.54988, 46.56267], [49.16518, 46.38542], [49.32259, 46.26944], [49.88945, 46.04554], [49.2134, 44.84989], [52.26048, 41.69249], [52.47884, 41.78034], [52.97575, 42.1308], [54.20635, 42.38477], [54.95182, 41.92424], [55.45471, 41.25609], [56.00314, 41.32584], [55.97584, 44.99322], [55.97584, 44.99328], [55.97584, 44.99338], [55.97584, 44.99343], [55.97584, 44.99348], [55.97584, 44.99353], [55.97584, 44.99359], [55.97584, 44.99369], [55.97584, 44.99374], [55.97584, 44.99384], [55.97584, 44.9939], [55.97584, 44.994], [55.97584, 44.99405], [55.97584, 44.99415], [55.97584, 44.99421], [55.97584, 44.99426], [55.97584, 44.99431], [55.97584, 44.99436], [55.97584, 44.99441], [55.97594, 44.99446], [55.97605, 44.99452], [55.97605, 44.99457], [55.97605, 44.99462], [55.97605, 44.99467], [55.97605, 44.99477], [55.97615, 44.99477], [55.97615, 44.99483], [55.97615, 44.99493], [55.97615, 44.99498], [55.97615, 44.99503], [55.97615, 44.99508], [55.97625, 44.99514], [55.97636, 44.99519], [55.97636, 44.99524], [55.97646, 44.99529], [55.97646, 44.99534], [55.97656, 44.99539], [55.97667, 44.99545], [55.97677, 44.9955], [55.97677, 44.99555], [55.97677, 44.9956], [55.97687, 44.9956], [55.97698, 44.99565], [55.97698, 44.9957], [55.97708, 44.99576], [55.97718, 44.99581], [55.97729, 44.99586], [55.97739, 44.99586], [55.97739, 44.99591], [55.97749, 44.99591], [55.9776, 44.99591], [55.9777, 44.99596], [55.9777, 44.99601], [55.9778, 44.99607], [55.97791, 44.99607], [55.97801, 44.99607], [55.97801, 44.99612], [55.97811, 44.99617], [55.97822, 44.99617], [55.97832, 44.99622], [55.97842, 44.99622], [58.59711, 45.58671], [61.01475, 44.41383], [62.01711, 43.51008], [63.34656, 43.64003], [64.53885, 43.56941], [64.96464, 43.74748], [65.18666, 43.48835], [65.53277, 43.31856], [65.85194, 42.85481], [66.09482, 42.93426], [66.00546, 41.94455], [66.53302, 41.87388], [66.69129, 41.1311], [67.9644, 41.14611], [67.98511, 41.02794], [68.08273, 41.08148], [68.1271, 41.0324], [67.96736, 40.83798], [68.49983, 40.56437], [68.63, 40.59358], [68.58444, 40.91447], [68.49983, 40.99669], [68.62221, 41.03019], [68.65662, 40.93861], [68.73945, 40.96989], [68.7217, 41.05025], [69.01308, 41.22804], [69.05006, 41.36183], [69.15137, 41.43078], [69.17701, 41.43769], [69.18528, 41.45175], [69.20439, 41.45391], [69.22671, 41.46298], [69.23332, 41.45847], [69.25059, 41.46693], [69.29778, 41.43673], [69.35554, 41.47211], [69.37468, 41.46555], [69.45081, 41.46246], [69.39485, 41.51518], [69.45751, 41.56863], [69.49545, 41.545], [70.94483, 42.26238], [70.85973, 42.30188], [70.97717, 42.50147], [71.15232, 42.60486], [71.17807, 42.67381], [71.22785, 42.69248], [71.2724, 42.77853], [71.53272, 42.8014], [71.62405, 42.76613], [71.88792, 42.83578], [73.44393, 42.43098], [73.50992, 42.82356], [73.55634, 43.03071], [74.22489, 43.24657], [74.57491, 43.13702], [74.64615, 43.05881], [74.70331, 43.02519], [74.75, 42.99029], [74.88756, 42.98612], [75.22619, 42.85528], [75.29966, 42.86183], [75.72174, 42.79672], [75.82823, 42.94848], [78.48469, 42.89649], [78.91502, 42.76839], [79.19763, 42.804], [79.52921, 42.44778], [79.97364, 42.42816], [80.17807, 42.21166], [80.26841, 42.23797], [80.16892, 42.61137], [80.26886, 42.8366], [80.38169, 42.83142], [80.58999, 42.9011], [80.3735, 43.01557], [80.62913, 43.141], [80.78817, 43.14235], [80.77771, 43.30065], [80.69718, 43.32589], [80.75156, 43.44948], [80.40031, 44.10986], [80.40229, 44.23319], [80.38384, 44.63073], [79.8987, 44.89957], [80.11169, 45.03352], [81.73278, 45.3504], [82.51374, 45.1755], [82.58474, 45.40027], [82.21792, 45.56619], [83.04622, 47.19053], [83.92184, 46.98912], [84.73077, 47.01394], [84.93995, 46.87399], [85.22443, 47.04816], [85.54294, 47.06171], [85.69696, 47.2898], [85.61067, 47.49753], [85.5169, 48.05493], [85.73581, 48.3939], [86.38069, 48.46064], [86.75343, 48.70331], [86.73568, 48.99918], [86.87238, 49.12432], [87.28386, 49.11626], [87.31465, 49.23603], [87.03071, 49.25142], [86.82606, 49.51796], [86.61307, 49.60239], [86.79056, 49.74787], [86.63674, 49.80136], [86.18709, 49.50259], [85.24047, 49.60239], [84.99198, 50.06793], [84.29385, 50.27257], [83.8442, 50.87375], [83.14607, 51.00796], [82.55443, 50.75412], [81.94999, 50.79307], [81.46581, 50.77658], [81.41248, 50.97524], [81.06091, 50.94833], [81.16999, 51.15662], [80.80318, 51.28262], [80.44819, 51.20855], [80.4127, 50.95581], [80.08138, 50.77658], [79.11255, 52.01171], [77.90383, 53.29807], [76.54243, 53.99329], [76.44076, 54.16017], [76.82266, 54.1798], [76.91052, 54.4677], [75.3668, 54.07439], [75.43398, 53.98652], [75.07405, 53.80831], [73.39218, 53.44623], [73.25412, 53.61532], [73.68921, 53.86522], [73.74778, 54.07194], [73.37963, 53.96132], [72.71026, 54.1161], [72.43415, 53.92685], [72.17477, 54.36303], [71.96141, 54.17736], [71.10379, 54.13326], [71.08706, 54.33376], [71.24185, 54.64965], [71.08288, 54.71253], [70.96009, 55.10558], [70.76493, 55.3027], [70.19179, 55.1476], [69.74917, 55.35545], [69.34224, 55.36344], [68.90865, 55.38148]]]] } },
29124     { type: "Feature", properties: { iso1A2: "LA", iso1A3: "LAO", iso1N3: "418", wikidata: "Q819", nameEn: "Laos", groups: ["035", "142", "UN"], callingCodes: ["856"] }, geometry: { type: "MultiPolygon", coordinates: [[[[102.1245, 22.43372], [102.03633, 22.46164], [101.98487, 22.42766], [101.91344, 22.44417], [101.90714, 22.38688], [101.86828, 22.38397], [101.7685, 22.50337], [101.68973, 22.46843], [101.61306, 22.27515], [101.56789, 22.28876], [101.53638, 22.24794], [101.60675, 22.13513], [101.57525, 22.13026], [101.62566, 21.96574], [101.7791, 21.83019], [101.74555, 21.72852], [101.83257, 21.61562], [101.80001, 21.57461], [101.7475, 21.5873], [101.7727, 21.51794], [101.74224, 21.48276], [101.74014, 21.30967], [101.84412, 21.25291], [101.83887, 21.20983], [101.76745, 21.21571], [101.79266, 21.19025], [101.7622, 21.14813], [101.70548, 21.14911], [101.66977, 21.20004], [101.60886, 21.17947], [101.59491, 21.18621], [101.6068, 21.23329], [101.54563, 21.25668], [101.29326, 21.17254], [101.2229, 21.23271], [101.26912, 21.36482], [101.19349, 21.41959], [101.2124, 21.56422], [101.15156, 21.56129], [101.16198, 21.52808], [101.00234, 21.39612], [100.80173, 21.2934], [100.72716, 21.31786], [100.63578, 21.05639], [100.55281, 21.02796], [100.50974, 20.88574], [100.64628, 20.88279], [100.60112, 20.8347], [100.51079, 20.82194], [100.36375, 20.82783], [100.1957, 20.68247], [100.08404, 20.36626], [100.09999, 20.31614], [100.09337, 20.26293], [100.11785, 20.24787], [100.1712, 20.24324], [100.16668, 20.2986], [100.22076, 20.31598], [100.25769, 20.3992], [100.33383, 20.4028], [100.37439, 20.35156], [100.41473, 20.25625], [100.44992, 20.23644], [100.4537, 20.19971], [100.47567, 20.19133], [100.51052, 20.14928], [100.55218, 20.17741], [100.58808, 20.15791], [100.5094, 19.87904], [100.398, 19.75047], [100.49604, 19.53504], [100.58219, 19.49164], [100.64606, 19.55884], [100.77231, 19.48324], [100.90302, 19.61901], [101.08928, 19.59748], [101.26545, 19.59242], [101.26991, 19.48324], [101.21347, 19.46223], [101.20604, 19.35296], [101.24911, 19.33334], [101.261, 19.12717], [101.35606, 19.04716], [101.25803, 18.89545], [101.22832, 18.73377], [101.27585, 18.68875], [101.06047, 18.43247], [101.18227, 18.34367], [101.15108, 18.25624], [101.19118, 18.2125], [101.1793, 18.0544], [101.02185, 17.87637], [100.96541, 17.57926], [101.15108, 17.47586], [101.44667, 17.7392], [101.72294, 17.92867], [101.78087, 18.07559], [101.88485, 18.02474], [102.11359, 18.21532], [102.45523, 17.97106], [102.59234, 17.96127], [102.60971, 17.95411], [102.61432, 17.92273], [102.5896, 17.84889], [102.59485, 17.83537], [102.68194, 17.80151], [102.69946, 17.81686], [102.67543, 17.84529], [102.68538, 17.86653], [102.75954, 17.89561], [102.79044, 17.93612], [102.81988, 17.94233], [102.86323, 17.97531], [102.95812, 18.0054], [102.9912, 17.9949], [103.01998, 17.97095], [103.0566, 18.00144], [103.07823, 18.03833], [103.07343, 18.12351], [103.1493, 18.17799], [103.14994, 18.23172], [103.17093, 18.2618], [103.29757, 18.30475], [103.23818, 18.34875], [103.24779, 18.37807], [103.30977, 18.4341], [103.41044, 18.4486], [103.47773, 18.42841], [103.60957, 18.40528], [103.699, 18.34125], [103.82449, 18.33979], [103.85642, 18.28666], [103.93916, 18.33914], [103.97725, 18.33631], [104.06533, 18.21656], [104.10927, 18.10826], [104.21776, 17.99335], [104.2757, 17.86139], [104.35432, 17.82871], [104.45404, 17.66788], [104.69867, 17.53038], [104.80061, 17.39367], [104.80716, 17.19025], [104.73712, 17.01404], [104.7373, 16.91125], [104.76442, 16.84752], [104.7397, 16.81005], [104.76099, 16.69302], [104.73349, 16.565], [104.88057, 16.37311], [105.00262, 16.25627], [105.06204, 16.09792], [105.42001, 16.00657], [105.38508, 15.987], [105.34115, 15.92737], [105.37959, 15.84074], [105.42285, 15.76971], [105.46573, 15.74742], [105.61756, 15.68792], [105.60446, 15.53301], [105.58191, 15.41031], [105.47635, 15.3796], [105.4692, 15.33709], [105.50662, 15.32054], [105.58043, 15.32724], [105.46661, 15.13132], [105.61162, 15.00037], [105.5121, 14.80802], [105.53864, 14.55731], [105.43783, 14.43865], [105.20894, 14.34967], [105.2759, 14.17496], [105.36775, 14.09948], [105.44869, 14.10703], [105.5561, 14.15684], [105.78338, 14.08438], [105.78182, 14.02247], [105.90791, 13.92881], [106.10405, 13.9137], [106.10094, 13.98471], [106.16632, 14.01794], [106.18656, 14.06324], [106.11962, 14.11307], [106.10872, 14.18401], [106.04801, 14.20363], [106.02311, 14.30623], [105.99509, 14.32734], [106.00131, 14.36957], [106.21302, 14.36203], [106.25194, 14.48415], [106.32355, 14.44043], [106.40916, 14.45249], [106.43874, 14.52032], [106.47766, 14.50977], [106.45898, 14.55045], [106.50723, 14.58963], [106.54148, 14.59565], [106.57106, 14.50525], [106.59908, 14.50977], [106.63333, 14.44194], [106.73762, 14.42687], [106.80767, 14.31226], [106.8497, 14.29416], [106.90574, 14.33639], [106.9649, 14.3198], [106.98825, 14.36806], [107.04585, 14.41782], [107.03962, 14.45099], [107.09722, 14.3937], [107.17038, 14.41782], [107.21241, 14.48716], [107.256, 14.48716], [107.26534, 14.54292], [107.29803, 14.58963], [107.3276, 14.58812], [107.37897, 14.54443], [107.44435, 14.52785], [107.47238, 14.61523], [107.54361, 14.69092], [107.51579, 14.79282], [107.59285, 14.87795], [107.48277, 14.93751], [107.46516, 15.00982], [107.61486, 15.0566], [107.61926, 15.13949], [107.58844, 15.20111], [107.62587, 15.2266], [107.60605, 15.37524], [107.62367, 15.42193], [107.53341, 15.40496], [107.50699, 15.48771], [107.3815, 15.49832], [107.34408, 15.62345], [107.27583, 15.62769], [107.27143, 15.71459], [107.21859, 15.74638], [107.21419, 15.83747], [107.34188, 15.89464], [107.39471, 15.88829], [107.46296, 16.01106], [107.44975, 16.08511], [107.33968, 16.05549], [107.25822, 16.13587], [107.14595, 16.17816], [107.15035, 16.26271], [107.09091, 16.3092], [107.02597, 16.31132], [106.97385, 16.30204], [106.96638, 16.34938], [106.88067, 16.43594], [106.88727, 16.52671], [106.84104, 16.55415], [106.74418, 16.41904], [106.65832, 16.47816], [106.66052, 16.56892], [106.61477, 16.60713], [106.58267, 16.6012], [106.59013, 16.62259], [106.55485, 16.68704], [106.55265, 16.86831], [106.52183, 16.87884], [106.51963, 16.92097], [106.54824, 16.92729], [106.55045, 17.0031], [106.50862, 16.9673], [106.43597, 17.01362], [106.31929, 17.20509], [106.29287, 17.3018], [106.24444, 17.24714], [106.18991, 17.28227], [106.09019, 17.36399], [105.85744, 17.63221], [105.76612, 17.67147], [105.60381, 17.89356], [105.64784, 17.96687], [105.46292, 18.22008], [105.38366, 18.15315], [105.15942, 18.38691], [105.10408, 18.43533], [105.1327, 18.58355], [105.19654, 18.64196], [105.12829, 18.70453], [104.64617, 18.85668], [104.5361, 18.97747], [103.87125, 19.31854], [104.06058, 19.43484], [104.10832, 19.51575], [104.05617, 19.61743], [104.06498, 19.66926], [104.23229, 19.70242], [104.41281, 19.70035], [104.53169, 19.61743], [104.64837, 19.62365], [104.68359, 19.72729], [104.8355, 19.80395], [104.8465, 19.91783], [104.9874, 20.09573], [104.91695, 20.15567], [104.86852, 20.14121], [104.61315, 20.24452], [104.62195, 20.36633], [104.72102, 20.40554], [104.66158, 20.47774], [104.47886, 20.37459], [104.40621, 20.3849], [104.38199, 20.47155], [104.63957, 20.6653], [104.27412, 20.91433], [104.11121, 20.96779], [103.98024, 20.91531], [103.82282, 20.8732], [103.73478, 20.6669], [103.68633, 20.66324], [103.45737, 20.82382], [103.38032, 20.79501], [103.21497, 20.89832], [103.12055, 20.89994], [103.03469, 21.05821], [102.97745, 21.05821], [102.89825, 21.24707], [102.80794, 21.25736], [102.88939, 21.3107], [102.94223, 21.46034], [102.86297, 21.4255], [102.98846, 21.58936], [102.97965, 21.74076], [102.86077, 21.71213], [102.85637, 21.84501], [102.81894, 21.83888], [102.82115, 21.73667], [102.74189, 21.66713], [102.67145, 21.65894], [102.62301, 21.91447], [102.49092, 21.99002], [102.51734, 22.02676], [102.18712, 22.30403], [102.14099, 22.40092], [102.1245, 22.43372]]]] } },
29125     { type: "Feature", properties: { iso1A2: "LB", iso1A3: "LBN", iso1N3: "422", wikidata: "Q822", nameEn: "Lebanon", aliases: ["RL"], groups: ["145", "142", "UN"], callingCodes: ["961"] }, geometry: { type: "MultiPolygon", coordinates: [[[[35.94816, 33.47886], [35.94465, 33.52774], [36.05723, 33.57904], [35.9341, 33.6596], [36.06778, 33.82927], [36.14517, 33.85118], [36.3967, 33.83365], [36.38263, 33.86579], [36.28589, 33.91981], [36.41078, 34.05253], [36.50576, 34.05982], [36.5128, 34.09916], [36.62537, 34.20251], [36.59195, 34.2316], [36.58667, 34.27667], [36.60778, 34.31009], [36.56556, 34.31881], [36.53039, 34.3798], [36.55853, 34.41609], [36.46179, 34.46541], [36.4442, 34.50165], [36.34745, 34.5002], [36.3369, 34.52629], [36.39846, 34.55672], [36.41429, 34.61175], [36.45299, 34.59438], [36.46003, 34.6378], [36.42941, 34.62505], [36.35384, 34.65447], [36.35135, 34.68516], [36.32399, 34.69334], [36.29165, 34.62991], [35.98718, 34.64977], [35.97386, 34.63322], [35.48515, 34.70851], [34.78515, 33.20368], [35.10645, 33.09318], [35.1924, 33.08743], [35.31429, 33.10515], [35.35223, 33.05617], [35.43059, 33.06659], [35.448, 33.09264], [35.50272, 33.09056], [35.50335, 33.114], [35.52573, 33.11921], [35.54228, 33.19865], [35.5362, 33.23196], [35.54808, 33.236], [35.54544, 33.25513], [35.55555, 33.25844], [35.56523, 33.28969], [35.58326, 33.28381], [35.58502, 33.26653], [35.62283, 33.24226], [35.62019, 33.27278], [35.77477, 33.33609], [35.81324, 33.36354], [35.82577, 33.40479], [35.88668, 33.43183], [35.94816, 33.47886]]]] } },
29126     { type: "Feature", properties: { iso1A2: "LC", iso1A3: "LCA", iso1N3: "662", wikidata: "Q760", nameEn: "St. Lucia", aliases: ["WL"], groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 758"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-59.95997, 14.20285], [-61.69315, 14.26451], [-59.94058, 12.34011], [-59.95997, 14.20285]]]] } },
29127     { type: "Feature", properties: { iso1A2: "LI", iso1A3: "LIE", iso1N3: "438", wikidata: "Q347", nameEn: "Liechtenstein", aliases: ["FL"], groups: ["155", "150", "UN"], callingCodes: ["423"] }, geometry: { type: "MultiPolygon", coordinates: [[[[9.60717, 47.06091], [9.61216, 47.07732], [9.63395, 47.08443], [9.62623, 47.14685], [9.56539, 47.17124], [9.58264, 47.20673], [9.56981, 47.21926], [9.55176, 47.22585], [9.56766, 47.24281], [9.53116, 47.27029], [9.52406, 47.24959], [9.50318, 47.22153], [9.4891, 47.19346], [9.48774, 47.17402], [9.51044, 47.13727], [9.52089, 47.10019], [9.51362, 47.08505], [9.47139, 47.06402], [9.47548, 47.05257], [9.54041, 47.06495], [9.55721, 47.04762], [9.60717, 47.06091]]]] } },
29128     { type: "Feature", properties: { iso1A2: "LK", iso1A3: "LKA", iso1N3: "144", wikidata: "Q854", nameEn: "Sri Lanka", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["94"] }, geometry: { type: "MultiPolygon", coordinates: [[[[76.59015, 5.591], [85.15017, 5.21497], [80.48418, 10.20786], [79.42124, 9.80115], [79.50447, 8.91876], [76.59015, 5.591]]]] } },
29129     { type: "Feature", properties: { iso1A2: "LR", iso1A3: "LBR", iso1N3: "430", wikidata: "Q1014", nameEn: "Liberia", groups: ["011", "202", "002", "UN"], callingCodes: ["231"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-8.47114, 7.55676], [-8.55874, 7.62525], [-8.55874, 7.70167], [-8.67814, 7.69428], [-8.72789, 7.51429], [-8.8448, 7.35149], [-8.85724, 7.26019], [-8.93435, 7.2824], [-9.09107, 7.1985], [-9.18311, 7.30461], [-9.20798, 7.38109], [-9.305, 7.42056], [-9.41943, 7.41809], [-9.48161, 7.37122], [-9.37465, 7.62032], [-9.35724, 7.74111], [-9.44928, 7.9284], [-9.41445, 8.02448], [-9.50898, 8.18455], [-9.47415, 8.35195], [-9.77763, 8.54633], [-10.05873, 8.42578], [-10.05375, 8.50697], [-10.14579, 8.52665], [-10.203, 8.47991], [-10.27575, 8.48711], [-10.30084, 8.30008], [-10.31635, 8.28554], [-10.29839, 8.21283], [-10.35227, 8.15223], [-10.45023, 8.15627], [-10.51554, 8.1393], [-10.57523, 8.04829], [-10.60492, 8.04072], [-10.60422, 7.7739], [-11.29417, 7.21576], [-11.4027, 6.97746], [-11.50429, 6.92704], [-12.15048, 6.15992], [-7.52774, 3.7105], [-7.53259, 4.35145], [-7.59349, 4.8909], [-7.53876, 4.94294], [-7.55369, 5.08667], [-7.48901, 5.14118], [-7.46165, 5.26256], [-7.36463, 5.32944], [-7.43428, 5.42355], [-7.37209, 5.61173], [-7.43926, 5.74787], [-7.43677, 5.84687], [-7.46165, 5.84934], [-7.48155, 5.80974], [-7.67309, 5.94337], [-7.70294, 5.90625], [-7.78254, 5.99037], [-7.79747, 6.07696], [-7.8497, 6.08932], [-7.83478, 6.20309], [-7.90692, 6.27728], [-8.00642, 6.31684], [-8.17557, 6.28222], [-8.3298, 6.36381], [-8.38453, 6.35887], [-8.45666, 6.49977], [-8.48652, 6.43797], [-8.59456, 6.50612], [-8.31736, 6.82837], [-8.29249, 7.1691], [-8.37458, 7.25794], [-8.41935, 7.51203], [-8.47114, 7.55676]]]] } },
29130     { type: "Feature", properties: { iso1A2: "LS", iso1A3: "LSO", iso1N3: "426", wikidata: "Q1013", nameEn: "Lesotho", groups: ["018", "202", "002", "UN"], driveSide: "left", callingCodes: ["266"] }, geometry: { type: "MultiPolygon", coordinates: [[[[29.33204, -29.45598], [29.44883, -29.3772], [29.40524, -29.21246], [28.68043, -28.58744], [28.65091, -28.57025], [28.40612, -28.6215], [28.30518, -28.69531], [28.2348, -28.69471], [28.1317, -28.7293], [28.02503, -28.85991], [27.98675, -28.8787], [27.9392, -28.84864], [27.88933, -28.88156], [27.8907, -28.91612], [27.75458, -28.89839], [27.55974, -29.18954], [27.5158, -29.2261], [27.54258, -29.25575], [27.48679, -29.29349], [27.45125, -29.29708], [27.47254, -29.31968], [27.4358, -29.33465], [27.33464, -29.48161], [27.01016, -29.65439], [27.09489, -29.72796], [27.22719, -30.00718], [27.29603, -30.05473], [27.32555, -30.14785], [27.40778, -30.14577], [27.37293, -30.19401], [27.36649, -30.27246], [27.38108, -30.33456], [27.45452, -30.32239], [27.56901, -30.42504], [27.56781, -30.44562], [27.62137, -30.50509], [27.6521, -30.51707], [27.67819, -30.53437], [27.69467, -30.55862], [27.74814, -30.60635], [28.12073, -30.68072], [28.2319, -30.28476], [28.399, -30.1592], [28.68627, -30.12885], [28.80222, -30.10579], [28.9338, -30.05072], [29.16548, -29.91706], [29.12553, -29.76266], [29.28545, -29.58456], [29.33204, -29.45598]]]] } },
29131     { type: "Feature", properties: { iso1A2: "LT", iso1A3: "LTU", iso1N3: "440", wikidata: "Q37", nameEn: "Lithuania", groups: ["EU", "154", "150", "UN"], callingCodes: ["370"] }, geometry: { type: "MultiPolygon", coordinates: [[[[24.89005, 56.46666], [24.83686, 56.41565], [24.70022, 56.40483], [24.57353, 56.31525], [24.58143, 56.29125], [24.42746, 56.26522], [24.32334, 56.30226], [24.13139, 56.24881], [24.02657, 56.3231], [23.75726, 56.37282], [23.49803, 56.34307], [23.40486, 56.37689], [23.31606, 56.3827], [23.17312, 56.36795], [23.09531, 56.30511], [22.96988, 56.41213], [22.83048, 56.367], [22.69354, 56.36284], [22.56441, 56.39305], [22.3361, 56.4016], [22.09728, 56.42851], [22.00548, 56.41508], [21.74558, 56.33181], [21.57888, 56.31406], [21.49736, 56.29106], [21.24644, 56.16917], [21.15016, 56.07818], [20.68447, 56.04073], [20.60454, 55.40986], [20.95181, 55.27994], [21.26425, 55.24456], [21.35465, 55.28427], [21.38446, 55.29348], [21.46766, 55.21115], [21.51095, 55.18507], [21.55605, 55.20311], [21.64954, 55.1791], [21.85521, 55.09493], [21.96505, 55.07353], [21.99543, 55.08691], [22.03984, 55.07888], [22.02582, 55.05078], [22.06087, 55.02935], [22.11697, 55.02131], [22.14267, 55.05345], [22.31562, 55.0655], [22.47688, 55.04408], [22.58907, 55.07085], [22.60075, 55.01863], [22.65451, 54.97037], [22.68723, 54.9811], [22.76422, 54.92521], [22.85083, 54.88711], [22.87317, 54.79492], [22.73631, 54.72952], [22.73397, 54.66604], [22.75467, 54.6483], [22.74225, 54.64339], [22.7522, 54.63525], [22.68021, 54.58486], [22.71293, 54.56454], [22.67788, 54.532], [22.70208, 54.45312], [22.7253, 54.41732], [22.79705, 54.36264], [22.83756, 54.40827], [23.00584, 54.38514], [22.99649, 54.35927], [23.05726, 54.34565], [23.04323, 54.31567], [23.104, 54.29794], [23.13905, 54.31567], [23.15526, 54.31076], [23.15938, 54.29894], [23.24656, 54.25701], [23.3494, 54.25155], [23.39525, 54.21672], [23.42418, 54.17911], [23.45223, 54.17775], [23.49196, 54.14764], [23.52702, 54.04622], [23.48261, 53.98855], [23.51284, 53.95052], [23.61677, 53.92691], [23.71726, 53.93379], [23.80543, 53.89558], [23.81309, 53.94205], [23.95098, 53.9613], [23.98837, 53.92554], [24.19638, 53.96405], [24.34128, 53.90076], [24.44411, 53.90076], [24.62275, 54.00217], [24.69652, 54.01901], [24.69185, 53.96543], [24.74279, 53.96663], [24.85311, 54.02862], [24.77131, 54.11091], [24.96894, 54.17589], [24.991, 54.14241], [25.0728, 54.13419], [25.19199, 54.219], [25.22705, 54.26271], [25.35559, 54.26544], [25.509, 54.30267], [25.56823, 54.25212], [25.51452, 54.17799], [25.54724, 54.14925], [25.64875, 54.1259], [25.71084, 54.16704], [25.78563, 54.15747], [25.78553, 54.23327], [25.68513, 54.31727], [25.55425, 54.31591], [25.5376, 54.33158], [25.63371, 54.42075], [25.62203, 54.4656], [25.64813, 54.48704], [25.68045, 54.5321], [25.75977, 54.57252], [25.74122, 54.80108], [25.89462, 54.93438], [25.99129, 54.95705], [26.05907, 54.94631], [26.13386, 54.98924], [26.20397, 54.99729], [26.26941, 55.08032], [26.23202, 55.10439], [26.30628, 55.12536], [26.35121, 55.1525], [26.46249, 55.12814], [26.51481, 55.16051], [26.54753, 55.14181], [26.69243, 55.16718], [26.68075, 55.19787], [26.72983, 55.21788], [26.73017, 55.24226], [26.835, 55.28182], [26.83266, 55.30444], [26.80929, 55.31642], [26.6714, 55.33902], [26.5709, 55.32572], [26.44937, 55.34832], [26.5522, 55.40277], [26.55094, 55.5093], [26.63167, 55.57887], [26.63231, 55.67968], [26.58248, 55.6754], [26.46661, 55.70375], [26.39561, 55.71156], [26.18509, 55.86813], [26.03815, 55.95884], [25.90047, 56.0013], [25.85893, 56.00188], [25.81773, 56.05444], [25.69246, 56.08892], [25.68588, 56.14725], [25.53621, 56.16663], [25.39751, 56.15707], [25.23099, 56.19147], [25.09325, 56.1878], [25.05762, 56.26742], [24.89005, 56.46666]]]] } },
29132     { type: "Feature", properties: { iso1A2: "LU", iso1A3: "LUX", iso1N3: "442", wikidata: "Q32", nameEn: "Luxembourg", groups: ["EU", "155", "150", "UN"], callingCodes: ["352"] }, geometry: { type: "MultiPolygon", coordinates: [[[[6.1379, 50.12964], [6.1137, 50.13668], [6.12028, 50.16374], [6.08577, 50.17246], [6.06406, 50.15344], [6.03093, 50.16362], [6.02488, 50.18283], [5.96453, 50.17259], [5.95929, 50.13295], [5.89488, 50.11476], [5.8857, 50.07824], [5.85474, 50.06342], [5.86904, 50.04614], [5.8551, 50.02683], [5.81866, 50.01286], [5.82331, 49.99662], [5.83968, 49.9892], [5.83467, 49.97823], [5.81163, 49.97142], [5.80833, 49.96451], [5.77291, 49.96056], [5.77314, 49.93646], [5.73621, 49.89796], [5.78415, 49.87922], [5.75269, 49.8711], [5.75861, 49.85631], [5.74567, 49.85368], [5.75884, 49.84811], [5.74953, 49.84709], [5.74975, 49.83933], [5.74076, 49.83823], [5.7404, 49.83452], [5.74844, 49.82435], [5.74364, 49.82058], [5.74953, 49.81428], [5.75409, 49.79239], [5.78871, 49.7962], [5.82245, 49.75048], [5.83149, 49.74729], [5.82562, 49.72395], [5.84193, 49.72161], [5.86503, 49.72739], [5.88677, 49.70951], [5.86527, 49.69291], [5.86175, 49.67862], [5.9069, 49.66377], [5.90164, 49.6511], [5.90599, 49.63853], [5.88552, 49.63507], [5.88393, 49.62802], [5.87609, 49.62047], [5.8762, 49.60898], [5.84826, 49.5969], [5.84971, 49.58674], [5.86986, 49.58756], [5.87256, 49.57539], [5.8424, 49.56082], [5.84692, 49.55663], [5.84143, 49.5533], [5.81838, 49.54777], [5.80871, 49.5425], [5.81664, 49.53775], [5.83648, 49.5425], [5.84466, 49.53027], [5.83467, 49.52717], [5.83389, 49.52152], [5.86571, 49.50015], [5.94128, 49.50034], [5.94224, 49.49608], [5.96876, 49.49053], [5.97693, 49.45513], [6.02648, 49.45451], [6.02743, 49.44845], [6.04176, 49.44801], [6.05553, 49.46663], [6.07887, 49.46399], [6.08373, 49.45594], [6.10072, 49.45268], [6.09845, 49.46351], [6.10325, 49.4707], [6.12346, 49.4735], [6.12814, 49.49365], [6.14321, 49.48796], [6.16115, 49.49297], [6.15366, 49.50226], [6.17386, 49.50934], [6.19543, 49.50536], [6.2409, 49.51408], [6.25029, 49.50609], [6.27875, 49.503], [6.28818, 49.48465], [6.3687, 49.4593], [6.36778, 49.46937], [6.36907, 49.48931], [6.36788, 49.50377], [6.35666, 49.52931], [6.38072, 49.55171], [6.38228, 49.55855], [6.35825, 49.57053], [6.36676, 49.57813], [6.38024, 49.57593], [6.38342, 49.5799], [6.37464, 49.58886], [6.385, 49.59946], [6.39822, 49.60081], [6.41861, 49.61723], [6.4413, 49.65722], [6.43768, 49.66021], [6.42726, 49.66078], [6.42937, 49.66857], [6.44654, 49.67799], [6.46048, 49.69092], [6.48014, 49.69767], [6.49785, 49.71118], [6.50647, 49.71353], [6.5042, 49.71808], [6.49694, 49.72205], [6.49535, 49.72645], [6.50261, 49.72718], [6.51397, 49.72058], [6.51805, 49.72425], [6.50193, 49.73291], [6.50174, 49.75292], [6.51646, 49.75961], [6.51828, 49.76855], [6.51056, 49.77515], [6.51669, 49.78336], [6.50534, 49.78952], [6.52169, 49.79787], [6.53122, 49.80666], [6.52121, 49.81338], [6.51215, 49.80124], [6.50647, 49.80916], [6.48718, 49.81267], [6.47111, 49.82263], [6.45425, 49.81164], [6.44131, 49.81443], [6.42905, 49.81091], [6.42521, 49.81591], [6.40022, 49.82029], [6.36576, 49.85032], [6.34267, 49.84974], [6.33585, 49.83785], [6.32098, 49.83728], [6.32303, 49.85133], [6.30963, 49.87021], [6.29692, 49.86685], [6.28874, 49.87592], [6.26146, 49.88203], [6.23496, 49.89972], [6.22926, 49.92096], [6.21882, 49.92403], [6.22608, 49.929], [6.22094, 49.94955], [6.19856, 49.95053], [6.19089, 49.96991], [6.18045, 49.96611], [6.18554, 49.95622], [6.17872, 49.9537], [6.16466, 49.97086], [6.1701, 49.98518], [6.14147, 49.99563], [6.14948, 50.00908], [6.13806, 50.01056], [6.1295, 50.01849], [6.13273, 50.02019], [6.13794, 50.01466], [6.14666, 50.02207], [6.13044, 50.02929], [6.13458, 50.04141], [6.11274, 50.05916], [6.12055, 50.09171], [6.1379, 50.12964]]]] } },
29133     { type: "Feature", properties: { iso1A2: "LV", iso1A3: "LVA", iso1N3: "428", wikidata: "Q211", nameEn: "Latvia", groups: ["EU", "154", "150", "UN"], callingCodes: ["371"] }, geometry: { type: "MultiPolygon", coordinates: [[[[27.34698, 57.52242], [26.90364, 57.62823], [26.54675, 57.51813], [26.46527, 57.56885], [26.29253, 57.59244], [26.1866, 57.6849], [26.2029, 57.7206], [26.08098, 57.76619], [26.0543, 57.76105], [26.03332, 57.7718], [26.02415, 57.76865], [26.02069, 57.77169], [26.0266, 57.77441], [26.027, 57.78158], [26.02456, 57.78342], [26.0324, 57.79037], [26.05949, 57.84744], [25.73499, 57.90193], [25.29581, 58.08288], [25.28237, 57.98539], [25.19484, 58.0831], [24.3579, 57.87471], [24.26221, 57.91787], [23.20055, 57.56697], [22.80496, 57.87798], [19.84909, 57.57876], [19.64795, 57.06466], [20.68447, 56.04073], [21.15016, 56.07818], [21.24644, 56.16917], [21.49736, 56.29106], [21.57888, 56.31406], [21.74558, 56.33181], [22.00548, 56.41508], [22.09728, 56.42851], [22.3361, 56.4016], [22.56441, 56.39305], [22.69354, 56.36284], [22.83048, 56.367], [22.96988, 56.41213], [23.09531, 56.30511], [23.17312, 56.36795], [23.31606, 56.3827], [23.40486, 56.37689], [23.49803, 56.34307], [23.75726, 56.37282], [24.02657, 56.3231], [24.13139, 56.24881], [24.32334, 56.30226], [24.42746, 56.26522], [24.58143, 56.29125], [24.57353, 56.31525], [24.70022, 56.40483], [24.83686, 56.41565], [24.89005, 56.46666], [25.05762, 56.26742], [25.09325, 56.1878], [25.23099, 56.19147], [25.39751, 56.15707], [25.53621, 56.16663], [25.68588, 56.14725], [25.69246, 56.08892], [25.81773, 56.05444], [25.85893, 56.00188], [25.90047, 56.0013], [26.03815, 55.95884], [26.18509, 55.86813], [26.39561, 55.71156], [26.46661, 55.70375], [26.58248, 55.6754], [26.63231, 55.67968], [26.64888, 55.70515], [26.71802, 55.70645], [26.76872, 55.67658], [26.87448, 55.7172], [26.97153, 55.8102], [27.1559, 55.85032], [27.27804, 55.78299], [27.3541, 55.8089], [27.61683, 55.78558], [27.63065, 55.89687], [27.97865, 56.11849], [28.15217, 56.16964], [28.23716, 56.27588], [28.16599, 56.37806], [28.19057, 56.44637], [28.10069, 56.524], [28.13526, 56.57989], [28.04768, 56.59004], [27.86101, 56.88204], [27.66511, 56.83921], [27.86101, 57.29402], [27.52453, 57.42826], [27.56832, 57.53728], [27.34698, 57.52242]]]] } },
29134     { type: "Feature", properties: { iso1A2: "LY", iso1A3: "LBY", iso1N3: "434", wikidata: "Q1016", nameEn: "Libya", groups: ["015", "002", "UN"], callingCodes: ["218"] }, geometry: { type: "MultiPolygon", coordinates: [[[[26.92891, 33.39516], [11.58941, 33.36891], [11.55852, 33.1409], [11.51549, 33.09826], [11.46037, 32.6307], [11.57828, 32.48013], [11.53898, 32.4138], [11.04234, 32.2145], [10.7315, 31.97235], [10.62788, 31.96629], [10.48497, 31.72956], [10.31364, 31.72648], [10.12239, 31.42098], [10.29516, 30.90337], [9.88152, 30.34074], [9.76848, 30.34366], [9.55544, 30.23971], [9.3876, 30.16738], [9.78136, 29.40961], [9.89569, 26.57696], [9.51696, 26.39148], [9.38834, 26.19288], [10.03146, 25.35635], [10.02432, 24.98124], [10.33159, 24.5465], [10.85323, 24.5595], [11.41061, 24.21456], [11.62498, 24.26669], [11.96886, 23.51735], [13.5631, 23.16574], [14.22918, 22.61719], [14.99751, 23.00539], [15.99566, 23.49639], [23.99539, 19.49944], [23.99715, 20.00038], [24.99794, 19.99661], [24.99885, 21.99535], [24.99968, 29.24574], [24.71117, 30.17441], [25.01077, 30.73861], [24.8458, 31.39877], [26.92891, 33.39516]]]] } },
29135     { type: "Feature", properties: { iso1A2: "MA", iso1A3: "MAR", iso1N3: "504", wikidata: "Q1028", nameEn: "Morocco", groups: ["015", "002", "UN"], callingCodes: ["212"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.27707, 35.35051], [-5.10878, 36.05227], [-7.2725, 35.73269], [-14.43883, 27.02969], [-17.27295, 21.93519], [-17.21511, 21.34226], [-17.02707, 21.34022], [-16.9978, 21.36239], [-16.44269, 21.39745], [-14.78487, 21.36587], [-14.47329, 21.63839], [-14.48112, 22.00886], [-14.1291, 22.41636], [-14.10361, 22.75501], [-13.75627, 23.77231], [-13.00628, 24.01923], [-12.92147, 24.39502], [-12.12281, 25.13682], [-12.06001, 26.04442], [-11.62052, 26.05229], [-11.38635, 26.611], [-11.23622, 26.72023], [-11.35695, 26.8505], [-10.68417, 26.90984], [-9.81998, 26.71379], [-9.56957, 26.90042], [-9.08698, 26.98639], [-8.71787, 26.9898], [-8.77527, 27.66663], [-8.66879, 27.6666], [-8.6715, 28.71194], [-7.61585, 29.36252], [-6.95824, 29.50924], [-6.78351, 29.44634], [-6.69965, 29.51623], [-5.75616, 29.61407], [-5.72121, 29.52322], [-5.58831, 29.48103], [-5.21671, 29.95253], [-4.6058, 30.28343], [-4.31774, 30.53229], [-3.64735, 30.67539], [-3.65418, 30.85566], [-3.54944, 31.0503], [-3.77103, 31.14984], [-3.77647, 31.31912], [-3.66386, 31.39202], [-3.66314, 31.6339], [-2.82784, 31.79459], [-2.93873, 32.06557], [-2.46166, 32.16603], [-1.22829, 32.07832], [-1.15735, 32.12096], [-1.24453, 32.1917], [-1.24998, 32.32993], [-0.9912, 32.52467], [-1.37794, 32.73628], [-1.54244, 32.95499], [-1.46249, 33.0499], [-1.67067, 33.27084], [-1.59508, 33.59929], [-1.73494, 33.71721], [-1.64666, 34.10405], [-1.78042, 34.39018], [-1.69788, 34.48056], [-1.84569, 34.61907], [-1.73707, 34.74226], [-1.97469, 34.886], [-1.97833, 34.93218], [-2.04734, 34.93218], [-2.21445, 35.04378], [-2.21248, 35.08532], [-2.27707, 35.35051]], [[-2.91909, 35.33927], [-2.92272, 35.27509], [-2.93893, 35.26737], [-2.95065, 35.26576], [-2.95431, 35.2728], [-2.96516, 35.27967], [-2.96826, 35.28296], [-2.96507, 35.28801], [-2.97035, 35.28852], [-2.96978, 35.29459], [-2.96648, 35.30475], [-2.96038, 35.31609], [-2.91909, 35.33927]], [[-3.90602, 35.21494], [-3.89343, 35.22728], [-3.88372, 35.20767], [-3.90602, 35.21494]], [[-4.30191, 35.17419], [-4.29436, 35.17149], [-4.30112, 35.17058], [-4.30191, 35.17419]], [[-2.40316, 35.16893], [-2.45965, 35.16527], [-2.43262, 35.20652], [-2.40316, 35.16893]], [[-5.38491, 35.92591], [-5.21179, 35.90091], [-5.34379, 35.8711], [-5.35844, 35.87375], [-5.37338, 35.88417], [-5.38491, 35.92591]]]] } },
29136     { type: "Feature", properties: { iso1A2: "MC", iso1A3: "MCO", iso1N3: "492", wikidata: "Q235", nameEn: "Monaco", groups: ["155", "150", "UN"], callingCodes: ["377"] }, geometry: { type: "MultiPolygon", coordinates: [[[[7.47823, 43.73341], [7.4379, 43.74963], [7.4389, 43.75151], [7.43708, 43.75197], [7.43624, 43.75014], [7.43013, 43.74895], [7.42809, 43.74396], [7.42443, 43.74087], [7.42299, 43.74176], [7.42062, 43.73977], [7.41233, 43.73439], [7.41298, 43.73311], [7.41291, 43.73168], [7.41113, 43.73156], [7.40903, 43.7296], [7.42422, 43.72209], [7.47823, 43.73341]]]] } },
29137     { type: "Feature", properties: { iso1A2: "MD", iso1A3: "MDA", iso1N3: "498", wikidata: "Q217", nameEn: "Moldova", groups: ["151", "150", "UN"], callingCodes: ["373"] }, geometry: { type: "MultiPolygon", coordinates: [[[[27.74422, 48.45926], [27.6658, 48.44034], [27.59027, 48.46311], [27.5889, 48.49224], [27.46942, 48.454], [27.44333, 48.41209], [27.37741, 48.41026], [27.37604, 48.44398], [27.32159, 48.4434], [27.27855, 48.37534], [27.13434, 48.37288], [27.08078, 48.43214], [27.0231, 48.42485], [27.03821, 48.37653], [26.93384, 48.36558], [26.85556, 48.41095], [26.71274, 48.40388], [26.82809, 48.31629], [26.79239, 48.29071], [26.6839, 48.35828], [26.62823, 48.25804], [26.81161, 48.25049], [26.87708, 48.19919], [26.94265, 48.1969], [26.98042, 48.15752], [26.96119, 48.13003], [27.04118, 48.12522], [27.02985, 48.09083], [27.15622, 47.98538], [27.1618, 47.92391], [27.29069, 47.73722], [27.25519, 47.71366], [27.32202, 47.64009], [27.3979, 47.59473], [27.47942, 47.48113], [27.55731, 47.46637], [27.60263, 47.32507], [27.68706, 47.28962], [27.73172, 47.29248], [27.81892, 47.1381], [28.09095, 46.97621], [28.12173, 46.82283], [28.24808, 46.64305], [28.22281, 46.50481], [28.25769, 46.43334], [28.18902, 46.35283], [28.19864, 46.31869], [28.10937, 46.22852], [28.13684, 46.18099], [28.08612, 46.01105], [28.13111, 45.92819], [28.16568, 45.6421], [28.08927, 45.6051], [28.18741, 45.47358], [28.21139, 45.46895], [28.30201, 45.54744], [28.41836, 45.51715], [28.43072, 45.48538], [28.51449, 45.49982], [28.49252, 45.56716], [28.54196, 45.58062], [28.51587, 45.6613], [28.47879, 45.66994], [28.52823, 45.73803], [28.70401, 45.78019], [28.69852, 45.81753], [28.78503, 45.83475], [28.74383, 45.96664], [28.98004, 46.00385], [29.00613, 46.04962], [28.94643, 46.09176], [29.06656, 46.19716], [28.94953, 46.25852], [28.98478, 46.31803], [29.004, 46.31495], [28.9306, 46.45699], [29.01241, 46.46177], [29.02409, 46.49582], [29.23547, 46.55435], [29.24886, 46.37912], [29.35357, 46.49505], [29.49914, 46.45889], [29.5939, 46.35472], [29.6763, 46.36041], [29.66359, 46.4215], [29.74496, 46.45605], [29.88329, 46.35851], [29.94114, 46.40114], [30.09103, 46.38694], [30.16794, 46.40967], [30.02511, 46.45132], [29.88916, 46.54302], [29.94409, 46.56002], [29.9743, 46.75325], [29.94522, 46.80055], [29.98814, 46.82358], [29.87405, 46.88199], [29.75458, 46.8604], [29.72986, 46.92234], [29.57056, 46.94766], [29.62137, 47.05069], [29.61038, 47.09932], [29.53044, 47.07851], [29.49732, 47.12878], [29.57696, 47.13581], [29.54996, 47.24962], [29.59665, 47.25521], [29.5733, 47.36508], [29.48678, 47.36043], [29.47854, 47.30366], [29.39889, 47.30179], [29.3261, 47.44664], [29.18603, 47.43387], [29.11743, 47.55001], [29.22414, 47.60012], [29.22242, 47.73607], [29.27255, 47.79953], [29.20663, 47.80367], [29.27804, 47.88893], [29.19839, 47.89261], [29.1723, 47.99013], [28.9306, 47.96255], [28.8414, 48.03392], [28.85232, 48.12506], [28.69896, 48.13106], [28.53921, 48.17453], [28.48428, 48.0737], [28.42454, 48.12047], [28.43701, 48.15832], [28.38712, 48.17567], [28.34009, 48.13147], [28.30609, 48.14018], [28.30586, 48.1597], [28.34912, 48.1787], [28.36996, 48.20543], [28.35519, 48.24957], [28.32508, 48.23384], [28.2856, 48.23202], [28.19314, 48.20749], [28.17666, 48.25963], [28.07504, 48.23494], [28.09873, 48.3124], [28.04527, 48.32661], [27.95883, 48.32368], [27.88391, 48.36699], [27.87533, 48.4037], [27.81902, 48.41874], [27.79225, 48.44244], [27.74422, 48.45926]]]] } },
29138     { type: "Feature", properties: { iso1A2: "ME", iso1A3: "MNE", iso1N3: "499", wikidata: "Q236", nameEn: "Montenegro", groups: ["039", "150", "UN"], callingCodes: ["382"] }, geometry: { type: "MultiPolygon", coordinates: [[[[19.22807, 43.5264], [19.15685, 43.53943], [19.13933, 43.5282], [19.04934, 43.50384], [19.01078, 43.55806], [18.91379, 43.50299], [18.95469, 43.49367], [18.96053, 43.45042], [19.01078, 43.43854], [19.04071, 43.397], [19.08673, 43.31453], [19.08206, 43.29668], [19.04233, 43.30008], [19.00844, 43.24988], [18.95001, 43.29327], [18.95819, 43.32899], [18.90911, 43.36383], [18.83912, 43.34795], [18.84794, 43.33735], [18.85342, 43.32426], [18.76538, 43.29838], [18.6976, 43.25243], [18.71747, 43.2286], [18.66605, 43.2056], [18.64735, 43.14766], [18.66254, 43.03928], [18.52232, 43.01451], [18.49076, 42.95553], [18.49661, 42.89306], [18.4935, 42.86433], [18.47633, 42.85829], [18.45921, 42.81682], [18.47324, 42.74992], [18.56789, 42.72074], [18.55221, 42.69045], [18.54603, 42.69171], [18.54841, 42.68328], [18.57373, 42.64429], [18.52232, 42.62279], [18.55504, 42.58409], [18.53751, 42.57376], [18.49778, 42.58409], [18.43735, 42.55921], [18.44307, 42.51077], [18.43588, 42.48556], [18.52152, 42.42302], [18.54128, 42.39171], [18.45131, 42.21682], [19.26406, 41.74971], [19.37597, 41.84849], [19.37451, 41.8842], [19.33812, 41.90669], [19.34601, 41.95675], [19.37691, 41.96977], [19.36867, 42.02564], [19.37548, 42.06835], [19.40687, 42.10024], [19.28623, 42.17745], [19.42, 42.33019], [19.42352, 42.36546], [19.4836, 42.40831], [19.65972, 42.62774], [19.73244, 42.66299], [19.77375, 42.58517], [19.74731, 42.57422], [19.76549, 42.50237], [19.82333, 42.46581], [19.9324, 42.51699], [20.00842, 42.5109], [20.01834, 42.54622], [20.07761, 42.55582], [20.0969, 42.65559], [20.02915, 42.71147], [20.02088, 42.74789], [20.04898, 42.77701], [20.2539, 42.76245], [20.27869, 42.81945], [20.35692, 42.8335], [20.34528, 42.90676], [20.16415, 42.97177], [20.14896, 42.99058], [20.12325, 42.96237], [20.05431, 42.99571], [20.04729, 43.02732], [19.98887, 43.0538], [19.96549, 43.11098], [19.92576, 43.08539], [19.79255, 43.11951], [19.76918, 43.16044], [19.64063, 43.19027], [19.62661, 43.2286], [19.54598, 43.25158], [19.52962, 43.31623], [19.48171, 43.32644], [19.44315, 43.38846], [19.22229, 43.47926], [19.22807, 43.5264]]]] } },
29139     { type: "Feature", properties: { iso1A2: "MF", iso1A3: "MAF", iso1N3: "663", wikidata: "Q126125", nameEn: "Saint-Martin", country: "FR", groups: ["Q3320166", "EU", "029", "003", "419", "019", "UN"], callingCodes: ["590"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-62.93924, 18.02904], [-62.62718, 18.26185], [-63.35989, 18.06012], [-63.33064, 17.9615], [-63.13502, 18.05445], [-63.11042, 18.05339], [-63.09686, 18.04608], [-63.07759, 18.04943], [-63.0579, 18.06614], [-63.04039, 18.05619], [-63.02323, 18.05757], [-62.93924, 18.02904]]]] } },
29140     { type: "Feature", properties: { iso1A2: "MG", iso1A3: "MDG", iso1N3: "450", wikidata: "Q1019", nameEn: "Madagascar", aliases: ["RM"], groups: ["014", "202", "002", "UN"], callingCodes: ["261"] }, geometry: { type: "MultiPolygon", coordinates: [[[[51.93891, -10.85085], [45.84651, -12.77177], [42.14681, -19.63341], [45.80092, -33.00974], [51.93891, -10.85085]]]] } },
29141     { type: "Feature", properties: { iso1A2: "MH", iso1A3: "MHL", iso1N3: "584", wikidata: "Q709", nameEn: "Marshall Islands", groups: ["057", "009", "UN"], roadSpeedUnit: "mph", callingCodes: ["692"] }, geometry: { type: "MultiPolygon", coordinates: [[[[169, 3.9], [173.53711, 5.70687], [169.29099, 15.77133], [159.04653, 10.59067], [169, 3.9]]]] } },
29142     { type: "Feature", properties: { iso1A2: "MK", iso1A3: "MKD", iso1N3: "807", wikidata: "Q221", nameEn: "North Macedonia", groups: ["039", "150", "UN"], callingCodes: ["389"] }, geometry: { type: "MultiPolygon", coordinates: [[[[22.34773, 42.31725], [22.29275, 42.34913], [22.29605, 42.37477], [22.16384, 42.32103], [22.02908, 42.29848], [21.94405, 42.34669], [21.91595, 42.30392], [21.84654, 42.3247], [21.77176, 42.2648], [21.70111, 42.23789], [21.58992, 42.25915], [21.52145, 42.24465], [21.50823, 42.27156], [21.43882, 42.2789], [21.43882, 42.23609], [21.38428, 42.24465], [21.30496, 42.1418], [21.29913, 42.13954], [21.31983, 42.10993], [21.22728, 42.08909], [21.16614, 42.19815], [21.11491, 42.20794], [20.75464, 42.05229], [20.76786, 41.91839], [20.68523, 41.85318], [20.59524, 41.8818], [20.55976, 41.87068], [20.57144, 41.7897], [20.53405, 41.78099], [20.51301, 41.72433], [20.52937, 41.69292], [20.51769, 41.65975], [20.55508, 41.58113], [20.52103, 41.56473], [20.45809, 41.5549], [20.45331, 41.51436], [20.49039, 41.49277], [20.51301, 41.442], [20.55976, 41.4087], [20.52119, 41.34381], [20.49432, 41.33679], [20.51068, 41.2323], [20.59715, 41.13644], [20.58546, 41.11179], [20.59832, 41.09066], [20.63454, 41.0889], [20.65558, 41.08009], [20.71634, 40.91781], [20.73504, 40.9081], [20.81567, 40.89662], [20.83671, 40.92752], [20.94305, 40.92399], [20.97693, 40.90103], [20.97887, 40.85475], [21.15262, 40.85546], [21.21105, 40.8855], [21.25779, 40.86165], [21.35595, 40.87578], [21.41555, 40.9173], [21.53007, 40.90759], [21.57448, 40.86076], [21.69601, 40.9429], [21.7556, 40.92525], [21.91102, 41.04786], [21.90869, 41.09191], [22.06527, 41.15617], [22.1424, 41.12449], [22.17629, 41.15969], [22.26744, 41.16409], [22.42285, 41.11921], [22.5549, 41.13065], [22.58295, 41.11568], [22.62852, 41.14385], [22.65306, 41.18168], [22.71266, 41.13945], [22.74538, 41.16321], [22.76408, 41.32225], [22.81199, 41.3398], [22.93334, 41.34104], [22.96331, 41.35782], [22.95513, 41.63265], [23.03342, 41.71034], [23.01239, 41.76527], [22.96682, 41.77137], [22.90254, 41.87587], [22.86749, 42.02275], [22.67701, 42.06614], [22.51224, 42.15457], [22.50289, 42.19527], [22.47251, 42.20393], [22.38136, 42.30339], [22.34773, 42.31725]]]] } },
29143     { type: "Feature", properties: { iso1A2: "ML", iso1A3: "MLI", iso1N3: "466", wikidata: "Q912", nameEn: "Mali", groups: ["011", "202", "002", "UN"], callingCodes: ["223"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-4.83423, 24.99935], [-6.57191, 25.0002], [-5.60725, 16.49919], [-5.33435, 16.33354], [-5.50165, 15.50061], [-9.32979, 15.50032], [-9.31106, 15.69412], [-9.33314, 15.7044], [-9.44673, 15.60553], [-9.40447, 15.4396], [-10.71721, 15.4223], [-10.90932, 15.11001], [-11.43483, 15.62339], [-11.70705, 15.51558], [-11.94903, 14.76143], [-12.23936, 14.76324], [-11.93043, 13.84505], [-12.06897, 13.71049], [-11.83345, 13.33333], [-11.63025, 13.39174], [-11.39935, 12.97808], [-11.37536, 12.40788], [-11.50006, 12.17826], [-11.24136, 12.01286], [-10.99758, 12.24634], [-10.80355, 12.1053], [-10.71897, 11.91552], [-10.30604, 12.24634], [-9.714, 12.0226], [-9.63938, 12.18312], [-9.32097, 12.29009], [-9.38067, 12.48446], [-9.13689, 12.50875], [-8.94784, 12.34842], [-8.80854, 11.66715], [-8.40058, 11.37466], [-8.66923, 10.99397], [-8.35083, 11.06234], [-8.2667, 10.91762], [-8.32614, 10.69273], [-8.22711, 10.41722], [-8.10207, 10.44649], [-7.9578, 10.2703], [-7.97971, 10.17117], [-7.92107, 10.15577], [-7.63048, 10.46334], [-7.54462, 10.40921], [-7.52261, 10.4655], [-7.44555, 10.44602], [-7.3707, 10.24677], [-7.13331, 10.24877], [-7.0603, 10.14711], [-7.00966, 10.15794], [-6.97444, 10.21644], [-7.01186, 10.25111], [-6.93921, 10.35291], [-6.68164, 10.35074], [-6.63541, 10.66893], [-6.52974, 10.59104], [-6.42847, 10.5694], [-6.40646, 10.69922], [-6.325, 10.68624], [-6.24795, 10.74248], [-6.1731, 10.46983], [-6.18851, 10.24244], [-5.99478, 10.19694], [-5.78124, 10.43952], [-5.65135, 10.46767], [-5.51058, 10.43177], [-5.46643, 10.56074], [-5.47083, 10.75329], [-5.41579, 10.84628], [-5.49284, 11.07538], [-5.32994, 11.13371], [-5.32553, 11.21578], [-5.25949, 11.24816], [-5.25509, 11.36905], [-5.20665, 11.43811], [-5.22867, 11.60421], [-5.29251, 11.61715], [-5.26389, 11.75728], [-5.40258, 11.8327], [-5.26389, 11.84778], [-5.07897, 11.97918], [-4.72893, 12.01579], [-4.70692, 12.06746], [-4.62987, 12.06531], [-4.62546, 12.13204], [-4.54841, 12.1385], [-4.57703, 12.19875], [-4.41412, 12.31922], [-4.47356, 12.71252], [-4.238, 12.71467], [-4.21819, 12.95722], [-4.34477, 13.12927], [-3.96501, 13.49778], [-3.90558, 13.44375], [-3.96282, 13.38164], [-3.7911, 13.36665], [-3.54454, 13.1781], [-3.4313, 13.1588], [-3.43507, 13.27272], [-3.23599, 13.29035], [-3.28396, 13.5422], [-3.26407, 13.70699], [-2.88189, 13.64921], [-2.90831, 13.81174], [-2.84667, 14.05532], [-2.66175, 14.14713], [-2.47587, 14.29671], [-2.10223, 14.14878], [-1.9992, 14.19011], [-1.97945, 14.47709], [-1.68083, 14.50023], [-1.32166, 14.72774], [-1.05875, 14.7921], [-0.72004, 15.08655], [-0.24673, 15.07805], [0.06588, 14.96961], [0.23859, 15.00135], [0.72632, 14.95898], [0.96711, 14.98275], [1.31275, 15.27978], [3.01806, 15.34571], [3.03134, 15.42221], [3.50368, 15.35934], [4.19893, 16.39923], [4.21787, 17.00118], [4.26762, 17.00432], [4.26651, 19.14224], [3.36082, 18.9745], [3.12501, 19.1366], [3.24648, 19.81703], [1.20992, 20.73533], [1.15698, 21.12843], [-4.83423, 24.99935]]]] } },
29144     { type: "Feature", properties: { iso1A2: "MM", iso1A3: "MMR", iso1N3: "104", wikidata: "Q836", nameEn: "Myanmar", aliases: ["Burma", "BU"], groups: ["035", "142", "UN"], callingCodes: ["95"] }, geometry: { type: "MultiPolygon", coordinates: [[[[92.62187, 21.87037], [92.59775, 21.6092], [92.68152, 21.28454], [92.60187, 21.24615], [92.55105, 21.3856], [92.43158, 21.37025], [92.37939, 21.47764], [92.20087, 21.337], [92.17752, 21.17445], [92.26071, 21.05697], [92.47409, 20.38654], [92.61042, 13.76986], [94.6371, 13.81803], [97.63455, 9.60854], [98.12555, 9.44056], [98.33094, 9.91973], [98.47298, 9.95782], [98.52291, 9.92389], [98.55174, 9.92804], [98.7391, 10.31488], [98.81944, 10.52761], [98.77275, 10.62548], [98.78511, 10.68351], [98.86819, 10.78336], [99.0069, 10.85485], [98.99701, 10.92962], [99.02337, 10.97217], [99.06938, 10.94857], [99.32756, 11.28545], [99.31573, 11.32081], [99.39485, 11.3925], [99.47598, 11.62434], [99.5672, 11.62732], [99.64108, 11.78948], [99.64891, 11.82699], [99.53424, 12.02317], [99.56445, 12.14805], [99.47519, 12.1353], [99.409, 12.60603], [99.29254, 12.68921], [99.18905, 12.84799], [99.18748, 12.9898], [99.10646, 13.05804], [99.12225, 13.19847], [99.20617, 13.20575], [99.16695, 13.72621], [98.97356, 14.04868], [98.56762, 14.37701], [98.24874, 14.83013], [98.18821, 15.13125], [98.22, 15.21327], [98.30446, 15.30667], [98.40522, 15.25268], [98.41906, 15.27103], [98.39351, 15.34177], [98.4866, 15.39154], [98.56027, 15.33471], [98.58598, 15.46821], [98.541, 15.65406], [98.59853, 15.87197], [98.57019, 16.04578], [98.69585, 16.13353], [98.8376, 16.11706], [98.92656, 16.36425], [98.84485, 16.42354], [98.68074, 16.27068], [98.63817, 16.47424], [98.57912, 16.55983], [98.5695, 16.62826], [98.51113, 16.64503], [98.51833, 16.676], [98.51472, 16.68521], [98.51579, 16.69433], [98.51043, 16.70107], [98.49713, 16.69022], [98.50253, 16.7139], [98.46994, 16.73613], [98.53833, 16.81934], [98.49603, 16.8446], [98.52624, 16.89979], [98.39441, 17.06266], [98.34566, 17.04822], [98.10439, 17.33847], [98.11185, 17.36829], [97.91829, 17.54504], [97.76407, 17.71595], [97.66794, 17.88005], [97.73723, 17.97912], [97.60841, 18.23846], [97.64116, 18.29778], [97.56219, 18.33885], [97.50383, 18.26844], [97.34522, 18.54596], [97.36444, 18.57138], [97.5258, 18.4939], [97.76752, 18.58097], [97.73836, 18.88478], [97.66487, 18.9371], [97.73654, 18.9812], [97.73797, 19.04261], [97.83479, 19.09972], [97.84024, 19.22217], [97.78606, 19.26769], [97.84186, 19.29526], [97.78769, 19.39429], [97.88423, 19.5041], [97.84715, 19.55782], [98.04364, 19.65755], [98.03314, 19.80941], [98.13829, 19.78541], [98.24884, 19.67876], [98.51182, 19.71303], [98.56065, 19.67807], [98.83661, 19.80931], [98.98679, 19.7419], [99.0735, 20.10298], [99.20328, 20.12877], [99.416, 20.08614], [99.52943, 20.14811], [99.5569, 20.20676], [99.46077, 20.36198], [99.46008, 20.39673], [99.68255, 20.32077], [99.81096, 20.33687], [99.86383, 20.44371], [99.88211, 20.44488], [99.88451, 20.44596], [99.89168, 20.44548], [99.89301, 20.44311], [99.89692, 20.44789], [99.90499, 20.4487], [99.91616, 20.44986], [99.95721, 20.46301], [100.08404, 20.36626], [100.1957, 20.68247], [100.36375, 20.82783], [100.51079, 20.82194], [100.60112, 20.8347], [100.64628, 20.88279], [100.50974, 20.88574], [100.55281, 21.02796], [100.63578, 21.05639], [100.72716, 21.31786], [100.80173, 21.2934], [101.00234, 21.39612], [101.16198, 21.52808], [101.15156, 21.56129], [101.11744, 21.77659], [100.87265, 21.67396], [100.72143, 21.51898], [100.57861, 21.45637], [100.4811, 21.46148], [100.42892, 21.54325], [100.35201, 21.53176], [100.25863, 21.47043], [100.18447, 21.51898], [100.1625, 21.48704], [100.12542, 21.50365], [100.10757, 21.59945], [100.17486, 21.65306], [100.12679, 21.70539], [100.04956, 21.66843], [99.98654, 21.71064], [99.94003, 21.82782], [99.99084, 21.97053], [99.96612, 22.05965], [99.85351, 22.04183], [99.47585, 22.13345], [99.33166, 22.09656], [99.1552, 22.15874], [99.19176, 22.16983], [99.17318, 22.18025], [99.28771, 22.4105], [99.37972, 22.50188], [99.38247, 22.57544], [99.31243, 22.73893], [99.45654, 22.85726], [99.43537, 22.94086], [99.54218, 22.90014], [99.52214, 23.08218], [99.34127, 23.13099], [99.25741, 23.09025], [99.04601, 23.12215], [99.05975, 23.16382], [98.88597, 23.18656], [98.92515, 23.29535], [98.93958, 23.31414], [98.87573, 23.33038], [98.92104, 23.36946], [98.87683, 23.48995], [98.82877, 23.47908], [98.80294, 23.5345], [98.88396, 23.59555], [98.81775, 23.694], [98.82933, 23.72921], [98.79607, 23.77947], [98.68209, 23.80492], [98.67797, 23.9644], [98.89632, 24.10612], [98.87998, 24.15624], [98.85319, 24.13042], [98.59256, 24.08371], [98.54476, 24.13119], [98.20666, 24.11406], [98.07806, 24.07988], [98.06703, 24.08028], [98.0607, 24.07812], [98.05671, 24.07961], [98.05302, 24.07408], [98.04709, 24.07616], [97.99583, 24.04932], [97.98691, 24.03897], [97.93951, 24.01953], [97.90998, 24.02094], [97.88616, 24.00463], [97.88414, 23.99405], [97.88814, 23.98605], [97.89683, 23.98389], [97.89676, 23.97931], [97.8955, 23.97758], [97.88811, 23.97446], [97.86545, 23.97723], [97.84328, 23.97603], [97.79416, 23.95663], [97.79456, 23.94836], [97.72302, 23.89288], [97.64667, 23.84574], [97.5247, 23.94032], [97.62363, 24.00506], [97.72903, 24.12606], [97.75305, 24.16902], [97.72799, 24.18883], [97.72998, 24.2302], [97.76799, 24.26365], [97.71941, 24.29652], [97.66723, 24.30027], [97.65624, 24.33781], [97.7098, 24.35658], [97.66998, 24.45288], [97.60029, 24.4401], [97.52757, 24.43748], [97.56286, 24.54535], [97.56525, 24.72838], [97.54675, 24.74202], [97.5542, 24.74943], [97.56383, 24.75535], [97.56648, 24.76475], [97.64354, 24.79171], [97.70181, 24.84557], [97.73127, 24.83015], [97.76481, 24.8289], [97.79949, 24.85655], [97.72903, 24.91332], [97.72216, 25.08508], [97.77023, 25.11492], [97.83614, 25.2715], [97.92541, 25.20815], [98.14925, 25.41547], [98.12591, 25.50722], [98.18084, 25.56298], [98.16848, 25.62739], [98.25774, 25.6051], [98.31268, 25.55307], [98.40606, 25.61129], [98.54064, 25.85129], [98.63128, 25.79937], [98.70818, 25.86241], [98.60763, 26.01512], [98.57085, 26.11547], [98.63128, 26.15492], [98.66884, 26.09165], [98.7329, 26.17218], [98.67797, 26.24487], [98.72741, 26.36183], [98.77547, 26.61994], [98.7333, 26.85615], [98.69582, 27.56499], [98.43353, 27.67086], [98.42529, 27.55404], [98.32641, 27.51385], [98.13964, 27.9478], [98.15337, 28.12114], [97.90069, 28.3776], [97.79632, 28.33168], [97.70705, 28.5056], [97.56835, 28.55628], [97.50518, 28.49716], [97.47085, 28.2688], [97.41729, 28.29783], [97.34547, 28.21385], [97.31292, 28.06784], [97.35412, 28.06663], [97.38845, 28.01329], [97.35824, 27.87256], [97.29919, 27.92233], [96.90112, 27.62149], [96.91431, 27.45752], [97.17422, 27.14052], [97.14675, 27.09041], [96.89132, 27.17474], [96.85287, 27.2065], [96.88445, 27.25046], [96.73888, 27.36638], [96.55761, 27.29928], [96.40779, 27.29818], [96.15591, 27.24572], [96.04949, 27.19428], [95.93002, 27.04149], [95.81603, 27.01335], [95.437, 26.7083], [95.30339, 26.65372], [95.23513, 26.68499], [95.05798, 26.45408], [95.12801, 26.38397], [95.11428, 26.1019], [95.18556, 26.07338], [94.80117, 25.49359], [94.68032, 25.47003], [94.57458, 25.20318], [94.74212, 25.13606], [94.73937, 25.00545], [94.60204, 24.70889], [94.5526, 24.70764], [94.50729, 24.59281], [94.45279, 24.56656], [94.32362, 24.27692], [94.30215, 24.23752], [94.14081, 23.83333], [93.92089, 23.95812], [93.80279, 23.92549], [93.75952, 24.0003], [93.62871, 24.00922], [93.50616, 23.94432], [93.46633, 23.97067], [93.41415, 24.07854], [93.34735, 24.10151], [93.32351, 24.04468], [93.36059, 23.93176], [93.3908, 23.92925], [93.3908, 23.7622], [93.43475, 23.68299], [93.38805, 23.4728], [93.39981, 23.38828], [93.38781, 23.36139], [93.36862, 23.35426], [93.38478, 23.13698], [93.2878, 23.00464], [93.12988, 23.05772], [93.134, 22.92498], [93.09417, 22.69459], [93.134, 22.59573], [93.11477, 22.54374], [93.13537, 22.45873], [93.18206, 22.43716], [93.19991, 22.25425], [93.14224, 22.24535], [93.15734, 22.18687], [93.04885, 22.20595], [92.99255, 22.05965], [92.99804, 21.98964], [92.93899, 22.02656], [92.89504, 21.95143], [92.86208, 22.05456], [92.70416, 22.16017], [92.67532, 22.03547], [92.60949, 21.97638], [92.62187, 21.87037]]]] } },
29145     { type: "Feature", properties: { iso1A2: "MN", iso1A3: "MNG", iso1N3: "496", wikidata: "Q711", nameEn: "Mongolia", groups: ["030", "142", "UN"], callingCodes: ["976"] }, geometry: { type: "MultiPolygon", coordinates: [[[[102.14032, 51.35566], [101.5044, 51.50467], [101.39085, 51.45753], [100.61116, 51.73028], [99.89203, 51.74903], [99.75578, 51.90108], [99.27888, 51.96876], [98.87768, 52.14563], [98.74142, 51.8637], [98.33222, 51.71832], [98.22053, 51.46579], [98.05257, 51.46696], [97.83305, 51.00248], [98.01472, 50.86652], [97.9693, 50.78044], [98.06393, 50.61262], [98.31373, 50.4996], [98.29481, 50.33561], [97.85197, 49.91339], [97.76871, 49.99861], [97.56432, 49.92801], [97.56811, 49.84265], [97.24639, 49.74737], [96.97388, 49.88413], [95.80056, 50.04239], [95.74757, 49.97915], [95.02465, 49.96941], [94.97166, 50.04725], [94.6121, 50.04239], [94.49477, 50.17832], [94.39258, 50.22193], [94.30823, 50.57498], [92.99595, 50.63183], [93.01109, 50.79001], [92.44714, 50.78762], [92.07173, 50.69585], [91.86048, 50.73734], [89.59711, 49.90851], [89.70687, 49.72535], [88.82499, 49.44808], [88.42449, 49.48821], [88.17223, 49.46934], [88.15543, 49.30314], [87.98977, 49.18147], [87.81333, 49.17354], [87.88171, 48.95853], [87.73822, 48.89582], [88.0788, 48.71436], [87.96361, 48.58478], [88.58939, 48.34531], [88.58316, 48.21893], [88.8011, 48.11302], [88.93186, 48.10263], [89.0711, 47.98528], [89.55453, 48.0423], [89.76624, 47.82745], [90.06512, 47.88177], [90.10871, 47.7375], [90.33598, 47.68303], [90.48854, 47.41826], [90.48542, 47.30438], [90.76108, 46.99399], [90.84035, 46.99525], [91.03649, 46.72916], [91.0147, 46.58171], [91.07696, 46.57315], [90.89639, 46.30711], [90.99672, 46.14207], [91.03026, 46.04194], [90.70907, 45.73437], [90.65114, 45.49314], [90.89169, 45.19667], [91.64048, 45.07408], [93.51161, 44.95964], [94.10003, 44.71016], [94.71959, 44.35284], [95.01191, 44.25274], [95.39772, 44.2805], [95.32891, 44.02407], [95.52594, 43.99353], [95.89543, 43.2528], [96.35658, 42.90363], [96.37926, 42.72055], [97.1777, 42.7964], [99.50671, 42.56535], [100.33297, 42.68231], [100.84979, 42.67087], [101.80515, 42.50074], [102.07645, 42.22519], [102.72403, 42.14675], [103.92804, 41.78246], [104.52258, 41.8706], [104.51667, 41.66113], [105.0123, 41.63188], [106.76517, 42.28741], [107.24774, 42.36107], [107.29755, 42.41395], [107.49681, 42.46221], [107.57258, 42.40898], [108.84489, 42.40246], [109.00679, 42.45302], [109.452, 42.44842], [109.89402, 42.63111], [110.08401, 42.6411], [110.4327, 42.78293], [111.0149, 43.3289], [111.59087, 43.51207], [111.79758, 43.6637], [111.93776, 43.68709], [111.96289, 43.81596], [111.40498, 44.3461], [111.76275, 44.98032], [111.98695, 45.09074], [112.4164, 45.06858], [112.74662, 44.86297], [113.70918, 44.72891], [114.5166, 45.27189], [114.54801, 45.38337], [114.74612, 45.43585], [114.94546, 45.37377], [115.60329, 45.44717], [116.16989, 45.68603], [116.27366, 45.78637], [116.24012, 45.8778], [116.26678, 45.96479], [116.58612, 46.30211], [116.75551, 46.33083], [116.83166, 46.38637], [117.36609, 46.36335], [117.41782, 46.57862], [117.60748, 46.59771], [117.69554, 46.50991], [118.30534, 46.73519], [118.78747, 46.68689], [118.8337, 46.77742], [118.89974, 46.77139], [118.92616, 46.72765], [119.00541, 46.74273], [119.10448, 46.65516], [119.24978, 46.64761], [119.32827, 46.61433], [119.42827, 46.63783], [119.65265, 46.62342], [119.68127, 46.59015], [119.77373, 46.62947], [119.80455, 46.67631], [119.89261, 46.66423], [119.91242, 46.90091], [119.85518, 46.92196], [119.71209, 47.19192], [119.62403, 47.24575], [119.56019, 47.24874], [119.54918, 47.29505], [119.31964, 47.42617], [119.35892, 47.48104], [119.13995, 47.53997], [119.12343, 47.66458], [118.7564, 47.76947], [118.55766, 47.99277], [118.29654, 48.00246], [118.22677, 48.03853], [118.11009, 48.04], [118.03676, 48.00982], [117.80196, 48.01661], [117.50181, 47.77216], [117.37875, 47.63627], [116.9723, 47.87285], [116.67405, 47.89039], [116.4465, 47.83662], [116.21879, 47.88505], [115.94296, 47.67741], [115.57128, 47.91988], [115.52082, 48.15367], [115.811, 48.25699], [115.78876, 48.51781], [116.06565, 48.81716], [116.03781, 48.87014], [116.71193, 49.83813], [116.62502, 49.92919], [116.22402, 50.04477], [115.73602, 49.87688], [115.26068, 49.97367], [114.9703, 50.19254], [114.325, 50.28098], [113.20216, 49.83356], [113.02647, 49.60772], [110.64493, 49.1816], [110.39891, 49.25083], [110.24373, 49.16676], [109.51325, 49.22859], [109.18017, 49.34709], [108.53969, 49.32325], [108.27937, 49.53167], [107.95387, 49.66659], [107.96116, 49.93191], [107.36407, 49.97612], [107.1174, 50.04239], [107.00007, 50.1977], [106.80326, 50.30177], [106.58373, 50.34044], [106.51122, 50.34408], [106.49628, 50.32436], [106.47156, 50.31909], [106.07865, 50.33474], [106.05562, 50.40582], [105.32528, 50.4648], [103.70343, 50.13952], [102.71178, 50.38873], [102.32194, 50.67982], [102.14032, 51.35566]]]] } },
29146     { type: "Feature", properties: { iso1A2: "MO", iso1A3: "MAC", iso1N3: "446", wikidata: "Q14773", nameEn: "Macau", aliases: ["Macao"], country: "CN", groups: ["030", "142", "UN"], driveSide: "left", callingCodes: ["853"] }, geometry: { type: "MultiPolygon", coordinates: [[[[113.54942, 22.14519], [113.54839, 22.10909], [113.57191, 22.07696], [113.63011, 22.10782], [113.60504, 22.20464], [113.57123, 22.20416], [113.56865, 22.20973], [113.5508, 22.21672], [113.54333, 22.21688], [113.54093, 22.21314], [113.53593, 22.2137], [113.53301, 22.21235], [113.53552, 22.20607], [113.52659, 22.18271], [113.54093, 22.15497], [113.54942, 22.14519]]]] } },
29147     { type: "Feature", properties: { iso1A2: "MP", iso1A3: "MNP", iso1N3: "580", wikidata: "Q16644", nameEn: "Northern Mariana Islands", aliases: ["US-MP"], country: "US", groups: ["Q1352230", "Q153732", "057", "009", "UN"], roadSpeedUnit: "mph", callingCodes: ["1 670"] }, geometry: { type: "MultiPolygon", coordinates: [[[[135.52896, 14.32623], [152.19114, 13.63487], [145.05972, 21.28731], [135.52896, 14.32623]]]] } },
29148     { type: "Feature", properties: { iso1A2: "MQ", iso1A3: "MTQ", iso1N3: "474", wikidata: "Q17054", nameEn: "Martinique", country: "FR", groups: ["Q3320166", "EU", "029", "003", "419", "019", "UN"], callingCodes: ["596"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-59.95997, 14.20285], [-61.07821, 15.25109], [-61.69315, 14.26451], [-59.95997, 14.20285]]]] } },
29149     { type: "Feature", properties: { iso1A2: "MR", iso1A3: "MRT", iso1N3: "478", wikidata: "Q1025", nameEn: "Mauritania", groups: ["011", "202", "002", "UN"], callingCodes: ["222"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-5.60725, 16.49919], [-6.57191, 25.0002], [-4.83423, 24.99935], [-8.66674, 27.31569], [-8.66721, 25.99918], [-12.0002, 25.9986], [-12.00251, 23.4538], [-12.14969, 23.41935], [-12.36213, 23.3187], [-12.5741, 23.28975], [-13.00412, 23.02297], [-13.10753, 22.89493], [-13.15313, 22.75649], [-13.08438, 22.53866], [-13.01525, 21.33343], [-16.95474, 21.33997], [-16.99806, 21.12142], [-17.0357, 21.05368], [-17.0396, 20.9961], [-17.06781, 20.92697], [-17.0695, 20.85742], [-17.0471, 20.76408], [-17.15288, 16.07139], [-16.50854, 16.09032], [-16.48967, 16.0496], [-16.44814, 16.09753], [-16.4429, 16.20605], [-16.27016, 16.51565], [-15.6509, 16.50315], [-15.00557, 16.64997], [-14.32144, 16.61495], [-13.80075, 16.13961], [-13.43135, 16.09022], [-13.11029, 15.52116], [-12.23936, 14.76324], [-11.94903, 14.76143], [-11.70705, 15.51558], [-11.43483, 15.62339], [-10.90932, 15.11001], [-10.71721, 15.4223], [-9.40447, 15.4396], [-9.44673, 15.60553], [-9.33314, 15.7044], [-9.31106, 15.69412], [-9.32979, 15.50032], [-5.50165, 15.50061], [-5.33435, 16.33354], [-5.60725, 16.49919]]]] } },
29150     { type: "Feature", properties: { iso1A2: "MS", iso1A3: "MSR", iso1N3: "500", wikidata: "Q13353", nameEn: "Montserrat", country: "GB", groups: ["BOTS", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 664"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-61.91508, 16.51165], [-62.1023, 16.97277], [-62.58307, 16.68909], [-61.91508, 16.51165]]]] } },
29151     { type: "Feature", properties: { iso1A2: "MT", iso1A3: "MLT", iso1N3: "470", wikidata: "Q233", nameEn: "Malta", groups: ["EU", "039", "150", "UN"], driveSide: "left", callingCodes: ["356"] }, geometry: { type: "MultiPolygon", coordinates: [[[[15.70991, 35.79901], [14.07544, 36.41525], [13.27636, 35.20764], [15.70991, 35.79901]]]] } },
29152     { type: "Feature", properties: { iso1A2: "MU", iso1A3: "MUS", iso1N3: "480", wikidata: "Q1027", nameEn: "Mauritius", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["230"] }, geometry: { type: "MultiPolygon", coordinates: [[[[56.09755, -9.55401], [57.50644, -31.92637], [68.4673, -19.15185], [56.09755, -9.55401]]]] } },
29153     { type: "Feature", properties: { iso1A2: "MV", iso1A3: "MDV", iso1N3: "462", wikidata: "Q826", nameEn: "Maldives", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["960"] }, geometry: { type: "MultiPolygon", coordinates: [[[[71.9161, 8.55531], [72.57428, -3.7623], [76.59015, 5.591], [71.9161, 8.55531]]]] } },
29154     { type: "Feature", properties: { iso1A2: "MW", iso1A3: "MWI", iso1N3: "454", wikidata: "Q1020", nameEn: "Malawi", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["265"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.48052, -9.62442], [33.31581, -9.48554], [33.14925, -9.49322], [32.99397, -9.36712], [32.95389, -9.40138], [33.00476, -9.5133], [33.00256, -9.63053], [33.05485, -9.61316], [33.10163, -9.66525], [33.12144, -9.58929], [33.2095, -9.61099], [33.31517, -9.82364], [33.36581, -9.81063], [33.37902, -9.9104], [33.31297, -10.05133], [33.53863, -10.20148], [33.54797, -10.36077], [33.70675, -10.56896], [33.47636, -10.78465], [33.28022, -10.84428], [33.25998, -10.88862], [33.39697, -11.15296], [33.29267, -11.3789], [33.29267, -11.43536], [33.23663, -11.40637], [33.24252, -11.59302], [33.32692, -11.59248], [33.33937, -11.91252], [33.25998, -12.14242], [33.3705, -12.34931], [33.47636, -12.32498], [33.54485, -12.35996], [33.37517, -12.54085], [33.28177, -12.54692], [33.18837, -12.61377], [33.05917, -12.59554], [32.94397, -12.76868], [32.96733, -12.88251], [33.02181, -12.88707], [32.98289, -13.12671], [33.0078, -13.19492], [32.86113, -13.47292], [32.84176, -13.52794], [32.73683, -13.57682], [32.68436, -13.55769], [32.66468, -13.60019], [32.68654, -13.64268], [32.7828, -13.64805], [32.84528, -13.71576], [32.76962, -13.77224], [32.79015, -13.80755], [32.88985, -13.82956], [32.99042, -13.95689], [33.02977, -14.05022], [33.07568, -13.98447], [33.16749, -13.93992], [33.24249, -14.00019], [33.66677, -14.61306], [33.7247, -14.4989], [33.88503, -14.51652], [33.92898, -14.47929], [34.08588, -14.48893], [34.18733, -14.43823], [34.22355, -14.43607], [34.34453, -14.3985], [34.35843, -14.38652], [34.39277, -14.39467], [34.4192, -14.43191], [34.44641, -14.47746], [34.45053, -14.49873], [34.47628, -14.53363], [34.48932, -14.53646], [34.49636, -14.55091], [34.52366, -14.5667], [34.53962, -14.59776], [34.55112, -14.64494], [34.53516, -14.67782], [34.52057, -14.68263], [34.54503, -14.74672], [34.567, -14.77345], [34.61522, -14.99583], [34.57503, -15.30619], [34.43126, -15.44778], [34.44981, -15.60864], [34.25195, -15.90321], [34.43126, -16.04737], [34.40344, -16.20923], [35.04805, -16.83167], [35.13771, -16.81687], [35.17017, -16.93521], [35.04805, -17.00027], [35.0923, -17.13235], [35.3062, -17.1244], [35.27065, -16.93817], [35.30929, -16.82871], [35.27219, -16.69402], [35.14235, -16.56812], [35.25828, -16.4792], [35.30157, -16.2211], [35.43355, -16.11371], [35.52365, -16.15414], [35.70107, -16.10147], [35.80487, -16.03907], [35.85303, -15.41913], [35.78799, -15.17428], [35.91812, -14.89514], [35.87212, -14.89478], [35.86945, -14.67481], [35.5299, -14.27714], [35.47989, -14.15594], [34.86229, -13.48958], [34.60253, -13.48487], [34.37831, -12.17408], [34.46088, -12.0174], [34.70739, -12.15652], [34.82903, -12.04837], [34.57917, -11.87849], [34.64241, -11.57499], [34.96296, -11.57354], [34.91153, -11.39799], [34.79375, -11.32245], [34.63305, -11.11731], [34.61161, -11.01611], [34.67047, -10.93796], [34.65946, -10.6828], [34.57581, -10.56271], [34.51911, -10.12279], [34.54499, -10.0678], [34.03865, -9.49398], [33.95829, -9.54066], [33.9638, -9.62206], [33.93298, -9.71647], [33.76677, -9.58516], [33.48052, -9.62442]]]] } },
29155     { type: "Feature", properties: { iso1A2: "MX", iso1A3: "MEX", iso1N3: "484", wikidata: "Q96", nameEn: "Mexico", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["52"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-117.1243, 32.53427], [-118.48109, 32.5991], [-120.12904, 18.41089], [-92.37213, 14.39277], [-92.2261, 14.53423], [-92.1454, 14.6804], [-92.18161, 14.84147], [-92.1423, 14.88647], [-92.1454, 14.98143], [-92.0621, 15.07406], [-92.20983, 15.26077], [-91.73182, 16.07371], [-90.44567, 16.07573], [-90.40499, 16.40524], [-90.61212, 16.49832], [-90.69064, 16.70697], [-91.04436, 16.92175], [-91.43809, 17.25373], [-90.99199, 17.25192], [-90.98678, 17.81655], [-89.14985, 17.81563], [-89.15105, 17.95104], [-89.03839, 18.0067], [-88.8716, 17.89535], [-88.71505, 18.0707], [-88.48242, 18.49164], [-88.3268, 18.49048], [-88.29909, 18.47591], [-88.26593, 18.47617], [-88.03238, 18.41778], [-88.03165, 18.16657], [-87.90671, 18.15213], [-87.87604, 18.18313], [-87.86657, 18.19971], [-87.85693, 18.18266], [-87.84815, 18.18511], [-86.92368, 17.61462], [-85.9092, 21.8218], [-96.92418, 25.97377], [-97.13927, 25.96583], [-97.35946, 25.92189], [-97.37332, 25.83854], [-97.42511, 25.83969], [-97.45669, 25.86874], [-97.49828, 25.89877], [-97.52025, 25.88518], [-97.66511, 26.01708], [-97.95155, 26.0625], [-97.97017, 26.05232], [-98.24603, 26.07191], [-98.27075, 26.09457], [-98.30491, 26.10475], [-98.35126, 26.15129], [-99.00546, 26.3925], [-99.03053, 26.41249], [-99.08477, 26.39849], [-99.53573, 27.30926], [-99.49744, 27.43746], [-99.482, 27.47128], [-99.48045, 27.49016], [-99.50208, 27.50021], [-99.52955, 27.49747], [-99.51478, 27.55836], [-99.55409, 27.61314], [-100.50029, 28.66117], [-100.51222, 28.70679], [-100.5075, 28.74066], [-100.52313, 28.75598], [-100.59809, 28.88197], [-100.63689, 28.90812], [-100.67294, 29.09744], [-100.79696, 29.24688], [-100.87982, 29.296], [-100.94056, 29.33371], [-100.94579, 29.34523], [-100.96725, 29.3477], [-101.01128, 29.36947], [-101.05686, 29.44738], [-101.47277, 29.7744], [-102.60596, 29.8192], [-103.15787, 28.93865], [-104.37752, 29.54255], [-104.39363, 29.55396], [-104.3969, 29.57105], [-104.5171, 29.64671], [-104.77674, 30.4236], [-106.00363, 31.39181], [-106.09025, 31.40569], [-106.20346, 31.46305], [-106.23711, 31.51262], [-106.24612, 31.54193], [-106.28084, 31.56173], [-106.30305, 31.62154], [-106.33419, 31.66303], [-106.34864, 31.69663], [-106.3718, 31.71165], [-106.38003, 31.73151], [-106.41773, 31.75196], [-106.43419, 31.75478], [-106.45244, 31.76523], [-106.46726, 31.75998], [-106.47298, 31.75054], [-106.48815, 31.74769], [-106.50111, 31.75714], [-106.50962, 31.76155], [-106.51251, 31.76922], [-106.52266, 31.77509], [-106.529, 31.784], [-108.20899, 31.78534], [-108.20979, 31.33316], [-111.07523, 31.33232], [-114.82011, 32.49609], [-114.79524, 32.55731], [-114.81141, 32.55543], [-114.80584, 32.62028], [-114.76736, 32.64094], [-114.71871, 32.71894], [-115.88053, 32.63624], [-117.1243, 32.53427]]]] } },
29156     { type: "Feature", properties: { iso1A2: "MY", iso1A3: "MYS", iso1N3: "458", wikidata: "Q833", nameEn: "Malaysia" }, geometry: null },
29157     { type: "Feature", properties: { iso1A2: "MZ", iso1A3: "MOZ", iso1N3: "508", wikidata: "Q1029", nameEn: "Mozambique", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["258"] }, geometry: { type: "MultiPolygon", coordinates: [[[[40.74206, -10.25691], [40.44265, -10.4618], [40.00295, -10.80255], [39.58249, -10.96043], [39.24395, -11.17433], [38.88996, -11.16978], [38.47258, -11.4199], [38.21598, -11.27289], [37.93618, -11.26228], [37.8388, -11.3123], [37.76614, -11.53352], [37.3936, -11.68949], [36.80309, -11.56836], [36.62068, -11.72884], [36.19094, -11.70008], [36.19094, -11.57593], [35.82767, -11.41081], [35.63599, -11.55927], [34.96296, -11.57354], [34.64241, -11.57499], [34.57917, -11.87849], [34.82903, -12.04837], [34.70739, -12.15652], [34.46088, -12.0174], [34.37831, -12.17408], [34.60253, -13.48487], [34.86229, -13.48958], [35.47989, -14.15594], [35.5299, -14.27714], [35.86945, -14.67481], [35.87212, -14.89478], [35.91812, -14.89514], [35.78799, -15.17428], [35.85303, -15.41913], [35.80487, -16.03907], [35.70107, -16.10147], [35.52365, -16.15414], [35.43355, -16.11371], [35.30157, -16.2211], [35.25828, -16.4792], [35.14235, -16.56812], [35.27219, -16.69402], [35.30929, -16.82871], [35.27065, -16.93817], [35.3062, -17.1244], [35.0923, -17.13235], [35.04805, -17.00027], [35.17017, -16.93521], [35.13771, -16.81687], [35.04805, -16.83167], [34.40344, -16.20923], [34.43126, -16.04737], [34.25195, -15.90321], [34.44981, -15.60864], [34.43126, -15.44778], [34.57503, -15.30619], [34.61522, -14.99583], [34.567, -14.77345], [34.54503, -14.74672], [34.52057, -14.68263], [34.53516, -14.67782], [34.55112, -14.64494], [34.53962, -14.59776], [34.52366, -14.5667], [34.49636, -14.55091], [34.48932, -14.53646], [34.47628, -14.53363], [34.45053, -14.49873], [34.44641, -14.47746], [34.4192, -14.43191], [34.39277, -14.39467], [34.35843, -14.38652], [34.34453, -14.3985], [34.22355, -14.43607], [34.18733, -14.43823], [34.08588, -14.48893], [33.92898, -14.47929], [33.88503, -14.51652], [33.7247, -14.4989], [33.66677, -14.61306], [33.24249, -14.00019], [30.22098, -14.99447], [30.41902, -15.62269], [30.42568, -15.9962], [30.91597, -15.99924], [30.97761, -16.05848], [31.13171, -15.98019], [31.30563, -16.01193], [31.42451, -16.15154], [31.67988, -16.19595], [31.90223, -16.34388], [31.91324, -16.41569], [32.02772, -16.43892], [32.28529, -16.43892], [32.42838, -16.4727], [32.71017, -16.59932], [32.69917, -16.66893], [32.78943, -16.70267], [32.97655, -16.70689], [32.91051, -16.89446], [32.84113, -16.92259], [32.96554, -17.11971], [33.00517, -17.30477], [33.0426, -17.3468], [32.96554, -17.48964], [32.98536, -17.55891], [33.0492, -17.60298], [32.94133, -17.99705], [33.03159, -18.35054], [33.02278, -18.4696], [32.88629, -18.51344], [32.88629, -18.58023], [32.95013, -18.69079], [32.9017, -18.7992], [32.82465, -18.77419], [32.70137, -18.84712], [32.73439, -18.92628], [32.69917, -18.94293], [32.72118, -19.02204], [32.84006, -19.0262], [32.87088, -19.09279], [32.85107, -19.29238], [32.77966, -19.36098], [32.78282, -19.47513], [32.84446, -19.48343], [32.84666, -19.68462], [32.95013, -19.67219], [33.06461, -19.77787], [33.01178, -20.02007], [32.93032, -20.03868], [32.85987, -20.16686], [32.85987, -20.27841], [32.66174, -20.56106], [32.55167, -20.56312], [32.48122, -20.63319], [32.51644, -20.91929], [32.37115, -21.133], [32.48236, -21.32873], [32.41234, -21.31246], [31.38336, -22.36919], [31.30611, -22.422], [31.55779, -23.176], [31.56539, -23.47268], [31.67942, -23.60858], [31.70223, -23.72695], [31.77445, -23.90082], [31.87707, -23.95293], [31.90368, -24.18892], [31.9835, -24.29983], [32.03196, -25.10785], [32.01676, -25.38117], [31.97875, -25.46356], [32.00631, -25.65044], [31.92649, -25.84216], [31.974, -25.95387], [32.00916, -25.999], [32.08599, -26.00978], [32.10435, -26.15656], [32.07352, -26.40185], [32.13409, -26.5317], [32.13315, -26.84345], [32.19409, -26.84032], [32.22302, -26.84136], [32.29584, -26.852], [32.35222, -26.86027], [34.51034, -26.91792], [42.99868, -12.65261], [40.74206, -10.25691]]]] } },
29158     { type: "Feature", properties: { iso1A2: "NA", iso1A3: "NAM", iso1N3: "516", wikidata: "Q1030", nameEn: "Namibia", groups: ["018", "202", "002", "UN"], driveSide: "left", callingCodes: ["264"] }, geometry: { type: "MultiPolygon", coordinates: [[[[14.28743, -17.38814], [13.95896, -17.43141], [13.36212, -16.98048], [12.97145, -16.98567], [12.52111, -17.24495], [12.07076, -17.15165], [11.75063, -17.25013], [10.5065, -17.25284], [12.51595, -32.27486], [16.45332, -28.63117], [16.46592, -28.57126], [16.59922, -28.53246], [16.90446, -28.057], [17.15405, -28.08573], [17.4579, -28.68718], [18.99885, -28.89165], [19.99882, -28.42622], [19.99817, -24.76768], [19.99912, -21.99991], [20.99751, -22.00026], [20.99904, -18.31743], [21.45556, -18.31795], [23.0996, -18.00075], [23.29618, -17.99855], [23.61088, -18.4881], [24.19416, -18.01919], [24.40577, -17.95726], [24.57485, -18.07151], [24.6303, -17.9863], [24.71887, -17.9218], [24.73364, -17.89338], [24.95586, -17.79674], [25.05895, -17.84452], [25.16882, -17.78253], [25.26433, -17.79571], [25.00198, -17.58221], [24.70864, -17.49501], [24.5621, -17.52963], [24.38712, -17.46818], [24.32811, -17.49082], [24.23619, -17.47489], [23.47474, -17.62877], [21.42741, -18.02787], [21.14283, -17.94318], [18.84226, -17.80375], [18.39229, -17.38927], [14.28743, -17.38814]]]] } },
29159     { type: "Feature", properties: { iso1A2: "NC", iso1A3: "NCL", iso1N3: "540", wikidata: "Q33788", nameEn: "New Caledonia", country: "FR", groups: ["EU", "Q1451600", "054", "009", "UN"], callingCodes: ["687"] }, geometry: { type: "MultiPolygon", coordinates: [[[[159.77159, -28.41151], [174.245, -23.1974], [156.73836, -14.50464], [159.77159, -28.41151]]]] } },
29160     { type: "Feature", properties: { iso1A2: "NE", iso1A3: "NER", iso1N3: "562", wikidata: "Q1032", nameEn: "Niger", aliases: ["RN"], groups: ["011", "202", "002", "UN"], callingCodes: ["227"] }, geometry: { type: "MultiPolygon", coordinates: [[[[14.22918, 22.61719], [13.5631, 23.16574], [11.96886, 23.51735], [7.48273, 20.87258], [7.38361, 20.79165], [5.8153, 19.45101], [4.26651, 19.14224], [4.26762, 17.00432], [4.21787, 17.00118], [4.19893, 16.39923], [3.50368, 15.35934], [3.03134, 15.42221], [3.01806, 15.34571], [1.31275, 15.27978], [0.96711, 14.98275], [0.72632, 14.95898], [0.23859, 15.00135], [0.16936, 14.51654], [0.38051, 14.05575], [0.61924, 13.68491], [0.77377, 13.6866], [0.77637, 13.64442], [0.99514, 13.5668], [1.02813, 13.46635], [1.20088, 13.38951], [1.24429, 13.39373], [1.28509, 13.35488], [1.24516, 13.33968], [1.21217, 13.37853], [1.18873, 13.31771], [0.99253, 13.37515], [0.99167, 13.10727], [2.26349, 12.41915], [2.05785, 12.35539], [2.39723, 11.89473], [2.45824, 11.98672], [2.39657, 12.10952], [2.37783, 12.24804], [2.6593, 12.30631], [2.83978, 12.40585], [3.25352, 12.01467], [3.31613, 11.88495], [3.48187, 11.86092], [3.59375, 11.70269], [3.61075, 11.69181], [3.67988, 11.75429], [3.67122, 11.80865], [3.63063, 11.83042], [3.61955, 11.91847], [3.67775, 11.97599], [3.63136, 12.11826], [3.66364, 12.25884], [3.65111, 12.52223], [3.94339, 12.74979], [4.10006, 12.98862], [4.14367, 13.17189], [4.14186, 13.47586], [4.23456, 13.47725], [4.4668, 13.68286], [4.87425, 13.78], [4.9368, 13.7345], [5.07396, 13.75052], [5.21026, 13.73627], [5.27797, 13.75474], [5.35437, 13.83567], [5.52957, 13.8845], [6.15771, 13.64564], [6.27411, 13.67835], [6.43053, 13.6006], [6.69617, 13.34057], [6.94445, 12.99825], [7.0521, 13.00076], [7.12676, 13.02445], [7.22399, 13.1293], [7.39241, 13.09717], [7.81085, 13.34902], [8.07997, 13.30847], [8.25185, 13.20369], [8.41853, 13.06166], [8.49493, 13.07519], [8.60431, 13.01768], [8.64251, 12.93985], [8.97413, 12.83661], [9.65995, 12.80614], [10.00373, 13.18171], [10.19993, 13.27129], [10.46731, 13.28819], [10.66004, 13.36422], [11.4535, 13.37773], [11.88236, 13.2527], [12.04209, 13.14452], [12.16189, 13.10056], [12.19315, 13.12423], [12.47095, 13.06673], [12.58033, 13.27805], [12.6793, 13.29157], [12.87376, 13.48919], [13.05085, 13.53984], [13.19844, 13.52802], [13.33213, 13.71195], [13.6302, 13.71094], [13.47559, 14.40881], [13.48259, 14.46704], [13.68573, 14.55276], [13.67878, 14.64013], [13.809, 14.72915], [13.78991, 14.87519], [13.86301, 15.04043], [14.37425, 15.72591], [15.50373, 16.89649], [15.6032, 18.77402], [15.75098, 19.93002], [15.99632, 20.35364], [15.6721, 20.70069], [15.59841, 20.74039], [15.56004, 20.79488], [15.55382, 20.86507], [15.57248, 20.92138], [15.62515, 20.95395], [15.28332, 21.44557], [15.20213, 21.49365], [15.19692, 21.99339], [14.99751, 23.00539], [14.22918, 22.61719]]]] } },
29161     { type: "Feature", properties: { iso1A2: "NF", iso1A3: "NFK", iso1N3: "574", wikidata: "Q31057", nameEn: "Norfolk Island", country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["672 3"] }, geometry: { type: "MultiPolygon", coordinates: [[[[169.82316, -28.16667], [166.29505, -28.29175], [167.94076, -30.60745], [169.82316, -28.16667]]]] } },
29162     { type: "Feature", properties: { iso1A2: "NG", iso1A3: "NGA", iso1N3: "566", wikidata: "Q1033", nameEn: "Nigeria", groups: ["011", "202", "002", "UN"], callingCodes: ["234"] }, geometry: { type: "MultiPolygon", coordinates: [[[[6.15771, 13.64564], [5.52957, 13.8845], [5.35437, 13.83567], [5.27797, 13.75474], [5.21026, 13.73627], [5.07396, 13.75052], [4.9368, 13.7345], [4.87425, 13.78], [4.4668, 13.68286], [4.23456, 13.47725], [4.14186, 13.47586], [4.14367, 13.17189], [4.10006, 12.98862], [3.94339, 12.74979], [3.65111, 12.52223], [3.66364, 12.25884], [3.63136, 12.11826], [3.67775, 11.97599], [3.61955, 11.91847], [3.63063, 11.83042], [3.67122, 11.80865], [3.67988, 11.75429], [3.61075, 11.69181], [3.59375, 11.70269], [3.49175, 11.29765], [3.71505, 11.13015], [3.84243, 10.59316], [3.78292, 10.40538], [3.6844, 10.46351], [3.57275, 10.27185], [3.66908, 10.18136], [3.54429, 9.87739], [3.35383, 9.83641], [3.32099, 9.78032], [3.34726, 9.70696], [3.25093, 9.61632], [3.13928, 9.47167], [3.14147, 9.28375], [3.08017, 9.10006], [2.77907, 9.06924], [2.67523, 7.87825], [2.73095, 7.7755], [2.73405, 7.5423], [2.78668, 7.5116], [2.79442, 7.43486], [2.74489, 7.42565], [2.76965, 7.13543], [2.71702, 6.95722], [2.74024, 6.92802], [2.73405, 6.78508], [2.78823, 6.76356], [2.78204, 6.70514], [2.7325, 6.64057], [2.74334, 6.57291], [2.70464, 6.50831], [2.70566, 6.38038], [2.74181, 6.13349], [5.87055, 3.78489], [8.34397, 4.30689], [8.60302, 4.87353], [8.78027, 5.1243], [8.92029, 5.58403], [8.83687, 5.68483], [8.88156, 5.78857], [8.84209, 5.82562], [9.51757, 6.43874], [9.70674, 6.51717], [9.77824, 6.79088], [9.86314, 6.77756], [10.15135, 7.03781], [10.21466, 6.88996], [10.53639, 6.93432], [10.57214, 7.16345], [10.59746, 7.14719], [10.60789, 7.06885], [10.83727, 6.9358], [10.8179, 6.83377], [10.94302, 6.69325], [11.09644, 6.68437], [11.09495, 6.51717], [11.42041, 6.53789], [11.42264, 6.5882], [11.51499, 6.60892], [11.57755, 6.74059], [11.55818, 6.86186], [11.63117, 6.9905], [11.87396, 7.09398], [11.84864, 7.26098], [11.93205, 7.47812], [12.01844, 7.52981], [11.99908, 7.67302], [12.20909, 7.97553], [12.19271, 8.10826], [12.24782, 8.17904], [12.26123, 8.43696], [12.4489, 8.52536], [12.44146, 8.6152], [12.68722, 8.65938], [12.71701, 8.7595], [12.79, 8.75361], [12.81085, 8.91992], [12.90022, 9.11411], [12.91958, 9.33905], [12.85628, 9.36698], [13.02385, 9.49334], [13.22642, 9.57266], [13.25472, 9.76795], [13.29941, 9.8296], [13.25025, 9.86042], [13.24132, 9.91031], [13.27409, 9.93232], [13.286, 9.9822], [13.25323, 10.00127], [13.25025, 10.03647], [13.34111, 10.12299], [13.43644, 10.13326], [13.5705, 10.53183], [13.54964, 10.61236], [13.73434, 10.9255], [13.70753, 10.94451], [13.7403, 11.00593], [13.78945, 11.00154], [13.97489, 11.30258], [14.17821, 11.23831], [14.6124, 11.51283], [14.64591, 11.66166], [14.55207, 11.72001], [14.61612, 11.7798], [14.6474, 12.17466], [14.4843, 12.35223], [14.22215, 12.36533], [14.17523, 12.41916], [14.20204, 12.53405], [14.08251, 13.0797], [13.6302, 13.71094], [13.33213, 13.71195], [13.19844, 13.52802], [13.05085, 13.53984], [12.87376, 13.48919], [12.6793, 13.29157], [12.58033, 13.27805], [12.47095, 13.06673], [12.19315, 13.12423], [12.16189, 13.10056], [12.04209, 13.14452], [11.88236, 13.2527], [11.4535, 13.37773], [10.66004, 13.36422], [10.46731, 13.28819], [10.19993, 13.27129], [10.00373, 13.18171], [9.65995, 12.80614], [8.97413, 12.83661], [8.64251, 12.93985], [8.60431, 13.01768], [8.49493, 13.07519], [8.41853, 13.06166], [8.25185, 13.20369], [8.07997, 13.30847], [7.81085, 13.34902], [7.39241, 13.09717], [7.22399, 13.1293], [7.12676, 13.02445], [7.0521, 13.00076], [6.94445, 12.99825], [6.69617, 13.34057], [6.43053, 13.6006], [6.27411, 13.67835], [6.15771, 13.64564]]]] } },
29163     { type: "Feature", properties: { iso1A2: "NI", iso1A3: "NIC", iso1N3: "558", wikidata: "Q811", nameEn: "Nicaragua", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["505"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-83.13724, 15.00002], [-83.49268, 15.01158], [-83.62101, 14.89448], [-83.89551, 14.76697], [-84.10584, 14.76353], [-84.48373, 14.63249], [-84.70119, 14.68078], [-84.82596, 14.82212], [-84.90082, 14.80489], [-85.1575, 14.53934], [-85.18602, 14.24929], [-85.32149, 14.2562], [-85.45762, 14.11304], [-85.73964, 13.9698], [-85.75477, 13.8499], [-86.03458, 13.99181], [-86.00685, 14.08474], [-86.14801, 14.04317], [-86.35219, 13.77157], [-86.76812, 13.79605], [-86.71267, 13.30348], [-86.87066, 13.30641], [-86.93383, 13.18677], [-86.93197, 13.05313], [-87.03785, 12.98682], [-87.06306, 13.00892], [-87.37107, 12.98646], [-87.55124, 13.12523], [-87.7346, 13.13228], [-88.11443, 12.63306], [-86.14524, 11.09059], [-85.71223, 11.06868], [-85.60529, 11.22607], [-84.92439, 10.9497], [-84.68197, 11.07568], [-83.90838, 10.71161], [-83.66597, 10.79916], [-83.68276, 11.01562], [-82.56142, 11.91792], [-82.06974, 14.49418], [-83.04763, 15.03256], [-83.13724, 15.00002]]]] } },
29164     { type: "Feature", properties: { iso1A2: "NL", iso1A3: "NLD", iso1N3: "528", wikidata: "Q29999", nameEn: "Kingdom of the Netherlands" }, geometry: null },
29165     { type: "Feature", properties: { iso1A2: "NO", iso1A3: "NOR", iso1N3: "578", wikidata: "Q20", nameEn: "Norway" }, geometry: null },
29166     { type: "Feature", properties: { iso1A2: "NP", iso1A3: "NPL", iso1N3: "524", wikidata: "Q837", nameEn: "Nepal", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["977"] }, geometry: { type: "MultiPolygon", coordinates: [[[[88.13378, 27.88015], [87.82681, 27.95248], [87.72718, 27.80938], [87.56996, 27.84517], [87.11696, 27.84104], [87.03757, 27.94835], [86.75582, 28.04182], [86.74181, 28.10638], [86.56265, 28.09569], [86.51609, 27.96623], [86.42736, 27.91122], [86.22966, 27.9786], [86.18607, 28.17364], [86.088, 28.09264], [86.08333, 28.02121], [86.12069, 27.93047], [86.06309, 27.90021], [85.94946, 27.9401], [85.97813, 27.99023], [85.90743, 28.05144], [85.84672, 28.18187], [85.74864, 28.23126], [85.71907, 28.38064], [85.69105, 28.38475], [85.60854, 28.25045], [85.59765, 28.30529], [85.4233, 28.32996], [85.38127, 28.28336], [85.10729, 28.34092], [85.18668, 28.54076], [85.19135, 28.62825], [85.06059, 28.68562], [84.85511, 28.58041], [84.62317, 28.73887], [84.47528, 28.74023], [84.2231, 28.89571], [84.24801, 29.02783], [84.18107, 29.23451], [83.97559, 29.33091], [83.82303, 29.30513], [83.63156, 29.16249], [83.44787, 29.30513], [83.28131, 29.56813], [83.07116, 29.61957], [82.73024, 29.81695], [82.5341, 29.9735], [82.38622, 30.02608], [82.16984, 30.0692], [82.19475, 30.16884], [82.10757, 30.23745], [82.10135, 30.35439], [81.99082, 30.33423], [81.62033, 30.44703], [81.5459, 30.37688], [81.41018, 30.42153], [81.39928, 30.21862], [81.33355, 30.15303], [81.2623, 30.14596], [81.29032, 30.08806], [81.24362, 30.0126], [81.12842, 30.01395], [81.03953, 30.20059], [80.92547, 30.17193], [80.91143, 30.22173], [80.86673, 30.17321], [80.8778, 30.13384], [80.67076, 29.95732], [80.60226, 29.95732], [80.57179, 29.91422], [80.56247, 29.86661], [80.48997, 29.79566], [80.43458, 29.80466], [80.41554, 29.79451], [80.36803, 29.73865], [80.38428, 29.68513], [80.41858, 29.63581], [80.37939, 29.57098], [80.24322, 29.44299], [80.31428, 29.30784], [80.28626, 29.20327], [80.24112, 29.21414], [80.26602, 29.13938], [80.23178, 29.11626], [80.18085, 29.13649], [80.05743, 28.91479], [80.06957, 28.82763], [80.12125, 28.82346], [80.37188, 28.63371], [80.44504, 28.63098], [80.52443, 28.54897], [80.50575, 28.6706], [80.55142, 28.69182], [81.03471, 28.40054], [81.19847, 28.36284], [81.32923, 28.13521], [81.38683, 28.17638], [81.48179, 28.12148], [81.47867, 28.08303], [81.91223, 27.84995], [81.97214, 27.93322], [82.06554, 27.92222], [82.46405, 27.6716], [82.70378, 27.72122], [82.74119, 27.49838], [82.93261, 27.50328], [82.94938, 27.46036], [83.19413, 27.45632], [83.27197, 27.38309], [83.2673, 27.36235], [83.29999, 27.32778], [83.35136, 27.33885], [83.38872, 27.39276], [83.39495, 27.4798], [83.61288, 27.47013], [83.85595, 27.35797], [83.86182, 27.4241], [83.93306, 27.44939], [84.02229, 27.43836], [84.10791, 27.52399], [84.21376, 27.45218], [84.25735, 27.44941], [84.29315, 27.39], [84.62161, 27.33885], [84.69166, 27.21294], [84.64496, 27.04669], [84.793, 26.9968], [84.82913, 27.01989], [84.85754, 26.98984], [84.96687, 26.95599], [84.97186, 26.9149], [85.00536, 26.89523], [85.05592, 26.88991], [85.02635, 26.85381], [85.15883, 26.86966], [85.19291, 26.86909], [85.18046, 26.80519], [85.21159, 26.75933], [85.34302, 26.74954], [85.47752, 26.79292], [85.56471, 26.84133], [85.5757, 26.85955], [85.59461, 26.85161], [85.61621, 26.86721], [85.66239, 26.84822], [85.73483, 26.79613], [85.72315, 26.67471], [85.76907, 26.63076], [85.83126, 26.61134], [85.85126, 26.60866], [85.8492, 26.56667], [86.02729, 26.66756], [86.13596, 26.60651], [86.22513, 26.58863], [86.26235, 26.61886], [86.31564, 26.61925], [86.49726, 26.54218], [86.54258, 26.53819], [86.57073, 26.49825], [86.61313, 26.48658], [86.62686, 26.46891], [86.69124, 26.45169], [86.74025, 26.42386], [86.76797, 26.45892], [86.82898, 26.43919], [86.94543, 26.52076], [86.95912, 26.52076], [87.01559, 26.53228], [87.04691, 26.58685], [87.0707, 26.58571], [87.09147, 26.45039], [87.14751, 26.40542], [87.18863, 26.40558], [87.24682, 26.4143], [87.26587, 26.40592], [87.26568, 26.37294], [87.34568, 26.34787], [87.37314, 26.40815], [87.46566, 26.44058], [87.51571, 26.43106], [87.55274, 26.40596], [87.59175, 26.38342], [87.66803, 26.40294], [87.67893, 26.43501], [87.76004, 26.40711], [87.7918, 26.46737], [87.84193, 26.43663], [87.89085, 26.48565], [87.90115, 26.44923], [88.00895, 26.36029], [88.09414, 26.43732], [88.09963, 26.54195], [88.16452, 26.64111], [88.1659, 26.68177], [88.19107, 26.75516], [88.12302, 26.95324], [88.13422, 26.98705], [88.11719, 26.98758], [87.9887, 27.11045], [88.01587, 27.21388], [88.01646, 27.21612], [88.07277, 27.43007], [88.04008, 27.49223], [88.19107, 27.79285], [88.1973, 27.85067], [88.13378, 27.88015]]]] } },
29167     { type: "Feature", properties: { iso1A2: "NR", iso1A3: "NRU", iso1N3: "520", wikidata: "Q697", nameEn: "Nauru", groups: ["057", "009", "UN"], driveSide: "left", callingCodes: ["674"] }, geometry: { type: "MultiPolygon", coordinates: [[[[166.95155, 0.14829], [166.21778, -0.7977], [167.60042, -0.88259], [166.95155, 0.14829]]]] } },
29168     { type: "Feature", properties: { iso1A2: "NU", iso1A3: "NIU", iso1N3: "570", wikidata: "Q34020", nameEn: "Niue", country: "NZ", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["683"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-170.83899, -18.53439], [-170.82274, -20.44429], [-168.63096, -18.60489], [-170.83899, -18.53439]]]] } },
29169     { type: "Feature", properties: { iso1A2: "NZ", iso1A3: "NZL", iso1N3: "554", wikidata: "Q664", nameEn: "New Zealand" }, geometry: null },
29170     { type: "Feature", properties: { iso1A2: "OM", iso1A3: "OMN", iso1N3: "512", wikidata: "Q842", nameEn: "Oman", groups: ["145", "142", "UN"], callingCodes: ["968"] }, geometry: { type: "MultiPolygon", coordinates: [[[[56.82555, 25.7713], [56.79239, 26.41236], [56.68954, 26.76645], [56.2644, 26.58649], [55.81777, 26.18798], [56.08666, 26.05038], [56.15498, 26.06828], [56.19334, 25.9795], [56.13963, 25.82765], [56.17416, 25.77239], [56.13579, 25.73524], [56.14826, 25.66351], [56.18363, 25.65508], [56.20473, 25.61119], [56.25365, 25.60211], [56.26636, 25.60643], [56.25341, 25.61443], [56.26534, 25.62825], [56.82555, 25.7713]]], [[[56.26062, 25.33108], [56.23362, 25.31253], [56.25008, 25.28843], [56.24465, 25.27505], [56.20838, 25.25668], [56.20872, 25.24104], [56.24341, 25.22867], [56.27628, 25.23404], [56.34438, 25.26653], [56.35172, 25.30681], [56.3111, 25.30107], [56.3005, 25.31815], [56.26062, 25.33108]], [[56.28423, 25.26344], [56.27086, 25.26128], [56.2716, 25.27916], [56.28102, 25.28486], [56.29379, 25.2754], [56.28423, 25.26344]]], [[[61.45114, 22.55394], [56.86325, 25.03856], [56.3227, 24.97284], [56.34873, 24.93205], [56.30269, 24.88334], [56.20568, 24.85063], [56.20062, 24.78565], [56.13684, 24.73699], [56.06128, 24.74457], [56.03535, 24.81161], [55.97836, 24.87673], [55.97467, 24.89639], [56.05106, 24.87461], [56.05715, 24.95727], [55.96316, 25.00857], [55.90849, 24.96771], [55.85094, 24.96858], [55.81116, 24.9116], [55.81348, 24.80102], [55.83408, 24.77858], [55.83271, 24.68567], [55.76461, 24.5287], [55.83271, 24.41521], [55.83395, 24.32776], [55.80747, 24.31069], [55.79145, 24.27914], [55.76781, 24.26209], [55.75939, 24.26114], [55.75382, 24.2466], [55.75257, 24.23466], [55.76558, 24.23227], [55.77658, 24.23476], [55.83367, 24.20193], [55.95472, 24.2172], [56.01799, 24.07426], [55.8308, 24.01633], [55.73301, 24.05994], [55.48677, 23.94946], [55.57358, 23.669], [55.22634, 23.10378], [55.2137, 22.71065], [55.66469, 21.99658], [54.99756, 20.00083], [52.00311, 19.00083], [52.78009, 17.35124], [52.74267, 17.29519], [52.81185, 17.28568], [57.49095, 8.14549], [61.45114, 22.55394]]]] } },
29171     { type: "Feature", properties: { iso1A2: "PA", iso1A3: "PAN", iso1N3: "591", wikidata: "Q804", nameEn: "Panama", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["507"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-77.32389, 8.81247], [-77.58292, 9.22278], [-78.79327, 9.93766], [-82.51044, 9.65379], [-82.56507, 9.57279], [-82.61345, 9.49881], [-82.66667, 9.49746], [-82.77206, 9.59573], [-82.87919, 9.62645], [-82.84871, 9.4973], [-82.93516, 9.46741], [-82.93516, 9.07687], [-82.72126, 8.97125], [-82.88253, 8.83331], [-82.91377, 8.774], [-82.92068, 8.74832], [-82.8794, 8.6981], [-82.82739, 8.60153], [-82.83975, 8.54755], [-82.83322, 8.52464], [-82.8382, 8.48117], [-82.8679, 8.44042], [-82.93056, 8.43465], [-83.05209, 8.33394], [-82.9388, 8.26634], [-82.88641, 8.10219], [-82.89137, 8.05755], [-82.89978, 8.04083], [-82.94503, 7.93865], [-82.13751, 6.97312], [-78.06168, 7.07793], [-77.89178, 7.22681], [-77.81426, 7.48319], [-77.72157, 7.47612], [-77.72514, 7.72348], [-77.57185, 7.51147], [-77.17257, 7.97422], [-77.45064, 8.49991], [-77.32389, 8.81247]]]] } },
29172     { type: "Feature", properties: { iso1A2: "PE", iso1A3: "PER", iso1N3: "604", wikidata: "Q419", nameEn: "Peru", groups: ["005", "419", "019", "UN"], callingCodes: ["51"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-74.26675, -0.97229], [-74.42701, -0.50218], [-75.18513, -0.0308], [-75.25764, -0.11943], [-75.40192, -0.17196], [-75.61997, -0.10012], [-75.60169, -0.18708], [-75.53615, -0.19213], [-75.22862, -0.60048], [-75.22862, -0.95588], [-75.3872, -0.9374], [-75.57429, -1.55961], [-76.05203, -2.12179], [-76.6324, -2.58397], [-77.94147, -3.05454], [-78.19369, -3.36431], [-78.14324, -3.47653], [-78.22642, -3.51113], [-78.24589, -3.39907], [-78.34362, -3.38633], [-78.68394, -4.60754], [-78.85149, -4.66795], [-79.01659, -5.01481], [-79.1162, -4.97774], [-79.26248, -4.95167], [-79.59402, -4.46848], [-79.79722, -4.47558], [-80.13945, -4.29786], [-80.39256, -4.48269], [-80.46386, -4.41516], [-80.32114, -4.21323], [-80.45023, -4.20938], [-80.4822, -4.05477], [-80.46386, -4.01342], [-80.13232, -3.90317], [-80.19926, -3.68894], [-80.18741, -3.63994], [-80.19848, -3.59249], [-80.21642, -3.5888], [-80.20535, -3.51667], [-80.22629, -3.501], [-80.23651, -3.48652], [-80.24586, -3.48677], [-80.24123, -3.46124], [-80.20647, -3.431], [-80.30602, -3.39149], [-84.52388, -3.36941], [-85.71054, -21.15413], [-70.59118, -18.35072], [-70.378, -18.3495], [-70.31267, -18.31258], [-70.16394, -18.31737], [-69.96732, -18.25992], [-69.81607, -18.12582], [-69.75305, -17.94605], [-69.82868, -17.72048], [-69.79087, -17.65563], [-69.66483, -17.65083], [-69.46897, -17.4988], [-69.46863, -17.37466], [-69.62883, -17.28142], [-69.16896, -16.72233], [-69.00853, -16.66769], [-69.04027, -16.57214], [-68.98358, -16.42165], [-68.79464, -16.33272], [-68.96238, -16.194], [-69.09986, -16.22693], [-69.20291, -16.16668], [-69.40336, -15.61358], [-69.14856, -15.23478], [-69.36254, -14.94634], [-68.88135, -14.18639], [-69.05265, -13.68546], [-68.8864, -13.40792], [-68.85615, -12.87769], [-68.65044, -12.50689], [-68.98115, -11.8979], [-69.57156, -10.94555], [-69.57835, -10.94051], [-69.90896, -10.92744], [-70.38791, -11.07096], [-70.51395, -10.92249], [-70.64134, -11.0108], [-70.62487, -9.80666], [-70.55429, -9.76692], [-70.58453, -9.58303], [-70.53373, -9.42628], [-71.23394, -9.9668], [-72.14742, -9.98049], [-72.31883, -9.5184], [-72.72216, -9.41397], [-73.21498, -9.40904], [-72.92886, -9.04074], [-73.76576, -7.89884], [-73.65485, -7.77897], [-73.96938, -7.58465], [-73.77011, -7.28944], [-73.73986, -6.87919], [-73.12983, -6.43852], [-73.24579, -6.05764], [-72.83973, -5.14765], [-72.64391, -5.0391], [-71.87003, -4.51661], [-70.96814, -4.36915], [-70.77601, -4.15717], [-70.33236, -4.15214], [-70.19582, -4.3607], [-70.11305, -4.27281], [-70.00888, -4.37833], [-69.94708, -4.2431], [-70.3374, -3.79505], [-70.52393, -3.87553], [-70.71396, -3.7921], [-70.04609, -2.73906], [-70.94377, -2.23142], [-71.75223, -2.15058], [-72.92587, -2.44514], [-73.65312, -1.26222], [-74.26675, -0.97229]]]] } },
29173     { type: "Feature", properties: { iso1A2: "PF", iso1A3: "PYF", iso1N3: "258", wikidata: "Q30971", nameEn: "French Polynesia", country: "FR", groups: ["EU", "Q1451600", "061", "009", "UN"], callingCodes: ["689"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-135.59706, -4.70473], [-156.48634, -15.52824], [-156.45576, -31.75456], [-133.59543, -28.4709], [-135.59706, -4.70473]]]] } },
29174     { type: "Feature", properties: { iso1A2: "PG", iso1A3: "PNG", iso1N3: "598", wikidata: "Q691", nameEn: "Papua New Guinea", groups: ["054", "009", "UN"], driveSide: "left", callingCodes: ["675"] }, geometry: { type: "MultiPolygon", coordinates: [[[[141.03157, 2.12829], [140.99813, -6.3233], [140.85295, -6.72996], [140.90448, -6.85033], [141.01763, -6.90181], [141.01842, -9.35091], [141.88934, -9.36111], [142.19246, -9.15378], [142.48658, -9.36754], [143.29772, -9.33993], [143.87386, -9.02382], [145.2855, -9.62524], [156.73836, -14.50464], [154.74815, -7.33315], [155.60735, -6.92266], [155.69784, -6.92661], [155.92557, -6.84664], [156.03993, -6.65703], [156.03296, -6.55528], [160.43769, -4.17974], [141.03157, 2.12829]]]] } },
29175     { type: "Feature", properties: { iso1A2: "PH", iso1A3: "PHL", iso1N3: "608", wikidata: "Q928", nameEn: "Philippines", aliases: ["PI", "RP"], groups: ["035", "142", "UN"], callingCodes: ["63"] }, geometry: { type: "MultiPolygon", coordinates: [[[[129.19694, 7.84182], [121.8109, 21.77688], [120.69238, 21.52331], [118.82252, 14.67191], [115.39742, 10.92666], [116.79524, 7.43869], [117.17735, 7.52841], [117.93857, 6.89845], [117.98544, 6.27477], [119.52945, 5.35672], [118.93936, 4.09009], [118.06469, 4.16638], [121.14448, 2.12444], [129.19694, 7.84182]]]] } },
29176     { type: "Feature", properties: { iso1A2: "PK", iso1A3: "PAK", iso1N3: "586", wikidata: "Q843", nameEn: "Pakistan", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["92"] }, geometry: { type: "MultiPolygon", coordinates: [[[[75.72737, 36.7529], [75.45562, 36.71971], [75.40481, 36.95382], [75.13839, 37.02622], [74.56453, 37.03023], [74.53739, 36.96224], [74.43389, 37.00977], [74.04856, 36.82648], [73.82685, 36.91421], [72.6323, 36.84601], [72.18135, 36.71838], [71.80267, 36.49924], [71.60491, 36.39429], [71.19505, 36.04134], [71.37969, 35.95865], [71.55273, 35.71483], [71.49917, 35.6267], [71.65435, 35.4479], [71.54294, 35.31037], [71.5541, 35.28776], [71.67495, 35.21262], [71.52938, 35.09023], [71.55273, 35.02615], [71.49917, 35.00478], [71.50329, 34.97328], [71.29472, 34.87728], [71.28356, 34.80882], [71.08718, 34.69034], [71.11602, 34.63047], [71.0089, 34.54568], [71.02401, 34.44835], [71.17662, 34.36769], [71.12815, 34.26619], [71.13078, 34.16503], [71.09453, 34.13524], [71.09307, 34.11961], [71.06933, 34.10564], [71.07345, 34.06242], [70.88119, 33.97933], [70.54336, 33.9463], [69.90203, 34.04194], [69.87307, 33.9689], [69.85671, 33.93719], [70.00503, 33.73528], [70.14236, 33.71701], [70.14785, 33.6553], [70.20141, 33.64387], [70.17062, 33.53535], [70.32775, 33.34496], [70.13686, 33.21064], [70.07369, 33.22557], [70.02563, 33.14282], [69.85259, 33.09451], [69.79766, 33.13247], [69.71526, 33.09911], [69.57656, 33.09911], [69.49004, 33.01509], [69.49854, 32.88843], [69.5436, 32.8768], [69.47082, 32.85834], [69.38018, 32.76601], [69.43649, 32.7302], [69.44747, 32.6678], [69.38155, 32.56601], [69.2868, 32.53938], [69.23599, 32.45946], [69.27932, 32.29119], [69.27032, 32.14141], [69.3225, 31.93186], [69.20577, 31.85957], [69.11514, 31.70782], [69.00939, 31.62249], [68.95995, 31.64822], [68.91078, 31.59687], [68.79997, 31.61665], [68.6956, 31.75687], [68.57475, 31.83158], [68.44222, 31.76446], [68.27605, 31.75863], [68.25614, 31.80357], [68.1655, 31.82691], [68.00071, 31.6564], [67.86887, 31.63536], [67.72056, 31.52304], [67.58323, 31.52772], [67.62374, 31.40473], [67.7748, 31.4188], [67.78854, 31.33203], [67.29964, 31.19586], [67.03323, 31.24519], [67.04147, 31.31561], [66.83273, 31.26867], [66.72561, 31.20526], [66.68166, 31.07597], [66.58175, 30.97532], [66.42645, 30.95309], [66.39194, 30.9408], [66.28413, 30.57001], [66.34869, 30.404], [66.23609, 30.06321], [66.36042, 29.9583], [66.24175, 29.85181], [65.04005, 29.53957], [64.62116, 29.58903], [64.19796, 29.50407], [64.12966, 29.39157], [63.5876, 29.50456], [62.47751, 29.40782], [60.87231, 29.86514], [61.31508, 29.38903], [61.53765, 29.00507], [61.65978, 28.77937], [61.93581, 28.55284], [62.40259, 28.42703], [62.59499, 28.24842], [62.79412, 28.28108], [62.7638, 28.02992], [62.84905, 27.47627], [62.79684, 27.34381], [62.80604, 27.22412], [63.19649, 27.25674], [63.32283, 27.14437], [63.25005, 27.08692], [63.25005, 26.84212], [63.18688, 26.83844], [63.1889, 26.65072], [62.77352, 26.64099], [62.31484, 26.528], [62.21304, 26.26601], [62.05117, 26.31647], [61.89391, 26.26251], [61.83831, 26.07249], [61.83968, 25.7538], [61.683, 25.66638], [61.6433, 25.27541], [61.46682, 24.57869], [68.11329, 23.53945], [68.20763, 23.85849], [68.39339, 23.96838], [68.74643, 23.97027], [68.7416, 24.31904], [68.90914, 24.33156], [68.97781, 24.26021], [69.07806, 24.29777], [69.19341, 24.25646], [69.29778, 24.28712], [69.59579, 24.29777], [69.73335, 24.17007], [70.03428, 24.172], [70.11712, 24.30915], [70.5667, 24.43787], [70.57906, 24.27774], [70.71502, 24.23517], [70.88393, 24.27398], [70.85784, 24.30903], [70.94985, 24.3791], [71.04461, 24.34657], [71.12838, 24.42662], [71.00341, 24.46038], [70.97594, 24.60904], [71.09405, 24.69017], [70.94002, 24.92843], [70.89148, 25.15064], [70.66695, 25.39314], [70.67382, 25.68186], [70.60378, 25.71898], [70.53649, 25.68928], [70.37444, 25.67443], [70.2687, 25.71156], [70.0985, 25.93238], [70.08193, 26.08094], [70.17532, 26.24118], [70.17532, 26.55362], [70.05584, 26.60398], [69.88555, 26.56836], [69.50904, 26.74892], [69.58519, 27.18109], [70.03136, 27.56627], [70.12502, 27.8057], [70.37307, 28.01208], [70.60927, 28.02178], [70.79054, 27.68423], [71.89921, 27.96035], [71.9244, 28.11555], [72.20329, 28.3869], [72.29495, 28.66367], [72.40402, 28.78283], [72.94272, 29.02487], [73.01337, 29.16422], [73.05886, 29.1878], [73.28094, 29.56646], [73.3962, 29.94707], [73.58665, 30.01848], [73.80299, 30.06969], [73.97225, 30.19829], [73.95736, 30.28466], [73.88993, 30.36305], [74.5616, 31.04153], [74.67971, 31.05479], [74.6852, 31.12771], [74.60006, 31.13711], [74.60281, 31.10419], [74.56023, 31.08303], [74.51629, 31.13829], [74.53223, 31.30321], [74.59773, 31.4136], [74.64713, 31.45605], [74.59319, 31.50197], [74.61517, 31.55698], [74.57498, 31.60382], [74.47771, 31.72227], [74.58907, 31.87824], [74.79919, 31.95983], [74.86236, 32.04485], [74.9269, 32.0658], [75.00793, 32.03786], [75.25649, 32.10187], [75.38046, 32.26836], [75.28259, 32.36556], [75.03265, 32.49538], [74.97634, 32.45367], [74.84725, 32.49075], [74.68362, 32.49298], [74.67431, 32.56676], [74.65251, 32.56416], [74.64424, 32.60985], [74.69542, 32.66792], [74.65345, 32.71225], [74.7113, 32.84219], [74.64675, 32.82604], [74.6289, 32.75561], [74.45312, 32.77755], [74.41467, 32.90563], [74.31227, 32.92795], [74.34875, 32.97823], [74.31854, 33.02891], [74.17571, 33.07495], [74.15374, 33.13477], [74.02144, 33.18908], [74.01366, 33.25199], [74.08782, 33.26232], [74.17983, 33.3679], [74.18121, 33.4745], [74.10115, 33.56392], [74.03576, 33.56718], [73.97367, 33.64061], [73.98968, 33.66155], [73.96423, 33.73071], [74.00891, 33.75437], [74.05898, 33.82089], [74.14001, 33.83002], [74.26086, 33.92237], [74.25262, 34.01577], [74.21554, 34.03853], [73.91341, 34.01235], [73.88732, 34.05105], [73.90677, 34.10504], [73.98208, 34.2522], [73.90517, 34.35317], [73.8475, 34.32935], [73.74862, 34.34183], [73.74999, 34.3781], [73.88732, 34.48911], [73.89419, 34.54568], [73.93951, 34.57169], [73.93401, 34.63386], [73.96423, 34.68244], [74.12897, 34.70073], [74.31239, 34.79626], [74.58083, 34.77386], [74.6663, 34.703], [75.01479, 34.64629], [75.38009, 34.55021], [75.75438, 34.51827], [76.04614, 34.67566], [76.15463, 34.6429], [76.47186, 34.78965], [76.67648, 34.76371], [76.74377, 34.84039], [76.74514, 34.92488], [76.87193, 34.96906], [76.99251, 34.93349], [77.11796, 35.05419], [76.93465, 35.39866], [76.85088, 35.39754], [76.75475, 35.52617], [76.77323, 35.66062], [76.50961, 35.8908], [76.33453, 35.84296], [76.14913, 35.82848], [76.15325, 35.9264], [75.93028, 36.13136], [76.00906, 36.17511], [76.0324, 36.41198], [75.92391, 36.56986], [75.72737, 36.7529]]]] } },
29177     { type: "Feature", properties: { iso1A2: "PL", iso1A3: "POL", iso1N3: "616", wikidata: "Q36", nameEn: "Poland", groups: ["EU", "151", "150", "UN"], callingCodes: ["48"] }, geometry: { type: "MultiPolygon", coordinates: [[[[18.57853, 55.25302], [14.20811, 54.12784], [14.22634, 53.9291], [14.20647, 53.91671], [14.18544, 53.91258], [14.20823, 53.90776], [14.21323, 53.8664], [14.27249, 53.74464], [14.26782, 53.69866], [14.2836, 53.67721], [14.27133, 53.66613], [14.28477, 53.65955], [14.2853, 53.63392], [14.31904, 53.61581], [14.30416, 53.55499], [14.3273, 53.50587], [14.35209, 53.49506], [14.4215, 53.27724], [14.44133, 53.27427], [14.45125, 53.26241], [14.40662, 53.21098], [14.37853, 53.20405], [14.36696, 53.16444], [14.38679, 53.13669], [14.35044, 53.05829], [14.25954, 53.00264], [14.14056, 52.95786], [14.15873, 52.87715], [14.12256, 52.84311], [14.13806, 52.82392], [14.22071, 52.81175], [14.61073, 52.59847], [14.6289, 52.57136], [14.60081, 52.53116], [14.63056, 52.48993], [14.54423, 52.42568], [14.55228, 52.35264], [14.56378, 52.33838], [14.58149, 52.28007], [14.70139, 52.25038], [14.71319, 52.22144], [14.68344, 52.19612], [14.70616, 52.16927], [14.67683, 52.13936], [14.6917, 52.10283], [14.72971, 52.09167], [14.76026, 52.06624], [14.71339, 52.00337], [14.70488, 51.97679], [14.7139, 51.95643], [14.71836, 51.95606], [14.72163, 51.95188], [14.7177, 51.94048], [14.70601, 51.92944], [14.6933, 51.9044], [14.6588, 51.88359], [14.59089, 51.83302], [14.60493, 51.80473], [14.64625, 51.79472], [14.66386, 51.73282], [14.69065, 51.70842], [14.75392, 51.67445], [14.75759, 51.62318], [14.7727, 51.61263], [14.71125, 51.56209], [14.73047, 51.54606], [14.72652, 51.53902], [14.73219, 51.52922], [14.94749, 51.47155], [14.9652, 51.44793], [14.96899, 51.38367], [14.98008, 51.33449], [15.04288, 51.28387], [15.01242, 51.21285], [15.0047, 51.16874], [14.99311, 51.16249], [14.99414, 51.15813], [15.00083, 51.14974], [14.99646, 51.14365], [14.99079, 51.14284], [14.99689, 51.12205], [14.98229, 51.11354], [14.97938, 51.07742], [14.95529, 51.04552], [14.92942, 50.99744], [14.89252, 50.94999], [14.89681, 50.9422], [14.81664, 50.88148], [14.82803, 50.86966], [14.99852, 50.86817], [15.01088, 50.97984], [14.96419, 50.99108], [15.02433, 51.0242], [15.03895, 51.0123], [15.06218, 51.02269], [15.10152, 51.01095], [15.11937, 50.99021], [15.16744, 51.01959], [15.1743, 50.9833], [15.2361, 50.99886], [15.27043, 50.97724], [15.2773, 50.8907], [15.36656, 50.83956], [15.3803, 50.77187], [15.43798, 50.80833], [15.73186, 50.73885], [15.81683, 50.75666], [15.87331, 50.67188], [15.97219, 50.69799], [16.0175, 50.63009], [15.98317, 50.61528], [16.02437, 50.60046], [16.10265, 50.66405], [16.20839, 50.63096], [16.23174, 50.67101], [16.33611, 50.66579], [16.44597, 50.58041], [16.34572, 50.49575], [16.31413, 50.50274], [16.19526, 50.43291], [16.21585, 50.40627], [16.22821, 50.41054], [16.28118, 50.36891], [16.30289, 50.38292], [16.36495, 50.37679], [16.3622, 50.34875], [16.39379, 50.3207], [16.42674, 50.32509], [16.56407, 50.21009], [16.55446, 50.16613], [16.63137, 50.1142], [16.7014, 50.09659], [16.8456, 50.20834], [16.98018, 50.24172], [17.00353, 50.21449], [17.02825, 50.23118], [16.99803, 50.25753], [17.02138, 50.27772], [16.99803, 50.30316], [16.94448, 50.31281], [16.90877, 50.38642], [16.85933, 50.41093], [16.89229, 50.45117], [17.1224, 50.39494], [17.14498, 50.38117], [17.19579, 50.38817], [17.19991, 50.3654], [17.27681, 50.32246], [17.34273, 50.32947], [17.34548, 50.2628], [17.3702, 50.28123], [17.58889, 50.27837], [17.67764, 50.28977], [17.69292, 50.32859], [17.74648, 50.29966], [17.72176, 50.25665], [17.76296, 50.23382], [17.70528, 50.18812], [17.59404, 50.16437], [17.66683, 50.10275], [17.6888, 50.12037], [17.7506, 50.07896], [17.77669, 50.02253], [17.86886, 49.97452], [18.00191, 50.01723], [18.04585, 50.01194], [18.04585, 50.03311], [18.00396, 50.04954], [18.03212, 50.06574], [18.07898, 50.04535], [18.10628, 50.00223], [18.20241, 49.99958], [18.21752, 49.97309], [18.27107, 49.96779], [18.27794, 49.93863], [18.31914, 49.91565], [18.33278, 49.92415], [18.33562, 49.94747], [18.41604, 49.93498], [18.53423, 49.89906], [18.54495, 49.9079], [18.54299, 49.92537], [18.57697, 49.91565], [18.57045, 49.87849], [18.60341, 49.86256], [18.57183, 49.83334], [18.61278, 49.7618], [18.61368, 49.75426], [18.62645, 49.75002], [18.62943, 49.74603], [18.62676, 49.71983], [18.69817, 49.70473], [18.72838, 49.68163], [18.80479, 49.6815], [18.84786, 49.5446], [18.84521, 49.51672], [18.94536, 49.52143], [18.97283, 49.49914], [18.9742, 49.39557], [19.18019, 49.41165], [19.25435, 49.53391], [19.36009, 49.53747], [19.37795, 49.574], [19.45348, 49.61583], [19.52626, 49.57311], [19.53313, 49.52856], [19.57845, 49.46077], [19.64162, 49.45184], [19.6375, 49.40897], [19.72127, 49.39288], [19.78581, 49.41701], [19.82237, 49.27806], [19.75286, 49.20751], [19.86409, 49.19316], [19.90529, 49.23532], [19.98494, 49.22904], [20.08238, 49.1813], [20.13738, 49.31685], [20.21977, 49.35265], [20.31453, 49.34817], [20.31728, 49.39914], [20.39939, 49.3896], [20.46422, 49.41612], [20.5631, 49.375], [20.61666, 49.41791], [20.72274, 49.41813], [20.77971, 49.35383], [20.9229, 49.29626], [20.98733, 49.30774], [21.09799, 49.37176], [21.041, 49.41791], [21.12477, 49.43666], [21.19756, 49.4054], [21.27858, 49.45988], [21.43376, 49.41433], [21.62328, 49.4447], [21.77983, 49.35443], [21.82927, 49.39467], [21.96385, 49.3437], [22.04427, 49.22136], [22.56155, 49.08865], [22.89122, 49.00725], [22.86336, 49.10513], [22.72009, 49.20288], [22.748, 49.32759], [22.69444, 49.49378], [22.64534, 49.53094], [22.78304, 49.65543], [22.80261, 49.69098], [22.83179, 49.69875], [22.99329, 49.84249], [23.28221, 50.0957], [23.67635, 50.33385], [23.71382, 50.38248], [23.79445, 50.40481], [23.99563, 50.41289], [24.03668, 50.44507], [24.07048, 50.5071], [24.0996, 50.60752], [24.0595, 50.71625], [23.95925, 50.79271], [23.99254, 50.83847], [24.0952, 50.83262], [24.14524, 50.86128], [24.04576, 50.90196], [23.92217, 51.00836], [23.90376, 51.07697], [23.80678, 51.18405], [23.63858, 51.32182], [23.69905, 51.40871], [23.62751, 51.50512], [23.56236, 51.53673], [23.57053, 51.55938], [23.53198, 51.74298], [23.62691, 51.78208], [23.61523, 51.92066], [23.68733, 51.9906], [23.64066, 52.07626], [23.61, 52.11264], [23.54314, 52.12148], [23.47859, 52.18215], [23.20071, 52.22848], [23.18196, 52.28812], [23.34141, 52.44845], [23.45112, 52.53774], [23.58296, 52.59868], [23.73615, 52.6149], [23.93763, 52.71332], [23.91805, 52.94016], [23.94689, 52.95919], [23.92184, 53.02079], [23.87548, 53.0831], [23.91393, 53.16469], [23.85657, 53.22923], [23.81995, 53.24131], [23.62004, 53.60942], [23.51284, 53.95052], [23.48261, 53.98855], [23.52702, 54.04622], [23.49196, 54.14764], [23.45223, 54.17775], [23.42418, 54.17911], [23.39525, 54.21672], [23.3494, 54.25155], [23.24656, 54.25701], [23.15938, 54.29894], [23.15526, 54.31076], [23.13905, 54.31567], [23.104, 54.29794], [23.04323, 54.31567], [23.05726, 54.34565], [22.99649, 54.35927], [23.00584, 54.38514], [22.83756, 54.40827], [22.79705, 54.36264], [21.41123, 54.32395], [20.63871, 54.3706], [19.8038, 54.44203], [19.64312, 54.45423], [18.57853, 55.25302]]]] } },
29178     { type: "Feature", properties: { iso1A2: "PM", iso1A3: "SPM", iso1N3: "666", wikidata: "Q34617", nameEn: "Saint Pierre and Miquelon", country: "FR", groups: ["EU", "Q1451600", "021", "003", "019", "UN"], callingCodes: ["508"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-56.72993, 46.65575], [-55.90758, 46.6223], [-56.27503, 47.39728], [-56.72993, 46.65575]]]] } },
29179     { type: "Feature", properties: { iso1A2: "PN", iso1A3: "PCN", iso1N3: "612", wikidata: "Q35672", nameEn: "Pitcairn Islands", country: "GB", groups: ["BOTS", "061", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-133.59543, -28.4709], [-122.0366, -24.55017], [-133.61511, -21.93325], [-133.59543, -28.4709]]]] } },
29180     { type: "Feature", properties: { iso1A2: "PR", iso1A3: "PRI", iso1N3: "630", wikidata: "Q1183", nameEn: "Puerto Rico", aliases: ["US-PR"], country: "US", groups: ["Q1352230", "029", "003", "419", "019", "UN"], roadSpeedUnit: "mph", callingCodes: ["1 787", "1 939"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-65.27974, 17.56928], [-65.02435, 18.73231], [-67.99519, 18.97186], [-68.23894, 17.84663], [-65.27974, 17.56928]]]] } },
29181     { type: "Feature", properties: { iso1A2: "PS", iso1A3: "PSE", iso1N3: "275", wikidata: "Q219060", nameEn: "Palestine" }, geometry: null },
29182     { type: "Feature", properties: { iso1A2: "PT", iso1A3: "PRT", iso1N3: "620", wikidata: "Q45", nameEn: "Portugal" }, geometry: null },
29183     { type: "Feature", properties: { iso1A2: "PW", iso1A3: "PLW", iso1N3: "585", wikidata: "Q695", nameEn: "Palau", groups: ["057", "009", "UN"], roadSpeedUnit: "mph", callingCodes: ["680"] }, geometry: { type: "MultiPolygon", coordinates: [[[[128.97621, 3.08804], [136.39296, 1.54187], [136.04605, 12.45908], [128.97621, 3.08804]]]] } },
29184     { type: "Feature", properties: { iso1A2: "PY", iso1A3: "PRY", iso1N3: "600", wikidata: "Q733", nameEn: "Paraguay", groups: ["005", "419", "019", "UN"], callingCodes: ["595"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-58.16225, -20.16193], [-58.23216, -19.80058], [-59.06965, -19.29148], [-60.00638, -19.2981], [-61.73723, -19.63958], [-61.93912, -20.10053], [-62.26883, -20.55311], [-62.2757, -21.06657], [-62.64455, -22.25091], [-62.51761, -22.37684], [-62.22768, -22.55807], [-61.9756, -23.0507], [-61.0782, -23.62932], [-60.99754, -23.80934], [-60.28163, -24.04436], [-60.03367, -24.00701], [-59.45482, -24.34787], [-59.33886, -24.49935], [-58.33055, -24.97099], [-58.25492, -24.92528], [-57.80821, -25.13863], [-57.57431, -25.47269], [-57.87176, -25.93604], [-58.1188, -26.16704], [-58.3198, -26.83443], [-58.65321, -27.14028], [-58.59549, -27.29973], [-58.04205, -27.2387], [-56.85337, -27.5165], [-56.18313, -27.29851], [-55.89195, -27.3467], [-55.74475, -27.44485], [-55.59094, -27.32444], [-55.62322, -27.1941], [-55.39611, -26.97679], [-55.25243, -26.93808], [-55.16948, -26.96068], [-55.06351, -26.80195], [-55.00584, -26.78754], [-54.80868, -26.55669], [-54.70732, -26.45099], [-54.69333, -26.37705], [-54.67359, -25.98607], [-54.60664, -25.9691], [-54.62063, -25.91213], [-54.59398, -25.59224], [-54.59509, -25.53696], [-54.60196, -25.48397], [-54.62033, -25.46026], [-54.4423, -25.13381], [-54.28207, -24.07305], [-54.32807, -24.01865], [-54.6238, -23.83078], [-55.02691, -23.97317], [-55.0518, -23.98666], [-55.12292, -23.99669], [-55.41784, -23.9657], [-55.44117, -23.9185], [-55.43585, -23.87157], [-55.5555, -23.28237], [-55.52288, -23.2595], [-55.5446, -23.22811], [-55.63849, -22.95122], [-55.62493, -22.62765], [-55.68742, -22.58407], [-55.6986, -22.56268], [-55.72366, -22.5519], [-55.741, -22.52018], [-55.74941, -22.46436], [-55.8331, -22.29008], [-56.23206, -22.25347], [-56.45893, -22.08072], [-56.5212, -22.11556], [-56.6508, -22.28387], [-57.98625, -22.09157], [-57.94642, -21.73799], [-57.88239, -21.6868], [-57.93492, -21.65505], [-57.84536, -20.93155], [-58.16225, -20.16193]]]] } },
29185     { type: "Feature", properties: { iso1A2: "QA", iso1A3: "QAT", iso1N3: "634", wikidata: "Q846", nameEn: "Qatar", groups: ["145", "142", "UN"], callingCodes: ["974"] }, geometry: { type: "MultiPolygon", coordinates: [[[[50.92992, 24.54396], [51.09638, 24.46907], [51.29972, 24.50747], [51.39468, 24.62785], [51.58834, 24.66608], [51.83108, 24.71675], [51.83682, 26.70231], [50.93865, 26.30758], [50.81266, 25.88946], [50.86149, 25.6965], [50.7801, 25.595], [50.80824, 25.54641], [50.57069, 25.57887], [50.8133, 24.74049], [50.92992, 24.54396]]]] } },
29186     { type: "Feature", properties: { iso1A2: "RE", iso1A3: "REU", iso1N3: "638", wikidata: "Q17070", nameEn: "R\xE9union", country: "FR", groups: ["Q3320166", "EU", "014", "202", "002", "UN"], callingCodes: ["262"] }, geometry: { type: "MultiPolygon", coordinates: [[[[53.37984, -21.23941], [56.73473, -21.9174], [56.62373, -20.2711], [53.37984, -21.23941]]]] } },
29187     { type: "Feature", properties: { iso1A2: "RO", iso1A3: "ROU", iso1N3: "642", wikidata: "Q218", nameEn: "Romania", groups: ["EU", "151", "150", "UN"], callingCodes: ["40"] }, geometry: { type: "MultiPolygon", coordinates: [[[[27.15622, 47.98538], [27.02985, 48.09083], [27.04118, 48.12522], [26.96119, 48.13003], [26.98042, 48.15752], [26.94265, 48.1969], [26.87708, 48.19919], [26.81161, 48.25049], [26.62823, 48.25804], [26.55202, 48.22445], [26.33504, 48.18418], [26.17711, 47.99246], [26.05901, 47.9897], [25.77723, 47.93919], [25.63878, 47.94924], [25.23778, 47.89403], [25.11144, 47.75203], [24.88896, 47.7234], [24.81893, 47.82031], [24.70632, 47.84428], [24.61994, 47.95062], [24.43578, 47.97131], [24.34926, 47.9244], [24.22566, 47.90231], [24.11281, 47.91487], [24.06466, 47.95317], [24.02999, 47.95087], [24.00801, 47.968], [23.98553, 47.96076], [23.96337, 47.96672], [23.94192, 47.94868], [23.89352, 47.94512], [23.8602, 47.9329], [23.80904, 47.98142], [23.75188, 47.99705], [23.66262, 47.98786], [23.63894, 48.00293], [23.5653, 48.00499], [23.52803, 48.01818], [23.4979, 47.96858], [23.33577, 48.0237], [23.27397, 48.08245], [23.15999, 48.12188], [23.1133, 48.08061], [23.08858, 48.00716], [23.0158, 47.99338], [22.92241, 48.02002], [22.94301, 47.96672], [22.89849, 47.95851], [22.77991, 47.87211], [22.76617, 47.8417], [22.67247, 47.7871], [22.46559, 47.76583], [22.41979, 47.7391], [22.31816, 47.76126], [22.00917, 47.50492], [22.03389, 47.42508], [22.01055, 47.37767], [21.94463, 47.38046], [21.78395, 47.11104], [21.648, 47.03902], [21.68645, 46.99595], [21.59581, 46.91628], [21.59307, 46.86935], [21.52028, 46.84118], [21.48935, 46.7577], [21.5151, 46.72147], [21.43926, 46.65109], [21.33214, 46.63035], [21.26929, 46.4993], [21.28061, 46.44941], [21.16872, 46.30118], [21.06572, 46.24897], [20.86797, 46.28884], [20.74574, 46.25467], [20.76085, 46.21002], [20.63863, 46.12728], [20.49718, 46.18721], [20.45377, 46.14405], [20.35573, 46.16629], [20.28324, 46.1438], [20.26068, 46.12332], [20.35862, 45.99356], [20.54818, 45.89939], [20.65645, 45.82801], [20.70069, 45.7493], [20.77416, 45.75601], [20.78446, 45.78522], [20.82364, 45.77738], [20.80361, 45.65875], [20.76798, 45.60969], [20.83321, 45.53567], [20.77217, 45.49788], [20.86026, 45.47295], [20.87948, 45.42743], [21.09894, 45.30144], [21.17612, 45.32566], [21.20392, 45.2677], [21.29398, 45.24148], [21.48278, 45.19557], [21.51299, 45.15345], [21.4505, 45.04294], [21.35855, 45.01941], [21.54938, 44.9327], [21.56328, 44.89502], [21.48202, 44.87199], [21.44013, 44.87613], [21.35643, 44.86364], [21.38802, 44.78133], [21.55007, 44.77304], [21.60019, 44.75208], [21.61942, 44.67059], [21.67504, 44.67107], [21.71692, 44.65349], [21.7795, 44.66165], [21.99364, 44.63395], [22.08016, 44.49844], [22.13234, 44.47444], [22.18315, 44.48179], [22.30844, 44.6619], [22.45301, 44.7194], [22.61917, 44.61489], [22.69196, 44.61587], [22.76749, 44.54446], [22.70981, 44.51852], [22.61368, 44.55719], [22.56493, 44.53419], [22.54021, 44.47836], [22.45436, 44.47258], [22.56012, 44.30712], [22.68166, 44.28206], [22.67173, 44.21564], [23.04988, 44.07694], [23.01674, 44.01946], [22.87873, 43.9844], [22.83753, 43.88055], [22.85314, 43.84452], [23.05288, 43.79494], [23.26772, 43.84843], [23.4507, 43.84936], [23.61687, 43.79289], [23.73978, 43.80627], [24.18149, 43.68218], [24.35364, 43.70211], [24.50264, 43.76314], [24.62281, 43.74082], [24.73542, 43.68523], [24.96682, 43.72693], [25.10718, 43.6831], [25.17144, 43.70261], [25.39528, 43.61866], [25.72792, 43.69263], [25.94911, 43.85745], [26.05584, 43.90925], [26.10115, 43.96908], [26.38764, 44.04356], [26.62712, 44.05698], [26.95141, 44.13555], [27.26845, 44.12602], [27.39757, 44.0141], [27.60834, 44.01206], [27.64542, 44.04958], [27.73468, 43.95326], [27.92008, 44.00761], [27.99558, 43.84193], [28.23293, 43.76], [29.24336, 43.70874], [30.04414, 45.08461], [29.69272, 45.19227], [29.65428, 45.25629], [29.68175, 45.26885], [29.59798, 45.38857], [29.42632, 45.44545], [29.24779, 45.43388], [28.96077, 45.33164], [28.94292, 45.28045], [28.81383, 45.3384], [28.78911, 45.24179], [28.71358, 45.22631], [28.5735, 45.24759], [28.34554, 45.32102], [28.28504, 45.43907], [28.21139, 45.46895], [28.18741, 45.47358], [28.08927, 45.6051], [28.16568, 45.6421], [28.13111, 45.92819], [28.08612, 46.01105], [28.13684, 46.18099], [28.10937, 46.22852], [28.19864, 46.31869], [28.18902, 46.35283], [28.25769, 46.43334], [28.22281, 46.50481], [28.24808, 46.64305], [28.12173, 46.82283], [28.09095, 46.97621], [27.81892, 47.1381], [27.73172, 47.29248], [27.68706, 47.28962], [27.60263, 47.32507], [27.55731, 47.46637], [27.47942, 47.48113], [27.3979, 47.59473], [27.32202, 47.64009], [27.25519, 47.71366], [27.29069, 47.73722], [27.1618, 47.92391], [27.15622, 47.98538]]]] } },
29188     { type: "Feature", properties: { iso1A2: "RS", iso1A3: "SRB", iso1N3: "688", wikidata: "Q403", nameEn: "Serbia", groups: ["039", "150", "UN"], callingCodes: ["381"] }, geometry: { type: "MultiPolygon", coordinates: [[[[19.66007, 46.19005], [19.56113, 46.16824], [19.52473, 46.1171], [19.28826, 45.99694], [19.14543, 45.9998], [19.10388, 46.04015], [19.0791, 45.96458], [19.01284, 45.96529], [18.99712, 45.93537], [18.81394, 45.91329], [18.85783, 45.85493], [18.90305, 45.71863], [18.96691, 45.66731], [18.88776, 45.57253], [18.94562, 45.53712], [19.07471, 45.53086], [19.08364, 45.48804], [18.99918, 45.49333], [18.97446, 45.37528], [19.10774, 45.29547], [19.28208, 45.23813], [19.41941, 45.23475], [19.43589, 45.17137], [19.19144, 45.17863], [19.14063, 45.12972], [19.07952, 45.14668], [19.1011, 45.01191], [19.05205, 44.97692], [19.15573, 44.95409], [19.06853, 44.89915], [19.02871, 44.92541], [18.98957, 44.90645], [19.01994, 44.85493], [19.18183, 44.92055], [19.36722, 44.88164], [19.32543, 44.74058], [19.26388, 44.65412], [19.16699, 44.52197], [19.13369, 44.52521], [19.12278, 44.50132], [19.14837, 44.45253], [19.14681, 44.41463], [19.11785, 44.40313], [19.10749, 44.39421], [19.10704, 44.38249], [19.10365, 44.37795], [19.10298, 44.36924], [19.11865, 44.36712], [19.1083, 44.3558], [19.11547, 44.34218], [19.13556, 44.338], [19.13332, 44.31492], [19.16741, 44.28648], [19.18328, 44.28383], [19.20508, 44.2917], [19.23306, 44.26097], [19.26945, 44.26957], [19.32464, 44.27185], [19.34773, 44.23244], [19.3588, 44.18353], [19.40927, 44.16722], [19.43905, 44.13088], [19.47338, 44.15034], [19.48386, 44.14332], [19.47321, 44.1193], [19.51167, 44.08158], [19.55999, 44.06894], [19.57467, 44.04716], [19.61991, 44.05254], [19.61836, 44.01464], [19.56498, 43.99922], [19.52515, 43.95573], [19.38439, 43.96611], [19.24363, 44.01502], [19.23465, 43.98764], [19.3986, 43.79668], [19.5176, 43.71403], [19.50455, 43.58385], [19.42696, 43.57987], [19.41941, 43.54056], [19.36653, 43.60921], [19.33426, 43.58833], [19.2553, 43.5938], [19.24774, 43.53061], [19.22807, 43.5264], [19.22229, 43.47926], [19.44315, 43.38846], [19.48171, 43.32644], [19.52962, 43.31623], [19.54598, 43.25158], [19.62661, 43.2286], [19.64063, 43.19027], [19.76918, 43.16044], [19.79255, 43.11951], [19.92576, 43.08539], [19.96549, 43.11098], [19.98887, 43.0538], [20.04729, 43.02732], [20.05431, 42.99571], [20.12325, 42.96237], [20.14896, 42.99058], [20.16415, 42.97177], [20.34528, 42.90676], [20.35692, 42.8335], [20.40594, 42.84853], [20.43734, 42.83157], [20.53484, 42.8885], [20.48692, 42.93208], [20.59929, 43.01067], [20.64557, 43.00826], [20.69515, 43.09641], [20.59929, 43.20492], [20.68688, 43.21335], [20.73811, 43.25068], [20.82145, 43.26769], [20.88685, 43.21697], [20.83727, 43.17842], [20.96287, 43.12416], [21.00749, 43.13984], [21.05378, 43.10707], [21.08952, 43.13471], [21.14465, 43.11089], [21.16734, 42.99694], [21.2041, 43.02277], [21.23877, 43.00848], [21.23534, 42.95523], [21.2719, 42.8994], [21.32974, 42.90424], [21.36941, 42.87397], [21.44047, 42.87276], [21.39045, 42.74888], [21.47498, 42.74695], [21.59154, 42.72643], [21.58755, 42.70418], [21.6626, 42.67813], [21.75025, 42.70125], [21.79413, 42.65923], [21.75672, 42.62695], [21.7327, 42.55041], [21.70522, 42.54176], [21.7035, 42.51899], [21.62556, 42.45106], [21.64209, 42.41081], [21.62887, 42.37664], [21.59029, 42.38042], [21.57021, 42.3647], [21.53467, 42.36809], [21.5264, 42.33634], [21.56772, 42.30946], [21.58992, 42.25915], [21.70111, 42.23789], [21.77176, 42.2648], [21.84654, 42.3247], [21.91595, 42.30392], [21.94405, 42.34669], [22.02908, 42.29848], [22.16384, 42.32103], [22.29605, 42.37477], [22.29275, 42.34913], [22.34773, 42.31725], [22.45919, 42.33822], [22.47498, 42.3915], [22.51961, 42.3991], [22.55669, 42.50144], [22.43983, 42.56851], [22.4997, 42.74144], [22.43309, 42.82057], [22.54302, 42.87774], [22.74826, 42.88701], [22.78397, 42.98253], [22.89521, 43.03625], [22.98104, 43.11199], [23.00806, 43.19279], [22.89727, 43.22417], [22.82036, 43.33665], [22.53397, 43.47225], [22.47582, 43.6558], [22.41043, 43.69566], [22.35558, 43.81281], [22.41449, 44.00514], [22.61688, 44.06534], [22.61711, 44.16938], [22.67173, 44.21564], [22.68166, 44.28206], [22.56012, 44.30712], [22.45436, 44.47258], [22.54021, 44.47836], [22.56493, 44.53419], [22.61368, 44.55719], [22.70981, 44.51852], [22.76749, 44.54446], [22.69196, 44.61587], [22.61917, 44.61489], [22.45301, 44.7194], [22.30844, 44.6619], [22.18315, 44.48179], [22.13234, 44.47444], [22.08016, 44.49844], [21.99364, 44.63395], [21.7795, 44.66165], [21.71692, 44.65349], [21.67504, 44.67107], [21.61942, 44.67059], [21.60019, 44.75208], [21.55007, 44.77304], [21.38802, 44.78133], [21.35643, 44.86364], [21.44013, 44.87613], [21.48202, 44.87199], [21.56328, 44.89502], [21.54938, 44.9327], [21.35855, 45.01941], [21.4505, 45.04294], [21.51299, 45.15345], [21.48278, 45.19557], [21.29398, 45.24148], [21.20392, 45.2677], [21.17612, 45.32566], [21.09894, 45.30144], [20.87948, 45.42743], [20.86026, 45.47295], [20.77217, 45.49788], [20.83321, 45.53567], [20.76798, 45.60969], [20.80361, 45.65875], [20.82364, 45.77738], [20.78446, 45.78522], [20.77416, 45.75601], [20.70069, 45.7493], [20.65645, 45.82801], [20.54818, 45.89939], [20.35862, 45.99356], [20.26068, 46.12332], [20.09713, 46.17315], [20.03533, 46.14509], [20.01816, 46.17696], [19.93508, 46.17553], [19.81491, 46.1313], [19.66007, 46.19005]]]] } },
29189     { type: "Feature", properties: { iso1A2: "RU", iso1A3: "RUS", iso1N3: "643", wikidata: "Q159", nameEn: "Russia" }, geometry: null },
29190     { type: "Feature", properties: { iso1A2: "RW", iso1A3: "RWA", iso1N3: "646", wikidata: "Q1037", nameEn: "Rwanda", groups: ["014", "202", "002", "UN"], callingCodes: ["250"] }, geometry: { type: "MultiPolygon", coordinates: [[[[30.47194, -1.0555], [30.35212, -1.06896], [30.16369, -1.34303], [29.912, -1.48269], [29.82657, -1.31187], [29.59061, -1.39016], [29.53062, -1.40499], [29.45038, -1.5054], [29.36322, -1.50887], [29.24323, -1.66826], [29.24458, -1.69663], [29.11847, -1.90576], [29.17562, -2.12278], [29.105, -2.27043], [29.00051, -2.29001], [28.95642, -2.37321], [28.89601, -2.37321], [28.86826, -2.41888], [28.86846, -2.44866], [28.89132, -2.47557], [28.89342, -2.49017], [28.88846, -2.50493], [28.87497, -2.50887], [28.86209, -2.5231], [28.86193, -2.53185], [28.87943, -2.55165], [28.89288, -2.55848], [28.90226, -2.62385], [28.89793, -2.66111], [28.94346, -2.69124], [29.00357, -2.70596], [29.04081, -2.7416], [29.0562, -2.58632], [29.32234, -2.6483], [29.36805, -2.82933], [29.88237, -2.75105], [29.95911, -2.33348], [30.14034, -2.43626], [30.42933, -2.31064], [30.54501, -2.41404], [30.83915, -2.35795], [30.89303, -2.08223], [30.80802, -1.91477], [30.84079, -1.64652], [30.71974, -1.43244], [30.57123, -1.33264], [30.50889, -1.16412], [30.45116, -1.10641], [30.47194, -1.0555]]]] } },
29191     { type: "Feature", properties: { iso1A2: "SA", iso1A3: "SAU", iso1N3: "682", wikidata: "Q851", nameEn: "Saudi Arabia", groups: ["145", "142", "UN"], callingCodes: ["966"] }, geometry: { type: "MultiPolygon", coordinates: [[[[40.01521, 32.05667], [39.29903, 32.23259], [38.99233, 31.99721], [36.99791, 31.50081], [37.99354, 30.49998], [37.66395, 30.33245], [37.4971, 29.99949], [36.75083, 29.86903], [36.50005, 29.49696], [36.07081, 29.18469], [34.8812, 29.36878], [34.4454, 27.91479], [37.8565, 22.00903], [39.63762, 18.37348], [40.99158, 15.81743], [42.15205, 16.40211], [42.76801, 16.40371], [42.94625, 16.39721], [42.94351, 16.49467], [42.97215, 16.51093], [43.11601, 16.53166], [43.15274, 16.67248], [43.22066, 16.65179], [43.21325, 16.74416], [43.25857, 16.75304], [43.26303, 16.79479], [43.24801, 16.80613], [43.22956, 16.80613], [43.22012, 16.83932], [43.18338, 16.84852], [43.1398, 16.90696], [43.19328, 16.94703], [43.1813, 16.98438], [43.18233, 17.02673], [43.23967, 17.03428], [43.17787, 17.14717], [43.20156, 17.25901], [43.32653, 17.31179], [43.22533, 17.38343], [43.29185, 17.53224], [43.43005, 17.56148], [43.70631, 17.35762], [44.50126, 17.47475], [46.31018, 17.20464], [46.76494, 17.29151], [47.00571, 16.94765], [47.48245, 17.10808], [47.58351, 17.50366], [48.19996, 18.20584], [49.04884, 18.59899], [52.00311, 19.00083], [54.99756, 20.00083], [55.66469, 21.99658], [55.2137, 22.71065], [55.13599, 22.63334], [52.56622, 22.94341], [51.59617, 24.12041], [51.58871, 24.27256], [51.41644, 24.39615], [51.58834, 24.66608], [51.39468, 24.62785], [51.29972, 24.50747], [51.09638, 24.46907], [50.92992, 24.54396], [50.8133, 24.74049], [50.57069, 25.57887], [50.302, 25.87592], [50.26923, 26.08243], [50.38162, 26.53976], [50.71771, 26.73086], [50.37726, 27.89227], [49.98877, 27.87827], [49.00421, 28.81495], [48.42991, 28.53628], [47.70561, 28.5221], [47.59863, 28.66798], [47.58376, 28.83382], [47.46202, 29.0014], [46.5527, 29.10283], [46.42415, 29.05947], [44.72255, 29.19736], [42.97796, 30.48295], [42.97601, 30.72204], [40.01521, 32.05667]]]] } },
29192     { type: "Feature", properties: { iso1A2: "SB", iso1A3: "SLB", iso1N3: "090", wikidata: "Q685", nameEn: "Solomon Islands", groups: ["054", "009", "UN"], driveSide: "left", callingCodes: ["677"] }, geometry: { type: "MultiPolygon", coordinates: [[[[172.71443, -12.01327], [160.43769, -4.17974], [156.03296, -6.55528], [156.03993, -6.65703], [155.92557, -6.84664], [155.69784, -6.92661], [155.60735, -6.92266], [154.74815, -7.33315], [156.73836, -14.50464], [172.71443, -12.01327]]]] } },
29193     { type: "Feature", properties: { iso1A2: "SC", iso1A3: "SYC", iso1N3: "690", wikidata: "Q1042", nameEn: "Seychelles", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["248"] }, geometry: { type: "MultiPolygon", coordinates: [[[[43.75112, -10.38913], [54.83239, -10.93575], [66.3222, 5.65313], [43.75112, -10.38913]]]] } },
29194     { type: "Feature", properties: { iso1A2: "SD", iso1A3: "SDN", iso1N3: "729", wikidata: "Q1049", nameEn: "Sudan", groups: ["015", "002", "UN"], callingCodes: ["249"] }, geometry: { type: "MultiPolygon", coordinates: [[[[37.8565, 22.00903], [34.0765, 22.00501], [33.99686, 21.76784], [33.57251, 21.72406], [33.17563, 22.00405], [24.99885, 21.99535], [24.99794, 19.99661], [23.99715, 20.00038], [23.99539, 19.49944], [23.99997, 15.69575], [23.62785, 15.7804], [23.38812, 15.69649], [23.10792, 15.71297], [22.93201, 15.55107], [22.92579, 15.47007], [22.99584, 15.40105], [22.99584, 15.22989], [22.66115, 14.86308], [22.70474, 14.69149], [22.38562, 14.58907], [22.44944, 14.24986], [22.55997, 14.23024], [22.5553, 14.11704], [22.22995, 13.96754], [22.08674, 13.77863], [22.29689, 13.3731], [22.1599, 13.19281], [22.02914, 13.13976], [21.94819, 13.05637], [21.81432, 12.81362], [21.89371, 12.68001], [21.98711, 12.63292], [22.15679, 12.66634], [22.22684, 12.74682], [22.46345, 12.61925], [22.38873, 12.45514], [22.50548, 12.16769], [22.48369, 12.02766], [22.64092, 12.07485], [22.54907, 11.64372], [22.7997, 11.40424], [22.93124, 11.41645], [22.97249, 11.21955], [22.87758, 10.91915], [23.02221, 10.69235], [23.3128, 10.45214], [23.67164, 9.86923], [23.69155, 9.67566], [24.09319, 9.66572], [24.12744, 9.73784], [24.49389, 9.79962], [24.84653, 9.80643], [24.97739, 9.9081], [25.05688, 10.06776], [25.0918, 10.33718], [25.78141, 10.42599], [25.93163, 10.38159], [25.93241, 10.17941], [26.21338, 9.91545], [26.35815, 9.57946], [26.70685, 9.48735], [27.14427, 9.62858], [27.90704, 9.61323], [28.99983, 9.67155], [29.06988, 9.74826], [29.53844, 9.75133], [29.54, 10.07949], [29.94629, 10.29245], [30.00389, 10.28633], [30.53005, 9.95992], [30.82893, 9.71451], [30.84605, 9.7498], [31.28504, 9.75287], [31.77539, 10.28939], [31.99177, 10.65065], [32.46967, 11.04662], [32.39358, 11.18207], [32.39578, 11.70208], [32.10079, 11.95203], [32.73921, 11.95203], [32.73921, 12.22757], [33.25876, 12.22111], [33.13988, 11.43248], [33.26977, 10.83632], [33.24645, 10.77913], [33.52294, 10.64382], [33.66604, 10.44254], [33.80913, 10.32994], [33.90159, 10.17179], [33.96984, 10.15446], [33.99185, 9.99623], [33.96323, 9.80972], [33.9082, 9.762], [33.87958, 9.49937], [34.10229, 9.50238], [34.08717, 9.55243], [34.13186, 9.7492], [34.20484, 9.9033], [34.22718, 10.02506], [34.32102, 10.11599], [34.34783, 10.23914], [34.2823, 10.53508], [34.4372, 10.781], [34.59062, 10.89072], [34.77383, 10.74588], [34.77532, 10.69027], [34.86618, 10.74588], [34.86916, 10.78832], [34.97491, 10.86147], [34.97789, 10.91559], [34.93172, 10.95946], [35.01215, 11.19626], [34.95704, 11.24448], [35.09556, 11.56278], [35.05832, 11.71158], [35.11492, 11.85156], [35.24302, 11.91132], [35.70476, 12.67101], [36.01458, 12.72478], [36.14268, 12.70879], [36.16651, 12.88019], [36.13374, 12.92665], [36.24545, 13.36759], [36.38993, 13.56459], [36.48824, 13.83954], [36.44653, 13.95666], [36.54376, 14.25597], [36.44337, 15.14963], [36.54276, 15.23478], [36.69761, 15.75323], [36.76371, 15.80831], [36.92193, 16.23451], [36.99777, 17.07172], [37.42694, 17.04041], [37.50967, 17.32199], [38.13362, 17.53906], [38.37133, 17.66269], [38.45916, 17.87167], [38.57727, 17.98125], [39.63762, 18.37348], [37.8565, 22.00903]]]] } },
29195     { type: "Feature", properties: { iso1A2: "SE", iso1A3: "SWE", iso1N3: "752", wikidata: "Q34", nameEn: "Sweden", groups: ["EU", "154", "150", "UN"], callingCodes: ["46"] }, geometry: { type: "MultiPolygon", coordinates: [[[[24.15791, 65.85385], [23.90497, 66.15802], [23.71339, 66.21299], [23.64982, 66.30603], [23.67591, 66.3862], [23.63776, 66.43568], [23.85959, 66.56434], [23.89488, 66.772], [23.98059, 66.79585], [23.98563, 66.84149], [23.56214, 67.17038], [23.58735, 67.20752], [23.54701, 67.25435], [23.75372, 67.29914], [23.75372, 67.43688], [23.39577, 67.46974], [23.54701, 67.59306], [23.45627, 67.85297], [23.65793, 67.9497], [23.40081, 68.05545], [23.26469, 68.15134], [23.15377, 68.14759], [23.10336, 68.26551], [22.73028, 68.40881], [22.00429, 68.50692], [21.03001, 68.88969], [20.90649, 68.89696], [20.85104, 68.93142], [20.91658, 68.96764], [20.78802, 69.03087], [20.55258, 69.06069], [20.0695, 69.04469], [20.28444, 68.93283], [20.33435, 68.80174], [20.22027, 68.67246], [19.95647, 68.55546], [20.22027, 68.48759], [19.93508, 68.35911], [18.97255, 68.52416], [18.63032, 68.50849], [18.39503, 68.58672], [18.1241, 68.53721], [18.13836, 68.20874], [17.90787, 67.96537], [17.30416, 68.11591], [16.7409, 67.91037], [16.38441, 67.52923], [16.12774, 67.52106], [16.09922, 67.4364], [16.39154, 67.21653], [16.35589, 67.06419], [15.37197, 66.48217], [15.49318, 66.28509], [15.05113, 66.15572], [14.53778, 66.12399], [14.50926, 65.31786], [13.64276, 64.58402], [14.11117, 64.46674], [14.16051, 64.18725], [13.98222, 64.00953], [13.23411, 64.09087], [12.74105, 64.02171], [12.14928, 63.59373], [12.19919, 63.47935], [11.98529, 63.27487], [12.19919, 63.00104], [12.07085, 62.6297], [12.29187, 62.25699], [12.14746, 61.7147], [12.40595, 61.57226], [12.57707, 61.56547], [12.86939, 61.35427], [12.69115, 61.06584], [12.2277, 61.02442], [12.59133, 60.50559], [12.52003, 60.13846], [12.36317, 59.99259], [12.15641, 59.8926], [11.87121, 59.86039], [11.92112, 59.69531], [11.69297, 59.59442], [11.8213, 59.24985], [11.65732, 58.90177], [11.45199, 58.89604], [11.4601, 58.99022], [11.34459, 59.11672], [11.15367, 59.07862], [11.08911, 58.98745], [10.64958, 58.89391], [10.40861, 58.38489], [12.16597, 56.60205], [12.07466, 56.29488], [12.65312, 56.04345], [12.6372, 55.91371], [12.88472, 55.63369], [12.60345, 55.42675], [12.84405, 55.13257], [14.28399, 55.1553], [14.89259, 55.5623], [15.79951, 55.54655], [19.64795, 57.06466], [19.84909, 57.57876], [20.5104, 59.15546], [19.08191, 60.19152], [19.23413, 60.61414], [20.15877, 63.06556], [24.14112, 65.39731], [24.15107, 65.81427], [24.14798, 65.83466], [24.15791, 65.85385]]]] } },
29196     { type: "Feature", properties: { iso1A2: "SG", iso1A3: "SGP", iso1N3: "702", wikidata: "Q334", nameEn: "Singapore", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["65"] }, geometry: { type: "MultiPolygon", coordinates: [[[[104.00131, 1.42405], [103.93384, 1.42926], [103.89565, 1.42841], [103.86383, 1.46288], [103.81181, 1.47953], [103.76395, 1.45183], [103.74161, 1.4502], [103.7219, 1.46108], [103.67468, 1.43166], [103.62738, 1.35255], [103.56591, 1.19719], [103.66049, 1.18825], [103.74084, 1.12902], [104.03085, 1.26954], [104.12282, 1.27714], [104.08072, 1.35998], [104.09162, 1.39694], [104.08871, 1.42015], [104.07348, 1.43322], [104.04622, 1.44691], [104.02277, 1.4438], [104.00131, 1.42405]]]] } },
29197     { type: "Feature", properties: { iso1A2: "SH", iso1A3: "SHN", iso1N3: "654", wikidata: "Q192184", nameEn: "Saint Helena, Ascension and Tristan da Cunha", country: "GB" }, geometry: null },
29198     { type: "Feature", properties: { iso1A2: "SI", iso1A3: "SVN", iso1N3: "705", wikidata: "Q215", nameEn: "Slovenia", groups: ["EU", "039", "150", "UN"], callingCodes: ["386"] }, geometry: { type: "MultiPolygon", coordinates: [[[[16.50139, 46.56684], [16.39217, 46.63673], [16.38594, 46.6549], [16.41863, 46.66238], [16.42641, 46.69228], [16.37816, 46.69975], [16.30966, 46.7787], [16.31303, 46.79838], [16.3408, 46.80641], [16.34547, 46.83836], [16.2941, 46.87137], [16.2365, 46.87775], [16.21892, 46.86961], [16.15711, 46.85434], [16.14365, 46.8547], [16.10983, 46.867], [16.05786, 46.83927], [15.99054, 46.82772], [15.99126, 46.78199], [15.98432, 46.74991], [15.99769, 46.7266], [16.02808, 46.71094], [16.04347, 46.68694], [16.04036, 46.6549], [15.99988, 46.67947], [15.98512, 46.68463], [15.94864, 46.68769], [15.87691, 46.7211], [15.8162, 46.71897], [15.78518, 46.70712], [15.76771, 46.69863], [15.73823, 46.70011], [15.72279, 46.69548], [15.69523, 46.69823], [15.67411, 46.70735], [15.6543, 46.70616], [15.6543, 46.69228], [15.6365, 46.6894], [15.63255, 46.68069], [15.62317, 46.67947], [15.59826, 46.68908], [15.54533, 46.66985], [15.55333, 46.64988], [15.54431, 46.6312], [15.46906, 46.61321], [15.45514, 46.63697], [15.41235, 46.65556], [15.23711, 46.63994], [15.14215, 46.66131], [15.01451, 46.641], [14.98024, 46.6009], [14.96002, 46.63459], [14.92283, 46.60848], [14.87129, 46.61], [14.86419, 46.59411], [14.83549, 46.56614], [14.81836, 46.51046], [14.72185, 46.49974], [14.66892, 46.44936], [14.5942, 46.43434], [14.56463, 46.37208], [14.52176, 46.42617], [14.45877, 46.41717], [14.42608, 46.44614], [14.314, 46.43327], [14.28326, 46.44315], [14.15989, 46.43327], [14.12097, 46.47724], [14.04002, 46.49117], [14.00422, 46.48474], [13.89837, 46.52331], [13.7148, 46.5222], [13.68684, 46.43881], [13.59777, 46.44137], [13.5763, 46.42613], [13.5763, 46.40915], [13.47019, 46.3621], [13.43418, 46.35992], [13.44808, 46.33507], [13.37671, 46.29668], [13.42218, 46.20758], [13.47587, 46.22725], [13.56114, 46.2054], [13.56682, 46.18703], [13.64451, 46.18966], [13.66472, 46.17392], [13.64053, 46.13587], [13.57072, 46.09022], [13.50104, 46.05986], [13.49568, 46.04839], [13.50998, 46.04498], [13.49702, 46.01832], [13.47474, 46.00546], [13.50104, 45.98078], [13.52963, 45.96588], [13.56759, 45.96991], [13.58903, 45.99009], [13.62074, 45.98388], [13.63458, 45.98947], [13.64307, 45.98326], [13.6329, 45.94894], [13.63815, 45.93607], [13.61931, 45.91782], [13.60857, 45.89907], [13.59565, 45.89446], [13.58644, 45.88173], [13.57563, 45.8425], [13.58858, 45.83503], [13.59784, 45.8072], [13.66986, 45.79955], [13.8235, 45.7176], [13.83332, 45.70855], [13.83422, 45.68703], [13.87933, 45.65207], [13.9191, 45.6322], [13.8695, 45.60835], [13.86771, 45.59898], [13.84106, 45.58185], [13.78445, 45.5825], [13.74587, 45.59811], [13.7198, 45.59352], [13.6076, 45.64761], [13.45644, 45.59464], [13.56979, 45.4895], [13.62902, 45.45898], [13.67398, 45.4436], [13.7785, 45.46787], [13.81742, 45.43729], [13.88124, 45.42637], [13.90771, 45.45149], [13.97309, 45.45258], [13.99488, 45.47551], [13.96063, 45.50825], [14.00578, 45.52352], [14.07116, 45.48752], [14.20348, 45.46896], [14.22371, 45.50388], [14.24239, 45.50607], [14.26611, 45.48239], [14.27681, 45.4902], [14.32487, 45.47142], [14.36693, 45.48642], [14.49769, 45.54424], [14.5008, 45.60852], [14.53816, 45.6205], [14.57397, 45.67165], [14.60977, 45.66403], [14.59576, 45.62812], [14.69694, 45.57366], [14.68605, 45.53006], [14.71718, 45.53442], [14.80124, 45.49515], [14.81992, 45.45913], [14.90554, 45.47769], [14.92266, 45.52788], [15.02385, 45.48533], [15.05187, 45.49079], [15.16862, 45.42309], [15.27758, 45.46678], [15.33051, 45.45258], [15.38188, 45.48752], [15.30249, 45.53224], [15.29837, 45.5841], [15.27747, 45.60504], [15.31027, 45.6303], [15.34695, 45.63382], [15.34214, 45.64702], [15.38952, 45.63682], [15.4057, 45.64727], [15.34919, 45.71623], [15.30872, 45.69014], [15.25423, 45.72275], [15.40836, 45.79491], [15.47531, 45.79802], [15.47325, 45.8253], [15.52234, 45.82195], [15.57952, 45.84953], [15.64185, 45.82915], [15.66662, 45.84085], [15.70411, 45.8465], [15.68232, 45.86819], [15.68383, 45.88867], [15.67967, 45.90455], [15.70636, 45.92116], [15.70327, 46.00015], [15.71246, 46.01196], [15.72977, 46.04682], [15.62317, 46.09103], [15.6083, 46.11992], [15.59909, 46.14761], [15.64904, 46.19229], [15.6434, 46.21396], [15.67395, 46.22478], [15.75436, 46.21969], [15.75479, 46.20336], [15.78817, 46.21719], [15.79284, 46.25811], [15.97965, 46.30652], [16.07616, 46.3463], [16.07314, 46.36458], [16.05065, 46.3833], [16.05281, 46.39141], [16.14859, 46.40547], [16.18824, 46.38282], [16.30233, 46.37837], [16.30162, 46.40437], [16.27329, 46.41467], [16.27398, 46.42875], [16.25124, 46.48067], [16.23961, 46.49653], [16.26759, 46.50566], [16.26733, 46.51505], [16.29793, 46.5121], [16.37193, 46.55008], [16.38771, 46.53608], [16.44036, 46.5171], [16.5007, 46.49644], [16.52604, 46.47831], [16.59527, 46.47524], [16.52604, 46.5051], [16.52885, 46.53303], [16.50139, 46.56684]]]] } },
29199     { type: "Feature", properties: { iso1A2: "SJ", iso1A3: "SJM", iso1N3: "744", wikidata: "Q842829", nameEn: "Svalbard and Jan Mayen", country: "NO" }, geometry: null },
29200     { type: "Feature", properties: { iso1A2: "SK", iso1A3: "SVK", iso1N3: "703", wikidata: "Q214", nameEn: "Slovakia", groups: ["EU", "151", "150", "UN"], callingCodes: ["421"] }, geometry: { type: "MultiPolygon", coordinates: [[[[19.82237, 49.27806], [19.78581, 49.41701], [19.72127, 49.39288], [19.6375, 49.40897], [19.64162, 49.45184], [19.57845, 49.46077], [19.53313, 49.52856], [19.52626, 49.57311], [19.45348, 49.61583], [19.37795, 49.574], [19.36009, 49.53747], [19.25435, 49.53391], [19.18019, 49.41165], [18.9742, 49.39557], [18.97283, 49.49914], [18.94536, 49.52143], [18.84521, 49.51672], [18.74761, 49.492], [18.67757, 49.50895], [18.6144, 49.49824], [18.57183, 49.51162], [18.53063, 49.49022], [18.54848, 49.47059], [18.44686, 49.39467], [18.4084, 49.40003], [18.4139, 49.36517], [18.36446, 49.3267], [18.18456, 49.28909], [18.15022, 49.24518], [18.1104, 49.08624], [18.06885, 49.03157], [17.91814, 49.01784], [17.87831, 48.92679], [17.77944, 48.92318], [17.73126, 48.87885], [17.7094, 48.86721], [17.5295, 48.81117], [17.45671, 48.85004], [17.3853, 48.80936], [17.29054, 48.85546], [17.19355, 48.87602], [17.11202, 48.82925], [17.00215, 48.70887], [16.93955, 48.60371], [16.94611, 48.53614], [16.85204, 48.44968], [16.8497, 48.38321], [16.83588, 48.3844], [16.83317, 48.38138], [16.84243, 48.35258], [16.90903, 48.32519], [16.89461, 48.31332], [16.97701, 48.17385], [17.02919, 48.13996], [17.05735, 48.14179], [17.09168, 48.09366], [17.07039, 48.0317], [17.16001, 48.00636], [17.23699, 48.02094], [17.71215, 47.7548], [18.02938, 47.75665], [18.29305, 47.73541], [18.56496, 47.76588], [18.66521, 47.76772], [18.74074, 47.8157], [18.8506, 47.82308], [18.76821, 47.87469], [18.76134, 47.97499], [18.82176, 48.04206], [19.01952, 48.07052], [19.23924, 48.0595], [19.28182, 48.08336], [19.47957, 48.09437], [19.52489, 48.19791], [19.63338, 48.25006], [19.92452, 48.1283], [20.24312, 48.2784], [20.29943, 48.26104], [20.5215, 48.53336], [20.83248, 48.5824], [21.11516, 48.49546], [21.44063, 48.58456], [21.6068, 48.50365], [21.67134, 48.3989], [21.72525, 48.34628], [21.8279, 48.33321], [21.83339, 48.36242], [22.14689, 48.4005], [22.16023, 48.56548], [22.21379, 48.6218], [22.34151, 48.68893], [22.42934, 48.92857], [22.48296, 48.99172], [22.54338, 49.01424], [22.56155, 49.08865], [22.04427, 49.22136], [21.96385, 49.3437], [21.82927, 49.39467], [21.77983, 49.35443], [21.62328, 49.4447], [21.43376, 49.41433], [21.27858, 49.45988], [21.19756, 49.4054], [21.12477, 49.43666], [21.041, 49.41791], [21.09799, 49.37176], [20.98733, 49.30774], [20.9229, 49.29626], [20.77971, 49.35383], [20.72274, 49.41813], [20.61666, 49.41791], [20.5631, 49.375], [20.46422, 49.41612], [20.39939, 49.3896], [20.31728, 49.39914], [20.31453, 49.34817], [20.21977, 49.35265], [20.13738, 49.31685], [20.08238, 49.1813], [19.98494, 49.22904], [19.90529, 49.23532], [19.86409, 49.19316], [19.75286, 49.20751], [19.82237, 49.27806]]]] } },
29201     { type: "Feature", properties: { iso1A2: "SL", iso1A3: "SLE", iso1N3: "694", wikidata: "Q1044", nameEn: "Sierra Leone", groups: ["011", "202", "002", "UN"], callingCodes: ["232"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-10.27575, 8.48711], [-10.37257, 8.48941], [-10.54891, 8.31174], [-10.63934, 8.35326], [-10.70565, 8.29235], [-10.61422, 8.5314], [-10.47707, 8.67669], [-10.56197, 8.81225], [-10.5783, 9.06386], [-10.74484, 9.07998], [-10.6534, 9.29919], [-11.2118, 10.00098], [-11.89624, 9.99763], [-11.91023, 9.93927], [-12.12634, 9.87203], [-12.24262, 9.92386], [-12.47254, 9.86834], [-12.76788, 9.3133], [-12.94095, 9.26335], [-13.08953, 9.0409], [-13.18586, 9.0925], [-13.29911, 9.04245], [-14.36218, 8.64107], [-12.15048, 6.15992], [-11.50429, 6.92704], [-11.4027, 6.97746], [-11.29417, 7.21576], [-10.60422, 7.7739], [-10.60492, 8.04072], [-10.57523, 8.04829], [-10.51554, 8.1393], [-10.45023, 8.15627], [-10.35227, 8.15223], [-10.29839, 8.21283], [-10.31635, 8.28554], [-10.30084, 8.30008], [-10.27575, 8.48711]]]] } },
29202     { type: "Feature", properties: { iso1A2: "SM", iso1A3: "SMR", iso1N3: "674", wikidata: "Q238", nameEn: "San Marino", groups: ["039", "150", "UN"], callingCodes: ["378"] }, geometry: { type: "MultiPolygon", coordinates: [[[[12.45648, 43.89369], [12.48771, 43.89706], [12.49429, 43.90973], [12.49247, 43.91774], [12.49724, 43.92248], [12.50269, 43.92363], [12.50496, 43.93017], [12.51553, 43.94096], [12.51427, 43.94897], [12.50655, 43.95796], [12.50875, 43.96198], [12.50622, 43.97131], [12.51109, 43.97201], [12.51064, 43.98165], [12.5154, 43.98508], [12.51463, 43.99122], [12.50678, 43.99113], [12.49406, 43.98492], [12.47853, 43.98052], [12.46205, 43.97463], [12.44684, 43.96597], [12.43662, 43.95698], [12.42005, 43.9578], [12.41414, 43.95273], [12.40415, 43.95485], [12.40506, 43.94325], [12.41165, 43.93769], [12.41551, 43.92984], [12.40733, 43.92379], [12.41233, 43.90956], [12.40935, 43.9024], [12.41641, 43.89991], [12.44184, 43.90498], [12.45648, 43.89369]]]] } },
29203     { type: "Feature", properties: { iso1A2: "SN", iso1A3: "SEN", iso1N3: "686", wikidata: "Q1041", nameEn: "Senegal", groups: ["011", "202", "002", "UN"], callingCodes: ["221"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-14.32144, 16.61495], [-15.00557, 16.64997], [-15.6509, 16.50315], [-16.27016, 16.51565], [-16.4429, 16.20605], [-16.44814, 16.09753], [-16.48967, 16.0496], [-16.50854, 16.09032], [-17.15288, 16.07139], [-18.35085, 14.63444], [-17.43598, 13.59273], [-15.47902, 13.58758], [-15.36504, 13.79313], [-14.93719, 13.80173], [-14.34721, 13.46578], [-13.8955, 13.59126], [-13.79409, 13.34472], [-14.36795, 13.23033], [-15.14917, 13.57989], [-15.26908, 13.37768], [-15.80478, 13.34832], [-15.80355, 13.16729], [-16.69343, 13.16791], [-16.74676, 13.06025], [-17.43966, 13.04579], [-17.4623, 11.92379], [-16.70562, 12.34803], [-16.38191, 12.36449], [-16.20591, 12.46157], [-15.67302, 12.42974], [-15.17582, 12.6847], [-13.70523, 12.68013], [-13.05296, 12.64003], [-13.06603, 12.49342], [-12.87336, 12.51892], [-12.35415, 12.32758], [-11.91331, 12.42008], [-11.46267, 12.44559], [-11.37536, 12.40788], [-11.39935, 12.97808], [-11.63025, 13.39174], [-11.83345, 13.33333], [-12.06897, 13.71049], [-11.93043, 13.84505], [-12.23936, 14.76324], [-13.11029, 15.52116], [-13.43135, 16.09022], [-13.80075, 16.13961], [-14.32144, 16.61495]]]] } },
29204     { type: "Feature", properties: { iso1A2: "SO", iso1A3: "SOM", iso1N3: "706", wikidata: "Q1045", nameEn: "Somalia", groups: ["014", "202", "002", "UN"], callingCodes: ["252"] }, geometry: { type: "MultiPolygon", coordinates: [[[[51.12877, 12.56479], [43.90659, 12.3823], [42.95776, 10.98533], [42.69452, 10.62672], [42.87643, 10.18441], [43.0937, 9.90579], [43.23518, 9.84605], [43.32613, 9.59205], [44.19222, 8.93028], [46.99339, 7.9989], [47.92477, 8.00111], [47.97917, 8.00124], [44.98104, 4.91821], [44.02436, 4.9451], [43.40263, 4.79289], [43.04177, 4.57923], [42.97746, 4.44032], [42.84526, 4.28357], [42.55853, 4.20518], [42.07619, 4.17667], [41.89488, 3.97375], [41.31368, 3.14314], [40.98767, 2.82959], [41.00099, -0.83068], [41.56, -1.59812], [41.56362, -1.66375], [41.75542, -1.85308], [57.49095, 8.14549], [51.12877, 12.56479]]]] } },
29205     { type: "Feature", properties: { iso1A2: "SR", iso1A3: "SUR", iso1N3: "740", wikidata: "Q730", nameEn: "Suriname", groups: ["005", "419", "019", "UN"], driveSide: "left", callingCodes: ["597"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-54.26916, 5.26909], [-54.01877, 5.52789], [-54.01074, 5.68785], [-53.7094, 6.2264], [-56.84822, 6.73257], [-57.31629, 5.33714], [-57.22536, 5.15605], [-57.37442, 5.0208], [-57.8699, 4.89394], [-58.0307, 3.95513], [-57.35891, 3.32121], [-56.70519, 2.02964], [-56.55439, 2.02003], [-56.47045, 1.95135], [-55.99278, 1.83137], [-55.89863, 1.89861], [-55.92159, 2.05236], [-56.13054, 2.27723], [-55.96292, 2.53188], [-55.71493, 2.40342], [-55.01919, 2.564], [-54.6084, 2.32856], [-54.42864, 2.42442], [-54.28534, 2.67798], [-53.9849, 3.58697], [-53.98914, 3.627], [-54.05128, 3.63557], [-54.19367, 3.84387], [-54.38444, 4.13222], [-54.4717, 4.91964], [-54.26916, 5.26909]]]] } },
29206     { type: "Feature", properties: { iso1A2: "SS", iso1A3: "SSD", iso1N3: "728", wikidata: "Q958", nameEn: "South Sudan", groups: ["014", "202", "002", "UN"], callingCodes: ["211"] }, geometry: { type: "MultiPolygon", coordinates: [[[[34.10229, 9.50238], [33.87958, 9.49937], [33.9082, 9.762], [33.96323, 9.80972], [33.99185, 9.99623], [33.96984, 10.15446], [33.90159, 10.17179], [33.80913, 10.32994], [33.66604, 10.44254], [33.52294, 10.64382], [33.24645, 10.77913], [33.26977, 10.83632], [33.13988, 11.43248], [33.25876, 12.22111], [32.73921, 12.22757], [32.73921, 11.95203], [32.10079, 11.95203], [32.39578, 11.70208], [32.39358, 11.18207], [32.46967, 11.04662], [31.99177, 10.65065], [31.77539, 10.28939], [31.28504, 9.75287], [30.84605, 9.7498], [30.82893, 9.71451], [30.53005, 9.95992], [30.00389, 10.28633], [29.94629, 10.29245], [29.54, 10.07949], [29.53844, 9.75133], [29.06988, 9.74826], [28.99983, 9.67155], [27.90704, 9.61323], [27.14427, 9.62858], [26.70685, 9.48735], [26.35815, 9.57946], [26.21338, 9.91545], [25.93241, 10.17941], [25.93163, 10.38159], [25.78141, 10.42599], [25.0918, 10.33718], [25.05688, 10.06776], [24.97739, 9.9081], [24.84653, 9.80643], [24.49389, 9.79962], [24.12744, 9.73784], [24.09319, 9.66572], [23.69155, 9.67566], [23.62179, 9.53823], [23.64981, 9.44303], [23.64358, 9.28637], [23.56263, 9.19418], [23.4848, 9.16959], [23.44744, 8.99128], [23.59065, 8.99743], [23.51905, 8.71749], [24.25691, 8.69288], [24.13238, 8.36959], [24.35965, 8.26177], [24.85156, 8.16933], [24.98855, 7.96588], [25.25319, 7.8487], [25.29214, 7.66675], [25.20649, 7.61115], [25.20337, 7.50312], [25.35281, 7.42595], [25.37461, 7.33024], [25.90076, 7.09549], [26.38022, 6.63493], [26.32729, 6.36272], [26.58259, 6.1987], [26.51721, 6.09655], [27.22705, 5.71254], [27.22705, 5.62889], [27.28621, 5.56382], [27.23017, 5.37167], [27.26886, 5.25876], [27.44012, 5.07349], [27.56656, 4.89375], [27.65462, 4.89375], [27.76469, 4.79284], [27.79551, 4.59976], [28.20719, 4.35614], [28.6651, 4.42638], [28.8126, 4.48784], [29.03054, 4.48784], [29.22207, 4.34297], [29.43341, 4.50101], [29.49726, 4.7007], [29.82087, 4.56246], [29.79666, 4.37809], [30.06964, 4.13221], [30.1621, 4.10586], [30.22374, 3.93896], [30.27658, 3.95653], [30.47691, 3.83353], [30.55396, 3.84451], [30.57378, 3.74567], [30.56277, 3.62703], [30.78512, 3.67097], [30.80713, 3.60506], [30.85997, 3.5743], [30.85153, 3.48867], [30.97601, 3.693], [31.16666, 3.79853], [31.29476, 3.8015], [31.50478, 3.67814], [31.50776, 3.63652], [31.72075, 3.74354], [31.81459, 3.82083], [31.86821, 3.78664], [31.96205, 3.6499], [31.95907, 3.57408], [32.05187, 3.589], [32.08491, 3.56287], [32.08866, 3.53543], [32.19888, 3.50867], [32.20782, 3.6053], [32.41337, 3.748], [32.72021, 3.77327], [32.89746, 3.81339], [33.02852, 3.89296], [33.18356, 3.77812], [33.51264, 3.75068], [33.9873, 4.23316], [34.47601, 4.72162], [35.34151, 5.02364], [35.30992, 4.90402], [35.47843, 4.91872], [35.42366, 4.76969], [35.51424, 4.61643], [35.9419, 4.61933], [35.82118, 4.77382], [35.81968, 5.10757], [35.8576, 5.33413], [35.50792, 5.42431], [35.29938, 5.34042], [35.31188, 5.50106], [35.13058, 5.62118], [35.12611, 5.68937], [35.00546, 5.89387], [34.96227, 6.26415], [35.01738, 6.46991], [34.87736, 6.60161], [34.77459, 6.5957], [34.65096, 6.72589], [34.53776, 6.74808], [34.53925, 6.82794], [34.47669, 6.91076], [34.35753, 6.91963], [34.19369, 7.04382], [34.19369, 7.12807], [34.01495, 7.25664], [34.03878, 7.27437], [34.02984, 7.36449], [33.87642, 7.5491], [33.71407, 7.65983], [33.44745, 7.7543], [33.32531, 7.71297], [33.24637, 7.77939], [33.04944, 7.78989], [33.0006, 7.90333], [33.08401, 8.05822], [33.18083, 8.13047], [33.1853, 8.29264], [33.19721, 8.40317], [33.3119, 8.45474], [33.54575, 8.47094], [33.66938, 8.44442], [33.71407, 8.3678], [33.87195, 8.41938], [33.89579, 8.4842], [34.01346, 8.50041], [34.14453, 8.60204], [34.14304, 9.04654], [34.10229, 9.50238]]]] } },
29207     { type: "Feature", properties: { iso1A2: "ST", iso1A3: "STP", iso1N3: "678", wikidata: "Q1039", nameEn: "S\xE3o Tom\xE9 and Principe", groups: ["017", "202", "002", "UN"], callingCodes: ["239"] }, geometry: { type: "MultiPolygon", coordinates: [[[[4.34149, 1.91417], [6.6507, -0.28606], [7.9035, 1.92304], [4.34149, 1.91417]]]] } },
29208     { type: "Feature", properties: { iso1A2: "SV", iso1A3: "SLV", iso1N3: "222", wikidata: "Q792", nameEn: "El Salvador", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["503"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-89.34776, 14.43013], [-89.39028, 14.44561], [-89.57441, 14.41637], [-89.58814, 14.33165], [-89.50614, 14.26084], [-89.52397, 14.22628], [-89.61844, 14.21937], [-89.70756, 14.1537], [-89.75569, 14.07073], [-89.73251, 14.04133], [-89.76103, 14.02923], [-89.81807, 14.07073], [-89.88937, 14.0396], [-90.10505, 13.85104], [-90.11344, 13.73679], [-90.55276, 12.8866], [-88.11443, 12.63306], [-87.7346, 13.13228], [-87.55124, 13.12523], [-87.69751, 13.25228], [-87.73714, 13.32715], [-87.80177, 13.35689], [-87.84675, 13.41078], [-87.83467, 13.44655], [-87.77354, 13.45767], [-87.73841, 13.44169], [-87.72115, 13.46083], [-87.71657, 13.50577], [-87.78148, 13.52906], [-87.73106, 13.75443], [-87.68821, 13.80829], [-87.7966, 13.91353], [-88.00331, 13.86948], [-88.07641, 13.98447], [-88.23018, 13.99915], [-88.25791, 13.91108], [-88.48982, 13.86458], [-88.49738, 13.97224], [-88.70661, 14.04317], [-88.73182, 14.10919], [-88.815, 14.11652], [-88.85785, 14.17763], [-88.94608, 14.20207], [-89.04187, 14.33644], [-89.34776, 14.43013]]]] } },
29209     { type: "Feature", properties: { iso1A2: "SX", iso1A3: "SXM", iso1N3: "534", wikidata: "Q26273", nameEn: "Sint Maarten", aliases: ["NL-SX"], country: "NL", groups: ["Q1451600", "029", "003", "419", "019", "UN"], callingCodes: ["1 721"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.33064, 17.9615], [-63.1055, 17.86651], [-62.93924, 18.02904], [-63.02323, 18.05757], [-63.04039, 18.05619], [-63.0579, 18.06614], [-63.07759, 18.04943], [-63.09686, 18.04608], [-63.11042, 18.05339], [-63.13502, 18.05445], [-63.33064, 17.9615]]]] } },
29210     { type: "Feature", properties: { iso1A2: "SY", iso1A3: "SYR", iso1N3: "760", wikidata: "Q858", nameEn: "Syria", groups: ["145", "142", "UN"], callingCodes: ["963"] }, geometry: { type: "MultiPolygon", coordinates: [[[[42.23683, 37.2863], [42.21548, 37.28026], [42.20454, 37.28715], [42.22381, 37.30238], [42.22257, 37.31395], [42.2112, 37.32491], [42.19301, 37.31323], [42.18225, 37.28569], [42.00894, 37.17209], [41.515, 37.08084], [41.21937, 37.07665], [40.90856, 37.13147], [40.69136, 37.0996], [39.81589, 36.75538], [39.21538, 36.66834], [39.03217, 36.70911], [38.74042, 36.70629], [38.55908, 36.84429], [38.38859, 36.90064], [38.21064, 36.91842], [37.81974, 36.76055], [37.68048, 36.75065], [37.49103, 36.66904], [37.47253, 36.63243], [37.21988, 36.6736], [37.16177, 36.66069], [37.10894, 36.6704], [37.08279, 36.63495], [37.02088, 36.66422], [37.01647, 36.69512], [37.04619, 36.71101], [37.04399, 36.73483], [36.99886, 36.74012], [36.99557, 36.75997], [36.66727, 36.82901], [36.61581, 36.74629], [36.62681, 36.71189], [36.57398, 36.65186], [36.58829, 36.58295], [36.54206, 36.49539], [36.6081, 36.33772], [36.65653, 36.33861], [36.68672, 36.23677], [36.6125, 36.22592], [36.50463, 36.2419], [36.4617, 36.20461], [36.39206, 36.22088], [36.37474, 36.01163], [36.33956, 35.98687], [36.30099, 36.00985], [36.28338, 36.00273], [36.29769, 35.96086], [36.27678, 35.94839], [36.25366, 35.96264], [36.19973, 35.95195], [36.17441, 35.92076], [36.1623, 35.80925], [36.14029, 35.81015], [36.13919, 35.83692], [36.11827, 35.85923], [35.99829, 35.88242], [36.01844, 35.92403], [36.00514, 35.94113], [35.98499, 35.94107], [35.931, 35.92109], [35.51152, 36.10954], [35.48515, 34.70851], [35.97386, 34.63322], [35.98718, 34.64977], [36.29165, 34.62991], [36.32399, 34.69334], [36.35135, 34.68516], [36.35384, 34.65447], [36.42941, 34.62505], [36.46003, 34.6378], [36.45299, 34.59438], [36.41429, 34.61175], [36.39846, 34.55672], [36.3369, 34.52629], [36.34745, 34.5002], [36.4442, 34.50165], [36.46179, 34.46541], [36.55853, 34.41609], [36.53039, 34.3798], [36.56556, 34.31881], [36.60778, 34.31009], [36.58667, 34.27667], [36.59195, 34.2316], [36.62537, 34.20251], [36.5128, 34.09916], [36.50576, 34.05982], [36.41078, 34.05253], [36.28589, 33.91981], [36.38263, 33.86579], [36.3967, 33.83365], [36.14517, 33.85118], [36.06778, 33.82927], [35.9341, 33.6596], [36.05723, 33.57904], [35.94465, 33.52774], [35.94816, 33.47886], [35.88668, 33.43183], [35.82577, 33.40479], [35.81324, 33.36354], [35.77477, 33.33609], [35.813, 33.3172], [35.77513, 33.27342], [35.81295, 33.24841], [35.81647, 33.2028], [35.83846, 33.19397], [35.84285, 33.16673], [35.81911, 33.1336], [35.81911, 33.11077], [35.84802, 33.1031], [35.87188, 32.98028], [35.89298, 32.9456], [35.87012, 32.91976], [35.84021, 32.8725], [35.83758, 32.82817], [35.78745, 32.77938], [35.75983, 32.74803], [35.88405, 32.71321], [35.93307, 32.71966], [35.96633, 32.66237], [36.02239, 32.65911], [36.08074, 32.51463], [36.20379, 32.52751], [36.20875, 32.49529], [36.23948, 32.50108], [36.40959, 32.37908], [36.83946, 32.31293], [38.79171, 33.37328], [40.64314, 34.31604], [40.97676, 34.39788], [41.12388, 34.65742], [41.2345, 34.80049], [41.21654, 35.1508], [41.26569, 35.42708], [41.38184, 35.62502], [41.37027, 35.84095], [41.2564, 36.06012], [41.28864, 36.35368], [41.40058, 36.52502], [41.81736, 36.58782], [42.36697, 37.0627], [42.35724, 37.10998], [42.32313, 37.17814], [42.34735, 37.22548], [42.2824, 37.2798], [42.26039, 37.27017], [42.23683, 37.2863]]]] } },
29211     { type: "Feature", properties: { iso1A2: "SZ", iso1A3: "SWZ", iso1N3: "748", wikidata: "Q1050", nameEn: "Eswatini", aliases: ["Swaziland"], groups: ["018", "202", "002", "UN"], driveSide: "left", callingCodes: ["268"] }, geometry: { type: "MultiPolygon", coordinates: [[[[31.86881, -25.99973], [31.4175, -25.71886], [31.31237, -25.7431], [31.13073, -25.91558], [30.95819, -26.26303], [30.78927, -26.48271], [30.81101, -26.84722], [30.88826, -26.79622], [30.97757, -26.92706], [30.96088, -27.0245], [31.15027, -27.20151], [31.49834, -27.31549], [31.97592, -27.31675], [31.97463, -27.11057], [32.00893, -26.8096], [32.09664, -26.80721], [32.13315, -26.84345], [32.13409, -26.5317], [32.07352, -26.40185], [32.10435, -26.15656], [32.08599, -26.00978], [32.00916, -25.999], [31.974, -25.95387], [31.86881, -25.99973]]]] } },
29212     { type: "Feature", properties: { iso1A2: "TA", iso1A3: "TAA", wikidata: "Q220982", nameEn: "Tristan da Cunha", aliases: ["SH-TA"], country: "GB", groups: ["SH", "BOTS", "011", "202", "002", "UN"], isoStatus: "excRes", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["290 8", "44 20"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-13.38232, -34.07258], [-16.67337, -41.9188], [-5.88482, -41.4829], [-13.38232, -34.07258]]]] } },
29213     { type: "Feature", properties: { iso1A2: "TC", iso1A3: "TCA", iso1N3: "796", wikidata: "Q18221", nameEn: "Turks and Caicos Islands", country: "GB", groups: ["BOTS", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 649"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-71.70065, 25.7637], [-72.98446, 20.4801], [-69.80718, 21.35956], [-71.70065, 25.7637]]]] } },
29214     { type: "Feature", properties: { iso1A2: "TD", iso1A3: "TCD", iso1N3: "148", wikidata: "Q657", nameEn: "Chad", groups: ["017", "202", "002", "UN"], callingCodes: ["235"] }, geometry: { type: "MultiPolygon", coordinates: [[[[23.99539, 19.49944], [15.99566, 23.49639], [14.99751, 23.00539], [15.19692, 21.99339], [15.20213, 21.49365], [15.28332, 21.44557], [15.62515, 20.95395], [15.57248, 20.92138], [15.55382, 20.86507], [15.56004, 20.79488], [15.59841, 20.74039], [15.6721, 20.70069], [15.99632, 20.35364], [15.75098, 19.93002], [15.6032, 18.77402], [15.50373, 16.89649], [14.37425, 15.72591], [13.86301, 15.04043], [13.78991, 14.87519], [13.809, 14.72915], [13.67878, 14.64013], [13.68573, 14.55276], [13.48259, 14.46704], [13.47559, 14.40881], [13.6302, 13.71094], [14.08251, 13.0797], [14.46881, 13.08259], [14.56101, 12.91036], [14.55058, 12.78256], [14.83314, 12.62963], [14.90827, 12.3269], [14.89019, 12.16593], [14.96952, 12.0925], [15.00146, 12.1223], [15.0349, 12.10698], [15.05786, 12.0608], [15.04808, 11.8731], [15.11579, 11.79313], [15.06595, 11.71126], [15.13149, 11.5537], [15.0585, 11.40481], [15.10021, 11.04101], [15.04957, 11.02347], [15.09127, 10.87431], [15.06737, 10.80921], [15.15532, 10.62846], [15.14936, 10.53915], [15.23724, 10.47764], [15.30874, 10.31063], [15.50535, 10.1098], [15.68761, 9.99344], [15.41408, 9.92876], [15.24618, 9.99246], [15.14043, 9.99246], [15.05999, 9.94845], [14.95722, 9.97926], [14.80082, 9.93818], [14.4673, 10.00264], [14.20411, 10.00055], [14.1317, 9.82413], [14.01793, 9.73169], [13.97544, 9.6365], [14.37094, 9.2954], [14.35707, 9.19611], [14.83566, 8.80557], [15.09484, 8.65982], [15.20426, 8.50892], [15.50743, 7.79302], [15.59272, 7.7696], [15.56964, 7.58936], [15.49743, 7.52179], [15.73118, 7.52006], [15.79942, 7.44149], [16.40703, 7.68809], [16.41583, 7.77971], [16.58315, 7.88657], [16.59415, 7.76444], [16.658, 7.75353], [16.6668, 7.67281], [16.8143, 7.53971], [17.67288, 7.98905], [17.93926, 7.95853], [18.02731, 8.01085], [18.6085, 8.05009], [18.64153, 8.08714], [18.62612, 8.14163], [18.67455, 8.22226], [18.79783, 8.25929], [19.11044, 8.68172], [18.86388, 8.87971], [19.06421, 9.00367], [20.36748, 9.11019], [20.82979, 9.44696], [21.26348, 9.97642], [21.34934, 9.95907], [21.52766, 10.2105], [21.63553, 10.217], [21.71479, 10.29932], [21.72139, 10.64136], [22.45889, 11.00246], [22.87758, 10.91915], [22.97249, 11.21955], [22.93124, 11.41645], [22.7997, 11.40424], [22.54907, 11.64372], [22.64092, 12.07485], [22.48369, 12.02766], [22.50548, 12.16769], [22.38873, 12.45514], [22.46345, 12.61925], [22.22684, 12.74682], [22.15679, 12.66634], [21.98711, 12.63292], [21.89371, 12.68001], [21.81432, 12.81362], [21.94819, 13.05637], [22.02914, 13.13976], [22.1599, 13.19281], [22.29689, 13.3731], [22.08674, 13.77863], [22.22995, 13.96754], [22.5553, 14.11704], [22.55997, 14.23024], [22.44944, 14.24986], [22.38562, 14.58907], [22.70474, 14.69149], [22.66115, 14.86308], [22.99584, 15.22989], [22.99584, 15.40105], [22.92579, 15.47007], [22.93201, 15.55107], [23.10792, 15.71297], [23.38812, 15.69649], [23.62785, 15.7804], [23.99997, 15.69575], [23.99539, 19.49944]]]] } },
29215     { type: "Feature", properties: { iso1A2: "TF", iso1A3: "ATF", iso1N3: "260", wikidata: "Q129003", nameEn: "French Southern Territories", country: "FR", groups: ["EU", "UN"] }, geometry: null },
29216     { type: "Feature", properties: { iso1A2: "TG", iso1A3: "TGO", iso1N3: "768", wikidata: "Q945", nameEn: "Togo", groups: ["011", "202", "002", "UN"], callingCodes: ["228"] }, geometry: { type: "MultiPolygon", coordinates: [[[[0.50388, 11.01011], [-0.13493, 11.14075], [-0.14462, 11.10811], [-0.05733, 11.08628], [-0.0275, 11.11202], [-514e-5, 11.10763], [342e-5, 11.08317], [0.02395, 11.06229], [0.03355, 10.9807], [-63e-4, 10.96417], [-908e-5, 10.91644], [-0.02685, 10.8783], [-0.0228, 10.81916], [-0.07183, 10.76794], [-0.07327, 10.71845], [-0.09141, 10.7147], [-0.05945, 10.63458], [0.12886, 10.53149], [0.18846, 10.4096], [0.29453, 10.41546], [0.33028, 10.30408], [0.39584, 10.31112], [0.35293, 10.09412], [0.41371, 10.06361], [0.41252, 10.02018], [0.36366, 10.03309], [0.32075, 9.72781], [0.34816, 9.71607], [0.34816, 9.66907], [0.32313, 9.6491], [0.28261, 9.69022], [0.26712, 9.66437], [0.29334, 9.59387], [0.36008, 9.6256], [0.38153, 9.58682], [0.23851, 9.57389], [0.2409, 9.52335], [0.30406, 9.521], [0.31241, 9.50337], [0.2254, 9.47869], [0.25758, 9.42696], [0.33148, 9.44812], [0.36485, 9.49749], [0.49118, 9.48339], [0.56388, 9.40697], [0.45424, 9.04581], [0.52455, 8.87746], [0.37319, 8.75262], [0.47211, 8.59945], [0.64731, 8.48866], [0.73432, 8.29529], [0.63897, 8.25873], [0.5913, 8.19622], [0.61156, 8.18324], [0.6056, 8.13959], [0.58891, 8.12779], [0.62943, 7.85751], [0.58295, 7.62368], [0.51979, 7.58706], [0.52455, 7.45354], [0.57223, 7.39326], [0.62943, 7.41099], [0.65327, 7.31643], [0.59606, 7.01252], [0.52217, 6.9723], [0.52098, 6.94391], [0.56508, 6.92971], [0.52853, 6.82921], [0.57406, 6.80348], [0.58176, 6.76049], [0.6497, 6.73682], [0.63659, 6.63857], [0.74862, 6.56517], [0.71048, 6.53083], [0.89283, 6.33779], [0.99652, 6.33779], [1.03108, 6.24064], [1.05969, 6.22998], [1.09187, 6.17074], [1.19966, 6.17069], [1.19771, 6.11522], [1.27574, 5.93551], [1.67336, 6.02702], [1.62913, 6.24075], [1.79826, 6.28221], [1.76906, 6.43189], [1.58105, 6.68619], [1.61812, 6.74843], [1.55877, 6.99737], [1.64249, 6.99562], [1.61838, 9.0527], [1.5649, 9.16941], [1.41746, 9.3226], [1.33675, 9.54765], [1.36624, 9.5951], [1.35507, 9.99525], [0.77666, 10.37665], [0.80358, 10.71459], [0.8804, 10.803], [0.91245, 10.99597], [0.66104, 10.99964], [0.4958, 10.93269], [0.50521, 10.98035], [0.48852, 10.98561], [0.50388, 11.01011]]]] } },
29217     { type: "Feature", properties: { iso1A2: "TH", iso1A3: "THA", iso1N3: "764", wikidata: "Q869", nameEn: "Thailand", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["66"] }, geometry: { type: "MultiPolygon", coordinates: [[[[100.08404, 20.36626], [99.95721, 20.46301], [99.91616, 20.44986], [99.90499, 20.4487], [99.89692, 20.44789], [99.89301, 20.44311], [99.89168, 20.44548], [99.88451, 20.44596], [99.88211, 20.44488], [99.86383, 20.44371], [99.81096, 20.33687], [99.68255, 20.32077], [99.46008, 20.39673], [99.46077, 20.36198], [99.5569, 20.20676], [99.52943, 20.14811], [99.416, 20.08614], [99.20328, 20.12877], [99.0735, 20.10298], [98.98679, 19.7419], [98.83661, 19.80931], [98.56065, 19.67807], [98.51182, 19.71303], [98.24884, 19.67876], [98.13829, 19.78541], [98.03314, 19.80941], [98.04364, 19.65755], [97.84715, 19.55782], [97.88423, 19.5041], [97.78769, 19.39429], [97.84186, 19.29526], [97.78606, 19.26769], [97.84024, 19.22217], [97.83479, 19.09972], [97.73797, 19.04261], [97.73654, 18.9812], [97.66487, 18.9371], [97.73836, 18.88478], [97.76752, 18.58097], [97.5258, 18.4939], [97.36444, 18.57138], [97.34522, 18.54596], [97.50383, 18.26844], [97.56219, 18.33885], [97.64116, 18.29778], [97.60841, 18.23846], [97.73723, 17.97912], [97.66794, 17.88005], [97.76407, 17.71595], [97.91829, 17.54504], [98.11185, 17.36829], [98.10439, 17.33847], [98.34566, 17.04822], [98.39441, 17.06266], [98.52624, 16.89979], [98.49603, 16.8446], [98.53833, 16.81934], [98.46994, 16.73613], [98.50253, 16.7139], [98.49713, 16.69022], [98.51043, 16.70107], [98.51579, 16.69433], [98.51472, 16.68521], [98.51833, 16.676], [98.51113, 16.64503], [98.5695, 16.62826], [98.57912, 16.55983], [98.63817, 16.47424], [98.68074, 16.27068], [98.84485, 16.42354], [98.92656, 16.36425], [98.8376, 16.11706], [98.69585, 16.13353], [98.57019, 16.04578], [98.59853, 15.87197], [98.541, 15.65406], [98.58598, 15.46821], [98.56027, 15.33471], [98.4866, 15.39154], [98.39351, 15.34177], [98.41906, 15.27103], [98.40522, 15.25268], [98.30446, 15.30667], [98.22, 15.21327], [98.18821, 15.13125], [98.24874, 14.83013], [98.56762, 14.37701], [98.97356, 14.04868], [99.16695, 13.72621], [99.20617, 13.20575], [99.12225, 13.19847], [99.10646, 13.05804], [99.18748, 12.9898], [99.18905, 12.84799], [99.29254, 12.68921], [99.409, 12.60603], [99.47519, 12.1353], [99.56445, 12.14805], [99.53424, 12.02317], [99.64891, 11.82699], [99.64108, 11.78948], [99.5672, 11.62732], [99.47598, 11.62434], [99.39485, 11.3925], [99.31573, 11.32081], [99.32756, 11.28545], [99.06938, 10.94857], [99.02337, 10.97217], [98.99701, 10.92962], [99.0069, 10.85485], [98.86819, 10.78336], [98.78511, 10.68351], [98.77275, 10.62548], [98.81944, 10.52761], [98.7391, 10.31488], [98.55174, 9.92804], [98.52291, 9.92389], [98.47298, 9.95782], [98.33094, 9.91973], [98.12555, 9.44056], [97.63455, 9.60854], [97.19814, 8.18901], [99.31854, 5.99868], [99.50117, 6.44501], [99.91873, 6.50233], [100.0756, 6.4045], [100.12, 6.42105], [100.19511, 6.72559], [100.29651, 6.68439], [100.30828, 6.66462], [100.31618, 6.66781], [100.31884, 6.66423], [100.32671, 6.66526], [100.32607, 6.65933], [100.31929, 6.65413], [100.35413, 6.54932], [100.41152, 6.52299], [100.41791, 6.5189], [100.42351, 6.51762], [100.43027, 6.52389], [100.66986, 6.45086], [100.74361, 6.50811], [100.74822, 6.46231], [100.81045, 6.45086], [100.85884, 6.24929], [101.10313, 6.25617], [101.12618, 6.19431], [101.06165, 6.14161], [101.12388, 6.11411], [101.087, 5.9193], [101.02708, 5.91013], [100.98815, 5.79464], [101.14062, 5.61613], [101.25755, 5.71065], [101.25524, 5.78633], [101.58019, 5.93534], [101.69773, 5.75881], [101.75074, 5.79091], [101.80144, 5.74505], [101.89188, 5.8386], [101.91776, 5.84269], [101.92819, 5.85511], [101.94712, 5.98421], [101.9714, 6.00575], [101.97114, 6.01992], [101.99209, 6.04075], [102.01835, 6.05407], [102.09182, 6.14161], [102.07732, 6.193], [102.08127, 6.22679], [102.09086, 6.23546], [102.46318, 7.22462], [102.47649, 9.66162], [102.52395, 11.25257], [102.91449, 11.65512], [102.90973, 11.75613], [102.83957, 11.8519], [102.78427, 11.98746], [102.77026, 12.06815], [102.70176, 12.1686], [102.73134, 12.37091], [102.78116, 12.40284], [102.7796, 12.43781], [102.57567, 12.65358], [102.51963, 12.66117], [102.4994, 12.71736], [102.53053, 12.77506], [102.49335, 12.92711], [102.48694, 12.97537], [102.52275, 12.99813], [102.46011, 13.08057], [102.43422, 13.09061], [102.36146, 13.26006], [102.36001, 13.31142], [102.34611, 13.35618], [102.35692, 13.38274], [102.35563, 13.47307], [102.361, 13.50551], [102.33828, 13.55613], [102.36859, 13.57488], [102.44601, 13.5637], [102.5358, 13.56933], [102.57573, 13.60461], [102.62483, 13.60883], [102.58635, 13.6286], [102.5481, 13.6589], [102.56848, 13.69366], [102.72727, 13.77806], [102.77864, 13.93374], [102.91251, 14.01531], [102.93275, 14.19044], [103.16469, 14.33075], [103.39353, 14.35639], [103.53518, 14.42575], [103.71109, 14.4348], [103.70175, 14.38052], [103.93836, 14.3398], [104.27616, 14.39861], [104.55014, 14.36091], [104.69335, 14.42726], [104.97667, 14.38806], [105.02804, 14.23722], [105.08408, 14.20402], [105.14012, 14.23873], [105.17748, 14.34432], [105.20894, 14.34967], [105.43783, 14.43865], [105.53864, 14.55731], [105.5121, 14.80802], [105.61162, 15.00037], [105.46661, 15.13132], [105.58043, 15.32724], [105.50662, 15.32054], [105.4692, 15.33709], [105.47635, 15.3796], [105.58191, 15.41031], [105.60446, 15.53301], [105.61756, 15.68792], [105.46573, 15.74742], [105.42285, 15.76971], [105.37959, 15.84074], [105.34115, 15.92737], [105.38508, 15.987], [105.42001, 16.00657], [105.06204, 16.09792], [105.00262, 16.25627], [104.88057, 16.37311], [104.73349, 16.565], [104.76099, 16.69302], [104.7397, 16.81005], [104.76442, 16.84752], [104.7373, 16.91125], [104.73712, 17.01404], [104.80716, 17.19025], [104.80061, 17.39367], [104.69867, 17.53038], [104.45404, 17.66788], [104.35432, 17.82871], [104.2757, 17.86139], [104.21776, 17.99335], [104.10927, 18.10826], [104.06533, 18.21656], [103.97725, 18.33631], [103.93916, 18.33914], [103.85642, 18.28666], [103.82449, 18.33979], [103.699, 18.34125], [103.60957, 18.40528], [103.47773, 18.42841], [103.41044, 18.4486], [103.30977, 18.4341], [103.24779, 18.37807], [103.23818, 18.34875], [103.29757, 18.30475], [103.17093, 18.2618], [103.14994, 18.23172], [103.1493, 18.17799], [103.07343, 18.12351], [103.07823, 18.03833], [103.0566, 18.00144], [103.01998, 17.97095], [102.9912, 17.9949], [102.95812, 18.0054], [102.86323, 17.97531], [102.81988, 17.94233], [102.79044, 17.93612], [102.75954, 17.89561], [102.68538, 17.86653], [102.67543, 17.84529], [102.69946, 17.81686], [102.68194, 17.80151], [102.59485, 17.83537], [102.5896, 17.84889], [102.61432, 17.92273], [102.60971, 17.95411], [102.59234, 17.96127], [102.45523, 17.97106], [102.11359, 18.21532], [101.88485, 18.02474], [101.78087, 18.07559], [101.72294, 17.92867], [101.44667, 17.7392], [101.15108, 17.47586], [100.96541, 17.57926], [101.02185, 17.87637], [101.1793, 18.0544], [101.19118, 18.2125], [101.15108, 18.25624], [101.18227, 18.34367], [101.06047, 18.43247], [101.27585, 18.68875], [101.22832, 18.73377], [101.25803, 18.89545], [101.35606, 19.04716], [101.261, 19.12717], [101.24911, 19.33334], [101.20604, 19.35296], [101.21347, 19.46223], [101.26991, 19.48324], [101.26545, 19.59242], [101.08928, 19.59748], [100.90302, 19.61901], [100.77231, 19.48324], [100.64606, 19.55884], [100.58219, 19.49164], [100.49604, 19.53504], [100.398, 19.75047], [100.5094, 19.87904], [100.58808, 20.15791], [100.55218, 20.17741], [100.51052, 20.14928], [100.47567, 20.19133], [100.4537, 20.19971], [100.44992, 20.23644], [100.41473, 20.25625], [100.37439, 20.35156], [100.33383, 20.4028], [100.25769, 20.3992], [100.22076, 20.31598], [100.16668, 20.2986], [100.1712, 20.24324], [100.11785, 20.24787], [100.09337, 20.26293], [100.09999, 20.31614], [100.08404, 20.36626]]]] } },
29218     { type: "Feature", properties: { iso1A2: "TJ", iso1A3: "TJK", iso1N3: "762", wikidata: "Q863", nameEn: "Tajikistan", groups: ["143", "142", "UN"], callingCodes: ["992"] }, geometry: { type: "MultiPolygon", coordinates: [[[[70.45251, 41.04438], [70.38028, 41.02014], [70.36655, 40.90296], [69.69434, 40.62615], [69.59441, 40.70181], [69.53021, 40.77621], [69.38327, 40.7918], [69.32834, 40.70233], [69.3455, 40.57988], [69.2643, 40.57506], [69.21063, 40.54469], [69.27066, 40.49274], [69.28525, 40.41894], [69.30774, 40.36102], [69.33794, 40.34819], [69.32833, 40.29794], [69.30808, 40.2821], [69.24817, 40.30357], [69.25229, 40.26362], [69.30104, 40.24502], [69.30448, 40.18774], [69.2074, 40.21488], [69.15659, 40.2162], [69.04544, 40.22904], [68.85832, 40.20885], [68.84357, 40.18604], [68.79276, 40.17555], [68.77902, 40.20492], [68.5332, 40.14826], [68.52771, 40.11676], [68.62796, 40.07789], [69.01523, 40.15771], [69.01935, 40.11466], [68.96579, 40.06949], [68.84906, 40.04952], [68.93695, 39.91167], [68.88889, 39.87163], [68.63071, 39.85265], [68.61972, 39.68905], [68.54166, 39.53929], [68.12053, 39.56317], [67.70992, 39.66156], [67.62889, 39.60234], [67.44899, 39.57799], [67.46547, 39.53564], [67.39681, 39.52505], [67.46822, 39.46146], [67.45998, 39.315], [67.36522, 39.31287], [67.33226, 39.23739], [67.67833, 39.14479], [67.68915, 39.00775], [68.09704, 39.02589], [68.19743, 38.85985], [68.06948, 38.82115], [68.12877, 38.73677], [68.05598, 38.71641], [68.0807, 38.64136], [68.05873, 38.56087], [68.11366, 38.47169], [68.06274, 38.39435], [68.13289, 38.40822], [68.40343, 38.19484], [68.27159, 37.91477], [68.12635, 37.93], [67.81566, 37.43107], [67.8474, 37.31594], [67.78329, 37.1834], [67.7803, 37.08978], [67.87917, 37.0591], [68.02194, 36.91923], [68.18542, 37.02074], [68.27605, 37.00977], [68.29253, 37.10621], [68.41201, 37.10402], [68.41888, 37.13906], [68.61851, 37.19815], [68.6798, 37.27906], [68.81438, 37.23862], [68.80889, 37.32494], [68.91189, 37.26704], [68.88168, 37.33368], [68.96407, 37.32603], [69.03274, 37.25174], [69.25152, 37.09426], [69.39529, 37.16752], [69.45022, 37.23315], [69.36645, 37.40462], [69.44954, 37.4869], [69.51888, 37.5844], [69.80041, 37.5746], [69.84435, 37.60616], [69.93362, 37.61378], [69.95971, 37.5659], [70.15015, 37.52519], [70.28243, 37.66706], [70.27694, 37.81258], [70.1863, 37.84296], [70.17206, 37.93276], [70.4898, 38.12546], [70.54673, 38.24541], [70.60407, 38.28046], [70.61526, 38.34774], [70.64966, 38.34999], [70.69189, 38.37031], [70.6761, 38.39144], [70.67438, 38.40597], [70.69807, 38.41861], [70.72485, 38.4131], [70.75455, 38.4252], [70.77132, 38.45548], [70.78581, 38.45502], [70.78702, 38.45031], [70.79766, 38.44944], [70.80521, 38.44447], [70.81697, 38.44507], [70.82538, 38.45394], [70.84376, 38.44688], [70.88719, 38.46826], [70.92728, 38.43021], [70.98693, 38.48862], [71.03545, 38.44779], [71.0556, 38.40176], [71.09542, 38.42517], [71.10592, 38.42077], [71.10957, 38.40671], [71.1451, 38.40106], [71.21291, 38.32797], [71.33114, 38.30339], [71.33869, 38.27335], [71.37803, 38.25641], [71.36444, 38.15358], [71.29878, 38.04429], [71.28922, 38.01272], [71.27622, 37.99946], [71.27278, 37.96496], [71.24969, 37.93031], [71.2809, 37.91995], [71.296, 37.93403], [71.32871, 37.88564], [71.51565, 37.95349], [71.58843, 37.92425], [71.59255, 37.79956], [71.55752, 37.78677], [71.54324, 37.77104], [71.53053, 37.76534], [71.55234, 37.73209], [71.54186, 37.69691], [71.51972, 37.61945], [71.5065, 37.60912], [71.49693, 37.53527], [71.50616, 37.50733], [71.5256, 37.47971], [71.49612, 37.4279], [71.47685, 37.40281], [71.4862, 37.33405], [71.49821, 37.31975], [71.50674, 37.31502], [71.48536, 37.26017], [71.4824, 37.24921], [71.48339, 37.23937], [71.47386, 37.2269], [71.4555, 37.21418], [71.4494, 37.18137], [71.44127, 37.11856], [71.43097, 37.05855], [71.45578, 37.03094], [71.46923, 36.99925], [71.48481, 36.93218], [71.51502, 36.89128], [71.57195, 36.74943], [71.67083, 36.67346], [71.83229, 36.68084], [72.31676, 36.98115], [72.54095, 37.00007], [72.66381, 37.02014], [72.79693, 37.22222], [73.06884, 37.31729], [73.29633, 37.46495], [73.77197, 37.4417], [73.76647, 37.33913], [73.61129, 37.27469], [73.64974, 37.23643], [73.82552, 37.22659], [73.8564, 37.26158], [74.20308, 37.34208], [74.23339, 37.41116], [74.41055, 37.3948], [74.56161, 37.37734], [74.68383, 37.3948], [74.8294, 37.3435], [74.88887, 37.23275], [75.12328, 37.31839], [75.09719, 37.37297], [75.15899, 37.41443], [75.06011, 37.52779], [74.94338, 37.55501], [74.8912, 37.67576], [75.00935, 37.77486], [74.92416, 37.83428], [74.9063, 38.03033], [74.82665, 38.07359], [74.80331, 38.19889], [74.69894, 38.22155], [74.69619, 38.42947], [74.51217, 38.47034], [74.17022, 38.65504], [73.97933, 38.52945], [73.79806, 38.61106], [73.80656, 38.66449], [73.7033, 38.84782], [73.7445, 38.93867], [73.82964, 38.91517], [73.81728, 39.04007], [73.75823, 39.023], [73.60638, 39.24534], [73.54572, 39.27567], [73.55396, 39.3543], [73.5004, 39.38402], [73.59241, 39.40843], [73.59831, 39.46425], [73.45096, 39.46677], [73.31912, 39.38615], [73.18454, 39.35536], [72.85934, 39.35116], [72.62027, 39.39696], [72.33173, 39.33093], [72.23834, 39.17248], [72.17242, 39.2661], [72.09689, 39.26823], [72.04059, 39.36704], [71.90601, 39.27674], [71.79202, 39.27355], [71.7522, 39.32031], [71.80164, 39.40631], [71.76816, 39.45456], [71.62688, 39.44056], [71.5517, 39.45722], [71.55856, 39.57588], [71.49814, 39.61397], [71.08752, 39.50704], [71.06418, 39.41586], [70.7854, 39.38933], [70.64087, 39.58792], [70.44757, 39.60128], [70.2869, 39.53141], [70.11111, 39.58223], [69.87491, 39.53882], [69.68677, 39.59281], [69.3594, 39.52516], [69.26938, 39.8127], [69.35649, 40.01994], [69.43134, 39.98431], [69.43557, 39.92877], [69.53615, 39.93991], [69.5057, 40.03277], [69.53855, 40.0887], [69.53794, 40.11833], [69.55555, 40.12296], [69.57615, 40.10524], [69.64704, 40.12165], [69.67001, 40.10639], [70.01283, 40.23288], [70.58297, 40.00891], [70.57384, 39.99394], [70.47557, 39.93216], [70.55033, 39.96619], [70.58912, 39.95211], [70.65946, 39.9878], [70.65827, 40.0981], [70.7928, 40.12797], [70.80495, 40.16813], [70.9818, 40.22392], [70.8607, 40.217], [70.62342, 40.17396], [70.56394, 40.26421], [70.57149, 40.3442], [70.37511, 40.38605], [70.32626, 40.45174], [70.49871, 40.52503], [70.80009, 40.72825], [70.45251, 41.04438]]], [[[70.68112, 40.90612], [70.6158, 40.97661], [70.56077, 41.00642], [70.54223, 40.98787], [70.57501, 40.98941], [70.6721, 40.90555], [70.68112, 40.90612]]], [[[70.74189, 39.86319], [70.53651, 39.89155], [70.52631, 39.86989], [70.54998, 39.85137], [70.59667, 39.83542], [70.63105, 39.77923], [70.74189, 39.86319]]]] } },
29219     { type: "Feature", properties: { iso1A2: "TK", iso1A3: "TKL", iso1N3: "772", wikidata: "Q36823", nameEn: "Tokelau", country: "NZ", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["690"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-168.251, -9.44289], [-174.18635, -7.80441], [-174.17993, -10.13616], [-168.251, -9.44289]]]] } },
29220     { type: "Feature", properties: { iso1A2: "TL", iso1A3: "TLS", iso1N3: "626", wikidata: "Q574", nameEn: "East Timor", aliases: ["Timor-Leste", "TP"], groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["670"] }, geometry: { type: "MultiPolygon", coordinates: [[[[124.46701, -9.13002], [124.94011, -8.85617], [124.97742, -9.08128], [125.11764, -8.96359], [125.18632, -9.03142], [125.18907, -9.16434], [125.09434, -9.19669], [125.04044, -9.17093], [124.97892, -9.19281], [125.09025, -9.46406], [125.68138, -9.85176], [127.55165, -9.05052], [127.42116, -8.22471], [125.87691, -8.31789], [125.58506, -7.95311], [124.92337, -8.75859], [124.33472, -9.11416], [124.04628, -9.22671], [124.04286, -9.34243], [124.10539, -9.41206], [124.14517, -9.42324], [124.21247, -9.36904], [124.28115, -9.42189], [124.28115, -9.50453], [124.3535, -9.48493], [124.35258, -9.43002], [124.38554, -9.3582], [124.45971, -9.30263], [124.46701, -9.13002]]]] } },
29221     { type: "Feature", properties: { iso1A2: "TM", iso1A3: "TKM", iso1N3: "795", wikidata: "Q874", nameEn: "Turkmenistan", groups: ["143", "142", "UN"], callingCodes: ["993"] }, geometry: { type: "MultiPolygon", coordinates: [[[[60.5078, 41.21694], [60.06581, 41.4363], [60.18117, 41.60082], [60.06032, 41.76287], [60.08504, 41.80997], [60.33223, 41.75058], [59.95046, 41.97966], [60.0356, 42.01028], [60.04659, 42.08982], [59.96419, 42.1428], [60.00539, 42.212], [59.94633, 42.27655], [59.4341, 42.29738], [59.2955, 42.37064], [59.17317, 42.52248], [58.93422, 42.5407], [58.6266, 42.79314], [58.57991, 42.64988], [58.27504, 42.69632], [58.14321, 42.62159], [58.29427, 42.56497], [58.51674, 42.30348], [58.40688, 42.29535], [58.3492, 42.43335], [57.99214, 42.50021], [57.90975, 42.4374], [57.92897, 42.24047], [57.84932, 42.18555], [57.6296, 42.16519], [57.30275, 42.14076], [57.03633, 41.92043], [56.96218, 41.80383], [57.03359, 41.41777], [57.13796, 41.36625], [57.03423, 41.25435], [56.00314, 41.32584], [55.45471, 41.25609], [54.95182, 41.92424], [54.20635, 42.38477], [52.97575, 42.1308], [52.47884, 41.78034], [52.26048, 41.69249], [51.7708, 40.29239], [53.89734, 37.3464], [54.24565, 37.32047], [54.36211, 37.34912], [54.58664, 37.45809], [54.67247, 37.43532], [54.77822, 37.51597], [54.81804, 37.61285], [54.77684, 37.62264], [54.851, 37.75739], [55.13412, 37.94705], [55.44152, 38.08564], [55.76561, 38.12238], [55.97847, 38.08024], [56.33278, 38.08132], [56.32454, 38.18502], [56.43303, 38.26054], [56.62255, 38.24005], [56.73928, 38.27887], [57.03453, 38.18717], [57.21169, 38.28965], [57.37236, 38.09321], [57.35042, 37.98546], [57.79534, 37.89299], [58.21399, 37.77281], [58.22999, 37.6856], [58.39959, 37.63134], [58.47786, 37.6433], [58.5479, 37.70526], [58.6921, 37.64548], [58.9338, 37.67374], [59.22905, 37.51161], [59.33507, 37.53146], [59.39797, 37.47892], [59.39385, 37.34257], [59.55178, 37.13594], [59.74678, 37.12499], [60.00768, 37.04102], [60.34767, 36.63214], [61.14516, 36.64644], [61.18187, 36.55348], [61.1393, 36.38782], [61.22719, 36.12759], [61.12007, 35.95992], [61.22444, 35.92879], [61.26152, 35.80749], [61.22719, 35.67038], [61.27371, 35.61482], [61.58742, 35.43803], [61.77693, 35.41341], [61.97743, 35.4604], [62.05709, 35.43803], [62.15871, 35.33278], [62.29191, 35.25964], [62.29878, 35.13312], [62.48006, 35.28796], [62.62288, 35.22067], [62.74098, 35.25432], [62.90853, 35.37086], [63.0898, 35.43131], [63.12276, 35.53196], [63.10079, 35.63024], [63.23262, 35.67487], [63.10318, 35.81782], [63.12276, 35.86208], [63.29579, 35.85985], [63.53475, 35.90881], [63.56496, 35.95106], [63.98519, 36.03773], [64.05385, 36.10433], [64.43288, 36.24401], [64.57295, 36.34362], [64.62514, 36.44311], [64.61141, 36.6351], [64.97945, 37.21913], [65.51778, 37.23881], [65.64263, 37.34388], [65.64137, 37.45061], [65.72274, 37.55438], [66.30993, 37.32409], [66.55743, 37.35409], [66.52303, 37.39827], [66.65761, 37.45497], [66.52852, 37.58568], [66.53676, 37.80084], [66.67684, 37.96776], [66.56697, 38.0435], [66.41042, 38.02403], [66.24013, 38.16238], [65.83913, 38.25733], [65.55873, 38.29052], [64.32576, 38.98691], [64.19086, 38.95561], [63.70778, 39.22349], [63.6913, 39.27666], [62.43337, 39.98528], [62.34273, 40.43206], [62.11751, 40.58242], [61.87856, 41.12257], [61.4446, 41.29407], [61.39732, 41.19873], [61.33199, 41.14946], [61.22212, 41.14946], [61.03261, 41.25691], [60.5078, 41.21694]]]] } },
29222     { type: "Feature", properties: { iso1A2: "TN", iso1A3: "TUN", iso1N3: "788", wikidata: "Q948", nameEn: "Tunisia", groups: ["015", "002", "UN"], callingCodes: ["216"] }, geometry: { type: "MultiPolygon", coordinates: [[[[11.2718, 37.6713], [7.89009, 38.19924], [8.59123, 37.14286], [8.64044, 36.9401], [8.62972, 36.86499], [8.67706, 36.8364], [8.57613, 36.78062], [8.46537, 36.7706], [8.47609, 36.66607], [8.16167, 36.48817], [8.18936, 36.44939], [8.40731, 36.42208], [8.2626, 35.91733], [8.26472, 35.73669], [8.35371, 35.66373], [8.36086, 35.47774], [8.30329, 35.29884], [8.47318, 35.23376], [8.3555, 35.10007], [8.30727, 34.95378], [8.25189, 34.92009], [8.29655, 34.72798], [8.20482, 34.57575], [7.86264, 34.3987], [7.81242, 34.21841], [7.74207, 34.16492], [7.66174, 34.20167], [7.52851, 34.06493], [7.54088, 33.7726], [7.73687, 33.42114], [7.83028, 33.18851], [8.11433, 33.10175], [8.1179, 33.05086], [8.31895, 32.83483], [8.35999, 32.50101], [9.07483, 32.07865], [9.55544, 30.23971], [9.76848, 30.34366], [9.88152, 30.34074], [10.29516, 30.90337], [10.12239, 31.42098], [10.31364, 31.72648], [10.48497, 31.72956], [10.62788, 31.96629], [10.7315, 31.97235], [11.04234, 32.2145], [11.53898, 32.4138], [11.57828, 32.48013], [11.46037, 32.6307], [11.51549, 33.09826], [11.55852, 33.1409], [11.58941, 33.36891], [11.2718, 37.6713]]]] } },
29223     { type: "Feature", properties: { iso1A2: "TO", iso1A3: "TON", iso1N3: "776", wikidata: "Q678", nameEn: "Tonga", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["676"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-176.74538, -22.89767], [-180, -22.90585], [-180, -24.21376], [-173.10761, -24.19665], [-173.13438, -14.94228], [-176.76826, -14.95183], [-176.74538, -22.89767]]]] } },
29224     { type: "Feature", properties: { iso1A2: "TR", iso1A3: "TUR", iso1N3: "792", wikidata: "Q43", nameEn: "Turkey", groups: ["145", "142", "UN"], callingCodes: ["90"] }, geometry: { type: "MultiPolygon", coordinates: [[[[41.54366, 41.52185], [40.89217, 41.72528], [34.8305, 42.4581], [28.32297, 41.98371], [28.02971, 41.98066], [27.91479, 41.97902], [27.83492, 41.99709], [27.81235, 41.94803], [27.69949, 41.97515], [27.55191, 41.90928], [27.52379, 41.93756], [27.45478, 41.96591], [27.27411, 42.10409], [27.22376, 42.10152], [27.19251, 42.06028], [27.08486, 42.08735], [27.03277, 42.0809], [26.95638, 42.00741], [26.79143, 41.97386], [26.62996, 41.97644], [26.56051, 41.92995], [26.57961, 41.90024], [26.53968, 41.82653], [26.36952, 41.82265], [26.33589, 41.76802], [26.32952, 41.73637], [26.35957, 41.71149], [26.47958, 41.67037], [26.5209, 41.62592], [26.59196, 41.60491], [26.59742, 41.48058], [26.61767, 41.42281], [26.62997, 41.34613], [26.5837, 41.32131], [26.5209, 41.33993], [26.39861, 41.25053], [26.32259, 41.24929], [26.31928, 41.07386], [26.3606, 41.02027], [26.33297, 40.98388], [26.35894, 40.94292], [26.32259, 40.94042], [26.28623, 40.93005], [26.29441, 40.89119], [26.26169, 40.9168], [26.20856, 40.86048], [26.21351, 40.83298], [26.15685, 40.80709], [26.12854, 40.77339], [26.12495, 40.74283], [26.08638, 40.73214], [26.0754, 40.72772], [26.03489, 40.73051], [25.94795, 40.72797], [26.04292, 40.3958], [25.61285, 40.17161], [25.94257, 39.39358], [26.43357, 39.43096], [26.70773, 39.0312], [26.61814, 38.81372], [26.21136, 38.65436], [26.32173, 38.48731], [26.24183, 38.44695], [26.21136, 38.17558], [27.05537, 37.9131], [27.16428, 37.72343], [26.99377, 37.69034], [26.95583, 37.64989], [27.14757, 37.32], [27.20312, 36.94571], [27.45627, 36.9008], [27.24613, 36.71622], [27.46117, 36.53789], [27.89482, 36.69898], [27.95037, 36.46155], [28.23708, 36.56812], [29.30783, 36.01033], [29.48192, 36.18377], [29.61002, 36.1731], [29.61805, 36.14179], [29.69611, 36.10365], [29.73302, 35.92555], [32.82353, 35.70297], [35.51152, 36.10954], [35.931, 35.92109], [35.98499, 35.94107], [36.00514, 35.94113], [36.01844, 35.92403], [35.99829, 35.88242], [36.11827, 35.85923], [36.13919, 35.83692], [36.14029, 35.81015], [36.1623, 35.80925], [36.17441, 35.92076], [36.19973, 35.95195], [36.25366, 35.96264], [36.27678, 35.94839], [36.29769, 35.96086], [36.28338, 36.00273], [36.30099, 36.00985], [36.33956, 35.98687], [36.37474, 36.01163], [36.39206, 36.22088], [36.4617, 36.20461], [36.50463, 36.2419], [36.6125, 36.22592], [36.68672, 36.23677], [36.65653, 36.33861], [36.6081, 36.33772], [36.54206, 36.49539], [36.58829, 36.58295], [36.57398, 36.65186], [36.62681, 36.71189], [36.61581, 36.74629], [36.66727, 36.82901], [36.99557, 36.75997], [36.99886, 36.74012], [37.04399, 36.73483], [37.04619, 36.71101], [37.01647, 36.69512], [37.02088, 36.66422], [37.08279, 36.63495], [37.10894, 36.6704], [37.16177, 36.66069], [37.21988, 36.6736], [37.47253, 36.63243], [37.49103, 36.66904], [37.68048, 36.75065], [37.81974, 36.76055], [38.21064, 36.91842], [38.38859, 36.90064], [38.55908, 36.84429], [38.74042, 36.70629], [39.03217, 36.70911], [39.21538, 36.66834], [39.81589, 36.75538], [40.69136, 37.0996], [40.90856, 37.13147], [41.21937, 37.07665], [41.515, 37.08084], [42.00894, 37.17209], [42.18225, 37.28569], [42.19301, 37.31323], [42.2112, 37.32491], [42.22257, 37.31395], [42.22381, 37.30238], [42.20454, 37.28715], [42.21548, 37.28026], [42.23683, 37.2863], [42.26039, 37.27017], [42.2824, 37.2798], [42.34735, 37.22548], [42.32313, 37.17814], [42.35724, 37.10998], [42.56725, 37.14878], [42.78887, 37.38615], [42.93705, 37.32015], [43.11403, 37.37436], [43.30083, 37.30629], [43.33508, 37.33105], [43.50787, 37.24436], [43.56702, 37.25675], [43.63085, 37.21957], [43.7009, 37.23692], [43.8052, 37.22825], [43.82699, 37.19477], [43.84878, 37.22205], [43.90949, 37.22453], [44.02002, 37.33229], [44.13521, 37.32486], [44.2613, 37.25055], [44.27998, 37.16501], [44.22239, 37.15756], [44.18503, 37.09551], [44.25975, 36.98119], [44.30645, 36.97373], [44.35937, 37.02843], [44.35315, 37.04955], [44.38117, 37.05825], [44.42631, 37.05825], [44.63179, 37.19229], [44.76698, 37.16162], [44.78319, 37.1431], [44.7868, 37.16644], [44.75986, 37.21549], [44.81021, 37.2915], [44.58449, 37.45018], [44.61401, 37.60165], [44.56887, 37.6429], [44.62096, 37.71985], [44.55498, 37.783], [44.45948, 37.77065], [44.3883, 37.85433], [44.22509, 37.88859], [44.42476, 38.25763], [44.50115, 38.33939], [44.44386, 38.38295], [44.38309, 38.36117], [44.3119, 38.37887], [44.3207, 38.49799], [44.32058, 38.62752], [44.28065, 38.6465], [44.26155, 38.71427], [44.30322, 38.81581], [44.18863, 38.93881], [44.20946, 39.13975], [44.1043, 39.19842], [44.03667, 39.39223], [44.22452, 39.4169], [44.29818, 39.378], [44.37921, 39.4131], [44.42832, 39.4131], [44.41849, 39.56659], [44.48111, 39.61579], [44.47298, 39.68788], [44.6137, 39.78393], [44.65422, 39.72163], [44.71806, 39.71124], [44.81043, 39.62677], [44.80977, 39.65768], [44.75779, 39.7148], [44.61845, 39.8281], [44.46635, 39.97733], [44.26973, 40.04866], [44.1778, 40.02845], [44.1057, 40.03555], [43.92307, 40.01787], [43.65688, 40.11199], [43.65221, 40.14889], [43.71136, 40.16673], [43.59928, 40.34019], [43.60862, 40.43267], [43.54791, 40.47413], [43.63664, 40.54159], [43.7425, 40.66805], [43.74872, 40.7365], [43.67712, 40.84846], [43.67712, 40.93084], [43.58683, 40.98961], [43.47319, 41.02251], [43.44984, 41.0988], [43.4717, 41.12611], [43.44973, 41.17666], [43.36118, 41.2028], [43.23096, 41.17536], [43.1945, 41.25242], [43.13373, 41.25503], [43.21707, 41.30331], [43.02956, 41.37891], [42.8785, 41.50516], [42.84899, 41.47265], [42.78995, 41.50126], [42.84471, 41.58912], [42.72794, 41.59714], [42.59202, 41.58183], [42.51772, 41.43606], [42.26387, 41.49346], [41.95134, 41.52466], [41.81939, 41.43621], [41.7124, 41.47417], [41.7148, 41.4932], [41.54366, 41.52185]]]] } },
29225     { type: "Feature", properties: { iso1A2: "TT", iso1A3: "TTO", iso1N3: "780", wikidata: "Q754", nameEn: "Trinidad and Tobago", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", callingCodes: ["1 868"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-61.62505, 11.18974], [-62.08693, 10.04435], [-60.89962, 9.81445], [-60.07172, 11.77667], [-61.62505, 11.18974]]]] } },
29226     { type: "Feature", properties: { iso1A2: "TV", iso1A3: "TUV", iso1N3: "798", wikidata: "Q672", nameEn: "Tuvalu", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["688"] }, geometry: { type: "MultiPolygon", coordinates: [[[[174, -5], [174, -11.5], [179.99999, -11.5], [179.99999, -5], [174, -5]]]] } },
29227     { type: "Feature", properties: { iso1A2: "TW", iso1A3: "TWN", iso1N3: "158", wikidata: "Q865", nameEn: "Taiwan", aliases: ["RC"], groups: ["030", "142"], callingCodes: ["886"] }, geometry: { type: "MultiPolygon", coordinates: [[[[121.8109, 21.77688], [122.26612, 25.98197], [120.5128, 26.536], [120.0693, 26.3959], [119.78816, 26.2348], [119.98511, 25.37624], [119.42295, 25.0886], [118.6333, 24.46259], [118.42453, 24.54644], [118.35291, 24.51645], [118.28244, 24.51231], [118.11703, 24.39734], [120.69238, 21.52331], [121.8109, 21.77688]]]] } },
29228     { type: "Feature", properties: { iso1A2: "TZ", iso1A3: "TZA", iso1N3: "834", wikidata: "Q924", nameEn: "Tanzania", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["255"] }, geometry: { type: "MultiPolygon", coordinates: [[[[30.80408, -0.99911], [30.76635, -0.9852], [30.70631, -1.01175], [30.64166, -1.06601], [30.47194, -1.0555], [30.45116, -1.10641], [30.50889, -1.16412], [30.57123, -1.33264], [30.71974, -1.43244], [30.84079, -1.64652], [30.80802, -1.91477], [30.89303, -2.08223], [30.83915, -2.35795], [30.54501, -2.41404], [30.41789, -2.66266], [30.52747, -2.65841], [30.40662, -2.86151], [30.4987, -2.9573], [30.57926, -2.89791], [30.6675, -2.98987], [30.83823, -2.97837], [30.84165, -3.25152], [30.45915, -3.56532], [30.22042, -4.01738], [30.03323, -4.26631], [29.88172, -4.35743], [29.82885, -4.36153], [29.77289, -4.41733], [29.75109, -4.45836], [29.63827, -4.44681], [29.43673, -4.44845], [29.52552, -6.2731], [30.2567, -7.14121], [30.79243, -8.27382], [31.00796, -8.58615], [31.37533, -8.60769], [31.57147, -8.70619], [31.57147, -8.81388], [31.71158, -8.91386], [31.81587, -8.88618], [31.94663, -8.93846], [31.94196, -9.02303], [31.98866, -9.07069], [32.08206, -9.04609], [32.16146, -9.05993], [32.25486, -9.13371], [32.43543, -9.11988], [32.49147, -9.14754], [32.53661, -9.24281], [32.75611, -9.28583], [32.76233, -9.31963], [32.95389, -9.40138], [32.99397, -9.36712], [33.14925, -9.49322], [33.31581, -9.48554], [33.48052, -9.62442], [33.76677, -9.58516], [33.93298, -9.71647], [33.9638, -9.62206], [33.95829, -9.54066], [34.03865, -9.49398], [34.54499, -10.0678], [34.51911, -10.12279], [34.57581, -10.56271], [34.65946, -10.6828], [34.67047, -10.93796], [34.61161, -11.01611], [34.63305, -11.11731], [34.79375, -11.32245], [34.91153, -11.39799], [34.96296, -11.57354], [35.63599, -11.55927], [35.82767, -11.41081], [36.19094, -11.57593], [36.19094, -11.70008], [36.62068, -11.72884], [36.80309, -11.56836], [37.3936, -11.68949], [37.76614, -11.53352], [37.8388, -11.3123], [37.93618, -11.26228], [38.21598, -11.27289], [38.47258, -11.4199], [38.88996, -11.16978], [39.24395, -11.17433], [39.58249, -10.96043], [40.00295, -10.80255], [40.44265, -10.4618], [40.74206, -10.25691], [40.14328, -4.64201], [39.62121, -4.68136], [39.44306, -4.93877], [39.21631, -4.67835], [37.81321, -3.69179], [37.75036, -3.54243], [37.63099, -3.50723], [37.5903, -3.42735], [37.71745, -3.304], [37.67199, -3.06222], [34.0824, -1.02264], [34.03084, -1.05101], [34.02286, -1.00779], [33.93107, -0.99298], [30.80408, -0.99911]]]] } },
29229     { type: "Feature", properties: { iso1A2: "UA", iso1A3: "UKR", iso1N3: "804", wikidata: "Q212", nameEn: "Ukraine", groups: ["151", "150", "UN"], callingCodes: ["380"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.57318, 46.10317], [33.61467, 46.13561], [33.63854, 46.14147], [33.61517, 46.22615], [33.646, 46.23028], [33.74047, 46.18555], [33.79715, 46.20482], [33.85234, 46.19863], [33.91549, 46.15938], [34.05272, 46.10838], [34.07311, 46.11769], [34.12929, 46.10494], [34.181, 46.06804], [34.25111, 46.0532], [34.33912, 46.06114], [34.41221, 46.00245], [34.44155, 45.95995], [34.48729, 45.94267], [34.52011, 45.95097], [34.55889, 45.99347], [34.60861, 45.99347], [34.66679, 45.97136], [34.75479, 45.90705], [34.80153, 45.90047], [34.79905, 45.81009], [34.96015, 45.75634], [35.23066, 45.79231], [37.62608, 46.82615], [38.12112, 46.86078], [38.3384, 46.98085], [38.22955, 47.12069], [38.23049, 47.2324], [38.32112, 47.2585], [38.33074, 47.30508], [38.22225, 47.30788], [38.28954, 47.39255], [38.28679, 47.53552], [38.35062, 47.61631], [38.76379, 47.69346], [38.79628, 47.81109], [38.87979, 47.87719], [39.73935, 47.82876], [39.82213, 47.96396], [39.77544, 48.04206], [39.88256, 48.04482], [39.83724, 48.06501], [39.94847, 48.22811], [40.00752, 48.22445], [39.99241, 48.31768], [39.97325, 48.31399], [39.9693, 48.29904], [39.95248, 48.29972], [39.91465, 48.26743], [39.90041, 48.3049], [39.84273, 48.30947], [39.84136, 48.33321], [39.94847, 48.35055], [39.88794, 48.44226], [39.86196, 48.46633], [39.84548, 48.57821], [39.79764, 48.58668], [39.67226, 48.59368], [39.71765, 48.68673], [39.73104, 48.7325], [39.79466, 48.83739], [39.97182, 48.79398], [40.08168, 48.87443], [40.03636, 48.91957], [39.98967, 48.86901], [39.78368, 48.91596], [39.74874, 48.98675], [39.72649, 48.9754], [39.71353, 48.98959], [39.6683, 48.99454], [39.6836, 49.05121], [39.93437, 49.05709], [40.01988, 49.1761], [40.22176, 49.25683], [40.18331, 49.34996], [40.14912, 49.37681], [40.1141, 49.38798], [40.03087, 49.45452], [40.03636, 49.52321], [40.16683, 49.56865], [40.13249, 49.61672], [39.84548, 49.56064], [39.65047, 49.61761], [39.59142, 49.73758], [39.44496, 49.76067], [39.27968, 49.75976], [39.1808, 49.88911], [38.9391, 49.79524], [38.90477, 49.86787], [38.73311, 49.90238], [38.68677, 50.00904], [38.65688, 49.97176], [38.35408, 50.00664], [38.32524, 50.08866], [38.18517, 50.08161], [38.21675, 49.98104], [38.02999, 49.90592], [38.02999, 49.94482], [37.90776, 50.04194], [37.79515, 50.08425], [37.75807, 50.07896], [37.61113, 50.21976], [37.62879, 50.24481], [37.62486, 50.29966], [37.47243, 50.36277], [37.48204, 50.46079], [37.08468, 50.34935], [36.91762, 50.34963], [36.69377, 50.26982], [36.64571, 50.218], [36.56655, 50.2413], [36.58371, 50.28563], [36.47817, 50.31457], [36.30101, 50.29088], [36.20763, 50.3943], [36.06893, 50.45205], [35.8926, 50.43829], [35.80388, 50.41356], [35.73659, 50.35489], [35.61711, 50.35707], [35.58003, 50.45117], [35.47463, 50.49247], [35.39464, 50.64751], [35.48116, 50.66405], [35.47704, 50.77274], [35.41367, 50.80227], [35.39307, 50.92145], [35.32598, 50.94524], [35.40837, 51.04119], [35.31774, 51.08434], [35.20375, 51.04723], [35.12685, 51.16191], [35.14058, 51.23162], [34.97304, 51.2342], [34.82472, 51.17483], [34.6874, 51.18], [34.6613, 51.25053], [34.38802, 51.2746], [34.31661, 51.23936], [34.23009, 51.26429], [34.33446, 51.363], [34.22048, 51.4187], [34.30562, 51.5205], [34.17599, 51.63253], [34.07765, 51.67065], [34.42922, 51.72852], [34.41136, 51.82793], [34.09413, 52.00835], [34.11199, 52.14087], [34.05239, 52.20132], [33.78789, 52.37204], [33.55718, 52.30324], [33.48027, 52.31499], [33.51323, 52.35779], [33.18913, 52.3754], [32.89937, 52.2461], [32.85405, 52.27888], [32.69475, 52.25535], [32.54781, 52.32423], [32.3528, 52.32842], [32.38988, 52.24946], [32.33083, 52.23685], [32.34044, 52.1434], [32.2777, 52.10266], [32.23331, 52.08085], [32.08813, 52.03319], [31.92159, 52.05144], [31.96141, 52.08015], [31.85018, 52.11305], [31.81722, 52.09955], [31.7822, 52.11406], [31.38326, 52.12991], [31.25142, 52.04131], [31.13332, 52.1004], [30.95589, 52.07775], [30.90897, 52.00699], [30.76443, 51.89739], [30.68804, 51.82806], [30.51946, 51.59649], [30.64992, 51.35014], [30.56203, 51.25655], [30.36153, 51.33984], [30.34642, 51.42555], [30.17888, 51.51025], [29.77376, 51.4461], [29.7408, 51.53417], [29.54372, 51.48372], [29.49773, 51.39814], [29.42357, 51.4187], [29.32881, 51.37843], [29.25191, 51.49828], [29.25603, 51.57089], [29.20659, 51.56918], [29.16402, 51.64679], [29.1187, 51.65872], [28.99098, 51.56833], [28.95528, 51.59222], [28.81795, 51.55552], [28.76027, 51.48802], [28.78224, 51.45294], [28.75615, 51.41442], [28.73143, 51.46236], [28.69161, 51.44695], [28.64429, 51.5664], [28.47051, 51.59734], [28.37592, 51.54505], [28.23452, 51.66988], [28.10658, 51.57857], [27.95827, 51.56065], [27.91844, 51.61952], [27.85253, 51.62293], [27.76052, 51.47604], [27.67125, 51.50854], [27.71932, 51.60672], [27.55727, 51.63486], [27.51058, 51.5854], [27.47212, 51.61184], [27.24828, 51.60161], [27.26613, 51.65957], [27.20948, 51.66713], [27.20602, 51.77291], [26.99422, 51.76933], [26.9489, 51.73788], [26.80043, 51.75777], [26.69759, 51.82284], [26.46962, 51.80501], [26.39367, 51.87315], [26.19084, 51.86781], [26.00408, 51.92967], [25.83217, 51.92587], [25.80574, 51.94556], [25.73673, 51.91973], [25.46163, 51.92205], [25.20228, 51.97143], [24.98784, 51.91273], [24.37123, 51.88222], [24.29021, 51.80841], [24.3163, 51.75063], [24.13075, 51.66979], [23.99907, 51.58369], [23.8741, 51.59734], [23.91118, 51.63316], [23.7766, 51.66809], [23.60906, 51.62122], [23.6736, 51.50255], [23.62751, 51.50512], [23.69905, 51.40871], [23.63858, 51.32182], [23.80678, 51.18405], [23.90376, 51.07697], [23.92217, 51.00836], [24.04576, 50.90196], [24.14524, 50.86128], [24.0952, 50.83262], [23.99254, 50.83847], [23.95925, 50.79271], [24.0595, 50.71625], [24.0996, 50.60752], [24.07048, 50.5071], [24.03668, 50.44507], [23.99563, 50.41289], [23.79445, 50.40481], [23.71382, 50.38248], [23.67635, 50.33385], [23.28221, 50.0957], [22.99329, 49.84249], [22.83179, 49.69875], [22.80261, 49.69098], [22.78304, 49.65543], [22.64534, 49.53094], [22.69444, 49.49378], [22.748, 49.32759], [22.72009, 49.20288], [22.86336, 49.10513], [22.89122, 49.00725], [22.56155, 49.08865], [22.54338, 49.01424], [22.48296, 48.99172], [22.42934, 48.92857], [22.34151, 48.68893], [22.21379, 48.6218], [22.16023, 48.56548], [22.14689, 48.4005], [22.2083, 48.42534], [22.38133, 48.23726], [22.49806, 48.25189], [22.59007, 48.15121], [22.58733, 48.10813], [22.66835, 48.09162], [22.73427, 48.12005], [22.81804, 48.11363], [22.87847, 48.04665], [22.84276, 47.98602], [22.89849, 47.95851], [22.94301, 47.96672], [22.92241, 48.02002], [23.0158, 47.99338], [23.08858, 48.00716], [23.1133, 48.08061], [23.15999, 48.12188], [23.27397, 48.08245], [23.33577, 48.0237], [23.4979, 47.96858], [23.52803, 48.01818], [23.5653, 48.00499], [23.63894, 48.00293], [23.66262, 47.98786], [23.75188, 47.99705], [23.80904, 47.98142], [23.8602, 47.9329], [23.89352, 47.94512], [23.94192, 47.94868], [23.96337, 47.96672], [23.98553, 47.96076], [24.00801, 47.968], [24.02999, 47.95087], [24.06466, 47.95317], [24.11281, 47.91487], [24.22566, 47.90231], [24.34926, 47.9244], [24.43578, 47.97131], [24.61994, 47.95062], [24.70632, 47.84428], [24.81893, 47.82031], [24.88896, 47.7234], [25.11144, 47.75203], [25.23778, 47.89403], [25.63878, 47.94924], [25.77723, 47.93919], [26.05901, 47.9897], [26.17711, 47.99246], [26.33504, 48.18418], [26.55202, 48.22445], [26.62823, 48.25804], [26.6839, 48.35828], [26.79239, 48.29071], [26.82809, 48.31629], [26.71274, 48.40388], [26.85556, 48.41095], [26.93384, 48.36558], [27.03821, 48.37653], [27.0231, 48.42485], [27.08078, 48.43214], [27.13434, 48.37288], [27.27855, 48.37534], [27.32159, 48.4434], [27.37604, 48.44398], [27.37741, 48.41026], [27.44333, 48.41209], [27.46942, 48.454], [27.5889, 48.49224], [27.59027, 48.46311], [27.6658, 48.44034], [27.74422, 48.45926], [27.79225, 48.44244], [27.81902, 48.41874], [27.87533, 48.4037], [27.88391, 48.36699], [27.95883, 48.32368], [28.04527, 48.32661], [28.09873, 48.3124], [28.07504, 48.23494], [28.17666, 48.25963], [28.19314, 48.20749], [28.2856, 48.23202], [28.32508, 48.23384], [28.35519, 48.24957], [28.36996, 48.20543], [28.34912, 48.1787], [28.30586, 48.1597], [28.30609, 48.14018], [28.34009, 48.13147], [28.38712, 48.17567], [28.43701, 48.15832], [28.42454, 48.12047], [28.48428, 48.0737], [28.53921, 48.17453], [28.69896, 48.13106], [28.85232, 48.12506], [28.8414, 48.03392], [28.9306, 47.96255], [29.1723, 47.99013], [29.19839, 47.89261], [29.27804, 47.88893], [29.20663, 47.80367], [29.27255, 47.79953], [29.22242, 47.73607], [29.22414, 47.60012], [29.11743, 47.55001], [29.18603, 47.43387], [29.3261, 47.44664], [29.39889, 47.30179], [29.47854, 47.30366], [29.48678, 47.36043], [29.5733, 47.36508], [29.59665, 47.25521], [29.54996, 47.24962], [29.57696, 47.13581], [29.49732, 47.12878], [29.53044, 47.07851], [29.61038, 47.09932], [29.62137, 47.05069], [29.57056, 46.94766], [29.72986, 46.92234], [29.75458, 46.8604], [29.87405, 46.88199], [29.98814, 46.82358], [29.94522, 46.80055], [29.9743, 46.75325], [29.94409, 46.56002], [29.88916, 46.54302], [30.02511, 46.45132], [30.16794, 46.40967], [30.09103, 46.38694], [29.94114, 46.40114], [29.88329, 46.35851], [29.74496, 46.45605], [29.66359, 46.4215], [29.6763, 46.36041], [29.5939, 46.35472], [29.49914, 46.45889], [29.35357, 46.49505], [29.24886, 46.37912], [29.23547, 46.55435], [29.02409, 46.49582], [29.01241, 46.46177], [28.9306, 46.45699], [29.004, 46.31495], [28.98478, 46.31803], [28.94953, 46.25852], [29.06656, 46.19716], [28.94643, 46.09176], [29.00613, 46.04962], [28.98004, 46.00385], [28.74383, 45.96664], [28.78503, 45.83475], [28.69852, 45.81753], [28.70401, 45.78019], [28.52823, 45.73803], [28.47879, 45.66994], [28.51587, 45.6613], [28.54196, 45.58062], [28.49252, 45.56716], [28.51449, 45.49982], [28.43072, 45.48538], [28.41836, 45.51715], [28.30201, 45.54744], [28.21139, 45.46895], [28.28504, 45.43907], [28.34554, 45.32102], [28.5735, 45.24759], [28.71358, 45.22631], [28.78911, 45.24179], [28.81383, 45.3384], [28.94292, 45.28045], [28.96077, 45.33164], [29.24779, 45.43388], [29.42632, 45.44545], [29.59798, 45.38857], [29.68175, 45.26885], [29.65428, 45.25629], [29.69272, 45.19227], [30.04414, 45.08461], [31.62627, 45.50633], [33.54017, 46.0123], [33.59087, 46.06013], [33.57318, 46.10317]]]] } },
29230     { type: "Feature", properties: { iso1A2: "UG", iso1A3: "UGA", iso1N3: "800", wikidata: "Q1036", nameEn: "Uganda", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["256"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.93107, -0.99298], [33.9264, -0.54188], [33.98449, -0.13079], [33.90936, 0.10581], [34.10067, 0.36372], [34.08727, 0.44713], [34.11408, 0.48884], [34.13493, 0.58118], [34.20196, 0.62289], [34.27345, 0.63182], [34.31516, 0.75693], [34.40041, 0.80266], [34.43349, 0.85254], [34.52369, 1.10692], [34.57427, 1.09868], [34.58029, 1.14712], [34.67562, 1.21265], [34.80223, 1.22754], [34.82606, 1.26626], [34.82606, 1.30944], [34.7918, 1.36752], [34.87819, 1.5596], [34.92734, 1.56109], [34.9899, 1.6668], [34.98692, 1.97348], [34.90947, 2.42447], [34.95267, 2.47209], [34.77244, 2.70272], [34.78137, 2.76223], [34.73967, 2.85447], [34.65774, 2.8753], [34.60114, 2.93034], [34.56242, 3.11478], [34.45815, 3.18319], [34.40006, 3.37949], [34.41794, 3.44342], [34.39112, 3.48802], [34.44922, 3.51627], [34.45815, 3.67385], [34.15429, 3.80464], [34.06046, 4.15235], [33.9873, 4.23316], [33.51264, 3.75068], [33.18356, 3.77812], [33.02852, 3.89296], [32.89746, 3.81339], [32.72021, 3.77327], [32.41337, 3.748], [32.20782, 3.6053], [32.19888, 3.50867], [32.08866, 3.53543], [32.08491, 3.56287], [32.05187, 3.589], [31.95907, 3.57408], [31.96205, 3.6499], [31.86821, 3.78664], [31.81459, 3.82083], [31.72075, 3.74354], [31.50776, 3.63652], [31.50478, 3.67814], [31.29476, 3.8015], [31.16666, 3.79853], [30.97601, 3.693], [30.85153, 3.48867], [30.94081, 3.50847], [30.93486, 3.40737], [30.84251, 3.26908], [30.77101, 3.04897], [30.8574, 2.9508], [30.8857, 2.83923], [30.75612, 2.5863], [30.74271, 2.43601], [30.83059, 2.42559], [30.91102, 2.33332], [30.96911, 2.41071], [31.06593, 2.35862], [31.07934, 2.30207], [31.12104, 2.27676], [31.1985, 2.29462], [31.20148, 2.2217], [31.28042, 2.17853], [31.30127, 2.11006], [30.48503, 1.21675], [30.24671, 1.14974], [30.22139, 0.99635], [30.1484, 0.89805], [29.98307, 0.84295], [29.95477, 0.64486], [29.97413, 0.52124], [29.87284, 0.39166], [29.81922, 0.16824], [29.77454, 0.16675], [29.7224, 0.07291], [29.72687, -0.08051], [29.65091, -0.46777], [29.67474, -0.47969], [29.67176, -0.55714], [29.62708, -0.71055], [29.63006, -0.8997], [29.58388, -0.89821], [29.59061, -1.39016], [29.82657, -1.31187], [29.912, -1.48269], [30.16369, -1.34303], [30.35212, -1.06896], [30.47194, -1.0555], [30.64166, -1.06601], [30.70631, -1.01175], [30.76635, -0.9852], [30.80408, -0.99911], [33.93107, -0.99298]]]] } },
29231     { type: "Feature", properties: { iso1A2: "UM", iso1A3: "UMI", iso1N3: "581", wikidata: "Q16645", nameEn: "United States Minor Outlying Islands", country: "US" }, geometry: null },
29232     { type: "Feature", properties: { iso1A2: "UN", wikidata: "Q1065", nameEn: "United Nations", level: "unitedNations", isoStatus: "excRes" }, geometry: null },
29233     { type: "Feature", properties: { iso1A2: "US", iso1A3: "USA", iso1N3: "840", wikidata: "Q30", nameEn: "United States of America" }, geometry: null },
29234     { type: "Feature", properties: { iso1A2: "UY", iso1A3: "URY", iso1N3: "858", wikidata: "Q77", nameEn: "Uruguay", groups: ["005", "419", "019", "UN"], callingCodes: ["598"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-57.65132, -30.19229], [-57.61478, -30.25165], [-57.64859, -30.35095], [-57.89115, -30.49572], [-57.8024, -30.77193], [-57.89476, -30.95994], [-57.86729, -31.06352], [-57.9908, -31.34924], [-57.98127, -31.3872], [-58.07569, -31.44916], [-58.0023, -31.53084], [-58.00076, -31.65016], [-58.20252, -31.86966], [-58.10036, -32.25338], [-58.22362, -32.52416], [-58.1224, -32.98842], [-58.40475, -33.11777], [-58.44442, -33.84033], [-58.34425, -34.15035], [-57.83001, -34.69099], [-54.78916, -36.21945], [-52.83257, -34.01481], [-53.37138, -33.74313], [-53.39593, -33.75169], [-53.44031, -33.69344], [-53.52794, -33.68908], [-53.53459, -33.16843], [-53.1111, -32.71147], [-53.37671, -32.57005], [-53.39572, -32.58596], [-53.76024, -32.0751], [-54.17384, -31.86168], [-55.50821, -30.91349], [-55.50841, -30.9027], [-55.51862, -30.89828], [-55.52712, -30.89997], [-55.53276, -30.90218], [-55.53431, -30.89714], [-55.54572, -30.89051], [-55.55218, -30.88193], [-55.55373, -30.8732], [-55.5634, -30.8686], [-55.58866, -30.84117], [-55.87388, -31.05053], [-56.4619, -30.38457], [-56.4795, -30.3899], [-56.49267, -30.39471], [-56.90236, -30.02578], [-57.22502, -30.26121], [-57.65132, -30.19229]]]] } },
29235     { type: "Feature", properties: { iso1A2: "UZ", iso1A3: "UZB", iso1N3: "860", wikidata: "Q265", nameEn: "Uzbekistan", groups: ["143", "142", "UN"], callingCodes: ["998"] }, geometry: { type: "MultiPolygon", coordinates: [[[[65.85194, 42.85481], [65.53277, 43.31856], [65.18666, 43.48835], [64.96464, 43.74748], [64.53885, 43.56941], [63.34656, 43.64003], [62.01711, 43.51008], [61.01475, 44.41383], [58.59711, 45.58671], [55.97842, 44.99622], [55.97832, 44.99622], [55.97822, 44.99617], [55.97811, 44.99617], [55.97801, 44.99612], [55.97801, 44.99607], [55.97791, 44.99607], [55.9778, 44.99607], [55.9777, 44.99601], [55.9777, 44.99596], [55.9776, 44.99591], [55.97749, 44.99591], [55.97739, 44.99591], [55.97739, 44.99586], [55.97729, 44.99586], [55.97718, 44.99581], [55.97708, 44.99576], [55.97698, 44.9957], [55.97698, 44.99565], [55.97687, 44.9956], [55.97677, 44.9956], [55.97677, 44.99555], [55.97677, 44.9955], [55.97667, 44.99545], [55.97656, 44.99539], [55.97646, 44.99534], [55.97646, 44.99529], [55.97636, 44.99524], [55.97636, 44.99519], [55.97625, 44.99514], [55.97615, 44.99508], [55.97615, 44.99503], [55.97615, 44.99498], [55.97615, 44.99493], [55.97615, 44.99483], [55.97615, 44.99477], [55.97605, 44.99477], [55.97605, 44.99467], [55.97605, 44.99462], [55.97605, 44.99457], [55.97605, 44.99452], [55.97594, 44.99446], [55.97584, 44.99441], [55.97584, 44.99436], [55.97584, 44.99431], [55.97584, 44.99426], [55.97584, 44.99421], [55.97584, 44.99415], [55.97584, 44.99405], [55.97584, 44.994], [55.97584, 44.9939], [55.97584, 44.99384], [55.97584, 44.99374], [55.97584, 44.99369], [55.97584, 44.99359], [55.97584, 44.99353], [55.97584, 44.99348], [55.97584, 44.99343], [55.97584, 44.99338], [55.97584, 44.99328], [55.97584, 44.99322], [56.00314, 41.32584], [57.03423, 41.25435], [57.13796, 41.36625], [57.03359, 41.41777], [56.96218, 41.80383], [57.03633, 41.92043], [57.30275, 42.14076], [57.6296, 42.16519], [57.84932, 42.18555], [57.92897, 42.24047], [57.90975, 42.4374], [57.99214, 42.50021], [58.3492, 42.43335], [58.40688, 42.29535], [58.51674, 42.30348], [58.29427, 42.56497], [58.14321, 42.62159], [58.27504, 42.69632], [58.57991, 42.64988], [58.6266, 42.79314], [58.93422, 42.5407], [59.17317, 42.52248], [59.2955, 42.37064], [59.4341, 42.29738], [59.94633, 42.27655], [60.00539, 42.212], [59.96419, 42.1428], [60.04659, 42.08982], [60.0356, 42.01028], [59.95046, 41.97966], [60.33223, 41.75058], [60.08504, 41.80997], [60.06032, 41.76287], [60.18117, 41.60082], [60.06581, 41.4363], [60.5078, 41.21694], [61.03261, 41.25691], [61.22212, 41.14946], [61.33199, 41.14946], [61.39732, 41.19873], [61.4446, 41.29407], [61.87856, 41.12257], [62.11751, 40.58242], [62.34273, 40.43206], [62.43337, 39.98528], [63.6913, 39.27666], [63.70778, 39.22349], [64.19086, 38.95561], [64.32576, 38.98691], [65.55873, 38.29052], [65.83913, 38.25733], [66.24013, 38.16238], [66.41042, 38.02403], [66.56697, 38.0435], [66.67684, 37.96776], [66.53676, 37.80084], [66.52852, 37.58568], [66.65761, 37.45497], [66.52303, 37.39827], [66.55743, 37.35409], [66.64699, 37.32958], [66.95598, 37.40162], [67.08232, 37.35469], [67.13039, 37.27168], [67.2224, 37.24545], [67.2581, 37.17216], [67.51868, 37.26102], [67.78329, 37.1834], [67.8474, 37.31594], [67.81566, 37.43107], [68.12635, 37.93], [68.27159, 37.91477], [68.40343, 38.19484], [68.13289, 38.40822], [68.06274, 38.39435], [68.11366, 38.47169], [68.05873, 38.56087], [68.0807, 38.64136], [68.05598, 38.71641], [68.12877, 38.73677], [68.06948, 38.82115], [68.19743, 38.85985], [68.09704, 39.02589], [67.68915, 39.00775], [67.67833, 39.14479], [67.33226, 39.23739], [67.36522, 39.31287], [67.45998, 39.315], [67.46822, 39.46146], [67.39681, 39.52505], [67.46547, 39.53564], [67.44899, 39.57799], [67.62889, 39.60234], [67.70992, 39.66156], [68.12053, 39.56317], [68.54166, 39.53929], [68.61972, 39.68905], [68.63071, 39.85265], [68.88889, 39.87163], [68.93695, 39.91167], [68.84906, 40.04952], [68.96579, 40.06949], [69.01935, 40.11466], [69.01523, 40.15771], [68.62796, 40.07789], [68.52771, 40.11676], [68.5332, 40.14826], [68.77902, 40.20492], [68.79276, 40.17555], [68.84357, 40.18604], [68.85832, 40.20885], [69.04544, 40.22904], [69.15659, 40.2162], [69.2074, 40.21488], [69.30448, 40.18774], [69.30104, 40.24502], [69.25229, 40.26362], [69.24817, 40.30357], [69.30808, 40.2821], [69.32833, 40.29794], [69.33794, 40.34819], [69.30774, 40.36102], [69.28525, 40.41894], [69.27066, 40.49274], [69.21063, 40.54469], [69.2643, 40.57506], [69.3455, 40.57988], [69.32834, 40.70233], [69.38327, 40.7918], [69.53021, 40.77621], [69.59441, 40.70181], [69.69434, 40.62615], [70.36655, 40.90296], [70.38028, 41.02014], [70.45251, 41.04438], [70.80009, 40.72825], [70.49871, 40.52503], [70.32626, 40.45174], [70.37511, 40.38605], [70.57149, 40.3442], [70.56394, 40.26421], [70.62342, 40.17396], [70.8607, 40.217], [70.9818, 40.22392], [70.95789, 40.28761], [71.05901, 40.28765], [71.13042, 40.34106], [71.36663, 40.31593], [71.4246, 40.28619], [71.51215, 40.26943], [71.51549, 40.22986], [71.61725, 40.20615], [71.61931, 40.26775], [71.68386, 40.26984], [71.70569, 40.20391], [71.69621, 40.18492], [71.71719, 40.17886], [71.73054, 40.14818], [71.82646, 40.21872], [71.85002, 40.25647], [72.05464, 40.27586], [71.96401, 40.31907], [72.18648, 40.49893], [72.24368, 40.46091], [72.40346, 40.4007], [72.44191, 40.48222], [72.41513, 40.50856], [72.38384, 40.51535], [72.41714, 40.55736], [72.34406, 40.60144], [72.40517, 40.61917], [72.47795, 40.5532], [72.66713, 40.5219], [72.66713, 40.59076], [72.69579, 40.59778], [72.73995, 40.58409], [72.74768, 40.58051], [72.74862, 40.57131], [72.75982, 40.57273], [72.74894, 40.59592], [72.74866, 40.60873], [72.80137, 40.67856], [72.84754, 40.67229], [72.85372, 40.7116], [72.8722, 40.71111], [72.93296, 40.73089], [72.99133, 40.76457], [73.0612, 40.76678], [73.13412, 40.79122], [73.13267, 40.83512], [73.01869, 40.84681], [72.94454, 40.8094], [72.84291, 40.85512], [72.68157, 40.84942], [72.59136, 40.86947], [72.55109, 40.96046], [72.48742, 40.97136], [72.45206, 41.03018], [72.38511, 41.02785], [72.36138, 41.04384], [72.34757, 41.06104], [72.34026, 41.04539], [72.324, 41.03381], [72.18339, 40.99571], [72.17594, 41.02377], [72.21061, 41.05607], [72.1792, 41.10621], [72.14864, 41.13363], [72.17594, 41.15522], [72.16433, 41.16483], [72.10745, 41.15483], [72.07249, 41.11739], [71.85964, 41.19081], [71.91457, 41.2982], [71.83914, 41.3546], [71.76625, 41.4466], [71.71132, 41.43012], [71.73054, 41.54713], [71.65914, 41.49599], [71.6787, 41.42111], [71.57227, 41.29175], [71.46688, 41.31883], [71.43814, 41.19644], [71.46148, 41.13958], [71.40198, 41.09436], [71.34877, 41.16807], [71.27187, 41.11015], [71.25813, 41.18796], [71.11806, 41.15359], [71.02193, 41.19494], [70.9615, 41.16393], [70.86263, 41.23833], [70.77885, 41.24813], [70.78572, 41.36419], [70.67586, 41.47953], [70.48909, 41.40335], [70.17682, 41.5455], [70.69777, 41.92554], [71.28719, 42.18033], [71.13263, 42.28356], [70.94483, 42.26238], [69.49545, 41.545], [69.45751, 41.56863], [69.39485, 41.51518], [69.45081, 41.46246], [69.37468, 41.46555], [69.35554, 41.47211], [69.29778, 41.43673], [69.25059, 41.46693], [69.23332, 41.45847], [69.22671, 41.46298], [69.20439, 41.45391], [69.18528, 41.45175], [69.17701, 41.43769], [69.15137, 41.43078], [69.05006, 41.36183], [69.01308, 41.22804], [68.7217, 41.05025], [68.73945, 40.96989], [68.65662, 40.93861], [68.62221, 41.03019], [68.49983, 40.99669], [68.58444, 40.91447], [68.63, 40.59358], [68.49983, 40.56437], [67.96736, 40.83798], [68.1271, 41.0324], [68.08273, 41.08148], [67.98511, 41.02794], [67.9644, 41.14611], [66.69129, 41.1311], [66.53302, 41.87388], [66.00546, 41.94455], [66.09482, 42.93426], [65.85194, 42.85481]], [[70.68112, 40.90612], [70.6721, 40.90555], [70.57501, 40.98941], [70.54223, 40.98787], [70.56077, 41.00642], [70.6158, 40.97661], [70.68112, 40.90612]]], [[[71.21139, 40.03369], [71.12218, 40.03052], [71.06305, 40.1771], [71.00236, 40.18154], [71.01035, 40.05481], [71.11037, 40.01984], [71.11668, 39.99291], [71.09063, 39.99], [71.10501, 39.95568], [71.04979, 39.89808], [71.10531, 39.91354], [71.16101, 39.88423], [71.23067, 39.93581], [71.1427, 39.95026], [71.21139, 40.03369]]], [[[71.86463, 39.98598], [71.78838, 40.01404], [71.71511, 39.96348], [71.7504, 39.93701], [71.84316, 39.95582], [71.86463, 39.98598]]]] } },
29236     { type: "Feature", properties: { iso1A2: "VA", iso1A3: "VAT", iso1N3: "336", wikidata: "Q237", nameEn: "Vatican City", aliases: ["Holy See"], groups: ["039", "150"], callingCodes: ["379", "39 06"] }, geometry: { type: "MultiPolygon", coordinates: [[[[12.45181, 41.90056], [12.45446, 41.90028], [12.45435, 41.90143], [12.45626, 41.90172], [12.45691, 41.90125], [12.4577, 41.90115], [12.45834, 41.90174], [12.45826, 41.90281], [12.45755, 41.9033], [12.45762, 41.9058], [12.45561, 41.90629], [12.45543, 41.90738], [12.45091, 41.90625], [12.44984, 41.90545], [12.44815, 41.90326], [12.44582, 41.90194], [12.44834, 41.90095], [12.45181, 41.90056]]]] } },
29237     { type: "Feature", properties: { iso1A2: "VC", iso1A3: "VCT", iso1N3: "670", wikidata: "Q757", nameEn: "St. Vincent and the Grenadines", aliases: ["WV"], groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 784"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-62.64026, 12.69984], [-59.94058, 12.34011], [-61.69315, 14.26451], [-62.64026, 12.69984]]]] } },
29238     { type: "Feature", properties: { iso1A2: "VE", iso1A3: "VEN", iso1N3: "862", wikidata: "Q717", nameEn: "Venezuela", aliases: ["YV"], groups: ["005", "419", "019", "UN"], callingCodes: ["58"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-71.22331, 13.01387], [-70.92579, 11.96275], [-71.3275, 11.85], [-71.9675, 11.65536], [-72.24983, 11.14138], [-72.4767, 11.1117], [-72.88002, 10.44309], [-72.98085, 9.85253], [-73.36905, 9.16636], [-73.02119, 9.27584], [-72.94052, 9.10663], [-72.77415, 9.10165], [-72.65474, 8.61428], [-72.4042, 8.36513], [-72.36987, 8.19976], [-72.35163, 8.01163], [-72.39137, 8.03534], [-72.47213, 7.96106], [-72.48801, 7.94329], [-72.48183, 7.92909], [-72.47042, 7.92306], [-72.45806, 7.91141], [-72.46183, 7.90682], [-72.44454, 7.86031], [-72.46763, 7.79518], [-72.47827, 7.65604], [-72.45321, 7.57232], [-72.47415, 7.48928], [-72.43132, 7.40034], [-72.19437, 7.37034], [-72.04895, 7.03837], [-71.82441, 7.04314], [-71.44118, 7.02116], [-71.42212, 7.03854], [-71.37234, 7.01588], [-71.03941, 6.98163], [-70.7596, 7.09799], [-70.10716, 6.96516], [-69.41843, 6.1072], [-67.60654, 6.2891], [-67.4625, 6.20625], [-67.43513, 5.98835], [-67.58558, 5.84537], [-67.63914, 5.64963], [-67.59141, 5.5369], [-67.83341, 5.31104], [-67.85358, 4.53249], [-67.62671, 3.74303], [-67.50067, 3.75812], [-67.30945, 3.38393], [-67.85862, 2.86727], [-67.85862, 2.79173], [-67.65696, 2.81691], [-67.21967, 2.35778], [-66.85795, 1.22998], [-66.28507, 0.74585], [-65.6727, 1.01353], [-65.50158, 0.92086], [-65.57288, 0.62856], [-65.11657, 1.12046], [-64.38932, 1.5125], [-64.34654, 1.35569], [-64.08274, 1.64792], [-64.06135, 1.94722], [-63.39827, 2.16098], [-63.39114, 2.4317], [-64.0257, 2.48156], [-64.02908, 2.79797], [-64.48379, 3.7879], [-64.84028, 4.24665], [-64.72977, 4.28931], [-64.57648, 4.12576], [-64.14512, 4.12932], [-63.99183, 3.90172], [-63.86082, 3.94796], [-63.70218, 3.91417], [-63.67099, 4.01731], [-63.50611, 3.83592], [-63.42233, 3.89995], [-63.4464, 3.9693], [-63.21111, 3.96219], [-62.98296, 3.59935], [-62.7655, 3.73099], [-62.74411, 4.03331], [-62.57656, 4.04754], [-62.44822, 4.18621], [-62.13094, 4.08309], [-61.54629, 4.2822], [-61.48569, 4.43149], [-61.29675, 4.44216], [-61.31457, 4.54167], [-61.15703, 4.49839], [-60.98303, 4.54167], [-60.86539, 4.70512], [-60.5802, 4.94312], [-60.73204, 5.20931], [-61.4041, 5.95304], [-61.15058, 6.19558], [-61.20762, 6.58174], [-61.13632, 6.70922], [-60.54873, 6.8631], [-60.39419, 6.94847], [-60.28074, 7.1162], [-60.44116, 7.20817], [-60.54098, 7.14804], [-60.63367, 7.25061], [-60.59802, 7.33194], [-60.71923, 7.55817], [-60.64793, 7.56877], [-60.51959, 7.83373], [-60.38056, 7.8302], [-60.02407, 8.04557], [-59.97059, 8.20791], [-59.83156, 8.23261], [-59.80661, 8.28906], [-59.85562, 8.35213], [-59.98508, 8.53046], [-59.54058, 8.6862], [-60.89962, 9.81445], [-62.08693, 10.04435], [-61.62505, 11.18974], [-63.73917, 11.92623], [-63.19938, 16.44103], [-67.89186, 12.4116], [-68.01417, 11.77722], [-68.33524, 11.78151], [-68.99639, 11.79035], [-71.22331, 13.01387]]]] } },
29239     { type: "Feature", properties: { iso1A2: "VG", iso1A3: "VGB", iso1N3: "092", wikidata: "Q25305", nameEn: "British Virgin Islands", country: "GB", groups: ["BOTS", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 284"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-64.47127, 17.55688], [-63.88746, 19.15706], [-65.02435, 18.73231], [-64.86027, 18.39056], [-64.64673, 18.36549], [-64.47127, 17.55688]]]] } },
29240     { type: "Feature", properties: { iso1A2: "VI", iso1A3: "VIR", iso1N3: "850", wikidata: "Q11703", nameEn: "United States Virgin Islands", aliases: ["US-VI"], country: "US", groups: ["Q1352230", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 340"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-65.02435, 18.73231], [-65.27974, 17.56928], [-64.47127, 17.55688], [-64.64673, 18.36549], [-64.86027, 18.39056], [-65.02435, 18.73231]]]] } },
29241     { type: "Feature", properties: { iso1A2: "VN", iso1A3: "VNM", iso1N3: "704", wikidata: "Q881", nameEn: "Vietnam", groups: ["035", "142", "UN"], callingCodes: ["84"] }, geometry: { type: "MultiPolygon", coordinates: [[[[108.10003, 21.47338], [108.0569, 21.53604], [108.02926, 21.54997], [107.97932, 21.54503], [107.97383, 21.53961], [107.97074, 21.54072], [107.96774, 21.53601], [107.95232, 21.5388], [107.92652, 21.58906], [107.90006, 21.5905], [107.86114, 21.65128], [107.80355, 21.66141], [107.66967, 21.60787], [107.56537, 21.61945], [107.54047, 21.5934], [107.49065, 21.59774], [107.49532, 21.62958], [107.47197, 21.6672], [107.41593, 21.64839], [107.38636, 21.59774], [107.35989, 21.60063], [107.35834, 21.6672], [107.29296, 21.74674], [107.24625, 21.7077], [107.20734, 21.71493], [107.10771, 21.79879], [107.02615, 21.81981], [107.00964, 21.85948], [107.06101, 21.88982], [107.05634, 21.92303], [106.99252, 21.95191], [106.97228, 21.92592], [106.92714, 21.93459], [106.9178, 21.97357], [106.81038, 21.97934], [106.74345, 22.00965], [106.72551, 21.97923], [106.69276, 21.96013], [106.68274, 21.99811], [106.70142, 22.02409], [106.6983, 22.15102], [106.67495, 22.1885], [106.69986, 22.22309], [106.6516, 22.33977], [106.55976, 22.34841], [106.57221, 22.37], [106.55665, 22.46498], [106.58395, 22.474], [106.61269, 22.60301], [106.65316, 22.5757], [106.71698, 22.58432], [106.72321, 22.63606], [106.76293, 22.73491], [106.82404, 22.7881], [106.83685, 22.8098], [106.81271, 22.8226], [106.78422, 22.81532], [106.71128, 22.85982], [106.71387, 22.88296], [106.6734, 22.89587], [106.6516, 22.86862], [106.60179, 22.92884], [106.55976, 22.92311], [106.51306, 22.94891], [106.49749, 22.91164], [106.34961, 22.86718], [106.27022, 22.87722], [106.19705, 22.98475], [106.00179, 22.99049], [105.99568, 22.94178], [105.90119, 22.94168], [105.8726, 22.92756], [105.72382, 23.06641], [105.57594, 23.075], [105.56037, 23.16806], [105.49966, 23.20669], [105.42805, 23.30824], [105.40782, 23.28107], [105.32376, 23.39684], [105.22569, 23.27249], [105.17276, 23.28679], [105.11672, 23.25247], [105.07002, 23.26248], [104.98712, 23.19176], [104.96532, 23.20463], [104.9486, 23.17235], [104.91435, 23.18666], [104.87992, 23.17141], [104.87382, 23.12854], [104.79478, 23.12934], [104.8334, 23.01484], [104.86765, 22.95178], [104.84942, 22.93631], [104.77114, 22.90017], [104.72755, 22.81984], [104.65283, 22.83419], [104.60457, 22.81841], [104.58122, 22.85571], [104.47225, 22.75813], [104.35593, 22.69353], [104.25683, 22.76534], [104.27084, 22.8457], [104.11384, 22.80363], [104.03734, 22.72945], [104.01088, 22.51823], [103.99247, 22.51958], [103.97384, 22.50634], [103.96783, 22.51173], [103.96352, 22.50584], [103.95191, 22.5134], [103.94513, 22.52553], [103.93286, 22.52703], [103.87904, 22.56683], [103.64506, 22.79979], [103.56255, 22.69499], [103.57812, 22.65764], [103.52675, 22.59155], [103.43646, 22.70648], [103.43179, 22.75816], [103.32282, 22.8127], [103.28079, 22.68063], [103.18895, 22.64471], [103.15782, 22.59873], [103.17961, 22.55705], [103.07843, 22.50097], [103.0722, 22.44775], [102.9321, 22.48659], [102.8636, 22.60735], [102.60675, 22.73376], [102.57095, 22.7036], [102.51802, 22.77969], [102.46665, 22.77108], [102.42618, 22.69212], [102.38415, 22.67919], [102.41061, 22.64184], [102.25339, 22.4607], [102.26428, 22.41321], [102.16621, 22.43336], [102.14099, 22.40092], [102.18712, 22.30403], [102.51734, 22.02676], [102.49092, 21.99002], [102.62301, 21.91447], [102.67145, 21.65894], [102.74189, 21.66713], [102.82115, 21.73667], [102.81894, 21.83888], [102.85637, 21.84501], [102.86077, 21.71213], [102.97965, 21.74076], [102.98846, 21.58936], [102.86297, 21.4255], [102.94223, 21.46034], [102.88939, 21.3107], [102.80794, 21.25736], [102.89825, 21.24707], [102.97745, 21.05821], [103.03469, 21.05821], [103.12055, 20.89994], [103.21497, 20.89832], [103.38032, 20.79501], [103.45737, 20.82382], [103.68633, 20.66324], [103.73478, 20.6669], [103.82282, 20.8732], [103.98024, 20.91531], [104.11121, 20.96779], [104.27412, 20.91433], [104.63957, 20.6653], [104.38199, 20.47155], [104.40621, 20.3849], [104.47886, 20.37459], [104.66158, 20.47774], [104.72102, 20.40554], [104.62195, 20.36633], [104.61315, 20.24452], [104.86852, 20.14121], [104.91695, 20.15567], [104.9874, 20.09573], [104.8465, 19.91783], [104.8355, 19.80395], [104.68359, 19.72729], [104.64837, 19.62365], [104.53169, 19.61743], [104.41281, 19.70035], [104.23229, 19.70242], [104.06498, 19.66926], [104.05617, 19.61743], [104.10832, 19.51575], [104.06058, 19.43484], [103.87125, 19.31854], [104.5361, 18.97747], [104.64617, 18.85668], [105.12829, 18.70453], [105.19654, 18.64196], [105.1327, 18.58355], [105.10408, 18.43533], [105.15942, 18.38691], [105.38366, 18.15315], [105.46292, 18.22008], [105.64784, 17.96687], [105.60381, 17.89356], [105.76612, 17.67147], [105.85744, 17.63221], [106.09019, 17.36399], [106.18991, 17.28227], [106.24444, 17.24714], [106.29287, 17.3018], [106.31929, 17.20509], [106.43597, 17.01362], [106.50862, 16.9673], [106.55045, 17.0031], [106.54824, 16.92729], [106.51963, 16.92097], [106.52183, 16.87884], [106.55265, 16.86831], [106.55485, 16.68704], [106.59013, 16.62259], [106.58267, 16.6012], [106.61477, 16.60713], [106.66052, 16.56892], [106.65832, 16.47816], [106.74418, 16.41904], [106.84104, 16.55415], [106.88727, 16.52671], [106.88067, 16.43594], [106.96638, 16.34938], [106.97385, 16.30204], [107.02597, 16.31132], [107.09091, 16.3092], [107.15035, 16.26271], [107.14595, 16.17816], [107.25822, 16.13587], [107.33968, 16.05549], [107.44975, 16.08511], [107.46296, 16.01106], [107.39471, 15.88829], [107.34188, 15.89464], [107.21419, 15.83747], [107.21859, 15.74638], [107.27143, 15.71459], [107.27583, 15.62769], [107.34408, 15.62345], [107.3815, 15.49832], [107.50699, 15.48771], [107.53341, 15.40496], [107.62367, 15.42193], [107.60605, 15.37524], [107.62587, 15.2266], [107.58844, 15.20111], [107.61926, 15.13949], [107.61486, 15.0566], [107.46516, 15.00982], [107.48277, 14.93751], [107.59285, 14.87795], [107.51579, 14.79282], [107.54361, 14.69092], [107.55371, 14.628], [107.52102, 14.59034], [107.52569, 14.54665], [107.48521, 14.40346], [107.44941, 14.41552], [107.39493, 14.32655], [107.40427, 14.24509], [107.33577, 14.11832], [107.37158, 14.07906], [107.35757, 14.02319], [107.38247, 13.99147], [107.44318, 13.99751], [107.46498, 13.91593], [107.45252, 13.78897], [107.53503, 13.73908], [107.61909, 13.52577], [107.62843, 13.3668], [107.49144, 13.01215], [107.49611, 12.88926], [107.55993, 12.7982], [107.5755, 12.52177], [107.55059, 12.36824], [107.4463, 12.29373], [107.42917, 12.24657], [107.34511, 12.33327], [107.15831, 12.27547], [106.99953, 12.08983], [106.92325, 12.06548], [106.79405, 12.0807], [106.70687, 11.96956], [106.4111, 11.97413], [106.4687, 11.86751], [106.44068, 11.86294], [106.44535, 11.8279], [106.41577, 11.76999], [106.45158, 11.68616], [106.44691, 11.66787], [106.37219, 11.69836], [106.30525, 11.67549], [106.26478, 11.72122], [106.18539, 11.75171], [106.13158, 11.73283], [106.06708, 11.77761], [106.02038, 11.77457], [106.00792, 11.7197], [105.95188, 11.63738], [105.88962, 11.67854], [105.8507, 11.66635], [105.80867, 11.60536], [105.81645, 11.56876], [105.87328, 11.55953], [105.88962, 11.43605], [105.86782, 11.28343], [106.10444, 11.07879], [106.1527, 11.10476], [106.1757, 11.07301], [106.20095, 10.97795], [106.14301, 10.98176], [106.18539, 10.79451], [106.06708, 10.8098], [105.94535, 10.9168], [105.93403, 10.83853], [105.84603, 10.85873], [105.86376, 10.89839], [105.77751, 11.03671], [105.50045, 10.94586], [105.42884, 10.96878], [105.34011, 10.86179], [105.11449, 10.96332], [105.08326, 10.95656], [105.02722, 10.89236], [105.09571, 10.72722], [104.95094, 10.64003], [104.87933, 10.52833], [104.59018, 10.53073], [104.49869, 10.4057], [104.47963, 10.43046], [104.43778, 10.42386], [103.99198, 10.48391], [102.47649, 9.66162], [104.81582, 8.03101], [109.55486, 8.10026], [111.60491, 13.57105], [108.00365, 17.98159], [108.10003, 21.47338]]]] } },
29242     { type: "Feature", properties: { iso1A2: "VU", iso1A3: "VUT", iso1N3: "548", wikidata: "Q686", nameEn: "Vanuatu", groups: ["054", "009", "UN"], callingCodes: ["678"] }, geometry: { type: "MultiPolygon", coordinates: [[[[156.73836, -14.50464], [174.245, -23.1974], [172.71443, -12.01327], [156.73836, -14.50464]]]] } },
29243     { type: "Feature", properties: { iso1A2: "WF", iso1A3: "WLF", iso1N3: "876", wikidata: "Q35555", nameEn: "Wallis and Futuna", country: "FR", groups: ["EU", "Q1451600", "061", "009", "UN"], callingCodes: ["681"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-178.66551, -14.32452], [-176.76826, -14.95183], [-175.59809, -12.61507], [-178.66551, -14.32452]]]] } },
29244     { type: "Feature", properties: { iso1A2: "WS", iso1A3: "WSM", iso1N3: "882", wikidata: "Q683", nameEn: "Samoa", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["685"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-173.74402, -14.26669], [-170.99605, -15.1275], [-171.39864, -10.21587], [-173.74402, -14.26669]]]] } },
29245     { type: "Feature", properties: { iso1A2: "XK", iso1A3: "XKX", wikidata: "Q1246", nameEn: "Kosovo", aliases: ["KV"], groups: ["039", "150"], isoStatus: "usrAssn", callingCodes: ["383"] }, geometry: { type: "MultiPolygon", coordinates: [[[[21.39045, 42.74888], [21.44047, 42.87276], [21.36941, 42.87397], [21.32974, 42.90424], [21.2719, 42.8994], [21.23534, 42.95523], [21.23877, 43.00848], [21.2041, 43.02277], [21.16734, 42.99694], [21.14465, 43.11089], [21.08952, 43.13471], [21.05378, 43.10707], [21.00749, 43.13984], [20.96287, 43.12416], [20.83727, 43.17842], [20.88685, 43.21697], [20.82145, 43.26769], [20.73811, 43.25068], [20.68688, 43.21335], [20.59929, 43.20492], [20.69515, 43.09641], [20.64557, 43.00826], [20.59929, 43.01067], [20.48692, 42.93208], [20.53484, 42.8885], [20.43734, 42.83157], [20.40594, 42.84853], [20.35692, 42.8335], [20.27869, 42.81945], [20.2539, 42.76245], [20.04898, 42.77701], [20.02088, 42.74789], [20.02915, 42.71147], [20.0969, 42.65559], [20.07761, 42.55582], [20.17127, 42.50469], [20.21797, 42.41237], [20.24399, 42.32168], [20.34479, 42.32656], [20.3819, 42.3029], [20.48857, 42.25444], [20.56955, 42.12097], [20.55633, 42.08173], [20.59434, 42.03879], [20.63069, 41.94913], [20.57946, 41.91593], [20.59524, 41.8818], [20.68523, 41.85318], [20.76786, 41.91839], [20.75464, 42.05229], [21.11491, 42.20794], [21.16614, 42.19815], [21.22728, 42.08909], [21.31983, 42.10993], [21.29913, 42.13954], [21.30496, 42.1418], [21.38428, 42.24465], [21.43882, 42.23609], [21.43882, 42.2789], [21.50823, 42.27156], [21.52145, 42.24465], [21.58992, 42.25915], [21.56772, 42.30946], [21.5264, 42.33634], [21.53467, 42.36809], [21.57021, 42.3647], [21.59029, 42.38042], [21.62887, 42.37664], [21.64209, 42.41081], [21.62556, 42.45106], [21.7035, 42.51899], [21.70522, 42.54176], [21.7327, 42.55041], [21.75672, 42.62695], [21.79413, 42.65923], [21.75025, 42.70125], [21.6626, 42.67813], [21.58755, 42.70418], [21.59154, 42.72643], [21.47498, 42.74695], [21.39045, 42.74888]]]] } },
29246     { type: "Feature", properties: { iso1A2: "YE", iso1A3: "YEM", iso1N3: "887", wikidata: "Q805", nameEn: "Yemen", groups: ["145", "142", "UN"], callingCodes: ["967"] }, geometry: { type: "MultiPolygon", coordinates: [[[[57.49095, 8.14549], [52.81185, 17.28568], [52.74267, 17.29519], [52.78009, 17.35124], [52.00311, 19.00083], [49.04884, 18.59899], [48.19996, 18.20584], [47.58351, 17.50366], [47.48245, 17.10808], [47.00571, 16.94765], [46.76494, 17.29151], [46.31018, 17.20464], [44.50126, 17.47475], [43.70631, 17.35762], [43.43005, 17.56148], [43.29185, 17.53224], [43.22533, 17.38343], [43.32653, 17.31179], [43.20156, 17.25901], [43.17787, 17.14717], [43.23967, 17.03428], [43.18233, 17.02673], [43.1813, 16.98438], [43.19328, 16.94703], [43.1398, 16.90696], [43.18338, 16.84852], [43.22012, 16.83932], [43.22956, 16.80613], [43.24801, 16.80613], [43.26303, 16.79479], [43.25857, 16.75304], [43.21325, 16.74416], [43.22066, 16.65179], [43.15274, 16.67248], [43.11601, 16.53166], [42.97215, 16.51093], [42.94351, 16.49467], [42.94625, 16.39721], [42.76801, 16.40371], [42.15205, 16.40211], [40.99158, 15.81743], [43.29075, 12.79154], [43.32909, 12.59711], [43.90659, 12.3823], [51.12877, 12.56479], [57.49095, 8.14549]]]] } },
29247     { type: "Feature", properties: { iso1A2: "YT", iso1A3: "MYT", iso1N3: "175", wikidata: "Q17063", nameEn: "Mayotte", country: "FR", groups: ["Q3320166", "EU", "014", "202", "002", "UN"], callingCodes: ["262"] }, geometry: { type: "MultiPolygon", coordinates: [[[[43.28731, -13.97126], [45.54824, -13.22353], [45.4971, -11.75965], [43.28731, -13.97126]]]] } },
29248     { type: "Feature", properties: { iso1A2: "ZA", iso1A3: "ZAF", iso1N3: "710", wikidata: "Q258", nameEn: "South Africa", groups: ["018", "202", "002", "UN"], driveSide: "left", callingCodes: ["27"] }, geometry: { type: "MultiPolygon", coordinates: [[[[31.30611, -22.422], [31.16344, -22.32599], [31.08932, -22.34884], [30.86696, -22.28907], [30.6294, -22.32599], [30.48686, -22.31368], [30.38614, -22.34533], [30.28351, -22.35587], [30.2265, -22.2961], [30.13147, -22.30841], [29.92242, -22.19408], [29.76848, -22.14128], [29.64609, -22.12917], [29.37703, -22.19581], [29.21955, -22.17771], [29.18974, -22.18599], [29.15268, -22.21399], [29.10881, -22.21202], [29.0151, -22.22907], [28.91889, -22.44299], [28.63287, -22.55887], [28.34874, -22.5694], [28.04562, -22.8394], [28.04752, -22.90243], [27.93729, -22.96194], [27.93539, -23.04941], [27.74154, -23.2137], [27.6066, -23.21894], [27.52393, -23.37952], [27.33768, -23.40917], [26.99749, -23.65486], [26.84165, -24.24885], [26.51667, -24.47219], [26.46346, -24.60358], [26.39409, -24.63468], [25.8515, -24.75727], [25.84295, -24.78661], [25.88571, -24.87802], [25.72702, -25.25503], [25.69661, -25.29284], [25.6643, -25.4491], [25.58543, -25.6343], [25.33076, -25.76616], [25.12266, -25.75931], [25.01718, -25.72507], [24.8946, -25.80723], [24.67319, -25.81749], [24.44703, -25.73021], [24.36531, -25.773], [24.18287, -25.62916], [23.9244, -25.64286], [23.47588, -25.29971], [23.03497, -25.29971], [22.86012, -25.50572], [22.70808, -25.99186], [22.56365, -26.19668], [22.41921, -26.23078], [22.21206, -26.3773], [22.06192, -26.61882], [21.90703, -26.66808], [21.83291, -26.65959], [21.77114, -26.69015], [21.7854, -26.79199], [21.69322, -26.86152], [21.37869, -26.82083], [21.13353, -26.86661], [20.87031, -26.80047], [20.68596, -26.9039], [20.63275, -26.78181], [20.61754, -26.4692], [20.86081, -26.14892], [20.64795, -25.47827], [20.29826, -24.94869], [20.03678, -24.81004], [20.02809, -24.78725], [19.99817, -24.76768], [19.99882, -28.42622], [18.99885, -28.89165], [17.4579, -28.68718], [17.15405, -28.08573], [16.90446, -28.057], [16.59922, -28.53246], [16.46592, -28.57126], [16.45332, -28.63117], [12.51595, -32.27486], [38.88176, -48.03306], [34.51034, -26.91792], [32.35222, -26.86027], [32.29584, -26.852], [32.22302, -26.84136], [32.19409, -26.84032], [32.13315, -26.84345], [32.09664, -26.80721], [32.00893, -26.8096], [31.97463, -27.11057], [31.97592, -27.31675], [31.49834, -27.31549], [31.15027, -27.20151], [30.96088, -27.0245], [30.97757, -26.92706], [30.88826, -26.79622], [30.81101, -26.84722], [30.78927, -26.48271], [30.95819, -26.26303], [31.13073, -25.91558], [31.31237, -25.7431], [31.4175, -25.71886], [31.86881, -25.99973], [31.974, -25.95387], [31.92649, -25.84216], [32.00631, -25.65044], [31.97875, -25.46356], [32.01676, -25.38117], [32.03196, -25.10785], [31.9835, -24.29983], [31.90368, -24.18892], [31.87707, -23.95293], [31.77445, -23.90082], [31.70223, -23.72695], [31.67942, -23.60858], [31.56539, -23.47268], [31.55779, -23.176], [31.30611, -22.422]], [[29.33204, -29.45598], [29.28545, -29.58456], [29.12553, -29.76266], [29.16548, -29.91706], [28.9338, -30.05072], [28.80222, -30.10579], [28.68627, -30.12885], [28.399, -30.1592], [28.2319, -30.28476], [28.12073, -30.68072], [27.74814, -30.60635], [27.69467, -30.55862], [27.67819, -30.53437], [27.6521, -30.51707], [27.62137, -30.50509], [27.56781, -30.44562], [27.56901, -30.42504], [27.45452, -30.32239], [27.38108, -30.33456], [27.36649, -30.27246], [27.37293, -30.19401], [27.40778, -30.14577], [27.32555, -30.14785], [27.29603, -30.05473], [27.22719, -30.00718], [27.09489, -29.72796], [27.01016, -29.65439], [27.33464, -29.48161], [27.4358, -29.33465], [27.47254, -29.31968], [27.45125, -29.29708], [27.48679, -29.29349], [27.54258, -29.25575], [27.5158, -29.2261], [27.55974, -29.18954], [27.75458, -28.89839], [27.8907, -28.91612], [27.88933, -28.88156], [27.9392, -28.84864], [27.98675, -28.8787], [28.02503, -28.85991], [28.1317, -28.7293], [28.2348, -28.69471], [28.30518, -28.69531], [28.40612, -28.6215], [28.65091, -28.57025], [28.68043, -28.58744], [29.40524, -29.21246], [29.44883, -29.3772], [29.33204, -29.45598]]]] } },
29249     { type: "Feature", properties: { iso1A2: "ZM", iso1A3: "ZMB", iso1N3: "894", wikidata: "Q953", nameEn: "Zambia", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["260"] }, geometry: { type: "MultiPolygon", coordinates: [[[[32.95389, -9.40138], [32.76233, -9.31963], [32.75611, -9.28583], [32.53661, -9.24281], [32.49147, -9.14754], [32.43543, -9.11988], [32.25486, -9.13371], [32.16146, -9.05993], [32.08206, -9.04609], [31.98866, -9.07069], [31.94196, -9.02303], [31.94663, -8.93846], [31.81587, -8.88618], [31.71158, -8.91386], [31.57147, -8.81388], [31.57147, -8.70619], [31.37533, -8.60769], [31.00796, -8.58615], [30.79243, -8.27382], [28.88917, -8.4831], [28.9711, -8.66935], [28.38526, -9.23393], [28.36562, -9.30091], [28.52636, -9.35379], [28.51627, -9.44726], [28.56208, -9.49122], [28.68532, -9.78], [28.62795, -9.92942], [28.65032, -10.65133], [28.37241, -11.57848], [28.48357, -11.87532], [29.18592, -12.37921], [29.4992, -12.43843], [29.48404, -12.23604], [29.8139, -12.14898], [29.81551, -13.44683], [29.65078, -13.41844], [29.60531, -13.21685], [29.01918, -13.41353], [28.33199, -12.41375], [27.59932, -12.22123], [27.21025, -11.76157], [27.22541, -11.60323], [27.04351, -11.61312], [26.88687, -12.01868], [26.01777, -11.91488], [25.33058, -11.65767], [25.34069, -11.19707], [24.42612, -11.44975], [24.34528, -11.06816], [24.00027, -10.89356], [24.02603, -11.15368], [23.98804, -12.13149], [24.06672, -12.29058], [23.90937, -12.844], [24.03339, -12.99091], [21.97988, -13.00148], [22.00323, -16.18028], [22.17217, -16.50269], [23.20038, -17.47563], [23.47474, -17.62877], [24.23619, -17.47489], [24.32811, -17.49082], [24.38712, -17.46818], [24.5621, -17.52963], [24.70864, -17.49501], [25.00198, -17.58221], [25.26433, -17.79571], [25.51646, -17.86232], [25.6827, -17.81987], [25.85738, -17.91403], [25.85892, -17.97726], [26.08925, -17.98168], [26.0908, -17.93021], [26.21601, -17.88608], [26.55918, -17.99638], [26.68403, -18.07411], [26.74314, -18.0199], [26.89926, -17.98756], [27.14196, -17.81398], [27.30736, -17.60487], [27.61377, -17.34378], [27.62795, -17.24365], [27.83141, -16.96274], [28.73725, -16.5528], [28.76199, -16.51575], [28.81454, -16.48611], [28.8501, -16.04537], [28.9243, -15.93987], [29.01298, -15.93805], [29.21955, -15.76589], [29.4437, -15.68702], [29.8317, -15.6126], [30.35574, -15.6513], [30.41902, -15.62269], [30.22098, -14.99447], [33.24249, -14.00019], [33.16749, -13.93992], [33.07568, -13.98447], [33.02977, -14.05022], [32.99042, -13.95689], [32.88985, -13.82956], [32.79015, -13.80755], [32.76962, -13.77224], [32.84528, -13.71576], [32.7828, -13.64805], [32.68654, -13.64268], [32.66468, -13.60019], [32.68436, -13.55769], [32.73683, -13.57682], [32.84176, -13.52794], [32.86113, -13.47292], [33.0078, -13.19492], [32.98289, -13.12671], [33.02181, -12.88707], [32.96733, -12.88251], [32.94397, -12.76868], [33.05917, -12.59554], [33.18837, -12.61377], [33.28177, -12.54692], [33.37517, -12.54085], [33.54485, -12.35996], [33.47636, -12.32498], [33.3705, -12.34931], [33.25998, -12.14242], [33.33937, -11.91252], [33.32692, -11.59248], [33.24252, -11.59302], [33.23663, -11.40637], [33.29267, -11.43536], [33.29267, -11.3789], [33.39697, -11.15296], [33.25998, -10.88862], [33.28022, -10.84428], [33.47636, -10.78465], [33.70675, -10.56896], [33.54797, -10.36077], [33.53863, -10.20148], [33.31297, -10.05133], [33.37902, -9.9104], [33.36581, -9.81063], [33.31517, -9.82364], [33.2095, -9.61099], [33.12144, -9.58929], [33.10163, -9.66525], [33.05485, -9.61316], [33.00256, -9.63053], [33.00476, -9.5133], [32.95389, -9.40138]]]] } },
29250     { type: "Feature", properties: { iso1A2: "ZW", iso1A3: "ZWE", iso1N3: "716", wikidata: "Q954", nameEn: "Zimbabwe", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["263"] }, geometry: { type: "MultiPolygon", coordinates: [[[[30.41902, -15.62269], [30.35574, -15.6513], [29.8317, -15.6126], [29.4437, -15.68702], [29.21955, -15.76589], [29.01298, -15.93805], [28.9243, -15.93987], [28.8501, -16.04537], [28.81454, -16.48611], [28.76199, -16.51575], [28.73725, -16.5528], [27.83141, -16.96274], [27.62795, -17.24365], [27.61377, -17.34378], [27.30736, -17.60487], [27.14196, -17.81398], [26.89926, -17.98756], [26.74314, -18.0199], [26.68403, -18.07411], [26.55918, -17.99638], [26.21601, -17.88608], [26.0908, -17.93021], [26.08925, -17.98168], [25.85892, -17.97726], [25.85738, -17.91403], [25.6827, -17.81987], [25.51646, -17.86232], [25.26433, -17.79571], [25.23909, -17.90832], [25.31799, -18.07091], [25.39972, -18.12691], [25.53465, -18.39041], [25.68859, -18.56165], [25.79217, -18.6355], [25.82353, -18.82808], [25.94326, -18.90362], [25.99837, -19.02943], [25.96226, -19.08152], [26.17227, -19.53709], [26.72246, -19.92707], [27.21278, -20.08244], [27.29831, -20.28935], [27.28865, -20.49873], [27.69361, -20.48531], [27.72972, -20.51735], [27.69171, -21.08409], [27.91407, -21.31621], [28.01669, -21.57624], [28.29416, -21.59037], [28.49942, -21.66634], [28.58114, -21.63455], [29.07763, -21.81877], [29.04023, -21.85864], [29.02191, -21.90647], [29.02191, -21.95665], [29.04108, -22.00563], [29.08495, -22.04867], [29.14501, -22.07275], [29.1974, -22.07472], [29.24648, -22.05967], [29.3533, -22.18363], [29.37703, -22.19581], [29.64609, -22.12917], [29.76848, -22.14128], [29.92242, -22.19408], [30.13147, -22.30841], [30.2265, -22.2961], [30.28351, -22.35587], [30.38614, -22.34533], [30.48686, -22.31368], [30.6294, -22.32599], [30.86696, -22.28907], [31.08932, -22.34884], [31.16344, -22.32599], [31.30611, -22.422], [31.38336, -22.36919], [32.41234, -21.31246], [32.48236, -21.32873], [32.37115, -21.133], [32.51644, -20.91929], [32.48122, -20.63319], [32.55167, -20.56312], [32.66174, -20.56106], [32.85987, -20.27841], [32.85987, -20.16686], [32.93032, -20.03868], [33.01178, -20.02007], [33.06461, -19.77787], [32.95013, -19.67219], [32.84666, -19.68462], [32.84446, -19.48343], [32.78282, -19.47513], [32.77966, -19.36098], [32.85107, -19.29238], [32.87088, -19.09279], [32.84006, -19.0262], [32.72118, -19.02204], [32.69917, -18.94293], [32.73439, -18.92628], [32.70137, -18.84712], [32.82465, -18.77419], [32.9017, -18.7992], [32.95013, -18.69079], [32.88629, -18.58023], [32.88629, -18.51344], [33.02278, -18.4696], [33.03159, -18.35054], [32.94133, -17.99705], [33.0492, -17.60298], [32.98536, -17.55891], [32.96554, -17.48964], [33.0426, -17.3468], [33.00517, -17.30477], [32.96554, -17.11971], [32.84113, -16.92259], [32.91051, -16.89446], [32.97655, -16.70689], [32.78943, -16.70267], [32.69917, -16.66893], [32.71017, -16.59932], [32.42838, -16.4727], [32.28529, -16.43892], [32.02772, -16.43892], [31.91324, -16.41569], [31.90223, -16.34388], [31.67988, -16.19595], [31.42451, -16.15154], [31.30563, -16.01193], [31.13171, -15.98019], [30.97761, -16.05848], [30.91597, -15.99924], [30.42568, -15.9962], [30.41902, -15.62269]]]] } }
29251   ] };
29252   var borders = borders_default;
29253   var _whichPolygon = {};
29254   var _featuresByCode = {};
29255   var idFilterRegex = /(?=(?!^(and|the|of|el|la|de)$))(\b(and|the|of|el|la|de)\b)|[-_ .,'()&[\]/]/gi;
29256   function canonicalID(id2) {
29257     const s2 = id2 || "";
29258     if (s2.charAt(0) === ".") {
29259       return s2.toUpperCase();
29260     } else {
29261       return s2.replace(idFilterRegex, "").toUpperCase();
29262     }
29263   }
29264   var levels = [
29265     "subterritory",
29266     "territory",
29267     "subcountryGroup",
29268     "country",
29269     "sharedLandform",
29270     "intermediateRegion",
29271     "subregion",
29272     "region",
29273     "subunion",
29274     "union",
29275     "unitedNations",
29276     "world"
29277   ];
29278   loadDerivedDataAndCaches(borders);
29279   function loadDerivedDataAndCaches(borders2) {
29280     const identifierProps = ["iso1A2", "iso1A3", "m49", "wikidata", "emojiFlag", "ccTLD", "nameEn"];
29281     let geometryFeatures = [];
29282     for (const feature22 of borders2.features) {
29283       const props = feature22.properties;
29284       props.id = props.iso1A2 || props.m49 || props.wikidata;
29285       loadM49(feature22);
29286       loadTLD(feature22);
29287       loadIsoStatus(feature22);
29288       loadLevel(feature22);
29289       loadGroups(feature22);
29290       loadFlag(feature22);
29291       cacheFeatureByIDs(feature22);
29292       if (feature22.geometry) {
29293         geometryFeatures.push(feature22);
29294       }
29295     }
29296     for (const feature22 of borders2.features) {
29297       feature22.properties.groups = feature22.properties.groups.map((groupID) => {
29298         return _featuresByCode[groupID].properties.id;
29299       });
29300       loadMembersForGroupsOf(feature22);
29301     }
29302     for (const feature22 of borders2.features) {
29303       loadRoadSpeedUnit(feature22);
29304       loadRoadHeightUnit(feature22);
29305       loadDriveSide(feature22);
29306       loadCallingCodes(feature22);
29307       loadGroupGroups(feature22);
29308     }
29309     for (const feature22 of borders2.features) {
29310       feature22.properties.groups.sort((groupID1, groupID2) => {
29311         return levels.indexOf(_featuresByCode[groupID1].properties.level) - levels.indexOf(_featuresByCode[groupID2].properties.level);
29312       });
29313       if (feature22.properties.members) {
29314         feature22.properties.members.sort((id1, id2) => {
29315           const diff = levels.indexOf(_featuresByCode[id1].properties.level) - levels.indexOf(_featuresByCode[id2].properties.level);
29316           if (diff === 0) {
29317             return borders2.features.indexOf(_featuresByCode[id1]) - borders2.features.indexOf(_featuresByCode[id2]);
29318           }
29319           return diff;
29320         });
29321       }
29322     }
29323     const geometryOnlyCollection = {
29324       type: "FeatureCollection",
29325       features: geometryFeatures
29326     };
29327     _whichPolygon = (0, import_which_polygon.default)(geometryOnlyCollection);
29328     function loadGroups(feature22) {
29329       const props = feature22.properties;
29330       if (!props.groups) {
29331         props.groups = [];
29332       }
29333       if (feature22.geometry && props.country) {
29334         props.groups.push(props.country);
29335       }
29336       if (props.m49 !== "001") {
29337         props.groups.push("001");
29338       }
29339     }
29340     function loadM49(feature22) {
29341       const props = feature22.properties;
29342       if (!props.m49 && props.iso1N3) {
29343         props.m49 = props.iso1N3;
29344       }
29345     }
29346     function loadTLD(feature22) {
29347       const props = feature22.properties;
29348       if (props.level === "unitedNations") return;
29349       if (props.ccTLD === null) return;
29350       if (!props.ccTLD && props.iso1A2) {
29351         props.ccTLD = "." + props.iso1A2.toLowerCase();
29352       }
29353     }
29354     function loadIsoStatus(feature22) {
29355       const props = feature22.properties;
29356       if (!props.isoStatus && props.iso1A2) {
29357         props.isoStatus = "official";
29358       }
29359     }
29360     function loadLevel(feature22) {
29361       const props = feature22.properties;
29362       if (props.level) return;
29363       if (!props.country) {
29364         props.level = "country";
29365       } else if (!props.iso1A2 || props.isoStatus === "official") {
29366         props.level = "territory";
29367       } else {
29368         props.level = "subterritory";
29369       }
29370     }
29371     function loadGroupGroups(feature22) {
29372       const props = feature22.properties;
29373       if (feature22.geometry || !props.members) return;
29374       const featureLevelIndex = levels.indexOf(props.level);
29375       let sharedGroups = [];
29376       props.members.forEach((memberID, index) => {
29377         const member = _featuresByCode[memberID];
29378         const memberGroups = member.properties.groups.filter((groupID) => {
29379           return groupID !== feature22.properties.id && featureLevelIndex < levels.indexOf(_featuresByCode[groupID].properties.level);
29380         });
29381         if (index === 0) {
29382           sharedGroups = memberGroups;
29383         } else {
29384           sharedGroups = sharedGroups.filter((groupID) => memberGroups.indexOf(groupID) !== -1);
29385         }
29386       });
29387       props.groups = props.groups.concat(
29388         sharedGroups.filter((groupID) => props.groups.indexOf(groupID) === -1)
29389       );
29390       for (const groupID of sharedGroups) {
29391         const groupFeature = _featuresByCode[groupID];
29392         if (groupFeature.properties.members.indexOf(props.id) === -1) {
29393           groupFeature.properties.members.push(props.id);
29394         }
29395       }
29396     }
29397     function loadRoadSpeedUnit(feature22) {
29398       const props = feature22.properties;
29399       if (feature22.geometry) {
29400         if (!props.roadSpeedUnit) props.roadSpeedUnit = "km/h";
29401       } else if (props.members) {
29402         const vals = Array.from(
29403           new Set(
29404             props.members.map((id2) => {
29405               const member = _featuresByCode[id2];
29406               if (member.geometry) return member.properties.roadSpeedUnit || "km/h";
29407             }).filter(Boolean)
29408           )
29409         );
29410         if (vals.length === 1) props.roadSpeedUnit = vals[0];
29411       }
29412     }
29413     function loadRoadHeightUnit(feature22) {
29414       const props = feature22.properties;
29415       if (feature22.geometry) {
29416         if (!props.roadHeightUnit) props.roadHeightUnit = "m";
29417       } else if (props.members) {
29418         const vals = Array.from(
29419           new Set(
29420             props.members.map((id2) => {
29421               const member = _featuresByCode[id2];
29422               if (member.geometry) return member.properties.roadHeightUnit || "m";
29423             }).filter(Boolean)
29424           )
29425         );
29426         if (vals.length === 1) props.roadHeightUnit = vals[0];
29427       }
29428     }
29429     function loadDriveSide(feature22) {
29430       const props = feature22.properties;
29431       if (feature22.geometry) {
29432         if (!props.driveSide) props.driveSide = "right";
29433       } else if (props.members) {
29434         const vals = Array.from(
29435           new Set(
29436             props.members.map((id2) => {
29437               const member = _featuresByCode[id2];
29438               if (member.geometry) return member.properties.driveSide || "right";
29439             }).filter(Boolean)
29440           )
29441         );
29442         if (vals.length === 1) props.driveSide = vals[0];
29443       }
29444     }
29445     function loadCallingCodes(feature22) {
29446       const props = feature22.properties;
29447       if (!feature22.geometry && props.members) {
29448         props.callingCodes = Array.from(
29449           new Set(
29450             props.members.reduce((array2, id2) => {
29451               const member = _featuresByCode[id2];
29452               if (member.geometry && member.properties.callingCodes) {
29453                 return array2.concat(member.properties.callingCodes);
29454               }
29455               return array2;
29456             }, [])
29457           )
29458         );
29459       }
29460     }
29461     function loadFlag(feature22) {
29462       if (!feature22.properties.iso1A2) return;
29463       const flag = feature22.properties.iso1A2.replace(/./g, function(char) {
29464         return String.fromCodePoint(char.charCodeAt(0) + 127397);
29465       });
29466       feature22.properties.emojiFlag = flag;
29467     }
29468     function loadMembersForGroupsOf(feature22) {
29469       for (const groupID of feature22.properties.groups) {
29470         const groupFeature = _featuresByCode[groupID];
29471         if (!groupFeature.properties.members) {
29472           groupFeature.properties.members = [];
29473         }
29474         groupFeature.properties.members.push(feature22.properties.id);
29475       }
29476     }
29477     function cacheFeatureByIDs(feature22) {
29478       let ids = [];
29479       for (const prop of identifierProps) {
29480         const id2 = feature22.properties[prop];
29481         if (id2) {
29482           ids.push(id2);
29483         }
29484       }
29485       for (const alias of feature22.properties.aliases || []) {
29486         ids.push(alias);
29487       }
29488       for (const id2 of ids) {
29489         const cid = canonicalID(id2);
29490         _featuresByCode[cid] = feature22;
29491       }
29492     }
29493   }
29494   function locArray(loc) {
29495     if (Array.isArray(loc)) {
29496       return loc;
29497     } else if (loc.coordinates) {
29498       return loc.coordinates;
29499     }
29500     return loc.geometry.coordinates;
29501   }
29502   function smallestFeature(loc) {
29503     const query = locArray(loc);
29504     const featureProperties = _whichPolygon(query);
29505     if (!featureProperties) return null;
29506     return _featuresByCode[featureProperties.id];
29507   }
29508   function countryFeature(loc) {
29509     const feature22 = smallestFeature(loc);
29510     if (!feature22) return null;
29511     const countryCode = feature22.properties.country || feature22.properties.iso1A2;
29512     return _featuresByCode[countryCode] || null;
29513   }
29514   var defaultOpts = {
29515     level: void 0,
29516     maxLevel: void 0,
29517     withProp: void 0
29518   };
29519   function featureForLoc(loc, opts) {
29520     const targetLevel = opts.level || "country";
29521     const maxLevel = opts.maxLevel || "world";
29522     const withProp = opts.withProp;
29523     const targetLevelIndex = levels.indexOf(targetLevel);
29524     if (targetLevelIndex === -1) return null;
29525     const maxLevelIndex = levels.indexOf(maxLevel);
29526     if (maxLevelIndex === -1) return null;
29527     if (maxLevelIndex < targetLevelIndex) return null;
29528     if (targetLevel === "country") {
29529       const fastFeature = countryFeature(loc);
29530       if (fastFeature) {
29531         if (!withProp || fastFeature.properties[withProp]) {
29532           return fastFeature;
29533         }
29534       }
29535     }
29536     const features = featuresContaining(loc);
29537     const match = features.find((feature22) => {
29538       let levelIndex = levels.indexOf(feature22.properties.level);
29539       if (feature22.properties.level === targetLevel || // if no feature exists at the target level, return the first feature at the next level up
29540       levelIndex > targetLevelIndex && levelIndex <= maxLevelIndex) {
29541         if (!withProp || feature22.properties[withProp]) {
29542           return feature22;
29543         }
29544       }
29545       return false;
29546     });
29547     return match || null;
29548   }
29549   function featureForID(id2) {
29550     let stringID;
29551     if (typeof id2 === "number") {
29552       stringID = id2.toString();
29553       if (stringID.length === 1) {
29554         stringID = "00" + stringID;
29555       } else if (stringID.length === 2) {
29556         stringID = "0" + stringID;
29557       }
29558     } else {
29559       stringID = canonicalID(id2);
29560     }
29561     return _featuresByCode[stringID] || null;
29562   }
29563   function smallestFeaturesForBbox(bbox2) {
29564     return _whichPolygon.bbox(bbox2).map((props) => _featuresByCode[props.id]);
29565   }
29566   function smallestOrMatchingFeature(query) {
29567     if (typeof query === "object") {
29568       return smallestFeature(query);
29569     }
29570     return featureForID(query);
29571   }
29572   function feature(query, opts = defaultOpts) {
29573     if (typeof query === "object") {
29574       return featureForLoc(query, opts);
29575     }
29576     return featureForID(query);
29577   }
29578   function iso1A2Code(query, opts = defaultOpts) {
29579     opts.withProp = "iso1A2";
29580     const match = feature(query, opts);
29581     if (!match) return null;
29582     return match.properties.iso1A2 || null;
29583   }
29584   function propertiesForQuery(query, property) {
29585     const features = featuresContaining(query, false);
29586     return features.map((feature22) => feature22.properties[property]).filter(Boolean);
29587   }
29588   function iso1A2Codes(query) {
29589     return propertiesForQuery(query, "iso1A2");
29590   }
29591   function featuresContaining(query, strict) {
29592     let matchingFeatures;
29593     if (Array.isArray(query) && query.length === 4) {
29594       matchingFeatures = smallestFeaturesForBbox(query);
29595     } else {
29596       const smallestOrMatching = smallestOrMatchingFeature(query);
29597       matchingFeatures = smallestOrMatching ? [smallestOrMatching] : [];
29598     }
29599     if (!matchingFeatures.length) return [];
29600     let returnFeatures;
29601     if (!strict || typeof query === "object") {
29602       returnFeatures = matchingFeatures.slice();
29603     } else {
29604       returnFeatures = [];
29605     }
29606     for (const feature22 of matchingFeatures) {
29607       const properties = feature22.properties;
29608       for (const groupID of properties.groups) {
29609         const groupFeature = _featuresByCode[groupID];
29610         if (returnFeatures.indexOf(groupFeature) === -1) {
29611           returnFeatures.push(groupFeature);
29612         }
29613       }
29614     }
29615     return returnFeatures;
29616   }
29617   function featuresIn(id2, strict) {
29618     const feature22 = featureForID(id2);
29619     if (!feature22) return [];
29620     let features = [];
29621     if (!strict) {
29622       features.push(feature22);
29623     }
29624     const properties = feature22.properties;
29625     for (const memberID of properties.members || []) {
29626       features.push(_featuresByCode[memberID]);
29627     }
29628     return features;
29629   }
29630   function aggregateFeature(id2) {
29631     var _a4;
29632     const features = featuresIn(id2, false);
29633     if (features.length === 0) return null;
29634     let aggregateCoordinates = [];
29635     for (const feature22 of features) {
29636       if (((_a4 = feature22.geometry) == null ? void 0 : _a4.type) === "MultiPolygon" && feature22.geometry.coordinates) {
29637         aggregateCoordinates = aggregateCoordinates.concat(feature22.geometry.coordinates);
29638       }
29639     }
29640     return {
29641       type: "Feature",
29642       properties: features[0].properties,
29643       geometry: {
29644         type: "MultiPolygon",
29645         coordinates: aggregateCoordinates
29646       }
29647     };
29648   }
29649   function roadSpeedUnit(query) {
29650     const feature22 = smallestOrMatchingFeature(query);
29651     return feature22 && feature22.properties.roadSpeedUnit || null;
29652   }
29653   function roadHeightUnit(query) {
29654     const feature22 = smallestOrMatchingFeature(query);
29655     return feature22 && feature22.properties.roadHeightUnit || null;
29656   }
29657
29658   // node_modules/bignumber.js/bignumber.mjs
29659   var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
29660   var mathceil = Math.ceil;
29661   var mathfloor = Math.floor;
29662   var bignumberError = "[BigNumber Error] ";
29663   var tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ";
29664   var BASE = 1e14;
29665   var LOG_BASE = 14;
29666   var MAX_SAFE_INTEGER3 = 9007199254740991;
29667   var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
29668   var SQRT_BASE = 1e7;
29669   var MAX = 1e9;
29670   function clone(configObject) {
29671     var div, convertBase, parseNumeric2, P2 = BigNumber2.prototype = { constructor: BigNumber2, toString: null, valueOf: null }, ONE = new BigNumber2(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
29672       prefix: "",
29673       groupSize: 3,
29674       secondaryGroupSize: 0,
29675       groupSeparator: ",",
29676       decimalSeparator: ".",
29677       fractionGroupSize: 0,
29678       fractionGroupSeparator: "\xA0",
29679       // non-breaking space
29680       suffix: ""
29681     }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
29682     function BigNumber2(v2, b2) {
29683       var alphabet, c2, caseChanged, e3, i3, isNum, len, str, x2 = this;
29684       if (!(x2 instanceof BigNumber2)) return new BigNumber2(v2, b2);
29685       if (b2 == null) {
29686         if (v2 && v2._isBigNumber === true) {
29687           x2.s = v2.s;
29688           if (!v2.c || v2.e > MAX_EXP) {
29689             x2.c = x2.e = null;
29690           } else if (v2.e < MIN_EXP) {
29691             x2.c = [x2.e = 0];
29692           } else {
29693             x2.e = v2.e;
29694             x2.c = v2.c.slice();
29695           }
29696           return;
29697         }
29698         if ((isNum = typeof v2 == "number") && v2 * 0 == 0) {
29699           x2.s = 1 / v2 < 0 ? (v2 = -v2, -1) : 1;
29700           if (v2 === ~~v2) {
29701             for (e3 = 0, i3 = v2; i3 >= 10; i3 /= 10, e3++) ;
29702             if (e3 > MAX_EXP) {
29703               x2.c = x2.e = null;
29704             } else {
29705               x2.e = e3;
29706               x2.c = [v2];
29707             }
29708             return;
29709           }
29710           str = String(v2);
29711         } else {
29712           if (!isNumeric.test(str = String(v2))) return parseNumeric2(x2, str, isNum);
29713           x2.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
29714         }
29715         if ((e3 = str.indexOf(".")) > -1) str = str.replace(".", "");
29716         if ((i3 = str.search(/e/i)) > 0) {
29717           if (e3 < 0) e3 = i3;
29718           e3 += +str.slice(i3 + 1);
29719           str = str.substring(0, i3);
29720         } else if (e3 < 0) {
29721           e3 = str.length;
29722         }
29723       } else {
29724         intCheck(b2, 2, ALPHABET.length, "Base");
29725         if (b2 == 10 && alphabetHasNormalDecimalDigits) {
29726           x2 = new BigNumber2(v2);
29727           return round(x2, DECIMAL_PLACES + x2.e + 1, ROUNDING_MODE);
29728         }
29729         str = String(v2);
29730         if (isNum = typeof v2 == "number") {
29731           if (v2 * 0 != 0) return parseNumeric2(x2, str, isNum, b2);
29732           x2.s = 1 / v2 < 0 ? (str = str.slice(1), -1) : 1;
29733           if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
29734             throw Error(tooManyDigits + v2);
29735           }
29736         } else {
29737           x2.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
29738         }
29739         alphabet = ALPHABET.slice(0, b2);
29740         e3 = i3 = 0;
29741         for (len = str.length; i3 < len; i3++) {
29742           if (alphabet.indexOf(c2 = str.charAt(i3)) < 0) {
29743             if (c2 == ".") {
29744               if (i3 > e3) {
29745                 e3 = len;
29746                 continue;
29747               }
29748             } else if (!caseChanged) {
29749               if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
29750                 caseChanged = true;
29751                 i3 = -1;
29752                 e3 = 0;
29753                 continue;
29754               }
29755             }
29756             return parseNumeric2(x2, String(v2), isNum, b2);
29757           }
29758         }
29759         isNum = false;
29760         str = convertBase(str, b2, 10, x2.s);
29761         if ((e3 = str.indexOf(".")) > -1) str = str.replace(".", "");
29762         else e3 = str.length;
29763       }
29764       for (i3 = 0; str.charCodeAt(i3) === 48; i3++) ;
29765       for (len = str.length; str.charCodeAt(--len) === 48; ) ;
29766       if (str = str.slice(i3, ++len)) {
29767         len -= i3;
29768         if (isNum && BigNumber2.DEBUG && len > 15 && (v2 > MAX_SAFE_INTEGER3 || v2 !== mathfloor(v2))) {
29769           throw Error(tooManyDigits + x2.s * v2);
29770         }
29771         if ((e3 = e3 - i3 - 1) > MAX_EXP) {
29772           x2.c = x2.e = null;
29773         } else if (e3 < MIN_EXP) {
29774           x2.c = [x2.e = 0];
29775         } else {
29776           x2.e = e3;
29777           x2.c = [];
29778           i3 = (e3 + 1) % LOG_BASE;
29779           if (e3 < 0) i3 += LOG_BASE;
29780           if (i3 < len) {
29781             if (i3) x2.c.push(+str.slice(0, i3));
29782             for (len -= LOG_BASE; i3 < len; ) {
29783               x2.c.push(+str.slice(i3, i3 += LOG_BASE));
29784             }
29785             i3 = LOG_BASE - (str = str.slice(i3)).length;
29786           } else {
29787             i3 -= len;
29788           }
29789           for (; i3--; str += "0") ;
29790           x2.c.push(+str);
29791         }
29792       } else {
29793         x2.c = [x2.e = 0];
29794       }
29795     }
29796     BigNumber2.clone = clone;
29797     BigNumber2.ROUND_UP = 0;
29798     BigNumber2.ROUND_DOWN = 1;
29799     BigNumber2.ROUND_CEIL = 2;
29800     BigNumber2.ROUND_FLOOR = 3;
29801     BigNumber2.ROUND_HALF_UP = 4;
29802     BigNumber2.ROUND_HALF_DOWN = 5;
29803     BigNumber2.ROUND_HALF_EVEN = 6;
29804     BigNumber2.ROUND_HALF_CEIL = 7;
29805     BigNumber2.ROUND_HALF_FLOOR = 8;
29806     BigNumber2.EUCLID = 9;
29807     BigNumber2.config = BigNumber2.set = function(obj) {
29808       var p2, v2;
29809       if (obj != null) {
29810         if (typeof obj == "object") {
29811           if (obj.hasOwnProperty(p2 = "DECIMAL_PLACES")) {
29812             v2 = obj[p2];
29813             intCheck(v2, 0, MAX, p2);
29814             DECIMAL_PLACES = v2;
29815           }
29816           if (obj.hasOwnProperty(p2 = "ROUNDING_MODE")) {
29817             v2 = obj[p2];
29818             intCheck(v2, 0, 8, p2);
29819             ROUNDING_MODE = v2;
29820           }
29821           if (obj.hasOwnProperty(p2 = "EXPONENTIAL_AT")) {
29822             v2 = obj[p2];
29823             if (v2 && v2.pop) {
29824               intCheck(v2[0], -MAX, 0, p2);
29825               intCheck(v2[1], 0, MAX, p2);
29826               TO_EXP_NEG = v2[0];
29827               TO_EXP_POS = v2[1];
29828             } else {
29829               intCheck(v2, -MAX, MAX, p2);
29830               TO_EXP_NEG = -(TO_EXP_POS = v2 < 0 ? -v2 : v2);
29831             }
29832           }
29833           if (obj.hasOwnProperty(p2 = "RANGE")) {
29834             v2 = obj[p2];
29835             if (v2 && v2.pop) {
29836               intCheck(v2[0], -MAX, -1, p2);
29837               intCheck(v2[1], 1, MAX, p2);
29838               MIN_EXP = v2[0];
29839               MAX_EXP = v2[1];
29840             } else {
29841               intCheck(v2, -MAX, MAX, p2);
29842               if (v2) {
29843                 MIN_EXP = -(MAX_EXP = v2 < 0 ? -v2 : v2);
29844               } else {
29845                 throw Error(bignumberError + p2 + " cannot be zero: " + v2);
29846               }
29847             }
29848           }
29849           if (obj.hasOwnProperty(p2 = "CRYPTO")) {
29850             v2 = obj[p2];
29851             if (v2 === !!v2) {
29852               if (v2) {
29853                 if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
29854                   CRYPTO = v2;
29855                 } else {
29856                   CRYPTO = !v2;
29857                   throw Error(bignumberError + "crypto unavailable");
29858                 }
29859               } else {
29860                 CRYPTO = v2;
29861               }
29862             } else {
29863               throw Error(bignumberError + p2 + " not true or false: " + v2);
29864             }
29865           }
29866           if (obj.hasOwnProperty(p2 = "MODULO_MODE")) {
29867             v2 = obj[p2];
29868             intCheck(v2, 0, 9, p2);
29869             MODULO_MODE = v2;
29870           }
29871           if (obj.hasOwnProperty(p2 = "POW_PRECISION")) {
29872             v2 = obj[p2];
29873             intCheck(v2, 0, MAX, p2);
29874             POW_PRECISION = v2;
29875           }
29876           if (obj.hasOwnProperty(p2 = "FORMAT")) {
29877             v2 = obj[p2];
29878             if (typeof v2 == "object") FORMAT = v2;
29879             else throw Error(bignumberError + p2 + " not an object: " + v2);
29880           }
29881           if (obj.hasOwnProperty(p2 = "ALPHABET")) {
29882             v2 = obj[p2];
29883             if (typeof v2 == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v2)) {
29884               alphabetHasNormalDecimalDigits = v2.slice(0, 10) == "0123456789";
29885               ALPHABET = v2;
29886             } else {
29887               throw Error(bignumberError + p2 + " invalid: " + v2);
29888             }
29889           }
29890         } else {
29891           throw Error(bignumberError + "Object expected: " + obj);
29892         }
29893       }
29894       return {
29895         DECIMAL_PLACES,
29896         ROUNDING_MODE,
29897         EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
29898         RANGE: [MIN_EXP, MAX_EXP],
29899         CRYPTO,
29900         MODULO_MODE,
29901         POW_PRECISION,
29902         FORMAT,
29903         ALPHABET
29904       };
29905     };
29906     BigNumber2.isBigNumber = function(v2) {
29907       if (!v2 || v2._isBigNumber !== true) return false;
29908       if (!BigNumber2.DEBUG) return true;
29909       var i3, n3, c2 = v2.c, e3 = v2.e, s2 = v2.s;
29910       out: if ({}.toString.call(c2) == "[object Array]") {
29911         if ((s2 === 1 || s2 === -1) && e3 >= -MAX && e3 <= MAX && e3 === mathfloor(e3)) {
29912           if (c2[0] === 0) {
29913             if (e3 === 0 && c2.length === 1) return true;
29914             break out;
29915           }
29916           i3 = (e3 + 1) % LOG_BASE;
29917           if (i3 < 1) i3 += LOG_BASE;
29918           if (String(c2[0]).length == i3) {
29919             for (i3 = 0; i3 < c2.length; i3++) {
29920               n3 = c2[i3];
29921               if (n3 < 0 || n3 >= BASE || n3 !== mathfloor(n3)) break out;
29922             }
29923             if (n3 !== 0) return true;
29924           }
29925         }
29926       } else if (c2 === null && e3 === null && (s2 === null || s2 === 1 || s2 === -1)) {
29927         return true;
29928       }
29929       throw Error(bignumberError + "Invalid BigNumber: " + v2);
29930     };
29931     BigNumber2.maximum = BigNumber2.max = function() {
29932       return maxOrMin(arguments, -1);
29933     };
29934     BigNumber2.minimum = BigNumber2.min = function() {
29935       return maxOrMin(arguments, 1);
29936     };
29937     BigNumber2.random = function() {
29938       var pow2_53 = 9007199254740992;
29939       var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
29940         return mathfloor(Math.random() * pow2_53);
29941       } : function() {
29942         return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
29943       };
29944       return function(dp) {
29945         var a2, b2, e3, k2, v2, i3 = 0, c2 = [], rand = new BigNumber2(ONE);
29946         if (dp == null) dp = DECIMAL_PLACES;
29947         else intCheck(dp, 0, MAX);
29948         k2 = mathceil(dp / LOG_BASE);
29949         if (CRYPTO) {
29950           if (crypto.getRandomValues) {
29951             a2 = crypto.getRandomValues(new Uint32Array(k2 *= 2));
29952             for (; i3 < k2; ) {
29953               v2 = a2[i3] * 131072 + (a2[i3 + 1] >>> 11);
29954               if (v2 >= 9e15) {
29955                 b2 = crypto.getRandomValues(new Uint32Array(2));
29956                 a2[i3] = b2[0];
29957                 a2[i3 + 1] = b2[1];
29958               } else {
29959                 c2.push(v2 % 1e14);
29960                 i3 += 2;
29961               }
29962             }
29963             i3 = k2 / 2;
29964           } else if (crypto.randomBytes) {
29965             a2 = crypto.randomBytes(k2 *= 7);
29966             for (; i3 < k2; ) {
29967               v2 = (a2[i3] & 31) * 281474976710656 + a2[i3 + 1] * 1099511627776 + a2[i3 + 2] * 4294967296 + a2[i3 + 3] * 16777216 + (a2[i3 + 4] << 16) + (a2[i3 + 5] << 8) + a2[i3 + 6];
29968               if (v2 >= 9e15) {
29969                 crypto.randomBytes(7).copy(a2, i3);
29970               } else {
29971                 c2.push(v2 % 1e14);
29972                 i3 += 7;
29973               }
29974             }
29975             i3 = k2 / 7;
29976           } else {
29977             CRYPTO = false;
29978             throw Error(bignumberError + "crypto unavailable");
29979           }
29980         }
29981         if (!CRYPTO) {
29982           for (; i3 < k2; ) {
29983             v2 = random53bitInt();
29984             if (v2 < 9e15) c2[i3++] = v2 % 1e14;
29985           }
29986         }
29987         k2 = c2[--i3];
29988         dp %= LOG_BASE;
29989         if (k2 && dp) {
29990           v2 = POWS_TEN[LOG_BASE - dp];
29991           c2[i3] = mathfloor(k2 / v2) * v2;
29992         }
29993         for (; c2[i3] === 0; c2.pop(), i3--) ;
29994         if (i3 < 0) {
29995           c2 = [e3 = 0];
29996         } else {
29997           for (e3 = -1; c2[0] === 0; c2.splice(0, 1), e3 -= LOG_BASE) ;
29998           for (i3 = 1, v2 = c2[0]; v2 >= 10; v2 /= 10, i3++) ;
29999           if (i3 < LOG_BASE) e3 -= LOG_BASE - i3;
30000         }
30001         rand.e = e3;
30002         rand.c = c2;
30003         return rand;
30004       };
30005     }();
30006     BigNumber2.sum = function() {
30007       var i3 = 1, args = arguments, sum = new BigNumber2(args[0]);
30008       for (; i3 < args.length; ) sum = sum.plus(args[i3++]);
30009       return sum;
30010     };
30011     convertBase = /* @__PURE__ */ function() {
30012       var decimal = "0123456789";
30013       function toBaseOut(str, baseIn, baseOut, alphabet) {
30014         var j2, arr = [0], arrL, i3 = 0, len = str.length;
30015         for (; i3 < len; ) {
30016           for (arrL = arr.length; arrL--; arr[arrL] *= baseIn) ;
30017           arr[0] += alphabet.indexOf(str.charAt(i3++));
30018           for (j2 = 0; j2 < arr.length; j2++) {
30019             if (arr[j2] > baseOut - 1) {
30020               if (arr[j2 + 1] == null) arr[j2 + 1] = 0;
30021               arr[j2 + 1] += arr[j2] / baseOut | 0;
30022               arr[j2] %= baseOut;
30023             }
30024           }
30025         }
30026         return arr.reverse();
30027       }
30028       return function(str, baseIn, baseOut, sign2, callerIsToString) {
30029         var alphabet, d2, e3, k2, r2, x2, xc, y2, i3 = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
30030         if (i3 >= 0) {
30031           k2 = POW_PRECISION;
30032           POW_PRECISION = 0;
30033           str = str.replace(".", "");
30034           y2 = new BigNumber2(baseIn);
30035           x2 = y2.pow(str.length - i3);
30036           POW_PRECISION = k2;
30037           y2.c = toBaseOut(
30038             toFixedPoint(coeffToString(x2.c), x2.e, "0"),
30039             10,
30040             baseOut,
30041             decimal
30042           );
30043           y2.e = y2.c.length;
30044         }
30045         xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
30046         e3 = k2 = xc.length;
30047         for (; xc[--k2] == 0; xc.pop()) ;
30048         if (!xc[0]) return alphabet.charAt(0);
30049         if (i3 < 0) {
30050           --e3;
30051         } else {
30052           x2.c = xc;
30053           x2.e = e3;
30054           x2.s = sign2;
30055           x2 = div(x2, y2, dp, rm, baseOut);
30056           xc = x2.c;
30057           r2 = x2.r;
30058           e3 = x2.e;
30059         }
30060         d2 = e3 + dp + 1;
30061         i3 = xc[d2];
30062         k2 = baseOut / 2;
30063         r2 = r2 || d2 < 0 || xc[d2 + 1] != null;
30064         r2 = rm < 4 ? (i3 != null || r2) && (rm == 0 || rm == (x2.s < 0 ? 3 : 2)) : i3 > k2 || i3 == k2 && (rm == 4 || r2 || rm == 6 && xc[d2 - 1] & 1 || rm == (x2.s < 0 ? 8 : 7));
30065         if (d2 < 1 || !xc[0]) {
30066           str = r2 ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
30067         } else {
30068           xc.length = d2;
30069           if (r2) {
30070             for (--baseOut; ++xc[--d2] > baseOut; ) {
30071               xc[d2] = 0;
30072               if (!d2) {
30073                 ++e3;
30074                 xc = [1].concat(xc);
30075               }
30076             }
30077           }
30078           for (k2 = xc.length; !xc[--k2]; ) ;
30079           for (i3 = 0, str = ""; i3 <= k2; str += alphabet.charAt(xc[i3++])) ;
30080           str = toFixedPoint(str, e3, alphabet.charAt(0));
30081         }
30082         return str;
30083       };
30084     }();
30085     div = /* @__PURE__ */ function() {
30086       function multiply(x2, k2, base) {
30087         var m2, temp, xlo, xhi, carry = 0, i3 = x2.length, klo = k2 % SQRT_BASE, khi = k2 / SQRT_BASE | 0;
30088         for (x2 = x2.slice(); i3--; ) {
30089           xlo = x2[i3] % SQRT_BASE;
30090           xhi = x2[i3] / SQRT_BASE | 0;
30091           m2 = khi * xlo + xhi * klo;
30092           temp = klo * xlo + m2 % SQRT_BASE * SQRT_BASE + carry;
30093           carry = (temp / base | 0) + (m2 / SQRT_BASE | 0) + khi * xhi;
30094           x2[i3] = temp % base;
30095         }
30096         if (carry) x2 = [carry].concat(x2);
30097         return x2;
30098       }
30099       function compare2(a2, b2, aL, bL) {
30100         var i3, cmp;
30101         if (aL != bL) {
30102           cmp = aL > bL ? 1 : -1;
30103         } else {
30104           for (i3 = cmp = 0; i3 < aL; i3++) {
30105             if (a2[i3] != b2[i3]) {
30106               cmp = a2[i3] > b2[i3] ? 1 : -1;
30107               break;
30108             }
30109           }
30110         }
30111         return cmp;
30112       }
30113       function subtract(a2, b2, aL, base) {
30114         var i3 = 0;
30115         for (; aL--; ) {
30116           a2[aL] -= i3;
30117           i3 = a2[aL] < b2[aL] ? 1 : 0;
30118           a2[aL] = i3 * base + a2[aL] - b2[aL];
30119         }
30120         for (; !a2[0] && a2.length > 1; a2.splice(0, 1)) ;
30121       }
30122       return function(x2, y2, dp, rm, base) {
30123         var cmp, e3, i3, more, n3, prod, prodL, q2, qc, rem, remL, rem0, xi, xL, yc0, yL, yz, s2 = x2.s == y2.s ? 1 : -1, xc = x2.c, yc = y2.c;
30124         if (!xc || !xc[0] || !yc || !yc[0]) {
30125           return new BigNumber2(
30126             // Return NaN if either NaN, or both Infinity or 0.
30127             !x2.s || !y2.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : (
30128               // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
30129               xc && xc[0] == 0 || !yc ? s2 * 0 : s2 / 0
30130             )
30131           );
30132         }
30133         q2 = new BigNumber2(s2);
30134         qc = q2.c = [];
30135         e3 = x2.e - y2.e;
30136         s2 = dp + e3 + 1;
30137         if (!base) {
30138           base = BASE;
30139           e3 = bitFloor(x2.e / LOG_BASE) - bitFloor(y2.e / LOG_BASE);
30140           s2 = s2 / LOG_BASE | 0;
30141         }
30142         for (i3 = 0; yc[i3] == (xc[i3] || 0); i3++) ;
30143         if (yc[i3] > (xc[i3] || 0)) e3--;
30144         if (s2 < 0) {
30145           qc.push(1);
30146           more = true;
30147         } else {
30148           xL = xc.length;
30149           yL = yc.length;
30150           i3 = 0;
30151           s2 += 2;
30152           n3 = mathfloor(base / (yc[0] + 1));
30153           if (n3 > 1) {
30154             yc = multiply(yc, n3, base);
30155             xc = multiply(xc, n3, base);
30156             yL = yc.length;
30157             xL = xc.length;
30158           }
30159           xi = yL;
30160           rem = xc.slice(0, yL);
30161           remL = rem.length;
30162           for (; remL < yL; rem[remL++] = 0) ;
30163           yz = yc.slice();
30164           yz = [0].concat(yz);
30165           yc0 = yc[0];
30166           if (yc[1] >= base / 2) yc0++;
30167           do {
30168             n3 = 0;
30169             cmp = compare2(yc, rem, yL, remL);
30170             if (cmp < 0) {
30171               rem0 = rem[0];
30172               if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
30173               n3 = mathfloor(rem0 / yc0);
30174               if (n3 > 1) {
30175                 if (n3 >= base) n3 = base - 1;
30176                 prod = multiply(yc, n3, base);
30177                 prodL = prod.length;
30178                 remL = rem.length;
30179                 while (compare2(prod, rem, prodL, remL) == 1) {
30180                   n3--;
30181                   subtract(prod, yL < prodL ? yz : yc, prodL, base);
30182                   prodL = prod.length;
30183                   cmp = 1;
30184                 }
30185               } else {
30186                 if (n3 == 0) {
30187                   cmp = n3 = 1;
30188                 }
30189                 prod = yc.slice();
30190                 prodL = prod.length;
30191               }
30192               if (prodL < remL) prod = [0].concat(prod);
30193               subtract(rem, prod, remL, base);
30194               remL = rem.length;
30195               if (cmp == -1) {
30196                 while (compare2(yc, rem, yL, remL) < 1) {
30197                   n3++;
30198                   subtract(rem, yL < remL ? yz : yc, remL, base);
30199                   remL = rem.length;
30200                 }
30201               }
30202             } else if (cmp === 0) {
30203               n3++;
30204               rem = [0];
30205             }
30206             qc[i3++] = n3;
30207             if (rem[0]) {
30208               rem[remL++] = xc[xi] || 0;
30209             } else {
30210               rem = [xc[xi]];
30211               remL = 1;
30212             }
30213           } while ((xi++ < xL || rem[0] != null) && s2--);
30214           more = rem[0] != null;
30215           if (!qc[0]) qc.splice(0, 1);
30216         }
30217         if (base == BASE) {
30218           for (i3 = 1, s2 = qc[0]; s2 >= 10; s2 /= 10, i3++) ;
30219           round(q2, dp + (q2.e = i3 + e3 * LOG_BASE - 1) + 1, rm, more);
30220         } else {
30221           q2.e = e3;
30222           q2.r = +more;
30223         }
30224         return q2;
30225       };
30226     }();
30227     function format2(n3, i3, rm, id2) {
30228       var c0, e3, ne2, len, str;
30229       if (rm == null) rm = ROUNDING_MODE;
30230       else intCheck(rm, 0, 8);
30231       if (!n3.c) return n3.toString();
30232       c0 = n3.c[0];
30233       ne2 = n3.e;
30234       if (i3 == null) {
30235         str = coeffToString(n3.c);
30236         str = id2 == 1 || id2 == 2 && (ne2 <= TO_EXP_NEG || ne2 >= TO_EXP_POS) ? toExponential(str, ne2) : toFixedPoint(str, ne2, "0");
30237       } else {
30238         n3 = round(new BigNumber2(n3), i3, rm);
30239         e3 = n3.e;
30240         str = coeffToString(n3.c);
30241         len = str.length;
30242         if (id2 == 1 || id2 == 2 && (i3 <= e3 || e3 <= TO_EXP_NEG)) {
30243           for (; len < i3; str += "0", len++) ;
30244           str = toExponential(str, e3);
30245         } else {
30246           i3 -= ne2;
30247           str = toFixedPoint(str, e3, "0");
30248           if (e3 + 1 > len) {
30249             if (--i3 > 0) for (str += "."; i3--; str += "0") ;
30250           } else {
30251             i3 += e3 - len;
30252             if (i3 > 0) {
30253               if (e3 + 1 == len) str += ".";
30254               for (; i3--; str += "0") ;
30255             }
30256           }
30257         }
30258       }
30259       return n3.s < 0 && c0 ? "-" + str : str;
30260     }
30261     function maxOrMin(args, n3) {
30262       var k2, y2, i3 = 1, x2 = new BigNumber2(args[0]);
30263       for (; i3 < args.length; i3++) {
30264         y2 = new BigNumber2(args[i3]);
30265         if (!y2.s || (k2 = compare(x2, y2)) === n3 || k2 === 0 && x2.s === n3) {
30266           x2 = y2;
30267         }
30268       }
30269       return x2;
30270     }
30271     function normalise(n3, c2, e3) {
30272       var i3 = 1, j2 = c2.length;
30273       for (; !c2[--j2]; c2.pop()) ;
30274       for (j2 = c2[0]; j2 >= 10; j2 /= 10, i3++) ;
30275       if ((e3 = i3 + e3 * LOG_BASE - 1) > MAX_EXP) {
30276         n3.c = n3.e = null;
30277       } else if (e3 < MIN_EXP) {
30278         n3.c = [n3.e = 0];
30279       } else {
30280         n3.e = e3;
30281         n3.c = c2;
30282       }
30283       return n3;
30284     }
30285     parseNumeric2 = /* @__PURE__ */ function() {
30286       var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
30287       return function(x2, str, isNum, b2) {
30288         var base, s2 = isNum ? str : str.replace(whitespaceOrPlus, "");
30289         if (isInfinityOrNaN.test(s2)) {
30290           x2.s = isNaN(s2) ? null : s2 < 0 ? -1 : 1;
30291         } else {
30292           if (!isNum) {
30293             s2 = s2.replace(basePrefix, function(m2, p1, p2) {
30294               base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
30295               return !b2 || b2 == base ? p1 : m2;
30296             });
30297             if (b2) {
30298               base = b2;
30299               s2 = s2.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
30300             }
30301             if (str != s2) return new BigNumber2(s2, base);
30302           }
30303           if (BigNumber2.DEBUG) {
30304             throw Error(bignumberError + "Not a" + (b2 ? " base " + b2 : "") + " number: " + str);
30305           }
30306           x2.s = null;
30307         }
30308         x2.c = x2.e = null;
30309       };
30310     }();
30311     function round(x2, sd, rm, r2) {
30312       var d2, i3, j2, k2, n3, ni, rd, xc = x2.c, pows10 = POWS_TEN;
30313       if (xc) {
30314         out: {
30315           for (d2 = 1, k2 = xc[0]; k2 >= 10; k2 /= 10, d2++) ;
30316           i3 = sd - d2;
30317           if (i3 < 0) {
30318             i3 += LOG_BASE;
30319             j2 = sd;
30320             n3 = xc[ni = 0];
30321             rd = mathfloor(n3 / pows10[d2 - j2 - 1] % 10);
30322           } else {
30323             ni = mathceil((i3 + 1) / LOG_BASE);
30324             if (ni >= xc.length) {
30325               if (r2) {
30326                 for (; xc.length <= ni; xc.push(0)) ;
30327                 n3 = rd = 0;
30328                 d2 = 1;
30329                 i3 %= LOG_BASE;
30330                 j2 = i3 - LOG_BASE + 1;
30331               } else {
30332                 break out;
30333               }
30334             } else {
30335               n3 = k2 = xc[ni];
30336               for (d2 = 1; k2 >= 10; k2 /= 10, d2++) ;
30337               i3 %= LOG_BASE;
30338               j2 = i3 - LOG_BASE + d2;
30339               rd = j2 < 0 ? 0 : mathfloor(n3 / pows10[d2 - j2 - 1] % 10);
30340             }
30341           }
30342           r2 = r2 || sd < 0 || // Are there any non-zero digits after the rounding digit?
30343           // The expression  n % pows10[d - j - 1]  returns all digits of n to the right
30344           // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
30345           xc[ni + 1] != null || (j2 < 0 ? n3 : n3 % pows10[d2 - j2 - 1]);
30346           r2 = rm < 4 ? (rd || r2) && (rm == 0 || rm == (x2.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r2 || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
30347           (i3 > 0 ? j2 > 0 ? n3 / pows10[d2 - j2] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x2.s < 0 ? 8 : 7));
30348           if (sd < 1 || !xc[0]) {
30349             xc.length = 0;
30350             if (r2) {
30351               sd -= x2.e + 1;
30352               xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
30353               x2.e = -sd || 0;
30354             } else {
30355               xc[0] = x2.e = 0;
30356             }
30357             return x2;
30358           }
30359           if (i3 == 0) {
30360             xc.length = ni;
30361             k2 = 1;
30362             ni--;
30363           } else {
30364             xc.length = ni + 1;
30365             k2 = pows10[LOG_BASE - i3];
30366             xc[ni] = j2 > 0 ? mathfloor(n3 / pows10[d2 - j2] % pows10[j2]) * k2 : 0;
30367           }
30368           if (r2) {
30369             for (; ; ) {
30370               if (ni == 0) {
30371                 for (i3 = 1, j2 = xc[0]; j2 >= 10; j2 /= 10, i3++) ;
30372                 j2 = xc[0] += k2;
30373                 for (k2 = 1; j2 >= 10; j2 /= 10, k2++) ;
30374                 if (i3 != k2) {
30375                   x2.e++;
30376                   if (xc[0] == BASE) xc[0] = 1;
30377                 }
30378                 break;
30379               } else {
30380                 xc[ni] += k2;
30381                 if (xc[ni] != BASE) break;
30382                 xc[ni--] = 0;
30383                 k2 = 1;
30384               }
30385             }
30386           }
30387           for (i3 = xc.length; xc[--i3] === 0; xc.pop()) ;
30388         }
30389         if (x2.e > MAX_EXP) {
30390           x2.c = x2.e = null;
30391         } else if (x2.e < MIN_EXP) {
30392           x2.c = [x2.e = 0];
30393         }
30394       }
30395       return x2;
30396     }
30397     function valueOf(n3) {
30398       var str, e3 = n3.e;
30399       if (e3 === null) return n3.toString();
30400       str = coeffToString(n3.c);
30401       str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(str, e3) : toFixedPoint(str, e3, "0");
30402       return n3.s < 0 ? "-" + str : str;
30403     }
30404     P2.absoluteValue = P2.abs = function() {
30405       var x2 = new BigNumber2(this);
30406       if (x2.s < 0) x2.s = 1;
30407       return x2;
30408     };
30409     P2.comparedTo = function(y2, b2) {
30410       return compare(this, new BigNumber2(y2, b2));
30411     };
30412     P2.decimalPlaces = P2.dp = function(dp, rm) {
30413       var c2, n3, v2, x2 = this;
30414       if (dp != null) {
30415         intCheck(dp, 0, MAX);
30416         if (rm == null) rm = ROUNDING_MODE;
30417         else intCheck(rm, 0, 8);
30418         return round(new BigNumber2(x2), dp + x2.e + 1, rm);
30419       }
30420       if (!(c2 = x2.c)) return null;
30421       n3 = ((v2 = c2.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
30422       if (v2 = c2[v2]) for (; v2 % 10 == 0; v2 /= 10, n3--) ;
30423       if (n3 < 0) n3 = 0;
30424       return n3;
30425     };
30426     P2.dividedBy = P2.div = function(y2, b2) {
30427       return div(this, new BigNumber2(y2, b2), DECIMAL_PLACES, ROUNDING_MODE);
30428     };
30429     P2.dividedToIntegerBy = P2.idiv = function(y2, b2) {
30430       return div(this, new BigNumber2(y2, b2), 0, 1);
30431     };
30432     P2.exponentiatedBy = P2.pow = function(n3, m2) {
30433       var half, isModExp, i3, k2, more, nIsBig, nIsNeg, nIsOdd, y2, x2 = this;
30434       n3 = new BigNumber2(n3);
30435       if (n3.c && !n3.isInteger()) {
30436         throw Error(bignumberError + "Exponent not an integer: " + valueOf(n3));
30437       }
30438       if (m2 != null) m2 = new BigNumber2(m2);
30439       nIsBig = n3.e > 14;
30440       if (!x2.c || !x2.c[0] || x2.c[0] == 1 && !x2.e && x2.c.length == 1 || !n3.c || !n3.c[0]) {
30441         y2 = new BigNumber2(Math.pow(+valueOf(x2), nIsBig ? n3.s * (2 - isOdd(n3)) : +valueOf(n3)));
30442         return m2 ? y2.mod(m2) : y2;
30443       }
30444       nIsNeg = n3.s < 0;
30445       if (m2) {
30446         if (m2.c ? !m2.c[0] : !m2.s) return new BigNumber2(NaN);
30447         isModExp = !nIsNeg && x2.isInteger() && m2.isInteger();
30448         if (isModExp) x2 = x2.mod(m2);
30449       } else if (n3.e > 9 && (x2.e > 0 || x2.e < -1 || (x2.e == 0 ? x2.c[0] > 1 || nIsBig && x2.c[1] >= 24e7 : x2.c[0] < 8e13 || nIsBig && x2.c[0] <= 9999975e7))) {
30450         k2 = x2.s < 0 && isOdd(n3) ? -0 : 0;
30451         if (x2.e > -1) k2 = 1 / k2;
30452         return new BigNumber2(nIsNeg ? 1 / k2 : k2);
30453       } else if (POW_PRECISION) {
30454         k2 = mathceil(POW_PRECISION / LOG_BASE + 2);
30455       }
30456       if (nIsBig) {
30457         half = new BigNumber2(0.5);
30458         if (nIsNeg) n3.s = 1;
30459         nIsOdd = isOdd(n3);
30460       } else {
30461         i3 = Math.abs(+valueOf(n3));
30462         nIsOdd = i3 % 2;
30463       }
30464       y2 = new BigNumber2(ONE);
30465       for (; ; ) {
30466         if (nIsOdd) {
30467           y2 = y2.times(x2);
30468           if (!y2.c) break;
30469           if (k2) {
30470             if (y2.c.length > k2) y2.c.length = k2;
30471           } else if (isModExp) {
30472             y2 = y2.mod(m2);
30473           }
30474         }
30475         if (i3) {
30476           i3 = mathfloor(i3 / 2);
30477           if (i3 === 0) break;
30478           nIsOdd = i3 % 2;
30479         } else {
30480           n3 = n3.times(half);
30481           round(n3, n3.e + 1, 1);
30482           if (n3.e > 14) {
30483             nIsOdd = isOdd(n3);
30484           } else {
30485             i3 = +valueOf(n3);
30486             if (i3 === 0) break;
30487             nIsOdd = i3 % 2;
30488           }
30489         }
30490         x2 = x2.times(x2);
30491         if (k2) {
30492           if (x2.c && x2.c.length > k2) x2.c.length = k2;
30493         } else if (isModExp) {
30494           x2 = x2.mod(m2);
30495         }
30496       }
30497       if (isModExp) return y2;
30498       if (nIsNeg) y2 = ONE.div(y2);
30499       return m2 ? y2.mod(m2) : k2 ? round(y2, POW_PRECISION, ROUNDING_MODE, more) : y2;
30500     };
30501     P2.integerValue = function(rm) {
30502       var n3 = new BigNumber2(this);
30503       if (rm == null) rm = ROUNDING_MODE;
30504       else intCheck(rm, 0, 8);
30505       return round(n3, n3.e + 1, rm);
30506     };
30507     P2.isEqualTo = P2.eq = function(y2, b2) {
30508       return compare(this, new BigNumber2(y2, b2)) === 0;
30509     };
30510     P2.isFinite = function() {
30511       return !!this.c;
30512     };
30513     P2.isGreaterThan = P2.gt = function(y2, b2) {
30514       return compare(this, new BigNumber2(y2, b2)) > 0;
30515     };
30516     P2.isGreaterThanOrEqualTo = P2.gte = function(y2, b2) {
30517       return (b2 = compare(this, new BigNumber2(y2, b2))) === 1 || b2 === 0;
30518     };
30519     P2.isInteger = function() {
30520       return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
30521     };
30522     P2.isLessThan = P2.lt = function(y2, b2) {
30523       return compare(this, new BigNumber2(y2, b2)) < 0;
30524     };
30525     P2.isLessThanOrEqualTo = P2.lte = function(y2, b2) {
30526       return (b2 = compare(this, new BigNumber2(y2, b2))) === -1 || b2 === 0;
30527     };
30528     P2.isNaN = function() {
30529       return !this.s;
30530     };
30531     P2.isNegative = function() {
30532       return this.s < 0;
30533     };
30534     P2.isPositive = function() {
30535       return this.s > 0;
30536     };
30537     P2.isZero = function() {
30538       return !!this.c && this.c[0] == 0;
30539     };
30540     P2.minus = function(y2, b2) {
30541       var i3, j2, t2, xLTy, x2 = this, a2 = x2.s;
30542       y2 = new BigNumber2(y2, b2);
30543       b2 = y2.s;
30544       if (!a2 || !b2) return new BigNumber2(NaN);
30545       if (a2 != b2) {
30546         y2.s = -b2;
30547         return x2.plus(y2);
30548       }
30549       var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c;
30550       if (!xe2 || !ye2) {
30551         if (!xc || !yc) return xc ? (y2.s = -b2, y2) : new BigNumber2(yc ? x2 : NaN);
30552         if (!xc[0] || !yc[0]) {
30553           return yc[0] ? (y2.s = -b2, y2) : new BigNumber2(xc[0] ? x2 : (
30554             // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
30555             ROUNDING_MODE == 3 ? -0 : 0
30556           ));
30557         }
30558       }
30559       xe2 = bitFloor(xe2);
30560       ye2 = bitFloor(ye2);
30561       xc = xc.slice();
30562       if (a2 = xe2 - ye2) {
30563         if (xLTy = a2 < 0) {
30564           a2 = -a2;
30565           t2 = xc;
30566         } else {
30567           ye2 = xe2;
30568           t2 = yc;
30569         }
30570         t2.reverse();
30571         for (b2 = a2; b2--; t2.push(0)) ;
30572         t2.reverse();
30573       } else {
30574         j2 = (xLTy = (a2 = xc.length) < (b2 = yc.length)) ? a2 : b2;
30575         for (a2 = b2 = 0; b2 < j2; b2++) {
30576           if (xc[b2] != yc[b2]) {
30577             xLTy = xc[b2] < yc[b2];
30578             break;
30579           }
30580         }
30581       }
30582       if (xLTy) {
30583         t2 = xc;
30584         xc = yc;
30585         yc = t2;
30586         y2.s = -y2.s;
30587       }
30588       b2 = (j2 = yc.length) - (i3 = xc.length);
30589       if (b2 > 0) for (; b2--; xc[i3++] = 0) ;
30590       b2 = BASE - 1;
30591       for (; j2 > a2; ) {
30592         if (xc[--j2] < yc[j2]) {
30593           for (i3 = j2; i3 && !xc[--i3]; xc[i3] = b2) ;
30594           --xc[i3];
30595           xc[j2] += BASE;
30596         }
30597         xc[j2] -= yc[j2];
30598       }
30599       for (; xc[0] == 0; xc.splice(0, 1), --ye2) ;
30600       if (!xc[0]) {
30601         y2.s = ROUNDING_MODE == 3 ? -1 : 1;
30602         y2.c = [y2.e = 0];
30603         return y2;
30604       }
30605       return normalise(y2, xc, ye2);
30606     };
30607     P2.modulo = P2.mod = function(y2, b2) {
30608       var q2, s2, x2 = this;
30609       y2 = new BigNumber2(y2, b2);
30610       if (!x2.c || !y2.s || y2.c && !y2.c[0]) {
30611         return new BigNumber2(NaN);
30612       } else if (!y2.c || x2.c && !x2.c[0]) {
30613         return new BigNumber2(x2);
30614       }
30615       if (MODULO_MODE == 9) {
30616         s2 = y2.s;
30617         y2.s = 1;
30618         q2 = div(x2, y2, 0, 3);
30619         y2.s = s2;
30620         q2.s *= s2;
30621       } else {
30622         q2 = div(x2, y2, 0, MODULO_MODE);
30623       }
30624       y2 = x2.minus(q2.times(y2));
30625       if (!y2.c[0] && MODULO_MODE == 1) y2.s = x2.s;
30626       return y2;
30627     };
30628     P2.multipliedBy = P2.times = function(y2, b2) {
30629       var c2, e3, i3, j2, k2, m2, xcL, xlo, xhi, ycL, ylo, yhi, zc, base, sqrtBase, x2 = this, xc = x2.c, yc = (y2 = new BigNumber2(y2, b2)).c;
30630       if (!xc || !yc || !xc[0] || !yc[0]) {
30631         if (!x2.s || !y2.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
30632           y2.c = y2.e = y2.s = null;
30633         } else {
30634           y2.s *= x2.s;
30635           if (!xc || !yc) {
30636             y2.c = y2.e = null;
30637           } else {
30638             y2.c = [0];
30639             y2.e = 0;
30640           }
30641         }
30642         return y2;
30643       }
30644       e3 = bitFloor(x2.e / LOG_BASE) + bitFloor(y2.e / LOG_BASE);
30645       y2.s *= x2.s;
30646       xcL = xc.length;
30647       ycL = yc.length;
30648       if (xcL < ycL) {
30649         zc = xc;
30650         xc = yc;
30651         yc = zc;
30652         i3 = xcL;
30653         xcL = ycL;
30654         ycL = i3;
30655       }
30656       for (i3 = xcL + ycL, zc = []; i3--; zc.push(0)) ;
30657       base = BASE;
30658       sqrtBase = SQRT_BASE;
30659       for (i3 = ycL; --i3 >= 0; ) {
30660         c2 = 0;
30661         ylo = yc[i3] % sqrtBase;
30662         yhi = yc[i3] / sqrtBase | 0;
30663         for (k2 = xcL, j2 = i3 + k2; j2 > i3; ) {
30664           xlo = xc[--k2] % sqrtBase;
30665           xhi = xc[k2] / sqrtBase | 0;
30666           m2 = yhi * xlo + xhi * ylo;
30667           xlo = ylo * xlo + m2 % sqrtBase * sqrtBase + zc[j2] + c2;
30668           c2 = (xlo / base | 0) + (m2 / sqrtBase | 0) + yhi * xhi;
30669           zc[j2--] = xlo % base;
30670         }
30671         zc[j2] = c2;
30672       }
30673       if (c2) {
30674         ++e3;
30675       } else {
30676         zc.splice(0, 1);
30677       }
30678       return normalise(y2, zc, e3);
30679     };
30680     P2.negated = function() {
30681       var x2 = new BigNumber2(this);
30682       x2.s = -x2.s || null;
30683       return x2;
30684     };
30685     P2.plus = function(y2, b2) {
30686       var t2, x2 = this, a2 = x2.s;
30687       y2 = new BigNumber2(y2, b2);
30688       b2 = y2.s;
30689       if (!a2 || !b2) return new BigNumber2(NaN);
30690       if (a2 != b2) {
30691         y2.s = -b2;
30692         return x2.minus(y2);
30693       }
30694       var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c;
30695       if (!xe2 || !ye2) {
30696         if (!xc || !yc) return new BigNumber2(a2 / 0);
30697         if (!xc[0] || !yc[0]) return yc[0] ? y2 : new BigNumber2(xc[0] ? x2 : a2 * 0);
30698       }
30699       xe2 = bitFloor(xe2);
30700       ye2 = bitFloor(ye2);
30701       xc = xc.slice();
30702       if (a2 = xe2 - ye2) {
30703         if (a2 > 0) {
30704           ye2 = xe2;
30705           t2 = yc;
30706         } else {
30707           a2 = -a2;
30708           t2 = xc;
30709         }
30710         t2.reverse();
30711         for (; a2--; t2.push(0)) ;
30712         t2.reverse();
30713       }
30714       a2 = xc.length;
30715       b2 = yc.length;
30716       if (a2 - b2 < 0) {
30717         t2 = yc;
30718         yc = xc;
30719         xc = t2;
30720         b2 = a2;
30721       }
30722       for (a2 = 0; b2; ) {
30723         a2 = (xc[--b2] = xc[b2] + yc[b2] + a2) / BASE | 0;
30724         xc[b2] = BASE === xc[b2] ? 0 : xc[b2] % BASE;
30725       }
30726       if (a2) {
30727         xc = [a2].concat(xc);
30728         ++ye2;
30729       }
30730       return normalise(y2, xc, ye2);
30731     };
30732     P2.precision = P2.sd = function(sd, rm) {
30733       var c2, n3, v2, x2 = this;
30734       if (sd != null && sd !== !!sd) {
30735         intCheck(sd, 1, MAX);
30736         if (rm == null) rm = ROUNDING_MODE;
30737         else intCheck(rm, 0, 8);
30738         return round(new BigNumber2(x2), sd, rm);
30739       }
30740       if (!(c2 = x2.c)) return null;
30741       v2 = c2.length - 1;
30742       n3 = v2 * LOG_BASE + 1;
30743       if (v2 = c2[v2]) {
30744         for (; v2 % 10 == 0; v2 /= 10, n3--) ;
30745         for (v2 = c2[0]; v2 >= 10; v2 /= 10, n3++) ;
30746       }
30747       if (sd && x2.e + 1 > n3) n3 = x2.e + 1;
30748       return n3;
30749     };
30750     P2.shiftedBy = function(k2) {
30751       intCheck(k2, -MAX_SAFE_INTEGER3, MAX_SAFE_INTEGER3);
30752       return this.times("1e" + k2);
30753     };
30754     P2.squareRoot = P2.sqrt = function() {
30755       var m2, n3, r2, rep, t2, x2 = this, c2 = x2.c, s2 = x2.s, e3 = x2.e, dp = DECIMAL_PLACES + 4, half = new BigNumber2("0.5");
30756       if (s2 !== 1 || !c2 || !c2[0]) {
30757         return new BigNumber2(!s2 || s2 < 0 && (!c2 || c2[0]) ? NaN : c2 ? x2 : 1 / 0);
30758       }
30759       s2 = Math.sqrt(+valueOf(x2));
30760       if (s2 == 0 || s2 == 1 / 0) {
30761         n3 = coeffToString(c2);
30762         if ((n3.length + e3) % 2 == 0) n3 += "0";
30763         s2 = Math.sqrt(+n3);
30764         e3 = bitFloor((e3 + 1) / 2) - (e3 < 0 || e3 % 2);
30765         if (s2 == 1 / 0) {
30766           n3 = "5e" + e3;
30767         } else {
30768           n3 = s2.toExponential();
30769           n3 = n3.slice(0, n3.indexOf("e") + 1) + e3;
30770         }
30771         r2 = new BigNumber2(n3);
30772       } else {
30773         r2 = new BigNumber2(s2 + "");
30774       }
30775       if (r2.c[0]) {
30776         e3 = r2.e;
30777         s2 = e3 + dp;
30778         if (s2 < 3) s2 = 0;
30779         for (; ; ) {
30780           t2 = r2;
30781           r2 = half.times(t2.plus(div(x2, t2, dp, 1)));
30782           if (coeffToString(t2.c).slice(0, s2) === (n3 = coeffToString(r2.c)).slice(0, s2)) {
30783             if (r2.e < e3) --s2;
30784             n3 = n3.slice(s2 - 3, s2 + 1);
30785             if (n3 == "9999" || !rep && n3 == "4999") {
30786               if (!rep) {
30787                 round(t2, t2.e + DECIMAL_PLACES + 2, 0);
30788                 if (t2.times(t2).eq(x2)) {
30789                   r2 = t2;
30790                   break;
30791                 }
30792               }
30793               dp += 4;
30794               s2 += 4;
30795               rep = 1;
30796             } else {
30797               if (!+n3 || !+n3.slice(1) && n3.charAt(0) == "5") {
30798                 round(r2, r2.e + DECIMAL_PLACES + 2, 1);
30799                 m2 = !r2.times(r2).eq(x2);
30800               }
30801               break;
30802             }
30803           }
30804         }
30805       }
30806       return round(r2, r2.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m2);
30807     };
30808     P2.toExponential = function(dp, rm) {
30809       if (dp != null) {
30810         intCheck(dp, 0, MAX);
30811         dp++;
30812       }
30813       return format2(this, dp, rm, 1);
30814     };
30815     P2.toFixed = function(dp, rm) {
30816       if (dp != null) {
30817         intCheck(dp, 0, MAX);
30818         dp = dp + this.e + 1;
30819       }
30820       return format2(this, dp, rm);
30821     };
30822     P2.toFormat = function(dp, rm, format3) {
30823       var str, x2 = this;
30824       if (format3 == null) {
30825         if (dp != null && rm && typeof rm == "object") {
30826           format3 = rm;
30827           rm = null;
30828         } else if (dp && typeof dp == "object") {
30829           format3 = dp;
30830           dp = rm = null;
30831         } else {
30832           format3 = FORMAT;
30833         }
30834       } else if (typeof format3 != "object") {
30835         throw Error(bignumberError + "Argument not an object: " + format3);
30836       }
30837       str = x2.toFixed(dp, rm);
30838       if (x2.c) {
30839         var i3, arr = str.split("."), g1 = +format3.groupSize, g22 = +format3.secondaryGroupSize, groupSeparator = format3.groupSeparator || "", intPart = arr[0], fractionPart = arr[1], isNeg = x2.s < 0, intDigits = isNeg ? intPart.slice(1) : intPart, len = intDigits.length;
30840         if (g22) {
30841           i3 = g1;
30842           g1 = g22;
30843           g22 = i3;
30844           len -= i3;
30845         }
30846         if (g1 > 0 && len > 0) {
30847           i3 = len % g1 || g1;
30848           intPart = intDigits.substr(0, i3);
30849           for (; i3 < len; i3 += g1) intPart += groupSeparator + intDigits.substr(i3, g1);
30850           if (g22 > 0) intPart += groupSeparator + intDigits.slice(i3);
30851           if (isNeg) intPart = "-" + intPart;
30852         }
30853         str = fractionPart ? intPart + (format3.decimalSeparator || "") + ((g22 = +format3.fractionGroupSize) ? fractionPart.replace(
30854           new RegExp("\\d{" + g22 + "}\\B", "g"),
30855           "$&" + (format3.fractionGroupSeparator || "")
30856         ) : fractionPart) : intPart;
30857       }
30858       return (format3.prefix || "") + str + (format3.suffix || "");
30859     };
30860     P2.toFraction = function(md) {
30861       var d2, d0, d1, d22, e3, exp2, n3, n0, n1, q2, r2, s2, x2 = this, xc = x2.c;
30862       if (md != null) {
30863         n3 = new BigNumber2(md);
30864         if (!n3.isInteger() && (n3.c || n3.s !== 1) || n3.lt(ONE)) {
30865           throw Error(bignumberError + "Argument " + (n3.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n3));
30866         }
30867       }
30868       if (!xc) return new BigNumber2(x2);
30869       d2 = new BigNumber2(ONE);
30870       n1 = d0 = new BigNumber2(ONE);
30871       d1 = n0 = new BigNumber2(ONE);
30872       s2 = coeffToString(xc);
30873       e3 = d2.e = s2.length - x2.e - 1;
30874       d2.c[0] = POWS_TEN[(exp2 = e3 % LOG_BASE) < 0 ? LOG_BASE + exp2 : exp2];
30875       md = !md || n3.comparedTo(d2) > 0 ? e3 > 0 ? d2 : n1 : n3;
30876       exp2 = MAX_EXP;
30877       MAX_EXP = 1 / 0;
30878       n3 = new BigNumber2(s2);
30879       n0.c[0] = 0;
30880       for (; ; ) {
30881         q2 = div(n3, d2, 0, 1);
30882         d22 = d0.plus(q2.times(d1));
30883         if (d22.comparedTo(md) == 1) break;
30884         d0 = d1;
30885         d1 = d22;
30886         n1 = n0.plus(q2.times(d22 = n1));
30887         n0 = d22;
30888         d2 = n3.minus(q2.times(d22 = d2));
30889         n3 = d22;
30890       }
30891       d22 = div(md.minus(d0), d1, 0, 1);
30892       n0 = n0.plus(d22.times(n1));
30893       d0 = d0.plus(d22.times(d1));
30894       n0.s = n1.s = x2.s;
30895       e3 = e3 * 2;
30896       r2 = div(n1, d1, e3, ROUNDING_MODE).minus(x2).abs().comparedTo(
30897         div(n0, d0, e3, ROUNDING_MODE).minus(x2).abs()
30898       ) < 1 ? [n1, d1] : [n0, d0];
30899       MAX_EXP = exp2;
30900       return r2;
30901     };
30902     P2.toNumber = function() {
30903       return +valueOf(this);
30904     };
30905     P2.toPrecision = function(sd, rm) {
30906       if (sd != null) intCheck(sd, 1, MAX);
30907       return format2(this, sd, rm, 2);
30908     };
30909     P2.toString = function(b2) {
30910       var str, n3 = this, s2 = n3.s, e3 = n3.e;
30911       if (e3 === null) {
30912         if (s2) {
30913           str = "Infinity";
30914           if (s2 < 0) str = "-" + str;
30915         } else {
30916           str = "NaN";
30917         }
30918       } else {
30919         if (b2 == null) {
30920           str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(coeffToString(n3.c), e3) : toFixedPoint(coeffToString(n3.c), e3, "0");
30921         } else if (b2 === 10 && alphabetHasNormalDecimalDigits) {
30922           n3 = round(new BigNumber2(n3), DECIMAL_PLACES + e3 + 1, ROUNDING_MODE);
30923           str = toFixedPoint(coeffToString(n3.c), n3.e, "0");
30924         } else {
30925           intCheck(b2, 2, ALPHABET.length, "Base");
30926           str = convertBase(toFixedPoint(coeffToString(n3.c), e3, "0"), 10, b2, s2, true);
30927         }
30928         if (s2 < 0 && n3.c[0]) str = "-" + str;
30929       }
30930       return str;
30931     };
30932     P2.valueOf = P2.toJSON = function() {
30933       return valueOf(this);
30934     };
30935     P2._isBigNumber = true;
30936     P2[Symbol.toStringTag] = "BigNumber";
30937     P2[Symbol.for("nodejs.util.inspect.custom")] = P2.valueOf;
30938     if (configObject != null) BigNumber2.set(configObject);
30939     return BigNumber2;
30940   }
30941   function bitFloor(n3) {
30942     var i3 = n3 | 0;
30943     return n3 > 0 || n3 === i3 ? i3 : i3 - 1;
30944   }
30945   function coeffToString(a2) {
30946     var s2, z2, i3 = 1, j2 = a2.length, r2 = a2[0] + "";
30947     for (; i3 < j2; ) {
30948       s2 = a2[i3++] + "";
30949       z2 = LOG_BASE - s2.length;
30950       for (; z2--; s2 = "0" + s2) ;
30951       r2 += s2;
30952     }
30953     for (j2 = r2.length; r2.charCodeAt(--j2) === 48; ) ;
30954     return r2.slice(0, j2 + 1 || 1);
30955   }
30956   function compare(x2, y2) {
30957     var a2, b2, xc = x2.c, yc = y2.c, i3 = x2.s, j2 = y2.s, k2 = x2.e, l2 = y2.e;
30958     if (!i3 || !j2) return null;
30959     a2 = xc && !xc[0];
30960     b2 = yc && !yc[0];
30961     if (a2 || b2) return a2 ? b2 ? 0 : -j2 : i3;
30962     if (i3 != j2) return i3;
30963     a2 = i3 < 0;
30964     b2 = k2 == l2;
30965     if (!xc || !yc) return b2 ? 0 : !xc ^ a2 ? 1 : -1;
30966     if (!b2) return k2 > l2 ^ a2 ? 1 : -1;
30967     j2 = (k2 = xc.length) < (l2 = yc.length) ? k2 : l2;
30968     for (i3 = 0; i3 < j2; i3++) if (xc[i3] != yc[i3]) return xc[i3] > yc[i3] ^ a2 ? 1 : -1;
30969     return k2 == l2 ? 0 : k2 > l2 ^ a2 ? 1 : -1;
30970   }
30971   function intCheck(n3, min3, max3, name) {
30972     if (n3 < min3 || n3 > max3 || n3 !== mathfloor(n3)) {
30973       throw Error(bignumberError + (name || "Argument") + (typeof n3 == "number" ? n3 < min3 || n3 > max3 ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n3));
30974     }
30975   }
30976   function isOdd(n3) {
30977     var k2 = n3.c.length - 1;
30978     return bitFloor(n3.e / LOG_BASE) == k2 && n3.c[k2] % 2 != 0;
30979   }
30980   function toExponential(str, e3) {
30981     return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e3 < 0 ? "e" : "e+") + e3;
30982   }
30983   function toFixedPoint(str, e3, z2) {
30984     var len, zs;
30985     if (e3 < 0) {
30986       for (zs = z2 + "."; ++e3; zs += z2) ;
30987       str = zs + str;
30988     } else {
30989       len = str.length;
30990       if (++e3 > len) {
30991         for (zs = z2, e3 -= len; --e3; zs += z2) ;
30992         str += zs;
30993       } else if (e3 < len) {
30994         str = str.slice(0, e3) + "." + str.slice(e3);
30995       }
30996     }
30997     return str;
30998   }
30999   var BigNumber = clone();
31000   var bignumber_default = BigNumber;
31001
31002   // node_modules/splaytree-ts/dist/esm/index.js
31003   var SplayTreeNode = class {
31004     constructor(key) {
31005       __publicField(this, "key");
31006       __publicField(this, "left", null);
31007       __publicField(this, "right", null);
31008       this.key = key;
31009     }
31010   };
31011   var SplayTreeSetNode = class extends SplayTreeNode {
31012     constructor(key) {
31013       super(key);
31014     }
31015   };
31016   var SplayTree = class {
31017     constructor() {
31018       __publicField(this, "size", 0);
31019       __publicField(this, "modificationCount", 0);
31020       __publicField(this, "splayCount", 0);
31021     }
31022     splay(key) {
31023       const root3 = this.root;
31024       if (root3 == null) {
31025         this.compare(key, key);
31026         return -1;
31027       }
31028       let right = null;
31029       let newTreeRight = null;
31030       let left = null;
31031       let newTreeLeft = null;
31032       let current = root3;
31033       const compare2 = this.compare;
31034       let comp;
31035       while (true) {
31036         comp = compare2(current.key, key);
31037         if (comp > 0) {
31038           let currentLeft = current.left;
31039           if (currentLeft == null) break;
31040           comp = compare2(currentLeft.key, key);
31041           if (comp > 0) {
31042             current.left = currentLeft.right;
31043             currentLeft.right = current;
31044             current = currentLeft;
31045             currentLeft = current.left;
31046             if (currentLeft == null) break;
31047           }
31048           if (right == null) {
31049             newTreeRight = current;
31050           } else {
31051             right.left = current;
31052           }
31053           right = current;
31054           current = currentLeft;
31055         } else if (comp < 0) {
31056           let currentRight = current.right;
31057           if (currentRight == null) break;
31058           comp = compare2(currentRight.key, key);
31059           if (comp < 0) {
31060             current.right = currentRight.left;
31061             currentRight.left = current;
31062             current = currentRight;
31063             currentRight = current.right;
31064             if (currentRight == null) break;
31065           }
31066           if (left == null) {
31067             newTreeLeft = current;
31068           } else {
31069             left.right = current;
31070           }
31071           left = current;
31072           current = currentRight;
31073         } else {
31074           break;
31075         }
31076       }
31077       if (left != null) {
31078         left.right = current.left;
31079         current.left = newTreeLeft;
31080       }
31081       if (right != null) {
31082         right.left = current.right;
31083         current.right = newTreeRight;
31084       }
31085       if (this.root !== current) {
31086         this.root = current;
31087         this.splayCount++;
31088       }
31089       return comp;
31090     }
31091     splayMin(node) {
31092       let current = node;
31093       let nextLeft = current.left;
31094       while (nextLeft != null) {
31095         const left = nextLeft;
31096         current.left = left.right;
31097         left.right = current;
31098         current = left;
31099         nextLeft = current.left;
31100       }
31101       return current;
31102     }
31103     splayMax(node) {
31104       let current = node;
31105       let nextRight = current.right;
31106       while (nextRight != null) {
31107         const right = nextRight;
31108         current.right = right.left;
31109         right.left = current;
31110         current = right;
31111         nextRight = current.right;
31112       }
31113       return current;
31114     }
31115     _delete(key) {
31116       if (this.root == null) return null;
31117       const comp = this.splay(key);
31118       if (comp != 0) return null;
31119       let root3 = this.root;
31120       const result = root3;
31121       const left = root3.left;
31122       this.size--;
31123       if (left == null) {
31124         this.root = root3.right;
31125       } else {
31126         const right = root3.right;
31127         root3 = this.splayMax(left);
31128         root3.right = right;
31129         this.root = root3;
31130       }
31131       this.modificationCount++;
31132       return result;
31133     }
31134     addNewRoot(node, comp) {
31135       this.size++;
31136       this.modificationCount++;
31137       const root3 = this.root;
31138       if (root3 == null) {
31139         this.root = node;
31140         return;
31141       }
31142       if (comp < 0) {
31143         node.left = root3;
31144         node.right = root3.right;
31145         root3.right = null;
31146       } else {
31147         node.right = root3;
31148         node.left = root3.left;
31149         root3.left = null;
31150       }
31151       this.root = node;
31152     }
31153     _first() {
31154       const root3 = this.root;
31155       if (root3 == null) return null;
31156       this.root = this.splayMin(root3);
31157       return this.root;
31158     }
31159     _last() {
31160       const root3 = this.root;
31161       if (root3 == null) return null;
31162       this.root = this.splayMax(root3);
31163       return this.root;
31164     }
31165     clear() {
31166       this.root = null;
31167       this.size = 0;
31168       this.modificationCount++;
31169     }
31170     has(key) {
31171       return this.validKey(key) && this.splay(key) == 0;
31172     }
31173     defaultCompare() {
31174       return (a2, b2) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
31175     }
31176     wrap() {
31177       return {
31178         getRoot: () => {
31179           return this.root;
31180         },
31181         setRoot: (root3) => {
31182           this.root = root3;
31183         },
31184         getSize: () => {
31185           return this.size;
31186         },
31187         getModificationCount: () => {
31188           return this.modificationCount;
31189         },
31190         getSplayCount: () => {
31191           return this.splayCount;
31192         },
31193         setSplayCount: (count) => {
31194           this.splayCount = count;
31195         },
31196         splay: (key) => {
31197           return this.splay(key);
31198         },
31199         has: (key) => {
31200           return this.has(key);
31201         }
31202       };
31203     }
31204   };
31205   var _a2, _b2;
31206   var SplayTreeSet = class _SplayTreeSet extends SplayTree {
31207     constructor(compare2, isValidKey) {
31208       super();
31209       __publicField(this, "root", null);
31210       __publicField(this, "compare");
31211       __publicField(this, "validKey");
31212       __publicField(this, _a2, "[object Set]");
31213       this.compare = compare2 != null ? compare2 : this.defaultCompare();
31214       this.validKey = isValidKey != null ? isValidKey : (v2) => v2 != null && v2 != void 0;
31215     }
31216     delete(element) {
31217       if (!this.validKey(element)) return false;
31218       return this._delete(element) != null;
31219     }
31220     deleteAll(elements) {
31221       for (const element of elements) {
31222         this.delete(element);
31223       }
31224     }
31225     forEach(f2) {
31226       const nodes = this[Symbol.iterator]();
31227       let result;
31228       while (result = nodes.next(), !result.done) {
31229         f2(result.value, result.value, this);
31230       }
31231     }
31232     add(element) {
31233       const compare2 = this.splay(element);
31234       if (compare2 != 0) this.addNewRoot(new SplayTreeSetNode(element), compare2);
31235       return this;
31236     }
31237     addAndReturn(element) {
31238       const compare2 = this.splay(element);
31239       if (compare2 != 0) this.addNewRoot(new SplayTreeSetNode(element), compare2);
31240       return this.root.key;
31241     }
31242     addAll(elements) {
31243       for (const element of elements) {
31244         this.add(element);
31245       }
31246     }
31247     isEmpty() {
31248       return this.root == null;
31249     }
31250     isNotEmpty() {
31251       return this.root != null;
31252     }
31253     single() {
31254       if (this.size == 0) throw "Bad state: No element";
31255       if (this.size > 1) throw "Bad state: Too many element";
31256       return this.root.key;
31257     }
31258     first() {
31259       if (this.size == 0) throw "Bad state: No element";
31260       return this._first().key;
31261     }
31262     last() {
31263       if (this.size == 0) throw "Bad state: No element";
31264       return this._last().key;
31265     }
31266     lastBefore(element) {
31267       if (element == null) throw "Invalid arguments(s)";
31268       if (this.root == null) return null;
31269       const comp = this.splay(element);
31270       if (comp < 0) return this.root.key;
31271       let node = this.root.left;
31272       if (node == null) return null;
31273       let nodeRight = node.right;
31274       while (nodeRight != null) {
31275         node = nodeRight;
31276         nodeRight = node.right;
31277       }
31278       return node.key;
31279     }
31280     firstAfter(element) {
31281       if (element == null) throw "Invalid arguments(s)";
31282       if (this.root == null) return null;
31283       const comp = this.splay(element);
31284       if (comp > 0) return this.root.key;
31285       let node = this.root.right;
31286       if (node == null) return null;
31287       let nodeLeft = node.left;
31288       while (nodeLeft != null) {
31289         node = nodeLeft;
31290         nodeLeft = node.left;
31291       }
31292       return node.key;
31293     }
31294     retainAll(elements) {
31295       const retainSet = new _SplayTreeSet(this.compare, this.validKey);
31296       const modificationCount = this.modificationCount;
31297       for (const object of elements) {
31298         if (modificationCount != this.modificationCount) {
31299           throw "Concurrent modification during iteration.";
31300         }
31301         if (this.validKey(object) && this.splay(object) == 0) {
31302           retainSet.add(this.root.key);
31303         }
31304       }
31305       if (retainSet.size != this.size) {
31306         this.root = retainSet.root;
31307         this.size = retainSet.size;
31308         this.modificationCount++;
31309       }
31310     }
31311     lookup(object) {
31312       if (!this.validKey(object)) return null;
31313       const comp = this.splay(object);
31314       if (comp != 0) return null;
31315       return this.root.key;
31316     }
31317     intersection(other2) {
31318       const result = new _SplayTreeSet(this.compare, this.validKey);
31319       for (const element of this) {
31320         if (other2.has(element)) result.add(element);
31321       }
31322       return result;
31323     }
31324     difference(other2) {
31325       const result = new _SplayTreeSet(this.compare, this.validKey);
31326       for (const element of this) {
31327         if (!other2.has(element)) result.add(element);
31328       }
31329       return result;
31330     }
31331     union(other2) {
31332       const u2 = this.clone();
31333       u2.addAll(other2);
31334       return u2;
31335     }
31336     clone() {
31337       const set4 = new _SplayTreeSet(this.compare, this.validKey);
31338       set4.size = this.size;
31339       set4.root = this.copyNode(this.root);
31340       return set4;
31341     }
31342     copyNode(node) {
31343       if (node == null) return null;
31344       function copyChildren(node2, dest) {
31345         let left;
31346         let right;
31347         do {
31348           left = node2.left;
31349           right = node2.right;
31350           if (left != null) {
31351             const newLeft = new SplayTreeSetNode(left.key);
31352             dest.left = newLeft;
31353             copyChildren(left, newLeft);
31354           }
31355           if (right != null) {
31356             const newRight = new SplayTreeSetNode(right.key);
31357             dest.right = newRight;
31358             node2 = right;
31359             dest = newRight;
31360           }
31361         } while (right != null);
31362       }
31363       const result = new SplayTreeSetNode(node.key);
31364       copyChildren(node, result);
31365       return result;
31366     }
31367     toSet() {
31368       return this.clone();
31369     }
31370     entries() {
31371       return new SplayTreeSetEntryIterableIterator(this.wrap());
31372     }
31373     keys() {
31374       return this[Symbol.iterator]();
31375     }
31376     values() {
31377       return this[Symbol.iterator]();
31378     }
31379     [(_b2 = Symbol.iterator, _a2 = Symbol.toStringTag, _b2)]() {
31380       return new SplayTreeKeyIterableIterator(this.wrap());
31381     }
31382   };
31383   var SplayTreeIterableIterator = class {
31384     constructor(tree) {
31385       __publicField(this, "tree");
31386       __publicField(this, "path", new Array());
31387       __publicField(this, "modificationCount", null);
31388       __publicField(this, "splayCount");
31389       this.tree = tree;
31390       this.splayCount = tree.getSplayCount();
31391     }
31392     [Symbol.iterator]() {
31393       return this;
31394     }
31395     next() {
31396       if (this.moveNext()) return { done: false, value: this.current() };
31397       return { done: true, value: null };
31398     }
31399     current() {
31400       if (!this.path.length) return null;
31401       const node = this.path[this.path.length - 1];
31402       return this.getValue(node);
31403     }
31404     rebuildPath(key) {
31405       this.path.splice(0, this.path.length);
31406       this.tree.splay(key);
31407       this.path.push(this.tree.getRoot());
31408       this.splayCount = this.tree.getSplayCount();
31409     }
31410     findLeftMostDescendent(node) {
31411       while (node != null) {
31412         this.path.push(node);
31413         node = node.left;
31414       }
31415     }
31416     moveNext() {
31417       if (this.modificationCount != this.tree.getModificationCount()) {
31418         if (this.modificationCount == null) {
31419           this.modificationCount = this.tree.getModificationCount();
31420           let node2 = this.tree.getRoot();
31421           while (node2 != null) {
31422             this.path.push(node2);
31423             node2 = node2.left;
31424           }
31425           return this.path.length > 0;
31426         }
31427         throw "Concurrent modification during iteration.";
31428       }
31429       if (!this.path.length) return false;
31430       if (this.splayCount != this.tree.getSplayCount()) {
31431         this.rebuildPath(this.path[this.path.length - 1].key);
31432       }
31433       let node = this.path[this.path.length - 1];
31434       let next = node.right;
31435       if (next != null) {
31436         while (next != null) {
31437           this.path.push(next);
31438           next = next.left;
31439         }
31440         return true;
31441       }
31442       this.path.pop();
31443       while (this.path.length && this.path[this.path.length - 1].right === node) {
31444         node = this.path.pop();
31445       }
31446       return this.path.length > 0;
31447     }
31448   };
31449   var SplayTreeKeyIterableIterator = class extends SplayTreeIterableIterator {
31450     getValue(node) {
31451       return node.key;
31452     }
31453   };
31454   var SplayTreeSetEntryIterableIterator = class extends SplayTreeIterableIterator {
31455     getValue(node) {
31456       return [node.key, node.key];
31457     }
31458   };
31459
31460   // node_modules/polyclip-ts/dist/esm/index.js
31461   var constant_default5 = (x2) => {
31462     return () => {
31463       return x2;
31464     };
31465   };
31466   var compare_default = (eps) => {
31467     const almostEqual = eps ? (a2, b2) => b2.minus(a2).abs().isLessThanOrEqualTo(eps) : constant_default5(false);
31468     return (a2, b2) => {
31469       if (almostEqual(a2, b2)) return 0;
31470       return a2.comparedTo(b2);
31471     };
31472   };
31473   function orient_default(eps) {
31474     const almostCollinear = eps ? (area2, ax, ay, cx, cy) => area2.exponentiatedBy(2).isLessThanOrEqualTo(
31475       cx.minus(ax).exponentiatedBy(2).plus(cy.minus(ay).exponentiatedBy(2)).times(eps)
31476     ) : constant_default5(false);
31477     return (a2, b2, c2) => {
31478       const ax = a2.x, ay = a2.y, cx = c2.x, cy = c2.y;
31479       const area2 = ay.minus(cy).times(b2.x.minus(cx)).minus(ax.minus(cx).times(b2.y.minus(cy)));
31480       if (almostCollinear(area2, ax, ay, cx, cy)) return 0;
31481       return area2.comparedTo(0);
31482     };
31483   }
31484   var identity_default3 = (x2) => {
31485     return x2;
31486   };
31487   var snap_default = (eps) => {
31488     if (eps) {
31489       const xTree = new SplayTreeSet(compare_default(eps));
31490       const yTree = new SplayTreeSet(compare_default(eps));
31491       const snapCoord = (coord2, tree) => {
31492         return tree.addAndReturn(coord2);
31493       };
31494       const snap = (v2) => {
31495         return {
31496           x: snapCoord(v2.x, xTree),
31497           y: snapCoord(v2.y, yTree)
31498         };
31499       };
31500       snap({ x: new bignumber_default(0), y: new bignumber_default(0) });
31501       return snap;
31502     }
31503     return identity_default3;
31504   };
31505   var set3 = (eps) => {
31506     return {
31507       set: (eps2) => {
31508         precision = set3(eps2);
31509       },
31510       reset: () => set3(eps),
31511       compare: compare_default(eps),
31512       snap: snap_default(eps),
31513       orient: orient_default(eps)
31514     };
31515   };
31516   var precision = set3();
31517   var isInBbox = (bbox2, point) => {
31518     return bbox2.ll.x.isLessThanOrEqualTo(point.x) && point.x.isLessThanOrEqualTo(bbox2.ur.x) && bbox2.ll.y.isLessThanOrEqualTo(point.y) && point.y.isLessThanOrEqualTo(bbox2.ur.y);
31519   };
31520   var getBboxOverlap = (b1, b2) => {
31521     if (b2.ur.x.isLessThan(b1.ll.x) || b1.ur.x.isLessThan(b2.ll.x) || b2.ur.y.isLessThan(b1.ll.y) || b1.ur.y.isLessThan(b2.ll.y))
31522       return null;
31523     const lowerX = b1.ll.x.isLessThan(b2.ll.x) ? b2.ll.x : b1.ll.x;
31524     const upperX = b1.ur.x.isLessThan(b2.ur.x) ? b1.ur.x : b2.ur.x;
31525     const lowerY = b1.ll.y.isLessThan(b2.ll.y) ? b2.ll.y : b1.ll.y;
31526     const upperY = b1.ur.y.isLessThan(b2.ur.y) ? b1.ur.y : b2.ur.y;
31527     return { ll: { x: lowerX, y: lowerY }, ur: { x: upperX, y: upperY } };
31528   };
31529   var crossProduct = (a2, b2) => a2.x.times(b2.y).minus(a2.y.times(b2.x));
31530   var dotProduct = (a2, b2) => a2.x.times(b2.x).plus(a2.y.times(b2.y));
31531   var length = (v2) => dotProduct(v2, v2).sqrt();
31532   var sineOfAngle = (pShared, pBase, pAngle) => {
31533     const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) };
31534     const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) };
31535     return crossProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase));
31536   };
31537   var cosineOfAngle = (pShared, pBase, pAngle) => {
31538     const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) };
31539     const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) };
31540     return dotProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase));
31541   };
31542   var horizontalIntersection = (pt2, v2, y2) => {
31543     if (v2.y.isZero()) return null;
31544     return { x: pt2.x.plus(v2.x.div(v2.y).times(y2.minus(pt2.y))), y: y2 };
31545   };
31546   var verticalIntersection = (pt2, v2, x2) => {
31547     if (v2.x.isZero()) return null;
31548     return { x: x2, y: pt2.y.plus(v2.y.div(v2.x).times(x2.minus(pt2.x))) };
31549   };
31550   var intersection = (pt1, v1, pt2, v2) => {
31551     if (v1.x.isZero()) return verticalIntersection(pt2, v2, pt1.x);
31552     if (v2.x.isZero()) return verticalIntersection(pt1, v1, pt2.x);
31553     if (v1.y.isZero()) return horizontalIntersection(pt2, v2, pt1.y);
31554     if (v2.y.isZero()) return horizontalIntersection(pt1, v1, pt2.y);
31555     const kross = crossProduct(v1, v2);
31556     if (kross.isZero()) return null;
31557     const ve2 = { x: pt2.x.minus(pt1.x), y: pt2.y.minus(pt1.y) };
31558     const d1 = crossProduct(ve2, v1).div(kross);
31559     const d2 = crossProduct(ve2, v2).div(kross);
31560     const x12 = pt1.x.plus(d2.times(v1.x)), x2 = pt2.x.plus(d1.times(v2.x));
31561     const y12 = pt1.y.plus(d2.times(v1.y)), y2 = pt2.y.plus(d1.times(v2.y));
31562     const x3 = x12.plus(x2).div(2);
31563     const y3 = y12.plus(y2).div(2);
31564     return { x: x3, y: y3 };
31565   };
31566   var SweepEvent = class _SweepEvent {
31567     // Warning: 'point' input will be modified and re-used (for performance)
31568     constructor(point, isLeft) {
31569       __publicField(this, "point");
31570       __publicField(this, "isLeft");
31571       __publicField(this, "segment");
31572       __publicField(this, "otherSE");
31573       __publicField(this, "consumedBy");
31574       if (point.events === void 0) point.events = [this];
31575       else point.events.push(this);
31576       this.point = point;
31577       this.isLeft = isLeft;
31578     }
31579     // for ordering sweep events in the sweep event queue
31580     static compare(a2, b2) {
31581       const ptCmp = _SweepEvent.comparePoints(a2.point, b2.point);
31582       if (ptCmp !== 0) return ptCmp;
31583       if (a2.point !== b2.point) a2.link(b2);
31584       if (a2.isLeft !== b2.isLeft) return a2.isLeft ? 1 : -1;
31585       return Segment.compare(a2.segment, b2.segment);
31586     }
31587     // for ordering points in sweep line order
31588     static comparePoints(aPt, bPt) {
31589       if (aPt.x.isLessThan(bPt.x)) return -1;
31590       if (aPt.x.isGreaterThan(bPt.x)) return 1;
31591       if (aPt.y.isLessThan(bPt.y)) return -1;
31592       if (aPt.y.isGreaterThan(bPt.y)) return 1;
31593       return 0;
31594     }
31595     link(other2) {
31596       if (other2.point === this.point) {
31597         throw new Error("Tried to link already linked events");
31598       }
31599       const otherEvents = other2.point.events;
31600       for (let i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) {
31601         const evt = otherEvents[i3];
31602         this.point.events.push(evt);
31603         evt.point = this.point;
31604       }
31605       this.checkForConsuming();
31606     }
31607     /* Do a pass over our linked events and check to see if any pair
31608      * of segments match, and should be consumed. */
31609     checkForConsuming() {
31610       const numEvents = this.point.events.length;
31611       for (let i3 = 0; i3 < numEvents; i3++) {
31612         const evt1 = this.point.events[i3];
31613         if (evt1.segment.consumedBy !== void 0) continue;
31614         for (let j2 = i3 + 1; j2 < numEvents; j2++) {
31615           const evt2 = this.point.events[j2];
31616           if (evt2.consumedBy !== void 0) continue;
31617           if (evt1.otherSE.point.events !== evt2.otherSE.point.events) continue;
31618           evt1.segment.consume(evt2.segment);
31619         }
31620       }
31621     }
31622     getAvailableLinkedEvents() {
31623       const events = [];
31624       for (let i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) {
31625         const evt = this.point.events[i3];
31626         if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) {
31627           events.push(evt);
31628         }
31629       }
31630       return events;
31631     }
31632     /**
31633      * Returns a comparator function for sorting linked events that will
31634      * favor the event that will give us the smallest left-side angle.
31635      * All ring construction starts as low as possible heading to the right,
31636      * so by always turning left as sharp as possible we'll get polygons
31637      * without uncessary loops & holes.
31638      *
31639      * The comparator function has a compute cache such that it avoids
31640      * re-computing already-computed values.
31641      */
31642     getLeftmostComparator(baseEvent) {
31643       const cache = /* @__PURE__ */ new Map();
31644       const fillCache = (linkedEvent) => {
31645         const nextEvent = linkedEvent.otherSE;
31646         cache.set(linkedEvent, {
31647           sine: sineOfAngle(this.point, baseEvent.point, nextEvent.point),
31648           cosine: cosineOfAngle(this.point, baseEvent.point, nextEvent.point)
31649         });
31650       };
31651       return (a2, b2) => {
31652         if (!cache.has(a2)) fillCache(a2);
31653         if (!cache.has(b2)) fillCache(b2);
31654         const { sine: asine, cosine: acosine } = cache.get(a2);
31655         const { sine: bsine, cosine: bcosine } = cache.get(b2);
31656         if (asine.isGreaterThanOrEqualTo(0) && bsine.isGreaterThanOrEqualTo(0)) {
31657           if (acosine.isLessThan(bcosine)) return 1;
31658           if (acosine.isGreaterThan(bcosine)) return -1;
31659           return 0;
31660         }
31661         if (asine.isLessThan(0) && bsine.isLessThan(0)) {
31662           if (acosine.isLessThan(bcosine)) return -1;
31663           if (acosine.isGreaterThan(bcosine)) return 1;
31664           return 0;
31665         }
31666         if (bsine.isLessThan(asine)) return -1;
31667         if (bsine.isGreaterThan(asine)) return 1;
31668         return 0;
31669       };
31670     }
31671   };
31672   var RingOut = class _RingOut {
31673     constructor(events) {
31674       __publicField(this, "events");
31675       __publicField(this, "poly");
31676       __publicField(this, "_isExteriorRing");
31677       __publicField(this, "_enclosingRing");
31678       this.events = events;
31679       for (let i3 = 0, iMax = events.length; i3 < iMax; i3++) {
31680         events[i3].segment.ringOut = this;
31681       }
31682       this.poly = null;
31683     }
31684     /* Given the segments from the sweep line pass, compute & return a series
31685      * of closed rings from all the segments marked to be part of the result */
31686     static factory(allSegments) {
31687       const ringsOut = [];
31688       for (let i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) {
31689         const segment = allSegments[i3];
31690         if (!segment.isInResult() || segment.ringOut) continue;
31691         let prevEvent = null;
31692         let event = segment.leftSE;
31693         let nextEvent = segment.rightSE;
31694         const events = [event];
31695         const startingPoint = event.point;
31696         const intersectionLEs = [];
31697         while (true) {
31698           prevEvent = event;
31699           event = nextEvent;
31700           events.push(event);
31701           if (event.point === startingPoint) break;
31702           while (true) {
31703             const availableLEs = event.getAvailableLinkedEvents();
31704             if (availableLEs.length === 0) {
31705               const firstPt = events[0].point;
31706               const lastPt = events[events.length - 1].point;
31707               throw new Error(
31708                 "Unable to complete output ring starting at [".concat(firstPt.x, ", ").concat(firstPt.y, "]. Last matching segment found ends at [").concat(lastPt.x, ", ").concat(lastPt.y, "].")
31709               );
31710             }
31711             if (availableLEs.length === 1) {
31712               nextEvent = availableLEs[0].otherSE;
31713               break;
31714             }
31715             let indexLE = null;
31716             for (let j2 = 0, jMax = intersectionLEs.length; j2 < jMax; j2++) {
31717               if (intersectionLEs[j2].point === event.point) {
31718                 indexLE = j2;
31719                 break;
31720               }
31721             }
31722             if (indexLE !== null) {
31723               const intersectionLE = intersectionLEs.splice(indexLE)[0];
31724               const ringEvents = events.splice(intersectionLE.index);
31725               ringEvents.unshift(ringEvents[0].otherSE);
31726               ringsOut.push(new _RingOut(ringEvents.reverse()));
31727               continue;
31728             }
31729             intersectionLEs.push({
31730               index: events.length,
31731               point: event.point
31732             });
31733             const comparator = event.getLeftmostComparator(prevEvent);
31734             nextEvent = availableLEs.sort(comparator)[0].otherSE;
31735             break;
31736           }
31737         }
31738         ringsOut.push(new _RingOut(events));
31739       }
31740       return ringsOut;
31741     }
31742     getGeom() {
31743       let prevPt = this.events[0].point;
31744       const points = [prevPt];
31745       for (let i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) {
31746         const pt22 = this.events[i3].point;
31747         const nextPt2 = this.events[i3 + 1].point;
31748         if (precision.orient(pt22, prevPt, nextPt2) === 0) continue;
31749         points.push(pt22);
31750         prevPt = pt22;
31751       }
31752       if (points.length === 1) return null;
31753       const pt2 = points[0];
31754       const nextPt = points[1];
31755       if (precision.orient(pt2, prevPt, nextPt) === 0) points.shift();
31756       points.push(points[0]);
31757       const step = this.isExteriorRing() ? 1 : -1;
31758       const iStart = this.isExteriorRing() ? 0 : points.length - 1;
31759       const iEnd = this.isExteriorRing() ? points.length : -1;
31760       const orderedPoints = [];
31761       for (let i3 = iStart; i3 != iEnd; i3 += step)
31762         orderedPoints.push([points[i3].x.toNumber(), points[i3].y.toNumber()]);
31763       return orderedPoints;
31764     }
31765     isExteriorRing() {
31766       if (this._isExteriorRing === void 0) {
31767         const enclosing = this.enclosingRing();
31768         this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true;
31769       }
31770       return this._isExteriorRing;
31771     }
31772     enclosingRing() {
31773       if (this._enclosingRing === void 0) {
31774         this._enclosingRing = this._calcEnclosingRing();
31775       }
31776       return this._enclosingRing;
31777     }
31778     /* Returns the ring that encloses this one, if any */
31779     _calcEnclosingRing() {
31780       var _a4, _b3;
31781       let leftMostEvt = this.events[0];
31782       for (let i3 = 1, iMax = this.events.length; i3 < iMax; i3++) {
31783         const evt = this.events[i3];
31784         if (SweepEvent.compare(leftMostEvt, evt) > 0) leftMostEvt = evt;
31785       }
31786       let prevSeg = leftMostEvt.segment.prevInResult();
31787       let prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
31788       while (true) {
31789         if (!prevSeg) return null;
31790         if (!prevPrevSeg) return prevSeg.ringOut;
31791         if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
31792           if (((_a4 = prevPrevSeg.ringOut) == null ? void 0 : _a4.enclosingRing()) !== prevSeg.ringOut) {
31793             return prevSeg.ringOut;
31794           } else return (_b3 = prevSeg.ringOut) == null ? void 0 : _b3.enclosingRing();
31795         }
31796         prevSeg = prevPrevSeg.prevInResult();
31797         prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
31798       }
31799     }
31800   };
31801   var PolyOut = class {
31802     constructor(exteriorRing) {
31803       __publicField(this, "exteriorRing");
31804       __publicField(this, "interiorRings");
31805       this.exteriorRing = exteriorRing;
31806       exteriorRing.poly = this;
31807       this.interiorRings = [];
31808     }
31809     addInterior(ring) {
31810       this.interiorRings.push(ring);
31811       ring.poly = this;
31812     }
31813     getGeom() {
31814       const geom0 = this.exteriorRing.getGeom();
31815       if (geom0 === null) return null;
31816       const geom = [geom0];
31817       for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
31818         const ringGeom = this.interiorRings[i3].getGeom();
31819         if (ringGeom === null) continue;
31820         geom.push(ringGeom);
31821       }
31822       return geom;
31823     }
31824   };
31825   var MultiPolyOut = class {
31826     constructor(rings) {
31827       __publicField(this, "rings");
31828       __publicField(this, "polys");
31829       this.rings = rings;
31830       this.polys = this._composePolys(rings);
31831     }
31832     getGeom() {
31833       const geom = [];
31834       for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
31835         const polyGeom = this.polys[i3].getGeom();
31836         if (polyGeom === null) continue;
31837         geom.push(polyGeom);
31838       }
31839       return geom;
31840     }
31841     _composePolys(rings) {
31842       var _a4;
31843       const polys = [];
31844       for (let i3 = 0, iMax = rings.length; i3 < iMax; i3++) {
31845         const ring = rings[i3];
31846         if (ring.poly) continue;
31847         if (ring.isExteriorRing()) polys.push(new PolyOut(ring));
31848         else {
31849           const enclosingRing = ring.enclosingRing();
31850           if (!(enclosingRing == null ? void 0 : enclosingRing.poly)) polys.push(new PolyOut(enclosingRing));
31851           (_a4 = enclosingRing == null ? void 0 : enclosingRing.poly) == null ? void 0 : _a4.addInterior(ring);
31852         }
31853       }
31854       return polys;
31855     }
31856   };
31857   var SweepLine = class {
31858     constructor(queue, comparator = Segment.compare) {
31859       __publicField(this, "queue");
31860       __publicField(this, "tree");
31861       __publicField(this, "segments");
31862       this.queue = queue;
31863       this.tree = new SplayTreeSet(comparator);
31864       this.segments = [];
31865     }
31866     process(event) {
31867       const segment = event.segment;
31868       const newEvents = [];
31869       if (event.consumedBy) {
31870         if (event.isLeft) this.queue.delete(event.otherSE);
31871         else this.tree.delete(segment);
31872         return newEvents;
31873       }
31874       if (event.isLeft) this.tree.add(segment);
31875       let prevSeg = segment;
31876       let nextSeg = segment;
31877       do {
31878         prevSeg = this.tree.lastBefore(prevSeg);
31879       } while (prevSeg != null && prevSeg.consumedBy != void 0);
31880       do {
31881         nextSeg = this.tree.firstAfter(nextSeg);
31882       } while (nextSeg != null && nextSeg.consumedBy != void 0);
31883       if (event.isLeft) {
31884         let prevMySplitter = null;
31885         if (prevSeg) {
31886           const prevInter = prevSeg.getIntersection(segment);
31887           if (prevInter !== null) {
31888             if (!segment.isAnEndpoint(prevInter)) prevMySplitter = prevInter;
31889             if (!prevSeg.isAnEndpoint(prevInter)) {
31890               const newEventsFromSplit = this._splitSafely(prevSeg, prevInter);
31891               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
31892                 newEvents.push(newEventsFromSplit[i3]);
31893               }
31894             }
31895           }
31896         }
31897         let nextMySplitter = null;
31898         if (nextSeg) {
31899           const nextInter = nextSeg.getIntersection(segment);
31900           if (nextInter !== null) {
31901             if (!segment.isAnEndpoint(nextInter)) nextMySplitter = nextInter;
31902             if (!nextSeg.isAnEndpoint(nextInter)) {
31903               const newEventsFromSplit = this._splitSafely(nextSeg, nextInter);
31904               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
31905                 newEvents.push(newEventsFromSplit[i3]);
31906               }
31907             }
31908           }
31909         }
31910         if (prevMySplitter !== null || nextMySplitter !== null) {
31911           let mySplitter = null;
31912           if (prevMySplitter === null) mySplitter = nextMySplitter;
31913           else if (nextMySplitter === null) mySplitter = prevMySplitter;
31914           else {
31915             const cmpSplitters = SweepEvent.comparePoints(
31916               prevMySplitter,
31917               nextMySplitter
31918             );
31919             mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter;
31920           }
31921           this.queue.delete(segment.rightSE);
31922           newEvents.push(segment.rightSE);
31923           const newEventsFromSplit = segment.split(mySplitter);
31924           for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
31925             newEvents.push(newEventsFromSplit[i3]);
31926           }
31927         }
31928         if (newEvents.length > 0) {
31929           this.tree.delete(segment);
31930           newEvents.push(event);
31931         } else {
31932           this.segments.push(segment);
31933           segment.prev = prevSeg;
31934         }
31935       } else {
31936         if (prevSeg && nextSeg) {
31937           const inter = prevSeg.getIntersection(nextSeg);
31938           if (inter !== null) {
31939             if (!prevSeg.isAnEndpoint(inter)) {
31940               const newEventsFromSplit = this._splitSafely(prevSeg, inter);
31941               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
31942                 newEvents.push(newEventsFromSplit[i3]);
31943               }
31944             }
31945             if (!nextSeg.isAnEndpoint(inter)) {
31946               const newEventsFromSplit = this._splitSafely(nextSeg, inter);
31947               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
31948                 newEvents.push(newEventsFromSplit[i3]);
31949               }
31950             }
31951           }
31952         }
31953         this.tree.delete(segment);
31954       }
31955       return newEvents;
31956     }
31957     /* Safely split a segment that is currently in the datastructures
31958      * IE - a segment other than the one that is currently being processed. */
31959     _splitSafely(seg, pt2) {
31960       this.tree.delete(seg);
31961       const rightSE = seg.rightSE;
31962       this.queue.delete(rightSE);
31963       const newEvents = seg.split(pt2);
31964       newEvents.push(rightSE);
31965       if (seg.consumedBy === void 0) this.tree.add(seg);
31966       return newEvents;
31967     }
31968   };
31969   var Operation = class {
31970     constructor() {
31971       __publicField(this, "type");
31972       __publicField(this, "numMultiPolys");
31973     }
31974     run(type2, geom, moreGeoms) {
31975       operation.type = type2;
31976       const multipolys = [new MultiPolyIn(geom, true)];
31977       for (let i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) {
31978         multipolys.push(new MultiPolyIn(moreGeoms[i3], false));
31979       }
31980       operation.numMultiPolys = multipolys.length;
31981       if (operation.type === "difference") {
31982         const subject = multipolys[0];
31983         let i3 = 1;
31984         while (i3 < multipolys.length) {
31985           if (getBboxOverlap(multipolys[i3].bbox, subject.bbox) !== null) i3++;
31986           else multipolys.splice(i3, 1);
31987         }
31988       }
31989       if (operation.type === "intersection") {
31990         for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
31991           const mpA = multipolys[i3];
31992           for (let j2 = i3 + 1, jMax = multipolys.length; j2 < jMax; j2++) {
31993             if (getBboxOverlap(mpA.bbox, multipolys[j2].bbox) === null) return [];
31994           }
31995         }
31996       }
31997       const queue = new SplayTreeSet(SweepEvent.compare);
31998       for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
31999         const sweepEvents = multipolys[i3].getSweepEvents();
32000         for (let j2 = 0, jMax = sweepEvents.length; j2 < jMax; j2++) {
32001           queue.add(sweepEvents[j2]);
32002         }
32003       }
32004       const sweepLine = new SweepLine(queue);
32005       let evt = null;
32006       if (queue.size != 0) {
32007         evt = queue.first();
32008         queue.delete(evt);
32009       }
32010       while (evt) {
32011         const newEvents = sweepLine.process(evt);
32012         for (let i3 = 0, iMax = newEvents.length; i3 < iMax; i3++) {
32013           const evt2 = newEvents[i3];
32014           if (evt2.consumedBy === void 0) queue.add(evt2);
32015         }
32016         if (queue.size != 0) {
32017           evt = queue.first();
32018           queue.delete(evt);
32019         } else {
32020           evt = null;
32021         }
32022       }
32023       precision.reset();
32024       const ringsOut = RingOut.factory(sweepLine.segments);
32025       const result = new MultiPolyOut(ringsOut);
32026       return result.getGeom();
32027     }
32028   };
32029   var operation = new Operation();
32030   var operation_default = operation;
32031   var segmentId = 0;
32032   var Segment = class _Segment {
32033     /* Warning: a reference to ringWindings input will be stored,
32034      *  and possibly will be later modified */
32035     constructor(leftSE, rightSE, rings, windings) {
32036       __publicField(this, "id");
32037       __publicField(this, "leftSE");
32038       __publicField(this, "rightSE");
32039       __publicField(this, "rings");
32040       __publicField(this, "windings");
32041       __publicField(this, "ringOut");
32042       __publicField(this, "consumedBy");
32043       __publicField(this, "prev");
32044       __publicField(this, "_prevInResult");
32045       __publicField(this, "_beforeState");
32046       __publicField(this, "_afterState");
32047       __publicField(this, "_isInResult");
32048       this.id = ++segmentId;
32049       this.leftSE = leftSE;
32050       leftSE.segment = this;
32051       leftSE.otherSE = rightSE;
32052       this.rightSE = rightSE;
32053       rightSE.segment = this;
32054       rightSE.otherSE = leftSE;
32055       this.rings = rings;
32056       this.windings = windings;
32057     }
32058     /* This compare() function is for ordering segments in the sweep
32059      * line tree, and does so according to the following criteria:
32060      *
32061      * Consider the vertical line that lies an infinestimal step to the
32062      * right of the right-more of the two left endpoints of the input
32063      * segments. Imagine slowly moving a point up from negative infinity
32064      * in the increasing y direction. Which of the two segments will that
32065      * point intersect first? That segment comes 'before' the other one.
32066      *
32067      * If neither segment would be intersected by such a line, (if one
32068      * or more of the segments are vertical) then the line to be considered
32069      * is directly on the right-more of the two left inputs.
32070      */
32071     static compare(a2, b2) {
32072       const alx = a2.leftSE.point.x;
32073       const blx = b2.leftSE.point.x;
32074       const arx = a2.rightSE.point.x;
32075       const brx = b2.rightSE.point.x;
32076       if (brx.isLessThan(alx)) return 1;
32077       if (arx.isLessThan(blx)) return -1;
32078       const aly = a2.leftSE.point.y;
32079       const bly = b2.leftSE.point.y;
32080       const ary = a2.rightSE.point.y;
32081       const bry = b2.rightSE.point.y;
32082       if (alx.isLessThan(blx)) {
32083         if (bly.isLessThan(aly) && bly.isLessThan(ary)) return 1;
32084         if (bly.isGreaterThan(aly) && bly.isGreaterThan(ary)) return -1;
32085         const aCmpBLeft = a2.comparePoint(b2.leftSE.point);
32086         if (aCmpBLeft < 0) return 1;
32087         if (aCmpBLeft > 0) return -1;
32088         const bCmpARight = b2.comparePoint(a2.rightSE.point);
32089         if (bCmpARight !== 0) return bCmpARight;
32090         return -1;
32091       }
32092       if (alx.isGreaterThan(blx)) {
32093         if (aly.isLessThan(bly) && aly.isLessThan(bry)) return -1;
32094         if (aly.isGreaterThan(bly) && aly.isGreaterThan(bry)) return 1;
32095         const bCmpALeft = b2.comparePoint(a2.leftSE.point);
32096         if (bCmpALeft !== 0) return bCmpALeft;
32097         const aCmpBRight = a2.comparePoint(b2.rightSE.point);
32098         if (aCmpBRight < 0) return 1;
32099         if (aCmpBRight > 0) return -1;
32100         return 1;
32101       }
32102       if (aly.isLessThan(bly)) return -1;
32103       if (aly.isGreaterThan(bly)) return 1;
32104       if (arx.isLessThan(brx)) {
32105         const bCmpARight = b2.comparePoint(a2.rightSE.point);
32106         if (bCmpARight !== 0) return bCmpARight;
32107       }
32108       if (arx.isGreaterThan(brx)) {
32109         const aCmpBRight = a2.comparePoint(b2.rightSE.point);
32110         if (aCmpBRight < 0) return 1;
32111         if (aCmpBRight > 0) return -1;
32112       }
32113       if (!arx.eq(brx)) {
32114         const ay = ary.minus(aly);
32115         const ax = arx.minus(alx);
32116         const by = bry.minus(bly);
32117         const bx = brx.minus(blx);
32118         if (ay.isGreaterThan(ax) && by.isLessThan(bx)) return 1;
32119         if (ay.isLessThan(ax) && by.isGreaterThan(bx)) return -1;
32120       }
32121       if (arx.isGreaterThan(brx)) return 1;
32122       if (arx.isLessThan(brx)) return -1;
32123       if (ary.isLessThan(bry)) return -1;
32124       if (ary.isGreaterThan(bry)) return 1;
32125       if (a2.id < b2.id) return -1;
32126       if (a2.id > b2.id) return 1;
32127       return 0;
32128     }
32129     static fromRing(pt1, pt2, ring) {
32130       let leftPt, rightPt, winding;
32131       const cmpPts = SweepEvent.comparePoints(pt1, pt2);
32132       if (cmpPts < 0) {
32133         leftPt = pt1;
32134         rightPt = pt2;
32135         winding = 1;
32136       } else if (cmpPts > 0) {
32137         leftPt = pt2;
32138         rightPt = pt1;
32139         winding = -1;
32140       } else
32141         throw new Error(
32142           "Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]")
32143         );
32144       const leftSE = new SweepEvent(leftPt, true);
32145       const rightSE = new SweepEvent(rightPt, false);
32146       return new _Segment(leftSE, rightSE, [ring], [winding]);
32147     }
32148     /* When a segment is split, the rightSE is replaced with a new sweep event */
32149     replaceRightSE(newRightSE) {
32150       this.rightSE = newRightSE;
32151       this.rightSE.segment = this;
32152       this.rightSE.otherSE = this.leftSE;
32153       this.leftSE.otherSE = this.rightSE;
32154     }
32155     bbox() {
32156       const y12 = this.leftSE.point.y;
32157       const y2 = this.rightSE.point.y;
32158       return {
32159         ll: { x: this.leftSE.point.x, y: y12.isLessThan(y2) ? y12 : y2 },
32160         ur: { x: this.rightSE.point.x, y: y12.isGreaterThan(y2) ? y12 : y2 }
32161       };
32162     }
32163     /* A vector from the left point to the right */
32164     vector() {
32165       return {
32166         x: this.rightSE.point.x.minus(this.leftSE.point.x),
32167         y: this.rightSE.point.y.minus(this.leftSE.point.y)
32168       };
32169     }
32170     isAnEndpoint(pt2) {
32171       return pt2.x.eq(this.leftSE.point.x) && pt2.y.eq(this.leftSE.point.y) || pt2.x.eq(this.rightSE.point.x) && pt2.y.eq(this.rightSE.point.y);
32172     }
32173     /* Compare this segment with a point.
32174      *
32175      * A point P is considered to be colinear to a segment if there
32176      * exists a distance D such that if we travel along the segment
32177      * from one * endpoint towards the other a distance D, we find
32178      * ourselves at point P.
32179      *
32180      * Return value indicates:
32181      *
32182      *   1: point lies above the segment (to the left of vertical)
32183      *   0: point is colinear to segment
32184      *  -1: point lies below the segment (to the right of vertical)
32185      */
32186     comparePoint(point) {
32187       return precision.orient(this.leftSE.point, point, this.rightSE.point);
32188     }
32189     /**
32190      * Given another segment, returns the first non-trivial intersection
32191      * between the two segments (in terms of sweep line ordering), if it exists.
32192      *
32193      * A 'non-trivial' intersection is one that will cause one or both of the
32194      * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection:
32195      *
32196      *   * endpoint of segA with endpoint of segB --> trivial
32197      *   * endpoint of segA with point along segB --> non-trivial
32198      *   * endpoint of segB with point along segA --> non-trivial
32199      *   * point along segA with point along segB --> non-trivial
32200      *
32201      * If no non-trivial intersection exists, return null
32202      * Else, return null.
32203      */
32204     getIntersection(other2) {
32205       const tBbox = this.bbox();
32206       const oBbox = other2.bbox();
32207       const bboxOverlap = getBboxOverlap(tBbox, oBbox);
32208       if (bboxOverlap === null) return null;
32209       const tlp = this.leftSE.point;
32210       const trp = this.rightSE.point;
32211       const olp = other2.leftSE.point;
32212       const orp = other2.rightSE.point;
32213       const touchesOtherLSE = isInBbox(tBbox, olp) && this.comparePoint(olp) === 0;
32214       const touchesThisLSE = isInBbox(oBbox, tlp) && other2.comparePoint(tlp) === 0;
32215       const touchesOtherRSE = isInBbox(tBbox, orp) && this.comparePoint(orp) === 0;
32216       const touchesThisRSE = isInBbox(oBbox, trp) && other2.comparePoint(trp) === 0;
32217       if (touchesThisLSE && touchesOtherLSE) {
32218         if (touchesThisRSE && !touchesOtherRSE) return trp;
32219         if (!touchesThisRSE && touchesOtherRSE) return orp;
32220         return null;
32221       }
32222       if (touchesThisLSE) {
32223         if (touchesOtherRSE) {
32224           if (tlp.x.eq(orp.x) && tlp.y.eq(orp.y)) return null;
32225         }
32226         return tlp;
32227       }
32228       if (touchesOtherLSE) {
32229         if (touchesThisRSE) {
32230           if (trp.x.eq(olp.x) && trp.y.eq(olp.y)) return null;
32231         }
32232         return olp;
32233       }
32234       if (touchesThisRSE && touchesOtherRSE) return null;
32235       if (touchesThisRSE) return trp;
32236       if (touchesOtherRSE) return orp;
32237       const pt2 = intersection(tlp, this.vector(), olp, other2.vector());
32238       if (pt2 === null) return null;
32239       if (!isInBbox(bboxOverlap, pt2)) return null;
32240       return precision.snap(pt2);
32241     }
32242     /**
32243      * Split the given segment into multiple segments on the given points.
32244      *  * Each existing segment will retain its leftSE and a new rightSE will be
32245      *    generated for it.
32246      *  * A new segment will be generated which will adopt the original segment's
32247      *    rightSE, and a new leftSE will be generated for it.
32248      *  * If there are more than two points given to split on, new segments
32249      *    in the middle will be generated with new leftSE and rightSE's.
32250      *  * An array of the newly generated SweepEvents will be returned.
32251      *
32252      * Warning: input array of points is modified
32253      */
32254     split(point) {
32255       const newEvents = [];
32256       const alreadyLinked = point.events !== void 0;
32257       const newLeftSE = new SweepEvent(point, true);
32258       const newRightSE = new SweepEvent(point, false);
32259       const oldRightSE = this.rightSE;
32260       this.replaceRightSE(newRightSE);
32261       newEvents.push(newRightSE);
32262       newEvents.push(newLeftSE);
32263       const newSeg = new _Segment(
32264         newLeftSE,
32265         oldRightSE,
32266         this.rings.slice(),
32267         this.windings.slice()
32268       );
32269       if (SweepEvent.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) {
32270         newSeg.swapEvents();
32271       }
32272       if (SweepEvent.comparePoints(this.leftSE.point, this.rightSE.point) > 0) {
32273         this.swapEvents();
32274       }
32275       if (alreadyLinked) {
32276         newLeftSE.checkForConsuming();
32277         newRightSE.checkForConsuming();
32278       }
32279       return newEvents;
32280     }
32281     /* Swap which event is left and right */
32282     swapEvents() {
32283       const tmpEvt = this.rightSE;
32284       this.rightSE = this.leftSE;
32285       this.leftSE = tmpEvt;
32286       this.leftSE.isLeft = true;
32287       this.rightSE.isLeft = false;
32288       for (let i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) {
32289         this.windings[i3] *= -1;
32290       }
32291     }
32292     /* Consume another segment. We take their rings under our wing
32293      * and mark them as consumed. Use for perfectly overlapping segments */
32294     consume(other2) {
32295       let consumer = this;
32296       let consumee = other2;
32297       while (consumer.consumedBy) consumer = consumer.consumedBy;
32298       while (consumee.consumedBy) consumee = consumee.consumedBy;
32299       const cmp = _Segment.compare(consumer, consumee);
32300       if (cmp === 0) return;
32301       if (cmp > 0) {
32302         const tmp = consumer;
32303         consumer = consumee;
32304         consumee = tmp;
32305       }
32306       if (consumer.prev === consumee) {
32307         const tmp = consumer;
32308         consumer = consumee;
32309         consumee = tmp;
32310       }
32311       for (let i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) {
32312         const ring = consumee.rings[i3];
32313         const winding = consumee.windings[i3];
32314         const index = consumer.rings.indexOf(ring);
32315         if (index === -1) {
32316           consumer.rings.push(ring);
32317           consumer.windings.push(winding);
32318         } else consumer.windings[index] += winding;
32319       }
32320       consumee.rings = null;
32321       consumee.windings = null;
32322       consumee.consumedBy = consumer;
32323       consumee.leftSE.consumedBy = consumer.leftSE;
32324       consumee.rightSE.consumedBy = consumer.rightSE;
32325     }
32326     /* The first segment previous segment chain that is in the result */
32327     prevInResult() {
32328       if (this._prevInResult !== void 0) return this._prevInResult;
32329       if (!this.prev) this._prevInResult = null;
32330       else if (this.prev.isInResult()) this._prevInResult = this.prev;
32331       else this._prevInResult = this.prev.prevInResult();
32332       return this._prevInResult;
32333     }
32334     beforeState() {
32335       if (this._beforeState !== void 0) return this._beforeState;
32336       if (!this.prev)
32337         this._beforeState = {
32338           rings: [],
32339           windings: [],
32340           multiPolys: []
32341         };
32342       else {
32343         const seg = this.prev.consumedBy || this.prev;
32344         this._beforeState = seg.afterState();
32345       }
32346       return this._beforeState;
32347     }
32348     afterState() {
32349       if (this._afterState !== void 0) return this._afterState;
32350       const beforeState = this.beforeState();
32351       this._afterState = {
32352         rings: beforeState.rings.slice(0),
32353         windings: beforeState.windings.slice(0),
32354         multiPolys: []
32355       };
32356       const ringsAfter = this._afterState.rings;
32357       const windingsAfter = this._afterState.windings;
32358       const mpsAfter = this._afterState.multiPolys;
32359       for (let i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) {
32360         const ring = this.rings[i3];
32361         const winding = this.windings[i3];
32362         const index = ringsAfter.indexOf(ring);
32363         if (index === -1) {
32364           ringsAfter.push(ring);
32365           windingsAfter.push(winding);
32366         } else windingsAfter[index] += winding;
32367       }
32368       const polysAfter = [];
32369       const polysExclude = [];
32370       for (let i3 = 0, iMax = ringsAfter.length; i3 < iMax; i3++) {
32371         if (windingsAfter[i3] === 0) continue;
32372         const ring = ringsAfter[i3];
32373         const poly = ring.poly;
32374         if (polysExclude.indexOf(poly) !== -1) continue;
32375         if (ring.isExterior) polysAfter.push(poly);
32376         else {
32377           if (polysExclude.indexOf(poly) === -1) polysExclude.push(poly);
32378           const index = polysAfter.indexOf(ring.poly);
32379           if (index !== -1) polysAfter.splice(index, 1);
32380         }
32381       }
32382       for (let i3 = 0, iMax = polysAfter.length; i3 < iMax; i3++) {
32383         const mp = polysAfter[i3].multiPoly;
32384         if (mpsAfter.indexOf(mp) === -1) mpsAfter.push(mp);
32385       }
32386       return this._afterState;
32387     }
32388     /* Is this segment part of the final result? */
32389     isInResult() {
32390       if (this.consumedBy) return false;
32391       if (this._isInResult !== void 0) return this._isInResult;
32392       const mpsBefore = this.beforeState().multiPolys;
32393       const mpsAfter = this.afterState().multiPolys;
32394       switch (operation_default.type) {
32395         case "union": {
32396           const noBefores = mpsBefore.length === 0;
32397           const noAfters = mpsAfter.length === 0;
32398           this._isInResult = noBefores !== noAfters;
32399           break;
32400         }
32401         case "intersection": {
32402           let least;
32403           let most;
32404           if (mpsBefore.length < mpsAfter.length) {
32405             least = mpsBefore.length;
32406             most = mpsAfter.length;
32407           } else {
32408             least = mpsAfter.length;
32409             most = mpsBefore.length;
32410           }
32411           this._isInResult = most === operation_default.numMultiPolys && least < most;
32412           break;
32413         }
32414         case "xor": {
32415           const diff = Math.abs(mpsBefore.length - mpsAfter.length);
32416           this._isInResult = diff % 2 === 1;
32417           break;
32418         }
32419         case "difference": {
32420           const isJustSubject = (mps) => mps.length === 1 && mps[0].isSubject;
32421           this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter);
32422           break;
32423         }
32424       }
32425       return this._isInResult;
32426     }
32427   };
32428   var RingIn = class {
32429     constructor(geomRing, poly, isExterior) {
32430       __publicField(this, "poly");
32431       __publicField(this, "isExterior");
32432       __publicField(this, "segments");
32433       __publicField(this, "bbox");
32434       if (!Array.isArray(geomRing) || geomRing.length === 0) {
32435         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
32436       }
32437       this.poly = poly;
32438       this.isExterior = isExterior;
32439       this.segments = [];
32440       if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
32441         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
32442       }
32443       const firstPoint = precision.snap({ x: new bignumber_default(geomRing[0][0]), y: new bignumber_default(geomRing[0][1]) });
32444       this.bbox = {
32445         ll: { x: firstPoint.x, y: firstPoint.y },
32446         ur: { x: firstPoint.x, y: firstPoint.y }
32447       };
32448       let prevPoint = firstPoint;
32449       for (let i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) {
32450         if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") {
32451           throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
32452         }
32453         const point = precision.snap({ x: new bignumber_default(geomRing[i3][0]), y: new bignumber_default(geomRing[i3][1]) });
32454         if (point.x.eq(prevPoint.x) && point.y.eq(prevPoint.y)) continue;
32455         this.segments.push(Segment.fromRing(prevPoint, point, this));
32456         if (point.x.isLessThan(this.bbox.ll.x)) this.bbox.ll.x = point.x;
32457         if (point.y.isLessThan(this.bbox.ll.y)) this.bbox.ll.y = point.y;
32458         if (point.x.isGreaterThan(this.bbox.ur.x)) this.bbox.ur.x = point.x;
32459         if (point.y.isGreaterThan(this.bbox.ur.y)) this.bbox.ur.y = point.y;
32460         prevPoint = point;
32461       }
32462       if (!firstPoint.x.eq(prevPoint.x) || !firstPoint.y.eq(prevPoint.y)) {
32463         this.segments.push(Segment.fromRing(prevPoint, firstPoint, this));
32464       }
32465     }
32466     getSweepEvents() {
32467       const sweepEvents = [];
32468       for (let i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) {
32469         const segment = this.segments[i3];
32470         sweepEvents.push(segment.leftSE);
32471         sweepEvents.push(segment.rightSE);
32472       }
32473       return sweepEvents;
32474     }
32475   };
32476   var PolyIn = class {
32477     constructor(geomPoly, multiPoly) {
32478       __publicField(this, "multiPoly");
32479       __publicField(this, "exteriorRing");
32480       __publicField(this, "interiorRings");
32481       __publicField(this, "bbox");
32482       if (!Array.isArray(geomPoly)) {
32483         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
32484       }
32485       this.exteriorRing = new RingIn(geomPoly[0], this, true);
32486       this.bbox = {
32487         ll: { x: this.exteriorRing.bbox.ll.x, y: this.exteriorRing.bbox.ll.y },
32488         ur: { x: this.exteriorRing.bbox.ur.x, y: this.exteriorRing.bbox.ur.y }
32489       };
32490       this.interiorRings = [];
32491       for (let i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) {
32492         const ring = new RingIn(geomPoly[i3], this, false);
32493         if (ring.bbox.ll.x.isLessThan(this.bbox.ll.x)) this.bbox.ll.x = ring.bbox.ll.x;
32494         if (ring.bbox.ll.y.isLessThan(this.bbox.ll.y)) this.bbox.ll.y = ring.bbox.ll.y;
32495         if (ring.bbox.ur.x.isGreaterThan(this.bbox.ur.x)) this.bbox.ur.x = ring.bbox.ur.x;
32496         if (ring.bbox.ur.y.isGreaterThan(this.bbox.ur.y)) this.bbox.ur.y = ring.bbox.ur.y;
32497         this.interiorRings.push(ring);
32498       }
32499       this.multiPoly = multiPoly;
32500     }
32501     getSweepEvents() {
32502       const sweepEvents = this.exteriorRing.getSweepEvents();
32503       for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
32504         const ringSweepEvents = this.interiorRings[i3].getSweepEvents();
32505         for (let j2 = 0, jMax = ringSweepEvents.length; j2 < jMax; j2++) {
32506           sweepEvents.push(ringSweepEvents[j2]);
32507         }
32508       }
32509       return sweepEvents;
32510     }
32511   };
32512   var MultiPolyIn = class {
32513     constructor(geom, isSubject) {
32514       __publicField(this, "isSubject");
32515       __publicField(this, "polys");
32516       __publicField(this, "bbox");
32517       if (!Array.isArray(geom)) {
32518         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
32519       }
32520       try {
32521         if (typeof geom[0][0][0] === "number") geom = [geom];
32522       } catch (ex) {
32523       }
32524       this.polys = [];
32525       this.bbox = {
32526         ll: { x: new bignumber_default(Number.POSITIVE_INFINITY), y: new bignumber_default(Number.POSITIVE_INFINITY) },
32527         ur: { x: new bignumber_default(Number.NEGATIVE_INFINITY), y: new bignumber_default(Number.NEGATIVE_INFINITY) }
32528       };
32529       for (let i3 = 0, iMax = geom.length; i3 < iMax; i3++) {
32530         const poly = new PolyIn(geom[i3], this);
32531         if (poly.bbox.ll.x.isLessThan(this.bbox.ll.x)) this.bbox.ll.x = poly.bbox.ll.x;
32532         if (poly.bbox.ll.y.isLessThan(this.bbox.ll.y)) this.bbox.ll.y = poly.bbox.ll.y;
32533         if (poly.bbox.ur.x.isGreaterThan(this.bbox.ur.x)) this.bbox.ur.x = poly.bbox.ur.x;
32534         if (poly.bbox.ur.y.isGreaterThan(this.bbox.ur.y)) this.bbox.ur.y = poly.bbox.ur.y;
32535         this.polys.push(poly);
32536       }
32537       this.isSubject = isSubject;
32538     }
32539     getSweepEvents() {
32540       const sweepEvents = [];
32541       for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
32542         const polySweepEvents = this.polys[i3].getSweepEvents();
32543         for (let j2 = 0, jMax = polySweepEvents.length; j2 < jMax; j2++) {
32544           sweepEvents.push(polySweepEvents[j2]);
32545         }
32546       }
32547       return sweepEvents;
32548     }
32549   };
32550   var union = (geom, ...moreGeoms) => operation_default.run("union", geom, moreGeoms);
32551   var difference = (geom, ...moreGeoms) => operation_default.run("difference", geom, moreGeoms);
32552   var setPrecision = precision.set;
32553
32554   // node_modules/@rapideditor/location-conflation/index.mjs
32555   var import_geojson_area = __toESM(require_geojson_area(), 1);
32556   var import_circle_to_polygon = __toESM(require_circle_to_polygon(), 1);
32557   var import_geojson_precision = __toESM(require_geojson_precision(), 1);
32558   var import_json_stringify_pretty_compact = __toESM(require_json_stringify_pretty_compact(), 1);
32559   var LocationConflation = class {
32560     // constructor
32561     //
32562     // `fc`  Optional FeatureCollection of known features
32563     //
32564     // Optionally pass a GeoJSON FeatureCollection of known features which we can refer to later.
32565     // Each feature must have a filename-like `id`, for example: `something.geojson`
32566     //
32567     // {
32568     //   "type": "FeatureCollection"
32569     //   "features": [
32570     //     {
32571     //       "type": "Feature",
32572     //       "id": "philly_metro.geojson",
32573     //       "properties": { … },
32574     //       "geometry": { … }
32575     //     }
32576     //   ]
32577     // }
32578     constructor(fc) {
32579       this._cache = {};
32580       this.strict = true;
32581       if (fc && fc.type === "FeatureCollection" && Array.isArray(fc.features)) {
32582         fc.features.forEach((feature3) => {
32583           feature3.properties = feature3.properties || {};
32584           let props = feature3.properties;
32585           let id2 = feature3.id || props.id;
32586           if (!id2 || !/^\S+\.geojson$/i.test(id2)) return;
32587           id2 = id2.toLowerCase();
32588           feature3.id = id2;
32589           props.id = id2;
32590           if (!props.area) {
32591             const area = import_geojson_area.default.geometry(feature3.geometry) / 1e6;
32592             props.area = Number(area.toFixed(2));
32593           }
32594           this._cache[id2] = feature3;
32595         });
32596       }
32597       let world = _cloneDeep(feature("Q2"));
32598       world.geometry = {
32599         type: "Polygon",
32600         coordinates: [[[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]]
32601       };
32602       world.id = "Q2";
32603       world.properties.id = "Q2";
32604       world.properties.area = import_geojson_area.default.geometry(world.geometry) / 1e6;
32605       this._cache.Q2 = world;
32606     }
32607     // validateLocation
32608     // `location`  The location to validate
32609     //
32610     // Pass a `location` value to validate
32611     //
32612     // Returns a result like:
32613     //   {
32614     //     type:     'point', 'geojson', or 'countrycoder'
32615     //     location:  the queried location
32616     //     id:        the stable identifier for the feature
32617     //   }
32618     // or `null` if the location is invalid
32619     //
32620     validateLocation(location) {
32621       if (Array.isArray(location) && (location.length === 2 || location.length === 3)) {
32622         const lon = location[0];
32623         const lat = location[1];
32624         const radius = location[2];
32625         if (Number.isFinite(lon) && lon >= -180 && lon <= 180 && Number.isFinite(lat) && lat >= -90 && lat <= 90 && (location.length === 2 || Number.isFinite(radius) && radius > 0)) {
32626           const id2 = "[" + location.toString() + "]";
32627           return { type: "point", location, id: id2 };
32628         }
32629       } else if (typeof location === "string" && /^\S+\.geojson$/i.test(location)) {
32630         const id2 = location.toLowerCase();
32631         if (this._cache[id2]) {
32632           return { type: "geojson", location, id: id2 };
32633         }
32634       } else if (typeof location === "string" || typeof location === "number") {
32635         const feature3 = feature(location);
32636         if (feature3) {
32637           const id2 = feature3.properties.wikidata;
32638           return { type: "countrycoder", location, id: id2 };
32639         }
32640       }
32641       if (this.strict) {
32642         throw new Error('validateLocation:  Invalid location: "'.concat(location, '".'));
32643       } else {
32644         return null;
32645       }
32646     }
32647     // resolveLocation
32648     // `location`  The location to resolve
32649     //
32650     // Pass a `location` value to resolve
32651     //
32652     // Returns a result like:
32653     //   {
32654     //     type:      'point', 'geojson', or 'countrycoder'
32655     //     location:  the queried location
32656     //     id:        a stable identifier for the feature
32657     //     feature:   the resolved GeoJSON feature
32658     //   }
32659     //  or `null` if the location is invalid
32660     //
32661     resolveLocation(location) {
32662       const valid = this.validateLocation(location);
32663       if (!valid) return null;
32664       const id2 = valid.id;
32665       if (this._cache[id2]) {
32666         return Object.assign(valid, { feature: this._cache[id2] });
32667       }
32668       if (valid.type === "point") {
32669         const lon = location[0];
32670         const lat = location[1];
32671         const radius = location[2] || 25;
32672         const EDGES = 10;
32673         const PRECISION = 3;
32674         const area = Math.PI * radius * radius;
32675         const feature3 = this._cache[id2] = (0, import_geojson_precision.default)({
32676           type: "Feature",
32677           id: id2,
32678           properties: { id: id2, area: Number(area.toFixed(2)) },
32679           geometry: (0, import_circle_to_polygon.default)([lon, lat], radius * 1e3, EDGES)
32680           // km to m
32681         }, PRECISION);
32682         return Object.assign(valid, { feature: feature3 });
32683       } else if (valid.type === "geojson") {
32684       } else if (valid.type === "countrycoder") {
32685         let feature3 = _cloneDeep(feature(id2));
32686         let props = feature3.properties;
32687         if (Array.isArray(props.members)) {
32688           let aggregate = aggregateFeature(id2);
32689           aggregate.geometry.coordinates = _clip([aggregate], "UNION").geometry.coordinates;
32690           feature3.geometry = aggregate.geometry;
32691         }
32692         if (!props.area) {
32693           const area = import_geojson_area.default.geometry(feature3.geometry) / 1e6;
32694           props.area = Number(area.toFixed(2));
32695         }
32696         feature3.id = id2;
32697         props.id = id2;
32698         this._cache[id2] = feature3;
32699         return Object.assign(valid, { feature: feature3 });
32700       }
32701       if (this.strict) {
32702         throw new Error("resolveLocation:  Couldn't resolve location \"".concat(location, '".'));
32703       } else {
32704         return null;
32705       }
32706     }
32707     // validateLocationSet
32708     // `locationSet`  the locationSet to validate
32709     //
32710     // Pass a locationSet Object to validate like:
32711     //   {
32712     //     include: [ Array of locations ],
32713     //     exclude: [ Array of locations ]
32714     //   }
32715     //
32716     // Returns a result like:
32717     //   {
32718     //     type:         'locationset'
32719     //     locationSet:  the queried locationSet
32720     //     id:           the stable identifier for the feature
32721     //   }
32722     // or `null` if the locationSet is invalid
32723     //
32724     validateLocationSet(locationSet) {
32725       locationSet = locationSet || {};
32726       const validator = this.validateLocation.bind(this);
32727       let include = (locationSet.include || []).map(validator).filter(Boolean);
32728       let exclude = (locationSet.exclude || []).map(validator).filter(Boolean);
32729       if (!include.length) {
32730         if (this.strict) {
32731           throw new Error("validateLocationSet:  LocationSet includes nothing.");
32732         } else {
32733           locationSet.include = ["Q2"];
32734           include = [{ type: "countrycoder", location: "Q2", id: "Q2" }];
32735         }
32736       }
32737       include.sort(_sortLocations);
32738       let id2 = "+[" + include.map((d2) => d2.id).join(",") + "]";
32739       if (exclude.length) {
32740         exclude.sort(_sortLocations);
32741         id2 += "-[" + exclude.map((d2) => d2.id).join(",") + "]";
32742       }
32743       return { type: "locationset", locationSet, id: id2 };
32744     }
32745     // resolveLocationSet
32746     // `locationSet`  the locationSet to resolve
32747     //
32748     // Pass a locationSet Object to validate like:
32749     //   {
32750     //     include: [ Array of locations ],
32751     //     exclude: [ Array of locations ]
32752     //   }
32753     //
32754     // Returns a result like:
32755     //   {
32756     //     type:         'locationset'
32757     //     locationSet:  the queried locationSet
32758     //     id:           the stable identifier for the feature
32759     //     feature:      the resolved GeoJSON feature
32760     //   }
32761     // or `null` if the locationSet is invalid
32762     //
32763     resolveLocationSet(locationSet) {
32764       locationSet = locationSet || {};
32765       const valid = this.validateLocationSet(locationSet);
32766       if (!valid) return null;
32767       const id2 = valid.id;
32768       if (this._cache[id2]) {
32769         return Object.assign(valid, { feature: this._cache[id2] });
32770       }
32771       const resolver = this.resolveLocation.bind(this);
32772       const includes = (locationSet.include || []).map(resolver).filter(Boolean);
32773       const excludes = (locationSet.exclude || []).map(resolver).filter(Boolean);
32774       if (includes.length === 1 && excludes.length === 0) {
32775         return Object.assign(valid, { feature: includes[0].feature });
32776       }
32777       const includeGeoJSON = _clip(includes.map((d2) => d2.feature), "UNION");
32778       const excludeGeoJSON = _clip(excludes.map((d2) => d2.feature), "UNION");
32779       let resultGeoJSON = excludeGeoJSON ? _clip([includeGeoJSON, excludeGeoJSON], "DIFFERENCE") : includeGeoJSON;
32780       const area = import_geojson_area.default.geometry(resultGeoJSON.geometry) / 1e6;
32781       resultGeoJSON.id = id2;
32782       resultGeoJSON.properties = { id: id2, area: Number(area.toFixed(2)) };
32783       this._cache[id2] = resultGeoJSON;
32784       return Object.assign(valid, { feature: resultGeoJSON });
32785     }
32786     // stringify
32787     // convenience method to prettyStringify the given object
32788     stringify(obj, options2) {
32789       return (0, import_json_stringify_pretty_compact.default)(obj, options2);
32790     }
32791   };
32792   function _clip(features, which) {
32793     if (!Array.isArray(features) || !features.length) return null;
32794     const fn = { UNION: union, DIFFERENCE: difference }[which];
32795     const args = features.map((feature3) => feature3.geometry.coordinates);
32796     const coords = fn.apply(null, args);
32797     return {
32798       type: "Feature",
32799       properties: {},
32800       geometry: {
32801         type: whichType(coords),
32802         coordinates: coords
32803       }
32804     };
32805     function whichType(coords2) {
32806       const a2 = Array.isArray(coords2);
32807       const b2 = a2 && Array.isArray(coords2[0]);
32808       const c2 = b2 && Array.isArray(coords2[0][0]);
32809       const d2 = c2 && Array.isArray(coords2[0][0][0]);
32810       return d2 ? "MultiPolygon" : "Polygon";
32811     }
32812   }
32813   function _cloneDeep(obj) {
32814     return JSON.parse(JSON.stringify(obj));
32815   }
32816   function _sortLocations(a2, b2) {
32817     const rank = { countrycoder: 1, geojson: 2, point: 3 };
32818     const aRank = rank[a2.type];
32819     const bRank = rank[b2.type];
32820     return aRank > bRank ? 1 : aRank < bRank ? -1 : a2.id.localeCompare(b2.id);
32821   }
32822
32823   // modules/core/LocationManager.js
32824   var import_which_polygon2 = __toESM(require_which_polygon());
32825   var import_geojson_area2 = __toESM(require_geojson_area());
32826   var _loco = new LocationConflation();
32827   var LocationManager = class {
32828     /**
32829      * @constructor
32830      */
32831     constructor() {
32832       this._wp = null;
32833       this._resolved = /* @__PURE__ */ new Map();
32834       this._knownLocationSets = /* @__PURE__ */ new Map();
32835       this._locationIncludedIn = /* @__PURE__ */ new Map();
32836       this._locationExcludedIn = /* @__PURE__ */ new Map();
32837       const world = { locationSet: { include: ["Q2"] } };
32838       this._resolveLocationSet(world);
32839       this._rebuildIndex();
32840     }
32841     /**
32842      * _validateLocationSet
32843      * Pass an Object with a `locationSet` property.
32844      * Validates the `locationSet` and sets a `locationSetID` property on the object.
32845      * To avoid so much computation we only resolve the include and exclude regions, but not the locationSet itself.
32846      *
32847      * Use `_resolveLocationSet()` instead if you need to resolve geojson of locationSet, for example to render it.
32848      * Note: You need to call `_rebuildIndex()` after you're all finished validating the locationSets.
32849      *
32850      * @param  `obj`  Object to check, it should have `locationSet` property
32851      */
32852     _validateLocationSet(obj) {
32853       if (obj.locationSetID) return;
32854       try {
32855         let locationSet = obj.locationSet;
32856         if (!locationSet) {
32857           throw new Error("object missing locationSet property");
32858         }
32859         if (!locationSet.include) {
32860           locationSet.include = ["Q2"];
32861         }
32862         const locationSetID = _loco.validateLocationSet(locationSet).id;
32863         obj.locationSetID = locationSetID;
32864         if (this._knownLocationSets.has(locationSetID)) return;
32865         let area = 0;
32866         (locationSet.include || []).forEach((location) => {
32867           const locationID = _loco.validateLocation(location).id;
32868           let geojson = this._resolved.get(locationID);
32869           if (!geojson) {
32870             geojson = _loco.resolveLocation(location).feature;
32871             this._resolved.set(locationID, geojson);
32872           }
32873           area += geojson.properties.area;
32874           let s2 = this._locationIncludedIn.get(locationID);
32875           if (!s2) {
32876             s2 = /* @__PURE__ */ new Set();
32877             this._locationIncludedIn.set(locationID, s2);
32878           }
32879           s2.add(locationSetID);
32880         });
32881         (locationSet.exclude || []).forEach((location) => {
32882           const locationID = _loco.validateLocation(location).id;
32883           let geojson = this._resolved.get(locationID);
32884           if (!geojson) {
32885             geojson = _loco.resolveLocation(location).feature;
32886             this._resolved.set(locationID, geojson);
32887           }
32888           area -= geojson.properties.area;
32889           let s2 = this._locationExcludedIn.get(locationID);
32890           if (!s2) {
32891             s2 = /* @__PURE__ */ new Set();
32892             this._locationExcludedIn.set(locationID, s2);
32893           }
32894           s2.add(locationSetID);
32895         });
32896         this._knownLocationSets.set(locationSetID, area);
32897       } catch (e3) {
32898         obj.locationSet = { include: ["Q2"] };
32899         obj.locationSetID = "+[Q2]";
32900       }
32901     }
32902     /**
32903      * _resolveLocationSet
32904      * Does everything that `_validateLocationSet()` does, but then "resolves" the locationSet into GeoJSON.
32905      * This step is a bit more computationally expensive, so really only needed if you intend to render the shape.
32906      *
32907      * Note: You need to call `_rebuildIndex()` after you're all finished validating the locationSets.
32908      *
32909      * @param  `obj`  Object to check, it should have `locationSet` property
32910      */
32911     _resolveLocationSet(obj) {
32912       this._validateLocationSet(obj);
32913       if (this._resolved.has(obj.locationSetID)) return;
32914       try {
32915         const result = _loco.resolveLocationSet(obj.locationSet);
32916         const locationSetID = result.id;
32917         obj.locationSetID = locationSetID;
32918         if (!result.feature.geometry.coordinates.length || !result.feature.properties.area) {
32919           throw new Error("locationSet ".concat(locationSetID, " resolves to an empty feature."));
32920         }
32921         let geojson = JSON.parse(JSON.stringify(result.feature));
32922         geojson.id = locationSetID;
32923         geojson.properties.id = locationSetID;
32924         this._resolved.set(locationSetID, geojson);
32925       } catch (e3) {
32926         obj.locationSet = { include: ["Q2"] };
32927         obj.locationSetID = "+[Q2]";
32928       }
32929     }
32930     /**
32931      * _rebuildIndex
32932      * Rebuilds the whichPolygon index with whatever features have been resolved into GeoJSON.
32933      */
32934     _rebuildIndex() {
32935       this._wp = (0, import_which_polygon2.default)({ features: [...this._resolved.values()] });
32936     }
32937     /**
32938      * mergeCustomGeoJSON
32939      * Accepts a FeatureCollection-like object containing custom locations
32940      * Each feature must have a filename-like `id`, for example: `something.geojson`
32941      * {
32942      *   "type": "FeatureCollection"
32943      *   "features": [
32944      *     {
32945      *       "type": "Feature",
32946      *       "id": "philly_metro.geojson",
32947      *       "properties": { … },
32948      *       "geometry": { … }
32949      *     }
32950      *   ]
32951      * }
32952      *
32953      * @param  `fc`  FeatureCollection-like Object containing custom locations
32954      */
32955     mergeCustomGeoJSON(fc) {
32956       if (!fc || fc.type !== "FeatureCollection" || !Array.isArray(fc.features)) return;
32957       fc.features.forEach((feature3) => {
32958         feature3.properties = feature3.properties || {};
32959         let props = feature3.properties;
32960         let id2 = feature3.id || props.id;
32961         if (!id2 || !/^\S+\.geojson$/i.test(id2)) return;
32962         id2 = id2.toLowerCase();
32963         feature3.id = id2;
32964         props.id = id2;
32965         if (!props.area) {
32966           const area = import_geojson_area2.default.geometry(feature3.geometry) / 1e6;
32967           props.area = Number(area.toFixed(2));
32968         }
32969         _loco._cache[id2] = feature3;
32970       });
32971     }
32972     /**
32973      * mergeLocationSets
32974      * Accepts an Array of Objects containing `locationSet` properties:
32975      * [
32976      *  { id: 'preset1', locationSet: {…} },
32977      *  { id: 'preset2', locationSet: {…} },
32978      *  …
32979      * ]
32980      * After validating, the Objects will be decorated with a `locationSetID` property:
32981      * [
32982      *  { id: 'preset1', locationSet: {…}, locationSetID: '+[Q2]' },
32983      *  { id: 'preset2', locationSet: {…}, locationSetID: '+[Q30]' },
32984      *  …
32985      * ]
32986      *
32987      * @param  `objects`  Objects to check - they should have `locationSet` property
32988      * @return  Promise resolved true (this function used to be slow/async, now it's faster and sync)
32989      */
32990     mergeLocationSets(objects) {
32991       if (!Array.isArray(objects)) return Promise.reject("nothing to do");
32992       objects.forEach((obj) => this._validateLocationSet(obj));
32993       this._rebuildIndex();
32994       return Promise.resolve(objects);
32995     }
32996     /**
32997      * locationSetID
32998      * Returns a locationSetID for a given locationSet (fallback to `+[Q2]`, world)
32999      * (The locationSet doesn't necessarily need to be resolved to compute its `id`)
33000      *
33001      * @param  `locationSet`  A locationSet Object, e.g. `{ include: ['us'] }`
33002      * @return  String locationSetID, e.g. `+[Q30]`
33003      */
33004     locationSetID(locationSet) {
33005       let locationSetID;
33006       try {
33007         locationSetID = _loco.validateLocationSet(locationSet).id;
33008       } catch (e3) {
33009         locationSetID = "+[Q2]";
33010       }
33011       return locationSetID;
33012     }
33013     /**
33014      * feature
33015      * Returns the resolved GeoJSON feature for a given locationSetID (fallback to 'world')
33016      * A GeoJSON feature:
33017      * {
33018      *   type: 'Feature',
33019      *   id: '+[Q30]',
33020      *   properties: { id: '+[Q30]', area: 21817019.17, … },
33021      *   geometry: { … }
33022      * }
33023      *
33024      * @param  `locationSetID`  String identifier, e.g. `+[Q30]`
33025      * @return  GeoJSON object (fallback to world)
33026      */
33027     feature(locationSetID = "+[Q2]") {
33028       const feature3 = this._resolved.get(locationSetID);
33029       return feature3 || this._resolved.get("+[Q2]");
33030     }
33031     /**
33032      * locationSetsAt
33033      * Find all the locationSets valid at the given location.
33034      * Results include the area (in km²) to facilitate sorting.
33035      *
33036      * Object of locationSetIDs to areas (in km²)
33037      * {
33038      *   "+[Q2]": 511207893.3958111,
33039      *   "+[Q30]": 21817019.17,
33040      *   "+[new_jersey.geojson]": 22390.77,
33041      *   …
33042      * }
33043      *
33044      * @param  `loc`  `[lon,lat]` location to query, e.g. `[-74.4813, 40.7967]`
33045      * @return  Object of locationSetIDs valid at given location
33046      */
33047     locationSetsAt(loc) {
33048       let result = {};
33049       const hits = this._wp(loc, true) || [];
33050       const thiz = this;
33051       hits.forEach((prop) => {
33052         if (prop.id[0] !== "+") return;
33053         const locationSetID = prop.id;
33054         const area = thiz._knownLocationSets.get(locationSetID);
33055         if (area) {
33056           result[locationSetID] = area;
33057         }
33058       });
33059       hits.forEach((prop) => {
33060         if (prop.id[0] === "+") return;
33061         const locationID = prop.id;
33062         const included = thiz._locationIncludedIn.get(locationID);
33063         (included || []).forEach((locationSetID) => {
33064           const area = thiz._knownLocationSets.get(locationSetID);
33065           if (area) {
33066             result[locationSetID] = area;
33067           }
33068         });
33069       });
33070       hits.forEach((prop) => {
33071         if (prop.id[0] === "+") return;
33072         const locationID = prop.id;
33073         const excluded = thiz._locationExcludedIn.get(locationID);
33074         (excluded || []).forEach((locationSetID) => {
33075           delete result[locationSetID];
33076         });
33077       });
33078       return result;
33079     }
33080     // Direct access to the location-conflation resolver
33081     loco() {
33082       return _loco;
33083     }
33084   };
33085   var _sharedLocationManager = new LocationManager();
33086
33087   // modules/presets/collection.js
33088   function presetCollection(collection) {
33089     const MAXRESULTS = 50;
33090     let _this = {};
33091     let _memo = {};
33092     _this.collection = collection;
33093     _this.item = (id2) => {
33094       if (_memo[id2]) return _memo[id2];
33095       const found = _this.collection.find((d2) => d2.id === id2);
33096       if (found) _memo[id2] = found;
33097       return found;
33098     };
33099     _this.index = (id2) => _this.collection.findIndex((d2) => d2.id === id2);
33100     _this.matchGeometry = (geometry) => {
33101       return presetCollection(
33102         _this.collection.filter((d2) => d2.matchGeometry(geometry))
33103       );
33104     };
33105     _this.matchAllGeometry = (geometries) => {
33106       return presetCollection(
33107         _this.collection.filter((d2) => d2 && d2.matchAllGeometry(geometries))
33108       );
33109     };
33110     _this.matchAnyGeometry = (geometries) => {
33111       return presetCollection(
33112         _this.collection.filter((d2) => geometries.some((geom) => d2.matchGeometry(geom)))
33113       );
33114     };
33115     _this.fallback = (geometry) => {
33116       let id2 = geometry;
33117       if (id2 === "vertex") id2 = "point";
33118       return _this.item(id2);
33119     };
33120     _this.search = (value, geometry, loc) => {
33121       if (!value) return _this;
33122       value = value.toLowerCase().trim();
33123       function leading(a2) {
33124         const index = a2.indexOf(value);
33125         return index === 0 || a2[index - 1] === " ";
33126       }
33127       function leadingStrict(a2) {
33128         const index = a2.indexOf(value);
33129         return index === 0;
33130       }
33131       function sortPresets(nameProp, aliasesProp) {
33132         return function sortNames(a2, b2) {
33133           let aCompare = a2[nameProp]();
33134           let bCompare = b2[nameProp]();
33135           if (aliasesProp) {
33136             const findMatchingAlias = (strings) => {
33137               if (strings.some((s2) => s2 === value)) {
33138                 return strings.find((s2) => s2 === value);
33139               } else {
33140                 return strings.filter((s2) => s2.includes(value)).sort((a3, b3) => a3.length - b3.length)[0];
33141               }
33142             };
33143             aCompare = findMatchingAlias([aCompare].concat(a2[aliasesProp]()));
33144             bCompare = findMatchingAlias([bCompare].concat(b2[aliasesProp]()));
33145           }
33146           if (value === aCompare) return -1;
33147           if (value === bCompare) return 1;
33148           let i3 = b2.originalScore - a2.originalScore;
33149           if (i3 !== 0) return i3;
33150           i3 = aCompare.indexOf(value) - bCompare.indexOf(value);
33151           if (i3 !== 0) return i3;
33152           return aCompare.length - bCompare.length;
33153         };
33154       }
33155       let pool = _this.collection;
33156       if (Array.isArray(loc)) {
33157         const validHere = _sharedLocationManager.locationSetsAt(loc);
33158         pool = pool.filter((a2) => !a2.locationSetID || validHere[a2.locationSetID]);
33159       }
33160       const searchable = pool.filter((a2) => a2.searchable !== false && a2.suggestion !== true);
33161       const suggestions = pool.filter((a2) => a2.suggestion === true);
33162       const leadingNames = searchable.filter((a2) => leading(a2.searchName()) || a2.searchAliases().some(leading)).sort(sortPresets("searchName", "searchAliases"));
33163       const leadingSuggestions = suggestions.filter((a2) => leadingStrict(a2.searchName())).sort(sortPresets("searchName"));
33164       const leadingNamesStripped = searchable.filter((a2) => leading(a2.searchNameStripped()) || a2.searchAliasesStripped().some(leading)).sort(sortPresets("searchNameStripped", "searchAliasesStripped"));
33165       const leadingSuggestionsStripped = suggestions.filter((a2) => leadingStrict(a2.searchNameStripped())).sort(sortPresets("searchNameStripped"));
33166       const leadingTerms = searchable.filter((a2) => (a2.terms() || []).some(leading));
33167       const leadingSuggestionTerms = suggestions.filter((a2) => (a2.terms() || []).some(leading));
33168       const leadingTagValues = searchable.filter((a2) => Object.values(a2.tags || {}).filter((val) => val !== "*").some(leading));
33169       const similarName = searchable.map((a2) => ({ preset: a2, dist: utilEditDistance(value, a2.searchName()) })).filter((a2) => a2.dist + Math.min(value.length - a2.preset.searchName().length, 0) < 3).sort((a2, b2) => a2.dist - b2.dist).map((a2) => a2.preset);
33170       const similarSuggestions = suggestions.map((a2) => ({ preset: a2, dist: utilEditDistance(value, a2.searchName()) })).filter((a2) => a2.dist + Math.min(value.length - a2.preset.searchName().length, 0) < 1).sort((a2, b2) => a2.dist - b2.dist).map((a2) => a2.preset);
33171       const similarTerms = searchable.filter((a2) => {
33172         return (a2.terms() || []).some((b2) => {
33173           return utilEditDistance(value, b2) + Math.min(value.length - b2.length, 0) < 3;
33174         });
33175       });
33176       let leadingTagKeyValues = [];
33177       if (value.includes("=")) {
33178         leadingTagKeyValues = searchable.filter((a2) => a2.tags && Object.keys(a2.tags).some((key) => key + "=" + a2.tags[key] === value)).concat(searchable.filter((a2) => a2.tags && Object.keys(a2.tags).some((key) => leading(key + "=" + a2.tags[key]))));
33179       }
33180       let results = leadingNames.concat(
33181         leadingSuggestions,
33182         leadingNamesStripped,
33183         leadingSuggestionsStripped,
33184         leadingTerms,
33185         leadingSuggestionTerms,
33186         leadingTagValues,
33187         similarName,
33188         similarSuggestions,
33189         similarTerms,
33190         leadingTagKeyValues
33191       ).slice(0, MAXRESULTS - 1);
33192       if (geometry) {
33193         if (typeof geometry === "string") {
33194           results.push(_this.fallback(geometry));
33195         } else {
33196           geometry.forEach((geom) => results.push(_this.fallback(geom)));
33197         }
33198       }
33199       return presetCollection(utilArrayUniq(results));
33200     };
33201     return _this;
33202   }
33203
33204   // modules/presets/category.js
33205   function presetCategory(categoryID, category, allPresets) {
33206     let _this = Object.assign({}, category);
33207     let _searchName;
33208     let _searchNameStripped;
33209     _this.id = categoryID;
33210     _this.members = presetCollection(
33211       (category.members || []).map((presetID) => allPresets[presetID]).filter(Boolean)
33212     );
33213     _this.geometry = _this.members.collection.reduce((acc, preset) => {
33214       for (let i3 in preset.geometry) {
33215         const geometry = preset.geometry[i3];
33216         if (acc.indexOf(geometry) === -1) {
33217           acc.push(geometry);
33218         }
33219       }
33220       return acc;
33221     }, []);
33222     _this.matchGeometry = (geom) => _this.geometry.indexOf(geom) >= 0;
33223     _this.matchAllGeometry = (geometries) => _this.members.collection.some((preset) => preset.matchAllGeometry(geometries));
33224     _this.matchScore = () => -1;
33225     _this.name = () => _t("_tagging.presets.categories.".concat(categoryID, ".name"), { "default": categoryID });
33226     _this.nameLabel = () => _t.append("_tagging.presets.categories.".concat(categoryID, ".name"), { "default": categoryID });
33227     _this.terms = () => [];
33228     _this.searchName = () => {
33229       if (!_searchName) {
33230         _searchName = (_this.suggestion ? _this.originalName : _this.name()).toLowerCase();
33231       }
33232       return _searchName;
33233     };
33234     _this.searchNameStripped = () => {
33235       if (!_searchNameStripped) {
33236         _searchNameStripped = _this.searchName();
33237         if (_searchNameStripped.normalize) _searchNameStripped = _searchNameStripped.normalize("NFD");
33238         _searchNameStripped = _searchNameStripped.replace(/[\u0300-\u036f]/g, "");
33239       }
33240       return _searchNameStripped;
33241     };
33242     _this.searchAliases = () => [];
33243     _this.searchAliasesStripped = () => [];
33244     return _this;
33245   }
33246
33247   // modules/presets/field.js
33248   function presetField(fieldID, field, allFields) {
33249     allFields = allFields || {};
33250     let _this = Object.assign({}, field);
33251     _this.id = fieldID;
33252     _this.safeid = utilSafeClassName(fieldID);
33253     _this.matchGeometry = (geom) => !_this.geometry || _this.geometry.indexOf(geom) !== -1;
33254     _this.matchAllGeometry = (geometries) => {
33255       return !_this.geometry || geometries.every((geom) => _this.geometry.indexOf(geom) !== -1);
33256     };
33257     _this.t = (scope, options2) => _t("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
33258     _this.t.html = (scope, options2) => _t.html("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
33259     _this.t.append = (scope, options2) => _t.append("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
33260     _this.hasTextForStringId = (scope) => _mainLocalizer.hasTextForStringId("_tagging.presets.fields.".concat(fieldID, ".").concat(scope));
33261     _this.resolveReference = (which) => {
33262       const referenceRegex = /^\{(.*)\}$/;
33263       const match = (field[which] || "").match(referenceRegex);
33264       if (match) {
33265         const field2 = allFields[match[1]];
33266         if (field2) {
33267           return field2;
33268         }
33269         console.error("Unable to resolve referenced field: ".concat(match[1]));
33270       }
33271       return _this;
33272     };
33273     _this.title = () => _this.overrideLabel || _this.resolveReference("label").t("label", { "default": fieldID });
33274     _this.label = () => _this.overrideLabel ? (selection2) => selection2.text(_this.overrideLabel) : _this.resolveReference("label").t.append("label", { "default": fieldID });
33275     _this.placeholder = () => _this.resolveReference("placeholder").t("placeholder", { "default": "" });
33276     _this.originalTerms = (_this.terms || []).join();
33277     _this.terms = () => _this.resolveReference("label").t("terms", { "default": _this.originalTerms }).toLowerCase().trim().split(/\s*,+\s*/);
33278     _this.increment = _this.type === "number" ? _this.increment || 1 : void 0;
33279     return _this;
33280   }
33281
33282   // modules/presets/preset.js
33283   var import_lodash2 = __toESM(require_lodash());
33284   function presetPreset(presetID, preset, addable, allFields, allPresets) {
33285     allFields = allFields || {};
33286     allPresets = allPresets || {};
33287     let _this = Object.assign({}, preset);
33288     let _addable = addable || false;
33289     let _searchName;
33290     let _searchNameStripped;
33291     let _searchAliases;
33292     let _searchAliasesStripped;
33293     const referenceRegex = /^\{(.*)\}$/;
33294     _this.id = presetID;
33295     _this.safeid = utilSafeClassName(presetID);
33296     _this.originalTerms = (_this.terms || []).join();
33297     _this.originalName = _this.name || "";
33298     _this.originalAliases = (_this.aliases || []).join("\n");
33299     _this.originalScore = _this.matchScore || 1;
33300     _this.originalReference = _this.reference || {};
33301     _this.originalFields = _this.fields || [];
33302     _this.originalMoreFields = _this.moreFields || [];
33303     _this.fields = (loc) => resolveFields("fields", loc);
33304     _this.moreFields = (loc) => resolveFields("moreFields", loc);
33305     _this.tags = _this.tags || {};
33306     _this.addTags = _this.addTags || _this.tags;
33307     _this.removeTags = _this.removeTags || _this.addTags;
33308     _this.geometry = _this.geometry || [];
33309     _this.matchGeometry = (geom) => _this.geometry.indexOf(geom) >= 0;
33310     _this.matchAllGeometry = (geoms) => geoms.every(_this.matchGeometry);
33311     _this.matchScore = (entityTags) => {
33312       const tags = _this.tags;
33313       let seen = {};
33314       let score = 0;
33315       for (let k2 in tags) {
33316         seen[k2] = true;
33317         if (entityTags[k2] === tags[k2]) {
33318           score += _this.originalScore;
33319         } else if (tags[k2] === "*" && k2 in entityTags) {
33320           score += _this.originalScore / 2;
33321         } else {
33322           return -1;
33323         }
33324       }
33325       const addTags = _this.addTags;
33326       for (let k2 in addTags) {
33327         if (!seen[k2] && entityTags[k2] === addTags[k2]) {
33328           score += _this.originalScore;
33329         }
33330       }
33331       if (_this.searchable === false) {
33332         score *= 0.999;
33333       }
33334       return score;
33335     };
33336     _this.t = (scope, options2) => {
33337       const textID = "_tagging.presets.presets.".concat(presetID, ".").concat(scope);
33338       return _t(textID, options2);
33339     };
33340     _this.t.append = (scope, options2) => {
33341       const textID = "_tagging.presets.presets.".concat(presetID, ".").concat(scope);
33342       return _t.append(textID, options2);
33343     };
33344     function resolveReference(which) {
33345       const match = (_this[which] || "").match(referenceRegex);
33346       if (match) {
33347         const preset2 = allPresets[match[1]];
33348         if (preset2) {
33349           return preset2;
33350         }
33351         console.error("Unable to resolve referenced preset: ".concat(match[1]));
33352       }
33353       return _this;
33354     }
33355     _this.name = () => {
33356       return resolveReference("originalName").t("name", { "default": _this.originalName || presetID });
33357     };
33358     _this.nameLabel = () => {
33359       return resolveReference("originalName").t.append("name", { "default": _this.originalName || presetID });
33360     };
33361     _this.subtitle = () => {
33362       if (_this.suggestion) {
33363         let path = presetID.split("/");
33364         path.pop();
33365         return _t("_tagging.presets.presets." + path.join("/") + ".name");
33366       }
33367       return null;
33368     };
33369     _this.subtitleLabel = () => {
33370       if (_this.suggestion) {
33371         let path = presetID.split("/");
33372         path.pop();
33373         return _t.append("_tagging.presets.presets." + path.join("/") + ".name");
33374       }
33375       return null;
33376     };
33377     _this.aliases = () => {
33378       return resolveReference("originalName").t("aliases", { "default": _this.originalAliases }).trim().split(/\s*[\r\n]+\s*/);
33379     };
33380     _this.terms = () => {
33381       return resolveReference("originalName").t("terms", { "default": _this.originalTerms }).toLowerCase().trim().split(/\s*,+\s*/);
33382     };
33383     _this.searchName = () => {
33384       if (!_searchName) {
33385         _searchName = (_this.suggestion ? _this.originalName : _this.name()).toLowerCase();
33386       }
33387       return _searchName;
33388     };
33389     _this.searchNameStripped = () => {
33390       if (!_searchNameStripped) {
33391         _searchNameStripped = stripDiacritics(_this.searchName());
33392       }
33393       return _searchNameStripped;
33394     };
33395     _this.searchAliases = () => {
33396       if (!_searchAliases) {
33397         _searchAliases = _this.aliases().map((alias) => alias.toLowerCase());
33398       }
33399       return _searchAliases;
33400     };
33401     _this.searchAliasesStripped = () => {
33402       if (!_searchAliasesStripped) {
33403         _searchAliasesStripped = _this.searchAliases();
33404         _searchAliasesStripped = _searchAliasesStripped.map(stripDiacritics);
33405       }
33406       return _searchAliasesStripped;
33407     };
33408     _this.isFallback = () => {
33409       const tagCount = Object.keys(_this.tags).length;
33410       return tagCount === 0 || tagCount === 1 && _this.tags.hasOwnProperty("area");
33411     };
33412     _this.addable = function(val) {
33413       if (!arguments.length) return _addable;
33414       _addable = val;
33415       return _this;
33416     };
33417     _this.reference = () => {
33418       const qid = _this.tags.wikidata || _this.tags["flag:wikidata"] || _this.tags["brand:wikidata"] || _this.tags["network:wikidata"] || _this.tags["operator:wikidata"];
33419       if (qid) {
33420         return { qid };
33421       }
33422       let key = _this.originalReference.key || Object.keys(utilObjectOmit(_this.tags, "name"))[0];
33423       let value = _this.originalReference.value || _this.tags[key];
33424       if (value === "*") {
33425         return { key };
33426       } else {
33427         return { key, value };
33428       }
33429     };
33430     _this.unsetTags = (tags, geometry, ignoringKeys, skipFieldDefaults, loc) => {
33431       let removeTags = ignoringKeys ? utilObjectOmit(_this.removeTags, ignoringKeys) : _this.removeTags;
33432       tags = utilObjectOmit(tags, Object.keys(removeTags));
33433       if (geometry && !skipFieldDefaults) {
33434         _this.fields(loc).forEach((field) => {
33435           if (field.matchGeometry(geometry) && field.key && field.default === tags[field.key] && (!ignoringKeys || ignoringKeys.indexOf(field.key) === -1)) {
33436             delete tags[field.key];
33437           }
33438         });
33439       }
33440       delete tags.area;
33441       return tags;
33442     };
33443     _this.setTags = (tags, geometry, skipFieldDefaults, loc) => {
33444       const addTags = _this.addTags;
33445       tags = Object.assign({}, tags);
33446       for (let k2 in addTags) {
33447         if (addTags[k2] === "*") {
33448           if (_this.tags[k2] || !tags[k2]) {
33449             tags[k2] = "yes";
33450           }
33451         } else {
33452           tags[k2] = addTags[k2];
33453         }
33454       }
33455       if (!addTags.hasOwnProperty("area")) {
33456         delete tags.area;
33457         if (geometry === "area") {
33458           let needsAreaTag = true;
33459           for (let k2 in addTags) {
33460             if (_this.geometry.indexOf("line") === -1 && k2 in osmAreaKeys || k2 in osmAreaKeysExceptions && addTags[k2] in osmAreaKeysExceptions[k2]) {
33461               needsAreaTag = false;
33462               break;
33463             }
33464           }
33465           if (needsAreaTag) {
33466             tags.area = "yes";
33467           }
33468         }
33469       }
33470       if (geometry && !skipFieldDefaults) {
33471         _this.fields(loc).forEach((field) => {
33472           if (field.matchGeometry(geometry) && field.key && !tags[field.key] && field.default) {
33473             tags[field.key] = field.default;
33474           }
33475         });
33476       }
33477       return tags;
33478     };
33479     function resolveFields(which, loc) {
33480       const fieldIDs = which === "fields" ? _this.originalFields : _this.originalMoreFields;
33481       let resolved = [];
33482       fieldIDs.forEach((fieldID) => {
33483         const match = fieldID.match(referenceRegex);
33484         if (match !== null) {
33485           resolved = resolved.concat(inheritFields(allPresets[match[1]], which));
33486         } else if (allFields[fieldID]) {
33487           resolved.push(allFields[fieldID]);
33488         } else {
33489           console.log('Cannot resolve "'.concat(fieldID, '" found in ').concat(_this.id, ".").concat(which));
33490         }
33491       });
33492       if (!resolved.length) {
33493         const endIndex = _this.id.lastIndexOf("/");
33494         const parentID = endIndex && _this.id.substring(0, endIndex);
33495         if (parentID) {
33496           let parent = allPresets[parentID];
33497           if (loc) {
33498             const validHere = _sharedLocationManager.locationSetsAt(loc);
33499             if ((parent == null ? void 0 : parent.locationSetID) && !validHere[parent.locationSetID]) {
33500               const candidateIDs = Object.keys(allPresets).filter((k2) => k2.startsWith(parentID));
33501               parent = allPresets[candidateIDs.find((candidateID) => {
33502                 const candidate = allPresets[candidateID];
33503                 return validHere[candidate.locationSetID] && (0, import_lodash2.isEqual)(candidate.tags, parent.tags);
33504               })];
33505             }
33506           }
33507           resolved = inheritFields(parent, which);
33508         }
33509       }
33510       return utilArrayUniq(resolved);
33511       function inheritFields(parent, which2) {
33512         if (!parent) return [];
33513         if (which2 === "fields") {
33514           return parent.fields().filter(shouldInherit);
33515         } else if (which2 === "moreFields") {
33516           return parent.moreFields();
33517         } else {
33518           return [];
33519         }
33520       }
33521       function shouldInherit(f2) {
33522         if (f2.key && _this.tags[f2.key] !== void 0 && // inherit anyway if multiple values are allowed or just a checkbox
33523         f2.type !== "multiCombo" && f2.type !== "semiCombo" && f2.type !== "manyCombo" && f2.type !== "check") return false;
33524         return true;
33525       }
33526     }
33527     function stripDiacritics(s2) {
33528       if (s2.normalize) s2 = s2.normalize("NFD");
33529       s2 = s2.replace(/[\u0300-\u036f]/g, "");
33530       return s2;
33531     }
33532     return _this;
33533   }
33534
33535   // modules/presets/index.js
33536   var _mainPresetIndex = presetIndex();
33537   function presetIndex() {
33538     const dispatch14 = dispatch_default("favoritePreset", "recentsChange");
33539     const MAXRECENTS = 30;
33540     const POINT = presetPreset("point", { name: "Point", tags: {}, geometry: ["point", "vertex"], matchScore: 0.1 });
33541     const LINE = presetPreset("line", { name: "Line", tags: {}, geometry: ["line"], matchScore: 0.1 });
33542     const AREA = presetPreset("area", { name: "Area", tags: { area: "yes" }, geometry: ["area"], matchScore: 0.1 });
33543     const RELATION = presetPreset("relation", { name: "Relation", tags: {}, geometry: ["relation"], matchScore: 0.1 });
33544     let _this = presetCollection([POINT, LINE, AREA, RELATION]);
33545     let _presets = { point: POINT, line: LINE, area: AREA, relation: RELATION };
33546     let _defaults2 = {
33547       point: presetCollection([POINT]),
33548       vertex: presetCollection([POINT]),
33549       line: presetCollection([LINE]),
33550       area: presetCollection([AREA]),
33551       relation: presetCollection([RELATION])
33552     };
33553     let _fields = {};
33554     let _categories = {};
33555     let _universal = [];
33556     let _addablePresetIDs = null;
33557     let _recents;
33558     let _favorites;
33559     let _geometryIndex = { point: {}, vertex: {}, line: {}, area: {}, relation: {} };
33560     let _loadPromise;
33561     _this.ensureLoaded = (bypassCache) => {
33562       if (_loadPromise && !bypassCache) return _loadPromise;
33563       return _loadPromise = Promise.all([
33564         _mainFileFetcher.get("preset_categories"),
33565         _mainFileFetcher.get("preset_defaults"),
33566         _mainFileFetcher.get("preset_presets"),
33567         _mainFileFetcher.get("preset_fields")
33568       ]).then((vals) => {
33569         _this.merge({
33570           categories: vals[0],
33571           defaults: vals[1],
33572           presets: vals[2],
33573           fields: vals[3]
33574         });
33575         osmSetAreaKeys(_this.areaKeys());
33576         osmSetLineTags(_this.lineTags());
33577         osmSetPointTags(_this.pointTags());
33578         osmSetVertexTags(_this.vertexTags());
33579       });
33580     };
33581     _this.merge = (d2) => {
33582       let newLocationSets = [];
33583       if (d2.fields) {
33584         Object.keys(d2.fields).forEach((fieldID) => {
33585           let f2 = d2.fields[fieldID];
33586           if (f2) {
33587             f2 = presetField(fieldID, f2, _fields);
33588             if (f2.locationSet) newLocationSets.push(f2);
33589             _fields[fieldID] = f2;
33590           } else {
33591             delete _fields[fieldID];
33592           }
33593         });
33594       }
33595       if (d2.presets) {
33596         Object.keys(d2.presets).forEach((presetID) => {
33597           let p2 = d2.presets[presetID];
33598           if (p2) {
33599             const isAddable = !_addablePresetIDs || _addablePresetIDs.has(presetID);
33600             p2 = presetPreset(presetID, p2, isAddable, _fields, _presets);
33601             if (p2.locationSet) newLocationSets.push(p2);
33602             _presets[presetID] = p2;
33603           } else {
33604             const existing = _presets[presetID];
33605             if (existing && !existing.isFallback()) {
33606               delete _presets[presetID];
33607             }
33608           }
33609         });
33610       }
33611       if (d2.categories) {
33612         Object.keys(d2.categories).forEach((categoryID) => {
33613           let c2 = d2.categories[categoryID];
33614           if (c2) {
33615             c2 = presetCategory(categoryID, c2, _presets);
33616             if (c2.locationSet) newLocationSets.push(c2);
33617             _categories[categoryID] = c2;
33618           } else {
33619             delete _categories[categoryID];
33620           }
33621         });
33622       }
33623       _this.collection = Object.values(_presets).concat(Object.values(_categories));
33624       if (d2.defaults) {
33625         Object.keys(d2.defaults).forEach((geometry) => {
33626           const def2 = d2.defaults[geometry];
33627           if (Array.isArray(def2)) {
33628             _defaults2[geometry] = presetCollection(
33629               def2.map((id2) => _presets[id2] || _categories[id2]).filter(Boolean)
33630             );
33631           } else {
33632             delete _defaults2[geometry];
33633           }
33634         });
33635       }
33636       _universal = Object.values(_fields).filter((field) => field.universal);
33637       _geometryIndex = { point: {}, vertex: {}, line: {}, area: {}, relation: {} };
33638       _this.collection.forEach((preset) => {
33639         (preset.geometry || []).forEach((geometry) => {
33640           let g3 = _geometryIndex[geometry];
33641           for (let key in preset.tags) {
33642             g3[key] = g3[key] || {};
33643             let value = preset.tags[key];
33644             (g3[key][value] = g3[key][value] || []).push(preset);
33645           }
33646         });
33647       });
33648       if (d2.featureCollection && Array.isArray(d2.featureCollection.features)) {
33649         _sharedLocationManager.mergeCustomGeoJSON(d2.featureCollection);
33650       }
33651       if (newLocationSets.length) {
33652         _sharedLocationManager.mergeLocationSets(newLocationSets);
33653       }
33654       return _this;
33655     };
33656     _this.match = (entity, resolver) => {
33657       return resolver.transient(entity, "presetMatch", () => {
33658         let geometry = entity.geometry(resolver);
33659         if (geometry === "vertex" && entity.isOnAddressLine(resolver)) {
33660           geometry = "point";
33661         }
33662         const entityExtent = entity.extent(resolver);
33663         return _this.matchTags(entity.tags, geometry, entityExtent.center());
33664       });
33665     };
33666     _this.matchTags = (tags, geometry, loc) => {
33667       const keyIndex = _geometryIndex[geometry];
33668       let bestScore = -1;
33669       let bestMatch;
33670       let matchCandidates = [];
33671       for (let k2 in tags) {
33672         let indexMatches = [];
33673         let valueIndex = keyIndex[k2];
33674         if (!valueIndex) continue;
33675         let keyValueMatches = valueIndex[tags[k2]];
33676         if (keyValueMatches) indexMatches.push(...keyValueMatches);
33677         let keyStarMatches = valueIndex["*"];
33678         if (keyStarMatches) indexMatches.push(...keyStarMatches);
33679         if (indexMatches.length === 0) continue;
33680         for (let i3 = 0; i3 < indexMatches.length; i3++) {
33681           const candidate = indexMatches[i3];
33682           const score = candidate.matchScore(tags);
33683           if (score === -1) {
33684             continue;
33685           }
33686           matchCandidates.push({ score, candidate });
33687           if (score > bestScore) {
33688             bestScore = score;
33689             bestMatch = candidate;
33690           }
33691         }
33692       }
33693       if (bestMatch && bestMatch.locationSetID && bestMatch.locationSetID !== "+[Q2]" && Array.isArray(loc)) {
33694         const validHere = _sharedLocationManager.locationSetsAt(loc);
33695         if (!validHere[bestMatch.locationSetID]) {
33696           matchCandidates.sort((a2, b2) => a2.score < b2.score ? 1 : -1);
33697           for (let i3 = 0; i3 < matchCandidates.length; i3++) {
33698             const candidateScore = matchCandidates[i3];
33699             if (!candidateScore.candidate.locationSetID || validHere[candidateScore.candidate.locationSetID]) {
33700               bestMatch = candidateScore.candidate;
33701               bestScore = candidateScore.score;
33702               break;
33703             }
33704           }
33705         }
33706       }
33707       if (!bestMatch || bestMatch.isFallback()) {
33708         for (let k2 in tags) {
33709           if (/^addr:/.test(k2) && keyIndex["addr:*"] && keyIndex["addr:*"]["*"]) {
33710             bestMatch = keyIndex["addr:*"]["*"][0];
33711             break;
33712           }
33713         }
33714       }
33715       return bestMatch || _this.fallback(geometry);
33716     };
33717     _this.allowsVertex = (entity, resolver) => {
33718       if (entity.type !== "node") return false;
33719       if (Object.keys(entity.tags).length === 0) return true;
33720       return resolver.transient(entity, "vertexMatch", () => {
33721         if (entity.isOnAddressLine(resolver)) return true;
33722         const geometries = osmNodeGeometriesForTags(entity.tags);
33723         if (geometries.vertex) return true;
33724         if (geometries.point) return false;
33725         return true;
33726       });
33727     };
33728     _this.areaKeys = () => {
33729       const ignore = {
33730         barrier: true,
33731         highway: true,
33732         footway: true,
33733         railway: true,
33734         junction: true,
33735         type: true
33736       };
33737       let areaKeys = {};
33738       const presets = _this.collection.filter((p2) => !p2.suggestion && !p2.replacement);
33739       presets.forEach((p2) => {
33740         const keys2 = p2.tags && Object.keys(p2.tags);
33741         const key = keys2 && keys2.length && keys2[0];
33742         if (!key) return;
33743         if (ignore[key]) return;
33744         if (p2.geometry.indexOf("area") !== -1) {
33745           areaKeys[key] = areaKeys[key] || {};
33746         }
33747       });
33748       presets.forEach((p2) => {
33749         let key;
33750         for (key in p2.addTags) {
33751           const value = p2.addTags[key];
33752           if (key in areaKeys && // probably an area...
33753           p2.geometry.indexOf("line") !== -1 && // but sometimes a line
33754           value !== "*") {
33755             areaKeys[key][value] = true;
33756           }
33757         }
33758       });
33759       return areaKeys;
33760     };
33761     _this.lineTags = () => {
33762       return _this.collection.filter((lineTags, d2) => {
33763         if (d2.suggestion || d2.replacement || d2.searchable === false) return lineTags;
33764         const keys2 = d2.tags && Object.keys(d2.tags);
33765         const key = keys2 && keys2.length && keys2[0];
33766         if (!key) return lineTags;
33767         if (d2.geometry.indexOf("line") !== -1) {
33768           lineTags[key] = lineTags[key] || [];
33769           lineTags[key].push(d2.tags);
33770         }
33771         return lineTags;
33772       }, {});
33773     };
33774     _this.pointTags = () => {
33775       return _this.collection.reduce((pointTags, d2) => {
33776         if (d2.suggestion || d2.replacement || d2.searchable === false) return pointTags;
33777         const keys2 = d2.tags && Object.keys(d2.tags);
33778         const key = keys2 && keys2.length && keys2[0];
33779         if (!key) return pointTags;
33780         if (d2.geometry.indexOf("point") !== -1) {
33781           pointTags[key] = pointTags[key] || {};
33782           pointTags[key][d2.tags[key]] = true;
33783         }
33784         return pointTags;
33785       }, {});
33786     };
33787     _this.vertexTags = () => {
33788       return _this.collection.reduce((vertexTags, d2) => {
33789         if (d2.suggestion || d2.replacement || d2.searchable === false) return vertexTags;
33790         const keys2 = d2.tags && Object.keys(d2.tags);
33791         const key = keys2 && keys2.length && keys2[0];
33792         if (!key) return vertexTags;
33793         if (d2.geometry.indexOf("vertex") !== -1) {
33794           vertexTags[key] = vertexTags[key] || {};
33795           vertexTags[key][d2.tags[key]] = true;
33796         }
33797         return vertexTags;
33798       }, {});
33799     };
33800     _this.field = (id2) => _fields[id2];
33801     _this.universal = () => _universal;
33802     _this.defaults = (geometry, n3, startWithRecents, loc, extraPresets) => {
33803       let recents = [];
33804       if (startWithRecents) {
33805         recents = _this.recent().matchGeometry(geometry).collection.slice(0, 4);
33806       }
33807       let defaults;
33808       if (_addablePresetIDs) {
33809         defaults = Array.from(_addablePresetIDs).map(function(id2) {
33810           var preset = _this.item(id2);
33811           if (preset && preset.matchGeometry(geometry)) return preset;
33812           return null;
33813         }).filter(Boolean);
33814       } else {
33815         defaults = _defaults2[geometry].collection.concat(_this.fallback(geometry));
33816       }
33817       let result = presetCollection(
33818         utilArrayUniq(recents.concat(defaults).concat(extraPresets || [])).slice(0, n3 - 1)
33819       );
33820       if (Array.isArray(loc)) {
33821         const validHere = _sharedLocationManager.locationSetsAt(loc);
33822         result.collection = result.collection.filter((a2) => !a2.locationSetID || validHere[a2.locationSetID]);
33823       }
33824       return result;
33825     };
33826     _this.addablePresetIDs = function(val) {
33827       if (!arguments.length) return _addablePresetIDs;
33828       if (Array.isArray(val)) val = new Set(val);
33829       _addablePresetIDs = val;
33830       if (_addablePresetIDs) {
33831         _this.collection.forEach((p2) => {
33832           if (p2.addable) p2.addable(_addablePresetIDs.has(p2.id));
33833         });
33834       } else {
33835         _this.collection.forEach((p2) => {
33836           if (p2.addable) p2.addable(true);
33837         });
33838       }
33839       return _this;
33840     };
33841     _this.recent = () => {
33842       return presetCollection(
33843         utilArrayUniq(_this.getRecents().map((d2) => d2.preset).filter((d2) => d2.searchable !== false))
33844       );
33845     };
33846     function RibbonItem(preset, source) {
33847       let item = {};
33848       item.preset = preset;
33849       item.source = source;
33850       item.isFavorite = () => item.source === "favorite";
33851       item.isRecent = () => item.source === "recent";
33852       item.matches = (preset2) => item.preset.id === preset2.id;
33853       item.minified = () => ({ pID: item.preset.id });
33854       return item;
33855     }
33856     function ribbonItemForMinified(d2, source) {
33857       if (d2 && d2.pID) {
33858         const preset = _this.item(d2.pID);
33859         if (!preset) return null;
33860         return RibbonItem(preset, source);
33861       }
33862       return null;
33863     }
33864     _this.getGenericRibbonItems = () => {
33865       return ["point", "line", "area"].map((id2) => RibbonItem(_this.item(id2), "generic"));
33866     };
33867     _this.getAddable = () => {
33868       if (!_addablePresetIDs) return [];
33869       return _addablePresetIDs.map((id2) => {
33870         const preset = _this.item(id2);
33871         if (preset) return RibbonItem(preset, "addable");
33872         return null;
33873       }).filter(Boolean);
33874     };
33875     function setRecents(items) {
33876       _recents = items;
33877       const minifiedItems = items.map((d2) => d2.minified());
33878       corePreferences("preset_recents", JSON.stringify(minifiedItems));
33879       dispatch14.call("recentsChange");
33880     }
33881     _this.getRecents = () => {
33882       if (!_recents) {
33883         _recents = (JSON.parse(corePreferences("preset_recents")) || []).reduce((acc, d2) => {
33884           let item = ribbonItemForMinified(d2, "recent");
33885           if (item && item.preset.addable()) acc.push(item);
33886           return acc;
33887         }, []);
33888       }
33889       return _recents;
33890     };
33891     _this.addRecent = (preset, besidePreset, after) => {
33892       const recents = _this.getRecents();
33893       const beforeItem = _this.recentMatching(besidePreset);
33894       let toIndex = recents.indexOf(beforeItem);
33895       if (after) toIndex += 1;
33896       const newItem = RibbonItem(preset, "recent");
33897       recents.splice(toIndex, 0, newItem);
33898       setRecents(recents);
33899     };
33900     _this.removeRecent = (preset) => {
33901       const item = _this.recentMatching(preset);
33902       if (item) {
33903         let items = _this.getRecents();
33904         items.splice(items.indexOf(item), 1);
33905         setRecents(items);
33906       }
33907     };
33908     _this.recentMatching = (preset) => {
33909       const items = _this.getRecents();
33910       for (let i3 in items) {
33911         if (items[i3].matches(preset)) {
33912           return items[i3];
33913         }
33914       }
33915       return null;
33916     };
33917     _this.moveItem = (items, fromIndex, toIndex) => {
33918       if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length) return null;
33919       items.splice(toIndex, 0, items.splice(fromIndex, 1)[0]);
33920       return items;
33921     };
33922     _this.moveRecent = (item, beforeItem) => {
33923       const recents = _this.getRecents();
33924       const fromIndex = recents.indexOf(item);
33925       const toIndex = recents.indexOf(beforeItem);
33926       const items = _this.moveItem(recents, fromIndex, toIndex);
33927       if (items) setRecents(items);
33928     };
33929     _this.setMostRecent = (preset) => {
33930       if (preset.searchable === false) return;
33931       let items = _this.getRecents();
33932       let item = _this.recentMatching(preset);
33933       if (item) {
33934         items.splice(items.indexOf(item), 1);
33935       } else {
33936         item = RibbonItem(preset, "recent");
33937       }
33938       while (items.length >= MAXRECENTS) {
33939         items.pop();
33940       }
33941       items.unshift(item);
33942       setRecents(items);
33943     };
33944     function setFavorites(items) {
33945       _favorites = items;
33946       const minifiedItems = items.map((d2) => d2.minified());
33947       corePreferences("preset_favorites", JSON.stringify(minifiedItems));
33948       dispatch14.call("favoritePreset");
33949     }
33950     _this.addFavorite = (preset, besidePreset, after) => {
33951       const favorites = _this.getFavorites();
33952       const beforeItem = _this.favoriteMatching(besidePreset);
33953       let toIndex = favorites.indexOf(beforeItem);
33954       if (after) toIndex += 1;
33955       const newItem = RibbonItem(preset, "favorite");
33956       favorites.splice(toIndex, 0, newItem);
33957       setFavorites(favorites);
33958     };
33959     _this.toggleFavorite = (preset) => {
33960       const favs = _this.getFavorites();
33961       const favorite = _this.favoriteMatching(preset);
33962       if (favorite) {
33963         favs.splice(favs.indexOf(favorite), 1);
33964       } else {
33965         if (favs.length === 10) {
33966           favs.pop();
33967         }
33968         favs.push(RibbonItem(preset, "favorite"));
33969       }
33970       setFavorites(favs);
33971     };
33972     _this.removeFavorite = (preset) => {
33973       const item = _this.favoriteMatching(preset);
33974       if (item) {
33975         const items = _this.getFavorites();
33976         items.splice(items.indexOf(item), 1);
33977         setFavorites(items);
33978       }
33979     };
33980     _this.getFavorites = () => {
33981       if (!_favorites) {
33982         let rawFavorites = JSON.parse(corePreferences("preset_favorites"));
33983         if (!rawFavorites) {
33984           rawFavorites = [];
33985           corePreferences("preset_favorites", JSON.stringify(rawFavorites));
33986         }
33987         _favorites = rawFavorites.reduce((output, d2) => {
33988           const item = ribbonItemForMinified(d2, "favorite");
33989           if (item && item.preset.addable()) output.push(item);
33990           return output;
33991         }, []);
33992       }
33993       return _favorites;
33994     };
33995     _this.favoriteMatching = (preset) => {
33996       const favs = _this.getFavorites();
33997       for (let index in favs) {
33998         if (favs[index].matches(preset)) {
33999           return favs[index];
34000         }
34001       }
34002       return null;
34003     };
34004     return utilRebind(_this, dispatch14, "on");
34005   }
34006
34007   // modules/behavior/edit.js
34008   function behaviorEdit(context) {
34009     function behavior() {
34010       context.map().minzoom(context.minEditableZoom());
34011     }
34012     behavior.off = function() {
34013       context.map().minzoom(0);
34014     };
34015     return behavior;
34016   }
34017
34018   // modules/behavior/hover.js
34019   function behaviorHover(context) {
34020     var dispatch14 = dispatch_default("hover");
34021     var _selection = select_default2(null);
34022     var _newNodeId = null;
34023     var _initialNodeID = null;
34024     var _altDisables;
34025     var _ignoreVertex;
34026     var _targets = [];
34027     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
34028     function keydown(d3_event) {
34029       if (_altDisables && d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
34030         _selection.selectAll(".hover").classed("hover-suppressed", true).classed("hover", false);
34031         _selection.classed("hover-disabled", true);
34032         dispatch14.call("hover", this, null);
34033       }
34034     }
34035     function keyup(d3_event) {
34036       if (_altDisables && d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
34037         _selection.selectAll(".hover-suppressed").classed("hover-suppressed", false).classed("hover", true);
34038         _selection.classed("hover-disabled", false);
34039         dispatch14.call("hover", this, _targets);
34040       }
34041     }
34042     function behavior(selection2) {
34043       _selection = selection2;
34044       _targets = [];
34045       if (_initialNodeID) {
34046         _newNodeId = _initialNodeID;
34047         _initialNodeID = null;
34048       } else {
34049         _newNodeId = null;
34050       }
34051       _selection.on(_pointerPrefix + "over.hover", pointerover).on(_pointerPrefix + "out.hover", pointerout).on(_pointerPrefix + "down.hover", pointerover);
34052       select_default2(window).on(_pointerPrefix + "up.hover pointercancel.hover", pointerout, true).on("keydown.hover", keydown).on("keyup.hover", keyup);
34053       function eventTarget(d3_event) {
34054         var datum2 = d3_event.target && d3_event.target.__data__;
34055         if (typeof datum2 !== "object") return null;
34056         if (!(datum2 instanceof osmEntity) && datum2.properties && datum2.properties.entity instanceof osmEntity) {
34057           return datum2.properties.entity;
34058         }
34059         return datum2;
34060       }
34061       function pointerover(d3_event) {
34062         if (context.mode().id.indexOf("drag") === -1 && (!d3_event.pointerType || d3_event.pointerType === "mouse") && d3_event.buttons) return;
34063         var target = eventTarget(d3_event);
34064         if (target && _targets.indexOf(target) === -1) {
34065           _targets.push(target);
34066           updateHover(d3_event, _targets);
34067         }
34068       }
34069       function pointerout(d3_event) {
34070         var target = eventTarget(d3_event);
34071         var index = _targets.indexOf(target);
34072         if (index !== -1) {
34073           _targets.splice(index);
34074           updateHover(d3_event, _targets);
34075         }
34076       }
34077       function allowsVertex(d2) {
34078         return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
34079       }
34080       function modeAllowsHover(target) {
34081         var mode = context.mode();
34082         if (mode.id === "add-point") {
34083           return mode.preset.matchGeometry("vertex") || target.type !== "way" && target.geometry(context.graph()) !== "vertex";
34084         }
34085         return true;
34086       }
34087       function updateHover(d3_event, targets) {
34088         _selection.selectAll(".hover").classed("hover", false);
34089         _selection.selectAll(".hover-suppressed").classed("hover-suppressed", false);
34090         var mode = context.mode();
34091         if (!_newNodeId && (mode.id === "draw-line" || mode.id === "draw-area")) {
34092           var node = targets.find(function(target) {
34093             return target instanceof osmEntity && target.type === "node";
34094           });
34095           _newNodeId = node && node.id;
34096         }
34097         targets = targets.filter(function(datum3) {
34098           if (datum3 instanceof osmEntity) {
34099             return datum3.id !== _newNodeId && (datum3.type !== "node" || !_ignoreVertex || allowsVertex(datum3)) && modeAllowsHover(datum3);
34100           }
34101           return true;
34102         });
34103         var selector = "";
34104         for (var i3 in targets) {
34105           var datum2 = targets[i3];
34106           if (datum2.__featurehash__) {
34107             selector += ", .data" + datum2.__featurehash__;
34108           } else if (datum2 instanceof QAItem) {
34109             selector += ", ." + datum2.service + ".itemId-" + datum2.id;
34110           } else if (datum2 instanceof osmNote) {
34111             selector += ", .note-" + datum2.id;
34112           } else if (datum2 instanceof osmEntity) {
34113             selector += ", ." + datum2.id;
34114             if (datum2.type === "relation") {
34115               for (var j2 in datum2.members) {
34116                 selector += ", ." + datum2.members[j2].id;
34117               }
34118             }
34119           }
34120         }
34121         var suppressed = _altDisables && d3_event && d3_event.altKey;
34122         if (selector.trim().length) {
34123           selector = selector.slice(1);
34124           _selection.selectAll(selector).classed(suppressed ? "hover-suppressed" : "hover", true);
34125         }
34126         dispatch14.call("hover", this, !suppressed && targets);
34127       }
34128     }
34129     behavior.off = function(selection2) {
34130       selection2.selectAll(".hover").classed("hover", false);
34131       selection2.selectAll(".hover-suppressed").classed("hover-suppressed", false);
34132       selection2.classed("hover-disabled", false);
34133       selection2.on(_pointerPrefix + "over.hover", null).on(_pointerPrefix + "out.hover", null).on(_pointerPrefix + "down.hover", null);
34134       select_default2(window).on(_pointerPrefix + "up.hover pointercancel.hover", null, true).on("keydown.hover", null).on("keyup.hover", null);
34135     };
34136     behavior.altDisables = function(val) {
34137       if (!arguments.length) return _altDisables;
34138       _altDisables = val;
34139       return behavior;
34140     };
34141     behavior.ignoreVertex = function(val) {
34142       if (!arguments.length) return _ignoreVertex;
34143       _ignoreVertex = val;
34144       return behavior;
34145     };
34146     behavior.initialNodeID = function(nodeId) {
34147       _initialNodeID = nodeId;
34148       return behavior;
34149     };
34150     return utilRebind(behavior, dispatch14, "on");
34151   }
34152
34153   // modules/behavior/draw.js
34154   var _disableSpace = false;
34155   var _lastSpace = null;
34156   function behaviorDraw(context) {
34157     var dispatch14 = dispatch_default(
34158       "move",
34159       "down",
34160       "downcancel",
34161       "click",
34162       "clickWay",
34163       "clickNode",
34164       "undo",
34165       "cancel",
34166       "finish"
34167     );
34168     var keybinding = utilKeybinding("draw");
34169     var _hover = behaviorHover(context).altDisables(true).ignoreVertex(true).on("hover", context.ui().sidebar.hover);
34170     var _edit = behaviorEdit(context);
34171     var _closeTolerance = 4;
34172     var _tolerance = 12;
34173     var _mouseLeave = false;
34174     var _lastMouse = null;
34175     var _lastPointerUpEvent;
34176     var _downPointer;
34177     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
34178     function datum2(d3_event) {
34179       var mode = context.mode();
34180       var isNote = mode && mode.id.indexOf("note") !== -1;
34181       if (d3_event.altKey || isNote) return {};
34182       var element;
34183       if (d3_event.type === "keydown") {
34184         element = _lastMouse && _lastMouse.target;
34185       } else {
34186         element = d3_event.target;
34187       }
34188       var d2 = element.__data__;
34189       return d2 && d2.properties && d2.properties.target ? d2 : {};
34190     }
34191     function pointerdown(d3_event) {
34192       if (_downPointer) return;
34193       var pointerLocGetter = utilFastMouse(this);
34194       _downPointer = {
34195         id: d3_event.pointerId || "mouse",
34196         pointerLocGetter,
34197         downTime: +/* @__PURE__ */ new Date(),
34198         downLoc: pointerLocGetter(d3_event)
34199       };
34200       dispatch14.call("down", this, d3_event, datum2(d3_event));
34201     }
34202     function pointerup(d3_event) {
34203       if (!_downPointer || _downPointer.id !== (d3_event.pointerId || "mouse")) return;
34204       var downPointer = _downPointer;
34205       _downPointer = null;
34206       _lastPointerUpEvent = d3_event;
34207       if (downPointer.isCancelled) return;
34208       var t2 = +/* @__PURE__ */ new Date();
34209       var p2 = downPointer.pointerLocGetter(d3_event);
34210       var dist = geoVecLength(downPointer.downLoc, p2);
34211       if (dist < _closeTolerance || dist < _tolerance && t2 - downPointer.downTime < 500) {
34212         select_default2(window).on("click.draw-block", function() {
34213           d3_event.stopPropagation();
34214         }, true);
34215         context.map().dblclickZoomEnable(false);
34216         window.setTimeout(function() {
34217           context.map().dblclickZoomEnable(true);
34218           select_default2(window).on("click.draw-block", null);
34219         }, 500);
34220         click(d3_event, p2);
34221       }
34222     }
34223     function pointermove(d3_event) {
34224       if (_downPointer && _downPointer.id === (d3_event.pointerId || "mouse") && !_downPointer.isCancelled) {
34225         var p2 = _downPointer.pointerLocGetter(d3_event);
34226         var dist = geoVecLength(_downPointer.downLoc, p2);
34227         if (dist >= _closeTolerance) {
34228           _downPointer.isCancelled = true;
34229           dispatch14.call("downcancel", this);
34230         }
34231       }
34232       if (d3_event.pointerType && d3_event.pointerType !== "mouse" || d3_event.buttons || _downPointer) return;
34233       if (_lastPointerUpEvent && _lastPointerUpEvent.pointerType !== "mouse" && d3_event.timeStamp - _lastPointerUpEvent.timeStamp < 100) return;
34234       _lastMouse = d3_event;
34235       dispatch14.call("move", this, d3_event, datum2(d3_event));
34236     }
34237     function pointercancel(d3_event) {
34238       if (_downPointer && _downPointer.id === (d3_event.pointerId || "mouse")) {
34239         if (!_downPointer.isCancelled) {
34240           dispatch14.call("downcancel", this);
34241         }
34242         _downPointer = null;
34243       }
34244     }
34245     function mouseenter() {
34246       _mouseLeave = false;
34247     }
34248     function mouseleave() {
34249       _mouseLeave = true;
34250     }
34251     function allowsVertex(d2) {
34252       return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
34253     }
34254     function click(d3_event, loc) {
34255       var d2 = datum2(d3_event);
34256       var target = d2 && d2.properties && d2.properties.entity;
34257       var mode = context.mode();
34258       if (target && target.type === "node" && allowsVertex(target)) {
34259         dispatch14.call("clickNode", this, target, d2);
34260         return;
34261       } else if (target && target.type === "way" && (mode.id !== "add-point" || mode.preset.matchGeometry("vertex"))) {
34262         var choice = geoChooseEdge(
34263           context.graph().childNodes(target),
34264           loc,
34265           context.projection,
34266           context.activeID()
34267         );
34268         if (choice) {
34269           var edge = [target.nodes[choice.index - 1], target.nodes[choice.index]];
34270           dispatch14.call("clickWay", this, choice.loc, edge, d2);
34271           return;
34272         }
34273       } else if (mode.id !== "add-point" || mode.preset.matchGeometry("point")) {
34274         var locLatLng = context.projection.invert(loc);
34275         dispatch14.call("click", this, locLatLng, d2);
34276       }
34277     }
34278     function space(d3_event) {
34279       d3_event.preventDefault();
34280       d3_event.stopPropagation();
34281       var currSpace = context.map().mouse();
34282       if (_disableSpace && _lastSpace) {
34283         var dist = geoVecLength(_lastSpace, currSpace);
34284         if (dist > _tolerance) {
34285           _disableSpace = false;
34286         }
34287       }
34288       if (_disableSpace || _mouseLeave || !_lastMouse) return;
34289       _lastSpace = currSpace;
34290       _disableSpace = true;
34291       select_default2(window).on("keyup.space-block", function() {
34292         d3_event.preventDefault();
34293         d3_event.stopPropagation();
34294         _disableSpace = false;
34295         select_default2(window).on("keyup.space-block", null);
34296       });
34297       var loc = context.map().mouse() || // or the map center if the mouse has never entered the map
34298       context.projection(context.map().center());
34299       click(d3_event, loc);
34300     }
34301     function backspace(d3_event) {
34302       d3_event.preventDefault();
34303       dispatch14.call("undo");
34304     }
34305     function del(d3_event) {
34306       d3_event.preventDefault();
34307       dispatch14.call("cancel");
34308     }
34309     function ret(d3_event) {
34310       d3_event.preventDefault();
34311       dispatch14.call("finish");
34312     }
34313     function behavior(selection2) {
34314       context.install(_hover);
34315       context.install(_edit);
34316       _downPointer = null;
34317       keybinding.on("\u232B", backspace).on("\u2326", del).on("\u238B", ret).on("\u21A9", ret).on("space", space).on("\u2325space", space);
34318       selection2.on("mouseenter.draw", mouseenter).on("mouseleave.draw", mouseleave).on(_pointerPrefix + "down.draw", pointerdown).on(_pointerPrefix + "move.draw", pointermove);
34319       select_default2(window).on(_pointerPrefix + "up.draw", pointerup, true).on("pointercancel.draw", pointercancel, true);
34320       select_default2(document).call(keybinding);
34321       return behavior;
34322     }
34323     behavior.off = function(selection2) {
34324       context.ui().sidebar.hover.cancel();
34325       context.uninstall(_hover);
34326       context.uninstall(_edit);
34327       selection2.on("mouseenter.draw", null).on("mouseleave.draw", null).on(_pointerPrefix + "down.draw", null).on(_pointerPrefix + "move.draw", null);
34328       select_default2(window).on(_pointerPrefix + "up.draw", null).on("pointercancel.draw", null);
34329       select_default2(document).call(keybinding.unbind);
34330     };
34331     behavior.hover = function() {
34332       return _hover;
34333     };
34334     return utilRebind(behavior, dispatch14, "on");
34335   }
34336
34337   // modules/behavior/breathe.js
34338   var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
34339
34340   // node_modules/d3-scale/src/init.js
34341   function initRange(domain, range3) {
34342     switch (arguments.length) {
34343       case 0:
34344         break;
34345       case 1:
34346         this.range(domain);
34347         break;
34348       default:
34349         this.range(range3).domain(domain);
34350         break;
34351     }
34352     return this;
34353   }
34354
34355   // node_modules/d3-scale/src/constant.js
34356   function constants(x2) {
34357     return function() {
34358       return x2;
34359     };
34360   }
34361
34362   // node_modules/d3-scale/src/number.js
34363   function number2(x2) {
34364     return +x2;
34365   }
34366
34367   // node_modules/d3-scale/src/continuous.js
34368   var unit = [0, 1];
34369   function identity3(x2) {
34370     return x2;
34371   }
34372   function normalize(a2, b2) {
34373     return (b2 -= a2 = +a2) ? function(x2) {
34374       return (x2 - a2) / b2;
34375     } : constants(isNaN(b2) ? NaN : 0.5);
34376   }
34377   function clamper(a2, b2) {
34378     var t2;
34379     if (a2 > b2) t2 = a2, a2 = b2, b2 = t2;
34380     return function(x2) {
34381       return Math.max(a2, Math.min(b2, x2));
34382     };
34383   }
34384   function bimap(domain, range3, interpolate) {
34385     var d0 = domain[0], d1 = domain[1], r0 = range3[0], r1 = range3[1];
34386     if (d1 < d0) d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
34387     else d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
34388     return function(x2) {
34389       return r0(d0(x2));
34390     };
34391   }
34392   function polymap(domain, range3, interpolate) {
34393     var j2 = Math.min(domain.length, range3.length) - 1, d2 = new Array(j2), r2 = new Array(j2), i3 = -1;
34394     if (domain[j2] < domain[0]) {
34395       domain = domain.slice().reverse();
34396       range3 = range3.slice().reverse();
34397     }
34398     while (++i3 < j2) {
34399       d2[i3] = normalize(domain[i3], domain[i3 + 1]);
34400       r2[i3] = interpolate(range3[i3], range3[i3 + 1]);
34401     }
34402     return function(x2) {
34403       var i4 = bisect_default(domain, x2, 1, j2) - 1;
34404       return r2[i4](d2[i4](x2));
34405     };
34406   }
34407   function copy(source, target) {
34408     return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown());
34409   }
34410   function transformer2() {
34411     var domain = unit, range3 = unit, interpolate = value_default, transform2, untransform, unknown, clamp3 = identity3, piecewise, output, input;
34412     function rescale() {
34413       var n3 = Math.min(domain.length, range3.length);
34414       if (clamp3 !== identity3) clamp3 = clamper(domain[0], domain[n3 - 1]);
34415       piecewise = n3 > 2 ? polymap : bimap;
34416       output = input = null;
34417       return scale;
34418     }
34419     function scale(x2) {
34420       return x2 == null || isNaN(x2 = +x2) ? unknown : (output || (output = piecewise(domain.map(transform2), range3, interpolate)))(transform2(clamp3(x2)));
34421     }
34422     scale.invert = function(y2) {
34423       return clamp3(untransform((input || (input = piecewise(range3, domain.map(transform2), number_default)))(y2)));
34424     };
34425     scale.domain = function(_2) {
34426       return arguments.length ? (domain = Array.from(_2, number2), rescale()) : domain.slice();
34427     };
34428     scale.range = function(_2) {
34429       return arguments.length ? (range3 = Array.from(_2), rescale()) : range3.slice();
34430     };
34431     scale.rangeRound = function(_2) {
34432       return range3 = Array.from(_2), interpolate = round_default, rescale();
34433     };
34434     scale.clamp = function(_2) {
34435       return arguments.length ? (clamp3 = _2 ? true : identity3, rescale()) : clamp3 !== identity3;
34436     };
34437     scale.interpolate = function(_2) {
34438       return arguments.length ? (interpolate = _2, rescale()) : interpolate;
34439     };
34440     scale.unknown = function(_2) {
34441       return arguments.length ? (unknown = _2, scale) : unknown;
34442     };
34443     return function(t2, u2) {
34444       transform2 = t2, untransform = u2;
34445       return rescale();
34446     };
34447   }
34448   function continuous() {
34449     return transformer2()(identity3, identity3);
34450   }
34451
34452   // node_modules/d3-format/src/formatDecimal.js
34453   function formatDecimal_default(x2) {
34454     return Math.abs(x2 = Math.round(x2)) >= 1e21 ? x2.toLocaleString("en").replace(/,/g, "") : x2.toString(10);
34455   }
34456   function formatDecimalParts(x2, p2) {
34457     if ((i3 = (x2 = p2 ? x2.toExponential(p2 - 1) : x2.toExponential()).indexOf("e")) < 0) return null;
34458     var i3, coefficient = x2.slice(0, i3);
34459     return [
34460       coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
34461       +x2.slice(i3 + 1)
34462     ];
34463   }
34464
34465   // node_modules/d3-format/src/exponent.js
34466   function exponent_default(x2) {
34467     return x2 = formatDecimalParts(Math.abs(x2)), x2 ? x2[1] : NaN;
34468   }
34469
34470   // node_modules/d3-format/src/formatGroup.js
34471   function formatGroup_default(grouping, thousands) {
34472     return function(value, width) {
34473       var i3 = value.length, t2 = [], j2 = 0, g3 = grouping[0], length2 = 0;
34474       while (i3 > 0 && g3 > 0) {
34475         if (length2 + g3 + 1 > width) g3 = Math.max(1, width - length2);
34476         t2.push(value.substring(i3 -= g3, i3 + g3));
34477         if ((length2 += g3 + 1) > width) break;
34478         g3 = grouping[j2 = (j2 + 1) % grouping.length];
34479       }
34480       return t2.reverse().join(thousands);
34481     };
34482   }
34483
34484   // node_modules/d3-format/src/formatNumerals.js
34485   function formatNumerals_default(numerals) {
34486     return function(value) {
34487       return value.replace(/[0-9]/g, function(i3) {
34488         return numerals[+i3];
34489       });
34490     };
34491   }
34492
34493   // node_modules/d3-format/src/formatSpecifier.js
34494   var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
34495   function formatSpecifier(specifier) {
34496     if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier);
34497     var match;
34498     return new FormatSpecifier({
34499       fill: match[1],
34500       align: match[2],
34501       sign: match[3],
34502       symbol: match[4],
34503       zero: match[5],
34504       width: match[6],
34505       comma: match[7],
34506       precision: match[8] && match[8].slice(1),
34507       trim: match[9],
34508       type: match[10]
34509     });
34510   }
34511   formatSpecifier.prototype = FormatSpecifier.prototype;
34512   function FormatSpecifier(specifier) {
34513     this.fill = specifier.fill === void 0 ? " " : specifier.fill + "";
34514     this.align = specifier.align === void 0 ? ">" : specifier.align + "";
34515     this.sign = specifier.sign === void 0 ? "-" : specifier.sign + "";
34516     this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + "";
34517     this.zero = !!specifier.zero;
34518     this.width = specifier.width === void 0 ? void 0 : +specifier.width;
34519     this.comma = !!specifier.comma;
34520     this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision;
34521     this.trim = !!specifier.trim;
34522     this.type = specifier.type === void 0 ? "" : specifier.type + "";
34523   }
34524   FormatSpecifier.prototype.toString = function() {
34525     return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
34526   };
34527
34528   // node_modules/d3-format/src/formatTrim.js
34529   function formatTrim_default(s2) {
34530     out: for (var n3 = s2.length, i3 = 1, i0 = -1, i1; i3 < n3; ++i3) {
34531       switch (s2[i3]) {
34532         case ".":
34533           i0 = i1 = i3;
34534           break;
34535         case "0":
34536           if (i0 === 0) i0 = i3;
34537           i1 = i3;
34538           break;
34539         default:
34540           if (!+s2[i3]) break out;
34541           if (i0 > 0) i0 = 0;
34542           break;
34543       }
34544     }
34545     return i0 > 0 ? s2.slice(0, i0) + s2.slice(i1 + 1) : s2;
34546   }
34547
34548   // node_modules/d3-format/src/formatPrefixAuto.js
34549   var prefixExponent;
34550   function formatPrefixAuto_default(x2, p2) {
34551     var d2 = formatDecimalParts(x2, p2);
34552     if (!d2) return x2 + "";
34553     var coefficient = d2[0], exponent = d2[1], i3 = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, n3 = coefficient.length;
34554     return i3 === n3 ? coefficient : i3 > n3 ? coefficient + new Array(i3 - n3 + 1).join("0") : i3 > 0 ? coefficient.slice(0, i3) + "." + coefficient.slice(i3) : "0." + new Array(1 - i3).join("0") + formatDecimalParts(x2, Math.max(0, p2 + i3 - 1))[0];
34555   }
34556
34557   // node_modules/d3-format/src/formatRounded.js
34558   function formatRounded_default(x2, p2) {
34559     var d2 = formatDecimalParts(x2, p2);
34560     if (!d2) return x2 + "";
34561     var coefficient = d2[0], exponent = d2[1];
34562     return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) : coefficient + new Array(exponent - coefficient.length + 2).join("0");
34563   }
34564
34565   // node_modules/d3-format/src/formatTypes.js
34566   var formatTypes_default = {
34567     "%": (x2, p2) => (x2 * 100).toFixed(p2),
34568     "b": (x2) => Math.round(x2).toString(2),
34569     "c": (x2) => x2 + "",
34570     "d": formatDecimal_default,
34571     "e": (x2, p2) => x2.toExponential(p2),
34572     "f": (x2, p2) => x2.toFixed(p2),
34573     "g": (x2, p2) => x2.toPrecision(p2),
34574     "o": (x2) => Math.round(x2).toString(8),
34575     "p": (x2, p2) => formatRounded_default(x2 * 100, p2),
34576     "r": formatRounded_default,
34577     "s": formatPrefixAuto_default,
34578     "X": (x2) => Math.round(x2).toString(16).toUpperCase(),
34579     "x": (x2) => Math.round(x2).toString(16)
34580   };
34581
34582   // node_modules/d3-format/src/identity.js
34583   function identity_default4(x2) {
34584     return x2;
34585   }
34586
34587   // node_modules/d3-format/src/locale.js
34588   var map = Array.prototype.map;
34589   var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
34590   function locale_default(locale2) {
34591     var group = locale2.grouping === void 0 || locale2.thousands === void 0 ? identity_default4 : formatGroup_default(map.call(locale2.grouping, Number), locale2.thousands + ""), currencyPrefix = locale2.currency === void 0 ? "" : locale2.currency[0] + "", currencySuffix = locale2.currency === void 0 ? "" : locale2.currency[1] + "", decimal = locale2.decimal === void 0 ? "." : locale2.decimal + "", numerals = locale2.numerals === void 0 ? identity_default4 : formatNumerals_default(map.call(locale2.numerals, String)), percent = locale2.percent === void 0 ? "%" : locale2.percent + "", minus = locale2.minus === void 0 ? "\u2212" : locale2.minus + "", nan = locale2.nan === void 0 ? "NaN" : locale2.nan + "";
34592     function newFormat(specifier) {
34593       specifier = formatSpecifier(specifier);
34594       var fill = specifier.fill, align = specifier.align, sign2 = specifier.sign, symbol = specifier.symbol, zero3 = specifier.zero, width = specifier.width, comma = specifier.comma, precision3 = specifier.precision, trim = specifier.trim, type2 = specifier.type;
34595       if (type2 === "n") comma = true, type2 = "g";
34596       else if (!formatTypes_default[type2]) precision3 === void 0 && (precision3 = 12), trim = true, type2 = "g";
34597       if (zero3 || fill === "0" && align === "=") zero3 = true, fill = "0", align = "=";
34598       var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type2) ? "0" + type2.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type2) ? percent : "";
34599       var formatType = formatTypes_default[type2], maybeSuffix = /[defgprs%]/.test(type2);
34600       precision3 = precision3 === void 0 ? 6 : /[gprs]/.test(type2) ? Math.max(1, Math.min(21, precision3)) : Math.max(0, Math.min(20, precision3));
34601       function format2(value) {
34602         var valuePrefix = prefix, valueSuffix = suffix, i3, n3, c2;
34603         if (type2 === "c") {
34604           valueSuffix = formatType(value) + valueSuffix;
34605           value = "";
34606         } else {
34607           value = +value;
34608           var valueNegative = value < 0 || 1 / value < 0;
34609           value = isNaN(value) ? nan : formatType(Math.abs(value), precision3);
34610           if (trim) value = formatTrim_default(value);
34611           if (valueNegative && +value === 0 && sign2 !== "+") valueNegative = false;
34612           valuePrefix = (valueNegative ? sign2 === "(" ? sign2 : minus : sign2 === "-" || sign2 === "(" ? "" : sign2) + valuePrefix;
34613           valueSuffix = (type2 === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign2 === "(" ? ")" : "");
34614           if (maybeSuffix) {
34615             i3 = -1, n3 = value.length;
34616             while (++i3 < n3) {
34617               if (c2 = value.charCodeAt(i3), 48 > c2 || c2 > 57) {
34618                 valueSuffix = (c2 === 46 ? decimal + value.slice(i3 + 1) : value.slice(i3)) + valueSuffix;
34619                 value = value.slice(0, i3);
34620                 break;
34621               }
34622             }
34623           }
34624         }
34625         if (comma && !zero3) value = group(value, Infinity);
34626         var length2 = valuePrefix.length + value.length + valueSuffix.length, padding = length2 < width ? new Array(width - length2 + 1).join(fill) : "";
34627         if (comma && zero3) value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
34628         switch (align) {
34629           case "<":
34630             value = valuePrefix + value + valueSuffix + padding;
34631             break;
34632           case "=":
34633             value = valuePrefix + padding + value + valueSuffix;
34634             break;
34635           case "^":
34636             value = padding.slice(0, length2 = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length2);
34637             break;
34638           default:
34639             value = padding + valuePrefix + value + valueSuffix;
34640             break;
34641         }
34642         return numerals(value);
34643       }
34644       format2.toString = function() {
34645         return specifier + "";
34646       };
34647       return format2;
34648     }
34649     function formatPrefix2(specifier, value) {
34650       var f2 = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)), e3 = Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3, k2 = Math.pow(10, -e3), prefix = prefixes[8 + e3 / 3];
34651       return function(value2) {
34652         return f2(k2 * value2) + prefix;
34653       };
34654     }
34655     return {
34656       format: newFormat,
34657       formatPrefix: formatPrefix2
34658     };
34659   }
34660
34661   // node_modules/d3-format/src/defaultLocale.js
34662   var locale;
34663   var format;
34664   var formatPrefix;
34665   defaultLocale({
34666     thousands: ",",
34667     grouping: [3],
34668     currency: ["$", ""]
34669   });
34670   function defaultLocale(definition) {
34671     locale = locale_default(definition);
34672     format = locale.format;
34673     formatPrefix = locale.formatPrefix;
34674     return locale;
34675   }
34676
34677   // node_modules/d3-format/src/precisionFixed.js
34678   function precisionFixed_default(step) {
34679     return Math.max(0, -exponent_default(Math.abs(step)));
34680   }
34681
34682   // node_modules/d3-format/src/precisionPrefix.js
34683   function precisionPrefix_default(step, value) {
34684     return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3 - exponent_default(Math.abs(step)));
34685   }
34686
34687   // node_modules/d3-format/src/precisionRound.js
34688   function precisionRound_default(step, max3) {
34689     step = Math.abs(step), max3 = Math.abs(max3) - step;
34690     return Math.max(0, exponent_default(max3) - exponent_default(step)) + 1;
34691   }
34692
34693   // node_modules/d3-scale/src/tickFormat.js
34694   function tickFormat(start2, stop, count, specifier) {
34695     var step = tickStep(start2, stop, count), precision3;
34696     specifier = formatSpecifier(specifier == null ? ",f" : specifier);
34697     switch (specifier.type) {
34698       case "s": {
34699         var value = Math.max(Math.abs(start2), Math.abs(stop));
34700         if (specifier.precision == null && !isNaN(precision3 = precisionPrefix_default(step, value))) specifier.precision = precision3;
34701         return formatPrefix(specifier, value);
34702       }
34703       case "":
34704       case "e":
34705       case "g":
34706       case "p":
34707       case "r": {
34708         if (specifier.precision == null && !isNaN(precision3 = precisionRound_default(step, Math.max(Math.abs(start2), Math.abs(stop))))) specifier.precision = precision3 - (specifier.type === "e");
34709         break;
34710       }
34711       case "f":
34712       case "%": {
34713         if (specifier.precision == null && !isNaN(precision3 = precisionFixed_default(step))) specifier.precision = precision3 - (specifier.type === "%") * 2;
34714         break;
34715       }
34716     }
34717     return format(specifier);
34718   }
34719
34720   // node_modules/d3-scale/src/linear.js
34721   function linearish(scale) {
34722     var domain = scale.domain;
34723     scale.ticks = function(count) {
34724       var d2 = domain();
34725       return ticks(d2[0], d2[d2.length - 1], count == null ? 10 : count);
34726     };
34727     scale.tickFormat = function(count, specifier) {
34728       var d2 = domain();
34729       return tickFormat(d2[0], d2[d2.length - 1], count == null ? 10 : count, specifier);
34730     };
34731     scale.nice = function(count) {
34732       if (count == null) count = 10;
34733       var d2 = domain();
34734       var i0 = 0;
34735       var i1 = d2.length - 1;
34736       var start2 = d2[i0];
34737       var stop = d2[i1];
34738       var prestep;
34739       var step;
34740       var maxIter = 10;
34741       if (stop < start2) {
34742         step = start2, start2 = stop, stop = step;
34743         step = i0, i0 = i1, i1 = step;
34744       }
34745       while (maxIter-- > 0) {
34746         step = tickIncrement(start2, stop, count);
34747         if (step === prestep) {
34748           d2[i0] = start2;
34749           d2[i1] = stop;
34750           return domain(d2);
34751         } else if (step > 0) {
34752           start2 = Math.floor(start2 / step) * step;
34753           stop = Math.ceil(stop / step) * step;
34754         } else if (step < 0) {
34755           start2 = Math.ceil(start2 * step) / step;
34756           stop = Math.floor(stop * step) / step;
34757         } else {
34758           break;
34759         }
34760         prestep = step;
34761       }
34762       return scale;
34763     };
34764     return scale;
34765   }
34766   function linear3() {
34767     var scale = continuous();
34768     scale.copy = function() {
34769       return copy(scale, linear3());
34770     };
34771     initRange.apply(scale, arguments);
34772     return linearish(scale);
34773   }
34774
34775   // node_modules/d3-scale/src/quantize.js
34776   function quantize() {
34777     var x05 = 0, x12 = 1, n3 = 1, domain = [0.5], range3 = [0, 1], unknown;
34778     function scale(x2) {
34779       return x2 != null && x2 <= x2 ? range3[bisect_default(domain, x2, 0, n3)] : unknown;
34780     }
34781     function rescale() {
34782       var i3 = -1;
34783       domain = new Array(n3);
34784       while (++i3 < n3) domain[i3] = ((i3 + 1) * x12 - (i3 - n3) * x05) / (n3 + 1);
34785       return scale;
34786     }
34787     scale.domain = function(_2) {
34788       return arguments.length ? ([x05, x12] = _2, x05 = +x05, x12 = +x12, rescale()) : [x05, x12];
34789     };
34790     scale.range = function(_2) {
34791       return arguments.length ? (n3 = (range3 = Array.from(_2)).length - 1, rescale()) : range3.slice();
34792     };
34793     scale.invertExtent = function(y2) {
34794       var i3 = range3.indexOf(y2);
34795       return i3 < 0 ? [NaN, NaN] : i3 < 1 ? [x05, domain[0]] : i3 >= n3 ? [domain[n3 - 1], x12] : [domain[i3 - 1], domain[i3]];
34796     };
34797     scale.unknown = function(_2) {
34798       return arguments.length ? (unknown = _2, scale) : scale;
34799     };
34800     scale.thresholds = function() {
34801       return domain.slice();
34802     };
34803     scale.copy = function() {
34804       return quantize().domain([x05, x12]).range(range3).unknown(unknown);
34805     };
34806     return initRange.apply(linearish(scale), arguments);
34807   }
34808
34809   // modules/behavior/breathe.js
34810   function behaviorBreathe() {
34811     var duration = 800;
34812     var steps = 4;
34813     var selector = ".selected.shadow, .selected .shadow";
34814     var _selected = select_default2(null);
34815     var _classed = "";
34816     var _params = {};
34817     var _done = false;
34818     var _timer;
34819     function ratchetyInterpolator(a2, b2, steps2, units) {
34820       a2 = Number(a2);
34821       b2 = Number(b2);
34822       var sample = quantize().domain([0, 1]).range(quantize_default(number_default(a2, b2), steps2));
34823       return function(t2) {
34824         return String(sample(t2)) + (units || "");
34825       };
34826     }
34827     function reset(selection2) {
34828       selection2.style("stroke-opacity", null).style("stroke-width", null).style("fill-opacity", null).style("r", null);
34829     }
34830     function setAnimationParams(transition2, fromTo) {
34831       var toFrom = fromTo === "from" ? "to" : "from";
34832       transition2.styleTween("stroke-opacity", function(d2) {
34833         return ratchetyInterpolator(
34834           _params[d2.id][toFrom].opacity,
34835           _params[d2.id][fromTo].opacity,
34836           steps
34837         );
34838       }).styleTween("stroke-width", function(d2) {
34839         return ratchetyInterpolator(
34840           _params[d2.id][toFrom].width,
34841           _params[d2.id][fromTo].width,
34842           steps,
34843           "px"
34844         );
34845       }).styleTween("fill-opacity", function(d2) {
34846         return ratchetyInterpolator(
34847           _params[d2.id][toFrom].opacity,
34848           _params[d2.id][fromTo].opacity,
34849           steps
34850         );
34851       }).styleTween("r", function(d2) {
34852         return ratchetyInterpolator(
34853           _params[d2.id][toFrom].width,
34854           _params[d2.id][fromTo].width,
34855           steps,
34856           "px"
34857         );
34858       });
34859     }
34860     function calcAnimationParams(selection2) {
34861       selection2.call(reset).each(function(d2) {
34862         var s2 = select_default2(this);
34863         var tag2 = s2.node().tagName;
34864         var p2 = { "from": {}, "to": {} };
34865         var opacity;
34866         var width;
34867         if (tag2 === "circle") {
34868           opacity = Number(s2.style("fill-opacity") || 0.5);
34869           width = Number(s2.style("r") || 15.5);
34870         } else {
34871           opacity = Number(s2.style("stroke-opacity") || 0.7);
34872           width = Number(s2.style("stroke-width") || 10);
34873         }
34874         p2.tag = tag2;
34875         p2.from.opacity = opacity * 0.6;
34876         p2.to.opacity = opacity * 1.25;
34877         p2.from.width = width * 0.7;
34878         p2.to.width = width * (tag2 === "circle" ? 1.5 : 1);
34879         _params[d2.id] = p2;
34880       });
34881     }
34882     function run(surface, fromTo) {
34883       var toFrom = fromTo === "from" ? "to" : "from";
34884       var currSelected = surface.selectAll(selector);
34885       var currClassed = surface.attr("class");
34886       if (_done || currSelected.empty()) {
34887         _selected.call(reset);
34888         _selected = select_default2(null);
34889         return;
34890       }
34891       if (!(0, import_fast_deep_equal2.default)(currSelected.data(), _selected.data()) || currClassed !== _classed) {
34892         _selected.call(reset);
34893         _classed = currClassed;
34894         _selected = currSelected.call(calcAnimationParams);
34895       }
34896       var didCallNextRun = false;
34897       _selected.transition().duration(duration).call(setAnimationParams, fromTo).on("end", function() {
34898         if (!didCallNextRun) {
34899           surface.call(run, toFrom);
34900           didCallNextRun = true;
34901         }
34902         if (!select_default2(this).classed("selected")) {
34903           reset(select_default2(this));
34904         }
34905       });
34906     }
34907     function behavior(surface) {
34908       _done = false;
34909       _timer = timer(function() {
34910         if (surface.selectAll(selector).empty()) {
34911           return false;
34912         }
34913         surface.call(run, "from");
34914         _timer.stop();
34915         return true;
34916       }, 20);
34917     }
34918     behavior.restartIfNeeded = function(surface) {
34919       if (_selected.empty()) {
34920         surface.call(run, "from");
34921         if (_timer) {
34922           _timer.stop();
34923         }
34924       }
34925     };
34926     behavior.off = function() {
34927       _done = true;
34928       if (_timer) {
34929         _timer.stop();
34930       }
34931       _selected.interrupt().call(reset);
34932     };
34933     return behavior;
34934   }
34935
34936   // modules/behavior/operation.js
34937   function behaviorOperation(context) {
34938     var _operation;
34939     function keypress(d3_event) {
34940       if (!context.map().withinEditableZoom()) return;
34941       if (_operation.availableForKeypress && !_operation.availableForKeypress()) return;
34942       d3_event.preventDefault();
34943       var disabled = _operation.disabled();
34944       if (disabled) {
34945         context.ui().flash.duration(4e3).iconName("#iD-operation-" + _operation.id).iconClass("operation disabled").label(_operation.tooltip())();
34946       } else {
34947         context.ui().flash.duration(2e3).iconName("#iD-operation-" + _operation.id).iconClass("operation").label(_operation.annotation() || _operation.title)();
34948         if (_operation.point) _operation.point(null);
34949         _operation(d3_event);
34950       }
34951     }
34952     function behavior() {
34953       if (_operation && _operation.available()) {
34954         context.keybinding().on(_operation.keys, keypress);
34955       }
34956       return behavior;
34957     }
34958     behavior.off = function() {
34959       context.keybinding().off(_operation.keys);
34960     };
34961     behavior.which = function(_2) {
34962       if (!arguments.length) return _operation;
34963       _operation = _2;
34964       return behavior;
34965     };
34966     return behavior;
34967   }
34968
34969   // modules/operations/circularize.js
34970   function operationCircularize(context, selectedIDs) {
34971     var _extent;
34972     var _actions = selectedIDs.map(getAction).filter(Boolean);
34973     var _amount = _actions.length === 1 ? "single" : "multiple";
34974     var _coords = utilGetAllNodes(selectedIDs, context.graph()).map(function(n3) {
34975       return n3.loc;
34976     });
34977     function getAction(entityID) {
34978       var entity = context.entity(entityID);
34979       if (entity.type !== "way" || new Set(entity.nodes).size <= 1) return null;
34980       if (!_extent) {
34981         _extent = entity.extent(context.graph());
34982       } else {
34983         _extent = _extent.extend(entity.extent(context.graph()));
34984       }
34985       return actionCircularize(entityID, context.projection);
34986     }
34987     var operation2 = function() {
34988       if (!_actions.length) return;
34989       var combinedAction = function(graph, t2) {
34990         _actions.forEach(function(action) {
34991           if (!action.disabled(graph)) {
34992             graph = action(graph, t2);
34993           }
34994         });
34995         return graph;
34996       };
34997       combinedAction.transitionable = true;
34998       context.perform(combinedAction, operation2.annotation());
34999       window.setTimeout(function() {
35000         context.validator().validate();
35001       }, 300);
35002     };
35003     operation2.available = function() {
35004       return _actions.length && selectedIDs.length === _actions.length;
35005     };
35006     operation2.disabled = function() {
35007       if (!_actions.length) return "";
35008       var actionDisableds = _actions.map(function(action) {
35009         return action.disabled(context.graph());
35010       }).filter(Boolean);
35011       if (actionDisableds.length === _actions.length) {
35012         if (new Set(actionDisableds).size > 1) {
35013           return "multiple_blockers";
35014         }
35015         return actionDisableds[0];
35016       } else if (_extent.percentContainedIn(context.map().extent()) < 0.8) {
35017         return "too_large";
35018       } else if (someMissing()) {
35019         return "not_downloaded";
35020       } else if (selectedIDs.some(context.hasHiddenConnections)) {
35021         return "connected_to_hidden";
35022       }
35023       return false;
35024       function someMissing() {
35025         if (context.inIntro()) return false;
35026         var osm = context.connection();
35027         if (osm) {
35028           var missing = _coords.filter(function(loc) {
35029             return !osm.isDataLoaded(loc);
35030           });
35031           if (missing.length) {
35032             missing.forEach(function(loc) {
35033               context.loadTileAtLoc(loc);
35034             });
35035             return true;
35036           }
35037         }
35038         return false;
35039       }
35040     };
35041     operation2.tooltip = function() {
35042       var disable = operation2.disabled();
35043       return disable ? _t.append("operations.circularize." + disable + "." + _amount) : _t.append("operations.circularize.description." + _amount);
35044     };
35045     operation2.annotation = function() {
35046       return _t("operations.circularize.annotation.feature", { n: _actions.length });
35047     };
35048     operation2.id = "circularize";
35049     operation2.keys = [_t("operations.circularize.key")];
35050     operation2.title = _t.append("operations.circularize.title");
35051     operation2.behavior = behaviorOperation(context).which(operation2);
35052     return operation2;
35053   }
35054
35055   // modules/ui/cmd.js
35056   var uiCmd = function(code) {
35057     var detected = utilDetect();
35058     if (detected.os === "mac") {
35059       return code;
35060     }
35061     if (detected.os === "win") {
35062       if (code === "\u2318\u21E7Z") return "Ctrl+Y";
35063     }
35064     var result = "", replacements = {
35065       "\u2318": "Ctrl",
35066       "\u21E7": "Shift",
35067       "\u2325": "Alt",
35068       "\u232B": "Backspace",
35069       "\u2326": "Delete"
35070     };
35071     for (var i3 = 0; i3 < code.length; i3++) {
35072       if (code[i3] in replacements) {
35073         result += replacements[code[i3]] + (i3 < code.length - 1 ? "+" : "");
35074       } else {
35075         result += code[i3];
35076       }
35077     }
35078     return result;
35079   };
35080   uiCmd.display = function(code) {
35081     if (code.length !== 1) return code;
35082     var detected = utilDetect();
35083     var mac = detected.os === "mac";
35084     var replacements = {
35085       "\u2318": mac ? "\u2318 " + _t("shortcuts.key.cmd") : _t("shortcuts.key.ctrl"),
35086       "\u21E7": mac ? "\u21E7 " + _t("shortcuts.key.shift") : _t("shortcuts.key.shift"),
35087       "\u2325": mac ? "\u2325 " + _t("shortcuts.key.option") : _t("shortcuts.key.alt"),
35088       "\u2303": mac ? "\u2303 " + _t("shortcuts.key.ctrl") : _t("shortcuts.key.ctrl"),
35089       "\u232B": mac ? "\u232B " + _t("shortcuts.key.delete") : _t("shortcuts.key.backspace"),
35090       "\u2326": mac ? "\u2326 " + _t("shortcuts.key.del") : _t("shortcuts.key.del"),
35091       "\u2196": mac ? "\u2196 " + _t("shortcuts.key.pgup") : _t("shortcuts.key.pgup"),
35092       "\u2198": mac ? "\u2198 " + _t("shortcuts.key.pgdn") : _t("shortcuts.key.pgdn"),
35093       "\u21DE": mac ? "\u21DE " + _t("shortcuts.key.home") : _t("shortcuts.key.home"),
35094       "\u21DF": mac ? "\u21DF " + _t("shortcuts.key.end") : _t("shortcuts.key.end"),
35095       "\u21B5": mac ? "\u23CE " + _t("shortcuts.key.return") : _t("shortcuts.key.enter"),
35096       "\u238B": mac ? "\u238B " + _t("shortcuts.key.esc") : _t("shortcuts.key.esc"),
35097       "\u2630": mac ? "\u2630 " + _t("shortcuts.key.menu") : _t("shortcuts.key.menu")
35098     };
35099     return replacements[code] || code;
35100   };
35101
35102   // modules/operations/delete.js
35103   function operationDelete(context, selectedIDs) {
35104     var multi = selectedIDs.length === 1 ? "single" : "multiple";
35105     var action = actionDeleteMultiple(selectedIDs);
35106     var nodes = utilGetAllNodes(selectedIDs, context.graph());
35107     var coords = nodes.map(function(n3) {
35108       return n3.loc;
35109     });
35110     var extent = utilTotalExtent(selectedIDs, context.graph());
35111     var operation2 = function() {
35112       var nextSelectedID;
35113       var nextSelectedLoc;
35114       if (selectedIDs.length === 1) {
35115         var id2 = selectedIDs[0];
35116         var entity = context.entity(id2);
35117         var geometry = entity.geometry(context.graph());
35118         var parents = context.graph().parentWays(entity);
35119         var parent = parents[0];
35120         if (geometry === "vertex") {
35121           var nodes2 = parent.nodes;
35122           var i3 = nodes2.indexOf(id2);
35123           if (i3 === 0) {
35124             i3++;
35125           } else if (i3 === nodes2.length - 1) {
35126             i3--;
35127           } else {
35128             var a2 = geoSphericalDistance(entity.loc, context.entity(nodes2[i3 - 1]).loc);
35129             var b2 = geoSphericalDistance(entity.loc, context.entity(nodes2[i3 + 1]).loc);
35130             i3 = a2 < b2 ? i3 - 1 : i3 + 1;
35131           }
35132           nextSelectedID = nodes2[i3];
35133           nextSelectedLoc = context.entity(nextSelectedID).loc;
35134         }
35135       }
35136       context.perform(action, operation2.annotation());
35137       context.validator().validate();
35138       if (nextSelectedID && nextSelectedLoc) {
35139         if (context.hasEntity(nextSelectedID)) {
35140           context.enter(modeSelect(context, [nextSelectedID]).follow(true));
35141         } else {
35142           context.map().centerEase(nextSelectedLoc);
35143           context.enter(modeBrowse(context));
35144         }
35145       } else {
35146         context.enter(modeBrowse(context));
35147       }
35148     };
35149     operation2.available = function() {
35150       return true;
35151     };
35152     operation2.disabled = function() {
35153       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
35154         return "too_large";
35155       } else if (someMissing()) {
35156         return "not_downloaded";
35157       } else if (selectedIDs.some(context.hasHiddenConnections)) {
35158         return "connected_to_hidden";
35159       } else if (selectedIDs.some(protectedMember)) {
35160         return "part_of_relation";
35161       } else if (selectedIDs.some(incompleteRelation)) {
35162         return "incomplete_relation";
35163       } else if (selectedIDs.some(hasWikidataTag)) {
35164         return "has_wikidata_tag";
35165       }
35166       return false;
35167       function someMissing() {
35168         if (context.inIntro()) return false;
35169         var osm = context.connection();
35170         if (osm) {
35171           var missing = coords.filter(function(loc) {
35172             return !osm.isDataLoaded(loc);
35173           });
35174           if (missing.length) {
35175             missing.forEach(function(loc) {
35176               context.loadTileAtLoc(loc);
35177             });
35178             return true;
35179           }
35180         }
35181         return false;
35182       }
35183       function hasWikidataTag(id2) {
35184         var entity = context.entity(id2);
35185         return entity.tags.wikidata && entity.tags.wikidata.trim().length > 0;
35186       }
35187       function incompleteRelation(id2) {
35188         var entity = context.entity(id2);
35189         return entity.type === "relation" && !entity.isComplete(context.graph());
35190       }
35191       function protectedMember(id2) {
35192         var entity = context.entity(id2);
35193         if (entity.type !== "way") return false;
35194         var parents = context.graph().parentRelations(entity);
35195         for (var i3 = 0; i3 < parents.length; i3++) {
35196           var parent = parents[i3];
35197           var type2 = parent.tags.type;
35198           var role = parent.memberById(id2).role || "outer";
35199           if (type2 === "route" || type2 === "boundary" || type2 === "multipolygon" && role === "outer") {
35200             return true;
35201           }
35202         }
35203         return false;
35204       }
35205     };
35206     operation2.tooltip = function() {
35207       var disable = operation2.disabled();
35208       return disable ? _t.append("operations.delete." + disable + "." + multi) : _t.append("operations.delete.description." + multi);
35209     };
35210     operation2.annotation = function() {
35211       return selectedIDs.length === 1 ? _t("operations.delete.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.delete.annotation.feature", { n: selectedIDs.length });
35212     };
35213     operation2.id = "delete";
35214     operation2.keys = [uiCmd("\u2318\u232B"), uiCmd("\u2318\u2326"), uiCmd("\u2326")];
35215     operation2.title = _t.append("operations.delete.title");
35216     operation2.behavior = behaviorOperation(context).which(operation2);
35217     return operation2;
35218   }
35219
35220   // modules/operations/orthogonalize.js
35221   function operationOrthogonalize(context, selectedIDs) {
35222     var _extent;
35223     var _type;
35224     var _actions = selectedIDs.map(chooseAction).filter(Boolean);
35225     var _amount = _actions.length === 1 ? "single" : "multiple";
35226     var _coords = utilGetAllNodes(selectedIDs, context.graph()).map(function(n3) {
35227       return n3.loc;
35228     });
35229     function chooseAction(entityID) {
35230       var entity = context.entity(entityID);
35231       var geometry = entity.geometry(context.graph());
35232       if (!_extent) {
35233         _extent = entity.extent(context.graph());
35234       } else {
35235         _extent = _extent.extend(entity.extent(context.graph()));
35236       }
35237       if (entity.type === "way" && new Set(entity.nodes).size > 2) {
35238         if (_type && _type !== "feature") return null;
35239         _type = "feature";
35240         return actionOrthogonalize(entityID, context.projection);
35241       } else if (geometry === "vertex") {
35242         if (_type && _type !== "corner") return null;
35243         _type = "corner";
35244         var graph = context.graph();
35245         var parents = graph.parentWays(entity);
35246         if (parents.length === 1) {
35247           var way = parents[0];
35248           if (way.nodes.indexOf(entityID) !== -1) {
35249             return actionOrthogonalize(way.id, context.projection, entityID);
35250           }
35251         }
35252       }
35253       return null;
35254     }
35255     var operation2 = function() {
35256       if (!_actions.length) return;
35257       var combinedAction = function(graph, t2) {
35258         _actions.forEach(function(action) {
35259           if (!action.disabled(graph)) {
35260             graph = action(graph, t2);
35261           }
35262         });
35263         return graph;
35264       };
35265       combinedAction.transitionable = true;
35266       context.perform(combinedAction, operation2.annotation());
35267       window.setTimeout(function() {
35268         context.validator().validate();
35269       }, 300);
35270     };
35271     operation2.available = function() {
35272       return _actions.length && selectedIDs.length === _actions.length;
35273     };
35274     operation2.disabled = function() {
35275       if (!_actions.length) return "";
35276       var actionDisableds = _actions.map(function(action) {
35277         return action.disabled(context.graph());
35278       }).filter(Boolean);
35279       if (actionDisableds.length === _actions.length) {
35280         if (new Set(actionDisableds).size > 1) {
35281           return "multiple_blockers";
35282         }
35283         return actionDisableds[0];
35284       } else if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
35285         return "too_large";
35286       } else if (someMissing()) {
35287         return "not_downloaded";
35288       } else if (selectedIDs.some(context.hasHiddenConnections)) {
35289         return "connected_to_hidden";
35290       }
35291       return false;
35292       function someMissing() {
35293         if (context.inIntro()) return false;
35294         var osm = context.connection();
35295         if (osm) {
35296           var missing = _coords.filter(function(loc) {
35297             return !osm.isDataLoaded(loc);
35298           });
35299           if (missing.length) {
35300             missing.forEach(function(loc) {
35301               context.loadTileAtLoc(loc);
35302             });
35303             return true;
35304           }
35305         }
35306         return false;
35307       }
35308     };
35309     operation2.tooltip = function() {
35310       var disable = operation2.disabled();
35311       return disable ? _t.append("operations.orthogonalize." + disable + "." + _amount) : _t.append("operations.orthogonalize.description." + _type + "." + _amount);
35312     };
35313     operation2.annotation = function() {
35314       return _t("operations.orthogonalize.annotation." + _type, { n: _actions.length });
35315     };
35316     operation2.id = "orthogonalize";
35317     operation2.keys = [_t("operations.orthogonalize.key")];
35318     operation2.title = _t.append("operations.orthogonalize.title");
35319     operation2.behavior = behaviorOperation(context).which(operation2);
35320     return operation2;
35321   }
35322
35323   // modules/operations/reflect.js
35324   function operationReflectShort(context, selectedIDs) {
35325     return operationReflect(context, selectedIDs, "short");
35326   }
35327   function operationReflectLong(context, selectedIDs) {
35328     return operationReflect(context, selectedIDs, "long");
35329   }
35330   function operationReflect(context, selectedIDs, axis) {
35331     axis = axis || "long";
35332     var multi = selectedIDs.length === 1 ? "single" : "multiple";
35333     var nodes = utilGetAllNodes(selectedIDs, context.graph());
35334     var coords = nodes.map(function(n3) {
35335       return n3.loc;
35336     });
35337     var extent = utilTotalExtent(selectedIDs, context.graph());
35338     var operation2 = function() {
35339       var action = actionReflect(selectedIDs, context.projection).useLongAxis(Boolean(axis === "long"));
35340       context.perform(action, operation2.annotation());
35341       window.setTimeout(function() {
35342         context.validator().validate();
35343       }, 300);
35344     };
35345     operation2.available = function() {
35346       return nodes.length >= 3;
35347     };
35348     operation2.disabled = function() {
35349       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
35350         return "too_large";
35351       } else if (someMissing()) {
35352         return "not_downloaded";
35353       } else if (selectedIDs.some(context.hasHiddenConnections)) {
35354         return "connected_to_hidden";
35355       } else if (selectedIDs.some(incompleteRelation)) {
35356         return "incomplete_relation";
35357       }
35358       return false;
35359       function someMissing() {
35360         if (context.inIntro()) return false;
35361         var osm = context.connection();
35362         if (osm) {
35363           var missing = coords.filter(function(loc) {
35364             return !osm.isDataLoaded(loc);
35365           });
35366           if (missing.length) {
35367             missing.forEach(function(loc) {
35368               context.loadTileAtLoc(loc);
35369             });
35370             return true;
35371           }
35372         }
35373         return false;
35374       }
35375       function incompleteRelation(id2) {
35376         var entity = context.entity(id2);
35377         return entity.type === "relation" && !entity.isComplete(context.graph());
35378       }
35379     };
35380     operation2.tooltip = function() {
35381       var disable = operation2.disabled();
35382       return disable ? _t.append("operations.reflect." + disable + "." + multi) : _t.append("operations.reflect.description." + axis + "." + multi);
35383     };
35384     operation2.annotation = function() {
35385       return _t("operations.reflect.annotation." + axis + ".feature", { n: selectedIDs.length });
35386     };
35387     operation2.id = "reflect-" + axis;
35388     operation2.keys = [_t("operations.reflect.key." + axis)];
35389     operation2.title = _t.append("operations.reflect.title." + axis);
35390     operation2.behavior = behaviorOperation(context).which(operation2);
35391     return operation2;
35392   }
35393
35394   // modules/operations/move.js
35395   function operationMove(context, selectedIDs) {
35396     var multi = selectedIDs.length === 1 ? "single" : "multiple";
35397     var nodes = utilGetAllNodes(selectedIDs, context.graph());
35398     var coords = nodes.map(function(n3) {
35399       return n3.loc;
35400     });
35401     var extent = utilTotalExtent(selectedIDs, context.graph());
35402     var operation2 = function() {
35403       context.enter(modeMove(context, selectedIDs));
35404     };
35405     operation2.available = function() {
35406       return selectedIDs.length > 0;
35407     };
35408     operation2.disabled = function() {
35409       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
35410         return "too_large";
35411       } else if (someMissing()) {
35412         return "not_downloaded";
35413       } else if (selectedIDs.some(context.hasHiddenConnections)) {
35414         return "connected_to_hidden";
35415       } else if (selectedIDs.some(incompleteRelation)) {
35416         return "incomplete_relation";
35417       }
35418       return false;
35419       function someMissing() {
35420         if (context.inIntro()) return false;
35421         var osm = context.connection();
35422         if (osm) {
35423           var missing = coords.filter(function(loc) {
35424             return !osm.isDataLoaded(loc);
35425           });
35426           if (missing.length) {
35427             missing.forEach(function(loc) {
35428               context.loadTileAtLoc(loc);
35429             });
35430             return true;
35431           }
35432         }
35433         return false;
35434       }
35435       function incompleteRelation(id2) {
35436         var entity = context.entity(id2);
35437         return entity.type === "relation" && !entity.isComplete(context.graph());
35438       }
35439     };
35440     operation2.tooltip = function() {
35441       var disable = operation2.disabled();
35442       return disable ? _t.append("operations.move." + disable + "." + multi) : _t.append("operations.move.description." + multi);
35443     };
35444     operation2.annotation = function() {
35445       return selectedIDs.length === 1 ? _t("operations.move.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.move.annotation.feature", { n: selectedIDs.length });
35446     };
35447     operation2.id = "move";
35448     operation2.keys = [_t("operations.move.key")];
35449     operation2.title = _t.append("operations.move.title");
35450     operation2.behavior = behaviorOperation(context).which(operation2);
35451     operation2.mouseOnly = true;
35452     return operation2;
35453   }
35454
35455   // modules/modes/rotate.js
35456   function modeRotate(context, entityIDs) {
35457     var _tolerancePx = 4;
35458     var mode = {
35459       id: "rotate",
35460       button: "browse"
35461     };
35462     var keybinding = utilKeybinding("rotate");
35463     var behaviors = [
35464       behaviorEdit(context),
35465       operationCircularize(context, entityIDs).behavior,
35466       operationDelete(context, entityIDs).behavior,
35467       operationMove(context, entityIDs).behavior,
35468       operationOrthogonalize(context, entityIDs).behavior,
35469       operationReflectLong(context, entityIDs).behavior,
35470       operationReflectShort(context, entityIDs).behavior
35471     ];
35472     var annotation = entityIDs.length === 1 ? _t("operations.rotate.annotation." + context.graph().geometry(entityIDs[0])) : _t("operations.rotate.annotation.feature", { n: entityIDs.length });
35473     var _prevGraph;
35474     var _prevAngle;
35475     var _prevTransform;
35476     var _pivot;
35477     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
35478     function doRotate(d3_event) {
35479       var fn;
35480       if (context.graph() !== _prevGraph) {
35481         fn = context.perform;
35482       } else {
35483         fn = context.replace;
35484       }
35485       var projection2 = context.projection;
35486       var currTransform = projection2.transform();
35487       if (!_prevTransform || currTransform.k !== _prevTransform.k || currTransform.x !== _prevTransform.x || currTransform.y !== _prevTransform.y) {
35488         var nodes = utilGetAllNodes(entityIDs, context.graph());
35489         var points = nodes.map(function(n3) {
35490           return projection2(n3.loc);
35491         });
35492         _pivot = getPivot(points);
35493         _prevAngle = void 0;
35494       }
35495       var currMouse = context.map().mouse(d3_event);
35496       var currAngle = Math.atan2(currMouse[1] - _pivot[1], currMouse[0] - _pivot[0]);
35497       if (typeof _prevAngle === "undefined") _prevAngle = currAngle;
35498       var delta = currAngle - _prevAngle;
35499       fn(actionRotate(entityIDs, _pivot, delta, projection2));
35500       _prevTransform = currTransform;
35501       _prevAngle = currAngle;
35502       _prevGraph = context.graph();
35503     }
35504     function getPivot(points) {
35505       var _pivot2;
35506       if (points.length === 1) {
35507         _pivot2 = points[0];
35508       } else if (points.length === 2) {
35509         _pivot2 = geoVecInterp(points[0], points[1], 0.5);
35510       } else {
35511         var polygonHull = hull_default(points);
35512         if (polygonHull.length === 2) {
35513           _pivot2 = geoVecInterp(points[0], points[1], 0.5);
35514         } else {
35515           _pivot2 = centroid_default2(hull_default(points));
35516         }
35517       }
35518       return _pivot2;
35519     }
35520     function finish(d3_event) {
35521       d3_event.stopPropagation();
35522       context.replace(actionNoop(), annotation);
35523       context.enter(modeSelect(context, entityIDs));
35524     }
35525     function cancel() {
35526       if (_prevGraph) context.pop();
35527       context.enter(modeSelect(context, entityIDs));
35528     }
35529     function undone() {
35530       context.enter(modeBrowse(context));
35531     }
35532     mode.enter = function() {
35533       _prevGraph = null;
35534       context.features().forceVisible(entityIDs);
35535       behaviors.forEach(context.install);
35536       var downEvent;
35537       context.surface().on(_pointerPrefix + "down.modeRotate", function(d3_event) {
35538         downEvent = d3_event;
35539       });
35540       select_default2(window).on(_pointerPrefix + "move.modeRotate", doRotate, true).on(_pointerPrefix + "up.modeRotate", function(d3_event) {
35541         if (!downEvent) return;
35542         var mapNode = context.container().select(".main-map").node();
35543         var pointGetter = utilFastMouse(mapNode);
35544         var p1 = pointGetter(downEvent);
35545         var p2 = pointGetter(d3_event);
35546         var dist = geoVecLength(p1, p2);
35547         if (dist <= _tolerancePx) finish(d3_event);
35548         downEvent = null;
35549       }, true);
35550       context.history().on("undone.modeRotate", undone);
35551       keybinding.on("\u238B", cancel).on("\u21A9", finish);
35552       select_default2(document).call(keybinding);
35553     };
35554     mode.exit = function() {
35555       behaviors.forEach(context.uninstall);
35556       context.surface().on(_pointerPrefix + "down.modeRotate", null);
35557       select_default2(window).on(_pointerPrefix + "move.modeRotate", null, true).on(_pointerPrefix + "up.modeRotate", null, true);
35558       context.history().on("undone.modeRotate", null);
35559       select_default2(document).call(keybinding.unbind);
35560       context.features().forceVisible([]);
35561     };
35562     mode.selectedIDs = function() {
35563       if (!arguments.length) return entityIDs;
35564       return mode;
35565     };
35566     return mode;
35567   }
35568
35569   // modules/operations/rotate.js
35570   function operationRotate(context, selectedIDs) {
35571     var multi = selectedIDs.length === 1 ? "single" : "multiple";
35572     var nodes = utilGetAllNodes(selectedIDs, context.graph());
35573     var coords = nodes.map(function(n3) {
35574       return n3.loc;
35575     });
35576     var extent = utilTotalExtent(selectedIDs, context.graph());
35577     var operation2 = function() {
35578       context.enter(modeRotate(context, selectedIDs));
35579     };
35580     operation2.available = function() {
35581       return nodes.length >= 2;
35582     };
35583     operation2.disabled = function() {
35584       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
35585         return "too_large";
35586       } else if (someMissing()) {
35587         return "not_downloaded";
35588       } else if (selectedIDs.some(context.hasHiddenConnections)) {
35589         return "connected_to_hidden";
35590       } else if (selectedIDs.some(incompleteRelation)) {
35591         return "incomplete_relation";
35592       }
35593       return false;
35594       function someMissing() {
35595         if (context.inIntro()) return false;
35596         var osm = context.connection();
35597         if (osm) {
35598           var missing = coords.filter(function(loc) {
35599             return !osm.isDataLoaded(loc);
35600           });
35601           if (missing.length) {
35602             missing.forEach(function(loc) {
35603               context.loadTileAtLoc(loc);
35604             });
35605             return true;
35606           }
35607         }
35608         return false;
35609       }
35610       function incompleteRelation(id2) {
35611         var entity = context.entity(id2);
35612         return entity.type === "relation" && !entity.isComplete(context.graph());
35613       }
35614     };
35615     operation2.tooltip = function() {
35616       var disable = operation2.disabled();
35617       return disable ? _t.append("operations.rotate." + disable + "." + multi) : _t.append("operations.rotate.description." + multi);
35618     };
35619     operation2.annotation = function() {
35620       return selectedIDs.length === 1 ? _t("operations.rotate.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.rotate.annotation.feature", { n: selectedIDs.length });
35621     };
35622     operation2.id = "rotate";
35623     operation2.keys = [_t("operations.rotate.key")];
35624     operation2.title = _t.append("operations.rotate.title");
35625     operation2.behavior = behaviorOperation(context).which(operation2);
35626     operation2.mouseOnly = true;
35627     return operation2;
35628   }
35629
35630   // modules/modes/move.js
35631   function modeMove(context, entityIDs, baseGraph) {
35632     var _tolerancePx = 4;
35633     var mode = {
35634       id: "move",
35635       button: "browse"
35636     };
35637     var keybinding = utilKeybinding("move");
35638     var behaviors = [
35639       behaviorEdit(context),
35640       operationCircularize(context, entityIDs).behavior,
35641       operationDelete(context, entityIDs).behavior,
35642       operationOrthogonalize(context, entityIDs).behavior,
35643       operationReflectLong(context, entityIDs).behavior,
35644       operationReflectShort(context, entityIDs).behavior,
35645       operationRotate(context, entityIDs).behavior
35646     ];
35647     var annotation = entityIDs.length === 1 ? _t("operations.move.annotation." + context.graph().geometry(entityIDs[0])) : _t("operations.move.annotation.feature", { n: entityIDs.length });
35648     var _prevGraph;
35649     var _cache5;
35650     var _origin;
35651     var _nudgeInterval;
35652     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
35653     function doMove(nudge) {
35654       nudge = nudge || [0, 0];
35655       var fn;
35656       if (_prevGraph !== context.graph()) {
35657         _cache5 = {};
35658         _origin = context.map().mouseCoordinates();
35659         fn = context.perform;
35660       } else {
35661         fn = context.overwrite;
35662       }
35663       var currMouse = context.map().mouse();
35664       var origMouse = context.projection(_origin);
35665       var delta = geoVecSubtract(geoVecSubtract(currMouse, origMouse), nudge);
35666       fn(actionMove(entityIDs, delta, context.projection, _cache5));
35667       _prevGraph = context.graph();
35668     }
35669     function startNudge(nudge) {
35670       if (_nudgeInterval) window.clearInterval(_nudgeInterval);
35671       _nudgeInterval = window.setInterval(function() {
35672         context.map().pan(nudge);
35673         doMove(nudge);
35674       }, 50);
35675     }
35676     function stopNudge() {
35677       if (_nudgeInterval) {
35678         window.clearInterval(_nudgeInterval);
35679         _nudgeInterval = null;
35680       }
35681     }
35682     function move() {
35683       doMove();
35684       var nudge = geoViewportEdge(context.map().mouse(), context.map().dimensions());
35685       if (nudge) {
35686         startNudge(nudge);
35687       } else {
35688         stopNudge();
35689       }
35690     }
35691     function finish(d3_event) {
35692       d3_event.stopPropagation();
35693       context.replace(actionNoop(), annotation);
35694       context.enter(modeSelect(context, entityIDs));
35695       stopNudge();
35696     }
35697     function cancel() {
35698       if (baseGraph) {
35699         while (context.graph() !== baseGraph) context.pop();
35700         context.enter(modeBrowse(context));
35701       } else {
35702         if (_prevGraph) context.pop();
35703         context.enter(modeSelect(context, entityIDs));
35704       }
35705       stopNudge();
35706     }
35707     function undone() {
35708       context.enter(modeBrowse(context));
35709     }
35710     mode.enter = function() {
35711       _origin = context.map().mouseCoordinates();
35712       _prevGraph = null;
35713       _cache5 = {};
35714       context.features().forceVisible(entityIDs);
35715       behaviors.forEach(context.install);
35716       var downEvent;
35717       context.surface().on(_pointerPrefix + "down.modeMove", function(d3_event) {
35718         downEvent = d3_event;
35719       });
35720       select_default2(window).on(_pointerPrefix + "move.modeMove", move, true).on(_pointerPrefix + "up.modeMove", function(d3_event) {
35721         if (!downEvent) return;
35722         var mapNode = context.container().select(".main-map").node();
35723         var pointGetter = utilFastMouse(mapNode);
35724         var p1 = pointGetter(downEvent);
35725         var p2 = pointGetter(d3_event);
35726         var dist = geoVecLength(p1, p2);
35727         if (dist <= _tolerancePx) finish(d3_event);
35728         downEvent = null;
35729       }, true);
35730       context.history().on("undone.modeMove", undone);
35731       keybinding.on("\u238B", cancel).on("\u21A9", finish);
35732       select_default2(document).call(keybinding);
35733     };
35734     mode.exit = function() {
35735       stopNudge();
35736       behaviors.forEach(function(behavior) {
35737         context.uninstall(behavior);
35738       });
35739       context.surface().on(_pointerPrefix + "down.modeMove", null);
35740       select_default2(window).on(_pointerPrefix + "move.modeMove", null, true).on(_pointerPrefix + "up.modeMove", null, true);
35741       context.history().on("undone.modeMove", null);
35742       select_default2(document).call(keybinding.unbind);
35743       context.features().forceVisible([]);
35744     };
35745     mode.selectedIDs = function() {
35746       if (!arguments.length) return entityIDs;
35747       return mode;
35748     };
35749     return mode;
35750   }
35751
35752   // modules/behavior/paste.js
35753   function behaviorPaste(context) {
35754     function doPaste(d3_event) {
35755       if (!context.map().withinEditableZoom()) return;
35756       const isOsmLayerEnabled = context.layers().layer("osm").enabled();
35757       if (!isOsmLayerEnabled) return;
35758       d3_event.preventDefault();
35759       var baseGraph = context.graph();
35760       var mouse = context.map().mouse();
35761       var projection2 = context.projection;
35762       var viewport = geoExtent(projection2.clipExtent()).polygon();
35763       if (!geoPointInPolygon(mouse, viewport)) return;
35764       var oldIDs = context.copyIDs();
35765       if (!oldIDs.length) return;
35766       var extent = geoExtent();
35767       var oldGraph = context.copyGraph();
35768       var newIDs = [];
35769       var action = actionCopyEntities(oldIDs, oldGraph);
35770       context.perform(action);
35771       var copies = action.copies();
35772       var originals = /* @__PURE__ */ new Set();
35773       Object.values(copies).forEach(function(entity) {
35774         originals.add(entity.id);
35775       });
35776       for (var id2 in copies) {
35777         var oldEntity = oldGraph.entity(id2);
35778         var newEntity = copies[id2];
35779         extent._extend(oldEntity.extent(oldGraph));
35780         var parents = context.graph().parentWays(newEntity);
35781         var parentCopied = parents.some(function(parent) {
35782           return originals.has(parent.id);
35783         });
35784         if (!parentCopied) {
35785           newIDs.push(newEntity.id);
35786         }
35787       }
35788       var copyPoint = context.copyLonLat() && projection2(context.copyLonLat()) || projection2(extent.center());
35789       var delta = geoVecSubtract(mouse, copyPoint);
35790       context.perform(actionMove(newIDs, delta, projection2));
35791       context.enter(modeMove(context, newIDs, baseGraph));
35792     }
35793     function behavior() {
35794       context.keybinding().on(uiCmd("\u2318V"), doPaste);
35795       return behavior;
35796     }
35797     behavior.off = function() {
35798       context.keybinding().off(uiCmd("\u2318V"));
35799     };
35800     return behavior;
35801   }
35802
35803   // modules/behavior/drag.js
35804   function behaviorDrag() {
35805     var dispatch14 = dispatch_default("start", "move", "end");
35806     var _tolerancePx = 1;
35807     var _penTolerancePx = 4;
35808     var _origin = null;
35809     var _selector = "";
35810     var _targetNode;
35811     var _targetEntity;
35812     var _surface;
35813     var _pointerId;
35814     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
35815     var d3_event_userSelectProperty = utilPrefixCSSProperty("UserSelect");
35816     var d3_event_userSelectSuppress = function() {
35817       var selection2 = selection_default();
35818       var select = selection2.style(d3_event_userSelectProperty);
35819       selection2.style(d3_event_userSelectProperty, "none");
35820       return function() {
35821         selection2.style(d3_event_userSelectProperty, select);
35822       };
35823     };
35824     function pointerdown(d3_event) {
35825       if (_pointerId) return;
35826       _pointerId = d3_event.pointerId || "mouse";
35827       _targetNode = this;
35828       var pointerLocGetter = utilFastMouse(_surface || _targetNode.parentNode);
35829       var offset;
35830       var startOrigin = pointerLocGetter(d3_event);
35831       var started = false;
35832       var selectEnable = d3_event_userSelectSuppress();
35833       select_default2(window).on(_pointerPrefix + "move.drag", pointermove).on(_pointerPrefix + "up.drag pointercancel.drag", pointerup, true);
35834       if (_origin) {
35835         offset = _origin.call(_targetNode, _targetEntity);
35836         offset = [offset[0] - startOrigin[0], offset[1] - startOrigin[1]];
35837       } else {
35838         offset = [0, 0];
35839       }
35840       d3_event.stopPropagation();
35841       function pointermove(d3_event2) {
35842         if (_pointerId !== (d3_event2.pointerId || "mouse")) return;
35843         var p2 = pointerLocGetter(d3_event2);
35844         if (!started) {
35845           var dist = geoVecLength(startOrigin, p2);
35846           var tolerance = d3_event2.pointerType === "pen" ? _penTolerancePx : _tolerancePx;
35847           if (dist < tolerance) return;
35848           started = true;
35849           dispatch14.call("start", this, d3_event2, _targetEntity);
35850         } else {
35851           startOrigin = p2;
35852           d3_event2.stopPropagation();
35853           d3_event2.preventDefault();
35854           var dx = p2[0] - startOrigin[0];
35855           var dy = p2[1] - startOrigin[1];
35856           dispatch14.call("move", this, d3_event2, _targetEntity, [p2[0] + offset[0], p2[1] + offset[1]], [dx, dy]);
35857         }
35858       }
35859       function pointerup(d3_event2) {
35860         if (_pointerId !== (d3_event2.pointerId || "mouse")) return;
35861         _pointerId = null;
35862         if (started) {
35863           dispatch14.call("end", this, d3_event2, _targetEntity);
35864           d3_event2.preventDefault();
35865         }
35866         select_default2(window).on(_pointerPrefix + "move.drag", null).on(_pointerPrefix + "up.drag pointercancel.drag", null);
35867         selectEnable();
35868       }
35869     }
35870     function behavior(selection2) {
35871       var matchesSelector = utilPrefixDOMProperty("matchesSelector");
35872       var delegate = pointerdown;
35873       if (_selector) {
35874         delegate = function(d3_event) {
35875           var root3 = this;
35876           var target = d3_event.target;
35877           for (; target && target !== root3; target = target.parentNode) {
35878             var datum2 = target.__data__;
35879             _targetEntity = datum2 instanceof osmNote ? datum2 : datum2 && datum2.properties && datum2.properties.entity;
35880             if (_targetEntity && target[matchesSelector](_selector)) {
35881               return pointerdown.call(target, d3_event);
35882             }
35883           }
35884         };
35885       }
35886       selection2.on(_pointerPrefix + "down.drag" + _selector, delegate);
35887     }
35888     behavior.off = function(selection2) {
35889       selection2.on(_pointerPrefix + "down.drag" + _selector, null);
35890     };
35891     behavior.selector = function(_2) {
35892       if (!arguments.length) return _selector;
35893       _selector = _2;
35894       return behavior;
35895     };
35896     behavior.origin = function(_2) {
35897       if (!arguments.length) return _origin;
35898       _origin = _2;
35899       return behavior;
35900     };
35901     behavior.cancel = function() {
35902       select_default2(window).on(_pointerPrefix + "move.drag", null).on(_pointerPrefix + "up.drag pointercancel.drag", null);
35903       return behavior;
35904     };
35905     behavior.targetNode = function(_2) {
35906       if (!arguments.length) return _targetNode;
35907       _targetNode = _2;
35908       return behavior;
35909     };
35910     behavior.targetEntity = function(_2) {
35911       if (!arguments.length) return _targetEntity;
35912       _targetEntity = _2;
35913       return behavior;
35914     };
35915     behavior.surface = function(_2) {
35916       if (!arguments.length) return _surface;
35917       _surface = _2;
35918       return behavior;
35919     };
35920     return utilRebind(behavior, dispatch14, "on");
35921   }
35922
35923   // modules/modes/drag_node.js
35924   function modeDragNode(context) {
35925     var mode = {
35926       id: "drag-node",
35927       button: "browse"
35928     };
35929     var hover = behaviorHover(context).altDisables(true).on("hover", context.ui().sidebar.hover);
35930     var edit2 = behaviorEdit(context);
35931     var _nudgeInterval;
35932     var _restoreSelectedIDs = [];
35933     var _wasMidpoint = false;
35934     var _isCancelled = false;
35935     var _activeEntity;
35936     var _startLoc;
35937     var _lastLoc;
35938     function startNudge(d3_event, entity, nudge) {
35939       if (_nudgeInterval) window.clearInterval(_nudgeInterval);
35940       _nudgeInterval = window.setInterval(function() {
35941         context.map().pan(nudge);
35942         doMove(d3_event, entity, nudge);
35943       }, 50);
35944     }
35945     function stopNudge() {
35946       if (_nudgeInterval) {
35947         window.clearInterval(_nudgeInterval);
35948         _nudgeInterval = null;
35949       }
35950     }
35951     function moveAnnotation(entity) {
35952       return _t("operations.move.annotation." + entity.geometry(context.graph()));
35953     }
35954     function connectAnnotation(nodeEntity, targetEntity) {
35955       var nodeGeometry = nodeEntity.geometry(context.graph());
35956       var targetGeometry = targetEntity.geometry(context.graph());
35957       if (nodeGeometry === "vertex" && targetGeometry === "vertex") {
35958         var nodeParentWayIDs = context.graph().parentWays(nodeEntity);
35959         var targetParentWayIDs = context.graph().parentWays(targetEntity);
35960         var sharedParentWays = utilArrayIntersection(nodeParentWayIDs, targetParentWayIDs);
35961         if (sharedParentWays.length !== 0) {
35962           if (sharedParentWays[0].areAdjacent(nodeEntity.id, targetEntity.id)) {
35963             return _t("operations.connect.annotation.from_vertex.to_adjacent_vertex");
35964           }
35965           return _t("operations.connect.annotation.from_vertex.to_sibling_vertex");
35966         }
35967       }
35968       return _t("operations.connect.annotation.from_" + nodeGeometry + ".to_" + targetGeometry);
35969     }
35970     function shouldSnapToNode(target) {
35971       if (!_activeEntity) return false;
35972       return _activeEntity.geometry(context.graph()) !== "vertex" || (target.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(target, context.graph()));
35973     }
35974     function origin(entity) {
35975       return context.projection(entity.loc);
35976     }
35977     function keydown(d3_event) {
35978       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
35979         if (context.surface().classed("nope")) {
35980           context.surface().classed("nope-suppressed", true);
35981         }
35982         context.surface().classed("nope", false).classed("nope-disabled", true);
35983       }
35984     }
35985     function keyup(d3_event) {
35986       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
35987         if (context.surface().classed("nope-suppressed")) {
35988           context.surface().classed("nope", true);
35989         }
35990         context.surface().classed("nope-suppressed", false).classed("nope-disabled", false);
35991       }
35992     }
35993     function start2(d3_event, entity) {
35994       _wasMidpoint = entity.type === "midpoint";
35995       var hasHidden = context.features().hasHiddenConnections(entity, context.graph());
35996       _isCancelled = !context.editable() || d3_event.shiftKey || hasHidden;
35997       if (_isCancelled) {
35998         if (hasHidden) {
35999           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("modes.drag_node.connected_to_hidden"))();
36000         }
36001         return drag.cancel();
36002       }
36003       if (_wasMidpoint) {
36004         var midpoint = entity;
36005         entity = osmNode();
36006         context.perform(actionAddMidpoint(midpoint, entity));
36007         entity = context.entity(entity.id);
36008         var vertex = context.surface().selectAll("." + entity.id);
36009         drag.targetNode(vertex.node()).targetEntity(entity);
36010       } else {
36011         context.perform(actionNoop());
36012       }
36013       _activeEntity = entity;
36014       _startLoc = entity.loc;
36015       hover.ignoreVertex(entity.geometry(context.graph()) === "vertex");
36016       context.surface().selectAll("." + _activeEntity.id).classed("active", true);
36017       context.enter(mode);
36018     }
36019     function datum2(d3_event) {
36020       if (!d3_event || d3_event.altKey) {
36021         return {};
36022       } else {
36023         var d2 = d3_event.target.__data__;
36024         return d2 && d2.properties && d2.properties.target ? d2 : {};
36025       }
36026     }
36027     function doMove(d3_event, entity, nudge) {
36028       nudge = nudge || [0, 0];
36029       var currPoint = d3_event && d3_event.point || context.projection(_lastLoc);
36030       var currMouse = geoVecSubtract(currPoint, nudge);
36031       var loc = context.projection.invert(currMouse);
36032       var target, edge;
36033       if (!_nudgeInterval) {
36034         var d2 = datum2(d3_event);
36035         target = d2 && d2.properties && d2.properties.entity;
36036         var targetLoc = target && target.loc;
36037         var targetNodes = d2 && d2.properties && d2.properties.nodes;
36038         if (targetLoc) {
36039           if (shouldSnapToNode(target)) {
36040             loc = targetLoc;
36041           }
36042         } else if (targetNodes) {
36043           edge = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, end.id);
36044           if (edge) {
36045             loc = edge.loc;
36046           }
36047         }
36048       }
36049       context.replace(
36050         actionMoveNode(entity.id, loc)
36051       );
36052       var isInvalid = false;
36053       if (target) {
36054         isInvalid = hasRelationConflict(entity, target, edge, context.graph());
36055       }
36056       if (!isInvalid) {
36057         isInvalid = hasInvalidGeometry(entity, context.graph());
36058       }
36059       var nope = context.surface().classed("nope");
36060       if (isInvalid === "relation" || isInvalid === "restriction") {
36061         if (!nope) {
36062           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append(
36063             "operations.connect." + isInvalid,
36064             { relation: _mainPresetIndex.item("type/restriction").name() }
36065           ))();
36066         }
36067       } else if (isInvalid) {
36068         var errorID = isInvalid === "line" ? "lines" : "areas";
36069         context.ui().flash.duration(3e3).iconName("#iD-icon-no").label(_t.append("self_intersection.error." + errorID))();
36070       } else {
36071         if (nope) {
36072           context.ui().flash.duration(1).label("")();
36073         }
36074       }
36075       var nopeDisabled = context.surface().classed("nope-disabled");
36076       if (nopeDisabled) {
36077         context.surface().classed("nope", false).classed("nope-suppressed", isInvalid);
36078       } else {
36079         context.surface().classed("nope", isInvalid).classed("nope-suppressed", false);
36080       }
36081       _lastLoc = loc;
36082     }
36083     function hasRelationConflict(entity, target, edge, graph) {
36084       var testGraph = graph.update();
36085       if (edge) {
36086         var midpoint = osmNode();
36087         var action = actionAddMidpoint({
36088           loc: edge.loc,
36089           edge: [target.nodes[edge.index - 1], target.nodes[edge.index]]
36090         }, midpoint);
36091         testGraph = action(testGraph);
36092         target = midpoint;
36093       }
36094       var ids = [entity.id, target.id];
36095       return actionConnect(ids).disabled(testGraph);
36096     }
36097     function hasInvalidGeometry(entity, graph) {
36098       var parents = graph.parentWays(entity);
36099       var i3, j2, k2;
36100       for (i3 = 0; i3 < parents.length; i3++) {
36101         var parent = parents[i3];
36102         var nodes = [];
36103         var activeIndex = null;
36104         var relations = graph.parentRelations(parent);
36105         for (j2 = 0; j2 < relations.length; j2++) {
36106           if (!relations[j2].isMultipolygon()) continue;
36107           var rings = osmJoinWays(relations[j2].members, graph);
36108           for (k2 = 0; k2 < rings.length; k2++) {
36109             nodes = rings[k2].nodes;
36110             if (nodes.find(function(n3) {
36111               return n3.id === entity.id;
36112             })) {
36113               activeIndex = k2;
36114               if (geoHasSelfIntersections(nodes, entity.id)) {
36115                 return "multipolygonMember";
36116               }
36117             }
36118             rings[k2].coords = nodes.map(function(n3) {
36119               return n3.loc;
36120             });
36121           }
36122           for (k2 = 0; k2 < rings.length; k2++) {
36123             if (k2 === activeIndex) continue;
36124             if (geoHasLineIntersections(rings[activeIndex].nodes, rings[k2].nodes, entity.id)) {
36125               return "multipolygonRing";
36126             }
36127           }
36128         }
36129         if (activeIndex === null) {
36130           nodes = parent.nodes.map(function(nodeID) {
36131             return graph.entity(nodeID);
36132           });
36133           if (nodes.length && geoHasSelfIntersections(nodes, entity.id)) {
36134             return parent.geometry(graph);
36135           }
36136         }
36137       }
36138       return false;
36139     }
36140     function move(d3_event, entity, point) {
36141       if (_isCancelled) return;
36142       d3_event.stopPropagation();
36143       context.surface().classed("nope-disabled", d3_event.altKey);
36144       _lastLoc = context.projection.invert(point);
36145       doMove(d3_event, entity);
36146       var nudge = geoViewportEdge(point, context.map().dimensions());
36147       if (nudge) {
36148         startNudge(d3_event, entity, nudge);
36149       } else {
36150         stopNudge();
36151       }
36152     }
36153     function end(d3_event, entity) {
36154       if (_isCancelled) return;
36155       var wasPoint = entity.geometry(context.graph()) === "point";
36156       var d2 = datum2(d3_event);
36157       var nope = d2 && d2.properties && d2.properties.nope || context.surface().classed("nope");
36158       var target = d2 && d2.properties && d2.properties.entity;
36159       if (nope) {
36160         context.perform(
36161           _actionBounceBack(entity.id, _startLoc)
36162         );
36163       } else if (target && target.type === "way") {
36164         var choice = geoChooseEdge(context.graph().childNodes(target), context.map().mouse(), context.projection, entity.id);
36165         context.replace(
36166           actionAddMidpoint({
36167             loc: choice.loc,
36168             edge: [target.nodes[choice.index - 1], target.nodes[choice.index]]
36169           }, entity),
36170           connectAnnotation(entity, target)
36171         );
36172       } else if (target && target.type === "node" && shouldSnapToNode(target)) {
36173         context.replace(
36174           actionConnect([target.id, entity.id]),
36175           connectAnnotation(entity, target)
36176         );
36177       } else if (_wasMidpoint) {
36178         context.replace(
36179           actionNoop(),
36180           _t("operations.add.annotation.vertex")
36181         );
36182       } else {
36183         context.replace(
36184           actionNoop(),
36185           moveAnnotation(entity)
36186         );
36187       }
36188       if (wasPoint) {
36189         context.enter(modeSelect(context, [entity.id]));
36190       } else {
36191         var reselection = _restoreSelectedIDs.filter(function(id2) {
36192           return context.graph().hasEntity(id2);
36193         });
36194         if (reselection.length) {
36195           context.enter(modeSelect(context, reselection));
36196         } else {
36197           context.enter(modeBrowse(context));
36198         }
36199       }
36200     }
36201     function _actionBounceBack(nodeID, toLoc) {
36202       var moveNode = actionMoveNode(nodeID, toLoc);
36203       var action = function(graph, t2) {
36204         if (t2 === 1) context.pop();
36205         return moveNode(graph, t2);
36206       };
36207       action.transitionable = true;
36208       return action;
36209     }
36210     function cancel() {
36211       drag.cancel();
36212       context.enter(modeBrowse(context));
36213     }
36214     var drag = behaviorDrag().selector(".layer-touch.points .target").surface(context.container().select(".main-map").node()).origin(origin).on("start", start2).on("move", move).on("end", end);
36215     mode.enter = function() {
36216       context.install(hover);
36217       context.install(edit2);
36218       select_default2(window).on("keydown.dragNode", keydown).on("keyup.dragNode", keyup);
36219       context.history().on("undone.drag-node", cancel);
36220     };
36221     mode.exit = function() {
36222       context.ui().sidebar.hover.cancel();
36223       context.uninstall(hover);
36224       context.uninstall(edit2);
36225       select_default2(window).on("keydown.dragNode", null).on("keyup.dragNode", null);
36226       context.history().on("undone.drag-node", null);
36227       _activeEntity = null;
36228       context.surface().classed("nope", false).classed("nope-suppressed", false).classed("nope-disabled", false).selectAll(".active").classed("active", false);
36229       stopNudge();
36230     };
36231     mode.selectedIDs = function() {
36232       if (!arguments.length) return _activeEntity ? [_activeEntity.id] : [];
36233       return mode;
36234     };
36235     mode.activeID = function() {
36236       if (!arguments.length) return _activeEntity && _activeEntity.id;
36237       return mode;
36238     };
36239     mode.restoreSelectedIDs = function(_2) {
36240       if (!arguments.length) return _restoreSelectedIDs;
36241       _restoreSelectedIDs = _2;
36242       return mode;
36243     };
36244     mode.behavior = drag;
36245     return mode;
36246   }
36247
36248   // node_modules/quickselect/index.js
36249   function quickselect2(arr, k2, left = 0, right = arr.length - 1, compare2 = defaultCompare) {
36250     while (right > left) {
36251       if (right - left > 600) {
36252         const n3 = right - left + 1;
36253         const m2 = k2 - left + 1;
36254         const z2 = Math.log(n3);
36255         const s2 = 0.5 * Math.exp(2 * z2 / 3);
36256         const sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1);
36257         const newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd));
36258         const newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd));
36259         quickselect2(arr, k2, newLeft, newRight, compare2);
36260       }
36261       const t2 = arr[k2];
36262       let i3 = left;
36263       let j2 = right;
36264       swap2(arr, left, k2);
36265       if (compare2(arr[right], t2) > 0) swap2(arr, left, right);
36266       while (i3 < j2) {
36267         swap2(arr, i3, j2);
36268         i3++;
36269         j2--;
36270         while (compare2(arr[i3], t2) < 0) i3++;
36271         while (compare2(arr[j2], t2) > 0) j2--;
36272       }
36273       if (compare2(arr[left], t2) === 0) swap2(arr, left, j2);
36274       else {
36275         j2++;
36276         swap2(arr, j2, right);
36277       }
36278       if (j2 <= k2) left = j2 + 1;
36279       if (k2 <= j2) right = j2 - 1;
36280     }
36281   }
36282   function swap2(arr, i3, j2) {
36283     const tmp = arr[i3];
36284     arr[i3] = arr[j2];
36285     arr[j2] = tmp;
36286   }
36287   function defaultCompare(a2, b2) {
36288     return a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
36289   }
36290
36291   // node_modules/rbush/index.js
36292   var RBush = class {
36293     constructor(maxEntries = 9) {
36294       this._maxEntries = Math.max(4, maxEntries);
36295       this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
36296       this.clear();
36297     }
36298     all() {
36299       return this._all(this.data, []);
36300     }
36301     search(bbox2) {
36302       let node = this.data;
36303       const result = [];
36304       if (!intersects(bbox2, node)) return result;
36305       const toBBox = this.toBBox;
36306       const nodesToSearch = [];
36307       while (node) {
36308         for (let i3 = 0; i3 < node.children.length; i3++) {
36309           const child = node.children[i3];
36310           const childBBox = node.leaf ? toBBox(child) : child;
36311           if (intersects(bbox2, childBBox)) {
36312             if (node.leaf) result.push(child);
36313             else if (contains(bbox2, childBBox)) this._all(child, result);
36314             else nodesToSearch.push(child);
36315           }
36316         }
36317         node = nodesToSearch.pop();
36318       }
36319       return result;
36320     }
36321     collides(bbox2) {
36322       let node = this.data;
36323       if (!intersects(bbox2, node)) return false;
36324       const nodesToSearch = [];
36325       while (node) {
36326         for (let i3 = 0; i3 < node.children.length; i3++) {
36327           const child = node.children[i3];
36328           const childBBox = node.leaf ? this.toBBox(child) : child;
36329           if (intersects(bbox2, childBBox)) {
36330             if (node.leaf || contains(bbox2, childBBox)) return true;
36331             nodesToSearch.push(child);
36332           }
36333         }
36334         node = nodesToSearch.pop();
36335       }
36336       return false;
36337     }
36338     load(data) {
36339       if (!(data && data.length)) return this;
36340       if (data.length < this._minEntries) {
36341         for (let i3 = 0; i3 < data.length; i3++) {
36342           this.insert(data[i3]);
36343         }
36344         return this;
36345       }
36346       let node = this._build(data.slice(), 0, data.length - 1, 0);
36347       if (!this.data.children.length) {
36348         this.data = node;
36349       } else if (this.data.height === node.height) {
36350         this._splitRoot(this.data, node);
36351       } else {
36352         if (this.data.height < node.height) {
36353           const tmpNode = this.data;
36354           this.data = node;
36355           node = tmpNode;
36356         }
36357         this._insert(node, this.data.height - node.height - 1, true);
36358       }
36359       return this;
36360     }
36361     insert(item) {
36362       if (item) this._insert(item, this.data.height - 1);
36363       return this;
36364     }
36365     clear() {
36366       this.data = createNode([]);
36367       return this;
36368     }
36369     remove(item, equalsFn) {
36370       if (!item) return this;
36371       let node = this.data;
36372       const bbox2 = this.toBBox(item);
36373       const path = [];
36374       const indexes = [];
36375       let i3, parent, goingUp;
36376       while (node || path.length) {
36377         if (!node) {
36378           node = path.pop();
36379           parent = path[path.length - 1];
36380           i3 = indexes.pop();
36381           goingUp = true;
36382         }
36383         if (node.leaf) {
36384           const index = findItem(item, node.children, equalsFn);
36385           if (index !== -1) {
36386             node.children.splice(index, 1);
36387             path.push(node);
36388             this._condense(path);
36389             return this;
36390           }
36391         }
36392         if (!goingUp && !node.leaf && contains(node, bbox2)) {
36393           path.push(node);
36394           indexes.push(i3);
36395           i3 = 0;
36396           parent = node;
36397           node = node.children[0];
36398         } else if (parent) {
36399           i3++;
36400           node = parent.children[i3];
36401           goingUp = false;
36402         } else node = null;
36403       }
36404       return this;
36405     }
36406     toBBox(item) {
36407       return item;
36408     }
36409     compareMinX(a2, b2) {
36410       return a2.minX - b2.minX;
36411     }
36412     compareMinY(a2, b2) {
36413       return a2.minY - b2.minY;
36414     }
36415     toJSON() {
36416       return this.data;
36417     }
36418     fromJSON(data) {
36419       this.data = data;
36420       return this;
36421     }
36422     _all(node, result) {
36423       const nodesToSearch = [];
36424       while (node) {
36425         if (node.leaf) result.push(...node.children);
36426         else nodesToSearch.push(...node.children);
36427         node = nodesToSearch.pop();
36428       }
36429       return result;
36430     }
36431     _build(items, left, right, height) {
36432       const N2 = right - left + 1;
36433       let M2 = this._maxEntries;
36434       let node;
36435       if (N2 <= M2) {
36436         node = createNode(items.slice(left, right + 1));
36437         calcBBox(node, this.toBBox);
36438         return node;
36439       }
36440       if (!height) {
36441         height = Math.ceil(Math.log(N2) / Math.log(M2));
36442         M2 = Math.ceil(N2 / Math.pow(M2, height - 1));
36443       }
36444       node = createNode([]);
36445       node.leaf = false;
36446       node.height = height;
36447       const N22 = Math.ceil(N2 / M2);
36448       const N1 = N22 * Math.ceil(Math.sqrt(M2));
36449       multiSelect(items, left, right, N1, this.compareMinX);
36450       for (let i3 = left; i3 <= right; i3 += N1) {
36451         const right2 = Math.min(i3 + N1 - 1, right);
36452         multiSelect(items, i3, right2, N22, this.compareMinY);
36453         for (let j2 = i3; j2 <= right2; j2 += N22) {
36454           const right3 = Math.min(j2 + N22 - 1, right2);
36455           node.children.push(this._build(items, j2, right3, height - 1));
36456         }
36457       }
36458       calcBBox(node, this.toBBox);
36459       return node;
36460     }
36461     _chooseSubtree(bbox2, node, level, path) {
36462       while (true) {
36463         path.push(node);
36464         if (node.leaf || path.length - 1 === level) break;
36465         let minArea = Infinity;
36466         let minEnlargement = Infinity;
36467         let targetNode;
36468         for (let i3 = 0; i3 < node.children.length; i3++) {
36469           const child = node.children[i3];
36470           const area = bboxArea(child);
36471           const enlargement = enlargedArea(bbox2, child) - area;
36472           if (enlargement < minEnlargement) {
36473             minEnlargement = enlargement;
36474             minArea = area < minArea ? area : minArea;
36475             targetNode = child;
36476           } else if (enlargement === minEnlargement) {
36477             if (area < minArea) {
36478               minArea = area;
36479               targetNode = child;
36480             }
36481           }
36482         }
36483         node = targetNode || node.children[0];
36484       }
36485       return node;
36486     }
36487     _insert(item, level, isNode) {
36488       const bbox2 = isNode ? item : this.toBBox(item);
36489       const insertPath = [];
36490       const node = this._chooseSubtree(bbox2, this.data, level, insertPath);
36491       node.children.push(item);
36492       extend2(node, bbox2);
36493       while (level >= 0) {
36494         if (insertPath[level].children.length > this._maxEntries) {
36495           this._split(insertPath, level);
36496           level--;
36497         } else break;
36498       }
36499       this._adjustParentBBoxes(bbox2, insertPath, level);
36500     }
36501     // split overflowed node into two
36502     _split(insertPath, level) {
36503       const node = insertPath[level];
36504       const M2 = node.children.length;
36505       const m2 = this._minEntries;
36506       this._chooseSplitAxis(node, m2, M2);
36507       const splitIndex = this._chooseSplitIndex(node, m2, M2);
36508       const newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
36509       newNode.height = node.height;
36510       newNode.leaf = node.leaf;
36511       calcBBox(node, this.toBBox);
36512       calcBBox(newNode, this.toBBox);
36513       if (level) insertPath[level - 1].children.push(newNode);
36514       else this._splitRoot(node, newNode);
36515     }
36516     _splitRoot(node, newNode) {
36517       this.data = createNode([node, newNode]);
36518       this.data.height = node.height + 1;
36519       this.data.leaf = false;
36520       calcBBox(this.data, this.toBBox);
36521     }
36522     _chooseSplitIndex(node, m2, M2) {
36523       let index;
36524       let minOverlap = Infinity;
36525       let minArea = Infinity;
36526       for (let i3 = m2; i3 <= M2 - m2; i3++) {
36527         const bbox1 = distBBox(node, 0, i3, this.toBBox);
36528         const bbox2 = distBBox(node, i3, M2, this.toBBox);
36529         const overlap = intersectionArea(bbox1, bbox2);
36530         const area = bboxArea(bbox1) + bboxArea(bbox2);
36531         if (overlap < minOverlap) {
36532           minOverlap = overlap;
36533           index = i3;
36534           minArea = area < minArea ? area : minArea;
36535         } else if (overlap === minOverlap) {
36536           if (area < minArea) {
36537             minArea = area;
36538             index = i3;
36539           }
36540         }
36541       }
36542       return index || M2 - m2;
36543     }
36544     // sorts node children by the best axis for split
36545     _chooseSplitAxis(node, m2, M2) {
36546       const compareMinX = node.leaf ? this.compareMinX : compareNodeMinX;
36547       const compareMinY = node.leaf ? this.compareMinY : compareNodeMinY;
36548       const xMargin = this._allDistMargin(node, m2, M2, compareMinX);
36549       const yMargin = this._allDistMargin(node, m2, M2, compareMinY);
36550       if (xMargin < yMargin) node.children.sort(compareMinX);
36551     }
36552     // total margin of all possible split distributions where each node is at least m full
36553     _allDistMargin(node, m2, M2, compare2) {
36554       node.children.sort(compare2);
36555       const toBBox = this.toBBox;
36556       const leftBBox = distBBox(node, 0, m2, toBBox);
36557       const rightBBox = distBBox(node, M2 - m2, M2, toBBox);
36558       let margin = bboxMargin(leftBBox) + bboxMargin(rightBBox);
36559       for (let i3 = m2; i3 < M2 - m2; i3++) {
36560         const child = node.children[i3];
36561         extend2(leftBBox, node.leaf ? toBBox(child) : child);
36562         margin += bboxMargin(leftBBox);
36563       }
36564       for (let i3 = M2 - m2 - 1; i3 >= m2; i3--) {
36565         const child = node.children[i3];
36566         extend2(rightBBox, node.leaf ? toBBox(child) : child);
36567         margin += bboxMargin(rightBBox);
36568       }
36569       return margin;
36570     }
36571     _adjustParentBBoxes(bbox2, path, level) {
36572       for (let i3 = level; i3 >= 0; i3--) {
36573         extend2(path[i3], bbox2);
36574       }
36575     }
36576     _condense(path) {
36577       for (let i3 = path.length - 1, siblings; i3 >= 0; i3--) {
36578         if (path[i3].children.length === 0) {
36579           if (i3 > 0) {
36580             siblings = path[i3 - 1].children;
36581             siblings.splice(siblings.indexOf(path[i3]), 1);
36582           } else this.clear();
36583         } else calcBBox(path[i3], this.toBBox);
36584       }
36585     }
36586   };
36587   function findItem(item, items, equalsFn) {
36588     if (!equalsFn) return items.indexOf(item);
36589     for (let i3 = 0; i3 < items.length; i3++) {
36590       if (equalsFn(item, items[i3])) return i3;
36591     }
36592     return -1;
36593   }
36594   function calcBBox(node, toBBox) {
36595     distBBox(node, 0, node.children.length, toBBox, node);
36596   }
36597   function distBBox(node, k2, p2, toBBox, destNode) {
36598     if (!destNode) destNode = createNode(null);
36599     destNode.minX = Infinity;
36600     destNode.minY = Infinity;
36601     destNode.maxX = -Infinity;
36602     destNode.maxY = -Infinity;
36603     for (let i3 = k2; i3 < p2; i3++) {
36604       const child = node.children[i3];
36605       extend2(destNode, node.leaf ? toBBox(child) : child);
36606     }
36607     return destNode;
36608   }
36609   function extend2(a2, b2) {
36610     a2.minX = Math.min(a2.minX, b2.minX);
36611     a2.minY = Math.min(a2.minY, b2.minY);
36612     a2.maxX = Math.max(a2.maxX, b2.maxX);
36613     a2.maxY = Math.max(a2.maxY, b2.maxY);
36614     return a2;
36615   }
36616   function compareNodeMinX(a2, b2) {
36617     return a2.minX - b2.minX;
36618   }
36619   function compareNodeMinY(a2, b2) {
36620     return a2.minY - b2.minY;
36621   }
36622   function bboxArea(a2) {
36623     return (a2.maxX - a2.minX) * (a2.maxY - a2.minY);
36624   }
36625   function bboxMargin(a2) {
36626     return a2.maxX - a2.minX + (a2.maxY - a2.minY);
36627   }
36628   function enlargedArea(a2, b2) {
36629     return (Math.max(b2.maxX, a2.maxX) - Math.min(b2.minX, a2.minX)) * (Math.max(b2.maxY, a2.maxY) - Math.min(b2.minY, a2.minY));
36630   }
36631   function intersectionArea(a2, b2) {
36632     const minX = Math.max(a2.minX, b2.minX);
36633     const minY = Math.max(a2.minY, b2.minY);
36634     const maxX = Math.min(a2.maxX, b2.maxX);
36635     const maxY = Math.min(a2.maxY, b2.maxY);
36636     return Math.max(0, maxX - minX) * Math.max(0, maxY - minY);
36637   }
36638   function contains(a2, b2) {
36639     return a2.minX <= b2.minX && a2.minY <= b2.minY && b2.maxX <= a2.maxX && b2.maxY <= a2.maxY;
36640   }
36641   function intersects(a2, b2) {
36642     return b2.minX <= a2.maxX && b2.minY <= a2.maxY && b2.maxX >= a2.minX && b2.maxY >= a2.minY;
36643   }
36644   function createNode(children2) {
36645     return {
36646       children: children2,
36647       height: 1,
36648       leaf: true,
36649       minX: Infinity,
36650       minY: Infinity,
36651       maxX: -Infinity,
36652       maxY: -Infinity
36653     };
36654   }
36655   function multiSelect(arr, left, right, n3, compare2) {
36656     const stack = [left, right];
36657     while (stack.length) {
36658       right = stack.pop();
36659       left = stack.pop();
36660       if (right - left <= n3) continue;
36661       const mid = left + Math.ceil((right - left) / n3 / 2) * n3;
36662       quickselect2(arr, mid, left, right, compare2);
36663       stack.push(left, mid, mid, right);
36664     }
36665   }
36666
36667   // node_modules/d3-fetch/src/text.js
36668   function responseText(response) {
36669     if (!response.ok) throw new Error(response.status + " " + response.statusText);
36670     return response.text();
36671   }
36672   function text_default3(input, init2) {
36673     return fetch(input, init2).then(responseText);
36674   }
36675
36676   // node_modules/d3-fetch/src/json.js
36677   function responseJson(response) {
36678     if (!response.ok) throw new Error(response.status + " " + response.statusText);
36679     if (response.status === 204 || response.status === 205) return;
36680     return response.json();
36681   }
36682   function json_default(input, init2) {
36683     return fetch(input, init2).then(responseJson);
36684   }
36685
36686   // node_modules/d3-fetch/src/xml.js
36687   function parser(type2) {
36688     return (input, init2) => text_default3(input, init2).then((text) => new DOMParser().parseFromString(text, type2));
36689   }
36690   var xml_default = parser("application/xml");
36691   var html = parser("text/html");
36692   var svg = parser("image/svg+xml");
36693
36694   // modules/services/keepRight.js
36695   var tiler = utilTiler();
36696   var dispatch2 = dispatch_default("loaded");
36697   var _tileZoom = 14;
36698   var _krUrlRoot = "https://www.keepright.at";
36699   var _krData = { errorTypes: {}, localizeStrings: {} };
36700   var _cache;
36701   var _krRuleset = [
36702     // no 20 - multiple node on same spot - these are mostly boundaries overlapping roads
36703     30,
36704     40,
36705     50,
36706     60,
36707     70,
36708     90,
36709     100,
36710     110,
36711     120,
36712     130,
36713     150,
36714     160,
36715     170,
36716     180,
36717     190,
36718     191,
36719     192,
36720     193,
36721     194,
36722     195,
36723     196,
36724     197,
36725     198,
36726     200,
36727     201,
36728     202,
36729     203,
36730     204,
36731     205,
36732     206,
36733     207,
36734     208,
36735     210,
36736     220,
36737     230,
36738     231,
36739     232,
36740     270,
36741     280,
36742     281,
36743     282,
36744     283,
36745     284,
36746     285,
36747     290,
36748     291,
36749     292,
36750     293,
36751     294,
36752     295,
36753     296,
36754     297,
36755     298,
36756     300,
36757     310,
36758     311,
36759     312,
36760     313,
36761     320,
36762     350,
36763     360,
36764     370,
36765     380,
36766     390,
36767     400,
36768     401,
36769     402,
36770     410,
36771     411,
36772     412,
36773     413
36774   ];
36775   function abortRequest(controller) {
36776     if (controller) {
36777       controller.abort();
36778     }
36779   }
36780   function abortUnwantedRequests(cache, tiles) {
36781     Object.keys(cache.inflightTile).forEach((k2) => {
36782       const wanted = tiles.find((tile) => k2 === tile.id);
36783       if (!wanted) {
36784         abortRequest(cache.inflightTile[k2]);
36785         delete cache.inflightTile[k2];
36786       }
36787     });
36788   }
36789   function encodeIssueRtree(d2) {
36790     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
36791   }
36792   function updateRtree(item, replace) {
36793     _cache.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
36794     if (replace) {
36795       _cache.rtree.insert(item);
36796     }
36797   }
36798   function tokenReplacements(d2) {
36799     if (!(d2 instanceof QAItem)) return;
36800     const replacements = {};
36801     const issueTemplate = _krData.errorTypes[d2.whichType];
36802     if (!issueTemplate) {
36803       console.log("No Template: ", d2.whichType);
36804       console.log("  ", d2.description);
36805       return;
36806     }
36807     if (!issueTemplate.regex) return;
36808     const errorRegex = new RegExp(issueTemplate.regex, "i");
36809     const errorMatch = errorRegex.exec(d2.description);
36810     if (!errorMatch) {
36811       console.log("Unmatched: ", d2.whichType);
36812       console.log("  ", d2.description);
36813       console.log("  ", errorRegex);
36814       return;
36815     }
36816     for (let i3 = 1; i3 < errorMatch.length; i3++) {
36817       let capture = errorMatch[i3];
36818       let idType;
36819       idType = "IDs" in issueTemplate ? issueTemplate.IDs[i3 - 1] : "";
36820       if (idType && capture) {
36821         capture = parseError(capture, idType);
36822       } else {
36823         const compare2 = capture.toLowerCase();
36824         if (_krData.localizeStrings[compare2]) {
36825           capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]);
36826         } else {
36827           capture = unescape_default(capture);
36828         }
36829       }
36830       replacements["var" + i3] = capture;
36831     }
36832     return replacements;
36833   }
36834   function parseError(capture, idType) {
36835     const compare2 = capture.toLowerCase();
36836     if (_krData.localizeStrings[compare2]) {
36837       capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]);
36838     }
36839     switch (idType) {
36840       // link a string like "this node"
36841       case "this":
36842         capture = linkErrorObject(capture);
36843         break;
36844       case "url":
36845         capture = linkURL(capture);
36846         break;
36847       // link an entity ID
36848       case "n":
36849       case "w":
36850       case "r":
36851         capture = linkEntity(idType + capture);
36852         break;
36853       // some errors have more complex ID lists/variance
36854       case "20":
36855         capture = parse20(capture);
36856         break;
36857       case "211":
36858         capture = parse211(capture);
36859         break;
36860       case "231":
36861         capture = parse231(capture);
36862         break;
36863       case "294":
36864         capture = parse294(capture);
36865         break;
36866       case "370":
36867         capture = parse370(capture);
36868         break;
36869     }
36870     return capture;
36871     function linkErrorObject(d2) {
36872       return { html: '<a class="error_object_link">'.concat(d2, "</a>") };
36873     }
36874     function linkEntity(d2) {
36875       return { html: '<a class="error_entity_link">'.concat(d2, "</a>") };
36876     }
36877     function linkURL(d2) {
36878       return { html: '<a class="kr_external_link" target="_blank" href="'.concat(d2, '">').concat(d2, "</a>") };
36879     }
36880     function parse211(capture2) {
36881       let newList = [];
36882       const items = capture2.split(", ");
36883       items.forEach((item) => {
36884         let id2 = linkEntity("n" + item.slice(1));
36885         newList.push(id2);
36886       });
36887       return newList.join(", ");
36888     }
36889     function parse231(capture2) {
36890       let newList = [];
36891       const items = capture2.split("),");
36892       items.forEach((item) => {
36893         const match = item.match(/\#(\d+)\((.+)\)?/);
36894         if (match !== null && match.length > 2) {
36895           newList.push(
36896             linkEntity("w" + match[1]) + " " + _t("QA.keepRight.errorTypes.231.layer", { layer: match[2] })
36897           );
36898         }
36899       });
36900       return newList.join(", ");
36901     }
36902     function parse294(capture2) {
36903       let newList = [];
36904       const items = capture2.split(",");
36905       items.forEach((item) => {
36906         item = item.split(" ");
36907         const role = '"'.concat(item[0], '"');
36908         const idType2 = item[1].slice(0, 1);
36909         let id2 = item[2].slice(1);
36910         id2 = linkEntity(idType2 + id2);
36911         newList.push("".concat(role, " ").concat(item[1], " ").concat(id2));
36912       });
36913       return newList.join(", ");
36914     }
36915     function parse370(capture2) {
36916       if (!capture2) return "";
36917       const match = capture2.match(/\(including the name (\'.+\')\)/);
36918       if (match && match.length) {
36919         return _t("QA.keepRight.errorTypes.370.including_the_name", { name: match[1] });
36920       }
36921       return "";
36922     }
36923     function parse20(capture2) {
36924       let newList = [];
36925       const items = capture2.split(",");
36926       items.forEach((item) => {
36927         const id2 = linkEntity("n" + item.slice(1));
36928         newList.push(id2);
36929       });
36930       return newList.join(", ");
36931     }
36932   }
36933   var keepRight_default = {
36934     title: "keepRight",
36935     init() {
36936       _mainFileFetcher.get("keepRight").then((d2) => _krData = d2);
36937       if (!_cache) {
36938         this.reset();
36939       }
36940       this.event = utilRebind(this, dispatch2, "on");
36941     },
36942     reset() {
36943       if (_cache) {
36944         Object.values(_cache.inflightTile).forEach(abortRequest);
36945       }
36946       _cache = {
36947         data: {},
36948         loadedTile: {},
36949         inflightTile: {},
36950         inflightPost: {},
36951         closed: {},
36952         rtree: new RBush()
36953       };
36954     },
36955     // KeepRight API:  http://osm.mueschelsoft.de/keepright/interfacing.php
36956     loadIssues(projection2) {
36957       const options2 = {
36958         format: "geojson",
36959         ch: _krRuleset
36960       };
36961       const tiles = tiler.zoomExtent([_tileZoom, _tileZoom]).getTiles(projection2);
36962       abortUnwantedRequests(_cache, tiles);
36963       tiles.forEach((tile) => {
36964         if (_cache.loadedTile[tile.id] || _cache.inflightTile[tile.id]) return;
36965         const [left, top, right, bottom] = tile.extent.rectangle();
36966         const params = Object.assign({}, options2, { left, bottom, right, top });
36967         const url = "".concat(_krUrlRoot, "/export.php?") + utilQsString(params);
36968         const controller = new AbortController();
36969         _cache.inflightTile[tile.id] = controller;
36970         json_default(url, { signal: controller.signal }).then((data) => {
36971           delete _cache.inflightTile[tile.id];
36972           _cache.loadedTile[tile.id] = true;
36973           if (!data || !data.features || !data.features.length) {
36974             throw new Error("No Data");
36975           }
36976           data.features.forEach((feature3) => {
36977             const {
36978               properties: {
36979                 error_type: itemType,
36980                 error_id: id2,
36981                 comment = null,
36982                 object_id: objectId,
36983                 object_type: objectType,
36984                 schema,
36985                 title
36986               }
36987             } = feature3;
36988             let {
36989               geometry: { coordinates: loc },
36990               properties: { description = "" }
36991             } = feature3;
36992             const issueTemplate = _krData.errorTypes[itemType];
36993             const parentIssueType = (Math.floor(itemType / 10) * 10).toString();
36994             const whichType = issueTemplate ? itemType : parentIssueType;
36995             const whichTemplate = _krData.errorTypes[whichType];
36996             switch (whichType) {
36997               case "170":
36998                 description = "This feature has a FIXME tag: ".concat(description);
36999                 break;
37000               case "292":
37001               case "293":
37002                 description = description.replace("A turn-", "This turn-");
37003                 break;
37004               case "294":
37005               case "295":
37006               case "296":
37007               case "297":
37008               case "298":
37009                 description = "This turn-restriction~".concat(description);
37010                 break;
37011               case "300":
37012                 description = "This highway is missing a maxspeed tag";
37013                 break;
37014               case "411":
37015               case "412":
37016               case "413":
37017                 description = "This feature~".concat(description);
37018                 break;
37019             }
37020             let coincident = false;
37021             do {
37022               let delta = coincident ? [1e-5, 0] : [0, 1e-5];
37023               loc = geoVecAdd(loc, delta);
37024               let bbox2 = geoExtent(loc).bbox();
37025               coincident = _cache.rtree.search(bbox2).length;
37026             } while (coincident);
37027             let d2 = new QAItem(loc, this, itemType, id2, {
37028               comment,
37029               description,
37030               whichType,
37031               parentIssueType,
37032               severity: whichTemplate.severity || "error",
37033               objectId,
37034               objectType,
37035               schema,
37036               title
37037             });
37038             d2.replacements = tokenReplacements(d2);
37039             _cache.data[id2] = d2;
37040             _cache.rtree.insert(encodeIssueRtree(d2));
37041           });
37042           dispatch2.call("loaded");
37043         }).catch(() => {
37044           delete _cache.inflightTile[tile.id];
37045           _cache.loadedTile[tile.id] = true;
37046         });
37047       });
37048     },
37049     postUpdate(d2, callback) {
37050       if (_cache.inflightPost[d2.id]) {
37051         return callback({ message: "Error update already inflight", status: -2 }, d2);
37052       }
37053       const params = { schema: d2.schema, id: d2.id };
37054       if (d2.newStatus) {
37055         params.st = d2.newStatus;
37056       }
37057       if (d2.newComment !== void 0) {
37058         params.co = d2.newComment;
37059       }
37060       const url = "".concat(_krUrlRoot, "/comment.php?") + utilQsString(params);
37061       const controller = new AbortController();
37062       _cache.inflightPost[d2.id] = controller;
37063       json_default(url, { signal: controller.signal }).finally(() => {
37064         delete _cache.inflightPost[d2.id];
37065         if (d2.newStatus === "ignore") {
37066           this.removeItem(d2);
37067         } else if (d2.newStatus === "ignore_t") {
37068           this.removeItem(d2);
37069           _cache.closed["".concat(d2.schema, ":").concat(d2.id)] = true;
37070         } else {
37071           d2 = this.replaceItem(d2.update({
37072             comment: d2.newComment,
37073             newComment: void 0,
37074             newState: void 0
37075           }));
37076         }
37077         if (callback) callback(null, d2);
37078       });
37079     },
37080     // Get all cached QAItems covering the viewport
37081     getItems(projection2) {
37082       const viewport = projection2.clipExtent();
37083       const min3 = [viewport[0][0], viewport[1][1]];
37084       const max3 = [viewport[1][0], viewport[0][1]];
37085       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
37086       return _cache.rtree.search(bbox2).map((d2) => d2.data);
37087     },
37088     // Get a QAItem from cache
37089     // NOTE: Don't change method name until UI v3 is merged
37090     getError(id2) {
37091       return _cache.data[id2];
37092     },
37093     // Replace a single QAItem in the cache
37094     replaceItem(item) {
37095       if (!(item instanceof QAItem) || !item.id) return;
37096       _cache.data[item.id] = item;
37097       updateRtree(encodeIssueRtree(item), true);
37098       return item;
37099     },
37100     // Remove a single QAItem from the cache
37101     removeItem(item) {
37102       if (!(item instanceof QAItem) || !item.id) return;
37103       delete _cache.data[item.id];
37104       updateRtree(encodeIssueRtree(item), false);
37105     },
37106     issueURL(item) {
37107       return "".concat(_krUrlRoot, "/report_map.php?schema=").concat(item.schema, "&error=").concat(item.id);
37108     },
37109     // Get an array of issues closed during this session.
37110     // Used to populate `closed:keepright` changeset tag
37111     getClosedIDs() {
37112       return Object.keys(_cache.closed).sort();
37113     }
37114   };
37115
37116   // node_modules/marked/lib/marked.esm.js
37117   function _getDefaults() {
37118     return {
37119       async: false,
37120       breaks: false,
37121       extensions: null,
37122       gfm: true,
37123       hooks: null,
37124       pedantic: false,
37125       renderer: null,
37126       silent: false,
37127       tokenizer: null,
37128       walkTokens: null
37129     };
37130   }
37131   var _defaults = _getDefaults();
37132   function changeDefaults(newDefaults) {
37133     _defaults = newDefaults;
37134   }
37135   var noopTest = { exec: () => null };
37136   function edit(regex, opt = "") {
37137     let source = typeof regex === "string" ? regex : regex.source;
37138     const obj = {
37139       replace: (name, val) => {
37140         let valSource = typeof val === "string" ? val : val.source;
37141         valSource = valSource.replace(other.caret, "$1");
37142         source = source.replace(name, valSource);
37143         return obj;
37144       },
37145       getRegex: () => {
37146         return new RegExp(source, opt);
37147       }
37148     };
37149     return obj;
37150   }
37151   var other = {
37152     codeRemoveIndent: /^(?: {1,4}| {0,3}\t)/gm,
37153     outputLinkReplace: /\\([\[\]])/g,
37154     indentCodeCompensation: /^(\s+)(?:```)/,
37155     beginningSpace: /^\s+/,
37156     endingHash: /#$/,
37157     startingSpaceChar: /^ /,
37158     endingSpaceChar: / $/,
37159     nonSpaceChar: /[^ ]/,
37160     newLineCharGlobal: /\n/g,
37161     tabCharGlobal: /\t/g,
37162     multipleSpaceGlobal: /\s+/g,
37163     blankLine: /^[ \t]*$/,
37164     doubleBlankLine: /\n[ \t]*\n[ \t]*$/,
37165     blockquoteStart: /^ {0,3}>/,
37166     blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
37167     blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
37168     listReplaceTabs: /^\t+/,
37169     listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
37170     listIsTask: /^\[[ xX]\] /,
37171     listReplaceTask: /^\[[ xX]\] +/,
37172     anyLine: /\n.*\n/,
37173     hrefBrackets: /^<(.*)>$/,
37174     tableDelimiter: /[:|]/,
37175     tableAlignChars: /^\||\| *$/g,
37176     tableRowBlankLine: /\n[ \t]*$/,
37177     tableAlignRight: /^ *-+: *$/,
37178     tableAlignCenter: /^ *:-+: *$/,
37179     tableAlignLeft: /^ *:-+ *$/,
37180     startATag: /^<a /i,
37181     endATag: /^<\/a>/i,
37182     startPreScriptTag: /^<(pre|code|kbd|script)(\s|>)/i,
37183     endPreScriptTag: /^<\/(pre|code|kbd|script)(\s|>)/i,
37184     startAngleBracket: /^</,
37185     endAngleBracket: />$/,
37186     pedanticHrefTitle: /^([^'"]*[^\s])\s+(['"])(.*)\2/,
37187     unicodeAlphaNumeric: new RegExp("[\\p{L}\\p{N}]", "u"),
37188     escapeTest: /[&<>"']/,
37189     escapeReplace: /[&<>"']/g,
37190     escapeTestNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,
37191     escapeReplaceNoEncode: /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,
37192     unescapeTest: /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,
37193     caret: /(^|[^\[])\^/g,
37194     percentDecode: /%25/g,
37195     findPipe: /\|/g,
37196     splitPipe: / \|/,
37197     slashPipe: /\\\|/g,
37198     carriageReturn: /\r\n|\r/g,
37199     spaceLine: /^ +$/gm,
37200     notSpaceStart: /^\S*/,
37201     endingNewline: /\n$/,
37202     listItemRegex: (bull) => new RegExp("^( {0,3}".concat(bull, ")((?:[  ][^\\n]*)?(?:\\n|$))")),
37203     nextBulletRegex: (indent) => new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:[*+-]|\\d{1,9}[.)])((?:[       ][^\\n]*)?(?:\\n|$))")),
37204     hrRegex: (indent) => new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)")),
37205     fencesBeginRegex: (indent) => new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:```|~~~)")),
37206     headingBeginRegex: (indent) => new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}#")),
37207     htmlBeginRegex: (indent) => new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}<(?:[a-z].*>|!--)"), "i")
37208   };
37209   var newline = /^(?:[ \t]*(?:\n|$))+/;
37210   var blockCode = /^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/;
37211   var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
37212   var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
37213   var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
37214   var bullet = /(?:[*+-]|\d{1,9}[.)])/;
37215   var lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, /(?: {4}| {0,3}\t)/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex();
37216   var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
37217   var blockText = /^[^\n]+/;
37218   var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
37219   var def = edit(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
37220   var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
37221   var _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
37222   var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
37223   var html2 = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[  ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[     ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[     ]*)+\\n|$))", "i").replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
37224   var paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
37225   var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
37226   var blockNormal = {
37227     blockquote,
37228     code: blockCode,
37229     def,
37230     fences,
37231     heading,
37232     hr,
37233     html: html2,
37234     lheading,
37235     list,
37236     newline,
37237     paragraph,
37238     table: noopTest,
37239     text: blockText
37240   };
37241   var gfmTable = edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", "(?: {4}| {0,3}     )[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
37242   var blockGfm = __spreadProps(__spreadValues({}, blockNormal), {
37243     table: gfmTable,
37244     paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
37245   });
37246   var blockPedantic = __spreadProps(__spreadValues({}, blockNormal), {
37247     html: edit("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", _comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
37248     def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
37249     heading: /^(#{1,6})(.*)(?:\n+|$)/,
37250     fences: noopTest,
37251     // fences not supported
37252     lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
37253     paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
37254   });
37255   var escape$1 = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
37256   var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
37257   var br = /^( {2,}|\\)\n(?!\s*$)/;
37258   var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
37259   var _punctuation = new RegExp("[\\p{P}\\p{S}]", "u");
37260   var _punctuationOrSpace = new RegExp("[\\s\\p{P}\\p{S}]", "u");
37261   var _notPunctuationOrSpace = new RegExp("[^\\s\\p{P}\\p{S}]", "u");
37262   var punctuation = edit(/^((?![*_])punctSpace)/, "u").replace(/punctSpace/g, _punctuationOrSpace).getRegex();
37263   var _punctuationGfmStrongEm = new RegExp("(?!~)[\\p{P}\\p{S}]", "u");
37264   var _punctuationOrSpaceGfmStrongEm = new RegExp("(?!~)[\\s\\p{P}\\p{S}]", "u");
37265   var _notPunctuationOrSpaceGfmStrongEm = new RegExp("(?:[^\\s\\p{P}\\p{S}]|~)", "u");
37266   var blockSkip = /\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g;
37267   var emStrongLDelimCore = /^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/;
37268   var emStrongLDelim = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuation).getRegex();
37269   var emStrongLDelimGfm = edit(emStrongLDelimCore, "u").replace(/punct/g, _punctuationGfmStrongEm).getRegex();
37270   var emStrongRDelimAstCore = "^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)";
37271   var emStrongRDelimAst = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
37272   var emStrongRDelimAstGfm = edit(emStrongRDelimAstCore, "gu").replace(/notPunctSpace/g, _notPunctuationOrSpaceGfmStrongEm).replace(/punctSpace/g, _punctuationOrSpaceGfmStrongEm).replace(/punct/g, _punctuationGfmStrongEm).getRegex();
37273   var emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)", "gu").replace(/notPunctSpace/g, _notPunctuationOrSpace).replace(/punctSpace/g, _punctuationOrSpace).replace(/punct/g, _punctuation).getRegex();
37274   var anyPunctuation = edit(/\\(punct)/, "gu").replace(/punct/g, _punctuation).getRegex();
37275   var autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
37276   var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
37277   var tag = edit("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
37278   var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
37279   var link2 = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
37280   var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
37281   var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
37282   var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
37283   var inlineNormal = {
37284     _backpedal: noopTest,
37285     // only used for GFM url
37286     anyPunctuation,
37287     autolink,
37288     blockSkip,
37289     br,
37290     code: inlineCode,
37291     del: noopTest,
37292     emStrongLDelim,
37293     emStrongRDelimAst,
37294     emStrongRDelimUnd,
37295     escape: escape$1,
37296     link: link2,
37297     nolink,
37298     punctuation,
37299     reflink,
37300     reflinkSearch,
37301     tag,
37302     text: inlineText,
37303     url: noopTest
37304   };
37305   var inlinePedantic = __spreadProps(__spreadValues({}, inlineNormal), {
37306     link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
37307     reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
37308   });
37309   var inlineGfm = __spreadProps(__spreadValues({}, inlineNormal), {
37310     emStrongRDelimAst: emStrongRDelimAstGfm,
37311     emStrongLDelim: emStrongLDelimGfm,
37312     url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
37313     _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
37314     del: /^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,
37315     text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
37316   });
37317   var inlineBreaks = __spreadProps(__spreadValues({}, inlineGfm), {
37318     br: edit(br).replace("{2,}", "*").getRegex(),
37319     text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
37320   });
37321   var block = {
37322     normal: blockNormal,
37323     gfm: blockGfm,
37324     pedantic: blockPedantic
37325   };
37326   var inline = {
37327     normal: inlineNormal,
37328     gfm: inlineGfm,
37329     breaks: inlineBreaks,
37330     pedantic: inlinePedantic
37331   };
37332   var escapeReplacements = {
37333     "&": "&amp;",
37334     "<": "&lt;",
37335     ">": "&gt;",
37336     '"': "&quot;",
37337     "'": "&#39;"
37338   };
37339   var getEscapeReplacement = (ch) => escapeReplacements[ch];
37340   function escape4(html3, encode) {
37341     if (encode) {
37342       if (other.escapeTest.test(html3)) {
37343         return html3.replace(other.escapeReplace, getEscapeReplacement);
37344       }
37345     } else {
37346       if (other.escapeTestNoEncode.test(html3)) {
37347         return html3.replace(other.escapeReplaceNoEncode, getEscapeReplacement);
37348       }
37349     }
37350     return html3;
37351   }
37352   function cleanUrl(href) {
37353     try {
37354       href = encodeURI(href).replace(other.percentDecode, "%");
37355     } catch (e3) {
37356       return null;
37357     }
37358     return href;
37359   }
37360   function splitCells(tableRow, count) {
37361     var _a4;
37362     const row = tableRow.replace(other.findPipe, (match, offset, str) => {
37363       let escaped = false;
37364       let curr = offset;
37365       while (--curr >= 0 && str[curr] === "\\")
37366         escaped = !escaped;
37367       if (escaped) {
37368         return "|";
37369       } else {
37370         return " |";
37371       }
37372     }), cells = row.split(other.splitPipe);
37373     let i3 = 0;
37374     if (!cells[0].trim()) {
37375       cells.shift();
37376     }
37377     if (cells.length > 0 && !((_a4 = cells.at(-1)) == null ? void 0 : _a4.trim())) {
37378       cells.pop();
37379     }
37380     if (count) {
37381       if (cells.length > count) {
37382         cells.splice(count);
37383       } else {
37384         while (cells.length < count)
37385           cells.push("");
37386       }
37387     }
37388     for (; i3 < cells.length; i3++) {
37389       cells[i3] = cells[i3].trim().replace(other.slashPipe, "|");
37390     }
37391     return cells;
37392   }
37393   function rtrim(str, c2, invert) {
37394     const l2 = str.length;
37395     if (l2 === 0) {
37396       return "";
37397     }
37398     let suffLen = 0;
37399     while (suffLen < l2) {
37400       const currChar = str.charAt(l2 - suffLen - 1);
37401       if (currChar === c2 && true) {
37402         suffLen++;
37403       } else {
37404         break;
37405       }
37406     }
37407     return str.slice(0, l2 - suffLen);
37408   }
37409   function findClosingBracket(str, b2) {
37410     if (str.indexOf(b2[1]) === -1) {
37411       return -1;
37412     }
37413     let level = 0;
37414     for (let i3 = 0; i3 < str.length; i3++) {
37415       if (str[i3] === "\\") {
37416         i3++;
37417       } else if (str[i3] === b2[0]) {
37418         level++;
37419       } else if (str[i3] === b2[1]) {
37420         level--;
37421         if (level < 0) {
37422           return i3;
37423         }
37424       }
37425     }
37426     return -1;
37427   }
37428   function outputLink(cap, link3, raw, lexer2, rules) {
37429     const href = link3.href;
37430     const title = link3.title || null;
37431     const text = cap[1].replace(rules.other.outputLinkReplace, "$1");
37432     if (cap[0].charAt(0) !== "!") {
37433       lexer2.state.inLink = true;
37434       const token = {
37435         type: "link",
37436         raw,
37437         href,
37438         title,
37439         text,
37440         tokens: lexer2.inlineTokens(text)
37441       };
37442       lexer2.state.inLink = false;
37443       return token;
37444     }
37445     return {
37446       type: "image",
37447       raw,
37448       href,
37449       title,
37450       text
37451     };
37452   }
37453   function indentCodeCompensation(raw, text, rules) {
37454     const matchIndentToCode = raw.match(rules.other.indentCodeCompensation);
37455     if (matchIndentToCode === null) {
37456       return text;
37457     }
37458     const indentToCode = matchIndentToCode[1];
37459     return text.split("\n").map((node) => {
37460       const matchIndentInNode = node.match(rules.other.beginningSpace);
37461       if (matchIndentInNode === null) {
37462         return node;
37463       }
37464       const [indentInNode] = matchIndentInNode;
37465       if (indentInNode.length >= indentToCode.length) {
37466         return node.slice(indentToCode.length);
37467       }
37468       return node;
37469     }).join("\n");
37470   }
37471   var _Tokenizer = class {
37472     // set by the lexer
37473     constructor(options2) {
37474       __publicField(this, "options");
37475       __publicField(this, "rules");
37476       // set by the lexer
37477       __publicField(this, "lexer");
37478       this.options = options2 || _defaults;
37479     }
37480     space(src) {
37481       const cap = this.rules.block.newline.exec(src);
37482       if (cap && cap[0].length > 0) {
37483         return {
37484           type: "space",
37485           raw: cap[0]
37486         };
37487       }
37488     }
37489     code(src) {
37490       const cap = this.rules.block.code.exec(src);
37491       if (cap) {
37492         const text = cap[0].replace(this.rules.other.codeRemoveIndent, "");
37493         return {
37494           type: "code",
37495           raw: cap[0],
37496           codeBlockStyle: "indented",
37497           text: !this.options.pedantic ? rtrim(text, "\n") : text
37498         };
37499       }
37500     }
37501     fences(src) {
37502       const cap = this.rules.block.fences.exec(src);
37503       if (cap) {
37504         const raw = cap[0];
37505         const text = indentCodeCompensation(raw, cap[3] || "", this.rules);
37506         return {
37507           type: "code",
37508           raw,
37509           lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
37510           text
37511         };
37512       }
37513     }
37514     heading(src) {
37515       const cap = this.rules.block.heading.exec(src);
37516       if (cap) {
37517         let text = cap[2].trim();
37518         if (this.rules.other.endingHash.test(text)) {
37519           const trimmed = rtrim(text, "#");
37520           if (this.options.pedantic) {
37521             text = trimmed.trim();
37522           } else if (!trimmed || this.rules.other.endingSpaceChar.test(trimmed)) {
37523             text = trimmed.trim();
37524           }
37525         }
37526         return {
37527           type: "heading",
37528           raw: cap[0],
37529           depth: cap[1].length,
37530           text,
37531           tokens: this.lexer.inline(text)
37532         };
37533       }
37534     }
37535     hr(src) {
37536       const cap = this.rules.block.hr.exec(src);
37537       if (cap) {
37538         return {
37539           type: "hr",
37540           raw: rtrim(cap[0], "\n")
37541         };
37542       }
37543     }
37544     blockquote(src) {
37545       const cap = this.rules.block.blockquote.exec(src);
37546       if (cap) {
37547         let lines = rtrim(cap[0], "\n").split("\n");
37548         let raw = "";
37549         let text = "";
37550         const tokens = [];
37551         while (lines.length > 0) {
37552           let inBlockquote = false;
37553           const currentLines = [];
37554           let i3;
37555           for (i3 = 0; i3 < lines.length; i3++) {
37556             if (this.rules.other.blockquoteStart.test(lines[i3])) {
37557               currentLines.push(lines[i3]);
37558               inBlockquote = true;
37559             } else if (!inBlockquote) {
37560               currentLines.push(lines[i3]);
37561             } else {
37562               break;
37563             }
37564           }
37565           lines = lines.slice(i3);
37566           const currentRaw = currentLines.join("\n");
37567           const currentText = currentRaw.replace(this.rules.other.blockquoteSetextReplace, "\n    $1").replace(this.rules.other.blockquoteSetextReplace2, "");
37568           raw = raw ? "".concat(raw, "\n").concat(currentRaw) : currentRaw;
37569           text = text ? "".concat(text, "\n").concat(currentText) : currentText;
37570           const top = this.lexer.state.top;
37571           this.lexer.state.top = true;
37572           this.lexer.blockTokens(currentText, tokens, true);
37573           this.lexer.state.top = top;
37574           if (lines.length === 0) {
37575             break;
37576           }
37577           const lastToken = tokens.at(-1);
37578           if ((lastToken == null ? void 0 : lastToken.type) === "code") {
37579             break;
37580           } else if ((lastToken == null ? void 0 : lastToken.type) === "blockquote") {
37581             const oldToken = lastToken;
37582             const newText = oldToken.raw + "\n" + lines.join("\n");
37583             const newToken = this.blockquote(newText);
37584             tokens[tokens.length - 1] = newToken;
37585             raw = raw.substring(0, raw.length - oldToken.raw.length) + newToken.raw;
37586             text = text.substring(0, text.length - oldToken.text.length) + newToken.text;
37587             break;
37588           } else if ((lastToken == null ? void 0 : lastToken.type) === "list") {
37589             const oldToken = lastToken;
37590             const newText = oldToken.raw + "\n" + lines.join("\n");
37591             const newToken = this.list(newText);
37592             tokens[tokens.length - 1] = newToken;
37593             raw = raw.substring(0, raw.length - lastToken.raw.length) + newToken.raw;
37594             text = text.substring(0, text.length - oldToken.raw.length) + newToken.raw;
37595             lines = newText.substring(tokens.at(-1).raw.length).split("\n");
37596             continue;
37597           }
37598         }
37599         return {
37600           type: "blockquote",
37601           raw,
37602           tokens,
37603           text
37604         };
37605       }
37606     }
37607     list(src) {
37608       let cap = this.rules.block.list.exec(src);
37609       if (cap) {
37610         let bull = cap[1].trim();
37611         const isordered = bull.length > 1;
37612         const list2 = {
37613           type: "list",
37614           raw: "",
37615           ordered: isordered,
37616           start: isordered ? +bull.slice(0, -1) : "",
37617           loose: false,
37618           items: []
37619         };
37620         bull = isordered ? "\\d{1,9}\\".concat(bull.slice(-1)) : "\\".concat(bull);
37621         if (this.options.pedantic) {
37622           bull = isordered ? bull : "[*+-]";
37623         }
37624         const itemRegex = this.rules.other.listItemRegex(bull);
37625         let endsWithBlankLine = false;
37626         while (src) {
37627           let endEarly = false;
37628           let raw = "";
37629           let itemContents = "";
37630           if (!(cap = itemRegex.exec(src))) {
37631             break;
37632           }
37633           if (this.rules.block.hr.test(src)) {
37634             break;
37635           }
37636           raw = cap[0];
37637           src = src.substring(raw.length);
37638           let line = cap[2].split("\n", 1)[0].replace(this.rules.other.listReplaceTabs, (t2) => " ".repeat(3 * t2.length));
37639           let nextLine = src.split("\n", 1)[0];
37640           let blankLine = !line.trim();
37641           let indent = 0;
37642           if (this.options.pedantic) {
37643             indent = 2;
37644             itemContents = line.trimStart();
37645           } else if (blankLine) {
37646             indent = cap[1].length + 1;
37647           } else {
37648             indent = cap[2].search(this.rules.other.nonSpaceChar);
37649             indent = indent > 4 ? 1 : indent;
37650             itemContents = line.slice(indent);
37651             indent += cap[1].length;
37652           }
37653           if (blankLine && this.rules.other.blankLine.test(nextLine)) {
37654             raw += nextLine + "\n";
37655             src = src.substring(nextLine.length + 1);
37656             endEarly = true;
37657           }
37658           if (!endEarly) {
37659             const nextBulletRegex = this.rules.other.nextBulletRegex(indent);
37660             const hrRegex = this.rules.other.hrRegex(indent);
37661             const fencesBeginRegex = this.rules.other.fencesBeginRegex(indent);
37662             const headingBeginRegex = this.rules.other.headingBeginRegex(indent);
37663             const htmlBeginRegex = this.rules.other.htmlBeginRegex(indent);
37664             while (src) {
37665               const rawLine = src.split("\n", 1)[0];
37666               let nextLineWithoutTabs;
37667               nextLine = rawLine;
37668               if (this.options.pedantic) {
37669                 nextLine = nextLine.replace(this.rules.other.listReplaceNesting, "  ");
37670                 nextLineWithoutTabs = nextLine;
37671               } else {
37672                 nextLineWithoutTabs = nextLine.replace(this.rules.other.tabCharGlobal, "    ");
37673               }
37674               if (fencesBeginRegex.test(nextLine)) {
37675                 break;
37676               }
37677               if (headingBeginRegex.test(nextLine)) {
37678                 break;
37679               }
37680               if (htmlBeginRegex.test(nextLine)) {
37681                 break;
37682               }
37683               if (nextBulletRegex.test(nextLine)) {
37684                 break;
37685               }
37686               if (hrRegex.test(nextLine)) {
37687                 break;
37688               }
37689               if (nextLineWithoutTabs.search(this.rules.other.nonSpaceChar) >= indent || !nextLine.trim()) {
37690                 itemContents += "\n" + nextLineWithoutTabs.slice(indent);
37691               } else {
37692                 if (blankLine) {
37693                   break;
37694                 }
37695                 if (line.replace(this.rules.other.tabCharGlobal, "    ").search(this.rules.other.nonSpaceChar) >= 4) {
37696                   break;
37697                 }
37698                 if (fencesBeginRegex.test(line)) {
37699                   break;
37700                 }
37701                 if (headingBeginRegex.test(line)) {
37702                   break;
37703                 }
37704                 if (hrRegex.test(line)) {
37705                   break;
37706                 }
37707                 itemContents += "\n" + nextLine;
37708               }
37709               if (!blankLine && !nextLine.trim()) {
37710                 blankLine = true;
37711               }
37712               raw += rawLine + "\n";
37713               src = src.substring(rawLine.length + 1);
37714               line = nextLineWithoutTabs.slice(indent);
37715             }
37716           }
37717           if (!list2.loose) {
37718             if (endsWithBlankLine) {
37719               list2.loose = true;
37720             } else if (this.rules.other.doubleBlankLine.test(raw)) {
37721               endsWithBlankLine = true;
37722             }
37723           }
37724           let istask = null;
37725           let ischecked;
37726           if (this.options.gfm) {
37727             istask = this.rules.other.listIsTask.exec(itemContents);
37728             if (istask) {
37729               ischecked = istask[0] !== "[ ] ";
37730               itemContents = itemContents.replace(this.rules.other.listReplaceTask, "");
37731             }
37732           }
37733           list2.items.push({
37734             type: "list_item",
37735             raw,
37736             task: !!istask,
37737             checked: ischecked,
37738             loose: false,
37739             text: itemContents,
37740             tokens: []
37741           });
37742           list2.raw += raw;
37743         }
37744         const lastItem = list2.items.at(-1);
37745         if (lastItem) {
37746           lastItem.raw = lastItem.raw.trimEnd();
37747           lastItem.text = lastItem.text.trimEnd();
37748         } else {
37749           return;
37750         }
37751         list2.raw = list2.raw.trimEnd();
37752         for (let i3 = 0; i3 < list2.items.length; i3++) {
37753           this.lexer.state.top = false;
37754           list2.items[i3].tokens = this.lexer.blockTokens(list2.items[i3].text, []);
37755           if (!list2.loose) {
37756             const spacers = list2.items[i3].tokens.filter((t2) => t2.type === "space");
37757             const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t2) => this.rules.other.anyLine.test(t2.raw));
37758             list2.loose = hasMultipleLineBreaks;
37759           }
37760         }
37761         if (list2.loose) {
37762           for (let i3 = 0; i3 < list2.items.length; i3++) {
37763             list2.items[i3].loose = true;
37764           }
37765         }
37766         return list2;
37767       }
37768     }
37769     html(src) {
37770       const cap = this.rules.block.html.exec(src);
37771       if (cap) {
37772         const token = {
37773           type: "html",
37774           block: true,
37775           raw: cap[0],
37776           pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
37777           text: cap[0]
37778         };
37779         return token;
37780       }
37781     }
37782     def(src) {
37783       const cap = this.rules.block.def.exec(src);
37784       if (cap) {
37785         const tag2 = cap[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal, " ");
37786         const href = cap[2] ? cap[2].replace(this.rules.other.hrefBrackets, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
37787         const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
37788         return {
37789           type: "def",
37790           tag: tag2,
37791           raw: cap[0],
37792           href,
37793           title
37794         };
37795       }
37796     }
37797     table(src) {
37798       var _a4;
37799       const cap = this.rules.block.table.exec(src);
37800       if (!cap) {
37801         return;
37802       }
37803       if (!this.rules.other.tableDelimiter.test(cap[2])) {
37804         return;
37805       }
37806       const headers = splitCells(cap[1]);
37807       const aligns = cap[2].replace(this.rules.other.tableAlignChars, "").split("|");
37808       const rows = ((_a4 = cap[3]) == null ? void 0 : _a4.trim()) ? cap[3].replace(this.rules.other.tableRowBlankLine, "").split("\n") : [];
37809       const item = {
37810         type: "table",
37811         raw: cap[0],
37812         header: [],
37813         align: [],
37814         rows: []
37815       };
37816       if (headers.length !== aligns.length) {
37817         return;
37818       }
37819       for (const align of aligns) {
37820         if (this.rules.other.tableAlignRight.test(align)) {
37821           item.align.push("right");
37822         } else if (this.rules.other.tableAlignCenter.test(align)) {
37823           item.align.push("center");
37824         } else if (this.rules.other.tableAlignLeft.test(align)) {
37825           item.align.push("left");
37826         } else {
37827           item.align.push(null);
37828         }
37829       }
37830       for (let i3 = 0; i3 < headers.length; i3++) {
37831         item.header.push({
37832           text: headers[i3],
37833           tokens: this.lexer.inline(headers[i3]),
37834           header: true,
37835           align: item.align[i3]
37836         });
37837       }
37838       for (const row of rows) {
37839         item.rows.push(splitCells(row, item.header.length).map((cell, i3) => {
37840           return {
37841             text: cell,
37842             tokens: this.lexer.inline(cell),
37843             header: false,
37844             align: item.align[i3]
37845           };
37846         }));
37847       }
37848       return item;
37849     }
37850     lheading(src) {
37851       const cap = this.rules.block.lheading.exec(src);
37852       if (cap) {
37853         return {
37854           type: "heading",
37855           raw: cap[0],
37856           depth: cap[2].charAt(0) === "=" ? 1 : 2,
37857           text: cap[1],
37858           tokens: this.lexer.inline(cap[1])
37859         };
37860       }
37861     }
37862     paragraph(src) {
37863       const cap = this.rules.block.paragraph.exec(src);
37864       if (cap) {
37865         const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
37866         return {
37867           type: "paragraph",
37868           raw: cap[0],
37869           text,
37870           tokens: this.lexer.inline(text)
37871         };
37872       }
37873     }
37874     text(src) {
37875       const cap = this.rules.block.text.exec(src);
37876       if (cap) {
37877         return {
37878           type: "text",
37879           raw: cap[0],
37880           text: cap[0],
37881           tokens: this.lexer.inline(cap[0])
37882         };
37883       }
37884     }
37885     escape(src) {
37886       const cap = this.rules.inline.escape.exec(src);
37887       if (cap) {
37888         return {
37889           type: "escape",
37890           raw: cap[0],
37891           text: cap[1]
37892         };
37893       }
37894     }
37895     tag(src) {
37896       const cap = this.rules.inline.tag.exec(src);
37897       if (cap) {
37898         if (!this.lexer.state.inLink && this.rules.other.startATag.test(cap[0])) {
37899           this.lexer.state.inLink = true;
37900         } else if (this.lexer.state.inLink && this.rules.other.endATag.test(cap[0])) {
37901           this.lexer.state.inLink = false;
37902         }
37903         if (!this.lexer.state.inRawBlock && this.rules.other.startPreScriptTag.test(cap[0])) {
37904           this.lexer.state.inRawBlock = true;
37905         } else if (this.lexer.state.inRawBlock && this.rules.other.endPreScriptTag.test(cap[0])) {
37906           this.lexer.state.inRawBlock = false;
37907         }
37908         return {
37909           type: "html",
37910           raw: cap[0],
37911           inLink: this.lexer.state.inLink,
37912           inRawBlock: this.lexer.state.inRawBlock,
37913           block: false,
37914           text: cap[0]
37915         };
37916       }
37917     }
37918     link(src) {
37919       const cap = this.rules.inline.link.exec(src);
37920       if (cap) {
37921         const trimmedUrl = cap[2].trim();
37922         if (!this.options.pedantic && this.rules.other.startAngleBracket.test(trimmedUrl)) {
37923           if (!this.rules.other.endAngleBracket.test(trimmedUrl)) {
37924             return;
37925           }
37926           const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
37927           if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
37928             return;
37929           }
37930         } else {
37931           const lastParenIndex = findClosingBracket(cap[2], "()");
37932           if (lastParenIndex > -1) {
37933             const start2 = cap[0].indexOf("!") === 0 ? 5 : 4;
37934             const linkLen = start2 + cap[1].length + lastParenIndex;
37935             cap[2] = cap[2].substring(0, lastParenIndex);
37936             cap[0] = cap[0].substring(0, linkLen).trim();
37937             cap[3] = "";
37938           }
37939         }
37940         let href = cap[2];
37941         let title = "";
37942         if (this.options.pedantic) {
37943           const link3 = this.rules.other.pedanticHrefTitle.exec(href);
37944           if (link3) {
37945             href = link3[1];
37946             title = link3[3];
37947           }
37948         } else {
37949           title = cap[3] ? cap[3].slice(1, -1) : "";
37950         }
37951         href = href.trim();
37952         if (this.rules.other.startAngleBracket.test(href)) {
37953           if (this.options.pedantic && !this.rules.other.endAngleBracket.test(trimmedUrl)) {
37954             href = href.slice(1);
37955           } else {
37956             href = href.slice(1, -1);
37957           }
37958         }
37959         return outputLink(cap, {
37960           href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
37961           title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
37962         }, cap[0], this.lexer, this.rules);
37963       }
37964     }
37965     reflink(src, links) {
37966       let cap;
37967       if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
37968         const linkString = (cap[2] || cap[1]).replace(this.rules.other.multipleSpaceGlobal, " ");
37969         const link3 = links[linkString.toLowerCase()];
37970         if (!link3) {
37971           const text = cap[0].charAt(0);
37972           return {
37973             type: "text",
37974             raw: text,
37975             text
37976           };
37977         }
37978         return outputLink(cap, link3, cap[0], this.lexer, this.rules);
37979       }
37980     }
37981     emStrong(src, maskedSrc, prevChar = "") {
37982       let match = this.rules.inline.emStrongLDelim.exec(src);
37983       if (!match)
37984         return;
37985       if (match[3] && prevChar.match(this.rules.other.unicodeAlphaNumeric))
37986         return;
37987       const nextChar = match[1] || match[2] || "";
37988       if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
37989         const lLength = [...match[0]].length - 1;
37990         let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
37991         const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
37992         endReg.lastIndex = 0;
37993         maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
37994         while ((match = endReg.exec(maskedSrc)) != null) {
37995           rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
37996           if (!rDelim)
37997             continue;
37998           rLength = [...rDelim].length;
37999           if (match[3] || match[4]) {
38000             delimTotal += rLength;
38001             continue;
38002           } else if (match[5] || match[6]) {
38003             if (lLength % 3 && !((lLength + rLength) % 3)) {
38004               midDelimTotal += rLength;
38005               continue;
38006             }
38007           }
38008           delimTotal -= rLength;
38009           if (delimTotal > 0)
38010             continue;
38011           rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
38012           const lastCharLength = [...match[0]][0].length;
38013           const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
38014           if (Math.min(lLength, rLength) % 2) {
38015             const text2 = raw.slice(1, -1);
38016             return {
38017               type: "em",
38018               raw,
38019               text: text2,
38020               tokens: this.lexer.inlineTokens(text2)
38021             };
38022           }
38023           const text = raw.slice(2, -2);
38024           return {
38025             type: "strong",
38026             raw,
38027             text,
38028             tokens: this.lexer.inlineTokens(text)
38029           };
38030         }
38031       }
38032     }
38033     codespan(src) {
38034       const cap = this.rules.inline.code.exec(src);
38035       if (cap) {
38036         let text = cap[2].replace(this.rules.other.newLineCharGlobal, " ");
38037         const hasNonSpaceChars = this.rules.other.nonSpaceChar.test(text);
38038         const hasSpaceCharsOnBothEnds = this.rules.other.startingSpaceChar.test(text) && this.rules.other.endingSpaceChar.test(text);
38039         if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
38040           text = text.substring(1, text.length - 1);
38041         }
38042         return {
38043           type: "codespan",
38044           raw: cap[0],
38045           text
38046         };
38047       }
38048     }
38049     br(src) {
38050       const cap = this.rules.inline.br.exec(src);
38051       if (cap) {
38052         return {
38053           type: "br",
38054           raw: cap[0]
38055         };
38056       }
38057     }
38058     del(src) {
38059       const cap = this.rules.inline.del.exec(src);
38060       if (cap) {
38061         return {
38062           type: "del",
38063           raw: cap[0],
38064           text: cap[2],
38065           tokens: this.lexer.inlineTokens(cap[2])
38066         };
38067       }
38068     }
38069     autolink(src) {
38070       const cap = this.rules.inline.autolink.exec(src);
38071       if (cap) {
38072         let text, href;
38073         if (cap[2] === "@") {
38074           text = cap[1];
38075           href = "mailto:" + text;
38076         } else {
38077           text = cap[1];
38078           href = text;
38079         }
38080         return {
38081           type: "link",
38082           raw: cap[0],
38083           text,
38084           href,
38085           tokens: [
38086             {
38087               type: "text",
38088               raw: text,
38089               text
38090             }
38091           ]
38092         };
38093       }
38094     }
38095     url(src) {
38096       var _a4, _b3;
38097       let cap;
38098       if (cap = this.rules.inline.url.exec(src)) {
38099         let text, href;
38100         if (cap[2] === "@") {
38101           text = cap[0];
38102           href = "mailto:" + text;
38103         } else {
38104           let prevCapZero;
38105           do {
38106             prevCapZero = cap[0];
38107             cap[0] = (_b3 = (_a4 = this.rules.inline._backpedal.exec(cap[0])) == null ? void 0 : _a4[0]) != null ? _b3 : "";
38108           } while (prevCapZero !== cap[0]);
38109           text = cap[0];
38110           if (cap[1] === "www.") {
38111             href = "http://" + cap[0];
38112           } else {
38113             href = cap[0];
38114           }
38115         }
38116         return {
38117           type: "link",
38118           raw: cap[0],
38119           text,
38120           href,
38121           tokens: [
38122             {
38123               type: "text",
38124               raw: text,
38125               text
38126             }
38127           ]
38128         };
38129       }
38130     }
38131     inlineText(src) {
38132       const cap = this.rules.inline.text.exec(src);
38133       if (cap) {
38134         const escaped = this.lexer.state.inRawBlock;
38135         return {
38136           type: "text",
38137           raw: cap[0],
38138           text: cap[0],
38139           escaped
38140         };
38141       }
38142     }
38143   };
38144   var _Lexer = class __Lexer {
38145     constructor(options2) {
38146       __publicField(this, "tokens");
38147       __publicField(this, "options");
38148       __publicField(this, "state");
38149       __publicField(this, "tokenizer");
38150       __publicField(this, "inlineQueue");
38151       this.tokens = [];
38152       this.tokens.links = /* @__PURE__ */ Object.create(null);
38153       this.options = options2 || _defaults;
38154       this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
38155       this.tokenizer = this.options.tokenizer;
38156       this.tokenizer.options = this.options;
38157       this.tokenizer.lexer = this;
38158       this.inlineQueue = [];
38159       this.state = {
38160         inLink: false,
38161         inRawBlock: false,
38162         top: true
38163       };
38164       const rules = {
38165         other,
38166         block: block.normal,
38167         inline: inline.normal
38168       };
38169       if (this.options.pedantic) {
38170         rules.block = block.pedantic;
38171         rules.inline = inline.pedantic;
38172       } else if (this.options.gfm) {
38173         rules.block = block.gfm;
38174         if (this.options.breaks) {
38175           rules.inline = inline.breaks;
38176         } else {
38177           rules.inline = inline.gfm;
38178         }
38179       }
38180       this.tokenizer.rules = rules;
38181     }
38182     /**
38183      * Expose Rules
38184      */
38185     static get rules() {
38186       return {
38187         block,
38188         inline
38189       };
38190     }
38191     /**
38192      * Static Lex Method
38193      */
38194     static lex(src, options2) {
38195       const lexer2 = new __Lexer(options2);
38196       return lexer2.lex(src);
38197     }
38198     /**
38199      * Static Lex Inline Method
38200      */
38201     static lexInline(src, options2) {
38202       const lexer2 = new __Lexer(options2);
38203       return lexer2.inlineTokens(src);
38204     }
38205     /**
38206      * Preprocessing
38207      */
38208     lex(src) {
38209       src = src.replace(other.carriageReturn, "\n");
38210       this.blockTokens(src, this.tokens);
38211       for (let i3 = 0; i3 < this.inlineQueue.length; i3++) {
38212         const next = this.inlineQueue[i3];
38213         this.inlineTokens(next.src, next.tokens);
38214       }
38215       this.inlineQueue = [];
38216       return this.tokens;
38217     }
38218     blockTokens(src, tokens = [], lastParagraphClipped = false) {
38219       var _a4, _b3, _c2;
38220       if (this.options.pedantic) {
38221         src = src.replace(other.tabCharGlobal, "    ").replace(other.spaceLine, "");
38222       }
38223       while (src) {
38224         let token;
38225         if ((_b3 = (_a4 = this.options.extensions) == null ? void 0 : _a4.block) == null ? void 0 : _b3.some((extTokenizer) => {
38226           if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
38227             src = src.substring(token.raw.length);
38228             tokens.push(token);
38229             return true;
38230           }
38231           return false;
38232         })) {
38233           continue;
38234         }
38235         if (token = this.tokenizer.space(src)) {
38236           src = src.substring(token.raw.length);
38237           const lastToken = tokens.at(-1);
38238           if (token.raw.length === 1 && lastToken !== void 0) {
38239             lastToken.raw += "\n";
38240           } else {
38241             tokens.push(token);
38242           }
38243           continue;
38244         }
38245         if (token = this.tokenizer.code(src)) {
38246           src = src.substring(token.raw.length);
38247           const lastToken = tokens.at(-1);
38248           if ((lastToken == null ? void 0 : lastToken.type) === "paragraph" || (lastToken == null ? void 0 : lastToken.type) === "text") {
38249             lastToken.raw += "\n" + token.raw;
38250             lastToken.text += "\n" + token.text;
38251             this.inlineQueue.at(-1).src = lastToken.text;
38252           } else {
38253             tokens.push(token);
38254           }
38255           continue;
38256         }
38257         if (token = this.tokenizer.fences(src)) {
38258           src = src.substring(token.raw.length);
38259           tokens.push(token);
38260           continue;
38261         }
38262         if (token = this.tokenizer.heading(src)) {
38263           src = src.substring(token.raw.length);
38264           tokens.push(token);
38265           continue;
38266         }
38267         if (token = this.tokenizer.hr(src)) {
38268           src = src.substring(token.raw.length);
38269           tokens.push(token);
38270           continue;
38271         }
38272         if (token = this.tokenizer.blockquote(src)) {
38273           src = src.substring(token.raw.length);
38274           tokens.push(token);
38275           continue;
38276         }
38277         if (token = this.tokenizer.list(src)) {
38278           src = src.substring(token.raw.length);
38279           tokens.push(token);
38280           continue;
38281         }
38282         if (token = this.tokenizer.html(src)) {
38283           src = src.substring(token.raw.length);
38284           tokens.push(token);
38285           continue;
38286         }
38287         if (token = this.tokenizer.def(src)) {
38288           src = src.substring(token.raw.length);
38289           const lastToken = tokens.at(-1);
38290           if ((lastToken == null ? void 0 : lastToken.type) === "paragraph" || (lastToken == null ? void 0 : lastToken.type) === "text") {
38291             lastToken.raw += "\n" + token.raw;
38292             lastToken.text += "\n" + token.raw;
38293             this.inlineQueue.at(-1).src = lastToken.text;
38294           } else if (!this.tokens.links[token.tag]) {
38295             this.tokens.links[token.tag] = {
38296               href: token.href,
38297               title: token.title
38298             };
38299           }
38300           continue;
38301         }
38302         if (token = this.tokenizer.table(src)) {
38303           src = src.substring(token.raw.length);
38304           tokens.push(token);
38305           continue;
38306         }
38307         if (token = this.tokenizer.lheading(src)) {
38308           src = src.substring(token.raw.length);
38309           tokens.push(token);
38310           continue;
38311         }
38312         let cutSrc = src;
38313         if ((_c2 = this.options.extensions) == null ? void 0 : _c2.startBlock) {
38314           let startIndex = Infinity;
38315           const tempSrc = src.slice(1);
38316           let tempStart;
38317           this.options.extensions.startBlock.forEach((getStartIndex) => {
38318             tempStart = getStartIndex.call({ lexer: this }, tempSrc);
38319             if (typeof tempStart === "number" && tempStart >= 0) {
38320               startIndex = Math.min(startIndex, tempStart);
38321             }
38322           });
38323           if (startIndex < Infinity && startIndex >= 0) {
38324             cutSrc = src.substring(0, startIndex + 1);
38325           }
38326         }
38327         if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
38328           const lastToken = tokens.at(-1);
38329           if (lastParagraphClipped && (lastToken == null ? void 0 : lastToken.type) === "paragraph") {
38330             lastToken.raw += "\n" + token.raw;
38331             lastToken.text += "\n" + token.text;
38332             this.inlineQueue.pop();
38333             this.inlineQueue.at(-1).src = lastToken.text;
38334           } else {
38335             tokens.push(token);
38336           }
38337           lastParagraphClipped = cutSrc.length !== src.length;
38338           src = src.substring(token.raw.length);
38339           continue;
38340         }
38341         if (token = this.tokenizer.text(src)) {
38342           src = src.substring(token.raw.length);
38343           const lastToken = tokens.at(-1);
38344           if ((lastToken == null ? void 0 : lastToken.type) === "text") {
38345             lastToken.raw += "\n" + token.raw;
38346             lastToken.text += "\n" + token.text;
38347             this.inlineQueue.pop();
38348             this.inlineQueue.at(-1).src = lastToken.text;
38349           } else {
38350             tokens.push(token);
38351           }
38352           continue;
38353         }
38354         if (src) {
38355           const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
38356           if (this.options.silent) {
38357             console.error(errMsg);
38358             break;
38359           } else {
38360             throw new Error(errMsg);
38361           }
38362         }
38363       }
38364       this.state.top = true;
38365       return tokens;
38366     }
38367     inline(src, tokens = []) {
38368       this.inlineQueue.push({ src, tokens });
38369       return tokens;
38370     }
38371     /**
38372      * Lexing/Compiling
38373      */
38374     inlineTokens(src, tokens = []) {
38375       var _a4, _b3, _c2;
38376       let maskedSrc = src;
38377       let match = null;
38378       if (this.tokens.links) {
38379         const links = Object.keys(this.tokens.links);
38380         if (links.length > 0) {
38381           while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
38382             if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
38383               maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
38384             }
38385           }
38386         }
38387       }
38388       while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
38389         maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
38390       }
38391       while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
38392         maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
38393       }
38394       let keepPrevChar = false;
38395       let prevChar = "";
38396       while (src) {
38397         if (!keepPrevChar) {
38398           prevChar = "";
38399         }
38400         keepPrevChar = false;
38401         let token;
38402         if ((_b3 = (_a4 = this.options.extensions) == null ? void 0 : _a4.inline) == null ? void 0 : _b3.some((extTokenizer) => {
38403           if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
38404             src = src.substring(token.raw.length);
38405             tokens.push(token);
38406             return true;
38407           }
38408           return false;
38409         })) {
38410           continue;
38411         }
38412         if (token = this.tokenizer.escape(src)) {
38413           src = src.substring(token.raw.length);
38414           tokens.push(token);
38415           continue;
38416         }
38417         if (token = this.tokenizer.tag(src)) {
38418           src = src.substring(token.raw.length);
38419           tokens.push(token);
38420           continue;
38421         }
38422         if (token = this.tokenizer.link(src)) {
38423           src = src.substring(token.raw.length);
38424           tokens.push(token);
38425           continue;
38426         }
38427         if (token = this.tokenizer.reflink(src, this.tokens.links)) {
38428           src = src.substring(token.raw.length);
38429           const lastToken = tokens.at(-1);
38430           if (token.type === "text" && (lastToken == null ? void 0 : lastToken.type) === "text") {
38431             lastToken.raw += token.raw;
38432             lastToken.text += token.text;
38433           } else {
38434             tokens.push(token);
38435           }
38436           continue;
38437         }
38438         if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
38439           src = src.substring(token.raw.length);
38440           tokens.push(token);
38441           continue;
38442         }
38443         if (token = this.tokenizer.codespan(src)) {
38444           src = src.substring(token.raw.length);
38445           tokens.push(token);
38446           continue;
38447         }
38448         if (token = this.tokenizer.br(src)) {
38449           src = src.substring(token.raw.length);
38450           tokens.push(token);
38451           continue;
38452         }
38453         if (token = this.tokenizer.del(src)) {
38454           src = src.substring(token.raw.length);
38455           tokens.push(token);
38456           continue;
38457         }
38458         if (token = this.tokenizer.autolink(src)) {
38459           src = src.substring(token.raw.length);
38460           tokens.push(token);
38461           continue;
38462         }
38463         if (!this.state.inLink && (token = this.tokenizer.url(src))) {
38464           src = src.substring(token.raw.length);
38465           tokens.push(token);
38466           continue;
38467         }
38468         let cutSrc = src;
38469         if ((_c2 = this.options.extensions) == null ? void 0 : _c2.startInline) {
38470           let startIndex = Infinity;
38471           const tempSrc = src.slice(1);
38472           let tempStart;
38473           this.options.extensions.startInline.forEach((getStartIndex) => {
38474             tempStart = getStartIndex.call({ lexer: this }, tempSrc);
38475             if (typeof tempStart === "number" && tempStart >= 0) {
38476               startIndex = Math.min(startIndex, tempStart);
38477             }
38478           });
38479           if (startIndex < Infinity && startIndex >= 0) {
38480             cutSrc = src.substring(0, startIndex + 1);
38481           }
38482         }
38483         if (token = this.tokenizer.inlineText(cutSrc)) {
38484           src = src.substring(token.raw.length);
38485           if (token.raw.slice(-1) !== "_") {
38486             prevChar = token.raw.slice(-1);
38487           }
38488           keepPrevChar = true;
38489           const lastToken = tokens.at(-1);
38490           if ((lastToken == null ? void 0 : lastToken.type) === "text") {
38491             lastToken.raw += token.raw;
38492             lastToken.text += token.text;
38493           } else {
38494             tokens.push(token);
38495           }
38496           continue;
38497         }
38498         if (src) {
38499           const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
38500           if (this.options.silent) {
38501             console.error(errMsg);
38502             break;
38503           } else {
38504             throw new Error(errMsg);
38505           }
38506         }
38507       }
38508       return tokens;
38509     }
38510   };
38511   var _Renderer = class {
38512     // set by the parser
38513     constructor(options2) {
38514       __publicField(this, "options");
38515       __publicField(this, "parser");
38516       this.options = options2 || _defaults;
38517     }
38518     space(token) {
38519       return "";
38520     }
38521     code({ text, lang, escaped }) {
38522       var _a4;
38523       const langString = (_a4 = (lang || "").match(other.notSpaceStart)) == null ? void 0 : _a4[0];
38524       const code = text.replace(other.endingNewline, "") + "\n";
38525       if (!langString) {
38526         return "<pre><code>" + (escaped ? code : escape4(code, true)) + "</code></pre>\n";
38527       }
38528       return '<pre><code class="language-' + escape4(langString) + '">' + (escaped ? code : escape4(code, true)) + "</code></pre>\n";
38529     }
38530     blockquote({ tokens }) {
38531       const body = this.parser.parse(tokens);
38532       return "<blockquote>\n".concat(body, "</blockquote>\n");
38533     }
38534     html({ text }) {
38535       return text;
38536     }
38537     heading({ tokens, depth }) {
38538       return "<h".concat(depth, ">").concat(this.parser.parseInline(tokens), "</h").concat(depth, ">\n");
38539     }
38540     hr(token) {
38541       return "<hr>\n";
38542     }
38543     list(token) {
38544       const ordered = token.ordered;
38545       const start2 = token.start;
38546       let body = "";
38547       for (let j2 = 0; j2 < token.items.length; j2++) {
38548         const item = token.items[j2];
38549         body += this.listitem(item);
38550       }
38551       const type2 = ordered ? "ol" : "ul";
38552       const startAttr = ordered && start2 !== 1 ? ' start="' + start2 + '"' : "";
38553       return "<" + type2 + startAttr + ">\n" + body + "</" + type2 + ">\n";
38554     }
38555     listitem(item) {
38556       var _a4;
38557       let itemBody = "";
38558       if (item.task) {
38559         const checkbox = this.checkbox({ checked: !!item.checked });
38560         if (item.loose) {
38561           if (((_a4 = item.tokens[0]) == null ? void 0 : _a4.type) === "paragraph") {
38562             item.tokens[0].text = checkbox + " " + item.tokens[0].text;
38563             if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
38564               item.tokens[0].tokens[0].text = checkbox + " " + escape4(item.tokens[0].tokens[0].text);
38565               item.tokens[0].tokens[0].escaped = true;
38566             }
38567           } else {
38568             item.tokens.unshift({
38569               type: "text",
38570               raw: checkbox + " ",
38571               text: checkbox + " ",
38572               escaped: true
38573             });
38574           }
38575         } else {
38576           itemBody += checkbox + " ";
38577         }
38578       }
38579       itemBody += this.parser.parse(item.tokens, !!item.loose);
38580       return "<li>".concat(itemBody, "</li>\n");
38581     }
38582     checkbox({ checked }) {
38583       return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
38584     }
38585     paragraph({ tokens }) {
38586       return "<p>".concat(this.parser.parseInline(tokens), "</p>\n");
38587     }
38588     table(token) {
38589       let header = "";
38590       let cell = "";
38591       for (let j2 = 0; j2 < token.header.length; j2++) {
38592         cell += this.tablecell(token.header[j2]);
38593       }
38594       header += this.tablerow({ text: cell });
38595       let body = "";
38596       for (let j2 = 0; j2 < token.rows.length; j2++) {
38597         const row = token.rows[j2];
38598         cell = "";
38599         for (let k2 = 0; k2 < row.length; k2++) {
38600           cell += this.tablecell(row[k2]);
38601         }
38602         body += this.tablerow({ text: cell });
38603       }
38604       if (body)
38605         body = "<tbody>".concat(body, "</tbody>");
38606       return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
38607     }
38608     tablerow({ text }) {
38609       return "<tr>\n".concat(text, "</tr>\n");
38610     }
38611     tablecell(token) {
38612       const content = this.parser.parseInline(token.tokens);
38613       const type2 = token.header ? "th" : "td";
38614       const tag2 = token.align ? "<".concat(type2, ' align="').concat(token.align, '">') : "<".concat(type2, ">");
38615       return tag2 + content + "</".concat(type2, ">\n");
38616     }
38617     /**
38618      * span level renderer
38619      */
38620     strong({ tokens }) {
38621       return "<strong>".concat(this.parser.parseInline(tokens), "</strong>");
38622     }
38623     em({ tokens }) {
38624       return "<em>".concat(this.parser.parseInline(tokens), "</em>");
38625     }
38626     codespan({ text }) {
38627       return "<code>".concat(escape4(text, true), "</code>");
38628     }
38629     br(token) {
38630       return "<br>";
38631     }
38632     del({ tokens }) {
38633       return "<del>".concat(this.parser.parseInline(tokens), "</del>");
38634     }
38635     link({ href, title, tokens }) {
38636       const text = this.parser.parseInline(tokens);
38637       const cleanHref = cleanUrl(href);
38638       if (cleanHref === null) {
38639         return text;
38640       }
38641       href = cleanHref;
38642       let out = '<a href="' + href + '"';
38643       if (title) {
38644         out += ' title="' + escape4(title) + '"';
38645       }
38646       out += ">" + text + "</a>";
38647       return out;
38648     }
38649     image({ href, title, text }) {
38650       const cleanHref = cleanUrl(href);
38651       if (cleanHref === null) {
38652         return escape4(text);
38653       }
38654       href = cleanHref;
38655       let out = '<img src="'.concat(href, '" alt="').concat(text, '"');
38656       if (title) {
38657         out += ' title="'.concat(escape4(title), '"');
38658       }
38659       out += ">";
38660       return out;
38661     }
38662     text(token) {
38663       return "tokens" in token && token.tokens ? this.parser.parseInline(token.tokens) : "escaped" in token && token.escaped ? token.text : escape4(token.text);
38664     }
38665   };
38666   var _TextRenderer = class {
38667     // no need for block level renderers
38668     strong({ text }) {
38669       return text;
38670     }
38671     em({ text }) {
38672       return text;
38673     }
38674     codespan({ text }) {
38675       return text;
38676     }
38677     del({ text }) {
38678       return text;
38679     }
38680     html({ text }) {
38681       return text;
38682     }
38683     text({ text }) {
38684       return text;
38685     }
38686     link({ text }) {
38687       return "" + text;
38688     }
38689     image({ text }) {
38690       return "" + text;
38691     }
38692     br() {
38693       return "";
38694     }
38695   };
38696   var _Parser = class __Parser {
38697     constructor(options2) {
38698       __publicField(this, "options");
38699       __publicField(this, "renderer");
38700       __publicField(this, "textRenderer");
38701       this.options = options2 || _defaults;
38702       this.options.renderer = this.options.renderer || new _Renderer();
38703       this.renderer = this.options.renderer;
38704       this.renderer.options = this.options;
38705       this.renderer.parser = this;
38706       this.textRenderer = new _TextRenderer();
38707     }
38708     /**
38709      * Static Parse Method
38710      */
38711     static parse(tokens, options2) {
38712       const parser3 = new __Parser(options2);
38713       return parser3.parse(tokens);
38714     }
38715     /**
38716      * Static Parse Inline Method
38717      */
38718     static parseInline(tokens, options2) {
38719       const parser3 = new __Parser(options2);
38720       return parser3.parseInline(tokens);
38721     }
38722     /**
38723      * Parse Loop
38724      */
38725     parse(tokens, top = true) {
38726       var _a4, _b3;
38727       let out = "";
38728       for (let i3 = 0; i3 < tokens.length; i3++) {
38729         const anyToken = tokens[i3];
38730         if ((_b3 = (_a4 = this.options.extensions) == null ? void 0 : _a4.renderers) == null ? void 0 : _b3[anyToken.type]) {
38731           const genericToken = anyToken;
38732           const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
38733           if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
38734             out += ret || "";
38735             continue;
38736           }
38737         }
38738         const token = anyToken;
38739         switch (token.type) {
38740           case "space": {
38741             out += this.renderer.space(token);
38742             continue;
38743           }
38744           case "hr": {
38745             out += this.renderer.hr(token);
38746             continue;
38747           }
38748           case "heading": {
38749             out += this.renderer.heading(token);
38750             continue;
38751           }
38752           case "code": {
38753             out += this.renderer.code(token);
38754             continue;
38755           }
38756           case "table": {
38757             out += this.renderer.table(token);
38758             continue;
38759           }
38760           case "blockquote": {
38761             out += this.renderer.blockquote(token);
38762             continue;
38763           }
38764           case "list": {
38765             out += this.renderer.list(token);
38766             continue;
38767           }
38768           case "html": {
38769             out += this.renderer.html(token);
38770             continue;
38771           }
38772           case "paragraph": {
38773             out += this.renderer.paragraph(token);
38774             continue;
38775           }
38776           case "text": {
38777             let textToken = token;
38778             let body = this.renderer.text(textToken);
38779             while (i3 + 1 < tokens.length && tokens[i3 + 1].type === "text") {
38780               textToken = tokens[++i3];
38781               body += "\n" + this.renderer.text(textToken);
38782             }
38783             if (top) {
38784               out += this.renderer.paragraph({
38785                 type: "paragraph",
38786                 raw: body,
38787                 text: body,
38788                 tokens: [{ type: "text", raw: body, text: body, escaped: true }]
38789               });
38790             } else {
38791               out += body;
38792             }
38793             continue;
38794           }
38795           default: {
38796             const errMsg = 'Token with "' + token.type + '" type was not found.';
38797             if (this.options.silent) {
38798               console.error(errMsg);
38799               return "";
38800             } else {
38801               throw new Error(errMsg);
38802             }
38803           }
38804         }
38805       }
38806       return out;
38807     }
38808     /**
38809      * Parse Inline Tokens
38810      */
38811     parseInline(tokens, renderer = this.renderer) {
38812       var _a4, _b3;
38813       let out = "";
38814       for (let i3 = 0; i3 < tokens.length; i3++) {
38815         const anyToken = tokens[i3];
38816         if ((_b3 = (_a4 = this.options.extensions) == null ? void 0 : _a4.renderers) == null ? void 0 : _b3[anyToken.type]) {
38817           const ret = this.options.extensions.renderers[anyToken.type].call({ parser: this }, anyToken);
38818           if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(anyToken.type)) {
38819             out += ret || "";
38820             continue;
38821           }
38822         }
38823         const token = anyToken;
38824         switch (token.type) {
38825           case "escape": {
38826             out += renderer.text(token);
38827             break;
38828           }
38829           case "html": {
38830             out += renderer.html(token);
38831             break;
38832           }
38833           case "link": {
38834             out += renderer.link(token);
38835             break;
38836           }
38837           case "image": {
38838             out += renderer.image(token);
38839             break;
38840           }
38841           case "strong": {
38842             out += renderer.strong(token);
38843             break;
38844           }
38845           case "em": {
38846             out += renderer.em(token);
38847             break;
38848           }
38849           case "codespan": {
38850             out += renderer.codespan(token);
38851             break;
38852           }
38853           case "br": {
38854             out += renderer.br(token);
38855             break;
38856           }
38857           case "del": {
38858             out += renderer.del(token);
38859             break;
38860           }
38861           case "text": {
38862             out += renderer.text(token);
38863             break;
38864           }
38865           default: {
38866             const errMsg = 'Token with "' + token.type + '" type was not found.';
38867             if (this.options.silent) {
38868               console.error(errMsg);
38869               return "";
38870             } else {
38871               throw new Error(errMsg);
38872             }
38873           }
38874         }
38875       }
38876       return out;
38877     }
38878   };
38879   var _Hooks = class {
38880     constructor(options2) {
38881       __publicField(this, "options");
38882       __publicField(this, "block");
38883       this.options = options2 || _defaults;
38884     }
38885     /**
38886      * Process markdown before marked
38887      */
38888     preprocess(markdown) {
38889       return markdown;
38890     }
38891     /**
38892      * Process HTML after marked is finished
38893      */
38894     postprocess(html3) {
38895       return html3;
38896     }
38897     /**
38898      * Process all tokens before walk tokens
38899      */
38900     processAllTokens(tokens) {
38901       return tokens;
38902     }
38903     /**
38904      * Provide function to tokenize markdown
38905      */
38906     provideLexer() {
38907       return this.block ? _Lexer.lex : _Lexer.lexInline;
38908     }
38909     /**
38910      * Provide function to parse tokens
38911      */
38912     provideParser() {
38913       return this.block ? _Parser.parse : _Parser.parseInline;
38914     }
38915   };
38916   __publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
38917     "preprocess",
38918     "postprocess",
38919     "processAllTokens"
38920   ]));
38921   var Marked = class {
38922     constructor(...args) {
38923       __publicField(this, "defaults", _getDefaults());
38924       __publicField(this, "options", this.setOptions);
38925       __publicField(this, "parse", this.parseMarkdown(true));
38926       __publicField(this, "parseInline", this.parseMarkdown(false));
38927       __publicField(this, "Parser", _Parser);
38928       __publicField(this, "Renderer", _Renderer);
38929       __publicField(this, "TextRenderer", _TextRenderer);
38930       __publicField(this, "Lexer", _Lexer);
38931       __publicField(this, "Tokenizer", _Tokenizer);
38932       __publicField(this, "Hooks", _Hooks);
38933       this.use(...args);
38934     }
38935     /**
38936      * Run callback for every token
38937      */
38938     walkTokens(tokens, callback) {
38939       var _a4, _b3;
38940       let values = [];
38941       for (const token of tokens) {
38942         values = values.concat(callback.call(this, token));
38943         switch (token.type) {
38944           case "table": {
38945             const tableToken = token;
38946             for (const cell of tableToken.header) {
38947               values = values.concat(this.walkTokens(cell.tokens, callback));
38948             }
38949             for (const row of tableToken.rows) {
38950               for (const cell of row) {
38951                 values = values.concat(this.walkTokens(cell.tokens, callback));
38952               }
38953             }
38954             break;
38955           }
38956           case "list": {
38957             const listToken = token;
38958             values = values.concat(this.walkTokens(listToken.items, callback));
38959             break;
38960           }
38961           default: {
38962             const genericToken = token;
38963             if ((_b3 = (_a4 = this.defaults.extensions) == null ? void 0 : _a4.childTokens) == null ? void 0 : _b3[genericToken.type]) {
38964               this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
38965                 const tokens2 = genericToken[childTokens].flat(Infinity);
38966                 values = values.concat(this.walkTokens(tokens2, callback));
38967               });
38968             } else if (genericToken.tokens) {
38969               values = values.concat(this.walkTokens(genericToken.tokens, callback));
38970             }
38971           }
38972         }
38973       }
38974       return values;
38975     }
38976     use(...args) {
38977       const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
38978       args.forEach((pack) => {
38979         const opts = __spreadValues({}, pack);
38980         opts.async = this.defaults.async || opts.async || false;
38981         if (pack.extensions) {
38982           pack.extensions.forEach((ext) => {
38983             if (!ext.name) {
38984               throw new Error("extension name required");
38985             }
38986             if ("renderer" in ext) {
38987               const prevRenderer = extensions.renderers[ext.name];
38988               if (prevRenderer) {
38989                 extensions.renderers[ext.name] = function(...args2) {
38990                   let ret = ext.renderer.apply(this, args2);
38991                   if (ret === false) {
38992                     ret = prevRenderer.apply(this, args2);
38993                   }
38994                   return ret;
38995                 };
38996               } else {
38997                 extensions.renderers[ext.name] = ext.renderer;
38998               }
38999             }
39000             if ("tokenizer" in ext) {
39001               if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
39002                 throw new Error("extension level must be 'block' or 'inline'");
39003               }
39004               const extLevel = extensions[ext.level];
39005               if (extLevel) {
39006                 extLevel.unshift(ext.tokenizer);
39007               } else {
39008                 extensions[ext.level] = [ext.tokenizer];
39009               }
39010               if (ext.start) {
39011                 if (ext.level === "block") {
39012                   if (extensions.startBlock) {
39013                     extensions.startBlock.push(ext.start);
39014                   } else {
39015                     extensions.startBlock = [ext.start];
39016                   }
39017                 } else if (ext.level === "inline") {
39018                   if (extensions.startInline) {
39019                     extensions.startInline.push(ext.start);
39020                   } else {
39021                     extensions.startInline = [ext.start];
39022                   }
39023                 }
39024               }
39025             }
39026             if ("childTokens" in ext && ext.childTokens) {
39027               extensions.childTokens[ext.name] = ext.childTokens;
39028             }
39029           });
39030           opts.extensions = extensions;
39031         }
39032         if (pack.renderer) {
39033           const renderer = this.defaults.renderer || new _Renderer(this.defaults);
39034           for (const prop in pack.renderer) {
39035             if (!(prop in renderer)) {
39036               throw new Error("renderer '".concat(prop, "' does not exist"));
39037             }
39038             if (["options", "parser"].includes(prop)) {
39039               continue;
39040             }
39041             const rendererProp = prop;
39042             const rendererFunc = pack.renderer[rendererProp];
39043             const prevRenderer = renderer[rendererProp];
39044             renderer[rendererProp] = (...args2) => {
39045               let ret = rendererFunc.apply(renderer, args2);
39046               if (ret === false) {
39047                 ret = prevRenderer.apply(renderer, args2);
39048               }
39049               return ret || "";
39050             };
39051           }
39052           opts.renderer = renderer;
39053         }
39054         if (pack.tokenizer) {
39055           const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
39056           for (const prop in pack.tokenizer) {
39057             if (!(prop in tokenizer)) {
39058               throw new Error("tokenizer '".concat(prop, "' does not exist"));
39059             }
39060             if (["options", "rules", "lexer"].includes(prop)) {
39061               continue;
39062             }
39063             const tokenizerProp = prop;
39064             const tokenizerFunc = pack.tokenizer[tokenizerProp];
39065             const prevTokenizer = tokenizer[tokenizerProp];
39066             tokenizer[tokenizerProp] = (...args2) => {
39067               let ret = tokenizerFunc.apply(tokenizer, args2);
39068               if (ret === false) {
39069                 ret = prevTokenizer.apply(tokenizer, args2);
39070               }
39071               return ret;
39072             };
39073           }
39074           opts.tokenizer = tokenizer;
39075         }
39076         if (pack.hooks) {
39077           const hooks = this.defaults.hooks || new _Hooks();
39078           for (const prop in pack.hooks) {
39079             if (!(prop in hooks)) {
39080               throw new Error("hook '".concat(prop, "' does not exist"));
39081             }
39082             if (["options", "block"].includes(prop)) {
39083               continue;
39084             }
39085             const hooksProp = prop;
39086             const hooksFunc = pack.hooks[hooksProp];
39087             const prevHook = hooks[hooksProp];
39088             if (_Hooks.passThroughHooks.has(prop)) {
39089               hooks[hooksProp] = (arg) => {
39090                 if (this.defaults.async) {
39091                   return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
39092                     return prevHook.call(hooks, ret2);
39093                   });
39094                 }
39095                 const ret = hooksFunc.call(hooks, arg);
39096                 return prevHook.call(hooks, ret);
39097               };
39098             } else {
39099               hooks[hooksProp] = (...args2) => {
39100                 let ret = hooksFunc.apply(hooks, args2);
39101                 if (ret === false) {
39102                   ret = prevHook.apply(hooks, args2);
39103                 }
39104                 return ret;
39105               };
39106             }
39107           }
39108           opts.hooks = hooks;
39109         }
39110         if (pack.walkTokens) {
39111           const walkTokens2 = this.defaults.walkTokens;
39112           const packWalktokens = pack.walkTokens;
39113           opts.walkTokens = function(token) {
39114             let values = [];
39115             values.push(packWalktokens.call(this, token));
39116             if (walkTokens2) {
39117               values = values.concat(walkTokens2.call(this, token));
39118             }
39119             return values;
39120           };
39121         }
39122         this.defaults = __spreadValues(__spreadValues({}, this.defaults), opts);
39123       });
39124       return this;
39125     }
39126     setOptions(opt) {
39127       this.defaults = __spreadValues(__spreadValues({}, this.defaults), opt);
39128       return this;
39129     }
39130     lexer(src, options2) {
39131       return _Lexer.lex(src, options2 != null ? options2 : this.defaults);
39132     }
39133     parser(tokens, options2) {
39134       return _Parser.parse(tokens, options2 != null ? options2 : this.defaults);
39135     }
39136     parseMarkdown(blockType) {
39137       const parse = (src, options2) => {
39138         const origOpt = __spreadValues({}, options2);
39139         const opt = __spreadValues(__spreadValues({}, this.defaults), origOpt);
39140         const throwError = this.onError(!!opt.silent, !!opt.async);
39141         if (this.defaults.async === true && origOpt.async === false) {
39142           return throwError(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));
39143         }
39144         if (typeof src === "undefined" || src === null) {
39145           return throwError(new Error("marked(): input parameter is undefined or null"));
39146         }
39147         if (typeof src !== "string") {
39148           return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
39149         }
39150         if (opt.hooks) {
39151           opt.hooks.options = opt;
39152           opt.hooks.block = blockType;
39153         }
39154         const lexer2 = opt.hooks ? opt.hooks.provideLexer() : blockType ? _Lexer.lex : _Lexer.lexInline;
39155         const parser3 = opt.hooks ? opt.hooks.provideParser() : blockType ? _Parser.parse : _Parser.parseInline;
39156         if (opt.async) {
39157           return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser3(tokens, opt)).then((html3) => opt.hooks ? opt.hooks.postprocess(html3) : html3).catch(throwError);
39158         }
39159         try {
39160           if (opt.hooks) {
39161             src = opt.hooks.preprocess(src);
39162           }
39163           let tokens = lexer2(src, opt);
39164           if (opt.hooks) {
39165             tokens = opt.hooks.processAllTokens(tokens);
39166           }
39167           if (opt.walkTokens) {
39168             this.walkTokens(tokens, opt.walkTokens);
39169           }
39170           let html3 = parser3(tokens, opt);
39171           if (opt.hooks) {
39172             html3 = opt.hooks.postprocess(html3);
39173           }
39174           return html3;
39175         } catch (e3) {
39176           return throwError(e3);
39177         }
39178       };
39179       return parse;
39180     }
39181     onError(silent, async) {
39182       return (e3) => {
39183         e3.message += "\nPlease report this to https://github.com/markedjs/marked.";
39184         if (silent) {
39185           const msg = "<p>An error occurred:</p><pre>" + escape4(e3.message + "", true) + "</pre>";
39186           if (async) {
39187             return Promise.resolve(msg);
39188           }
39189           return msg;
39190         }
39191         if (async) {
39192           return Promise.reject(e3);
39193         }
39194         throw e3;
39195       };
39196     }
39197   };
39198   var markedInstance = new Marked();
39199   function marked(src, opt) {
39200     return markedInstance.parse(src, opt);
39201   }
39202   marked.options = marked.setOptions = function(options2) {
39203     markedInstance.setOptions(options2);
39204     marked.defaults = markedInstance.defaults;
39205     changeDefaults(marked.defaults);
39206     return marked;
39207   };
39208   marked.getDefaults = _getDefaults;
39209   marked.defaults = _defaults;
39210   marked.use = function(...args) {
39211     markedInstance.use(...args);
39212     marked.defaults = markedInstance.defaults;
39213     changeDefaults(marked.defaults);
39214     return marked;
39215   };
39216   marked.walkTokens = function(tokens, callback) {
39217     return markedInstance.walkTokens(tokens, callback);
39218   };
39219   marked.parseInline = markedInstance.parseInline;
39220   marked.Parser = _Parser;
39221   marked.parser = _Parser.parse;
39222   marked.Renderer = _Renderer;
39223   marked.TextRenderer = _TextRenderer;
39224   marked.Lexer = _Lexer;
39225   marked.lexer = _Lexer.lex;
39226   marked.Tokenizer = _Tokenizer;
39227   marked.Hooks = _Hooks;
39228   marked.parse = marked;
39229   var options = marked.options;
39230   var setOptions = marked.setOptions;
39231   var use = marked.use;
39232   var walkTokens = marked.walkTokens;
39233   var parseInline = marked.parseInline;
39234   var parser2 = _Parser.parse;
39235   var lexer = _Lexer.lex;
39236
39237   // modules/services/osmose.js
39238   var tiler2 = utilTiler();
39239   var dispatch3 = dispatch_default("loaded");
39240   var _tileZoom2 = 14;
39241   var _osmoseUrlRoot = "https://osmose.openstreetmap.fr/api/0.3";
39242   var _osmoseData = { icons: {}, items: [] };
39243   var _cache2;
39244   function abortRequest2(controller) {
39245     if (controller) {
39246       controller.abort();
39247     }
39248   }
39249   function abortUnwantedRequests2(cache, tiles) {
39250     Object.keys(cache.inflightTile).forEach((k2) => {
39251       let wanted = tiles.find((tile) => k2 === tile.id);
39252       if (!wanted) {
39253         abortRequest2(cache.inflightTile[k2]);
39254         delete cache.inflightTile[k2];
39255       }
39256     });
39257   }
39258   function encodeIssueRtree2(d2) {
39259     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
39260   }
39261   function updateRtree2(item, replace) {
39262     _cache2.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
39263     if (replace) {
39264       _cache2.rtree.insert(item);
39265     }
39266   }
39267   function preventCoincident(loc) {
39268     let coincident = false;
39269     do {
39270       let delta = coincident ? [1e-5, 0] : [0, 1e-5];
39271       loc = geoVecAdd(loc, delta);
39272       let bbox2 = geoExtent(loc).bbox();
39273       coincident = _cache2.rtree.search(bbox2).length;
39274     } while (coincident);
39275     return loc;
39276   }
39277   var osmose_default = {
39278     title: "osmose",
39279     init() {
39280       _mainFileFetcher.get("qa_data").then((d2) => {
39281         _osmoseData = d2.osmose;
39282         _osmoseData.items = Object.keys(d2.osmose.icons).map((s2) => s2.split("-")[0]).reduce((unique, item) => unique.indexOf(item) !== -1 ? unique : [...unique, item], []);
39283       });
39284       if (!_cache2) {
39285         this.reset();
39286       }
39287       this.event = utilRebind(this, dispatch3, "on");
39288     },
39289     reset() {
39290       let _strings = {};
39291       let _colors = {};
39292       if (_cache2) {
39293         Object.values(_cache2.inflightTile).forEach(abortRequest2);
39294         _strings = _cache2.strings;
39295         _colors = _cache2.colors;
39296       }
39297       _cache2 = {
39298         data: {},
39299         loadedTile: {},
39300         inflightTile: {},
39301         inflightPost: {},
39302         closed: {},
39303         rtree: new RBush(),
39304         strings: _strings,
39305         colors: _colors
39306       };
39307     },
39308     loadIssues(projection2) {
39309       let params = {
39310         // Tiles return a maximum # of issues
39311         // So we want to filter our request for only types iD supports
39312         item: _osmoseData.items
39313       };
39314       let tiles = tiler2.zoomExtent([_tileZoom2, _tileZoom2]).getTiles(projection2);
39315       abortUnwantedRequests2(_cache2, tiles);
39316       tiles.forEach((tile) => {
39317         if (_cache2.loadedTile[tile.id] || _cache2.inflightTile[tile.id]) return;
39318         let [x2, y2, z2] = tile.xyz;
39319         let url = "".concat(_osmoseUrlRoot, "/issues/").concat(z2, "/").concat(x2, "/").concat(y2, ".geojson?") + utilQsString(params);
39320         let controller = new AbortController();
39321         _cache2.inflightTile[tile.id] = controller;
39322         json_default(url, { signal: controller.signal }).then((data) => {
39323           delete _cache2.inflightTile[tile.id];
39324           _cache2.loadedTile[tile.id] = true;
39325           if (data.features) {
39326             data.features.forEach((issue) => {
39327               const { item, class: cl, uuid: id2 } = issue.properties;
39328               const itemType = "".concat(item, "-").concat(cl);
39329               if (itemType in _osmoseData.icons) {
39330                 let loc = issue.geometry.coordinates;
39331                 loc = preventCoincident(loc);
39332                 let d2 = new QAItem(loc, this, itemType, id2, { item });
39333                 if (item === 8300 || item === 8360) {
39334                   d2.elems = [];
39335                 }
39336                 _cache2.data[d2.id] = d2;
39337                 _cache2.rtree.insert(encodeIssueRtree2(d2));
39338               }
39339             });
39340           }
39341           dispatch3.call("loaded");
39342         }).catch(() => {
39343           delete _cache2.inflightTile[tile.id];
39344           _cache2.loadedTile[tile.id] = true;
39345         });
39346       });
39347     },
39348     loadIssueDetail(issue) {
39349       if (issue.elems !== void 0) {
39350         return Promise.resolve(issue);
39351       }
39352       const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "?langs=").concat(_mainLocalizer.localeCode());
39353       const cacheDetails = (data) => {
39354         issue.elems = data.elems.map((e3) => e3.type.substring(0, 1) + e3.id);
39355         issue.detail = data.subtitle ? marked(data.subtitle.auto) : "";
39356         this.replaceItem(issue);
39357       };
39358       return json_default(url).then(cacheDetails).then(() => issue);
39359     },
39360     loadStrings(locale2 = _mainLocalizer.localeCode()) {
39361       const items = Object.keys(_osmoseData.icons);
39362       if (locale2 in _cache2.strings && Object.keys(_cache2.strings[locale2]).length === items.length) {
39363         return Promise.resolve(_cache2.strings[locale2]);
39364       }
39365       if (!(locale2 in _cache2.strings)) {
39366         _cache2.strings[locale2] = {};
39367       }
39368       const allRequests = items.map((itemType) => {
39369         if (itemType in _cache2.strings[locale2]) return null;
39370         const cacheData = (data) => {
39371           const [cat = { items: [] }] = data.categories;
39372           const [item2 = { class: [] }] = cat.items;
39373           const [cl2 = null] = item2.class;
39374           if (!cl2) {
39375             console.log("Osmose strings request (".concat(itemType, ") had unexpected data"));
39376             return;
39377           }
39378           const { item: itemInt, color: color2 } = item2;
39379           if (/^#[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/.test(color2)) {
39380             _cache2.colors[itemInt] = color2;
39381           }
39382           const { title, detail, fix, trap } = cl2;
39383           let issueStrings = {};
39384           if (title) issueStrings.title = title.auto;
39385           if (detail) issueStrings.detail = marked(detail.auto);
39386           if (trap) issueStrings.trap = marked(trap.auto);
39387           if (fix) issueStrings.fix = marked(fix.auto);
39388           _cache2.strings[locale2][itemType] = issueStrings;
39389         };
39390         const [item, cl] = itemType.split("-");
39391         const url = "".concat(_osmoseUrlRoot, "/items/").concat(item, "/class/").concat(cl, "?langs=").concat(locale2);
39392         return json_default(url).then(cacheData);
39393       }).filter(Boolean);
39394       return Promise.all(allRequests).then(() => _cache2.strings[locale2]);
39395     },
39396     getStrings(itemType, locale2 = _mainLocalizer.localeCode()) {
39397       return locale2 in _cache2.strings ? _cache2.strings[locale2][itemType] : {};
39398     },
39399     getColor(itemType) {
39400       return itemType in _cache2.colors ? _cache2.colors[itemType] : "#FFFFFF";
39401     },
39402     postUpdate(issue, callback) {
39403       if (_cache2.inflightPost[issue.id]) {
39404         return callback({ message: "Issue update already inflight", status: -2 }, issue);
39405       }
39406       const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "/").concat(issue.newStatus);
39407       const controller = new AbortController();
39408       const after = () => {
39409         delete _cache2.inflightPost[issue.id];
39410         this.removeItem(issue);
39411         if (issue.newStatus === "done") {
39412           if (!(issue.item in _cache2.closed)) {
39413             _cache2.closed[issue.item] = 0;
39414           }
39415           _cache2.closed[issue.item] += 1;
39416         }
39417         if (callback) callback(null, issue);
39418       };
39419       _cache2.inflightPost[issue.id] = controller;
39420       fetch(url, { signal: controller.signal }).then(after).catch((err) => {
39421         delete _cache2.inflightPost[issue.id];
39422         if (callback) callback(err.message);
39423       });
39424     },
39425     // Get all cached QAItems covering the viewport
39426     getItems(projection2) {
39427       const viewport = projection2.clipExtent();
39428       const min3 = [viewport[0][0], viewport[1][1]];
39429       const max3 = [viewport[1][0], viewport[0][1]];
39430       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
39431       return _cache2.rtree.search(bbox2).map((d2) => d2.data);
39432     },
39433     // Get a QAItem from cache
39434     // NOTE: Don't change method name until UI v3 is merged
39435     getError(id2) {
39436       return _cache2.data[id2];
39437     },
39438     // get the name of the icon to display for this item
39439     getIcon(itemType) {
39440       return _osmoseData.icons[itemType];
39441     },
39442     // Replace a single QAItem in the cache
39443     replaceItem(item) {
39444       if (!(item instanceof QAItem) || !item.id) return;
39445       _cache2.data[item.id] = item;
39446       updateRtree2(encodeIssueRtree2(item), true);
39447       return item;
39448     },
39449     // Remove a single QAItem from the cache
39450     removeItem(item) {
39451       if (!(item instanceof QAItem) || !item.id) return;
39452       delete _cache2.data[item.id];
39453       updateRtree2(encodeIssueRtree2(item), false);
39454     },
39455     // Used to populate `closed:osmose:*` changeset tags
39456     getClosedCounts() {
39457       return _cache2.closed;
39458     },
39459     itemURL(item) {
39460       return "https://osmose.openstreetmap.fr/en/error/".concat(item.id);
39461     }
39462   };
39463
39464   // node_modules/pbf/index.js
39465   var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);
39466   var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
39467   var TEXT_DECODER_MIN_LENGTH = 12;
39468   var utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf-8");
39469   var PBF_VARINT = 0;
39470   var PBF_FIXED64 = 1;
39471   var PBF_BYTES = 2;
39472   var PBF_FIXED32 = 5;
39473   var Pbf = class {
39474     /**
39475      * @param {Uint8Array | ArrayBuffer} [buf]
39476      */
39477     constructor(buf = new Uint8Array(16)) {
39478       this.buf = ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf);
39479       this.dataView = new DataView(this.buf.buffer);
39480       this.pos = 0;
39481       this.type = 0;
39482       this.length = this.buf.length;
39483     }
39484     // === READING =================================================================
39485     /**
39486      * @template T
39487      * @param {(tag: number, result: T, pbf: Pbf) => void} readField
39488      * @param {T} result
39489      * @param {number} [end]
39490      */
39491     readFields(readField, result, end = this.length) {
39492       while (this.pos < end) {
39493         const val = this.readVarint(), tag2 = val >> 3, startPos = this.pos;
39494         this.type = val & 7;
39495         readField(tag2, result, this);
39496         if (this.pos === startPos) this.skip(val);
39497       }
39498       return result;
39499     }
39500     /**
39501      * @template T
39502      * @param {(tag: number, result: T, pbf: Pbf) => void} readField
39503      * @param {T} result
39504      */
39505     readMessage(readField, result) {
39506       return this.readFields(readField, result, this.readVarint() + this.pos);
39507     }
39508     readFixed32() {
39509       const val = this.dataView.getUint32(this.pos, true);
39510       this.pos += 4;
39511       return val;
39512     }
39513     readSFixed32() {
39514       const val = this.dataView.getInt32(this.pos, true);
39515       this.pos += 4;
39516       return val;
39517     }
39518     // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
39519     readFixed64() {
39520       const val = this.dataView.getUint32(this.pos, true) + this.dataView.getUint32(this.pos + 4, true) * SHIFT_LEFT_32;
39521       this.pos += 8;
39522       return val;
39523     }
39524     readSFixed64() {
39525       const val = this.dataView.getUint32(this.pos, true) + this.dataView.getInt32(this.pos + 4, true) * SHIFT_LEFT_32;
39526       this.pos += 8;
39527       return val;
39528     }
39529     readFloat() {
39530       const val = this.dataView.getFloat32(this.pos, true);
39531       this.pos += 4;
39532       return val;
39533     }
39534     readDouble() {
39535       const val = this.dataView.getFloat64(this.pos, true);
39536       this.pos += 8;
39537       return val;
39538     }
39539     /**
39540      * @param {boolean} [isSigned]
39541      */
39542     readVarint(isSigned) {
39543       const buf = this.buf;
39544       let val, b2;
39545       b2 = buf[this.pos++];
39546       val = b2 & 127;
39547       if (b2 < 128) return val;
39548       b2 = buf[this.pos++];
39549       val |= (b2 & 127) << 7;
39550       if (b2 < 128) return val;
39551       b2 = buf[this.pos++];
39552       val |= (b2 & 127) << 14;
39553       if (b2 < 128) return val;
39554       b2 = buf[this.pos++];
39555       val |= (b2 & 127) << 21;
39556       if (b2 < 128) return val;
39557       b2 = buf[this.pos];
39558       val |= (b2 & 15) << 28;
39559       return readVarintRemainder(val, isSigned, this);
39560     }
39561     readVarint64() {
39562       return this.readVarint(true);
39563     }
39564     readSVarint() {
39565       const num = this.readVarint();
39566       return num % 2 === 1 ? (num + 1) / -2 : num / 2;
39567     }
39568     readBoolean() {
39569       return Boolean(this.readVarint());
39570     }
39571     readString() {
39572       const end = this.readVarint() + this.pos;
39573       const pos = this.pos;
39574       this.pos = end;
39575       if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
39576         return utf8TextDecoder.decode(this.buf.subarray(pos, end));
39577       }
39578       return readUtf8(this.buf, pos, end);
39579     }
39580     readBytes() {
39581       const end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end);
39582       this.pos = end;
39583       return buffer;
39584     }
39585     // verbose for performance reasons; doesn't affect gzipped size
39586     /**
39587      * @param {number[]} [arr]
39588      * @param {boolean} [isSigned]
39589      */
39590     readPackedVarint(arr = [], isSigned) {
39591       const end = this.readPackedEnd();
39592       while (this.pos < end) arr.push(this.readVarint(isSigned));
39593       return arr;
39594     }
39595     /** @param {number[]} [arr] */
39596     readPackedSVarint(arr = []) {
39597       const end = this.readPackedEnd();
39598       while (this.pos < end) arr.push(this.readSVarint());
39599       return arr;
39600     }
39601     /** @param {boolean[]} [arr] */
39602     readPackedBoolean(arr = []) {
39603       const end = this.readPackedEnd();
39604       while (this.pos < end) arr.push(this.readBoolean());
39605       return arr;
39606     }
39607     /** @param {number[]} [arr] */
39608     readPackedFloat(arr = []) {
39609       const end = this.readPackedEnd();
39610       while (this.pos < end) arr.push(this.readFloat());
39611       return arr;
39612     }
39613     /** @param {number[]} [arr] */
39614     readPackedDouble(arr = []) {
39615       const end = this.readPackedEnd();
39616       while (this.pos < end) arr.push(this.readDouble());
39617       return arr;
39618     }
39619     /** @param {number[]} [arr] */
39620     readPackedFixed32(arr = []) {
39621       const end = this.readPackedEnd();
39622       while (this.pos < end) arr.push(this.readFixed32());
39623       return arr;
39624     }
39625     /** @param {number[]} [arr] */
39626     readPackedSFixed32(arr = []) {
39627       const end = this.readPackedEnd();
39628       while (this.pos < end) arr.push(this.readSFixed32());
39629       return arr;
39630     }
39631     /** @param {number[]} [arr] */
39632     readPackedFixed64(arr = []) {
39633       const end = this.readPackedEnd();
39634       while (this.pos < end) arr.push(this.readFixed64());
39635       return arr;
39636     }
39637     /** @param {number[]} [arr] */
39638     readPackedSFixed64(arr = []) {
39639       const end = this.readPackedEnd();
39640       while (this.pos < end) arr.push(this.readSFixed64());
39641       return arr;
39642     }
39643     readPackedEnd() {
39644       return this.type === PBF_BYTES ? this.readVarint() + this.pos : this.pos + 1;
39645     }
39646     /** @param {number} val */
39647     skip(val) {
39648       const type2 = val & 7;
39649       if (type2 === PBF_VARINT) while (this.buf[this.pos++] > 127) {
39650       }
39651       else if (type2 === PBF_BYTES) this.pos = this.readVarint() + this.pos;
39652       else if (type2 === PBF_FIXED32) this.pos += 4;
39653       else if (type2 === PBF_FIXED64) this.pos += 8;
39654       else throw new Error("Unimplemented type: ".concat(type2));
39655     }
39656     // === WRITING =================================================================
39657     /**
39658      * @param {number} tag
39659      * @param {number} type
39660      */
39661     writeTag(tag2, type2) {
39662       this.writeVarint(tag2 << 3 | type2);
39663     }
39664     /** @param {number} min */
39665     realloc(min3) {
39666       let length2 = this.length || 16;
39667       while (length2 < this.pos + min3) length2 *= 2;
39668       if (length2 !== this.length) {
39669         const buf = new Uint8Array(length2);
39670         buf.set(this.buf);
39671         this.buf = buf;
39672         this.dataView = new DataView(buf.buffer);
39673         this.length = length2;
39674       }
39675     }
39676     finish() {
39677       this.length = this.pos;
39678       this.pos = 0;
39679       return this.buf.subarray(0, this.length);
39680     }
39681     /** @param {number} val */
39682     writeFixed32(val) {
39683       this.realloc(4);
39684       this.dataView.setInt32(this.pos, val, true);
39685       this.pos += 4;
39686     }
39687     /** @param {number} val */
39688     writeSFixed32(val) {
39689       this.realloc(4);
39690       this.dataView.setInt32(this.pos, val, true);
39691       this.pos += 4;
39692     }
39693     /** @param {number} val */
39694     writeFixed64(val) {
39695       this.realloc(8);
39696       this.dataView.setInt32(this.pos, val & -1, true);
39697       this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);
39698       this.pos += 8;
39699     }
39700     /** @param {number} val */
39701     writeSFixed64(val) {
39702       this.realloc(8);
39703       this.dataView.setInt32(this.pos, val & -1, true);
39704       this.dataView.setInt32(this.pos + 4, Math.floor(val * SHIFT_RIGHT_32), true);
39705       this.pos += 8;
39706     }
39707     /** @param {number} val */
39708     writeVarint(val) {
39709       val = +val || 0;
39710       if (val > 268435455 || val < 0) {
39711         writeBigVarint(val, this);
39712         return;
39713       }
39714       this.realloc(4);
39715       this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);
39716       if (val <= 127) return;
39717       this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
39718       if (val <= 127) return;
39719       this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
39720       if (val <= 127) return;
39721       this.buf[this.pos++] = val >>> 7 & 127;
39722     }
39723     /** @param {number} val */
39724     writeSVarint(val) {
39725       this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
39726     }
39727     /** @param {boolean} val */
39728     writeBoolean(val) {
39729       this.writeVarint(+val);
39730     }
39731     /** @param {string} str */
39732     writeString(str) {
39733       str = String(str);
39734       this.realloc(str.length * 4);
39735       this.pos++;
39736       const startPos = this.pos;
39737       this.pos = writeUtf8(this.buf, str, this.pos);
39738       const len = this.pos - startPos;
39739       if (len >= 128) makeRoomForExtraLength(startPos, len, this);
39740       this.pos = startPos - 1;
39741       this.writeVarint(len);
39742       this.pos += len;
39743     }
39744     /** @param {number} val */
39745     writeFloat(val) {
39746       this.realloc(4);
39747       this.dataView.setFloat32(this.pos, val, true);
39748       this.pos += 4;
39749     }
39750     /** @param {number} val */
39751     writeDouble(val) {
39752       this.realloc(8);
39753       this.dataView.setFloat64(this.pos, val, true);
39754       this.pos += 8;
39755     }
39756     /** @param {Uint8Array} buffer */
39757     writeBytes(buffer) {
39758       const len = buffer.length;
39759       this.writeVarint(len);
39760       this.realloc(len);
39761       for (let i3 = 0; i3 < len; i3++) this.buf[this.pos++] = buffer[i3];
39762     }
39763     /**
39764      * @template T
39765      * @param {(obj: T, pbf: Pbf) => void} fn
39766      * @param {T} obj
39767      */
39768     writeRawMessage(fn, obj) {
39769       this.pos++;
39770       const startPos = this.pos;
39771       fn(obj, this);
39772       const len = this.pos - startPos;
39773       if (len >= 128) makeRoomForExtraLength(startPos, len, this);
39774       this.pos = startPos - 1;
39775       this.writeVarint(len);
39776       this.pos += len;
39777     }
39778     /**
39779      * @template T
39780      * @param {number} tag
39781      * @param {(obj: T, pbf: Pbf) => void} fn
39782      * @param {T} obj
39783      */
39784     writeMessage(tag2, fn, obj) {
39785       this.writeTag(tag2, PBF_BYTES);
39786       this.writeRawMessage(fn, obj);
39787     }
39788     /**
39789      * @param {number} tag
39790      * @param {number[]} arr
39791      */
39792     writePackedVarint(tag2, arr) {
39793       if (arr.length) this.writeMessage(tag2, writePackedVarint, arr);
39794     }
39795     /**
39796      * @param {number} tag
39797      * @param {number[]} arr
39798      */
39799     writePackedSVarint(tag2, arr) {
39800       if (arr.length) this.writeMessage(tag2, writePackedSVarint, arr);
39801     }
39802     /**
39803      * @param {number} tag
39804      * @param {boolean[]} arr
39805      */
39806     writePackedBoolean(tag2, arr) {
39807       if (arr.length) this.writeMessage(tag2, writePackedBoolean, arr);
39808     }
39809     /**
39810      * @param {number} tag
39811      * @param {number[]} arr
39812      */
39813     writePackedFloat(tag2, arr) {
39814       if (arr.length) this.writeMessage(tag2, writePackedFloat, arr);
39815     }
39816     /**
39817      * @param {number} tag
39818      * @param {number[]} arr
39819      */
39820     writePackedDouble(tag2, arr) {
39821       if (arr.length) this.writeMessage(tag2, writePackedDouble, arr);
39822     }
39823     /**
39824      * @param {number} tag
39825      * @param {number[]} arr
39826      */
39827     writePackedFixed32(tag2, arr) {
39828       if (arr.length) this.writeMessage(tag2, writePackedFixed32, arr);
39829     }
39830     /**
39831      * @param {number} tag
39832      * @param {number[]} arr
39833      */
39834     writePackedSFixed32(tag2, arr) {
39835       if (arr.length) this.writeMessage(tag2, writePackedSFixed32, arr);
39836     }
39837     /**
39838      * @param {number} tag
39839      * @param {number[]} arr
39840      */
39841     writePackedFixed64(tag2, arr) {
39842       if (arr.length) this.writeMessage(tag2, writePackedFixed64, arr);
39843     }
39844     /**
39845      * @param {number} tag
39846      * @param {number[]} arr
39847      */
39848     writePackedSFixed64(tag2, arr) {
39849       if (arr.length) this.writeMessage(tag2, writePackedSFixed64, arr);
39850     }
39851     /**
39852      * @param {number} tag
39853      * @param {Uint8Array} buffer
39854      */
39855     writeBytesField(tag2, buffer) {
39856       this.writeTag(tag2, PBF_BYTES);
39857       this.writeBytes(buffer);
39858     }
39859     /**
39860      * @param {number} tag
39861      * @param {number} val
39862      */
39863     writeFixed32Field(tag2, val) {
39864       this.writeTag(tag2, PBF_FIXED32);
39865       this.writeFixed32(val);
39866     }
39867     /**
39868      * @param {number} tag
39869      * @param {number} val
39870      */
39871     writeSFixed32Field(tag2, val) {
39872       this.writeTag(tag2, PBF_FIXED32);
39873       this.writeSFixed32(val);
39874     }
39875     /**
39876      * @param {number} tag
39877      * @param {number} val
39878      */
39879     writeFixed64Field(tag2, val) {
39880       this.writeTag(tag2, PBF_FIXED64);
39881       this.writeFixed64(val);
39882     }
39883     /**
39884      * @param {number} tag
39885      * @param {number} val
39886      */
39887     writeSFixed64Field(tag2, val) {
39888       this.writeTag(tag2, PBF_FIXED64);
39889       this.writeSFixed64(val);
39890     }
39891     /**
39892      * @param {number} tag
39893      * @param {number} val
39894      */
39895     writeVarintField(tag2, val) {
39896       this.writeTag(tag2, PBF_VARINT);
39897       this.writeVarint(val);
39898     }
39899     /**
39900      * @param {number} tag
39901      * @param {number} val
39902      */
39903     writeSVarintField(tag2, val) {
39904       this.writeTag(tag2, PBF_VARINT);
39905       this.writeSVarint(val);
39906     }
39907     /**
39908      * @param {number} tag
39909      * @param {string} str
39910      */
39911     writeStringField(tag2, str) {
39912       this.writeTag(tag2, PBF_BYTES);
39913       this.writeString(str);
39914     }
39915     /**
39916      * @param {number} tag
39917      * @param {number} val
39918      */
39919     writeFloatField(tag2, val) {
39920       this.writeTag(tag2, PBF_FIXED32);
39921       this.writeFloat(val);
39922     }
39923     /**
39924      * @param {number} tag
39925      * @param {number} val
39926      */
39927     writeDoubleField(tag2, val) {
39928       this.writeTag(tag2, PBF_FIXED64);
39929       this.writeDouble(val);
39930     }
39931     /**
39932      * @param {number} tag
39933      * @param {boolean} val
39934      */
39935     writeBooleanField(tag2, val) {
39936       this.writeVarintField(tag2, +val);
39937     }
39938   };
39939   function readVarintRemainder(l2, s2, p2) {
39940     const buf = p2.buf;
39941     let h2, b2;
39942     b2 = buf[p2.pos++];
39943     h2 = (b2 & 112) >> 4;
39944     if (b2 < 128) return toNum(l2, h2, s2);
39945     b2 = buf[p2.pos++];
39946     h2 |= (b2 & 127) << 3;
39947     if (b2 < 128) return toNum(l2, h2, s2);
39948     b2 = buf[p2.pos++];
39949     h2 |= (b2 & 127) << 10;
39950     if (b2 < 128) return toNum(l2, h2, s2);
39951     b2 = buf[p2.pos++];
39952     h2 |= (b2 & 127) << 17;
39953     if (b2 < 128) return toNum(l2, h2, s2);
39954     b2 = buf[p2.pos++];
39955     h2 |= (b2 & 127) << 24;
39956     if (b2 < 128) return toNum(l2, h2, s2);
39957     b2 = buf[p2.pos++];
39958     h2 |= (b2 & 1) << 31;
39959     if (b2 < 128) return toNum(l2, h2, s2);
39960     throw new Error("Expected varint not more than 10 bytes");
39961   }
39962   function toNum(low, high, isSigned) {
39963     return isSigned ? high * 4294967296 + (low >>> 0) : (high >>> 0) * 4294967296 + (low >>> 0);
39964   }
39965   function writeBigVarint(val, pbf) {
39966     let low, high;
39967     if (val >= 0) {
39968       low = val % 4294967296 | 0;
39969       high = val / 4294967296 | 0;
39970     } else {
39971       low = ~(-val % 4294967296);
39972       high = ~(-val / 4294967296);
39973       if (low ^ 4294967295) {
39974         low = low + 1 | 0;
39975       } else {
39976         low = 0;
39977         high = high + 1 | 0;
39978       }
39979     }
39980     if (val >= 18446744073709552e3 || val < -18446744073709552e3) {
39981       throw new Error("Given varint doesn't fit into 10 bytes");
39982     }
39983     pbf.realloc(10);
39984     writeBigVarintLow(low, high, pbf);
39985     writeBigVarintHigh(high, pbf);
39986   }
39987   function writeBigVarintLow(low, high, pbf) {
39988     pbf.buf[pbf.pos++] = low & 127 | 128;
39989     low >>>= 7;
39990     pbf.buf[pbf.pos++] = low & 127 | 128;
39991     low >>>= 7;
39992     pbf.buf[pbf.pos++] = low & 127 | 128;
39993     low >>>= 7;
39994     pbf.buf[pbf.pos++] = low & 127 | 128;
39995     low >>>= 7;
39996     pbf.buf[pbf.pos] = low & 127;
39997   }
39998   function writeBigVarintHigh(high, pbf) {
39999     const lsb = (high & 7) << 4;
40000     pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 128 : 0);
40001     if (!high) return;
40002     pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
40003     if (!high) return;
40004     pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
40005     if (!high) return;
40006     pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
40007     if (!high) return;
40008     pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
40009     if (!high) return;
40010     pbf.buf[pbf.pos++] = high & 127;
40011   }
40012   function makeRoomForExtraLength(startPos, len, pbf) {
40013     const extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
40014     pbf.realloc(extraLen);
40015     for (let i3 = pbf.pos - 1; i3 >= startPos; i3--) pbf.buf[i3 + extraLen] = pbf.buf[i3];
40016   }
40017   function writePackedVarint(arr, pbf) {
40018     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeVarint(arr[i3]);
40019   }
40020   function writePackedSVarint(arr, pbf) {
40021     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeSVarint(arr[i3]);
40022   }
40023   function writePackedFloat(arr, pbf) {
40024     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeFloat(arr[i3]);
40025   }
40026   function writePackedDouble(arr, pbf) {
40027     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeDouble(arr[i3]);
40028   }
40029   function writePackedBoolean(arr, pbf) {
40030     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeBoolean(arr[i3]);
40031   }
40032   function writePackedFixed32(arr, pbf) {
40033     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeFixed32(arr[i3]);
40034   }
40035   function writePackedSFixed32(arr, pbf) {
40036     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeSFixed32(arr[i3]);
40037   }
40038   function writePackedFixed64(arr, pbf) {
40039     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeFixed64(arr[i3]);
40040   }
40041   function writePackedSFixed64(arr, pbf) {
40042     for (let i3 = 0; i3 < arr.length; i3++) pbf.writeSFixed64(arr[i3]);
40043   }
40044   function readUtf8(buf, pos, end) {
40045     let str = "";
40046     let i3 = pos;
40047     while (i3 < end) {
40048       const b0 = buf[i3];
40049       let c2 = null;
40050       let bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
40051       if (i3 + bytesPerSequence > end) break;
40052       let b1, b2, b3;
40053       if (bytesPerSequence === 1) {
40054         if (b0 < 128) {
40055           c2 = b0;
40056         }
40057       } else if (bytesPerSequence === 2) {
40058         b1 = buf[i3 + 1];
40059         if ((b1 & 192) === 128) {
40060           c2 = (b0 & 31) << 6 | b1 & 63;
40061           if (c2 <= 127) {
40062             c2 = null;
40063           }
40064         }
40065       } else if (bytesPerSequence === 3) {
40066         b1 = buf[i3 + 1];
40067         b2 = buf[i3 + 2];
40068         if ((b1 & 192) === 128 && (b2 & 192) === 128) {
40069           c2 = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
40070           if (c2 <= 2047 || c2 >= 55296 && c2 <= 57343) {
40071             c2 = null;
40072           }
40073         }
40074       } else if (bytesPerSequence === 4) {
40075         b1 = buf[i3 + 1];
40076         b2 = buf[i3 + 2];
40077         b3 = buf[i3 + 3];
40078         if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
40079           c2 = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
40080           if (c2 <= 65535 || c2 >= 1114112) {
40081             c2 = null;
40082           }
40083         }
40084       }
40085       if (c2 === null) {
40086         c2 = 65533;
40087         bytesPerSequence = 1;
40088       } else if (c2 > 65535) {
40089         c2 -= 65536;
40090         str += String.fromCharCode(c2 >>> 10 & 1023 | 55296);
40091         c2 = 56320 | c2 & 1023;
40092       }
40093       str += String.fromCharCode(c2);
40094       i3 += bytesPerSequence;
40095     }
40096     return str;
40097   }
40098   function writeUtf8(buf, str, pos) {
40099     for (let i3 = 0, c2, lead; i3 < str.length; i3++) {
40100       c2 = str.charCodeAt(i3);
40101       if (c2 > 55295 && c2 < 57344) {
40102         if (lead) {
40103           if (c2 < 56320) {
40104             buf[pos++] = 239;
40105             buf[pos++] = 191;
40106             buf[pos++] = 189;
40107             lead = c2;
40108             continue;
40109           } else {
40110             c2 = lead - 55296 << 10 | c2 - 56320 | 65536;
40111             lead = null;
40112           }
40113         } else {
40114           if (c2 > 56319 || i3 + 1 === str.length) {
40115             buf[pos++] = 239;
40116             buf[pos++] = 191;
40117             buf[pos++] = 189;
40118           } else {
40119             lead = c2;
40120           }
40121           continue;
40122         }
40123       } else if (lead) {
40124         buf[pos++] = 239;
40125         buf[pos++] = 191;
40126         buf[pos++] = 189;
40127         lead = null;
40128       }
40129       if (c2 < 128) {
40130         buf[pos++] = c2;
40131       } else {
40132         if (c2 < 2048) {
40133           buf[pos++] = c2 >> 6 | 192;
40134         } else {
40135           if (c2 < 65536) {
40136             buf[pos++] = c2 >> 12 | 224;
40137           } else {
40138             buf[pos++] = c2 >> 18 | 240;
40139             buf[pos++] = c2 >> 12 & 63 | 128;
40140           }
40141           buf[pos++] = c2 >> 6 & 63 | 128;
40142         }
40143         buf[pos++] = c2 & 63 | 128;
40144       }
40145     }
40146     return pos;
40147   }
40148
40149   // node_modules/@mapbox/point-geometry/index.js
40150   function Point(x2, y2) {
40151     this.x = x2;
40152     this.y = y2;
40153   }
40154   Point.prototype = {
40155     /**
40156      * Clone this point, returning a new point that can be modified
40157      * without affecting the old one.
40158      * @return {Point} the clone
40159      */
40160     clone() {
40161       return new Point(this.x, this.y);
40162     },
40163     /**
40164      * Add this point's x & y coordinates to another point,
40165      * yielding a new point.
40166      * @param {Point} p the other point
40167      * @return {Point} output point
40168      */
40169     add(p2) {
40170       return this.clone()._add(p2);
40171     },
40172     /**
40173      * Subtract this point's x & y coordinates to from point,
40174      * yielding a new point.
40175      * @param {Point} p the other point
40176      * @return {Point} output point
40177      */
40178     sub(p2) {
40179       return this.clone()._sub(p2);
40180     },
40181     /**
40182      * Multiply this point's x & y coordinates by point,
40183      * yielding a new point.
40184      * @param {Point} p the other point
40185      * @return {Point} output point
40186      */
40187     multByPoint(p2) {
40188       return this.clone()._multByPoint(p2);
40189     },
40190     /**
40191      * Divide this point's x & y coordinates by point,
40192      * yielding a new point.
40193      * @param {Point} p the other point
40194      * @return {Point} output point
40195      */
40196     divByPoint(p2) {
40197       return this.clone()._divByPoint(p2);
40198     },
40199     /**
40200      * Multiply this point's x & y coordinates by a factor,
40201      * yielding a new point.
40202      * @param {number} k factor
40203      * @return {Point} output point
40204      */
40205     mult(k2) {
40206       return this.clone()._mult(k2);
40207     },
40208     /**
40209      * Divide this point's x & y coordinates by a factor,
40210      * yielding a new point.
40211      * @param {number} k factor
40212      * @return {Point} output point
40213      */
40214     div(k2) {
40215       return this.clone()._div(k2);
40216     },
40217     /**
40218      * Rotate this point around the 0, 0 origin by an angle a,
40219      * given in radians
40220      * @param {number} a angle to rotate around, in radians
40221      * @return {Point} output point
40222      */
40223     rotate(a2) {
40224       return this.clone()._rotate(a2);
40225     },
40226     /**
40227      * Rotate this point around p point by an angle a,
40228      * given in radians
40229      * @param {number} a angle to rotate around, in radians
40230      * @param {Point} p Point to rotate around
40231      * @return {Point} output point
40232      */
40233     rotateAround(a2, p2) {
40234       return this.clone()._rotateAround(a2, p2);
40235     },
40236     /**
40237      * Multiply this point by a 4x1 transformation matrix
40238      * @param {[number, number, number, number]} m transformation matrix
40239      * @return {Point} output point
40240      */
40241     matMult(m2) {
40242       return this.clone()._matMult(m2);
40243     },
40244     /**
40245      * Calculate this point but as a unit vector from 0, 0, meaning
40246      * that the distance from the resulting point to the 0, 0
40247      * coordinate will be equal to 1 and the angle from the resulting
40248      * point to the 0, 0 coordinate will be the same as before.
40249      * @return {Point} unit vector point
40250      */
40251     unit() {
40252       return this.clone()._unit();
40253     },
40254     /**
40255      * Compute a perpendicular point, where the new y coordinate
40256      * is the old x coordinate and the new x coordinate is the old y
40257      * coordinate multiplied by -1
40258      * @return {Point} perpendicular point
40259      */
40260     perp() {
40261       return this.clone()._perp();
40262     },
40263     /**
40264      * Return a version of this point with the x & y coordinates
40265      * rounded to integers.
40266      * @return {Point} rounded point
40267      */
40268     round() {
40269       return this.clone()._round();
40270     },
40271     /**
40272      * Return the magnitude of this point: this is the Euclidean
40273      * distance from the 0, 0 coordinate to this point's x and y
40274      * coordinates.
40275      * @return {number} magnitude
40276      */
40277     mag() {
40278       return Math.sqrt(this.x * this.x + this.y * this.y);
40279     },
40280     /**
40281      * Judge whether this point is equal to another point, returning
40282      * true or false.
40283      * @param {Point} other the other point
40284      * @return {boolean} whether the points are equal
40285      */
40286     equals(other2) {
40287       return this.x === other2.x && this.y === other2.y;
40288     },
40289     /**
40290      * Calculate the distance from this point to another point
40291      * @param {Point} p the other point
40292      * @return {number} distance
40293      */
40294     dist(p2) {
40295       return Math.sqrt(this.distSqr(p2));
40296     },
40297     /**
40298      * Calculate the distance from this point to another point,
40299      * without the square root step. Useful if you're comparing
40300      * relative distances.
40301      * @param {Point} p the other point
40302      * @return {number} distance
40303      */
40304     distSqr(p2) {
40305       const dx = p2.x - this.x, dy = p2.y - this.y;
40306       return dx * dx + dy * dy;
40307     },
40308     /**
40309      * Get the angle from the 0, 0 coordinate to this point, in radians
40310      * coordinates.
40311      * @return {number} angle
40312      */
40313     angle() {
40314       return Math.atan2(this.y, this.x);
40315     },
40316     /**
40317      * Get the angle from this point to another point, in radians
40318      * @param {Point} b the other point
40319      * @return {number} angle
40320      */
40321     angleTo(b2) {
40322       return Math.atan2(this.y - b2.y, this.x - b2.x);
40323     },
40324     /**
40325      * Get the angle between this point and another point, in radians
40326      * @param {Point} b the other point
40327      * @return {number} angle
40328      */
40329     angleWith(b2) {
40330       return this.angleWithSep(b2.x, b2.y);
40331     },
40332     /**
40333      * Find the angle of the two vectors, solving the formula for
40334      * the cross product a x b = |a||b|sin(θ) for θ.
40335      * @param {number} x the x-coordinate
40336      * @param {number} y the y-coordinate
40337      * @return {number} the angle in radians
40338      */
40339     angleWithSep(x2, y2) {
40340       return Math.atan2(
40341         this.x * y2 - this.y * x2,
40342         this.x * x2 + this.y * y2
40343       );
40344     },
40345     /** @param {[number, number, number, number]} m */
40346     _matMult(m2) {
40347       const x2 = m2[0] * this.x + m2[1] * this.y, y2 = m2[2] * this.x + m2[3] * this.y;
40348       this.x = x2;
40349       this.y = y2;
40350       return this;
40351     },
40352     /** @param {Point} p */
40353     _add(p2) {
40354       this.x += p2.x;
40355       this.y += p2.y;
40356       return this;
40357     },
40358     /** @param {Point} p */
40359     _sub(p2) {
40360       this.x -= p2.x;
40361       this.y -= p2.y;
40362       return this;
40363     },
40364     /** @param {number} k */
40365     _mult(k2) {
40366       this.x *= k2;
40367       this.y *= k2;
40368       return this;
40369     },
40370     /** @param {number} k */
40371     _div(k2) {
40372       this.x /= k2;
40373       this.y /= k2;
40374       return this;
40375     },
40376     /** @param {Point} p */
40377     _multByPoint(p2) {
40378       this.x *= p2.x;
40379       this.y *= p2.y;
40380       return this;
40381     },
40382     /** @param {Point} p */
40383     _divByPoint(p2) {
40384       this.x /= p2.x;
40385       this.y /= p2.y;
40386       return this;
40387     },
40388     _unit() {
40389       this._div(this.mag());
40390       return this;
40391     },
40392     _perp() {
40393       const y2 = this.y;
40394       this.y = this.x;
40395       this.x = -y2;
40396       return this;
40397     },
40398     /** @param {number} angle */
40399     _rotate(angle2) {
40400       const cos2 = Math.cos(angle2), sin2 = Math.sin(angle2), x2 = cos2 * this.x - sin2 * this.y, y2 = sin2 * this.x + cos2 * this.y;
40401       this.x = x2;
40402       this.y = y2;
40403       return this;
40404     },
40405     /**
40406      * @param {number} angle
40407      * @param {Point} p
40408      */
40409     _rotateAround(angle2, p2) {
40410       const cos2 = Math.cos(angle2), sin2 = Math.sin(angle2), x2 = p2.x + cos2 * (this.x - p2.x) - sin2 * (this.y - p2.y), y2 = p2.y + sin2 * (this.x - p2.x) + cos2 * (this.y - p2.y);
40411       this.x = x2;
40412       this.y = y2;
40413       return this;
40414     },
40415     _round() {
40416       this.x = Math.round(this.x);
40417       this.y = Math.round(this.y);
40418       return this;
40419     },
40420     constructor: Point
40421   };
40422   Point.convert = function(p2) {
40423     if (p2 instanceof Point) {
40424       return (
40425         /** @type {Point} */
40426         p2
40427       );
40428     }
40429     if (Array.isArray(p2)) {
40430       return new Point(+p2[0], +p2[1]);
40431     }
40432     if (p2.x !== void 0 && p2.y !== void 0) {
40433       return new Point(+p2.x, +p2.y);
40434     }
40435     throw new Error("Expected [x, y] or {x, y} point format");
40436   };
40437
40438   // node_modules/@mapbox/vector-tile/index.js
40439   var VectorTileFeature = class {
40440     /**
40441      * @param {Pbf} pbf
40442      * @param {number} end
40443      * @param {number} extent
40444      * @param {string[]} keys
40445      * @param {unknown[]} values
40446      */
40447     constructor(pbf, end, extent, keys2, values) {
40448       this.properties = {};
40449       this.extent = extent;
40450       this.type = 0;
40451       this.id = void 0;
40452       this._pbf = pbf;
40453       this._geometry = -1;
40454       this._keys = keys2;
40455       this._values = values;
40456       pbf.readFields(readFeature, this, end);
40457     }
40458     loadGeometry() {
40459       const pbf = this._pbf;
40460       pbf.pos = this._geometry;
40461       const end = pbf.readVarint() + pbf.pos;
40462       const lines = [];
40463       let line;
40464       let cmd = 1;
40465       let length2 = 0;
40466       let x2 = 0;
40467       let y2 = 0;
40468       while (pbf.pos < end) {
40469         if (length2 <= 0) {
40470           const cmdLen = pbf.readVarint();
40471           cmd = cmdLen & 7;
40472           length2 = cmdLen >> 3;
40473         }
40474         length2--;
40475         if (cmd === 1 || cmd === 2) {
40476           x2 += pbf.readSVarint();
40477           y2 += pbf.readSVarint();
40478           if (cmd === 1) {
40479             if (line) lines.push(line);
40480             line = [];
40481           }
40482           if (line) line.push(new Point(x2, y2));
40483         } else if (cmd === 7) {
40484           if (line) {
40485             line.push(line[0].clone());
40486           }
40487         } else {
40488           throw new Error("unknown command ".concat(cmd));
40489         }
40490       }
40491       if (line) lines.push(line);
40492       return lines;
40493     }
40494     bbox() {
40495       const pbf = this._pbf;
40496       pbf.pos = this._geometry;
40497       const end = pbf.readVarint() + pbf.pos;
40498       let cmd = 1, length2 = 0, x2 = 0, y2 = 0, x12 = Infinity, x22 = -Infinity, y12 = Infinity, y22 = -Infinity;
40499       while (pbf.pos < end) {
40500         if (length2 <= 0) {
40501           const cmdLen = pbf.readVarint();
40502           cmd = cmdLen & 7;
40503           length2 = cmdLen >> 3;
40504         }
40505         length2--;
40506         if (cmd === 1 || cmd === 2) {
40507           x2 += pbf.readSVarint();
40508           y2 += pbf.readSVarint();
40509           if (x2 < x12) x12 = x2;
40510           if (x2 > x22) x22 = x2;
40511           if (y2 < y12) y12 = y2;
40512           if (y2 > y22) y22 = y2;
40513         } else if (cmd !== 7) {
40514           throw new Error("unknown command ".concat(cmd));
40515         }
40516       }
40517       return [x12, y12, x22, y22];
40518     }
40519     /**
40520      * @param {number} x
40521      * @param {number} y
40522      * @param {number} z
40523      * @return {Feature}
40524      */
40525     toGeoJSON(x2, y2, z2) {
40526       const size = this.extent * Math.pow(2, z2), x05 = this.extent * x2, y05 = this.extent * y2, vtCoords = this.loadGeometry();
40527       function projectPoint(p2) {
40528         return [
40529           (p2.x + x05) * 360 / size - 180,
40530           360 / Math.PI * Math.atan(Math.exp((1 - (p2.y + y05) * 2 / size) * Math.PI)) - 90
40531         ];
40532       }
40533       function projectLine(line) {
40534         return line.map(projectPoint);
40535       }
40536       let geometry;
40537       if (this.type === 1) {
40538         const points = [];
40539         for (const line of vtCoords) {
40540           points.push(line[0]);
40541         }
40542         const coordinates = projectLine(points);
40543         geometry = points.length === 1 ? { type: "Point", coordinates: coordinates[0] } : { type: "MultiPoint", coordinates };
40544       } else if (this.type === 2) {
40545         const coordinates = vtCoords.map(projectLine);
40546         geometry = coordinates.length === 1 ? { type: "LineString", coordinates: coordinates[0] } : { type: "MultiLineString", coordinates };
40547       } else if (this.type === 3) {
40548         const polygons = classifyRings(vtCoords);
40549         const coordinates = [];
40550         for (const polygon2 of polygons) {
40551           coordinates.push(polygon2.map(projectLine));
40552         }
40553         geometry = coordinates.length === 1 ? { type: "Polygon", coordinates: coordinates[0] } : { type: "MultiPolygon", coordinates };
40554       } else {
40555         throw new Error("unknown feature type");
40556       }
40557       const result = {
40558         type: "Feature",
40559         geometry,
40560         properties: this.properties
40561       };
40562       if (this.id != null) {
40563         result.id = this.id;
40564       }
40565       return result;
40566     }
40567   };
40568   VectorTileFeature.types = ["Unknown", "Point", "LineString", "Polygon"];
40569   function readFeature(tag2, feature3, pbf) {
40570     if (tag2 === 1) feature3.id = pbf.readVarint();
40571     else if (tag2 === 2) readTag(pbf, feature3);
40572     else if (tag2 === 3) feature3.type = /** @type {0 | 1 | 2 | 3} */
40573     pbf.readVarint();
40574     else if (tag2 === 4) feature3._geometry = pbf.pos;
40575   }
40576   function readTag(pbf, feature3) {
40577     const end = pbf.readVarint() + pbf.pos;
40578     while (pbf.pos < end) {
40579       const key = feature3._keys[pbf.readVarint()], value = feature3._values[pbf.readVarint()];
40580       feature3.properties[key] = value;
40581     }
40582   }
40583   function classifyRings(rings) {
40584     const len = rings.length;
40585     if (len <= 1) return [rings];
40586     const polygons = [];
40587     let polygon2, ccw;
40588     for (let i3 = 0; i3 < len; i3++) {
40589       const area = signedArea(rings[i3]);
40590       if (area === 0) continue;
40591       if (ccw === void 0) ccw = area < 0;
40592       if (ccw === area < 0) {
40593         if (polygon2) polygons.push(polygon2);
40594         polygon2 = [rings[i3]];
40595       } else if (polygon2) {
40596         polygon2.push(rings[i3]);
40597       }
40598     }
40599     if (polygon2) polygons.push(polygon2);
40600     return polygons;
40601   }
40602   function signedArea(ring) {
40603     let sum = 0;
40604     for (let i3 = 0, len = ring.length, j2 = len - 1, p1, p2; i3 < len; j2 = i3++) {
40605       p1 = ring[i3];
40606       p2 = ring[j2];
40607       sum += (p2.x - p1.x) * (p1.y + p2.y);
40608     }
40609     return sum;
40610   }
40611   var VectorTileLayer = class {
40612     /**
40613      * @param {Pbf} pbf
40614      * @param {number} [end]
40615      */
40616     constructor(pbf, end) {
40617       this.version = 1;
40618       this.name = "";
40619       this.extent = 4096;
40620       this.length = 0;
40621       this._pbf = pbf;
40622       this._keys = [];
40623       this._values = [];
40624       this._features = [];
40625       pbf.readFields(readLayer, this, end);
40626       this.length = this._features.length;
40627     }
40628     /** return feature `i` from this layer as a `VectorTileFeature`
40629      * @param {number} i
40630      */
40631     feature(i3) {
40632       if (i3 < 0 || i3 >= this._features.length) throw new Error("feature index out of bounds");
40633       this._pbf.pos = this._features[i3];
40634       const end = this._pbf.readVarint() + this._pbf.pos;
40635       return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
40636     }
40637   };
40638   function readLayer(tag2, layer, pbf) {
40639     if (tag2 === 15) layer.version = pbf.readVarint();
40640     else if (tag2 === 1) layer.name = pbf.readString();
40641     else if (tag2 === 5) layer.extent = pbf.readVarint();
40642     else if (tag2 === 2) layer._features.push(pbf.pos);
40643     else if (tag2 === 3) layer._keys.push(pbf.readString());
40644     else if (tag2 === 4) layer._values.push(readValueMessage(pbf));
40645   }
40646   function readValueMessage(pbf) {
40647     let value = null;
40648     const end = pbf.readVarint() + pbf.pos;
40649     while (pbf.pos < end) {
40650       const tag2 = pbf.readVarint() >> 3;
40651       value = tag2 === 1 ? pbf.readString() : tag2 === 2 ? pbf.readFloat() : tag2 === 3 ? pbf.readDouble() : tag2 === 4 ? pbf.readVarint64() : tag2 === 5 ? pbf.readVarint() : tag2 === 6 ? pbf.readSVarint() : tag2 === 7 ? pbf.readBoolean() : null;
40652     }
40653     return value;
40654   }
40655   var VectorTile = class {
40656     /**
40657      * @param {Pbf} pbf
40658      * @param {number} [end]
40659      */
40660     constructor(pbf, end) {
40661       this.layers = pbf.readFields(readTile, {}, end);
40662     }
40663   };
40664   function readTile(tag2, layers, pbf) {
40665     if (tag2 === 3) {
40666       const layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
40667       if (layer.length) layers[layer.name] = layer;
40668     }
40669   }
40670
40671   // modules/services/mapillary.js
40672   var accessToken = "MLY|4100327730013843|5bb78b81720791946a9a7b956c57b7cf";
40673   var apiUrl = "https://graph.mapillary.com/";
40674   var baseTileUrl = "https://tiles.mapillary.com/maps/vtp";
40675   var mapFeatureTileUrl = "".concat(baseTileUrl, "/mly_map_feature_point/2/{z}/{x}/{y}?access_token=").concat(accessToken);
40676   var tileUrl = "".concat(baseTileUrl, "/mly1_public/2/{z}/{x}/{y}?access_token=").concat(accessToken);
40677   var trafficSignTileUrl = "".concat(baseTileUrl, "/mly_map_feature_traffic_sign/2/{z}/{x}/{y}?access_token=").concat(accessToken);
40678   var viewercss = "mapillary-js/mapillary.css";
40679   var viewerjs = "mapillary-js/mapillary.js";
40680   var minZoom = 14;
40681   var dispatch4 = dispatch_default("change", "loadedImages", "loadedSigns", "loadedMapFeatures", "bearingChanged", "imageChanged");
40682   var _loadViewerPromise;
40683   var _mlyActiveImage;
40684   var _mlyCache;
40685   var _mlyFallback = false;
40686   var _mlyHighlightedDetection;
40687   var _mlyShowFeatureDetections = false;
40688   var _mlyShowSignDetections = false;
40689   var _mlyViewer;
40690   var _mlyViewerFilter = ["all"];
40691   var _isViewerOpen = false;
40692   function loadTiles(which, url, maxZoom2, projection2) {
40693     const tiler8 = utilTiler().zoomExtent([minZoom, maxZoom2]).skipNullIsland(true);
40694     const tiles = tiler8.getTiles(projection2);
40695     tiles.forEach(function(tile) {
40696       loadTile(which, url, tile);
40697     });
40698   }
40699   function loadTile(which, url, tile) {
40700     const cache = _mlyCache.requests;
40701     const tileId = "".concat(tile.id, "-").concat(which);
40702     if (cache.loaded[tileId] || cache.inflight[tileId]) return;
40703     const controller = new AbortController();
40704     cache.inflight[tileId] = controller;
40705     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
40706     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
40707       if (!response.ok) {
40708         throw new Error(response.status + " " + response.statusText);
40709       }
40710       cache.loaded[tileId] = true;
40711       delete cache.inflight[tileId];
40712       return response.arrayBuffer();
40713     }).then(function(data) {
40714       if (!data) {
40715         throw new Error("No Data");
40716       }
40717       loadTileDataToCache(data, tile, which);
40718       if (which === "images") {
40719         dispatch4.call("loadedImages");
40720       } else if (which === "signs") {
40721         dispatch4.call("loadedSigns");
40722       } else if (which === "points") {
40723         dispatch4.call("loadedMapFeatures");
40724       }
40725     }).catch(function() {
40726       cache.loaded[tileId] = true;
40727       delete cache.inflight[tileId];
40728     });
40729   }
40730   function loadTileDataToCache(data, tile, which) {
40731     const vectorTile = new VectorTile(new Pbf(data));
40732     let features, cache, layer, i3, feature3, loc, d2;
40733     if (vectorTile.layers.hasOwnProperty("image")) {
40734       features = [];
40735       cache = _mlyCache.images;
40736       layer = vectorTile.layers.image;
40737       for (i3 = 0; i3 < layer.length; i3++) {
40738         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
40739         loc = feature3.geometry.coordinates;
40740         d2 = {
40741           loc,
40742           captured_at: feature3.properties.captured_at,
40743           ca: feature3.properties.compass_angle,
40744           id: feature3.properties.id,
40745           is_pano: feature3.properties.is_pano,
40746           sequence_id: feature3.properties.sequence_id
40747         };
40748         cache.forImageId[d2.id] = d2;
40749         features.push({
40750           minX: loc[0],
40751           minY: loc[1],
40752           maxX: loc[0],
40753           maxY: loc[1],
40754           data: d2
40755         });
40756       }
40757       if (cache.rtree) {
40758         cache.rtree.load(features);
40759       }
40760     }
40761     if (vectorTile.layers.hasOwnProperty("sequence")) {
40762       features = [];
40763       cache = _mlyCache.sequences;
40764       layer = vectorTile.layers.sequence;
40765       for (i3 = 0; i3 < layer.length; i3++) {
40766         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
40767         if (cache.lineString[feature3.properties.id]) {
40768           cache.lineString[feature3.properties.id].push(feature3);
40769         } else {
40770           cache.lineString[feature3.properties.id] = [feature3];
40771         }
40772       }
40773     }
40774     if (vectorTile.layers.hasOwnProperty("point")) {
40775       features = [];
40776       cache = _mlyCache[which];
40777       layer = vectorTile.layers.point;
40778       for (i3 = 0; i3 < layer.length; i3++) {
40779         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
40780         loc = feature3.geometry.coordinates;
40781         d2 = {
40782           loc,
40783           id: feature3.properties.id,
40784           first_seen_at: feature3.properties.first_seen_at,
40785           last_seen_at: feature3.properties.last_seen_at,
40786           value: feature3.properties.value
40787         };
40788         features.push({
40789           minX: loc[0],
40790           minY: loc[1],
40791           maxX: loc[0],
40792           maxY: loc[1],
40793           data: d2
40794         });
40795       }
40796       if (cache.rtree) {
40797         cache.rtree.load(features);
40798       }
40799     }
40800     if (vectorTile.layers.hasOwnProperty("traffic_sign")) {
40801       features = [];
40802       cache = _mlyCache[which];
40803       layer = vectorTile.layers.traffic_sign;
40804       for (i3 = 0; i3 < layer.length; i3++) {
40805         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
40806         loc = feature3.geometry.coordinates;
40807         d2 = {
40808           loc,
40809           id: feature3.properties.id,
40810           first_seen_at: feature3.properties.first_seen_at,
40811           last_seen_at: feature3.properties.last_seen_at,
40812           value: feature3.properties.value
40813         };
40814         features.push({
40815           minX: loc[0],
40816           minY: loc[1],
40817           maxX: loc[0],
40818           maxY: loc[1],
40819           data: d2
40820         });
40821       }
40822       if (cache.rtree) {
40823         cache.rtree.load(features);
40824       }
40825     }
40826   }
40827   function loadData(url) {
40828     return fetch(url).then(function(response) {
40829       if (!response.ok) {
40830         throw new Error(response.status + " " + response.statusText);
40831       }
40832       return response.json();
40833     }).then(function(result) {
40834       if (!result) {
40835         return [];
40836       }
40837       return result.data || [];
40838     });
40839   }
40840   function partitionViewport(projection2) {
40841     const z2 = geoScaleToZoom(projection2.scale());
40842     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
40843     const tiler8 = utilTiler().zoomExtent([z22, z22]);
40844     return tiler8.getTiles(projection2).map(function(tile) {
40845       return tile.extent;
40846     });
40847   }
40848   function searchLimited(limit, projection2, rtree) {
40849     limit = limit || 5;
40850     return partitionViewport(projection2).reduce(function(result, extent) {
40851       const found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
40852         return d2.data;
40853       });
40854       return found.length ? result.concat(found) : result;
40855     }, []);
40856   }
40857   var mapillary_default = {
40858     // Initialize Mapillary
40859     init: function() {
40860       if (!_mlyCache) {
40861         this.reset();
40862       }
40863       this.event = utilRebind(this, dispatch4, "on");
40864     },
40865     // Reset cache and state
40866     reset: function() {
40867       if (_mlyCache) {
40868         Object.values(_mlyCache.requests.inflight).forEach(function(request3) {
40869           request3.abort();
40870         });
40871       }
40872       _mlyCache = {
40873         images: { rtree: new RBush(), forImageId: {} },
40874         image_detections: { forImageId: {} },
40875         signs: { rtree: new RBush() },
40876         points: { rtree: new RBush() },
40877         sequences: { rtree: new RBush(), lineString: {} },
40878         requests: { loaded: {}, inflight: {} }
40879       };
40880       _mlyActiveImage = null;
40881     },
40882     // Get visible images
40883     images: function(projection2) {
40884       const limit = 5;
40885       return searchLimited(limit, projection2, _mlyCache.images.rtree);
40886     },
40887     // Get visible traffic signs
40888     signs: function(projection2) {
40889       const limit = 5;
40890       return searchLimited(limit, projection2, _mlyCache.signs.rtree);
40891     },
40892     // Get visible map (point) features
40893     mapFeatures: function(projection2) {
40894       const limit = 5;
40895       return searchLimited(limit, projection2, _mlyCache.points.rtree);
40896     },
40897     // Get cached image by id
40898     cachedImage: function(imageId) {
40899       return _mlyCache.images.forImageId[imageId];
40900     },
40901     // Get visible sequences
40902     sequences: function(projection2) {
40903       const viewport = projection2.clipExtent();
40904       const min3 = [viewport[0][0], viewport[1][1]];
40905       const max3 = [viewport[1][0], viewport[0][1]];
40906       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
40907       const sequenceIds = {};
40908       let lineStrings = [];
40909       _mlyCache.images.rtree.search(bbox2).forEach(function(d2) {
40910         if (d2.data.sequence_id) {
40911           sequenceIds[d2.data.sequence_id] = true;
40912         }
40913       });
40914       Object.keys(sequenceIds).forEach(function(sequenceId) {
40915         if (_mlyCache.sequences.lineString[sequenceId]) {
40916           lineStrings = lineStrings.concat(_mlyCache.sequences.lineString[sequenceId]);
40917         }
40918       });
40919       return lineStrings;
40920     },
40921     // Load images in the visible area
40922     loadImages: function(projection2) {
40923       loadTiles("images", tileUrl, 14, projection2);
40924     },
40925     // Load traffic signs in the visible area
40926     loadSigns: function(projection2) {
40927       loadTiles("signs", trafficSignTileUrl, 14, projection2);
40928     },
40929     // Load map (point) features in the visible area
40930     loadMapFeatures: function(projection2) {
40931       loadTiles("points", mapFeatureTileUrl, 14, projection2);
40932     },
40933     // Return a promise that resolves when the image viewer (Mapillary JS) library has finished loading
40934     ensureViewerLoaded: function(context) {
40935       if (_loadViewerPromise) return _loadViewerPromise;
40936       const wrap2 = context.container().select(".photoviewer").selectAll(".mly-wrapper").data([0]);
40937       wrap2.enter().append("div").attr("id", "ideditor-mly").attr("class", "photo-wrapper mly-wrapper").classed("hide", true);
40938       const that = this;
40939       _loadViewerPromise = new Promise((resolve, reject) => {
40940         let loadedCount = 0;
40941         function loaded() {
40942           loadedCount += 1;
40943           if (loadedCount === 2) resolve();
40944         }
40945         const head = select_default2("head");
40946         head.selectAll("#ideditor-mapillary-viewercss").data([0]).enter().append("link").attr("id", "ideditor-mapillary-viewercss").attr("rel", "stylesheet").attr("crossorigin", "anonymous").attr("href", context.asset(viewercss)).on("load.serviceMapillary", loaded).on("error.serviceMapillary", function() {
40947           reject();
40948         });
40949         head.selectAll("#ideditor-mapillary-viewerjs").data([0]).enter().append("script").attr("id", "ideditor-mapillary-viewerjs").attr("crossorigin", "anonymous").attr("src", context.asset(viewerjs)).on("load.serviceMapillary", loaded).on("error.serviceMapillary", function() {
40950           reject();
40951         });
40952       }).catch(function() {
40953         _loadViewerPromise = null;
40954       }).then(function() {
40955         that.initViewer(context);
40956       });
40957       return _loadViewerPromise;
40958     },
40959     // Load traffic sign image sprites
40960     loadSignResources: function(context) {
40961       context.ui().svgDefs.addSprites(
40962         ["mapillary-sprite"],
40963         false
40964         /* don't override colors */
40965       );
40966       return this;
40967     },
40968     // Load map (point) feature image sprites
40969     loadObjectResources: function(context) {
40970       context.ui().svgDefs.addSprites(
40971         ["mapillary-object-sprite"],
40972         false
40973         /* don't override colors */
40974       );
40975       return this;
40976     },
40977     // Remove previous detections in image viewer
40978     resetTags: function() {
40979       if (_mlyViewer && !_mlyFallback) {
40980         _mlyViewer.getComponent("tag").removeAll();
40981       }
40982     },
40983     // Show map feature detections in image viewer
40984     showFeatureDetections: function(value) {
40985       _mlyShowFeatureDetections = value;
40986       if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) {
40987         this.resetTags();
40988       }
40989     },
40990     // Show traffic sign detections in image viewer
40991     showSignDetections: function(value) {
40992       _mlyShowSignDetections = value;
40993       if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) {
40994         this.resetTags();
40995       }
40996     },
40997     // Apply filter to image viewer
40998     filterViewer: function(context) {
40999       const showsPano = context.photos().showsPanoramic();
41000       const showsFlat = context.photos().showsFlat();
41001       const fromDate = context.photos().fromDate();
41002       const toDate = context.photos().toDate();
41003       const filter2 = ["all"];
41004       if (!showsPano) filter2.push(["!=", "cameraType", "spherical"]);
41005       if (!showsFlat && showsPano) filter2.push(["==", "pano", true]);
41006       if (fromDate) {
41007         filter2.push([">=", "capturedAt", new Date(fromDate).getTime()]);
41008       }
41009       if (toDate) {
41010         filter2.push([">=", "capturedAt", new Date(toDate).getTime()]);
41011       }
41012       if (_mlyViewer) {
41013         _mlyViewer.setFilter(filter2);
41014       }
41015       _mlyViewerFilter = filter2;
41016       return filter2;
41017     },
41018     // Make the image viewer visible
41019     showViewer: function(context) {
41020       const wrap2 = context.container().select(".photoviewer").classed("hide", false);
41021       const isHidden = wrap2.selectAll(".photo-wrapper.mly-wrapper.hide").size();
41022       if (isHidden && _mlyViewer) {
41023         wrap2.selectAll(".photo-wrapper:not(.mly-wrapper)").classed("hide", true);
41024         wrap2.selectAll(".photo-wrapper.mly-wrapper").classed("hide", false);
41025         _mlyViewer.resize();
41026       }
41027       _isViewerOpen = true;
41028       return this;
41029     },
41030     // Hide the image viewer and resets map markers
41031     hideViewer: function(context) {
41032       _mlyActiveImage = null;
41033       if (!_mlyFallback && _mlyViewer) {
41034         _mlyViewer.getComponent("sequence").stop();
41035       }
41036       const viewer = context.container().select(".photoviewer");
41037       if (!viewer.empty()) viewer.datum(null);
41038       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
41039       this.updateUrlImage(null);
41040       dispatch4.call("imageChanged");
41041       dispatch4.call("loadedMapFeatures");
41042       dispatch4.call("loadedSigns");
41043       _isViewerOpen = false;
41044       return this.setStyles(context, null);
41045     },
41046     // Get viewer status
41047     isViewerOpen: function() {
41048       return _isViewerOpen;
41049     },
41050     // Update the URL with current image id
41051     updateUrlImage: function(imageId) {
41052       if (!window.mocha) {
41053         const hash2 = utilStringQs(window.location.hash);
41054         if (imageId) {
41055           hash2.photo = "mapillary/" + imageId;
41056         } else {
41057           delete hash2.photo;
41058         }
41059         window.location.replace("#" + utilQsString(hash2, true));
41060       }
41061     },
41062     // Highlight the detection in the viewer that is related to the clicked map feature
41063     highlightDetection: function(detection) {
41064       if (detection) {
41065         _mlyHighlightedDetection = detection.id;
41066       }
41067       return this;
41068     },
41069     // Initialize image viewer (Mapillar JS)
41070     initViewer: function(context) {
41071       const that = this;
41072       if (!window.mapillary) return;
41073       const opts = {
41074         accessToken,
41075         component: {
41076           cover: false,
41077           keyboard: false,
41078           tag: true
41079         },
41080         container: "ideditor-mly"
41081       };
41082       if (!mapillary.isSupported() && mapillary.isFallbackSupported()) {
41083         _mlyFallback = true;
41084         opts.component = {
41085           cover: false,
41086           direction: false,
41087           imagePlane: false,
41088           keyboard: false,
41089           mouse: false,
41090           sequence: false,
41091           tag: false,
41092           image: true,
41093           // fallback
41094           navigation: true
41095           // fallback
41096         };
41097       }
41098       _mlyViewer = new mapillary.Viewer(opts);
41099       _mlyViewer.on("image", imageChanged);
41100       _mlyViewer.on("bearing", bearingChanged);
41101       if (_mlyViewerFilter) {
41102         _mlyViewer.setFilter(_mlyViewerFilter);
41103       }
41104       context.ui().photoviewer.on("resize.mapillary", function() {
41105         if (_mlyViewer) _mlyViewer.resize();
41106       });
41107       function imageChanged(node) {
41108         that.resetTags();
41109         const image = node.image;
41110         that.setActiveImage(image);
41111         that.setStyles(context, null);
41112         const loc = [image.originalLngLat.lng, image.originalLngLat.lat];
41113         context.map().centerEase(loc);
41114         that.updateUrlImage(image.id);
41115         if (_mlyShowFeatureDetections || _mlyShowSignDetections) {
41116           that.updateDetections(image.id, "".concat(apiUrl, "/").concat(image.id, "/detections?access_token=").concat(accessToken, "&fields=id,image,geometry,value"));
41117         }
41118         dispatch4.call("imageChanged");
41119       }
41120       function bearingChanged(e3) {
41121         dispatch4.call("bearingChanged", void 0, e3);
41122       }
41123     },
41124     // Move to an image
41125     selectImage: function(context, imageId) {
41126       if (_mlyViewer && imageId) {
41127         _mlyViewer.moveTo(imageId).catch(function(e3) {
41128           console.error("mly3", e3);
41129         });
41130       }
41131       return this;
41132     },
41133     // Return the currently displayed image
41134     getActiveImage: function() {
41135       return _mlyActiveImage;
41136     },
41137     // Return a list of detection objects for the given id
41138     getDetections: function(id2) {
41139       return loadData("".concat(apiUrl, "/").concat(id2, "/detections?access_token=").concat(accessToken, "&fields=id,value,image"));
41140     },
41141     // Set the currently visible image
41142     setActiveImage: function(image) {
41143       if (image) {
41144         _mlyActiveImage = {
41145           ca: image.originalCompassAngle,
41146           id: image.id,
41147           loc: [image.originalLngLat.lng, image.originalLngLat.lat],
41148           is_pano: image.cameraType === "spherical",
41149           sequence_id: image.sequenceId
41150         };
41151       } else {
41152         _mlyActiveImage = null;
41153       }
41154     },
41155     // Update the currently highlighted sequence and selected bubble.
41156     setStyles: function(context, hovered) {
41157       const hoveredImageId = hovered && hovered.id;
41158       const hoveredSequenceId = hovered && hovered.sequence_id;
41159       const selectedSequenceId = _mlyActiveImage && _mlyActiveImage.sequence_id;
41160       context.container().selectAll(".layer-mapillary .viewfield-group").classed("highlighted", function(d2) {
41161         return d2.sequence_id === selectedSequenceId || d2.id === hoveredImageId;
41162       }).classed("hovered", function(d2) {
41163         return d2.id === hoveredImageId;
41164       });
41165       context.container().selectAll(".layer-mapillary .sequence").classed("highlighted", function(d2) {
41166         return d2.properties.id === hoveredSequenceId;
41167       }).classed("currentView", function(d2) {
41168         return d2.properties.id === selectedSequenceId;
41169       });
41170       return this;
41171     },
41172     // Get detections for the current image and shows them in the image viewer
41173     updateDetections: function(imageId, url) {
41174       if (!_mlyViewer || _mlyFallback) return;
41175       if (!imageId) return;
41176       const cache = _mlyCache.image_detections;
41177       if (cache.forImageId[imageId]) {
41178         showDetections(_mlyCache.image_detections.forImageId[imageId]);
41179       } else {
41180         loadData(url).then((detections) => {
41181           detections.forEach(function(detection) {
41182             if (!cache.forImageId[imageId]) {
41183               cache.forImageId[imageId] = [];
41184             }
41185             cache.forImageId[imageId].push({
41186               geometry: detection.geometry,
41187               id: detection.id,
41188               image_id: imageId,
41189               value: detection.value
41190             });
41191           });
41192           showDetections(_mlyCache.image_detections.forImageId[imageId] || []);
41193         });
41194       }
41195       function showDetections(detections) {
41196         const tagComponent = _mlyViewer.getComponent("tag");
41197         detections.forEach(function(data) {
41198           const tag2 = makeTag(data);
41199           if (tag2) {
41200             tagComponent.add([tag2]);
41201           }
41202         });
41203       }
41204       function makeTag(data) {
41205         const valueParts = data.value.split("--");
41206         if (!valueParts.length) return;
41207         let tag2;
41208         let text;
41209         let color2 = 16777215;
41210         if (_mlyHighlightedDetection === data.id) {
41211           color2 = 16776960;
41212           text = valueParts[1];
41213           if (text === "flat" || text === "discrete" || text === "sign") {
41214             text = valueParts[2];
41215           }
41216           text = text.replace(/-/g, " ");
41217           text = text.charAt(0).toUpperCase() + text.slice(1);
41218           _mlyHighlightedDetection = null;
41219         }
41220         var decodedGeometry = window.atob(data.geometry);
41221         var uintArray = new Uint8Array(decodedGeometry.length);
41222         for (var i3 = 0; i3 < decodedGeometry.length; i3++) {
41223           uintArray[i3] = decodedGeometry.charCodeAt(i3);
41224         }
41225         const tile = new VectorTile(new Pbf(uintArray.buffer));
41226         const layer = tile.layers["mpy-or"];
41227         const geometries = layer.feature(0).loadGeometry();
41228         const polygon2 = geometries.map((ring) => ring.map((point) => [point.x / layer.extent, point.y / layer.extent]));
41229         tag2 = new mapillary.OutlineTag(
41230           data.id,
41231           new mapillary.PolygonGeometry(polygon2[0]),
41232           {
41233             text,
41234             textColor: color2,
41235             lineColor: color2,
41236             lineWidth: 2,
41237             fillColor: color2,
41238             fillOpacity: 0.3
41239           }
41240         );
41241         return tag2;
41242       }
41243     },
41244     // Return the current cache
41245     cache: function() {
41246       return _mlyCache;
41247     }
41248   };
41249
41250   // modules/core/validation/models.js
41251   function validationIssue(attrs) {
41252     this.type = attrs.type;
41253     this.subtype = attrs.subtype;
41254     this.severity = attrs.severity;
41255     this.message = attrs.message;
41256     this.reference = attrs.reference;
41257     this.entityIds = attrs.entityIds;
41258     this.loc = attrs.loc;
41259     this.data = attrs.data;
41260     this.dynamicFixes = attrs.dynamicFixes;
41261     this.hash = attrs.hash;
41262     this.id = generateID.apply(this);
41263     this.key = generateKey.apply(this);
41264     this.autoFix = null;
41265     function generateID() {
41266       var parts = [this.type];
41267       if (this.hash) {
41268         parts.push(this.hash);
41269       }
41270       if (this.subtype) {
41271         parts.push(this.subtype);
41272       }
41273       if (this.entityIds) {
41274         var entityKeys = this.entityIds.slice().sort();
41275         parts.push.apply(parts, entityKeys);
41276       }
41277       return parts.join(":");
41278     }
41279     function generateKey() {
41280       return this.id + ":" + Date.now().toString();
41281     }
41282     this.extent = function(resolver) {
41283       if (this.loc) {
41284         return geoExtent(this.loc);
41285       }
41286       if (this.entityIds && this.entityIds.length) {
41287         return this.entityIds.reduce(function(extent, entityId) {
41288           return extent.extend(resolver.entity(entityId).extent(resolver));
41289         }, geoExtent());
41290       }
41291       return null;
41292     };
41293     this.fixes = function(context) {
41294       var fixes = this.dynamicFixes ? this.dynamicFixes(context) : [];
41295       var issue = this;
41296       if (issue.severity === "warning") {
41297         fixes.push(new validationIssueFix({
41298           title: _t.append("issues.fix.ignore_issue.title"),
41299           icon: "iD-icon-close",
41300           onClick: function() {
41301             context.validator().ignoreIssue(this.issue.id);
41302           }
41303         }));
41304       }
41305       fixes.forEach(function(fix) {
41306         fix.id = fix.title.stringId;
41307         fix.issue = issue;
41308         if (fix.autoArgs) {
41309           issue.autoFix = fix;
41310         }
41311       });
41312       return fixes;
41313     };
41314   }
41315   function validationIssueFix(attrs) {
41316     this.title = attrs.title;
41317     this.onClick = attrs.onClick;
41318     this.disabledReason = attrs.disabledReason;
41319     this.icon = attrs.icon;
41320     this.entityIds = attrs.entityIds || [];
41321     this.autoArgs = attrs.autoArgs;
41322     this.issue = null;
41323   }
41324
41325   // modules/services/maprules.js
41326   var buildRuleChecks = function() {
41327     return {
41328       equals: function(equals) {
41329         return function(tags) {
41330           return Object.keys(equals).every(function(k2) {
41331             return equals[k2] === tags[k2];
41332           });
41333         };
41334       },
41335       notEquals: function(notEquals) {
41336         return function(tags) {
41337           return Object.keys(notEquals).some(function(k2) {
41338             return notEquals[k2] !== tags[k2];
41339           });
41340         };
41341       },
41342       absence: function(absence) {
41343         return function(tags) {
41344           return Object.keys(tags).indexOf(absence) === -1;
41345         };
41346       },
41347       presence: function(presence) {
41348         return function(tags) {
41349           return Object.keys(tags).indexOf(presence) > -1;
41350         };
41351       },
41352       greaterThan: function(greaterThan) {
41353         var key = Object.keys(greaterThan)[0];
41354         var value = greaterThan[key];
41355         return function(tags) {
41356           return tags[key] > value;
41357         };
41358       },
41359       greaterThanEqual: function(greaterThanEqual) {
41360         var key = Object.keys(greaterThanEqual)[0];
41361         var value = greaterThanEqual[key];
41362         return function(tags) {
41363           return tags[key] >= value;
41364         };
41365       },
41366       lessThan: function(lessThan) {
41367         var key = Object.keys(lessThan)[0];
41368         var value = lessThan[key];
41369         return function(tags) {
41370           return tags[key] < value;
41371         };
41372       },
41373       lessThanEqual: function(lessThanEqual) {
41374         var key = Object.keys(lessThanEqual)[0];
41375         var value = lessThanEqual[key];
41376         return function(tags) {
41377           return tags[key] <= value;
41378         };
41379       },
41380       positiveRegex: function(positiveRegex) {
41381         var tagKey = Object.keys(positiveRegex)[0];
41382         var expression = positiveRegex[tagKey].join("|");
41383         var regex = new RegExp(expression);
41384         return function(tags) {
41385           return regex.test(tags[tagKey]);
41386         };
41387       },
41388       negativeRegex: function(negativeRegex) {
41389         var tagKey = Object.keys(negativeRegex)[0];
41390         var expression = negativeRegex[tagKey].join("|");
41391         var regex = new RegExp(expression);
41392         return function(tags) {
41393           return !regex.test(tags[tagKey]);
41394         };
41395       }
41396     };
41397   };
41398   var buildLineKeys = function() {
41399     return {
41400       highway: {
41401         rest_area: true,
41402         services: true
41403       },
41404       railway: {
41405         roundhouse: true,
41406         station: true,
41407         traverser: true,
41408         turntable: true,
41409         wash: true
41410       }
41411     };
41412   };
41413   var maprules_default = {
41414     init: function() {
41415       this._ruleChecks = buildRuleChecks();
41416       this._validationRules = [];
41417       this._areaKeys = osmAreaKeys;
41418       this._lineKeys = buildLineKeys();
41419     },
41420     // list of rules only relevant to tag checks...
41421     filterRuleChecks: function(selector) {
41422       var _ruleChecks = this._ruleChecks;
41423       return Object.keys(selector).reduce(function(rules, key) {
41424         if (["geometry", "error", "warning"].indexOf(key) === -1) {
41425           rules.push(_ruleChecks[key](selector[key]));
41426         }
41427         return rules;
41428       }, []);
41429     },
41430     // builds tagMap from mapcss-parse selector object...
41431     buildTagMap: function(selector) {
41432       var getRegexValues = function(regexes) {
41433         return regexes.map(function(regex) {
41434           return regex.replace(/\$|\^/g, "");
41435         });
41436       };
41437       var tagMap = Object.keys(selector).reduce(function(expectedTags, key) {
41438         var values;
41439         var isRegex = /regex/gi.test(key);
41440         var isEqual4 = /equals/gi.test(key);
41441         if (isRegex || isEqual4) {
41442           Object.keys(selector[key]).forEach(function(selectorKey) {
41443             values = isEqual4 ? [selector[key][selectorKey]] : getRegexValues(selector[key][selectorKey]);
41444             if (expectedTags.hasOwnProperty(selectorKey)) {
41445               values = values.concat(expectedTags[selectorKey]);
41446             }
41447             expectedTags[selectorKey] = values;
41448           });
41449         } else if (/(greater|less)Than(Equal)?|presence/g.test(key)) {
41450           var tagKey = /presence/.test(key) ? selector[key] : Object.keys(selector[key])[0];
41451           values = [selector[key][tagKey]];
41452           if (expectedTags.hasOwnProperty(tagKey)) {
41453             values = values.concat(expectedTags[tagKey]);
41454           }
41455           expectedTags[tagKey] = values;
41456         }
41457         return expectedTags;
41458       }, {});
41459       return tagMap;
41460     },
41461     // inspired by osmWay#isArea()
41462     inferGeometry: function(tagMap) {
41463       var _lineKeys = this._lineKeys;
41464       var _areaKeys = this._areaKeys;
41465       var keyValueDoesNotImplyArea = function(key2) {
41466         return utilArrayIntersection(tagMap[key2], Object.keys(_areaKeys[key2])).length > 0;
41467       };
41468       var keyValueImpliesLine = function(key2) {
41469         return utilArrayIntersection(tagMap[key2], Object.keys(_lineKeys[key2])).length > 0;
41470       };
41471       if (tagMap.hasOwnProperty("area")) {
41472         if (tagMap.area.indexOf("yes") > -1) {
41473           return "area";
41474         }
41475         if (tagMap.area.indexOf("no") > -1) {
41476           return "line";
41477         }
41478       }
41479       for (var key in tagMap) {
41480         if (key in _areaKeys && !keyValueDoesNotImplyArea(key)) {
41481           return "area";
41482         }
41483         if (key in _lineKeys && keyValueImpliesLine(key)) {
41484           return "area";
41485         }
41486       }
41487       return "line";
41488     },
41489     // adds from mapcss-parse selector check...
41490     addRule: function(selector) {
41491       var rule = {
41492         // checks relevant to mapcss-selector
41493         checks: this.filterRuleChecks(selector),
41494         // true if all conditions for a tag error are true..
41495         matches: function(entity) {
41496           return this.checks.every(function(check) {
41497             return check(entity.tags);
41498           });
41499         },
41500         // borrowed from Way#isArea()
41501         inferredGeometry: this.inferGeometry(this.buildTagMap(selector), this._areaKeys),
41502         geometryMatches: function(entity, graph) {
41503           if (entity.type === "node" || entity.type === "relation") {
41504             return selector.geometry === entity.type;
41505           } else if (entity.type === "way") {
41506             return this.inferredGeometry === entity.geometry(graph);
41507           }
41508         },
41509         // when geometries match and tag matches are present, return a warning...
41510         findIssues: function(entity, graph, issues) {
41511           if (this.geometryMatches(entity, graph) && this.matches(entity)) {
41512             var severity = Object.keys(selector).indexOf("error") > -1 ? "error" : "warning";
41513             var message = selector[severity];
41514             issues.push(new validationIssue({
41515               type: "maprules",
41516               severity,
41517               message: function() {
41518                 return message;
41519               },
41520               entityIds: [entity.id]
41521             }));
41522           }
41523         }
41524       };
41525       this._validationRules.push(rule);
41526     },
41527     clearRules: function() {
41528       this._validationRules = [];
41529     },
41530     // returns validationRules...
41531     validationRules: function() {
41532       return this._validationRules;
41533     },
41534     // returns ruleChecks
41535     ruleChecks: function() {
41536       return this._ruleChecks;
41537     }
41538   };
41539
41540   // modules/core/difference.js
41541   var import_fast_deep_equal3 = __toESM(require_fast_deep_equal());
41542   function coreDifference(base, head) {
41543     var _changes = {};
41544     var _didChange = {};
41545     var _diff = {};
41546     function checkEntityID(id2) {
41547       var h2 = head.entities[id2];
41548       var b2 = base.entities[id2];
41549       if (h2 === b2) return;
41550       if (_changes[id2]) return;
41551       if (!h2 && b2) {
41552         _changes[id2] = { base: b2, head: h2 };
41553         _didChange.deletion = true;
41554         return;
41555       }
41556       if (h2 && !b2) {
41557         _changes[id2] = { base: b2, head: h2 };
41558         _didChange.addition = true;
41559         return;
41560       }
41561       if (h2 && b2) {
41562         if (h2.members && b2.members && !(0, import_fast_deep_equal3.default)(h2.members, b2.members)) {
41563           _changes[id2] = { base: b2, head: h2 };
41564           _didChange.geometry = true;
41565           _didChange.properties = true;
41566           return;
41567         }
41568         if (h2.loc && b2.loc && !geoVecEqual(h2.loc, b2.loc)) {
41569           _changes[id2] = { base: b2, head: h2 };
41570           _didChange.geometry = true;
41571         }
41572         if (h2.nodes && b2.nodes && !(0, import_fast_deep_equal3.default)(h2.nodes, b2.nodes)) {
41573           _changes[id2] = { base: b2, head: h2 };
41574           _didChange.geometry = true;
41575         }
41576         if (h2.tags && b2.tags && !(0, import_fast_deep_equal3.default)(h2.tags, b2.tags)) {
41577           _changes[id2] = { base: b2, head: h2 };
41578           _didChange.properties = true;
41579         }
41580       }
41581     }
41582     function load() {
41583       var ids = utilArrayUniq(Object.keys(head.entities).concat(Object.keys(base.entities)));
41584       for (var i3 = 0; i3 < ids.length; i3++) {
41585         checkEntityID(ids[i3]);
41586       }
41587     }
41588     load();
41589     _diff.length = function length2() {
41590       return Object.keys(_changes).length;
41591     };
41592     _diff.changes = function changes() {
41593       return _changes;
41594     };
41595     _diff.didChange = _didChange;
41596     _diff.extantIDs = function extantIDs(includeRelMembers) {
41597       var result = /* @__PURE__ */ new Set();
41598       Object.keys(_changes).forEach(function(id2) {
41599         if (_changes[id2].head) {
41600           result.add(id2);
41601         }
41602         var h2 = _changes[id2].head;
41603         var b2 = _changes[id2].base;
41604         var entity = h2 || b2;
41605         if (includeRelMembers && entity.type === "relation") {
41606           var mh = h2 ? h2.members.map(function(m2) {
41607             return m2.id;
41608           }) : [];
41609           var mb = b2 ? b2.members.map(function(m2) {
41610             return m2.id;
41611           }) : [];
41612           utilArrayUnion(mh, mb).forEach(function(memberID) {
41613             if (head.hasEntity(memberID)) {
41614               result.add(memberID);
41615             }
41616           });
41617         }
41618       });
41619       return Array.from(result);
41620     };
41621     _diff.modified = function modified() {
41622       var result = [];
41623       Object.values(_changes).forEach(function(change) {
41624         if (change.base && change.head) {
41625           result.push(change.head);
41626         }
41627       });
41628       return result;
41629     };
41630     _diff.created = function created() {
41631       var result = [];
41632       Object.values(_changes).forEach(function(change) {
41633         if (!change.base && change.head) {
41634           result.push(change.head);
41635         }
41636       });
41637       return result;
41638     };
41639     _diff.deleted = function deleted() {
41640       var result = [];
41641       Object.values(_changes).forEach(function(change) {
41642         if (change.base && !change.head) {
41643           result.push(change.base);
41644         }
41645       });
41646       return result;
41647     };
41648     _diff.summary = function summary() {
41649       var relevant = {};
41650       var keys2 = Object.keys(_changes);
41651       for (var i3 = 0; i3 < keys2.length; i3++) {
41652         var change = _changes[keys2[i3]];
41653         if (change.head && change.head.geometry(head) !== "vertex") {
41654           addEntity(change.head, head, change.base ? "modified" : "created");
41655         } else if (change.base && change.base.geometry(base) !== "vertex") {
41656           addEntity(change.base, base, "deleted");
41657         } else if (change.base && change.head) {
41658           var moved = !(0, import_fast_deep_equal3.default)(change.base.loc, change.head.loc);
41659           var retagged = !(0, import_fast_deep_equal3.default)(change.base.tags, change.head.tags);
41660           if (moved) {
41661             addParents(change.head);
41662           }
41663           if (retagged || moved && change.head.hasInterestingTags()) {
41664             addEntity(change.head, head, "modified");
41665           }
41666         } else if (change.head && change.head.hasInterestingTags()) {
41667           addEntity(change.head, head, "created");
41668         } else if (change.base && change.base.hasInterestingTags()) {
41669           addEntity(change.base, base, "deleted");
41670         }
41671       }
41672       return Object.values(relevant);
41673       function addEntity(entity, graph, changeType) {
41674         relevant[entity.id] = {
41675           entity,
41676           graph,
41677           changeType
41678         };
41679       }
41680       function addParents(entity) {
41681         var parents = head.parentWays(entity);
41682         for (var j2 = parents.length - 1; j2 >= 0; j2--) {
41683           var parent = parents[j2];
41684           if (!(parent.id in relevant)) {
41685             addEntity(parent, head, "modified");
41686           }
41687         }
41688       }
41689     };
41690     _diff.complete = function complete(extent) {
41691       var result = {};
41692       var id2, change;
41693       for (id2 in _changes) {
41694         change = _changes[id2];
41695         var h2 = change.head;
41696         var b2 = change.base;
41697         var entity = h2 || b2;
41698         var i3;
41699         if (extent && (!h2 || !h2.intersects(extent, head)) && (!b2 || !b2.intersects(extent, base))) {
41700           continue;
41701         }
41702         result[id2] = h2;
41703         if (entity.type === "way") {
41704           var nh = h2 ? h2.nodes : [];
41705           var nb = b2 ? b2.nodes : [];
41706           var diff;
41707           diff = utilArrayDifference(nh, nb);
41708           for (i3 = 0; i3 < diff.length; i3++) {
41709             result[diff[i3]] = head.hasEntity(diff[i3]);
41710           }
41711           diff = utilArrayDifference(nb, nh);
41712           for (i3 = 0; i3 < diff.length; i3++) {
41713             result[diff[i3]] = head.hasEntity(diff[i3]);
41714           }
41715         }
41716         if (entity.type === "relation" && entity.isMultipolygon()) {
41717           var mh = h2 ? h2.members.map(function(m2) {
41718             return m2.id;
41719           }) : [];
41720           var mb = b2 ? b2.members.map(function(m2) {
41721             return m2.id;
41722           }) : [];
41723           var ids = utilArrayUnion(mh, mb);
41724           for (i3 = 0; i3 < ids.length; i3++) {
41725             var member = head.hasEntity(ids[i3]);
41726             if (!member) continue;
41727             if (extent && !member.intersects(extent, head)) continue;
41728             result[ids[i3]] = member;
41729           }
41730         }
41731         addParents(head.parentWays(entity), result);
41732         addParents(head.parentRelations(entity), result);
41733       }
41734       return result;
41735       function addParents(parents, result2) {
41736         for (var i4 = 0; i4 < parents.length; i4++) {
41737           var parent = parents[i4];
41738           if (parent.id in result2) continue;
41739           result2[parent.id] = parent;
41740           addParents(head.parentRelations(parent), result2);
41741         }
41742       }
41743     };
41744     return _diff;
41745   }
41746
41747   // modules/core/tree.js
41748   function coreTree(head) {
41749     var _rtree = new RBush();
41750     var _bboxes = {};
41751     var _segmentsRTree = new RBush();
41752     var _segmentsBBoxes = {};
41753     var _segmentsByWayId = {};
41754     var tree = {};
41755     function entityBBox(entity) {
41756       var bbox2 = entity.extent(head).bbox();
41757       bbox2.id = entity.id;
41758       _bboxes[entity.id] = bbox2;
41759       return bbox2;
41760     }
41761     function segmentBBox(segment) {
41762       var extent = segment.extent(head);
41763       if (!extent) return null;
41764       var bbox2 = extent.bbox();
41765       bbox2.segment = segment;
41766       _segmentsBBoxes[segment.id] = bbox2;
41767       return bbox2;
41768     }
41769     function removeEntity(entity) {
41770       _rtree.remove(_bboxes[entity.id]);
41771       delete _bboxes[entity.id];
41772       if (_segmentsByWayId[entity.id]) {
41773         _segmentsByWayId[entity.id].forEach(function(segment) {
41774           _segmentsRTree.remove(_segmentsBBoxes[segment.id]);
41775           delete _segmentsBBoxes[segment.id];
41776         });
41777         delete _segmentsByWayId[entity.id];
41778       }
41779     }
41780     function loadEntities(entities) {
41781       _rtree.load(entities.map(entityBBox));
41782       var segments = [];
41783       entities.forEach(function(entity) {
41784         if (entity.segments) {
41785           var entitySegments = entity.segments(head);
41786           _segmentsByWayId[entity.id] = entitySegments;
41787           segments = segments.concat(entitySegments);
41788         }
41789       });
41790       if (segments.length) _segmentsRTree.load(segments.map(segmentBBox).filter(Boolean));
41791     }
41792     function updateParents(entity, insertions, memo) {
41793       head.parentWays(entity).forEach(function(way) {
41794         if (_bboxes[way.id]) {
41795           removeEntity(way);
41796           insertions[way.id] = way;
41797         }
41798         updateParents(way, insertions, memo);
41799       });
41800       head.parentRelations(entity).forEach(function(relation) {
41801         if (memo[relation.id]) return;
41802         memo[relation.id] = true;
41803         if (_bboxes[relation.id]) {
41804           removeEntity(relation);
41805           insertions[relation.id] = relation;
41806         }
41807         updateParents(relation, insertions, memo);
41808       });
41809     }
41810     tree.rebase = function(entities, force) {
41811       var insertions = {};
41812       for (var i3 = 0; i3 < entities.length; i3++) {
41813         var entity = entities[i3];
41814         if (!entity.visible) continue;
41815         if (head.entities.hasOwnProperty(entity.id) || _bboxes[entity.id]) {
41816           if (!force) {
41817             continue;
41818           } else if (_bboxes[entity.id]) {
41819             removeEntity(entity);
41820           }
41821         }
41822         insertions[entity.id] = entity;
41823         updateParents(entity, insertions, {});
41824       }
41825       loadEntities(Object.values(insertions));
41826       return tree;
41827     };
41828     function updateToGraph(graph) {
41829       if (graph === head) return;
41830       var diff = coreDifference(head, graph);
41831       head = graph;
41832       var changed = diff.didChange;
41833       if (!changed.addition && !changed.deletion && !changed.geometry) return;
41834       var insertions = {};
41835       if (changed.deletion) {
41836         diff.deleted().forEach(function(entity) {
41837           removeEntity(entity);
41838         });
41839       }
41840       if (changed.geometry) {
41841         diff.modified().forEach(function(entity) {
41842           removeEntity(entity);
41843           insertions[entity.id] = entity;
41844           updateParents(entity, insertions, {});
41845         });
41846       }
41847       if (changed.addition) {
41848         diff.created().forEach(function(entity) {
41849           insertions[entity.id] = entity;
41850         });
41851       }
41852       loadEntities(Object.values(insertions));
41853     }
41854     tree.intersects = function(extent, graph) {
41855       updateToGraph(graph);
41856       return _rtree.search(extent.bbox()).map(function(bbox2) {
41857         return graph.entity(bbox2.id);
41858       });
41859     };
41860     tree.waySegments = function(extent, graph) {
41861       updateToGraph(graph);
41862       return _segmentsRTree.search(extent.bbox()).map(function(bbox2) {
41863         return bbox2.segment;
41864       });
41865     };
41866     return tree;
41867   }
41868
41869   // modules/svg/icon.js
41870   function svgIcon(name, svgklass, useklass) {
41871     return function drawIcon(selection2) {
41872       selection2.selectAll("svg.icon" + (svgklass ? "." + svgklass.split(" ")[0] : "")).data([0]).enter().append("svg").attr("class", "icon " + (svgklass || "")).append("use").attr("xlink:href", name).attr("class", useklass);
41873     };
41874   }
41875
41876   // modules/ui/modal.js
41877   function uiModal(selection2, blocking) {
41878     let keybinding = utilKeybinding("modal");
41879     let previous = selection2.select("div.modal");
41880     let animate = previous.empty();
41881     previous.transition().duration(200).style("opacity", 0).remove();
41882     let shaded = selection2.append("div").attr("class", "shaded").style("opacity", 0);
41883     shaded.close = () => {
41884       shaded.transition().duration(200).style("opacity", 0).remove();
41885       modal.transition().duration(200).style("top", "0px");
41886       select_default2(document).call(keybinding.unbind);
41887     };
41888     let modal = shaded.append("div").attr("class", "modal fillL");
41889     modal.append("input").attr("class", "keytrap keytrap-first").on("focus.keytrap", moveFocusToLast);
41890     if (!blocking) {
41891       shaded.on("click.remove-modal", (d3_event) => {
41892         if (d3_event.target === this) {
41893           shaded.close();
41894         }
41895       });
41896       modal.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", shaded.close).call(svgIcon("#iD-icon-close"));
41897       keybinding.on("\u232B", shaded.close).on("\u238B", shaded.close);
41898       select_default2(document).call(keybinding);
41899     }
41900     modal.append("div").attr("class", "content");
41901     modal.append("input").attr("class", "keytrap keytrap-last").on("focus.keytrap", moveFocusToFirst);
41902     if (animate) {
41903       shaded.transition().style("opacity", 1);
41904     } else {
41905       shaded.style("opacity", 1);
41906     }
41907     return shaded;
41908     function moveFocusToFirst() {
41909       let node = modal.select("a, button, input:not(.keytrap), select, textarea").node();
41910       if (node) {
41911         node.focus();
41912       } else {
41913         select_default2(this).node().blur();
41914       }
41915     }
41916     function moveFocusToLast() {
41917       let nodes = modal.selectAll("a, button, input:not(.keytrap), select, textarea").nodes();
41918       if (nodes.length) {
41919         nodes[nodes.length - 1].focus();
41920       } else {
41921         select_default2(this).node().blur();
41922       }
41923     }
41924   }
41925
41926   // modules/ui/loading.js
41927   function uiLoading(context) {
41928     let _modalSelection = select_default2(null);
41929     let _message = "";
41930     let _blocking = false;
41931     let loading = (selection2) => {
41932       _modalSelection = uiModal(selection2, _blocking);
41933       let loadertext = _modalSelection.select(".content").classed("loading-modal", true).append("div").attr("class", "modal-section fillL");
41934       loadertext.append("img").attr("class", "loader").attr("src", context.imagePath("loader-white.gif"));
41935       loadertext.append("h3").html(_message);
41936       _modalSelection.select("button.close").attr("class", "hide");
41937       return loading;
41938     };
41939     loading.message = function(val) {
41940       if (!arguments.length) return _message;
41941       _message = val;
41942       return loading;
41943     };
41944     loading.blocking = function(val) {
41945       if (!arguments.length) return _blocking;
41946       _blocking = val;
41947       return loading;
41948     };
41949     loading.close = () => {
41950       _modalSelection.remove();
41951     };
41952     loading.isShown = () => {
41953       return _modalSelection && !_modalSelection.empty() && _modalSelection.node().parentNode;
41954     };
41955     return loading;
41956   }
41957
41958   // modules/core/history.js
41959   function coreHistory(context) {
41960     var dispatch14 = dispatch_default("reset", "change", "merge", "restore", "undone", "redone", "storage_error");
41961     var lock = utilSessionMutex("lock");
41962     var _hasUnresolvedRestorableChanges = lock.lock() && !!corePreferences(getKey("saved_history"));
41963     var duration = 150;
41964     var _imageryUsed = [];
41965     var _photoOverlaysUsed = [];
41966     var _checkpoints = {};
41967     var _pausedGraph;
41968     var _stack;
41969     var _index;
41970     var _tree;
41971     function _act(actions, t2) {
41972       actions = Array.prototype.slice.call(actions);
41973       var annotation;
41974       if (typeof actions[actions.length - 1] !== "function") {
41975         annotation = actions.pop();
41976       }
41977       var graph = _stack[_index].graph;
41978       for (var i3 = 0; i3 < actions.length; i3++) {
41979         graph = actions[i3](graph, t2);
41980       }
41981       return {
41982         graph,
41983         annotation,
41984         imageryUsed: _imageryUsed,
41985         photoOverlaysUsed: _photoOverlaysUsed,
41986         transform: context.projection.transform(),
41987         selectedIDs: context.selectedIDs()
41988       };
41989     }
41990     function _perform(args, t2) {
41991       var previous = _stack[_index].graph;
41992       _stack = _stack.slice(0, _index + 1);
41993       var actionResult = _act(args, t2);
41994       _stack.push(actionResult);
41995       _index++;
41996       return change(previous);
41997     }
41998     function _replace(args, t2) {
41999       var previous = _stack[_index].graph;
42000       var actionResult = _act(args, t2);
42001       _stack[_index] = actionResult;
42002       return change(previous);
42003     }
42004     function _overwrite(args, t2) {
42005       var previous = _stack[_index].graph;
42006       if (_index > 0) {
42007         _index--;
42008         _stack.pop();
42009       }
42010       _stack = _stack.slice(0, _index + 1);
42011       var actionResult = _act(args, t2);
42012       _stack.push(actionResult);
42013       _index++;
42014       return change(previous);
42015     }
42016     function change(previous) {
42017       var difference2 = coreDifference(previous, history.graph());
42018       if (!_pausedGraph) {
42019         dispatch14.call("change", this, difference2);
42020       }
42021       return difference2;
42022     }
42023     function getKey(n3) {
42024       return "iD_" + window.location.origin + "_" + n3;
42025     }
42026     var history = {
42027       graph: function() {
42028         return _stack[_index].graph;
42029       },
42030       tree: function() {
42031         return _tree;
42032       },
42033       base: function() {
42034         return _stack[0].graph;
42035       },
42036       merge: function(entities) {
42037         var stack = _stack.map(function(state) {
42038           return state.graph;
42039         });
42040         _stack[0].graph.rebase(entities, stack, false);
42041         _tree.rebase(entities, false);
42042         dispatch14.call("merge", this, entities);
42043       },
42044       perform: function() {
42045         select_default2(document).interrupt("history.perform");
42046         var transitionable = false;
42047         var action0 = arguments[0];
42048         if (arguments.length === 1 || arguments.length === 2 && typeof arguments[1] !== "function") {
42049           transitionable = !!action0.transitionable;
42050         }
42051         if (transitionable) {
42052           var origArguments = arguments;
42053           select_default2(document).transition("history.perform").duration(duration).ease(linear2).tween("history.tween", function() {
42054             return function(t2) {
42055               if (t2 < 1) _overwrite([action0], t2);
42056             };
42057           }).on("start", function() {
42058             _perform([action0], 0);
42059           }).on("end interrupt", function() {
42060             _overwrite(origArguments, 1);
42061           });
42062         } else {
42063           return _perform(arguments);
42064         }
42065       },
42066       replace: function() {
42067         select_default2(document).interrupt("history.perform");
42068         return _replace(arguments, 1);
42069       },
42070       // Same as calling pop and then perform
42071       overwrite: function() {
42072         select_default2(document).interrupt("history.perform");
42073         return _overwrite(arguments, 1);
42074       },
42075       pop: function(n3) {
42076         select_default2(document).interrupt("history.perform");
42077         var previous = _stack[_index].graph;
42078         if (isNaN(+n3) || +n3 < 0) {
42079           n3 = 1;
42080         }
42081         while (n3-- > 0 && _index > 0) {
42082           _index--;
42083           _stack.pop();
42084         }
42085         return change(previous);
42086       },
42087       // Back to the previous annotated state or _index = 0.
42088       undo: function() {
42089         select_default2(document).interrupt("history.perform");
42090         var previousStack = _stack[_index];
42091         var previous = previousStack.graph;
42092         while (_index > 0) {
42093           _index--;
42094           if (_stack[_index].annotation) break;
42095         }
42096         dispatch14.call("undone", this, _stack[_index], previousStack);
42097         return change(previous);
42098       },
42099       // Forward to the next annotated state.
42100       redo: function() {
42101         select_default2(document).interrupt("history.perform");
42102         var previousStack = _stack[_index];
42103         var previous = previousStack.graph;
42104         var tryIndex = _index;
42105         while (tryIndex < _stack.length - 1) {
42106           tryIndex++;
42107           if (_stack[tryIndex].annotation) {
42108             _index = tryIndex;
42109             dispatch14.call("redone", this, _stack[_index], previousStack);
42110             break;
42111           }
42112         }
42113         return change(previous);
42114       },
42115       pauseChangeDispatch: function() {
42116         if (!_pausedGraph) {
42117           _pausedGraph = _stack[_index].graph;
42118         }
42119       },
42120       resumeChangeDispatch: function() {
42121         if (_pausedGraph) {
42122           var previous = _pausedGraph;
42123           _pausedGraph = null;
42124           return change(previous);
42125         }
42126       },
42127       undoAnnotation: function() {
42128         var i3 = _index;
42129         while (i3 >= 0) {
42130           if (_stack[i3].annotation) return _stack[i3].annotation;
42131           i3--;
42132         }
42133       },
42134       redoAnnotation: function() {
42135         var i3 = _index + 1;
42136         while (i3 <= _stack.length - 1) {
42137           if (_stack[i3].annotation) return _stack[i3].annotation;
42138           i3++;
42139         }
42140       },
42141       // Returns the entities from the active graph with bounding boxes
42142       // overlapping the given `extent`.
42143       intersects: function(extent) {
42144         return _tree.intersects(extent, _stack[_index].graph);
42145       },
42146       difference: function() {
42147         var base = _stack[0].graph;
42148         var head = _stack[_index].graph;
42149         return coreDifference(base, head);
42150       },
42151       changes: function(action) {
42152         var base = _stack[0].graph;
42153         var head = _stack[_index].graph;
42154         if (action) {
42155           head = action(head);
42156         }
42157         var difference2 = coreDifference(base, head);
42158         return {
42159           modified: difference2.modified(),
42160           created: difference2.created(),
42161           deleted: difference2.deleted()
42162         };
42163       },
42164       hasChanges: function() {
42165         return this.difference().length() > 0;
42166       },
42167       imageryUsed: function(sources) {
42168         if (sources) {
42169           _imageryUsed = sources;
42170           return history;
42171         } else {
42172           var s2 = /* @__PURE__ */ new Set();
42173           _stack.slice(1, _index + 1).forEach(function(state) {
42174             state.imageryUsed.forEach(function(source) {
42175               if (source !== "Custom") {
42176                 s2.add(source);
42177               }
42178             });
42179           });
42180           return Array.from(s2);
42181         }
42182       },
42183       photoOverlaysUsed: function(sources) {
42184         if (sources) {
42185           _photoOverlaysUsed = sources;
42186           return history;
42187         } else {
42188           var s2 = /* @__PURE__ */ new Set();
42189           _stack.slice(1, _index + 1).forEach(function(state) {
42190             if (state.photoOverlaysUsed && Array.isArray(state.photoOverlaysUsed)) {
42191               state.photoOverlaysUsed.forEach(function(photoOverlay) {
42192                 s2.add(photoOverlay);
42193               });
42194             }
42195           });
42196           return Array.from(s2);
42197         }
42198       },
42199       // save the current history state
42200       checkpoint: function(key) {
42201         _checkpoints[key] = {
42202           stack: _stack,
42203           index: _index
42204         };
42205         return history;
42206       },
42207       // restore history state to a given checkpoint or reset completely
42208       reset: function(key) {
42209         if (key !== void 0 && _checkpoints.hasOwnProperty(key)) {
42210           _stack = _checkpoints[key].stack;
42211           _index = _checkpoints[key].index;
42212         } else {
42213           _stack = [{ graph: coreGraph() }];
42214           _index = 0;
42215           _tree = coreTree(_stack[0].graph);
42216           _checkpoints = {};
42217         }
42218         dispatch14.call("reset");
42219         dispatch14.call("change");
42220         return history;
42221       },
42222       // `toIntroGraph()` is used to export the intro graph used by the walkthrough.
42223       //
42224       // To use it:
42225       //  1. Start the walkthrough.
42226       //  2. Get to a "free editing" tutorial step
42227       //  3. Make your edits to the walkthrough map
42228       //  4. In your browser dev console run:
42229       //        `id.history().toIntroGraph()`
42230       //  5. This outputs stringified JSON to the browser console
42231       //  6. Copy it to `data/intro_graph.json` and prettify it in your code editor
42232       toIntroGraph: function() {
42233         var nextID = { n: 0, r: 0, w: 0 };
42234         var permIDs = {};
42235         var graph = this.graph();
42236         var baseEntities = {};
42237         Object.values(graph.base().entities).forEach(function(entity) {
42238           var copy2 = copyIntroEntity(entity);
42239           baseEntities[copy2.id] = copy2;
42240         });
42241         Object.keys(graph.entities).forEach(function(id2) {
42242           var entity = graph.entities[id2];
42243           if (entity) {
42244             var copy2 = copyIntroEntity(entity);
42245             baseEntities[copy2.id] = copy2;
42246           } else {
42247             delete baseEntities[id2];
42248           }
42249         });
42250         Object.values(baseEntities).forEach(function(entity) {
42251           if (Array.isArray(entity.nodes)) {
42252             entity.nodes = entity.nodes.map(function(node) {
42253               return permIDs[node] || node;
42254             });
42255           }
42256           if (Array.isArray(entity.members)) {
42257             entity.members = entity.members.map(function(member) {
42258               member.id = permIDs[member.id] || member.id;
42259               return member;
42260             });
42261           }
42262         });
42263         return JSON.stringify({ dataIntroGraph: baseEntities });
42264         function copyIntroEntity(source) {
42265           var copy2 = utilObjectOmit(source, ["type", "user", "v", "version", "visible"]);
42266           if (copy2.tags && !Object.keys(copy2.tags)) {
42267             delete copy2.tags;
42268           }
42269           if (Array.isArray(copy2.loc)) {
42270             copy2.loc[0] = +copy2.loc[0].toFixed(6);
42271             copy2.loc[1] = +copy2.loc[1].toFixed(6);
42272           }
42273           var match = source.id.match(/([nrw])-\d*/);
42274           if (match !== null) {
42275             var nrw = match[1];
42276             var permID;
42277             do {
42278               permID = nrw + ++nextID[nrw];
42279             } while (baseEntities.hasOwnProperty(permID));
42280             copy2.id = permIDs[source.id] = permID;
42281           }
42282           return copy2;
42283         }
42284       },
42285       toJSON: function() {
42286         if (!this.hasChanges()) return;
42287         var allEntities = {};
42288         var baseEntities = {};
42289         var base = _stack[0];
42290         var s2 = _stack.map(function(i3) {
42291           var modified = [];
42292           var deleted = [];
42293           Object.keys(i3.graph.entities).forEach(function(id2) {
42294             var entity = i3.graph.entities[id2];
42295             if (entity) {
42296               var key = osmEntity.key(entity);
42297               allEntities[key] = entity;
42298               modified.push(key);
42299             } else {
42300               deleted.push(id2);
42301             }
42302             if (id2 in base.graph.entities) {
42303               baseEntities[id2] = base.graph.entities[id2];
42304             }
42305             if (entity && entity.nodes) {
42306               entity.nodes.forEach(function(nodeID) {
42307                 if (nodeID in base.graph.entities) {
42308                   baseEntities[nodeID] = base.graph.entities[nodeID];
42309                 }
42310               });
42311             }
42312             var baseParents = base.graph._parentWays[id2];
42313             if (baseParents) {
42314               baseParents.forEach(function(parentID) {
42315                 if (parentID in base.graph.entities) {
42316                   baseEntities[parentID] = base.graph.entities[parentID];
42317                 }
42318               });
42319             }
42320           });
42321           var x2 = {};
42322           if (modified.length) x2.modified = modified;
42323           if (deleted.length) x2.deleted = deleted;
42324           if (i3.imageryUsed) x2.imageryUsed = i3.imageryUsed;
42325           if (i3.photoOverlaysUsed) x2.photoOverlaysUsed = i3.photoOverlaysUsed;
42326           if (i3.annotation) x2.annotation = i3.annotation;
42327           if (i3.transform) x2.transform = i3.transform;
42328           if (i3.selectedIDs) x2.selectedIDs = i3.selectedIDs;
42329           return x2;
42330         });
42331         return JSON.stringify({
42332           version: 3,
42333           entities: Object.values(allEntities),
42334           baseEntities: Object.values(baseEntities),
42335           stack: s2,
42336           nextIDs: osmEntity.id.next,
42337           index: _index,
42338           // note the time the changes were saved
42339           timestamp: (/* @__PURE__ */ new Date()).getTime()
42340         });
42341       },
42342       fromJSON: function(json, loadChildNodes) {
42343         var h2 = JSON.parse(json);
42344         var loadComplete = true;
42345         osmEntity.id.next = h2.nextIDs;
42346         _index = h2.index;
42347         if (h2.version === 2 || h2.version === 3) {
42348           var allEntities = {};
42349           h2.entities.forEach(function(entity) {
42350             allEntities[osmEntity.key(entity)] = osmEntity(entity);
42351           });
42352           if (h2.version === 3) {
42353             var baseEntities = h2.baseEntities.map(function(d2) {
42354               return osmEntity(d2);
42355             });
42356             var stack = _stack.map(function(state) {
42357               return state.graph;
42358             });
42359             _stack[0].graph.rebase(baseEntities, stack, true);
42360             _tree.rebase(baseEntities, true);
42361             if (loadChildNodes) {
42362               var osm = context.connection();
42363               var baseWays = baseEntities.filter(function(e3) {
42364                 return e3.type === "way";
42365               });
42366               var nodeIDs = baseWays.reduce(function(acc, way) {
42367                 return utilArrayUnion(acc, way.nodes);
42368               }, []);
42369               var missing = nodeIDs.filter(function(n3) {
42370                 return !_stack[0].graph.hasEntity(n3);
42371               });
42372               if (missing.length && osm) {
42373                 loadComplete = false;
42374                 context.map().redrawEnable(false);
42375                 var loading = uiLoading(context).blocking(true);
42376                 context.container().call(loading);
42377                 var childNodesLoaded = function(err, result) {
42378                   if (!err) {
42379                     var visibleGroups = utilArrayGroupBy(result.data, "visible");
42380                     var visibles = visibleGroups.true || [];
42381                     var invisibles = visibleGroups.false || [];
42382                     if (visibles.length) {
42383                       var visibleIDs = visibles.map(function(entity) {
42384                         return entity.id;
42385                       });
42386                       var stack2 = _stack.map(function(state) {
42387                         return state.graph;
42388                       });
42389                       missing = utilArrayDifference(missing, visibleIDs);
42390                       _stack[0].graph.rebase(visibles, stack2, true);
42391                       _tree.rebase(visibles, true);
42392                     }
42393                     invisibles.forEach(function(entity) {
42394                       osm.loadEntityVersion(entity.id, +entity.version - 1, childNodesLoaded);
42395                     });
42396                   }
42397                   if (err || !missing.length) {
42398                     loading.close();
42399                     context.map().redrawEnable(true);
42400                     dispatch14.call("change");
42401                     dispatch14.call("restore", this);
42402                   }
42403                 };
42404                 osm.loadMultiple(missing, childNodesLoaded);
42405               }
42406             }
42407           }
42408           _stack = h2.stack.map(function(d2) {
42409             var entities = {}, entity;
42410             if (d2.modified) {
42411               d2.modified.forEach(function(key) {
42412                 entity = allEntities[key];
42413                 entities[entity.id] = entity;
42414               });
42415             }
42416             if (d2.deleted) {
42417               d2.deleted.forEach(function(id2) {
42418                 entities[id2] = void 0;
42419               });
42420             }
42421             return {
42422               graph: coreGraph(_stack[0].graph).load(entities),
42423               annotation: d2.annotation,
42424               imageryUsed: d2.imageryUsed,
42425               photoOverlaysUsed: d2.photoOverlaysUsed,
42426               transform: d2.transform,
42427               selectedIDs: d2.selectedIDs
42428             };
42429           });
42430         } else {
42431           _stack = h2.stack.map(function(d2) {
42432             var entities = {};
42433             for (var i3 in d2.entities) {
42434               var entity = d2.entities[i3];
42435               entities[i3] = entity === "undefined" ? void 0 : osmEntity(entity);
42436             }
42437             d2.graph = coreGraph(_stack[0].graph).load(entities);
42438             return d2;
42439           });
42440         }
42441         var transform2 = _stack[_index].transform;
42442         if (transform2) {
42443           context.map().transformEase(transform2, 0);
42444         }
42445         if (loadComplete) {
42446           dispatch14.call("change");
42447           dispatch14.call("restore", this);
42448         }
42449         return history;
42450       },
42451       lock: function() {
42452         return lock.lock();
42453       },
42454       unlock: function() {
42455         lock.unlock();
42456       },
42457       save: function() {
42458         if (lock.locked() && // don't overwrite existing, unresolved changes
42459         !_hasUnresolvedRestorableChanges) {
42460           const success = corePreferences(getKey("saved_history"), history.toJSON() || null);
42461           if (!success) dispatch14.call("storage_error");
42462         }
42463         return history;
42464       },
42465       // delete the history version saved in localStorage
42466       clearSaved: function() {
42467         context.debouncedSave.cancel();
42468         if (lock.locked()) {
42469           _hasUnresolvedRestorableChanges = false;
42470           corePreferences(getKey("saved_history"), null);
42471           corePreferences("comment", null);
42472           corePreferences("hashtags", null);
42473           corePreferences("source", null);
42474         }
42475         return history;
42476       },
42477       savedHistoryJSON: function() {
42478         return corePreferences(getKey("saved_history"));
42479       },
42480       hasRestorableChanges: function() {
42481         return _hasUnresolvedRestorableChanges;
42482       },
42483       // load history from a version stored in localStorage
42484       restore: function() {
42485         if (lock.locked()) {
42486           _hasUnresolvedRestorableChanges = false;
42487           var json = this.savedHistoryJSON();
42488           if (json) history.fromJSON(json, true);
42489         }
42490       },
42491       _getKey: getKey
42492     };
42493     history.reset();
42494     return utilRebind(history, dispatch14, "on");
42495   }
42496
42497   // modules/validations/index.js
42498   var validations_exports = {};
42499   __export(validations_exports, {
42500     validationAlmostJunction: () => validationAlmostJunction,
42501     validationCloseNodes: () => validationCloseNodes,
42502     validationCrossingWays: () => validationCrossingWays,
42503     validationDisconnectedWay: () => validationDisconnectedWay,
42504     validationFormatting: () => validationFormatting,
42505     validationHelpRequest: () => validationHelpRequest,
42506     validationImpossibleOneway: () => validationImpossibleOneway,
42507     validationIncompatibleSource: () => validationIncompatibleSource,
42508     validationMaprules: () => validationMaprules,
42509     validationMismatchedGeometry: () => validationMismatchedGeometry,
42510     validationMissingRole: () => validationMissingRole,
42511     validationMissingTag: () => validationMissingTag,
42512     validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags,
42513     validationOutdatedTags: () => validationOutdatedTags,
42514     validationPrivateData: () => validationPrivateData,
42515     validationSuspiciousName: () => validationSuspiciousName,
42516     validationUnsquareWay: () => validationUnsquareWay
42517   });
42518
42519   // modules/util/utilDisplayLabel.js
42520   function utilDisplayLabel(entity, graphOrGeometry, verbose) {
42521     var result;
42522     var displayName = utilDisplayName(entity);
42523     var preset = typeof graphOrGeometry === "string" ? _mainPresetIndex.matchTags(entity.tags, graphOrGeometry) : _mainPresetIndex.match(entity, graphOrGeometry);
42524     var presetName = preset && (preset.suggestion ? preset.subtitle() : preset.name());
42525     if (verbose) {
42526       result = [presetName, displayName].filter(Boolean).join(" ");
42527     } else {
42528       result = displayName || presetName;
42529     }
42530     return result || utilDisplayType(entity.id);
42531   }
42532
42533   // modules/validations/almost_junction.js
42534   function validationAlmostJunction(context) {
42535     const type2 = "almost_junction";
42536     const EXTEND_TH_METERS = 5;
42537     const WELD_TH_METERS = 0.75;
42538     const CLOSE_NODE_TH = EXTEND_TH_METERS - WELD_TH_METERS;
42539     const SIG_ANGLE_TH = Math.atan(WELD_TH_METERS / EXTEND_TH_METERS);
42540     function isHighway(entity) {
42541       return entity.type === "way" && osmRoutableHighwayTagValues[entity.tags.highway];
42542     }
42543     function isTaggedAsNotContinuing(node) {
42544       return node.tags.noexit === "yes" || node.tags.amenity === "parking_entrance" || node.tags.entrance && node.tags.entrance !== "no";
42545     }
42546     const validation = function checkAlmostJunction(entity, graph) {
42547       if (!isHighway(entity)) return [];
42548       if (entity.isDegenerate()) return [];
42549       const tree = context.history().tree();
42550       const extendableNodeInfos = findConnectableEndNodesByExtension(entity);
42551       let issues = [];
42552       extendableNodeInfos.forEach((extendableNodeInfo) => {
42553         issues.push(new validationIssue({
42554           type: type2,
42555           subtype: "highway-highway",
42556           severity: "warning",
42557           message: function(context2) {
42558             const entity1 = context2.hasEntity(this.entityIds[0]);
42559             if (this.entityIds[0] === this.entityIds[2]) {
42560               return entity1 ? _t.append("issues.almost_junction.self.message", {
42561                 feature: utilDisplayLabel(entity1, context2.graph())
42562               }) : "";
42563             } else {
42564               const entity2 = context2.hasEntity(this.entityIds[2]);
42565               return entity1 && entity2 ? _t.append("issues.almost_junction.message", {
42566                 feature: utilDisplayLabel(entity1, context2.graph()),
42567                 feature2: utilDisplayLabel(entity2, context2.graph())
42568               }) : "";
42569             }
42570           },
42571           reference: showReference,
42572           entityIds: [
42573             entity.id,
42574             extendableNodeInfo.node.id,
42575             extendableNodeInfo.wid
42576           ],
42577           loc: extendableNodeInfo.node.loc,
42578           hash: JSON.stringify(extendableNodeInfo.node.loc),
42579           data: {
42580             midId: extendableNodeInfo.mid.id,
42581             edge: extendableNodeInfo.edge,
42582             cross_loc: extendableNodeInfo.cross_loc
42583           },
42584           dynamicFixes: makeFixes
42585         }));
42586       });
42587       return issues;
42588       function makeFixes(context2) {
42589         let fixes = [new validationIssueFix({
42590           icon: "iD-icon-abutment",
42591           title: _t.append("issues.fix.connect_features.title"),
42592           onClick: function(context3) {
42593             const annotation = _t("issues.fix.connect_almost_junction.annotation");
42594             const [, endNodeId, crossWayId] = this.issue.entityIds;
42595             const midNode = context3.entity(this.issue.data.midId);
42596             const endNode = context3.entity(endNodeId);
42597             const crossWay = context3.entity(crossWayId);
42598             const nearEndNodes = findNearbyEndNodes(endNode, crossWay);
42599             if (nearEndNodes.length > 0) {
42600               const collinear = findSmallJoinAngle(midNode, endNode, nearEndNodes);
42601               if (collinear) {
42602                 context3.perform(
42603                   actionMergeNodes([collinear.id, endNode.id], collinear.loc),
42604                   annotation
42605                 );
42606                 return;
42607               }
42608             }
42609             const targetEdge = this.issue.data.edge;
42610             const crossLoc = this.issue.data.cross_loc;
42611             const edgeNodes = [context3.entity(targetEdge[0]), context3.entity(targetEdge[1])];
42612             const closestNodeInfo = geoSphericalClosestNode(edgeNodes, crossLoc);
42613             if (closestNodeInfo.distance < WELD_TH_METERS) {
42614               context3.perform(
42615                 actionMergeNodes([closestNodeInfo.node.id, endNode.id], closestNodeInfo.node.loc),
42616                 annotation
42617               );
42618             } else {
42619               context3.perform(
42620                 actionAddMidpoint({ loc: crossLoc, edge: targetEdge }, endNode),
42621                 annotation
42622               );
42623             }
42624           }
42625         })];
42626         const node = context2.hasEntity(this.entityIds[1]);
42627         if (node && !node.hasInterestingTags()) {
42628           fixes.push(new validationIssueFix({
42629             icon: "maki-barrier",
42630             title: _t.append("issues.fix.tag_as_disconnected.title"),
42631             onClick: function(context3) {
42632               const nodeID = this.issue.entityIds[1];
42633               const tags = Object.assign({}, context3.entity(nodeID).tags);
42634               tags.noexit = "yes";
42635               context3.perform(
42636                 actionChangeTags(nodeID, tags),
42637                 _t("issues.fix.tag_as_disconnected.annotation")
42638               );
42639             }
42640           }));
42641         }
42642         return fixes;
42643       }
42644       function showReference(selection2) {
42645         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.almost_junction.highway-highway.reference"));
42646       }
42647       function isExtendableCandidate(node, way) {
42648         const osm = services.osm;
42649         if (osm && !osm.isDataLoaded(node.loc)) {
42650           return false;
42651         }
42652         if (isTaggedAsNotContinuing(node) || graph.parentWays(node).length !== 1) {
42653           return false;
42654         }
42655         let occurrences = 0;
42656         for (const index in way.nodes) {
42657           if (way.nodes[index] === node.id) {
42658             occurrences += 1;
42659             if (occurrences > 1) {
42660               return false;
42661             }
42662           }
42663         }
42664         return true;
42665       }
42666       function findConnectableEndNodesByExtension(way) {
42667         let results = [];
42668         if (way.isClosed()) return results;
42669         let testNodes;
42670         const indices = [0, way.nodes.length - 1];
42671         indices.forEach((nodeIndex) => {
42672           const nodeID = way.nodes[nodeIndex];
42673           const node = graph.entity(nodeID);
42674           if (!isExtendableCandidate(node, way)) return;
42675           const connectionInfo = canConnectByExtend(way, nodeIndex);
42676           if (!connectionInfo) return;
42677           testNodes = graph.childNodes(way).slice();
42678           testNodes[nodeIndex] = testNodes[nodeIndex].move(connectionInfo.cross_loc);
42679           if (geoHasSelfIntersections(testNodes, nodeID)) return;
42680           results.push(connectionInfo);
42681         });
42682         return results;
42683       }
42684       function findNearbyEndNodes(node, way) {
42685         return [
42686           way.nodes[0],
42687           way.nodes[way.nodes.length - 1]
42688         ].map((d2) => graph.entity(d2)).filter((d2) => {
42689           return d2.id !== node.id && geoSphericalDistance(node.loc, d2.loc) <= CLOSE_NODE_TH;
42690         });
42691       }
42692       function findSmallJoinAngle(midNode, tipNode, endNodes) {
42693         let joinTo;
42694         let minAngle = Infinity;
42695         endNodes.forEach((endNode) => {
42696           const a1 = geoAngle(midNode, tipNode, context.projection) + Math.PI;
42697           const a2 = geoAngle(midNode, endNode, context.projection) + Math.PI;
42698           const diff = Math.max(a1, a2) - Math.min(a1, a2);
42699           if (diff < minAngle) {
42700             joinTo = endNode;
42701             minAngle = diff;
42702           }
42703         });
42704         if (minAngle <= SIG_ANGLE_TH) return joinTo;
42705         return null;
42706       }
42707       function hasTag(tags, key) {
42708         return tags[key] !== void 0 && tags[key] !== "no";
42709       }
42710       function canConnectWays(way, way2) {
42711         if (way.id === way2.id) return true;
42712         if ((hasTag(way.tags, "bridge") || hasTag(way2.tags, "bridge")) && !(hasTag(way.tags, "bridge") && hasTag(way2.tags, "bridge"))) return false;
42713         if ((hasTag(way.tags, "tunnel") || hasTag(way2.tags, "tunnel")) && !(hasTag(way.tags, "tunnel") && hasTag(way2.tags, "tunnel"))) return false;
42714         const layer1 = way.tags.layer || "0", layer2 = way2.tags.layer || "0";
42715         if (layer1 !== layer2) return false;
42716         const level1 = way.tags.level || "0", level2 = way2.tags.level || "0";
42717         if (level1 !== level2) return false;
42718         return true;
42719       }
42720       function canConnectByExtend(way, endNodeIdx) {
42721         const tipNid = way.nodes[endNodeIdx];
42722         const midNid = endNodeIdx === 0 ? way.nodes[1] : way.nodes[way.nodes.length - 2];
42723         const tipNode = graph.entity(tipNid);
42724         const midNode = graph.entity(midNid);
42725         const lon = tipNode.loc[0];
42726         const lat = tipNode.loc[1];
42727         const lon_range = geoMetersToLon(EXTEND_TH_METERS, lat) / 2;
42728         const lat_range = geoMetersToLat(EXTEND_TH_METERS) / 2;
42729         const queryExtent = geoExtent([
42730           [lon - lon_range, lat - lat_range],
42731           [lon + lon_range, lat + lat_range]
42732         ]);
42733         const edgeLen = geoSphericalDistance(midNode.loc, tipNode.loc);
42734         const t2 = EXTEND_TH_METERS / edgeLen + 1;
42735         const extTipLoc = geoVecInterp(midNode.loc, tipNode.loc, t2);
42736         const segmentInfos = tree.waySegments(queryExtent, graph);
42737         for (let i3 = 0; i3 < segmentInfos.length; i3++) {
42738           let segmentInfo = segmentInfos[i3];
42739           let way2 = graph.entity(segmentInfo.wayId);
42740           if (!isHighway(way2)) continue;
42741           if (!canConnectWays(way, way2)) continue;
42742           let nAid = segmentInfo.nodes[0], nBid = segmentInfo.nodes[1];
42743           if (nAid === tipNid || nBid === tipNid) continue;
42744           let nA = graph.entity(nAid), nB = graph.entity(nBid);
42745           let crossLoc = geoLineIntersection([tipNode.loc, extTipLoc], [nA.loc, nB.loc]);
42746           if (crossLoc) {
42747             return {
42748               mid: midNode,
42749               node: tipNode,
42750               wid: way2.id,
42751               edge: [nA.id, nB.id],
42752               cross_loc: crossLoc
42753             };
42754           }
42755         }
42756         return null;
42757       }
42758     };
42759     validation.type = type2;
42760     return validation;
42761   }
42762
42763   // modules/validations/close_nodes.js
42764   function validationCloseNodes(context) {
42765     var type2 = "close_nodes";
42766     var pointThresholdMeters = 0.2;
42767     var validation = function(entity, graph) {
42768       if (entity.type === "node") {
42769         return getIssuesForNode(entity);
42770       } else if (entity.type === "way") {
42771         return getIssuesForWay(entity);
42772       }
42773       return [];
42774       function getIssuesForNode(node) {
42775         var parentWays = graph.parentWays(node);
42776         if (parentWays.length) {
42777           return getIssuesForVertex(node, parentWays);
42778         } else {
42779           return getIssuesForDetachedPoint(node);
42780         }
42781       }
42782       function wayTypeFor(way) {
42783         if (way.tags.boundary && way.tags.boundary !== "no") return "boundary";
42784         if (way.tags.indoor && way.tags.indoor !== "no") return "indoor";
42785         if (way.tags.building && way.tags.building !== "no" || way.tags["building:part"] && way.tags["building:part"] !== "no") return "building";
42786         if (osmPathHighwayTagValues[way.tags.highway]) return "path";
42787         var parentRelations = graph.parentRelations(way);
42788         for (var i3 in parentRelations) {
42789           var relation = parentRelations[i3];
42790           if (relation.tags.type === "boundary") return "boundary";
42791           if (relation.isMultipolygon()) {
42792             if (relation.tags.indoor && relation.tags.indoor !== "no") return "indoor";
42793             if (relation.tags.building && relation.tags.building !== "no" || relation.tags["building:part"] && relation.tags["building:part"] !== "no") return "building";
42794           }
42795         }
42796         return "other";
42797       }
42798       function shouldCheckWay(way) {
42799         if (way.nodes.length <= 2 || way.isClosed() && way.nodes.length <= 4) return false;
42800         var bbox2 = way.extent(graph).bbox();
42801         var hypotenuseMeters = geoSphericalDistance([bbox2.minX, bbox2.minY], [bbox2.maxX, bbox2.maxY]);
42802         if (hypotenuseMeters < 1.5) return false;
42803         return true;
42804       }
42805       function getIssuesForWay(way) {
42806         if (!shouldCheckWay(way)) return [];
42807         var issues = [], nodes = graph.childNodes(way);
42808         for (var i3 = 0; i3 < nodes.length - 1; i3++) {
42809           var node1 = nodes[i3];
42810           var node2 = nodes[i3 + 1];
42811           var issue = getWayIssueIfAny(node1, node2, way);
42812           if (issue) issues.push(issue);
42813         }
42814         return issues;
42815       }
42816       function getIssuesForVertex(node, parentWays) {
42817         var issues = [];
42818         function checkForCloseness(node1, node2, way) {
42819           var issue = getWayIssueIfAny(node1, node2, way);
42820           if (issue) issues.push(issue);
42821         }
42822         for (var i3 = 0; i3 < parentWays.length; i3++) {
42823           var parentWay = parentWays[i3];
42824           if (!shouldCheckWay(parentWay)) continue;
42825           var lastIndex = parentWay.nodes.length - 1;
42826           for (var j2 = 0; j2 < parentWay.nodes.length; j2++) {
42827             if (j2 !== 0) {
42828               if (parentWay.nodes[j2 - 1] === node.id) {
42829                 checkForCloseness(node, graph.entity(parentWay.nodes[j2]), parentWay);
42830               }
42831             }
42832             if (j2 !== lastIndex) {
42833               if (parentWay.nodes[j2 + 1] === node.id) {
42834                 checkForCloseness(graph.entity(parentWay.nodes[j2]), node, parentWay);
42835               }
42836             }
42837           }
42838         }
42839         return issues;
42840       }
42841       function thresholdMetersForWay(way) {
42842         if (!shouldCheckWay(way)) return 0;
42843         var wayType = wayTypeFor(way);
42844         if (wayType === "boundary") return 0;
42845         if (wayType === "indoor") return 0.01;
42846         if (wayType === "building") return 0.05;
42847         if (wayType === "path") return 0.1;
42848         return 0.2;
42849       }
42850       function getIssuesForDetachedPoint(node) {
42851         var issues = [];
42852         var lon = node.loc[0];
42853         var lat = node.loc[1];
42854         var lon_range = geoMetersToLon(pointThresholdMeters, lat) / 2;
42855         var lat_range = geoMetersToLat(pointThresholdMeters) / 2;
42856         var queryExtent = geoExtent([
42857           [lon - lon_range, lat - lat_range],
42858           [lon + lon_range, lat + lat_range]
42859         ]);
42860         var intersected = context.history().tree().intersects(queryExtent, graph);
42861         for (var j2 = 0; j2 < intersected.length; j2++) {
42862           var nearby = intersected[j2];
42863           if (nearby.id === node.id) continue;
42864           if (nearby.type !== "node" || nearby.geometry(graph) !== "point") continue;
42865           if (nearby.loc === node.loc || geoSphericalDistance(node.loc, nearby.loc) < pointThresholdMeters) {
42866             if ("memorial:type" in node.tags && "memorial:type" in nearby.tags && node.tags["memorial:type"] === "stolperstein" && nearby.tags["memorial:type"] === "stolperstein") continue;
42867             if ("memorial" in node.tags && "memorial" in nearby.tags && node.tags.memorial === "stolperstein" && nearby.tags.memorial === "stolperstein") continue;
42868             var zAxisKeys = { layer: true, level: true, "addr:housenumber": true, "addr:unit": true };
42869             var zAxisDifferentiates = false;
42870             for (var key in zAxisKeys) {
42871               var nodeValue = node.tags[key] || "0";
42872               var nearbyValue = nearby.tags[key] || "0";
42873               if (nodeValue !== nearbyValue) {
42874                 zAxisDifferentiates = true;
42875                 break;
42876               }
42877             }
42878             if (zAxisDifferentiates) continue;
42879             issues.push(new validationIssue({
42880               type: type2,
42881               subtype: "detached",
42882               severity: "warning",
42883               message: function(context2) {
42884                 var entity2 = context2.hasEntity(this.entityIds[0]), entity22 = context2.hasEntity(this.entityIds[1]);
42885                 return entity2 && entity22 ? _t.append("issues.close_nodes.detached.message", {
42886                   feature: utilDisplayLabel(entity2, context2.graph()),
42887                   feature2: utilDisplayLabel(entity22, context2.graph())
42888                 }) : "";
42889               },
42890               reference: showReference,
42891               entityIds: [node.id, nearby.id],
42892               dynamicFixes: function() {
42893                 return [
42894                   new validationIssueFix({
42895                     icon: "iD-operation-disconnect",
42896                     title: _t.append("issues.fix.move_points_apart.title")
42897                   }),
42898                   new validationIssueFix({
42899                     icon: "iD-icon-layers",
42900                     title: _t.append("issues.fix.use_different_layers_or_levels.title")
42901                   })
42902                 ];
42903               }
42904             }));
42905           }
42906         }
42907         return issues;
42908         function showReference(selection2) {
42909           var referenceText = _t("issues.close_nodes.detached.reference");
42910           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").html(referenceText);
42911         }
42912       }
42913       function getWayIssueIfAny(node1, node2, way) {
42914         if (node1.id === node2.id || node1.hasInterestingTags() && node2.hasInterestingTags()) {
42915           return null;
42916         }
42917         if (node1.loc !== node2.loc) {
42918           var parentWays1 = graph.parentWays(node1);
42919           var parentWays2 = new Set(graph.parentWays(node2));
42920           var sharedWays = parentWays1.filter(function(parentWay) {
42921             return parentWays2.has(parentWay);
42922           });
42923           var thresholds = sharedWays.map(function(parentWay) {
42924             return thresholdMetersForWay(parentWay);
42925           });
42926           var threshold = Math.min(...thresholds);
42927           var distance = geoSphericalDistance(node1.loc, node2.loc);
42928           if (distance > threshold) return null;
42929         }
42930         return new validationIssue({
42931           type: type2,
42932           subtype: "vertices",
42933           severity: "warning",
42934           message: function(context2) {
42935             var entity2 = context2.hasEntity(this.entityIds[0]);
42936             return entity2 ? _t.append("issues.close_nodes.message", { way: utilDisplayLabel(entity2, context2.graph()) }) : "";
42937           },
42938           reference: showReference,
42939           entityIds: [way.id, node1.id, node2.id],
42940           loc: node1.loc,
42941           dynamicFixes: function() {
42942             return [
42943               new validationIssueFix({
42944                 icon: "iD-icon-plus",
42945                 title: _t.append("issues.fix.merge_points.title"),
42946                 onClick: function(context2) {
42947                   var entityIds = this.issue.entityIds;
42948                   var action = actionMergeNodes([entityIds[1], entityIds[2]]);
42949                   context2.perform(action, _t("issues.fix.merge_close_vertices.annotation"));
42950                 }
42951               }),
42952               new validationIssueFix({
42953                 icon: "iD-operation-disconnect",
42954                 title: _t.append("issues.fix.move_points_apart.title")
42955               })
42956             ];
42957           }
42958         });
42959         function showReference(selection2) {
42960           var referenceText = _t("issues.close_nodes.reference");
42961           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").html(referenceText);
42962         }
42963       }
42964     };
42965     validation.type = type2;
42966     return validation;
42967   }
42968
42969   // modules/validations/crossing_ways.js
42970   var import_lodash3 = __toESM(require_lodash());
42971   function validationCrossingWays(context) {
42972     var type2 = "crossing_ways";
42973     function getFeatureWithFeatureTypeTagsForWay(way, graph) {
42974       if (getFeatureType(way, graph) === null) {
42975         var parentRels = graph.parentRelations(way);
42976         for (var i3 = 0; i3 < parentRels.length; i3++) {
42977           var rel = parentRels[i3];
42978           if (getFeatureType(rel, graph) !== null) {
42979             return rel;
42980           }
42981         }
42982       }
42983       return way;
42984     }
42985     function hasTag(tags, key) {
42986       return tags[key] !== void 0 && tags[key] !== "no";
42987     }
42988     function taggedAsIndoor(tags) {
42989       return hasTag(tags, "indoor") || hasTag(tags, "level") || tags.highway === "corridor";
42990     }
42991     function allowsBridge(featureType) {
42992       return featureType === "highway" || featureType === "railway" || featureType === "waterway";
42993     }
42994     function allowsTunnel(featureType) {
42995       return featureType === "highway" || featureType === "railway" || featureType === "waterway";
42996     }
42997     var ignoredBuildings = {
42998       demolished: true,
42999       dismantled: true,
43000       proposed: true,
43001       razed: true
43002     };
43003     function getFeatureType(entity, graph) {
43004       var geometry = entity.geometry(graph);
43005       if (geometry !== "line" && geometry !== "area") return null;
43006       var tags = entity.tags;
43007       if (hasTag(tags, "building") && !ignoredBuildings[tags.building]) return "building";
43008       if (hasTag(tags, "highway") && osmRoutableHighwayTagValues[tags.highway]) return "highway";
43009       if (geometry !== "line") return null;
43010       if (hasTag(tags, "railway") && osmRailwayTrackTagValues[tags.railway]) return "railway";
43011       if (hasTag(tags, "waterway") && osmFlowingWaterwayTagValues[tags.waterway]) return "waterway";
43012       return null;
43013     }
43014     function isLegitCrossing(tags1, featureType1, tags2, featureType2) {
43015       var level1 = tags1.level || "0";
43016       var level2 = tags2.level || "0";
43017       if (taggedAsIndoor(tags1) && taggedAsIndoor(tags2) && level1 !== level2) {
43018         return true;
43019       }
43020       var layer1 = tags1.layer || "0";
43021       var layer2 = tags2.layer || "0";
43022       if (allowsBridge(featureType1) && allowsBridge(featureType2)) {
43023         if (hasTag(tags1, "bridge") && !hasTag(tags2, "bridge")) return true;
43024         if (!hasTag(tags1, "bridge") && hasTag(tags2, "bridge")) return true;
43025         if (hasTag(tags1, "bridge") && hasTag(tags2, "bridge") && layer1 !== layer2) return true;
43026       } else if (allowsBridge(featureType1) && hasTag(tags1, "bridge")) return true;
43027       else if (allowsBridge(featureType2) && hasTag(tags2, "bridge")) return true;
43028       if (allowsTunnel(featureType1) && allowsTunnel(featureType2)) {
43029         if (hasTag(tags1, "tunnel") && !hasTag(tags2, "tunnel")) return true;
43030         if (!hasTag(tags1, "tunnel") && hasTag(tags2, "tunnel")) return true;
43031         if (hasTag(tags1, "tunnel") && hasTag(tags2, "tunnel") && layer1 !== layer2) return true;
43032       } else if (allowsTunnel(featureType1) && hasTag(tags1, "tunnel")) return true;
43033       else if (allowsTunnel(featureType2) && hasTag(tags2, "tunnel")) return true;
43034       if (featureType1 === "waterway" && featureType2 === "highway" && tags2.man_made === "pier") return true;
43035       if (featureType2 === "waterway" && featureType1 === "highway" && tags1.man_made === "pier") return true;
43036       if (featureType1 === "building" || featureType2 === "building" || taggedAsIndoor(tags1) || taggedAsIndoor(tags2)) {
43037         if (layer1 !== layer2) return true;
43038       }
43039       return false;
43040     }
43041     var highwaysDisallowingFords = {
43042       motorway: true,
43043       motorway_link: true,
43044       trunk: true,
43045       trunk_link: true,
43046       primary: true,
43047       primary_link: true,
43048       secondary: true,
43049       secondary_link: true
43050     };
43051     function tagsForConnectionNodeIfAllowed(entity1, entity2, graph, lessLikelyTags) {
43052       var featureType1 = getFeatureType(entity1, graph);
43053       var featureType2 = getFeatureType(entity2, graph);
43054       var geometry1 = entity1.geometry(graph);
43055       var geometry2 = entity2.geometry(graph);
43056       var bothLines = geometry1 === "line" && geometry2 === "line";
43057       if (featureType1 === featureType2) {
43058         if (featureType1 === "highway") {
43059           var entity1IsPath = osmPathHighwayTagValues[entity1.tags.highway];
43060           var entity2IsPath = osmPathHighwayTagValues[entity2.tags.highway];
43061           if ((entity1IsPath || entity2IsPath) && entity1IsPath !== entity2IsPath) {
43062             var roadFeature = entity1IsPath ? entity2 : entity1;
43063             var pathFeature = entity1IsPath ? entity1 : entity2;
43064             if (roadFeature.tags.highway === "track") {
43065               return {};
43066             }
43067             if (!lessLikelyTags && roadFeature.tags.highway === "service" && pathFeature.tags.highway === "footway" && pathFeature.tags.footway === "sidewalk") {
43068               return {};
43069             }
43070             if (["marked", "unmarked", "traffic_signals", "uncontrolled"].indexOf(pathFeature.tags.crossing) !== -1) {
43071               return bothLines ? { highway: "crossing", crossing: pathFeature.tags.crossing } : {};
43072             }
43073             return bothLines ? { highway: "crossing" } : {};
43074           }
43075           return {};
43076         }
43077         if (featureType1 === "waterway") return {};
43078         if (featureType1 === "railway") return {};
43079       } else {
43080         var featureTypes = [featureType1, featureType2];
43081         if (featureTypes.indexOf("highway") !== -1) {
43082           if (featureTypes.indexOf("railway") !== -1) {
43083             if (!bothLines) return {};
43084             var isTram = entity1.tags.railway === "tram" || entity2.tags.railway === "tram";
43085             if (osmPathHighwayTagValues[entity1.tags.highway] || osmPathHighwayTagValues[entity2.tags.highway]) {
43086               if (isTram) return { railway: "tram_crossing" };
43087               return { railway: "crossing" };
43088             } else {
43089               if (isTram) return { railway: "tram_level_crossing" };
43090               return { railway: "level_crossing" };
43091             }
43092           }
43093           if (featureTypes.indexOf("waterway") !== -1) {
43094             if (hasTag(entity1.tags, "tunnel") && hasTag(entity2.tags, "tunnel")) return null;
43095             if (hasTag(entity1.tags, "bridge") && hasTag(entity2.tags, "bridge")) return null;
43096             if (highwaysDisallowingFords[entity1.tags.highway] || highwaysDisallowingFords[entity2.tags.highway]) {
43097               return null;
43098             }
43099             return bothLines ? { ford: "yes" } : {};
43100           }
43101         }
43102       }
43103       return null;
43104     }
43105     function findCrossingsByWay(way1, graph, tree) {
43106       var edgeCrossInfos = [];
43107       if (way1.type !== "way") return edgeCrossInfos;
43108       var taggedFeature1 = getFeatureWithFeatureTypeTagsForWay(way1, graph);
43109       var way1FeatureType = getFeatureType(taggedFeature1, graph);
43110       if (way1FeatureType === null) return edgeCrossInfos;
43111       var checkedSingleCrossingWays = {};
43112       var i3, j2;
43113       var extent;
43114       var n1, n22, nA, nB, nAId, nBId;
43115       var segment1, segment2;
43116       var oneOnly;
43117       var segmentInfos, segment2Info, way2, taggedFeature2, way2FeatureType;
43118       var way1Nodes = graph.childNodes(way1);
43119       var comparedWays = {};
43120       for (i3 = 0; i3 < way1Nodes.length - 1; i3++) {
43121         n1 = way1Nodes[i3];
43122         n22 = way1Nodes[i3 + 1];
43123         extent = geoExtent([
43124           [
43125             Math.min(n1.loc[0], n22.loc[0]),
43126             Math.min(n1.loc[1], n22.loc[1])
43127           ],
43128           [
43129             Math.max(n1.loc[0], n22.loc[0]),
43130             Math.max(n1.loc[1], n22.loc[1])
43131           ]
43132         ]);
43133         segmentInfos = tree.waySegments(extent, graph);
43134         for (j2 = 0; j2 < segmentInfos.length; j2++) {
43135           segment2Info = segmentInfos[j2];
43136           if (segment2Info.wayId === way1.id) continue;
43137           if (checkedSingleCrossingWays[segment2Info.wayId]) continue;
43138           comparedWays[segment2Info.wayId] = true;
43139           way2 = graph.hasEntity(segment2Info.wayId);
43140           if (!way2) continue;
43141           taggedFeature2 = getFeatureWithFeatureTypeTagsForWay(way2, graph);
43142           way2FeatureType = getFeatureType(taggedFeature2, graph);
43143           if (way2FeatureType === null || isLegitCrossing(taggedFeature1.tags, way1FeatureType, taggedFeature2.tags, way2FeatureType)) {
43144             continue;
43145           }
43146           oneOnly = way1FeatureType === "building" || way2FeatureType === "building";
43147           nAId = segment2Info.nodes[0];
43148           nBId = segment2Info.nodes[1];
43149           if (nAId === n1.id || nAId === n22.id || nBId === n1.id || nBId === n22.id) {
43150             continue;
43151           }
43152           nA = graph.hasEntity(nAId);
43153           if (!nA) continue;
43154           nB = graph.hasEntity(nBId);
43155           if (!nB) continue;
43156           segment1 = [n1.loc, n22.loc];
43157           segment2 = [nA.loc, nB.loc];
43158           var point = geoLineIntersection(segment1, segment2);
43159           if (point) {
43160             edgeCrossInfos.push({
43161               wayInfos: [
43162                 {
43163                   way: way1,
43164                   featureType: way1FeatureType,
43165                   edge: [n1.id, n22.id]
43166                 },
43167                 {
43168                   way: way2,
43169                   featureType: way2FeatureType,
43170                   edge: [nA.id, nB.id]
43171                 }
43172               ],
43173               crossPoint: point
43174             });
43175             if (oneOnly) {
43176               checkedSingleCrossingWays[way2.id] = true;
43177               break;
43178             }
43179           }
43180         }
43181       }
43182       return edgeCrossInfos;
43183     }
43184     function waysToCheck(entity, graph) {
43185       var featureType = getFeatureType(entity, graph);
43186       if (!featureType) return [];
43187       if (entity.type === "way") {
43188         return [entity];
43189       } else if (entity.type === "relation") {
43190         return entity.members.reduce(function(array2, member) {
43191           if (member.type === "way" && // only look at geometry ways
43192           (!member.role || member.role === "outer" || member.role === "inner")) {
43193             var entity2 = graph.hasEntity(member.id);
43194             if (entity2 && array2.indexOf(entity2) === -1) {
43195               array2.push(entity2);
43196             }
43197           }
43198           return array2;
43199         }, []);
43200       }
43201       return [];
43202     }
43203     var validation = function checkCrossingWays(entity, graph) {
43204       var tree = context.history().tree();
43205       var ways = waysToCheck(entity, graph);
43206       var issues = [];
43207       var wayIndex, crossingIndex, crossings;
43208       for (wayIndex in ways) {
43209         crossings = findCrossingsByWay(ways[wayIndex], graph, tree);
43210         for (crossingIndex in crossings) {
43211           issues.push(createIssue(crossings[crossingIndex], graph));
43212         }
43213       }
43214       return issues;
43215     };
43216     function createIssue(crossing, graph) {
43217       crossing.wayInfos.sort(function(way1Info, way2Info) {
43218         var type1 = way1Info.featureType;
43219         var type22 = way2Info.featureType;
43220         if (type1 === type22) {
43221           return utilDisplayLabel(way1Info.way, graph) > utilDisplayLabel(way2Info.way, graph);
43222         } else if (type1 === "waterway") {
43223           return true;
43224         } else if (type22 === "waterway") {
43225           return false;
43226         }
43227         return type1 < type22;
43228       });
43229       var entities = crossing.wayInfos.map(function(wayInfo) {
43230         return getFeatureWithFeatureTypeTagsForWay(wayInfo.way, graph);
43231       });
43232       var edges = [crossing.wayInfos[0].edge, crossing.wayInfos[1].edge];
43233       var featureTypes = [crossing.wayInfos[0].featureType, crossing.wayInfos[1].featureType];
43234       var connectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1], graph);
43235       var featureType1 = crossing.wayInfos[0].featureType;
43236       var featureType2 = crossing.wayInfos[1].featureType;
43237       var isCrossingIndoors = taggedAsIndoor(entities[0].tags) && taggedAsIndoor(entities[1].tags);
43238       var isCrossingTunnels = allowsTunnel(featureType1) && hasTag(entities[0].tags, "tunnel") && allowsTunnel(featureType2) && hasTag(entities[1].tags, "tunnel");
43239       var isCrossingBridges = allowsBridge(featureType1) && hasTag(entities[0].tags, "bridge") && allowsBridge(featureType2) && hasTag(entities[1].tags, "bridge");
43240       var subtype = [featureType1, featureType2].sort().join("-");
43241       var crossingTypeID = subtype;
43242       if (isCrossingIndoors) {
43243         crossingTypeID = "indoor-indoor";
43244       } else if (isCrossingTunnels) {
43245         crossingTypeID = "tunnel-tunnel";
43246       } else if (isCrossingBridges) {
43247         crossingTypeID = "bridge-bridge";
43248       }
43249       if (connectionTags && (isCrossingIndoors || isCrossingTunnels || isCrossingBridges)) {
43250         crossingTypeID += "_connectable";
43251       }
43252       var uniqueID = crossing.crossPoint[0].toFixed(4) + "," + crossing.crossPoint[1].toFixed(4);
43253       return new validationIssue({
43254         type: type2,
43255         subtype,
43256         severity: "warning",
43257         message: function(context2) {
43258           var graph2 = context2.graph();
43259           var entity1 = graph2.hasEntity(this.entityIds[0]), entity2 = graph2.hasEntity(this.entityIds[1]);
43260           return entity1 && entity2 ? _t.append("issues.crossing_ways.message", {
43261             feature: utilDisplayLabel(entity1, graph2),
43262             feature2: utilDisplayLabel(entity2, graph2)
43263           }) : "";
43264         },
43265         reference: showReference,
43266         entityIds: entities.map(function(entity) {
43267           return entity.id;
43268         }),
43269         data: {
43270           edges,
43271           featureTypes,
43272           connectionTags
43273         },
43274         hash: uniqueID,
43275         loc: crossing.crossPoint,
43276         dynamicFixes: function(context2) {
43277           var mode = context2.mode();
43278           if (!mode || mode.id !== "select" || mode.selectedIDs().length !== 1) return [];
43279           var selectedIndex = this.entityIds[0] === mode.selectedIDs()[0] ? 0 : 1;
43280           var selectedFeatureType = this.data.featureTypes[selectedIndex];
43281           var otherFeatureType = this.data.featureTypes[selectedIndex === 0 ? 1 : 0];
43282           var fixes = [];
43283           if (connectionTags) {
43284             fixes.push(makeConnectWaysFix(this.data.connectionTags));
43285             let lessLikelyConnectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1], graph, true);
43286             if (lessLikelyConnectionTags && !(0, import_lodash3.isEqual)(connectionTags, lessLikelyConnectionTags)) {
43287               fixes.push(makeConnectWaysFix(lessLikelyConnectionTags));
43288             }
43289           }
43290           if (isCrossingIndoors) {
43291             fixes.push(new validationIssueFix({
43292               icon: "iD-icon-layers",
43293               title: _t.append("issues.fix.use_different_levels.title")
43294             }));
43295           } else if (isCrossingTunnels || isCrossingBridges || featureType1 === "building" || featureType2 === "building") {
43296             fixes.push(makeChangeLayerFix("higher"));
43297             fixes.push(makeChangeLayerFix("lower"));
43298           } else if (context2.graph().geometry(this.entityIds[0]) === "line" && context2.graph().geometry(this.entityIds[1]) === "line") {
43299             if (allowsBridge(selectedFeatureType) && selectedFeatureType !== "waterway") {
43300               fixes.push(makeAddBridgeOrTunnelFix("add_a_bridge", "temaki-bridge", "bridge"));
43301             }
43302             var skipTunnelFix = otherFeatureType === "waterway" && selectedFeatureType !== "waterway";
43303             if (allowsTunnel(selectedFeatureType) && !skipTunnelFix) {
43304               fixes.push(makeAddBridgeOrTunnelFix("add_a_tunnel", "temaki-tunnel", "tunnel"));
43305             }
43306           }
43307           fixes.push(new validationIssueFix({
43308             icon: "iD-operation-move",
43309             title: _t.append("issues.fix.reposition_features.title")
43310           }));
43311           return fixes;
43312         }
43313       });
43314       function showReference(selection2) {
43315         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.crossing_ways." + crossingTypeID + ".reference"));
43316       }
43317     }
43318     function makeAddBridgeOrTunnelFix(fixTitleID, iconName, bridgeOrTunnel) {
43319       return new validationIssueFix({
43320         icon: iconName,
43321         title: _t.append("issues.fix." + fixTitleID + ".title"),
43322         onClick: function(context2) {
43323           var mode = context2.mode();
43324           if (!mode || mode.id !== "select") return;
43325           var selectedIDs = mode.selectedIDs();
43326           if (selectedIDs.length !== 1) return;
43327           var selectedWayID = selectedIDs[0];
43328           if (!context2.hasEntity(selectedWayID)) return;
43329           var resultWayIDs = [selectedWayID];
43330           var edge, crossedEdge, crossedWayID;
43331           if (this.issue.entityIds[0] === selectedWayID) {
43332             edge = this.issue.data.edges[0];
43333             crossedEdge = this.issue.data.edges[1];
43334             crossedWayID = this.issue.entityIds[1];
43335           } else {
43336             edge = this.issue.data.edges[1];
43337             crossedEdge = this.issue.data.edges[0];
43338             crossedWayID = this.issue.entityIds[0];
43339           }
43340           var crossingLoc = this.issue.loc;
43341           var projection2 = context2.projection;
43342           var action = function actionAddStructure(graph) {
43343             var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])];
43344             var crossedWay = graph.hasEntity(crossedWayID);
43345             var structLengthMeters = crossedWay && isFinite(crossedWay.tags.width) && Number(crossedWay.tags.width);
43346             if (!structLengthMeters) {
43347               structLengthMeters = crossedWay && crossedWay.impliedLineWidthMeters();
43348             }
43349             if (structLengthMeters) {
43350               if (getFeatureType(crossedWay, graph) === "railway") {
43351                 structLengthMeters *= 2;
43352               }
43353             } else {
43354               structLengthMeters = 8;
43355             }
43356             var a1 = geoAngle(edgeNodes[0], edgeNodes[1], projection2) + Math.PI;
43357             var a2 = geoAngle(graph.entity(crossedEdge[0]), graph.entity(crossedEdge[1]), projection2) + Math.PI;
43358             var crossingAngle = Math.max(a1, a2) - Math.min(a1, a2);
43359             if (crossingAngle > Math.PI) crossingAngle -= Math.PI;
43360             structLengthMeters = structLengthMeters / 2 / Math.sin(crossingAngle) * 2;
43361             structLengthMeters += 4;
43362             structLengthMeters = Math.min(Math.max(structLengthMeters, 4), 50);
43363             function geomToProj(geoPoint) {
43364               return [
43365                 geoLonToMeters(geoPoint[0], geoPoint[1]),
43366                 geoLatToMeters(geoPoint[1])
43367               ];
43368             }
43369             function projToGeom(projPoint) {
43370               var lat = geoMetersToLat(projPoint[1]);
43371               return [
43372                 geoMetersToLon(projPoint[0], lat),
43373                 lat
43374               ];
43375             }
43376             var projEdgeNode1 = geomToProj(edgeNodes[0].loc);
43377             var projEdgeNode2 = geomToProj(edgeNodes[1].loc);
43378             var projectedAngle = geoVecAngle(projEdgeNode1, projEdgeNode2);
43379             var projectedCrossingLoc = geomToProj(crossingLoc);
43380             var linearToSphericalMetersRatio = geoVecLength(projEdgeNode1, projEdgeNode2) / geoSphericalDistance(edgeNodes[0].loc, edgeNodes[1].loc);
43381             function locSphericalDistanceFromCrossingLoc(angle2, distanceMeters) {
43382               var lengthSphericalMeters = distanceMeters * linearToSphericalMetersRatio;
43383               return projToGeom([
43384                 projectedCrossingLoc[0] + Math.cos(angle2) * lengthSphericalMeters,
43385                 projectedCrossingLoc[1] + Math.sin(angle2) * lengthSphericalMeters
43386               ]);
43387             }
43388             var endpointLocGetter1 = function(lengthMeters) {
43389               return locSphericalDistanceFromCrossingLoc(projectedAngle, lengthMeters);
43390             };
43391             var endpointLocGetter2 = function(lengthMeters) {
43392               return locSphericalDistanceFromCrossingLoc(projectedAngle + Math.PI, lengthMeters);
43393             };
43394             var minEdgeLengthMeters = 0.55;
43395             function determineEndpoint(edge2, endNode, locGetter) {
43396               var newNode;
43397               var idealLengthMeters = structLengthMeters / 2;
43398               var crossingToEdgeEndDistance = geoSphericalDistance(crossingLoc, endNode.loc);
43399               if (crossingToEdgeEndDistance - idealLengthMeters > minEdgeLengthMeters) {
43400                 var idealNodeLoc = locGetter(idealLengthMeters);
43401                 newNode = osmNode();
43402                 graph = actionAddMidpoint({ loc: idealNodeLoc, edge: edge2 }, newNode)(graph);
43403               } else {
43404                 var edgeCount = 0;
43405                 endNode.parentIntersectionWays(graph).forEach(function(way) {
43406                   way.nodes.forEach(function(nodeID) {
43407                     if (nodeID === endNode.id) {
43408                       if (endNode.id === way.first() && endNode.id !== way.last() || endNode.id === way.last() && endNode.id !== way.first()) {
43409                         edgeCount += 1;
43410                       } else {
43411                         edgeCount += 2;
43412                       }
43413                     }
43414                   });
43415                 });
43416                 if (edgeCount >= 3) {
43417                   var insetLength = crossingToEdgeEndDistance - minEdgeLengthMeters;
43418                   if (insetLength > minEdgeLengthMeters) {
43419                     var insetNodeLoc = locGetter(insetLength);
43420                     newNode = osmNode();
43421                     graph = actionAddMidpoint({ loc: insetNodeLoc, edge: edge2 }, newNode)(graph);
43422                   }
43423                 }
43424               }
43425               if (!newNode) newNode = endNode;
43426               var splitAction = actionSplit([newNode.id]).limitWays(resultWayIDs);
43427               graph = splitAction(graph);
43428               if (splitAction.getCreatedWayIDs().length) {
43429                 resultWayIDs.push(splitAction.getCreatedWayIDs()[0]);
43430               }
43431               return newNode;
43432             }
43433             var structEndNode1 = determineEndpoint(edge, edgeNodes[1], endpointLocGetter1);
43434             var structEndNode2 = determineEndpoint([edgeNodes[0].id, structEndNode1.id], edgeNodes[0], endpointLocGetter2);
43435             var structureWay = resultWayIDs.map(function(id2) {
43436               return graph.entity(id2);
43437             }).find(function(way) {
43438               return way.nodes.indexOf(structEndNode1.id) !== -1 && way.nodes.indexOf(structEndNode2.id) !== -1;
43439             });
43440             var tags = Object.assign({}, structureWay.tags);
43441             if (bridgeOrTunnel === "bridge") {
43442               tags.bridge = "yes";
43443               tags.layer = "1";
43444             } else {
43445               var tunnelValue = "yes";
43446               if (getFeatureType(structureWay, graph) === "waterway") {
43447                 tunnelValue = "culvert";
43448               }
43449               tags.tunnel = tunnelValue;
43450               tags.layer = "-1";
43451             }
43452             graph = actionChangeTags(structureWay.id, tags)(graph);
43453             return graph;
43454           };
43455           context2.perform(action, _t("issues.fix." + fixTitleID + ".annotation"));
43456           context2.enter(modeSelect(context2, resultWayIDs));
43457         }
43458       });
43459     }
43460     function makeConnectWaysFix(connectionTags) {
43461       var fixTitleID = "connect_features";
43462       var fixIcon = "iD-icon-crossing";
43463       if (connectionTags.highway === "crossing") {
43464         fixTitleID = "connect_using_crossing";
43465         fixIcon = "temaki-pedestrian";
43466       }
43467       if (connectionTags.ford) {
43468         fixTitleID = "connect_using_ford";
43469         fixIcon = "roentgen-ford";
43470       }
43471       const fix = new validationIssueFix({
43472         icon: fixIcon,
43473         title: _t.append("issues.fix." + fixTitleID + ".title"),
43474         onClick: function(context2) {
43475           var loc = this.issue.loc;
43476           var edges = this.issue.data.edges;
43477           context2.perform(
43478             function actionConnectCrossingWays(graph) {
43479               var node = osmNode({ loc, tags: connectionTags });
43480               graph = graph.replace(node);
43481               var nodesToMerge = [node.id];
43482               var mergeThresholdInMeters = 0.75;
43483               edges.forEach(function(edge) {
43484                 var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])];
43485                 var nearby = geoSphericalClosestNode(edgeNodes, loc);
43486                 if ((!nearby.node.hasInterestingTags() || nearby.node.isCrossing()) && nearby.distance < mergeThresholdInMeters) {
43487                   nodesToMerge.push(nearby.node.id);
43488                 } else {
43489                   graph = actionAddMidpoint({ loc, edge }, node)(graph);
43490                 }
43491               });
43492               if (nodesToMerge.length > 1) {
43493                 graph = actionMergeNodes(nodesToMerge, loc)(graph);
43494               }
43495               return graph;
43496             },
43497             _t("issues.fix.connect_crossing_features.annotation")
43498           );
43499         }
43500       });
43501       fix._connectionTags = connectionTags;
43502       return fix;
43503     }
43504     function makeChangeLayerFix(higherOrLower) {
43505       return new validationIssueFix({
43506         icon: "iD-icon-" + (higherOrLower === "higher" ? "up" : "down"),
43507         title: _t.append("issues.fix.tag_this_as_" + higherOrLower + ".title"),
43508         onClick: function(context2) {
43509           var mode = context2.mode();
43510           if (!mode || mode.id !== "select") return;
43511           var selectedIDs = mode.selectedIDs();
43512           if (selectedIDs.length !== 1) return;
43513           var selectedID = selectedIDs[0];
43514           if (!this.issue.entityIds.some(function(entityId) {
43515             return entityId === selectedID;
43516           })) return;
43517           var entity = context2.hasEntity(selectedID);
43518           if (!entity) return;
43519           var tags = Object.assign({}, entity.tags);
43520           var layer = tags.layer && Number(tags.layer);
43521           if (layer && !isNaN(layer)) {
43522             if (higherOrLower === "higher") {
43523               layer += 1;
43524             } else {
43525               layer -= 1;
43526             }
43527           } else {
43528             if (higherOrLower === "higher") {
43529               layer = 1;
43530             } else {
43531               layer = -1;
43532             }
43533           }
43534           tags.layer = layer.toString();
43535           context2.perform(
43536             actionChangeTags(entity.id, tags),
43537             _t("operations.change_tags.annotation")
43538           );
43539         }
43540       });
43541     }
43542     validation.type = type2;
43543     return validation;
43544   }
43545
43546   // modules/behavior/draw_way.js
43547   function behaviorDrawWay(context, wayID, mode, startGraph) {
43548     const keybinding = utilKeybinding("drawWay");
43549     var dispatch14 = dispatch_default("rejectedSelfIntersection");
43550     var behavior = behaviorDraw(context);
43551     var _nodeIndex;
43552     var _origWay;
43553     var _wayGeometry;
43554     var _headNodeID;
43555     var _annotation;
43556     var _pointerHasMoved = false;
43557     var _drawNode;
43558     var _didResolveTempEdit = false;
43559     function createDrawNode(loc) {
43560       _drawNode = osmNode({ loc });
43561       context.pauseChangeDispatch();
43562       context.replace(function actionAddDrawNode(graph) {
43563         var way = graph.entity(wayID);
43564         return graph.replace(_drawNode).replace(way.addNode(_drawNode.id, _nodeIndex));
43565       }, _annotation);
43566       context.resumeChangeDispatch();
43567       setActiveElements();
43568     }
43569     function removeDrawNode() {
43570       context.pauseChangeDispatch();
43571       context.replace(
43572         function actionDeleteDrawNode(graph) {
43573           var way = graph.entity(wayID);
43574           return graph.replace(way.removeNode(_drawNode.id)).remove(_drawNode);
43575         },
43576         _annotation
43577       );
43578       _drawNode = void 0;
43579       context.resumeChangeDispatch();
43580     }
43581     function keydown(d3_event) {
43582       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
43583         if (context.surface().classed("nope")) {
43584           context.surface().classed("nope-suppressed", true);
43585         }
43586         context.surface().classed("nope", false).classed("nope-disabled", true);
43587       }
43588     }
43589     function keyup(d3_event) {
43590       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
43591         if (context.surface().classed("nope-suppressed")) {
43592           context.surface().classed("nope", true);
43593         }
43594         context.surface().classed("nope-suppressed", false).classed("nope-disabled", false);
43595       }
43596     }
43597     function allowsVertex(d2) {
43598       return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
43599     }
43600     function move(d3_event, datum2) {
43601       var loc = context.map().mouseCoordinates();
43602       if (!_drawNode) createDrawNode(loc);
43603       context.surface().classed("nope-disabled", d3_event.altKey);
43604       var targetLoc = datum2 && datum2.properties && datum2.properties.entity && allowsVertex(datum2.properties.entity) && datum2.properties.entity.loc;
43605       var targetNodes = datum2 && datum2.properties && datum2.properties.nodes;
43606       if (targetLoc) {
43607         loc = targetLoc;
43608       } else if (targetNodes) {
43609         var choice = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, _drawNode.id);
43610         if (choice) {
43611           loc = choice.loc;
43612         }
43613       }
43614       context.replace(actionMoveNode(_drawNode.id, loc), _annotation);
43615       _drawNode = context.entity(_drawNode.id);
43616       checkGeometry(
43617         true
43618         /* includeDrawNode */
43619       );
43620     }
43621     function checkGeometry(includeDrawNode) {
43622       var nopeDisabled = context.surface().classed("nope-disabled");
43623       var isInvalid = isInvalidGeometry(includeDrawNode);
43624       if (nopeDisabled) {
43625         context.surface().classed("nope", false).classed("nope-suppressed", isInvalid);
43626       } else {
43627         context.surface().classed("nope", isInvalid).classed("nope-suppressed", false);
43628       }
43629     }
43630     function isInvalidGeometry(includeDrawNode) {
43631       var testNode = _drawNode;
43632       var parentWay = context.graph().entity(wayID);
43633       var nodes = context.graph().childNodes(parentWay).slice();
43634       if (includeDrawNode) {
43635         if (parentWay.isClosed()) {
43636           nodes.pop();
43637         }
43638       } else {
43639         if (parentWay.isClosed()) {
43640           if (nodes.length < 3) return false;
43641           if (_drawNode) nodes.splice(-2, 1);
43642           testNode = nodes[nodes.length - 2];
43643         } else {
43644           return false;
43645         }
43646       }
43647       return testNode && geoHasSelfIntersections(nodes, testNode.id);
43648     }
43649     function undone() {
43650       _didResolveTempEdit = true;
43651       context.pauseChangeDispatch();
43652       var nextMode;
43653       if (context.graph() === startGraph) {
43654         nextMode = modeSelect(context, [wayID]);
43655       } else {
43656         context.pop(1);
43657         nextMode = mode;
43658       }
43659       context.perform(actionNoop());
43660       context.pop(1);
43661       context.resumeChangeDispatch();
43662       context.enter(nextMode);
43663     }
43664     function setActiveElements() {
43665       if (!_drawNode) return;
43666       context.surface().selectAll("." + _drawNode.id).classed("active", true);
43667     }
43668     function resetToStartGraph() {
43669       while (context.graph() !== startGraph) {
43670         context.pop();
43671       }
43672     }
43673     var drawWay = function(surface) {
43674       _drawNode = void 0;
43675       _didResolveTempEdit = false;
43676       _origWay = context.entity(wayID);
43677       if (typeof _nodeIndex === "number") {
43678         _headNodeID = _origWay.nodes[_nodeIndex];
43679       } else if (_origWay.isClosed()) {
43680         _headNodeID = _origWay.nodes[_origWay.nodes.length - 2];
43681       } else {
43682         _headNodeID = _origWay.nodes[_origWay.nodes.length - 1];
43683       }
43684       _wayGeometry = _origWay.geometry(context.graph());
43685       _annotation = _t(
43686         (_origWay.nodes.length === (_origWay.isClosed() ? 2 : 1) ? "operations.start.annotation." : "operations.continue.annotation.") + _wayGeometry
43687       );
43688       _pointerHasMoved = false;
43689       context.pauseChangeDispatch();
43690       context.perform(actionNoop(), _annotation);
43691       context.resumeChangeDispatch();
43692       behavior.hover().initialNodeID(_headNodeID);
43693       behavior.on("move", function() {
43694         _pointerHasMoved = true;
43695         move.apply(this, arguments);
43696       }).on("down", function() {
43697         move.apply(this, arguments);
43698       }).on("downcancel", function() {
43699         if (_drawNode) removeDrawNode();
43700       }).on("click", drawWay.add).on("clickWay", drawWay.addWay).on("clickNode", drawWay.addNode).on("undo", context.undo).on("cancel", drawWay.cancel).on("finish", drawWay.finish);
43701       select_default2(window).on("keydown.drawWay", keydown).on("keyup.drawWay", keyup);
43702       context.map().dblclickZoomEnable(false).on("drawn.draw", setActiveElements);
43703       setActiveElements();
43704       surface.call(behavior);
43705       context.history().on("undone.draw", undone);
43706     };
43707     drawWay.off = function(surface) {
43708       if (!_didResolveTempEdit) {
43709         context.pauseChangeDispatch();
43710         resetToStartGraph();
43711         context.resumeChangeDispatch();
43712       }
43713       _drawNode = void 0;
43714       _nodeIndex = void 0;
43715       context.map().on("drawn.draw", null);
43716       surface.call(behavior.off).selectAll(".active").classed("active", false);
43717       surface.classed("nope", false).classed("nope-suppressed", false).classed("nope-disabled", false);
43718       select_default2(window).on("keydown.drawWay", null).on("keyup.drawWay", null);
43719       context.history().on("undone.draw", null);
43720     };
43721     function attemptAdd(d2, loc, doAdd) {
43722       if (_drawNode) {
43723         context.replace(actionMoveNode(_drawNode.id, loc), _annotation);
43724         _drawNode = context.entity(_drawNode.id);
43725       } else {
43726         createDrawNode(loc);
43727       }
43728       checkGeometry(
43729         true
43730         /* includeDrawNode */
43731       );
43732       if (d2 && d2.properties && d2.properties.nope || context.surface().classed("nope")) {
43733         if (!_pointerHasMoved) {
43734           removeDrawNode();
43735         }
43736         dispatch14.call("rejectedSelfIntersection", this);
43737         return;
43738       }
43739       context.pauseChangeDispatch();
43740       doAdd();
43741       _didResolveTempEdit = true;
43742       context.resumeChangeDispatch();
43743       context.enter(mode);
43744     }
43745     drawWay.add = function(loc, d2) {
43746       attemptAdd(d2, loc, function() {
43747       });
43748     };
43749     drawWay.addWay = function(loc, edge, d2) {
43750       attemptAdd(d2, loc, function() {
43751         context.replace(
43752           actionAddMidpoint({ loc, edge }, _drawNode),
43753           _annotation
43754         );
43755       });
43756     };
43757     drawWay.addNode = function(node, d2) {
43758       if (node.id === _headNodeID || // or the first node when drawing an area
43759       _origWay.isClosed() && node.id === _origWay.first()) {
43760         drawWay.finish();
43761         return;
43762       }
43763       attemptAdd(d2, node.loc, function() {
43764         context.replace(
43765           function actionReplaceDrawNode(graph) {
43766             graph = graph.replace(graph.entity(wayID).removeNode(_drawNode.id)).remove(_drawNode);
43767             return graph.replace(graph.entity(wayID).addNode(node.id, _nodeIndex));
43768           },
43769           _annotation
43770         );
43771       });
43772     };
43773     function getFeatureType(ways) {
43774       if (ways.every((way) => way.isClosed())) return "area";
43775       if (ways.every((way) => !way.isClosed())) return "line";
43776       return "generic";
43777     }
43778     function followMode() {
43779       if (_didResolveTempEdit) return;
43780       try {
43781         const isDrawingArea = _origWay.nodes[0] === _origWay.nodes.slice(-1)[0];
43782         const [secondLastNodeId, lastNodeId] = _origWay.nodes.slice(isDrawingArea ? -3 : -2);
43783         const historyGraph = context.history().graph();
43784         if (!lastNodeId || !secondLastNodeId || !historyGraph.hasEntity(lastNodeId) || !historyGraph.hasEntity(secondLastNodeId)) {
43785           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.needs_more_initial_nodes"))();
43786           return;
43787         }
43788         const lastNodesParents = historyGraph.parentWays(historyGraph.entity(lastNodeId)).filter((w2) => w2.id !== wayID);
43789         const secondLastNodesParents = historyGraph.parentWays(historyGraph.entity(secondLastNodeId)).filter((w2) => w2.id !== wayID);
43790         const featureType = getFeatureType(lastNodesParents);
43791         if (lastNodesParents.length !== 1 || secondLastNodesParents.length === 0) {
43792           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_multiple_ways.".concat(featureType)))();
43793           return;
43794         }
43795         if (!secondLastNodesParents.some((n3) => n3.id === lastNodesParents[0].id)) {
43796           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_different_ways.".concat(featureType)))();
43797           return;
43798         }
43799         const way = lastNodesParents[0];
43800         const indexOfLast = way.nodes.indexOf(lastNodeId);
43801         const indexOfSecondLast = way.nodes.indexOf(secondLastNodeId);
43802         const isDescendingPastZero = indexOfLast === way.nodes.length - 2 && indexOfSecondLast === 0;
43803         let nextNodeIndex = indexOfLast + (indexOfLast > indexOfSecondLast && !isDescendingPastZero ? 1 : -1);
43804         if (nextNodeIndex === -1) nextNodeIndex = indexOfSecondLast === 1 ? way.nodes.length - 2 : 1;
43805         const nextNode = historyGraph.entity(way.nodes[nextNodeIndex]);
43806         drawWay.addNode(nextNode, {
43807           geometry: { type: "Point", coordinates: nextNode.loc },
43808           id: nextNode.id,
43809           properties: { target: true, entity: nextNode }
43810         });
43811       } catch (e3) {
43812         context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.unknown"))();
43813       }
43814     }
43815     keybinding.on(_t("operations.follow.key"), followMode);
43816     select_default2(document).call(keybinding);
43817     drawWay.finish = function() {
43818       checkGeometry(
43819         false
43820         /* includeDrawNode */
43821       );
43822       if (context.surface().classed("nope")) {
43823         dispatch14.call("rejectedSelfIntersection", this);
43824         return;
43825       }
43826       context.pauseChangeDispatch();
43827       context.pop(1);
43828       _didResolveTempEdit = true;
43829       context.resumeChangeDispatch();
43830       var way = context.hasEntity(wayID);
43831       if (!way || way.isDegenerate()) {
43832         drawWay.cancel();
43833         return;
43834       }
43835       window.setTimeout(function() {
43836         context.map().dblclickZoomEnable(true);
43837       }, 1e3);
43838       var isNewFeature = !mode.isContinuing;
43839       context.enter(modeSelect(context, [wayID]).newFeature(isNewFeature));
43840     };
43841     drawWay.cancel = function() {
43842       context.pauseChangeDispatch();
43843       resetToStartGraph();
43844       context.resumeChangeDispatch();
43845       window.setTimeout(function() {
43846         context.map().dblclickZoomEnable(true);
43847       }, 1e3);
43848       context.surface().classed("nope", false).classed("nope-disabled", false).classed("nope-suppressed", false);
43849       context.enter(modeBrowse(context));
43850     };
43851     drawWay.nodeIndex = function(val) {
43852       if (!arguments.length) return _nodeIndex;
43853       _nodeIndex = val;
43854       return drawWay;
43855     };
43856     drawWay.activeID = function() {
43857       if (!arguments.length) return _drawNode && _drawNode.id;
43858       return drawWay;
43859     };
43860     return utilRebind(drawWay, dispatch14, "on");
43861   }
43862
43863   // modules/modes/draw_line.js
43864   function modeDrawLine(context, wayID, startGraph, button, affix, continuing) {
43865     var mode = {
43866       button,
43867       id: "draw-line"
43868     };
43869     var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawLine", function() {
43870       context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.lines"))();
43871     });
43872     mode.wayID = wayID;
43873     mode.isContinuing = continuing;
43874     mode.enter = function() {
43875       behavior.nodeIndex(affix === "prefix" ? 0 : void 0);
43876       context.install(behavior);
43877     };
43878     mode.exit = function() {
43879       context.uninstall(behavior);
43880     };
43881     mode.selectedIDs = function() {
43882       return [wayID];
43883     };
43884     mode.activeID = function() {
43885       return behavior && behavior.activeID() || [];
43886     };
43887     return mode;
43888   }
43889
43890   // modules/validations/disconnected_way.js
43891   function validationDisconnectedWay() {
43892     var type2 = "disconnected_way";
43893     function isTaggedAsHighway(entity) {
43894       return osmRoutableHighwayTagValues[entity.tags.highway];
43895     }
43896     var validation = function checkDisconnectedWay(entity, graph) {
43897       var routingIslandWays = routingIslandForEntity(entity);
43898       if (!routingIslandWays) return [];
43899       return [new validationIssue({
43900         type: type2,
43901         subtype: "highway",
43902         severity: "warning",
43903         message: function(context) {
43904           var entity2 = this.entityIds.length && context.hasEntity(this.entityIds[0]);
43905           var label = entity2 && utilDisplayLabel(entity2, context.graph());
43906           return _t.append("issues.disconnected_way.routable.message", { count: this.entityIds.length, highway: label });
43907         },
43908         reference: showReference,
43909         entityIds: Array.from(routingIslandWays).map(function(way) {
43910           return way.id;
43911         }),
43912         dynamicFixes: makeFixes
43913       })];
43914       function makeFixes(context) {
43915         var fixes = [];
43916         var singleEntity = this.entityIds.length === 1 && context.hasEntity(this.entityIds[0]);
43917         if (singleEntity) {
43918           if (singleEntity.type === "way" && !singleEntity.isClosed()) {
43919             var textDirection = _mainLocalizer.textDirection();
43920             var startFix = makeContinueDrawingFixIfAllowed(textDirection, singleEntity.first(), "start");
43921             if (startFix) fixes.push(startFix);
43922             var endFix = makeContinueDrawingFixIfAllowed(textDirection, singleEntity.last(), "end");
43923             if (endFix) fixes.push(endFix);
43924           }
43925           if (!fixes.length) {
43926             fixes.push(new validationIssueFix({
43927               title: _t.append("issues.fix.connect_feature.title")
43928             }));
43929           }
43930           fixes.push(new validationIssueFix({
43931             icon: "iD-operation-delete",
43932             title: _t.append("issues.fix.delete_feature.title"),
43933             entityIds: [singleEntity.id],
43934             onClick: function(context2) {
43935               var id2 = this.issue.entityIds[0];
43936               var operation2 = operationDelete(context2, [id2]);
43937               if (!operation2.disabled()) {
43938                 operation2();
43939               }
43940             }
43941           }));
43942         } else {
43943           fixes.push(new validationIssueFix({
43944             title: _t.append("issues.fix.connect_features.title")
43945           }));
43946         }
43947         return fixes;
43948       }
43949       function showReference(selection2) {
43950         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.disconnected_way.routable.reference"));
43951       }
43952       function routingIslandForEntity(entity2) {
43953         var routingIsland = /* @__PURE__ */ new Set();
43954         var waysToCheck = [];
43955         function queueParentWays(node) {
43956           graph.parentWays(node).forEach(function(parentWay) {
43957             if (!routingIsland.has(parentWay) && // only check each feature once
43958             isRoutableWay(parentWay, false)) {
43959               routingIsland.add(parentWay);
43960               waysToCheck.push(parentWay);
43961             }
43962           });
43963         }
43964         if (entity2.type === "way" && isRoutableWay(entity2, true)) {
43965           routingIsland.add(entity2);
43966           waysToCheck.push(entity2);
43967         } else if (entity2.type === "node" && isRoutableNode(entity2)) {
43968           routingIsland.add(entity2);
43969           queueParentWays(entity2);
43970         } else {
43971           return null;
43972         }
43973         while (waysToCheck.length) {
43974           var wayToCheck = waysToCheck.pop();
43975           var childNodes = graph.childNodes(wayToCheck);
43976           for (var i3 in childNodes) {
43977             var vertex = childNodes[i3];
43978             if (isConnectedVertex(vertex)) {
43979               return null;
43980             }
43981             if (isRoutableNode(vertex)) {
43982               routingIsland.add(vertex);
43983             }
43984             queueParentWays(vertex);
43985           }
43986         }
43987         return routingIsland;
43988       }
43989       function isConnectedVertex(vertex) {
43990         var osm = services.osm;
43991         if (osm && !osm.isDataLoaded(vertex.loc)) return true;
43992         if (vertex.tags.entrance && vertex.tags.entrance !== "no") return true;
43993         if (vertex.tags.amenity === "parking_entrance") return true;
43994         return false;
43995       }
43996       function isRoutableNode(node) {
43997         if (node.tags.highway === "elevator") return true;
43998         return false;
43999       }
44000       function isRoutableWay(way, ignoreInnerWays) {
44001         if (isTaggedAsHighway(way) || way.tags.route === "ferry") return true;
44002         return graph.parentRelations(way).some(function(parentRelation) {
44003           if (parentRelation.tags.type === "route" && parentRelation.tags.route === "ferry") return true;
44004           if (parentRelation.isMultipolygon() && isTaggedAsHighway(parentRelation) && (!ignoreInnerWays || parentRelation.memberById(way.id).role !== "inner")) return true;
44005           return false;
44006         });
44007       }
44008       function makeContinueDrawingFixIfAllowed(textDirection, vertexID, whichEnd) {
44009         var vertex = graph.hasEntity(vertexID);
44010         if (!vertex || vertex.tags.noexit === "yes") return null;
44011         var useLeftContinue = whichEnd === "start" && textDirection === "ltr" || whichEnd === "end" && textDirection === "rtl";
44012         return new validationIssueFix({
44013           icon: "iD-operation-continue" + (useLeftContinue ? "-left" : ""),
44014           title: _t.append("issues.fix.continue_from_" + whichEnd + ".title"),
44015           entityIds: [vertexID],
44016           onClick: function(context) {
44017             var wayId = this.issue.entityIds[0];
44018             var way = context.hasEntity(wayId);
44019             var vertexId = this.entityIds[0];
44020             var vertex2 = context.hasEntity(vertexId);
44021             if (!way || !vertex2) return;
44022             var map2 = context.map();
44023             if (!context.editable() || !map2.trimmedExtent().contains(vertex2.loc)) {
44024               map2.zoomToEase(vertex2);
44025             }
44026             context.enter(
44027               modeDrawLine(context, wayId, context.graph(), "line", way.affix(vertexId), true)
44028             );
44029           }
44030         });
44031       }
44032     };
44033     validation.type = type2;
44034     return validation;
44035   }
44036
44037   // modules/validations/invalid_format.js
44038   function validationFormatting() {
44039     var type2 = "invalid_format";
44040     var validation = function(entity) {
44041       var issues = [];
44042       function isValidEmail(email) {
44043         var valid_email = /^[^\(\)\\,":;<>@\[\]]+@[^\(\)\\,":;<>@\[\]\.]+(?:\.[a-z0-9-]+)*$/i;
44044         return !email || valid_email.test(email);
44045       }
44046       function showReferenceEmail(selection2) {
44047         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.invalid_format.email.reference"));
44048       }
44049       if (entity.tags.email) {
44050         var emails = entity.tags.email.split(";").map(function(s2) {
44051           return s2.trim();
44052         }).filter(function(x2) {
44053           return !isValidEmail(x2);
44054         });
44055         if (emails.length) {
44056           issues.push(new validationIssue({
44057             type: type2,
44058             subtype: "email",
44059             severity: "warning",
44060             message: function(context) {
44061               var entity2 = context.hasEntity(this.entityIds[0]);
44062               return entity2 ? _t.append(
44063                 "issues.invalid_format.email.message" + this.data,
44064                 { feature: utilDisplayLabel(entity2, context.graph()), email: emails.join(", ") }
44065               ) : "";
44066             },
44067             reference: showReferenceEmail,
44068             entityIds: [entity.id],
44069             hash: emails.join(),
44070             data: emails.length > 1 ? "_multi" : ""
44071           }));
44072         }
44073       }
44074       return issues;
44075     };
44076     validation.type = type2;
44077     return validation;
44078   }
44079
44080   // modules/validations/help_request.js
44081   function validationHelpRequest(context) {
44082     var type2 = "help_request";
44083     var validation = function checkFixmeTag(entity) {
44084       if (!entity.tags.fixme) return [];
44085       if (entity.version === void 0) return [];
44086       if (entity.v !== void 0) {
44087         var baseEntity = context.history().base().hasEntity(entity.id);
44088         if (!baseEntity || !baseEntity.tags.fixme) return [];
44089       }
44090       return [new validationIssue({
44091         type: type2,
44092         subtype: "fixme_tag",
44093         severity: "warning",
44094         message: function(context2) {
44095           var entity2 = context2.hasEntity(this.entityIds[0]);
44096           return entity2 ? _t.append("issues.fixme_tag.message", {
44097             feature: utilDisplayLabel(
44098               entity2,
44099               context2.graph(),
44100               true
44101               /* verbose */
44102             )
44103           }) : "";
44104         },
44105         dynamicFixes: function() {
44106           return [
44107             new validationIssueFix({
44108               title: _t.append("issues.fix.address_the_concern.title")
44109             })
44110           ];
44111         },
44112         reference: showReference,
44113         entityIds: [entity.id]
44114       })];
44115       function showReference(selection2) {
44116         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.fixme_tag.reference"));
44117       }
44118     };
44119     validation.type = type2;
44120     return validation;
44121   }
44122
44123   // modules/validations/impossible_oneway.js
44124   function validationImpossibleOneway() {
44125     var type2 = "impossible_oneway";
44126     var validation = function checkImpossibleOneway(entity, graph) {
44127       if (entity.type !== "way" || entity.geometry(graph) !== "line") return [];
44128       if (entity.isClosed()) return [];
44129       if (!typeForWay(entity)) return [];
44130       if (!isOneway(entity)) return [];
44131       var firstIssues = issuesForNode(entity, entity.first());
44132       var lastIssues = issuesForNode(entity, entity.last());
44133       return firstIssues.concat(lastIssues);
44134       function typeForWay(way) {
44135         if (way.geometry(graph) !== "line") return null;
44136         if (osmRoutableHighwayTagValues[way.tags.highway]) return "highway";
44137         if (osmFlowingWaterwayTagValues[way.tags.waterway]) return "waterway";
44138         return null;
44139       }
44140       function isOneway(way) {
44141         if (way.tags.oneway === "yes") return true;
44142         if (way.tags.oneway) return false;
44143         for (var key in way.tags) {
44144           if (osmOneWayTags[key] && osmOneWayTags[key][way.tags[key]]) {
44145             return true;
44146           }
44147         }
44148         return false;
44149       }
44150       function nodeOccursMoreThanOnce(way, nodeID) {
44151         var occurrences = 0;
44152         for (var index in way.nodes) {
44153           if (way.nodes[index] === nodeID) {
44154             occurrences += 1;
44155             if (occurrences > 1) return true;
44156           }
44157         }
44158         return false;
44159       }
44160       function isConnectedViaOtherTypes(way, node) {
44161         var wayType = typeForWay(way);
44162         if (wayType === "highway") {
44163           if (node.tags.entrance && node.tags.entrance !== "no") return true;
44164           if (node.tags.amenity === "parking_entrance") return true;
44165         } else if (wayType === "waterway") {
44166           if (node.id === way.first()) {
44167             if (node.tags.natural === "spring") return true;
44168           } else {
44169             if (node.tags.manhole === "drain") return true;
44170           }
44171         }
44172         return graph.parentWays(node).some(function(parentWay) {
44173           if (parentWay.id === way.id) return false;
44174           if (wayType === "highway") {
44175             if (parentWay.geometry(graph) === "area" && osmRoutableHighwayTagValues[parentWay.tags.highway]) return true;
44176             if (parentWay.tags.route === "ferry") return true;
44177             return graph.parentRelations(parentWay).some(function(parentRelation) {
44178               if (parentRelation.tags.type === "route" && parentRelation.tags.route === "ferry") return true;
44179               return parentRelation.isMultipolygon() && osmRoutableHighwayTagValues[parentRelation.tags.highway];
44180             });
44181           } else if (wayType === "waterway") {
44182             if (parentWay.tags.natural === "water" || parentWay.tags.natural === "coastline") return true;
44183           }
44184           return false;
44185         });
44186       }
44187       function issuesForNode(way, nodeID) {
44188         var isFirst = nodeID === way.first();
44189         var wayType = typeForWay(way);
44190         if (nodeOccursMoreThanOnce(way, nodeID)) return [];
44191         var osm = services.osm;
44192         if (!osm) return [];
44193         var node = graph.hasEntity(nodeID);
44194         if (!node || !osm.isDataLoaded(node.loc)) return [];
44195         if (isConnectedViaOtherTypes(way, node)) return [];
44196         var attachedWaysOfSameType = graph.parentWays(node).filter(function(parentWay) {
44197           if (parentWay.id === way.id) return false;
44198           return typeForWay(parentWay) === wayType;
44199         });
44200         if (wayType === "waterway" && attachedWaysOfSameType.length === 0) return [];
44201         var attachedOneways = attachedWaysOfSameType.filter(function(attachedWay) {
44202           return isOneway(attachedWay);
44203         });
44204         if (attachedOneways.length < attachedWaysOfSameType.length) return [];
44205         if (attachedOneways.length) {
44206           var connectedEndpointsOkay = attachedOneways.some(function(attachedOneway) {
44207             if ((isFirst ? attachedOneway.first() : attachedOneway.last()) !== nodeID) return true;
44208             if (nodeOccursMoreThanOnce(attachedOneway, nodeID)) return true;
44209             return false;
44210           });
44211           if (connectedEndpointsOkay) return [];
44212         }
44213         var placement = isFirst ? "start" : "end", messageID = wayType + ".", referenceID = wayType + ".";
44214         if (wayType === "waterway") {
44215           messageID += "connected." + placement;
44216           referenceID += "connected";
44217         } else {
44218           messageID += placement;
44219           referenceID += placement;
44220         }
44221         return [new validationIssue({
44222           type: type2,
44223           subtype: wayType,
44224           severity: "warning",
44225           message: function(context) {
44226             var entity2 = context.hasEntity(this.entityIds[0]);
44227             return entity2 ? _t.append("issues.impossible_oneway." + messageID + ".message", {
44228               feature: utilDisplayLabel(entity2, context.graph())
44229             }) : "";
44230           },
44231           reference: getReference(referenceID),
44232           entityIds: [way.id, node.id],
44233           dynamicFixes: function() {
44234             var fixes = [];
44235             if (attachedOneways.length) {
44236               fixes.push(new validationIssueFix({
44237                 icon: "iD-operation-reverse",
44238                 title: _t.append("issues.fix.reverse_feature.title"),
44239                 entityIds: [way.id],
44240                 onClick: function(context) {
44241                   var id2 = this.issue.entityIds[0];
44242                   context.perform(actionReverse(id2), _t("operations.reverse.annotation.line", { n: 1 }));
44243                 }
44244               }));
44245             }
44246             if (node.tags.noexit !== "yes") {
44247               var textDirection = _mainLocalizer.textDirection();
44248               var useLeftContinue = isFirst && textDirection === "ltr" || !isFirst && textDirection === "rtl";
44249               fixes.push(new validationIssueFix({
44250                 icon: "iD-operation-continue" + (useLeftContinue ? "-left" : ""),
44251                 title: _t.append("issues.fix.continue_from_" + (isFirst ? "start" : "end") + ".title"),
44252                 onClick: function(context) {
44253                   var entityID = this.issue.entityIds[0];
44254                   var vertexID = this.issue.entityIds[1];
44255                   var way2 = context.entity(entityID);
44256                   var vertex = context.entity(vertexID);
44257                   continueDrawing(way2, vertex, context);
44258                 }
44259               }));
44260             }
44261             return fixes;
44262           },
44263           loc: node.loc
44264         })];
44265         function getReference(referenceID2) {
44266           return function showReference(selection2) {
44267             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.impossible_oneway." + referenceID2 + ".reference"));
44268           };
44269         }
44270       }
44271     };
44272     function continueDrawing(way, vertex, context) {
44273       var map2 = context.map();
44274       if (!context.editable() || !map2.trimmedExtent().contains(vertex.loc)) {
44275         map2.zoomToEase(vertex);
44276       }
44277       context.enter(
44278         modeDrawLine(context, way.id, context.graph(), "line", way.affix(vertex.id), true)
44279       );
44280     }
44281     validation.type = type2;
44282     return validation;
44283   }
44284
44285   // modules/validations/incompatible_source.js
44286   function validationIncompatibleSource() {
44287     const type2 = "incompatible_source";
44288     const incompatibleRules = [
44289       {
44290         id: "amap",
44291         regex: /(^amap$|^amap\.com|autonavi|mapabc|高德)/i
44292       },
44293       {
44294         id: "baidu",
44295         regex: /(baidu|mapbar|百度)/i
44296       },
44297       {
44298         id: "google",
44299         regex: /google/i,
44300         exceptRegex: /((books|drive)\.google|google\s?(books|drive|plus))|(esri\/Google_Africa_Buildings)/i
44301       }
44302     ];
44303     const validation = function checkIncompatibleSource(entity) {
44304       const entitySources = entity.tags && entity.tags.source && entity.tags.source.split(";");
44305       if (!entitySources) return [];
44306       const entityID = entity.id;
44307       return entitySources.map((source) => {
44308         const matchRule = incompatibleRules.find((rule) => {
44309           if (!rule.regex.test(source)) return false;
44310           if (rule.exceptRegex && rule.exceptRegex.test(source)) return false;
44311           return true;
44312         });
44313         if (!matchRule) return null;
44314         return new validationIssue({
44315           type: type2,
44316           severity: "warning",
44317           message: (context) => {
44318             const entity2 = context.hasEntity(entityID);
44319             return entity2 ? _t.append("issues.incompatible_source.feature.message", {
44320               feature: utilDisplayLabel(
44321                 entity2,
44322                 context.graph(),
44323                 true
44324                 /* verbose */
44325               ),
44326               value: source
44327             }) : "";
44328           },
44329           reference: getReference(matchRule.id),
44330           entityIds: [entityID],
44331           hash: source,
44332           dynamicFixes: () => {
44333             return [
44334               new validationIssueFix({ title: _t.append("issues.fix.remove_proprietary_data.title") })
44335             ];
44336           }
44337         });
44338       }).filter(Boolean);
44339       function getReference(id2) {
44340         return function showReference(selection2) {
44341           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.incompatible_source.reference.".concat(id2)));
44342         };
44343       }
44344     };
44345     validation.type = type2;
44346     return validation;
44347   }
44348
44349   // modules/validations/maprules.js
44350   function validationMaprules() {
44351     var type2 = "maprules";
44352     var validation = function checkMaprules(entity, graph) {
44353       if (!services.maprules) return [];
44354       var rules = services.maprules.validationRules();
44355       var issues = [];
44356       for (var i3 = 0; i3 < rules.length; i3++) {
44357         var rule = rules[i3];
44358         rule.findIssues(entity, graph, issues);
44359       }
44360       return issues;
44361     };
44362     validation.type = type2;
44363     return validation;
44364   }
44365
44366   // modules/validations/mismatched_geometry.js
44367   var import_fast_deep_equal4 = __toESM(require_fast_deep_equal());
44368   function validationMismatchedGeometry() {
44369     var type2 = "mismatched_geometry";
44370     function tagSuggestingLineIsArea(entity) {
44371       if (entity.type !== "way" || entity.isClosed()) return null;
44372       var tagSuggestingArea = entity.tagSuggestingArea();
44373       if (!tagSuggestingArea) {
44374         return null;
44375       }
44376       var asLine = _mainPresetIndex.matchTags(tagSuggestingArea, "line");
44377       var asArea = _mainPresetIndex.matchTags(tagSuggestingArea, "area");
44378       if (asLine && asArea && (0, import_fast_deep_equal4.default)(asLine.tags, asArea.tags)) {
44379         return null;
44380       }
44381       if (asLine.isFallback() && asArea.isFallback() && !(0, import_fast_deep_equal4.default)(tagSuggestingArea, { area: "yes" })) {
44382         return null;
44383       }
44384       return tagSuggestingArea;
44385     }
44386     function makeConnectEndpointsFixOnClick(way, graph) {
44387       if (way.nodes.length < 3) return null;
44388       var nodes = graph.childNodes(way), testNodes;
44389       var firstToLastDistanceMeters = geoSphericalDistance(nodes[0].loc, nodes[nodes.length - 1].loc);
44390       if (firstToLastDistanceMeters < 0.75) {
44391         testNodes = nodes.slice();
44392         testNodes.pop();
44393         testNodes.push(testNodes[0]);
44394         if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
44395           return function(context) {
44396             var way2 = context.entity(this.issue.entityIds[0]);
44397             context.perform(
44398               actionMergeNodes([way2.nodes[0], way2.nodes[way2.nodes.length - 1]], nodes[0].loc),
44399               _t("issues.fix.connect_endpoints.annotation")
44400             );
44401           };
44402         }
44403       }
44404       testNodes = nodes.slice();
44405       testNodes.push(testNodes[0]);
44406       if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
44407         return function(context) {
44408           var wayId = this.issue.entityIds[0];
44409           var way2 = context.entity(wayId);
44410           var nodeId = way2.nodes[0];
44411           var index = way2.nodes.length;
44412           context.perform(
44413             actionAddVertex(wayId, nodeId, index),
44414             _t("issues.fix.connect_endpoints.annotation")
44415           );
44416         };
44417       }
44418     }
44419     function lineTaggedAsAreaIssue(entity) {
44420       var tagSuggestingArea = tagSuggestingLineIsArea(entity);
44421       if (!tagSuggestingArea) return null;
44422       var validAsLine = false;
44423       var presetAsLine = _mainPresetIndex.matchTags(entity.tags, "line");
44424       if (presetAsLine) {
44425         validAsLine = true;
44426         var key = Object.keys(tagSuggestingArea)[0];
44427         if (presetAsLine.tags[key] && presetAsLine.tags[key] === "*") {
44428           validAsLine = false;
44429         }
44430         if (Object.keys(presetAsLine.tags).length === 0) {
44431           validAsLine = false;
44432         }
44433       }
44434       return new validationIssue({
44435         type: type2,
44436         subtype: "area_as_line",
44437         severity: "warning",
44438         message: function(context) {
44439           var entity2 = context.hasEntity(this.entityIds[0]);
44440           return entity2 ? _t.append("issues.tag_suggests_area.message", {
44441             feature: utilDisplayLabel(
44442               entity2,
44443               "area",
44444               true
44445               /* verbose */
44446             ),
44447             tag: utilTagText({ tags: tagSuggestingArea })
44448           }) : "";
44449         },
44450         reference: showReference,
44451         entityIds: [entity.id],
44452         hash: JSON.stringify(tagSuggestingArea),
44453         dynamicFixes: function(context) {
44454           var fixes = [];
44455           var entity2 = context.entity(this.entityIds[0]);
44456           var connectEndsOnClick = makeConnectEndpointsFixOnClick(entity2, context.graph());
44457           if (!validAsLine) {
44458             fixes.push(new validationIssueFix({
44459               title: _t.append("issues.fix.connect_endpoints.title"),
44460               onClick: connectEndsOnClick
44461             }));
44462           }
44463           fixes.push(new validationIssueFix({
44464             icon: "iD-operation-delete",
44465             title: _t.append("issues.fix.remove_tag.title"),
44466             onClick: function(context2) {
44467               var entityId = this.issue.entityIds[0];
44468               var entity3 = context2.entity(entityId);
44469               var tags = Object.assign({}, entity3.tags);
44470               for (var key2 in tagSuggestingArea) {
44471                 delete tags[key2];
44472               }
44473               context2.perform(
44474                 actionChangeTags(entityId, tags),
44475                 _t("issues.fix.remove_tag.annotation")
44476               );
44477             }
44478           }));
44479           return fixes;
44480         }
44481       });
44482       function showReference(selection2) {
44483         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.tag_suggests_area.reference"));
44484       }
44485     }
44486     function vertexPointIssue(entity, graph) {
44487       if (entity.type !== "node") return null;
44488       if (Object.keys(entity.tags).length === 0) return null;
44489       if (entity.isOnAddressLine(graph)) return null;
44490       var geometry = entity.geometry(graph);
44491       var allowedGeometries = osmNodeGeometriesForTags(entity.tags);
44492       if (geometry === "point" && !allowedGeometries.point && allowedGeometries.vertex) {
44493         return new validationIssue({
44494           type: type2,
44495           subtype: "vertex_as_point",
44496           severity: "warning",
44497           message: function(context) {
44498             var entity2 = context.hasEntity(this.entityIds[0]);
44499             return entity2 ? _t.append("issues.vertex_as_point.message", {
44500               feature: utilDisplayLabel(
44501                 entity2,
44502                 "vertex",
44503                 true
44504                 /* verbose */
44505               )
44506             }) : "";
44507           },
44508           reference: function showReference(selection2) {
44509             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.vertex_as_point.reference"));
44510           },
44511           entityIds: [entity.id]
44512         });
44513       } else if (geometry === "vertex" && !allowedGeometries.vertex && allowedGeometries.point) {
44514         return new validationIssue({
44515           type: type2,
44516           subtype: "point_as_vertex",
44517           severity: "warning",
44518           message: function(context) {
44519             var entity2 = context.hasEntity(this.entityIds[0]);
44520             return entity2 ? _t.append("issues.point_as_vertex.message", {
44521               feature: utilDisplayLabel(
44522                 entity2,
44523                 "point",
44524                 true
44525                 /* verbose */
44526               )
44527             }) : "";
44528           },
44529           reference: function showReference(selection2) {
44530             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.point_as_vertex.reference"));
44531           },
44532           entityIds: [entity.id],
44533           dynamicFixes: extractPointDynamicFixes
44534         });
44535       }
44536       return null;
44537     }
44538     function otherMismatchIssue(entity, graph) {
44539       if (!entity.hasInterestingTags()) return null;
44540       if (entity.type !== "node" && entity.type !== "way") return null;
44541       if (entity.type === "node" && entity.isOnAddressLine(graph)) return null;
44542       var sourceGeom = entity.geometry(graph);
44543       var targetGeoms = entity.type === "way" ? ["point", "vertex"] : ["line", "area"];
44544       if (sourceGeom === "area") targetGeoms.unshift("line");
44545       var asSource = _mainPresetIndex.match(entity, graph);
44546       var targetGeom = targetGeoms.find((nodeGeom) => {
44547         const asTarget = _mainPresetIndex.matchTags(
44548           entity.tags,
44549           nodeGeom,
44550           entity.extent(graph).center()
44551         );
44552         if (!asSource || !asTarget || asSource === asTarget || // sometimes there are two presets with the same tags for different geometries
44553         (0, import_fast_deep_equal4.default)(asSource.tags, asTarget.tags)) return false;
44554         if (asTarget.isFallback()) return false;
44555         var primaryKey = Object.keys(asTarget.tags)[0];
44556         if (primaryKey === "building") return false;
44557         if (asTarget.tags[primaryKey] === "*") return false;
44558         return asSource.isFallback() || asSource.tags[primaryKey] === "*";
44559       });
44560       if (!targetGeom) return null;
44561       var subtype = targetGeom + "_as_" + sourceGeom;
44562       if (targetGeom === "vertex") targetGeom = "point";
44563       if (sourceGeom === "vertex") sourceGeom = "point";
44564       var referenceId = targetGeom + "_as_" + sourceGeom;
44565       var dynamicFixes;
44566       if (targetGeom === "point") {
44567         dynamicFixes = extractPointDynamicFixes;
44568       } else if (sourceGeom === "area" && targetGeom === "line") {
44569         dynamicFixes = lineToAreaDynamicFixes;
44570       }
44571       return new validationIssue({
44572         type: type2,
44573         subtype,
44574         severity: "warning",
44575         message: function(context) {
44576           var entity2 = context.hasEntity(this.entityIds[0]);
44577           return entity2 ? _t.append("issues." + referenceId + ".message", {
44578             feature: utilDisplayLabel(
44579               entity2,
44580               targetGeom,
44581               true
44582               /* verbose */
44583             )
44584           }) : "";
44585         },
44586         reference: function showReference(selection2) {
44587           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.mismatched_geometry.reference"));
44588         },
44589         entityIds: [entity.id],
44590         dynamicFixes
44591       });
44592     }
44593     function lineToAreaDynamicFixes(context) {
44594       var convertOnClick;
44595       var entityId = this.entityIds[0];
44596       var entity = context.entity(entityId);
44597       var tags = Object.assign({}, entity.tags);
44598       delete tags.area;
44599       if (!osmTagSuggestingArea(tags)) {
44600         convertOnClick = function(context2) {
44601           var entityId2 = this.issue.entityIds[0];
44602           var entity2 = context2.entity(entityId2);
44603           var tags2 = Object.assign({}, entity2.tags);
44604           if (tags2.area) {
44605             delete tags2.area;
44606           }
44607           context2.perform(
44608             actionChangeTags(entityId2, tags2),
44609             _t("issues.fix.convert_to_line.annotation")
44610           );
44611         };
44612       }
44613       return [
44614         new validationIssueFix({
44615           icon: "iD-icon-line",
44616           title: _t.append("issues.fix.convert_to_line.title"),
44617           onClick: convertOnClick
44618         })
44619       ];
44620     }
44621     function extractPointDynamicFixes(context) {
44622       var entityId = this.entityIds[0];
44623       var extractOnClick = null;
44624       if (!context.hasHiddenConnections(entityId)) {
44625         extractOnClick = function(context2) {
44626           var entityId2 = this.issue.entityIds[0];
44627           var action = actionExtract(entityId2, context2.projection);
44628           context2.perform(
44629             action,
44630             _t("operations.extract.annotation", { n: 1 })
44631           );
44632           context2.enter(modeSelect(context2, [action.getExtractedNodeID()]));
44633         };
44634       }
44635       return [
44636         new validationIssueFix({
44637           icon: "iD-operation-extract",
44638           title: _t.append("issues.fix.extract_point.title"),
44639           onClick: extractOnClick
44640         })
44641       ];
44642     }
44643     function unclosedMultipolygonPartIssues(entity, graph) {
44644       if (entity.type !== "relation" || !entity.isMultipolygon() || entity.isDegenerate() || // cannot determine issues for incompletely-downloaded relations
44645       !entity.isComplete(graph)) return [];
44646       var sequences = osmJoinWays(entity.members, graph);
44647       var issues = [];
44648       for (var i3 in sequences) {
44649         var sequence = sequences[i3];
44650         if (!sequence.nodes) continue;
44651         var firstNode = sequence.nodes[0];
44652         var lastNode = sequence.nodes[sequence.nodes.length - 1];
44653         if (firstNode === lastNode) continue;
44654         var issue = new validationIssue({
44655           type: type2,
44656           subtype: "unclosed_multipolygon_part",
44657           severity: "warning",
44658           message: function(context) {
44659             var entity2 = context.hasEntity(this.entityIds[0]);
44660             return entity2 ? _t.append("issues.unclosed_multipolygon_part.message", {
44661               feature: utilDisplayLabel(
44662                 entity2,
44663                 context.graph(),
44664                 true
44665                 /* verbose */
44666               )
44667             }) : "";
44668           },
44669           reference: showReference,
44670           loc: sequence.nodes[0].loc,
44671           entityIds: [entity.id],
44672           hash: sequence.map(function(way) {
44673             return way.id;
44674           }).join()
44675         });
44676         issues.push(issue);
44677       }
44678       return issues;
44679       function showReference(selection2) {
44680         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.unclosed_multipolygon_part.reference"));
44681       }
44682     }
44683     var validation = function checkMismatchedGeometry(entity, graph) {
44684       var vertexPoint = vertexPointIssue(entity, graph);
44685       if (vertexPoint) return [vertexPoint];
44686       var lineAsArea = lineTaggedAsAreaIssue(entity);
44687       if (lineAsArea) return [lineAsArea];
44688       var mismatch = otherMismatchIssue(entity, graph);
44689       if (mismatch) return [mismatch];
44690       return unclosedMultipolygonPartIssues(entity, graph);
44691     };
44692     validation.type = type2;
44693     return validation;
44694   }
44695
44696   // modules/validations/missing_role.js
44697   function validationMissingRole() {
44698     var type2 = "missing_role";
44699     var validation = function checkMissingRole(entity, graph) {
44700       var issues = [];
44701       if (entity.type === "way") {
44702         graph.parentRelations(entity).forEach(function(relation) {
44703           if (!relation.isMultipolygon()) return;
44704           var member = relation.memberById(entity.id);
44705           if (member && isMissingRole(member)) {
44706             issues.push(makeIssue(entity, relation, member));
44707           }
44708         });
44709       } else if (entity.type === "relation" && entity.isMultipolygon()) {
44710         entity.indexedMembers().forEach(function(member) {
44711           var way = graph.hasEntity(member.id);
44712           if (way && isMissingRole(member)) {
44713             issues.push(makeIssue(way, entity, member));
44714           }
44715         });
44716       }
44717       return issues;
44718     };
44719     function isMissingRole(member) {
44720       return !member.role || !member.role.trim().length;
44721     }
44722     function makeIssue(way, relation, member) {
44723       return new validationIssue({
44724         type: type2,
44725         severity: "warning",
44726         message: function(context) {
44727           var member2 = context.hasEntity(this.entityIds[1]), relation2 = context.hasEntity(this.entityIds[0]);
44728           return member2 && relation2 ? _t.append("issues.missing_role.message", {
44729             member: utilDisplayLabel(member2, context.graph()),
44730             relation: utilDisplayLabel(relation2, context.graph())
44731           }) : "";
44732         },
44733         reference: showReference,
44734         entityIds: [relation.id, way.id],
44735         data: {
44736           member
44737         },
44738         hash: member.index.toString(),
44739         dynamicFixes: function() {
44740           return [
44741             makeAddRoleFix("inner"),
44742             makeAddRoleFix("outer"),
44743             new validationIssueFix({
44744               icon: "iD-operation-delete",
44745               title: _t.append("issues.fix.remove_from_relation.title"),
44746               onClick: function(context) {
44747                 context.perform(
44748                   actionDeleteMember(this.issue.entityIds[0], this.issue.data.member.index),
44749                   _t("operations.delete_member.annotation", {
44750                     n: 1
44751                   })
44752                 );
44753               }
44754             })
44755           ];
44756         }
44757       });
44758       function showReference(selection2) {
44759         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.missing_role.multipolygon.reference"));
44760       }
44761     }
44762     function makeAddRoleFix(role) {
44763       return new validationIssueFix({
44764         title: _t.append("issues.fix.set_as_" + role + ".title"),
44765         onClick: function(context) {
44766           var oldMember = this.issue.data.member;
44767           var member = { id: this.issue.entityIds[1], type: oldMember.type, role };
44768           context.perform(
44769             actionChangeMember(this.issue.entityIds[0], member, oldMember.index),
44770             _t("operations.change_role.annotation", {
44771               n: 1
44772             })
44773           );
44774         }
44775       });
44776     }
44777     validation.type = type2;
44778     return validation;
44779   }
44780
44781   // modules/validations/missing_tag.js
44782   function validationMissingTag(context) {
44783     var type2 = "missing_tag";
44784     function hasDescriptiveTags(entity) {
44785       var onlyAttributeKeys = ["description", "name", "note", "start_date", "oneway"];
44786       var entityDescriptiveKeys = Object.keys(entity.tags).filter(function(k2) {
44787         if (k2 === "area" || !osmIsInterestingTag(k2)) return false;
44788         return !onlyAttributeKeys.some(function(attributeKey) {
44789           return k2 === attributeKey || k2.indexOf(attributeKey + ":") === 0;
44790         });
44791       });
44792       if (entity.type === "relation" && entityDescriptiveKeys.length === 1 && entity.tags.type === "multipolygon") {
44793         return false;
44794       }
44795       return entityDescriptiveKeys.length > 0;
44796     }
44797     function isUnknownRoad(entity) {
44798       return entity.type === "way" && entity.tags.highway === "road";
44799     }
44800     function isUntypedRelation(entity) {
44801       return entity.type === "relation" && !entity.tags.type;
44802     }
44803     var validation = function checkMissingTag(entity, graph) {
44804       var subtype;
44805       var osm = context.connection();
44806       var isUnloadedNode = entity.type === "node" && osm && !osm.isDataLoaded(entity.loc);
44807       if (!isUnloadedNode && // allow untagged nodes that are part of ways
44808       entity.geometry(graph) !== "vertex" && // allow untagged entities that are part of relations
44809       !entity.hasParentRelations(graph)) {
44810         if (Object.keys(entity.tags).length === 0) {
44811           subtype = "any";
44812         } else if (!hasDescriptiveTags(entity)) {
44813           subtype = "descriptive";
44814         } else if (isUntypedRelation(entity)) {
44815           subtype = "relation_type";
44816         }
44817       }
44818       if (!subtype && isUnknownRoad(entity)) {
44819         subtype = "highway_classification";
44820       }
44821       if (!subtype) return [];
44822       var messageID = subtype === "highway_classification" ? "unknown_road" : "missing_tag." + subtype;
44823       var referenceID = subtype === "highway_classification" ? "unknown_road" : "missing_tag";
44824       var canDelete = entity.version === void 0 || entity.v !== void 0;
44825       var severity = canDelete && subtype !== "highway_classification" ? "error" : "warning";
44826       return [new validationIssue({
44827         type: type2,
44828         subtype,
44829         severity,
44830         message: function(context2) {
44831           var entity2 = context2.hasEntity(this.entityIds[0]);
44832           return entity2 ? _t.append("issues." + messageID + ".message", {
44833             feature: utilDisplayLabel(entity2, context2.graph())
44834           }) : "";
44835         },
44836         reference: showReference,
44837         entityIds: [entity.id],
44838         dynamicFixes: function(context2) {
44839           var fixes = [];
44840           var selectFixType = subtype === "highway_classification" ? "select_road_type" : "select_preset";
44841           fixes.push(new validationIssueFix({
44842             icon: "iD-icon-search",
44843             title: _t.append("issues.fix." + selectFixType + ".title"),
44844             onClick: function(context3) {
44845               context3.ui().sidebar.showPresetList();
44846             }
44847           }));
44848           var deleteOnClick;
44849           var id2 = this.entityIds[0];
44850           var operation2 = operationDelete(context2, [id2]);
44851           var disabledReasonID = operation2.disabled();
44852           if (!disabledReasonID) {
44853             deleteOnClick = function(context3) {
44854               var id3 = this.issue.entityIds[0];
44855               var operation3 = operationDelete(context3, [id3]);
44856               if (!operation3.disabled()) {
44857                 operation3();
44858               }
44859             };
44860           }
44861           fixes.push(
44862             new validationIssueFix({
44863               icon: "iD-operation-delete",
44864               title: _t.append("issues.fix.delete_feature.title"),
44865               disabledReason: disabledReasonID ? _t("operations.delete." + disabledReasonID + ".single") : void 0,
44866               onClick: deleteOnClick
44867             })
44868           );
44869           return fixes;
44870         }
44871       })];
44872       function showReference(selection2) {
44873         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues." + referenceID + ".reference"));
44874       }
44875     };
44876     validation.type = type2;
44877     return validation;
44878   }
44879
44880   // modules/validations/mutually_exclusive_tags.js
44881   function validationMutuallyExclusiveTags() {
44882     const type2 = "mutually_exclusive_tags";
44883     const tagKeyPairs = osmMutuallyExclusiveTagPairs;
44884     const validation = function checkMutuallyExclusiveTags(entity) {
44885       let pairsFounds = tagKeyPairs.filter((pair3) => {
44886         return pair3[0] in entity.tags && pair3[1] in entity.tags;
44887       }).filter((pair3) => {
44888         return !(pair3[0].match(/^(addr:)?no[a-z]/) && entity.tags[pair3[0]] === "no" || pair3[1].match(/^(addr:)?no[a-z]/) && entity.tags[pair3[1]] === "no");
44889       });
44890       Object.keys(entity.tags).forEach((key) => {
44891         let negative_key = "not:" + key;
44892         if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) {
44893           pairsFounds.push([negative_key, key, "same_value"]);
44894         }
44895         if (key.match(/^name:[a-z]+/)) {
44896           negative_key = "not:name";
44897           if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) {
44898             pairsFounds.push([negative_key, key, "same_value"]);
44899           }
44900         }
44901       });
44902       let issues = pairsFounds.map((pair3) => {
44903         const subtype = pair3[2] || "default";
44904         return new validationIssue({
44905           type: type2,
44906           subtype,
44907           severity: "warning",
44908           message: function(context) {
44909             let entity2 = context.hasEntity(this.entityIds[0]);
44910             return entity2 ? _t.append("issues.".concat(type2, ".").concat(subtype, ".message"), {
44911               feature: utilDisplayLabel(entity2, context.graph()),
44912               tag1: pair3[0],
44913               tag2: pair3[1]
44914             }) : "";
44915           },
44916           reference: (selection2) => showReference(selection2, pair3, subtype),
44917           entityIds: [entity.id],
44918           dynamicFixes: () => pair3.slice(0, 2).map((tagToRemove) => createIssueFix(tagToRemove))
44919         });
44920       });
44921       function createIssueFix(tagToRemove) {
44922         return new validationIssueFix({
44923           icon: "iD-operation-delete",
44924           title: _t.append("issues.fix.remove_named_tag.title", { tag: tagToRemove }),
44925           onClick: function(context) {
44926             const entityId = this.issue.entityIds[0];
44927             const entity2 = context.entity(entityId);
44928             let tags = Object.assign({}, entity2.tags);
44929             delete tags[tagToRemove];
44930             context.perform(
44931               actionChangeTags(entityId, tags),
44932               _t("issues.fix.remove_named_tag.annotation", { tag: tagToRemove })
44933             );
44934           }
44935         });
44936       }
44937       function showReference(selection2, pair3, subtype) {
44938         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.".concat(type2, ".").concat(subtype, ".reference"), { tag1: pair3[0], tag2: pair3[1] }));
44939       }
44940       return issues;
44941     };
44942     validation.type = type2;
44943     return validation;
44944   }
44945
44946   // modules/validations/outdated_tags.js
44947   function validationOutdatedTags() {
44948     const type2 = "outdated_tags";
44949     let _waitingForDeprecated = true;
44950     let _dataDeprecated;
44951     _mainFileFetcher.get("deprecated").then((d2) => _dataDeprecated = d2).catch(() => {
44952     }).finally(() => _waitingForDeprecated = false);
44953     function oldTagIssues(entity, graph) {
44954       if (!entity.hasInterestingTags()) return [];
44955       let preset = _mainPresetIndex.match(entity, graph);
44956       if (!preset) return [];
44957       const oldTags = Object.assign({}, entity.tags);
44958       let subtype = "deprecated_tags";
44959       if (preset.replacement) {
44960         const newPreset = _mainPresetIndex.item(preset.replacement);
44961         graph = actionChangePreset(
44962           entity.id,
44963           preset,
44964           newPreset,
44965           true
44966           /* skip field defaults */
44967         )(graph);
44968         entity = graph.entity(entity.id);
44969         preset = newPreset;
44970       }
44971       const upgradeReasons = [];
44972       if (_dataDeprecated) {
44973         const deprecatedTags = entity.deprecatedTags(_dataDeprecated);
44974         if (entity.type === "way" && entity.isClosed() && entity.tags.traffic_calming === "island" && !entity.tags.highway) {
44975           deprecatedTags.push({
44976             old: { traffic_calming: "island" },
44977             replace: { "area:highway": "traffic_island" }
44978           });
44979         }
44980         if (deprecatedTags.length) {
44981           deprecatedTags.forEach((tag2) => {
44982             graph = actionUpgradeTags(entity.id, tag2.old, tag2.replace)(graph);
44983             upgradeReasons.push({
44984               source: "id-tagging-schema--deprecated",
44985               data: tag2
44986             });
44987           });
44988           entity = graph.entity(entity.id);
44989         }
44990       }
44991       let newTags = Object.assign({}, entity.tags);
44992       if (preset.tags !== preset.addTags) {
44993         Object.keys(preset.addTags).forEach((k2) => {
44994           if (!newTags[k2]) {
44995             if (preset.addTags[k2] === "*") {
44996               newTags[k2] = "yes";
44997             } else if (preset.addTags[k2]) {
44998               newTags[k2] = preset.addTags[k2];
44999             }
45000             upgradeReasons.push({
45001               source: "id-tagging-schema--preset-addTags",
45002               data: preset
45003             });
45004           }
45005         });
45006       }
45007       const nsi = services.nsi;
45008       let waitingForNsi = false;
45009       let nsiResult;
45010       if (nsi) {
45011         waitingForNsi = nsi.status() === "loading";
45012         if (!waitingForNsi) {
45013           const loc = entity.extent(graph).center();
45014           nsiResult = nsi.upgradeTags(newTags, loc);
45015           if (nsiResult) {
45016             newTags = nsiResult.newTags;
45017             subtype = "noncanonical_brand";
45018             upgradeReasons.push({
45019               source: "name-suggestion-index",
45020               data: nsiResult
45021             });
45022           }
45023         }
45024       }
45025       let issues = [];
45026       issues.provisional = _waitingForDeprecated || waitingForNsi;
45027       const tagDiff = utilTagDiff(oldTags, newTags);
45028       if (!tagDiff.length) return issues;
45029       const isOnlyAddingTags = tagDiff.every((d2) => d2.type === "+");
45030       let prefix = "";
45031       if (nsiResult) {
45032         prefix = "noncanonical_brand.";
45033       } else if (subtype === "deprecated_tags" && isOnlyAddingTags) {
45034         subtype = "incomplete_tags";
45035         prefix = "incomplete.";
45036       }
45037       let autoArgs = subtype !== "noncanonical_brand" ? [doUpgrade, _t("issues.fix.upgrade_tags.annotation")] : null;
45038       issues.push(new validationIssue({
45039         type: type2,
45040         subtype,
45041         severity: "warning",
45042         message: showMessage,
45043         reference: showReference,
45044         entityIds: [entity.id],
45045         hash: utilHashcode(JSON.stringify(tagDiff)),
45046         dynamicFixes: () => {
45047           let fixes = [
45048             new validationIssueFix({
45049               autoArgs,
45050               title: _t.append("issues.fix.upgrade_tags.title"),
45051               onClick: (context) => {
45052                 context.perform(doUpgrade, _t("issues.fix.upgrade_tags.annotation"));
45053               }
45054             })
45055           ];
45056           const item = nsiResult && nsiResult.matched;
45057           if (item) {
45058             fixes.push(
45059               new validationIssueFix({
45060                 title: _t.append("issues.fix.tag_as_not.title", { name: item.displayName }),
45061                 onClick: (context) => {
45062                   context.perform(addNotTag, _t("issues.fix.tag_as_not.annotation"));
45063                 }
45064               })
45065             );
45066           }
45067           return fixes;
45068         }
45069       }));
45070       return issues;
45071       function doUpgrade(graph2) {
45072         const currEntity = graph2.hasEntity(entity.id);
45073         if (!currEntity) return graph2;
45074         let newTags2 = Object.assign({}, currEntity.tags);
45075         tagDiff.forEach((diff) => {
45076           if (diff.type === "-") {
45077             delete newTags2[diff.key];
45078           } else if (diff.type === "+") {
45079             newTags2[diff.key] = diff.newVal;
45080           }
45081         });
45082         return actionChangeTags(currEntity.id, newTags2)(graph2);
45083       }
45084       function addNotTag(graph2) {
45085         const currEntity = graph2.hasEntity(entity.id);
45086         if (!currEntity) return graph2;
45087         const item = nsiResult && nsiResult.matched;
45088         if (!item) return graph2;
45089         let newTags2 = Object.assign({}, currEntity.tags);
45090         const wd = item.mainTag;
45091         const notwd = "not:".concat(wd);
45092         const qid = item.tags[wd];
45093         newTags2[notwd] = qid;
45094         if (newTags2[wd] === qid) {
45095           const wp = item.mainTag.replace("wikidata", "wikipedia");
45096           delete newTags2[wd];
45097           delete newTags2[wp];
45098         }
45099         return actionChangeTags(currEntity.id, newTags2)(graph2);
45100       }
45101       function showMessage(context) {
45102         const currEntity = context.hasEntity(entity.id);
45103         if (!currEntity) return "";
45104         let messageID = "issues.outdated_tags.".concat(prefix, "message");
45105         if (subtype === "noncanonical_brand" && isOnlyAddingTags) {
45106           messageID += "_incomplete";
45107         }
45108         return _t.append(messageID, {
45109           feature: utilDisplayLabel(
45110             currEntity,
45111             context.graph(),
45112             true
45113             /* verbose */
45114           )
45115         });
45116       }
45117       function showReference(selection2) {
45118         let enter = selection2.selectAll(".issue-reference").data([0]).enter();
45119         enter.append("div").attr("class", "issue-reference").call(_t.append("issues.outdated_tags.".concat(prefix, "reference")));
45120         enter.append("strong").call(_t.append("issues.suggested"));
45121         enter.append("table").attr("class", "tagDiff-table").selectAll(".tagDiff-row").data(tagDiff).enter().append("tr").attr("class", "tagDiff-row").append("td").attr("class", (d2) => {
45122           let klass = d2.type === "+" ? "add" : "remove";
45123           return "tagDiff-cell tagDiff-cell-".concat(klass);
45124         }).html((d2) => d2.display);
45125       }
45126     }
45127     let validation = oldTagIssues;
45128     validation.type = type2;
45129     return validation;
45130   }
45131
45132   // modules/validations/private_data.js
45133   function validationPrivateData() {
45134     var type2 = "private_data";
45135     var privateBuildingValues = {
45136       detached: true,
45137       farm: true,
45138       house: true,
45139       houseboat: true,
45140       residential: true,
45141       semidetached_house: true,
45142       static_caravan: true
45143     };
45144     var publicKeys = {
45145       amenity: true,
45146       craft: true,
45147       historic: true,
45148       leisure: true,
45149       office: true,
45150       shop: true,
45151       tourism: true
45152     };
45153     var personalTags = {
45154       "contact:email": true,
45155       "contact:fax": true,
45156       "contact:phone": true,
45157       email: true,
45158       fax: true,
45159       phone: true
45160     };
45161     var validation = function checkPrivateData(entity) {
45162       var tags = entity.tags;
45163       if (!tags.building || !privateBuildingValues[tags.building]) return [];
45164       var keepTags = {};
45165       for (var k2 in tags) {
45166         if (publicKeys[k2]) return [];
45167         if (!personalTags[k2]) {
45168           keepTags[k2] = tags[k2];
45169         }
45170       }
45171       var tagDiff = utilTagDiff(tags, keepTags);
45172       if (!tagDiff.length) return [];
45173       var fixID = tagDiff.length === 1 ? "remove_tag" : "remove_tags";
45174       return [new validationIssue({
45175         type: type2,
45176         severity: "warning",
45177         message: showMessage,
45178         reference: showReference,
45179         entityIds: [entity.id],
45180         dynamicFixes: function() {
45181           return [
45182             new validationIssueFix({
45183               icon: "iD-operation-delete",
45184               title: _t.append("issues.fix." + fixID + ".title"),
45185               onClick: function(context) {
45186                 context.perform(doUpgrade, _t("issues.fix.remove_tag.annotation"));
45187               }
45188             })
45189           ];
45190         }
45191       })];
45192       function doUpgrade(graph) {
45193         var currEntity = graph.hasEntity(entity.id);
45194         if (!currEntity) return graph;
45195         var newTags = Object.assign({}, currEntity.tags);
45196         tagDiff.forEach(function(diff) {
45197           if (diff.type === "-") {
45198             delete newTags[diff.key];
45199           } else if (diff.type === "+") {
45200             newTags[diff.key] = diff.newVal;
45201           }
45202         });
45203         return actionChangeTags(currEntity.id, newTags)(graph);
45204       }
45205       function showMessage(context) {
45206         var currEntity = context.hasEntity(this.entityIds[0]);
45207         if (!currEntity) return "";
45208         return _t.append(
45209           "issues.private_data.contact.message",
45210           { feature: utilDisplayLabel(currEntity, context.graph()) }
45211         );
45212       }
45213       function showReference(selection2) {
45214         var enter = selection2.selectAll(".issue-reference").data([0]).enter();
45215         enter.append("div").attr("class", "issue-reference").call(_t.append("issues.private_data.reference"));
45216         enter.append("strong").call(_t.append("issues.suggested"));
45217         enter.append("table").attr("class", "tagDiff-table").selectAll(".tagDiff-row").data(tagDiff).enter().append("tr").attr("class", "tagDiff-row").append("td").attr("class", function(d2) {
45218           var klass = d2.type === "+" ? "add" : "remove";
45219           return "tagDiff-cell tagDiff-cell-" + klass;
45220         }).html(function(d2) {
45221           return d2.display;
45222         });
45223       }
45224     };
45225     validation.type = type2;
45226     return validation;
45227   }
45228
45229   // modules/validations/suspicious_name.js
45230   function validationSuspiciousName() {
45231     const type2 = "suspicious_name";
45232     const keysToTestForGenericValues = [
45233       "aerialway",
45234       "aeroway",
45235       "amenity",
45236       "building",
45237       "craft",
45238       "highway",
45239       "leisure",
45240       "railway",
45241       "man_made",
45242       "office",
45243       "shop",
45244       "tourism",
45245       "waterway"
45246     ];
45247     let _waitingForNsi = false;
45248     function isGenericMatchInNsi(tags) {
45249       const nsi = services.nsi;
45250       if (nsi) {
45251         _waitingForNsi = nsi.status() === "loading";
45252         if (!_waitingForNsi) {
45253           return nsi.isGenericName(tags);
45254         }
45255       }
45256       return false;
45257     }
45258     function nameMatchesRawTag(lowercaseName, tags) {
45259       for (let i3 = 0; i3 < keysToTestForGenericValues.length; i3++) {
45260         let key = keysToTestForGenericValues[i3];
45261         let val = tags[key];
45262         if (val) {
45263           val = val.toLowerCase();
45264           if (key === lowercaseName || val === lowercaseName || key.replace(/\_/g, " ") === lowercaseName || val.replace(/\_/g, " ") === lowercaseName) {
45265             return true;
45266           }
45267         }
45268       }
45269       return false;
45270     }
45271     function isGenericName(name, tags) {
45272       name = name.toLowerCase();
45273       return nameMatchesRawTag(name, tags) || isGenericMatchInNsi(tags);
45274     }
45275     function makeGenericNameIssue(entityId, nameKey, genericName, langCode) {
45276       return new validationIssue({
45277         type: type2,
45278         subtype: "generic_name",
45279         severity: "warning",
45280         message: function(context) {
45281           let entity = context.hasEntity(this.entityIds[0]);
45282           if (!entity) return "";
45283           let preset = _mainPresetIndex.match(entity, context.graph());
45284           let langName = langCode && _mainLocalizer.languageName(langCode);
45285           return _t.append(
45286             "issues.generic_name.message" + (langName ? "_language" : ""),
45287             { feature: preset.name(), name: genericName, language: langName }
45288           );
45289         },
45290         reference: showReference,
45291         entityIds: [entityId],
45292         hash: "".concat(nameKey, "=").concat(genericName),
45293         dynamicFixes: function() {
45294           return [
45295             new validationIssueFix({
45296               icon: "iD-operation-delete",
45297               title: _t.append("issues.fix.remove_the_name.title"),
45298               onClick: function(context) {
45299                 let entityId2 = this.issue.entityIds[0];
45300                 let entity = context.entity(entityId2);
45301                 let tags = Object.assign({}, entity.tags);
45302                 delete tags[nameKey];
45303                 context.perform(
45304                   actionChangeTags(entityId2, tags),
45305                   _t("issues.fix.remove_generic_name.annotation")
45306                 );
45307               }
45308             })
45309           ];
45310         }
45311       });
45312       function showReference(selection2) {
45313         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.generic_name.reference"));
45314       }
45315     }
45316     let validation = function checkGenericName(entity) {
45317       const tags = entity.tags;
45318       const hasWikidata = !!tags.wikidata || !!tags["brand:wikidata"] || !!tags["operator:wikidata"];
45319       if (hasWikidata) return [];
45320       let issues = [];
45321       for (let key in tags) {
45322         const m2 = key.match(/^name(?:(?::)([a-zA-Z_-]+))?$/);
45323         if (!m2) continue;
45324         const langCode = m2.length >= 2 ? m2[1] : null;
45325         const value = tags[key];
45326         if (isGenericName(value, tags)) {
45327           issues.provisional = _waitingForNsi;
45328           issues.push(makeGenericNameIssue(entity.id, key, value, langCode));
45329         }
45330       }
45331       return issues;
45332     };
45333     validation.type = type2;
45334     return validation;
45335   }
45336
45337   // modules/validations/unsquare_way.js
45338   function validationUnsquareWay(context) {
45339     var type2 = "unsquare_way";
45340     var DEFAULT_DEG_THRESHOLD = 5;
45341     var epsilon3 = 0.05;
45342     var nodeThreshold = 10;
45343     function isBuilding(entity, graph) {
45344       if (entity.type !== "way" || entity.geometry(graph) !== "area") return false;
45345       return entity.tags.building && entity.tags.building !== "no";
45346     }
45347     var validation = function checkUnsquareWay(entity, graph) {
45348       if (!isBuilding(entity, graph)) return [];
45349       if (entity.tags.nonsquare === "yes") return [];
45350       var isClosed = entity.isClosed();
45351       if (!isClosed) return [];
45352       var nodes = graph.childNodes(entity).slice();
45353       if (nodes.length > nodeThreshold + 1) return [];
45354       var osm = services.osm;
45355       if (!osm || nodes.some(function(node) {
45356         return !osm.isDataLoaded(node.loc);
45357       })) return [];
45358       var hasConnectedSquarableWays = nodes.some(function(node) {
45359         return graph.parentWays(node).some(function(way) {
45360           if (way.id === entity.id) return false;
45361           if (isBuilding(way, graph)) return true;
45362           return graph.parentRelations(way).some(function(parentRelation) {
45363             return parentRelation.isMultipolygon() && parentRelation.tags.building && parentRelation.tags.building !== "no";
45364           });
45365         });
45366       });
45367       if (hasConnectedSquarableWays) return [];
45368       var storedDegreeThreshold = corePreferences("validate-square-degrees");
45369       var degreeThreshold = isFinite(storedDegreeThreshold) ? Number(storedDegreeThreshold) : DEFAULT_DEG_THRESHOLD;
45370       var points = nodes.map(function(node) {
45371         return context.projection(node.loc);
45372       });
45373       if (!geoOrthoCanOrthogonalize(points, isClosed, epsilon3, degreeThreshold, true)) return [];
45374       var autoArgs;
45375       if (!entity.tags.wikidata) {
45376         var autoAction = actionOrthogonalize(entity.id, context.projection, void 0, degreeThreshold);
45377         autoAction.transitionable = false;
45378         autoArgs = [autoAction, _t("operations.orthogonalize.annotation.feature", { n: 1 })];
45379       }
45380       return [new validationIssue({
45381         type: type2,
45382         subtype: "building",
45383         severity: "warning",
45384         message: function(context2) {
45385           var entity2 = context2.hasEntity(this.entityIds[0]);
45386           return entity2 ? _t.append("issues.unsquare_way.message", {
45387             feature: utilDisplayLabel(entity2, context2.graph())
45388           }) : "";
45389         },
45390         reference: showReference,
45391         entityIds: [entity.id],
45392         hash: degreeThreshold,
45393         dynamicFixes: function() {
45394           return [
45395             new validationIssueFix({
45396               icon: "iD-operation-orthogonalize",
45397               title: _t.append("issues.fix.square_feature.title"),
45398               autoArgs,
45399               onClick: function(context2, completionHandler) {
45400                 var entityId = this.issue.entityIds[0];
45401                 context2.perform(
45402                   actionOrthogonalize(entityId, context2.projection, void 0, degreeThreshold),
45403                   _t("operations.orthogonalize.annotation.feature", { n: 1 })
45404                 );
45405                 window.setTimeout(function() {
45406                   completionHandler();
45407                 }, 175);
45408               }
45409             })
45410             /*
45411             new validationIssueFix({
45412                 title: t.append('issues.fix.tag_as_unsquare.title'),
45413                 onClick: function(context) {
45414                     var entityId = this.issue.entityIds[0];
45415                     var entity = context.entity(entityId);
45416                     var tags = Object.assign({}, entity.tags);  // shallow copy
45417                     tags.nonsquare = 'yes';
45418                     context.perform(
45419                         actionChangeTags(entityId, tags),
45420                         t('issues.fix.tag_as_unsquare.annotation')
45421                     );
45422                 }
45423             })
45424             */
45425           ];
45426         }
45427       })];
45428       function showReference(selection2) {
45429         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.unsquare_way.buildings.reference"));
45430       }
45431     };
45432     validation.type = type2;
45433     return validation;
45434   }
45435
45436   // modules/core/validator.js
45437   function coreValidator(context) {
45438     let dispatch14 = dispatch_default("validated", "focusedIssue");
45439     let validator = utilRebind({}, dispatch14, "on");
45440     let _rules = {};
45441     let _disabledRules = {};
45442     let _ignoredIssueIDs = /* @__PURE__ */ new Set();
45443     let _resolvedIssueIDs = /* @__PURE__ */ new Set();
45444     let _baseCache = validationCache("base");
45445     let _headCache = validationCache("head");
45446     let _completeDiff = {};
45447     let _headIsCurrent = false;
45448     let _deferredRIC = {};
45449     let _deferredST = /* @__PURE__ */ new Set();
45450     let _headPromise;
45451     const RETRY = 5e3;
45452     const _errorOverrides = parseHashParam(context.initialHashParams.validationError);
45453     const _warningOverrides = parseHashParam(context.initialHashParams.validationWarning);
45454     const _disableOverrides = parseHashParam(context.initialHashParams.validationDisable);
45455     function parseHashParam(param) {
45456       let result = [];
45457       let rules = (param || "").split(",");
45458       rules.forEach((rule) => {
45459         rule = rule.trim();
45460         const parts = rule.split("/", 2);
45461         const type2 = parts[0];
45462         const subtype = parts[1] || "*";
45463         if (!type2 || !subtype) return;
45464         result.push({ type: makeRegExp(type2), subtype: makeRegExp(subtype) });
45465       });
45466       return result;
45467       function makeRegExp(str) {
45468         const escaped = str.replace(/[-\/\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*");
45469         return new RegExp("^" + escaped + "$");
45470       }
45471     }
45472     validator.init = () => {
45473       Object.values(validations_exports).forEach((validation) => {
45474         if (typeof validation !== "function") return;
45475         const fn = validation(context);
45476         const key = fn.type;
45477         _rules[key] = fn;
45478       });
45479       let disabledRules = corePreferences("validate-disabledRules");
45480       if (disabledRules) {
45481         disabledRules.split(",").forEach((k2) => _disabledRules[k2] = true);
45482       }
45483     };
45484     function reset(resetIgnored) {
45485       _baseCache.queue = [];
45486       _headCache.queue = [];
45487       Object.keys(_deferredRIC).forEach((key) => {
45488         window.cancelIdleCallback(key);
45489         _deferredRIC[key]();
45490       });
45491       _deferredRIC = {};
45492       _deferredST.forEach(window.clearTimeout);
45493       _deferredST.clear();
45494       if (resetIgnored) _ignoredIssueIDs.clear();
45495       _resolvedIssueIDs.clear();
45496       _baseCache = validationCache("base");
45497       _headCache = validationCache("head");
45498       _completeDiff = {};
45499       _headIsCurrent = false;
45500     }
45501     validator.reset = () => {
45502       reset(true);
45503     };
45504     validator.resetIgnoredIssues = () => {
45505       _ignoredIssueIDs.clear();
45506       dispatch14.call("validated");
45507     };
45508     validator.revalidateUnsquare = () => {
45509       revalidateUnsquare(_headCache);
45510       revalidateUnsquare(_baseCache);
45511       dispatch14.call("validated");
45512     };
45513     function revalidateUnsquare(cache) {
45514       const checkUnsquareWay = _rules.unsquare_way;
45515       if (!cache.graph || typeof checkUnsquareWay !== "function") return;
45516       cache.uncacheIssuesOfType("unsquare_way");
45517       const buildings = context.history().tree().intersects(geoExtent([-180, -90], [180, 90]), cache.graph).filter((entity) => entity.type === "way" && entity.tags.building && entity.tags.building !== "no");
45518       buildings.forEach((entity) => {
45519         const detected = checkUnsquareWay(entity, cache.graph);
45520         if (!detected.length) return;
45521         cache.cacheIssues(detected);
45522       });
45523     }
45524     validator.getIssues = (options2) => {
45525       const opts = Object.assign({ what: "all", where: "all", includeIgnored: false, includeDisabledRules: false }, options2);
45526       const view = context.map().extent();
45527       let seen = /* @__PURE__ */ new Set();
45528       let results = [];
45529       if (_headCache.graph && _headCache.graph !== _baseCache.graph) {
45530         Object.values(_headCache.issuesByIssueID).forEach((issue) => {
45531           const userModified = (issue.entityIds || []).some((id2) => _completeDiff.hasOwnProperty(id2));
45532           if (opts.what === "edited" && !userModified) return;
45533           if (!filter2(issue)) return;
45534           seen.add(issue.id);
45535           results.push(issue);
45536         });
45537       }
45538       if (opts.what === "all") {
45539         Object.values(_baseCache.issuesByIssueID).forEach((issue) => {
45540           if (!filter2(issue)) return;
45541           seen.add(issue.id);
45542           results.push(issue);
45543         });
45544       }
45545       return results;
45546       function filter2(issue) {
45547         if (!issue) return false;
45548         if (seen.has(issue.id)) return false;
45549         if (_resolvedIssueIDs.has(issue.id)) return false;
45550         if (opts.includeDisabledRules === "only" && !_disabledRules[issue.type]) return false;
45551         if (!opts.includeDisabledRules && _disabledRules[issue.type]) return false;
45552         if (opts.includeIgnored === "only" && !_ignoredIssueIDs.has(issue.id)) return false;
45553         if (!opts.includeIgnored && _ignoredIssueIDs.has(issue.id)) return false;
45554         if ((issue.entityIds || []).some((id2) => !context.hasEntity(id2))) return false;
45555         if (opts.where === "visible") {
45556           const extent = issue.extent(context.graph());
45557           if (!view.intersects(extent)) return false;
45558         }
45559         return true;
45560       }
45561     };
45562     validator.getResolvedIssues = () => {
45563       return Array.from(_resolvedIssueIDs).map((issueID) => _baseCache.issuesByIssueID[issueID]).filter(Boolean);
45564     };
45565     validator.focusIssue = (issue) => {
45566       const graph = context.graph();
45567       let selectID;
45568       let focusCenter;
45569       const issueExtent = issue.extent(graph);
45570       if (issueExtent) {
45571         focusCenter = issueExtent.center();
45572       }
45573       if (issue.entityIds && issue.entityIds.length) {
45574         selectID = issue.entityIds[0];
45575         if (selectID && selectID.charAt(0) === "r") {
45576           const ids = utilEntityAndDeepMemberIDs([selectID], graph);
45577           let nodeID = ids.find((id2) => id2.charAt(0) === "n" && graph.hasEntity(id2));
45578           if (!nodeID) {
45579             const wayID = ids.find((id2) => id2.charAt(0) === "w" && graph.hasEntity(id2));
45580             if (wayID) {
45581               nodeID = graph.entity(wayID).first();
45582             }
45583           }
45584           if (nodeID) {
45585             focusCenter = graph.entity(nodeID).loc;
45586           }
45587         }
45588       }
45589       if (focusCenter) {
45590         const setZoom = Math.max(context.map().zoom(), 19);
45591         context.map().unobscuredCenterZoomEase(focusCenter, setZoom);
45592       }
45593       if (selectID) {
45594         window.setTimeout(() => {
45595           context.enter(modeSelect(context, [selectID]));
45596           dispatch14.call("focusedIssue", this, issue);
45597         }, 250);
45598       }
45599     };
45600     validator.getIssuesBySeverity = (options2) => {
45601       let groups = utilArrayGroupBy(validator.getIssues(options2), "severity");
45602       groups.error = groups.error || [];
45603       groups.warning = groups.warning || [];
45604       return groups;
45605     };
45606     validator.getSharedEntityIssues = (entityIDs, options2) => {
45607       const orderedIssueTypes = [
45608         // Show some issue types in a particular order:
45609         "missing_tag",
45610         "missing_role",
45611         // - missing data first
45612         "outdated_tags",
45613         "mismatched_geometry",
45614         // - identity issues
45615         "crossing_ways",
45616         "almost_junction",
45617         // - geometry issues where fixing them might solve connectivity issues
45618         "disconnected_way",
45619         "impossible_oneway"
45620         // - finally connectivity issues
45621       ];
45622       const allIssues = validator.getIssues(options2);
45623       const forEntityIDs = new Set(entityIDs);
45624       return allIssues.filter((issue) => (issue.entityIds || []).some((entityID) => forEntityIDs.has(entityID))).sort((issue1, issue2) => {
45625         if (issue1.type === issue2.type) {
45626           return issue1.id < issue2.id ? -1 : 1;
45627         }
45628         const index1 = orderedIssueTypes.indexOf(issue1.type);
45629         const index2 = orderedIssueTypes.indexOf(issue2.type);
45630         if (index1 !== -1 && index2 !== -1) {
45631           return index1 - index2;
45632         } else if (index1 === -1 && index2 === -1) {
45633           return issue1.type < issue2.type ? -1 : 1;
45634         } else {
45635           return index1 !== -1 ? -1 : 1;
45636         }
45637       });
45638     };
45639     validator.getEntityIssues = (entityID, options2) => {
45640       return validator.getSharedEntityIssues([entityID], options2);
45641     };
45642     validator.getRuleKeys = () => {
45643       return Object.keys(_rules);
45644     };
45645     validator.isRuleEnabled = (key) => {
45646       return !_disabledRules[key];
45647     };
45648     validator.toggleRule = (key) => {
45649       if (_disabledRules[key]) {
45650         delete _disabledRules[key];
45651       } else {
45652         _disabledRules[key] = true;
45653       }
45654       corePreferences("validate-disabledRules", Object.keys(_disabledRules).join(","));
45655       validator.validate();
45656     };
45657     validator.disableRules = (keys2) => {
45658       _disabledRules = {};
45659       keys2.forEach((k2) => _disabledRules[k2] = true);
45660       corePreferences("validate-disabledRules", Object.keys(_disabledRules).join(","));
45661       validator.validate();
45662     };
45663     validator.ignoreIssue = (issueID) => {
45664       _ignoredIssueIDs.add(issueID);
45665     };
45666     validator.validate = () => {
45667       const baseGraph = context.history().base();
45668       if (!_headCache.graph) _headCache.graph = baseGraph;
45669       if (!_baseCache.graph) _baseCache.graph = baseGraph;
45670       const prevGraph = _headCache.graph;
45671       const currGraph = context.graph();
45672       if (currGraph === prevGraph) {
45673         _headIsCurrent = true;
45674         dispatch14.call("validated");
45675         return Promise.resolve();
45676       }
45677       if (_headPromise) {
45678         _headIsCurrent = false;
45679         return _headPromise;
45680       }
45681       _headCache.graph = currGraph;
45682       _completeDiff = context.history().difference().complete();
45683       const incrementalDiff = coreDifference(prevGraph, currGraph);
45684       let entityIDs = Object.keys(incrementalDiff.complete());
45685       entityIDs = _headCache.withAllRelatedEntities(entityIDs);
45686       if (!entityIDs.size) {
45687         dispatch14.call("validated");
45688         return Promise.resolve();
45689       }
45690       _headPromise = validateEntitiesAsync(entityIDs, _headCache).then(() => updateResolvedIssues(entityIDs)).then(() => dispatch14.call("validated")).catch(() => {
45691       }).then(() => {
45692         _headPromise = null;
45693         if (!_headIsCurrent) {
45694           validator.validate();
45695         }
45696       });
45697       return _headPromise;
45698     };
45699     context.history().on("restore.validator", validator.validate).on("undone.validator", validator.validate).on("redone.validator", validator.validate).on("reset.validator", () => {
45700       reset(false);
45701       validator.validate();
45702     });
45703     context.on("exit.validator", validator.validate);
45704     context.history().on("merge.validator", (entities) => {
45705       if (!entities) return;
45706       const baseGraph = context.history().base();
45707       if (!_headCache.graph) _headCache.graph = baseGraph;
45708       if (!_baseCache.graph) _baseCache.graph = baseGraph;
45709       let entityIDs = entities.map((entity) => entity.id);
45710       entityIDs = _baseCache.withAllRelatedEntities(entityIDs);
45711       validateEntitiesAsync(entityIDs, _baseCache);
45712     });
45713     function validateEntity(entity, graph) {
45714       let result = { issues: [], provisional: false };
45715       Object.keys(_rules).forEach(runValidation);
45716       return result;
45717       function runValidation(key) {
45718         const fn = _rules[key];
45719         if (typeof fn !== "function") {
45720           console.error("no such validation rule = " + key);
45721           return;
45722         }
45723         let detected = fn(entity, graph);
45724         if (detected.provisional) {
45725           result.provisional = true;
45726         }
45727         detected = detected.filter(applySeverityOverrides);
45728         result.issues = result.issues.concat(detected);
45729         function applySeverityOverrides(issue) {
45730           const type2 = issue.type;
45731           const subtype = issue.subtype || "";
45732           let i3;
45733           for (i3 = 0; i3 < _errorOverrides.length; i3++) {
45734             if (_errorOverrides[i3].type.test(type2) && _errorOverrides[i3].subtype.test(subtype)) {
45735               issue.severity = "error";
45736               return true;
45737             }
45738           }
45739           for (i3 = 0; i3 < _warningOverrides.length; i3++) {
45740             if (_warningOverrides[i3].type.test(type2) && _warningOverrides[i3].subtype.test(subtype)) {
45741               issue.severity = "warning";
45742               return true;
45743             }
45744           }
45745           for (i3 = 0; i3 < _disableOverrides.length; i3++) {
45746             if (_disableOverrides[i3].type.test(type2) && _disableOverrides[i3].subtype.test(subtype)) {
45747               return false;
45748             }
45749           }
45750           return true;
45751         }
45752       }
45753     }
45754     function updateResolvedIssues(entityIDs) {
45755       entityIDs.forEach((entityID) => {
45756         const baseIssues = _baseCache.issuesByEntityID[entityID];
45757         if (!baseIssues) return;
45758         baseIssues.forEach((issueID) => {
45759           const issue = _baseCache.issuesByIssueID[issueID];
45760           const userModified = (issue.entityIds || []).some((id2) => _completeDiff.hasOwnProperty(id2));
45761           if (userModified && !_headCache.issuesByIssueID[issueID]) {
45762             _resolvedIssueIDs.add(issueID);
45763           } else {
45764             _resolvedIssueIDs.delete(issueID);
45765           }
45766         });
45767       });
45768     }
45769     function validateEntitiesAsync(entityIDs, cache) {
45770       const jobs = Array.from(entityIDs).map((entityID) => {
45771         if (cache.queuedEntityIDs.has(entityID)) return null;
45772         cache.queuedEntityIDs.add(entityID);
45773         cache.uncacheEntityID(entityID);
45774         return () => {
45775           cache.queuedEntityIDs.delete(entityID);
45776           const graph = cache.graph;
45777           if (!graph) return;
45778           const entity = graph.hasEntity(entityID);
45779           if (!entity) return;
45780           const result = validateEntity(entity, graph);
45781           if (result.provisional) {
45782             cache.provisionalEntityIDs.add(entityID);
45783           }
45784           cache.cacheIssues(result.issues);
45785         };
45786       }).filter(Boolean);
45787       cache.queue = cache.queue.concat(utilArrayChunk(jobs, 100));
45788       if (cache.queuePromise) return cache.queuePromise;
45789       cache.queuePromise = processQueue(cache).then(() => revalidateProvisionalEntities(cache)).catch(() => {
45790       }).finally(() => cache.queuePromise = null);
45791       return cache.queuePromise;
45792     }
45793     function revalidateProvisionalEntities(cache) {
45794       if (!cache.provisionalEntityIDs.size) return;
45795       const handle = window.setTimeout(() => {
45796         _deferredST.delete(handle);
45797         if (!cache.provisionalEntityIDs.size) return;
45798         validateEntitiesAsync(Array.from(cache.provisionalEntityIDs), cache);
45799       }, RETRY);
45800       _deferredST.add(handle);
45801     }
45802     function processQueue(cache) {
45803       if (!cache.queue.length) return Promise.resolve();
45804       const chunk = cache.queue.pop();
45805       return new Promise((resolvePromise, rejectPromise) => {
45806         const handle = window.requestIdleCallback(() => {
45807           delete _deferredRIC[handle];
45808           chunk.forEach((job) => job());
45809           resolvePromise();
45810         });
45811         _deferredRIC[handle] = rejectPromise;
45812       }).then(() => {
45813         if (cache.queue.length % 25 === 0) dispatch14.call("validated");
45814       }).then(() => processQueue(cache));
45815     }
45816     return validator;
45817   }
45818   function validationCache(which) {
45819     let cache = {
45820       which,
45821       graph: null,
45822       queue: [],
45823       queuePromise: null,
45824       queuedEntityIDs: /* @__PURE__ */ new Set(),
45825       provisionalEntityIDs: /* @__PURE__ */ new Set(),
45826       issuesByIssueID: {},
45827       // issue.id -> issue
45828       issuesByEntityID: {}
45829       // entity.id -> Set(issue.id)
45830     };
45831     cache.cacheIssue = (issue) => {
45832       (issue.entityIds || []).forEach((entityID) => {
45833         if (!cache.issuesByEntityID[entityID]) {
45834           cache.issuesByEntityID[entityID] = /* @__PURE__ */ new Set();
45835         }
45836         cache.issuesByEntityID[entityID].add(issue.id);
45837       });
45838       cache.issuesByIssueID[issue.id] = issue;
45839     };
45840     cache.uncacheIssue = (issue) => {
45841       (issue.entityIds || []).forEach((entityID) => {
45842         if (cache.issuesByEntityID[entityID]) {
45843           cache.issuesByEntityID[entityID].delete(issue.id);
45844         }
45845       });
45846       delete cache.issuesByIssueID[issue.id];
45847     };
45848     cache.cacheIssues = (issues) => {
45849       issues.forEach(cache.cacheIssue);
45850     };
45851     cache.uncacheIssues = (issues) => {
45852       issues.forEach(cache.uncacheIssue);
45853     };
45854     cache.uncacheIssuesOfType = (type2) => {
45855       const issuesOfType = Object.values(cache.issuesByIssueID).filter((issue) => issue.type === type2);
45856       cache.uncacheIssues(issuesOfType);
45857     };
45858     cache.uncacheEntityID = (entityID) => {
45859       const entityIssueIDs = cache.issuesByEntityID[entityID];
45860       if (entityIssueIDs) {
45861         entityIssueIDs.forEach((issueID) => {
45862           const issue = cache.issuesByIssueID[issueID];
45863           if (issue) {
45864             cache.uncacheIssue(issue);
45865           } else {
45866             delete cache.issuesByIssueID[issueID];
45867           }
45868         });
45869       }
45870       delete cache.issuesByEntityID[entityID];
45871       cache.provisionalEntityIDs.delete(entityID);
45872     };
45873     cache.withAllRelatedEntities = (entityIDs) => {
45874       let result = /* @__PURE__ */ new Set();
45875       (entityIDs || []).forEach((entityID) => {
45876         result.add(entityID);
45877         const entityIssueIDs = cache.issuesByEntityID[entityID];
45878         if (entityIssueIDs) {
45879           entityIssueIDs.forEach((issueID) => {
45880             const issue = cache.issuesByIssueID[issueID];
45881             if (issue) {
45882               (issue.entityIds || []).forEach((relatedID) => result.add(relatedID));
45883             } else {
45884               delete cache.issuesByIssueID[issueID];
45885             }
45886           });
45887         }
45888       });
45889       return result;
45890     };
45891     return cache;
45892   }
45893
45894   // modules/core/uploader.js
45895   function coreUploader(context) {
45896     var dispatch14 = dispatch_default(
45897       // Start and end events are dispatched exactly once each per legitimate outside call to `save`
45898       "saveStarted",
45899       // dispatched as soon as a call to `save` has been deemed legitimate
45900       "saveEnded",
45901       // dispatched after the result event has been dispatched
45902       "willAttemptUpload",
45903       // dispatched before the actual upload call occurs, if it will
45904       "progressChanged",
45905       // Each save results in one of these outcomes:
45906       "resultNoChanges",
45907       // upload wasn't attempted since there were no edits
45908       "resultErrors",
45909       // upload failed due to errors
45910       "resultConflicts",
45911       // upload failed due to data conflicts
45912       "resultSuccess"
45913       // upload completed without errors
45914     );
45915     var _isSaving = false;
45916     var _conflicts = [];
45917     var _errors = [];
45918     var _origChanges;
45919     var _discardTags = {};
45920     _mainFileFetcher.get("discarded").then(function(d2) {
45921       _discardTags = d2;
45922     }).catch(function() {
45923     });
45924     var uploader = utilRebind({}, dispatch14, "on");
45925     uploader.isSaving = function() {
45926       return _isSaving;
45927     };
45928     uploader.save = function(changeset, tryAgain, checkConflicts) {
45929       if (_isSaving && !tryAgain) {
45930         return;
45931       }
45932       var osm = context.connection();
45933       if (!osm) return;
45934       if (!osm.authenticated()) {
45935         osm.authenticate(function(err) {
45936           if (!err) {
45937             uploader.save(changeset, tryAgain, checkConflicts);
45938           }
45939         });
45940         return;
45941       }
45942       if (!_isSaving) {
45943         _isSaving = true;
45944         dispatch14.call("saveStarted", this);
45945       }
45946       var history = context.history();
45947       _conflicts = [];
45948       _errors = [];
45949       _origChanges = history.changes(actionDiscardTags(history.difference(), _discardTags));
45950       if (!tryAgain) {
45951         history.perform(actionNoop());
45952       }
45953       if (!checkConflicts) {
45954         upload(changeset);
45955       } else {
45956         performFullConflictCheck(changeset);
45957       }
45958     };
45959     function performFullConflictCheck(changeset) {
45960       var osm = context.connection();
45961       if (!osm) return;
45962       var history = context.history();
45963       var localGraph = context.graph();
45964       var remoteGraph = coreGraph(history.base(), true);
45965       var summary = history.difference().summary();
45966       var _toCheck = [];
45967       for (var i3 = 0; i3 < summary.length; i3++) {
45968         var item = summary[i3];
45969         if (item.changeType === "modified") {
45970           _toCheck.push(item.entity.id);
45971         }
45972       }
45973       var _toLoad = withChildNodes(_toCheck, localGraph);
45974       var _loaded = {};
45975       var _toLoadCount = 0;
45976       var _toLoadTotal = _toLoad.length;
45977       if (_toCheck.length) {
45978         dispatch14.call("progressChanged", this, _toLoadCount, _toLoadTotal);
45979         _toLoad.forEach(function(id2) {
45980           _loaded[id2] = false;
45981         });
45982         osm.loadMultiple(_toLoad, loaded);
45983       } else {
45984         upload(changeset);
45985       }
45986       return;
45987       function withChildNodes(ids, graph) {
45988         var s2 = new Set(ids);
45989         ids.forEach(function(id2) {
45990           var entity = graph.entity(id2);
45991           if (entity.type !== "way") return;
45992           graph.childNodes(entity).forEach(function(child) {
45993             if (child.version !== void 0) {
45994               s2.add(child.id);
45995             }
45996           });
45997         });
45998         return Array.from(s2);
45999       }
46000       function loaded(err, result) {
46001         if (_errors.length) return;
46002         if (err) {
46003           _errors.push({
46004             msg: err.message || err.responseText,
46005             details: [_t("save.status_code", { code: err.status })]
46006           });
46007           didResultInErrors();
46008         } else {
46009           var loadMore = [];
46010           result.data.forEach(function(entity) {
46011             remoteGraph.replace(entity);
46012             _loaded[entity.id] = true;
46013             _toLoad = _toLoad.filter(function(val) {
46014               return val !== entity.id;
46015             });
46016             if (!entity.visible) return;
46017             var i4, id2;
46018             if (entity.type === "way") {
46019               for (i4 = 0; i4 < entity.nodes.length; i4++) {
46020                 id2 = entity.nodes[i4];
46021                 if (_loaded[id2] === void 0) {
46022                   _loaded[id2] = false;
46023                   loadMore.push(id2);
46024                 }
46025               }
46026             } else if (entity.type === "relation" && entity.isMultipolygon()) {
46027               for (i4 = 0; i4 < entity.members.length; i4++) {
46028                 id2 = entity.members[i4].id;
46029                 if (_loaded[id2] === void 0) {
46030                   _loaded[id2] = false;
46031                   loadMore.push(id2);
46032                 }
46033               }
46034             }
46035           });
46036           _toLoadCount += result.data.length;
46037           _toLoadTotal += loadMore.length;
46038           dispatch14.call("progressChanged", this, _toLoadCount, _toLoadTotal);
46039           if (loadMore.length) {
46040             _toLoad.push.apply(_toLoad, loadMore);
46041             osm.loadMultiple(loadMore, loaded);
46042           }
46043           if (!_toLoad.length) {
46044             detectConflicts();
46045             upload(changeset);
46046           }
46047         }
46048       }
46049       function detectConflicts() {
46050         function choice(id2, text, action) {
46051           return {
46052             id: id2,
46053             text,
46054             action: function() {
46055               history.replace(action);
46056             }
46057           };
46058         }
46059         function formatUser(d2) {
46060           return '<a href="' + osm.userURL(d2) + '" target="_blank">' + escape_default(d2) + "</a>";
46061         }
46062         function entityName(entity) {
46063           return utilDisplayName(entity) || utilDisplayType(entity.id) + " " + entity.id;
46064         }
46065         function sameVersions(local, remote) {
46066           if (local.version !== remote.version) return false;
46067           if (local.type === "way") {
46068             var children2 = utilArrayUnion(local.nodes, remote.nodes);
46069             for (var i4 = 0; i4 < children2.length; i4++) {
46070               var a2 = localGraph.hasEntity(children2[i4]);
46071               var b2 = remoteGraph.hasEntity(children2[i4]);
46072               if (a2 && b2 && a2.version !== b2.version) return false;
46073             }
46074           }
46075           return true;
46076         }
46077         _toCheck.forEach(function(id2) {
46078           var local = localGraph.entity(id2);
46079           var remote = remoteGraph.entity(id2);
46080           if (sameVersions(local, remote)) return;
46081           var merge2 = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags, formatUser);
46082           history.replace(merge2);
46083           var mergeConflicts = merge2.conflicts();
46084           if (!mergeConflicts.length) return;
46085           var forceLocal = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags).withOption("force_local");
46086           var forceRemote = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags).withOption("force_remote");
46087           var keepMine = _t("save.conflict." + (remote.visible ? "keep_local" : "restore"));
46088           var keepTheirs = _t("save.conflict." + (remote.visible ? "keep_remote" : "delete"));
46089           _conflicts.push({
46090             id: id2,
46091             name: entityName(local),
46092             details: mergeConflicts,
46093             chosen: 1,
46094             choices: [
46095               choice(id2, keepMine, forceLocal),
46096               choice(id2, keepTheirs, forceRemote)
46097             ]
46098           });
46099         });
46100       }
46101     }
46102     function upload(changeset) {
46103       var osm = context.connection();
46104       if (!osm) {
46105         _errors.push({ msg: "No OSM Service" });
46106       }
46107       if (_conflicts.length) {
46108         didResultInConflicts(changeset);
46109       } else if (_errors.length) {
46110         didResultInErrors();
46111       } else {
46112         var history = context.history();
46113         var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
46114         if (changes.modified.length || changes.created.length || changes.deleted.length) {
46115           dispatch14.call("willAttemptUpload", this);
46116           osm.putChangeset(changeset, changes, uploadCallback);
46117         } else {
46118           didResultInNoChanges();
46119         }
46120       }
46121     }
46122     function uploadCallback(err, changeset) {
46123       if (err) {
46124         if (err.status === 409) {
46125           uploader.save(changeset, true, true);
46126         } else {
46127           _errors.push({
46128             msg: err.message || err.responseText,
46129             details: [_t("save.status_code", { code: err.status })]
46130           });
46131           didResultInErrors();
46132         }
46133       } else {
46134         didResultInSuccess(changeset);
46135       }
46136     }
46137     function didResultInNoChanges() {
46138       dispatch14.call("resultNoChanges", this);
46139       endSave();
46140       context.flush();
46141     }
46142     function didResultInErrors() {
46143       context.history().pop();
46144       dispatch14.call("resultErrors", this, _errors);
46145       endSave();
46146     }
46147     function didResultInConflicts(changeset) {
46148       _conflicts.sort(function(a2, b2) {
46149         return b2.id.localeCompare(a2.id);
46150       });
46151       dispatch14.call("resultConflicts", this, changeset, _conflicts, _origChanges);
46152       endSave();
46153     }
46154     function didResultInSuccess(changeset) {
46155       context.history().clearSaved();
46156       dispatch14.call("resultSuccess", this, changeset);
46157       window.setTimeout(function() {
46158         endSave();
46159         context.flush();
46160       }, 2500);
46161     }
46162     function endSave() {
46163       _isSaving = false;
46164       dispatch14.call("saveEnded", this);
46165     }
46166     uploader.cancelConflictResolution = function() {
46167       context.history().pop();
46168     };
46169     uploader.processResolvedConflicts = function(changeset) {
46170       var history = context.history();
46171       for (var i3 = 0; i3 < _conflicts.length; i3++) {
46172         if (_conflicts[i3].chosen === 1) {
46173           var entity = context.hasEntity(_conflicts[i3].id);
46174           if (entity && entity.type === "way") {
46175             var children2 = utilArrayUniq(entity.nodes);
46176             for (var j2 = 0; j2 < children2.length; j2++) {
46177               history.replace(actionRevert(children2[j2]));
46178             }
46179           }
46180           history.replace(actionRevert(_conflicts[i3].id));
46181         }
46182       }
46183       uploader.save(changeset, true, false);
46184     };
46185     uploader.reset = function() {
46186     };
46187     return uploader;
46188   }
46189
46190   // modules/modes/draw_area.js
46191   function modeDrawArea(context, wayID, startGraph, button) {
46192     var mode = {
46193       button,
46194       id: "draw-area"
46195     };
46196     var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawArea", function() {
46197       context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.areas"))();
46198     });
46199     mode.wayID = wayID;
46200     mode.enter = function() {
46201       context.install(behavior);
46202     };
46203     mode.exit = function() {
46204       context.uninstall(behavior);
46205     };
46206     mode.selectedIDs = function() {
46207       return [wayID];
46208     };
46209     mode.activeID = function() {
46210       return behavior && behavior.activeID() || [];
46211     };
46212     return mode;
46213   }
46214
46215   // modules/modes/add_area.js
46216   function modeAddArea(context, mode) {
46217     mode.id = "add-area";
46218     var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
46219     function defaultTags(loc) {
46220       var defaultTags2 = { area: "yes" };
46221       if (mode.preset) defaultTags2 = mode.preset.setTags(defaultTags2, "area", false, loc);
46222       return defaultTags2;
46223     }
46224     function actionClose(wayId) {
46225       return function(graph) {
46226         return graph.replace(graph.entity(wayId).close());
46227       };
46228     }
46229     function start2(loc) {
46230       var startGraph = context.graph();
46231       var node = osmNode({ loc });
46232       var way = osmWay({ tags: defaultTags(loc) });
46233       context.perform(
46234         actionAddEntity(node),
46235         actionAddEntity(way),
46236         actionAddVertex(way.id, node.id),
46237         actionClose(way.id)
46238       );
46239       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
46240     }
46241     function startFromWay(loc, edge) {
46242       var startGraph = context.graph();
46243       var node = osmNode({ loc });
46244       var way = osmWay({ tags: defaultTags(loc) });
46245       context.perform(
46246         actionAddEntity(node),
46247         actionAddEntity(way),
46248         actionAddVertex(way.id, node.id),
46249         actionClose(way.id),
46250         actionAddMidpoint({ loc, edge }, node)
46251       );
46252       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
46253     }
46254     function startFromNode(node) {
46255       var startGraph = context.graph();
46256       var way = osmWay({ tags: defaultTags(node.loc) });
46257       context.perform(
46258         actionAddEntity(way),
46259         actionAddVertex(way.id, node.id),
46260         actionClose(way.id)
46261       );
46262       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
46263     }
46264     mode.enter = function() {
46265       context.install(behavior);
46266     };
46267     mode.exit = function() {
46268       context.uninstall(behavior);
46269     };
46270     return mode;
46271   }
46272
46273   // modules/modes/add_line.js
46274   function modeAddLine(context, mode) {
46275     mode.id = "add-line";
46276     var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
46277     function defaultTags(loc) {
46278       var defaultTags2 = {};
46279       if (mode.preset) defaultTags2 = mode.preset.setTags(defaultTags2, "line", false, loc);
46280       return defaultTags2;
46281     }
46282     function start2(loc) {
46283       var startGraph = context.graph();
46284       var node = osmNode({ loc });
46285       var way = osmWay({ tags: defaultTags(loc) });
46286       context.perform(
46287         actionAddEntity(node),
46288         actionAddEntity(way),
46289         actionAddVertex(way.id, node.id)
46290       );
46291       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
46292     }
46293     function startFromWay(loc, edge) {
46294       var startGraph = context.graph();
46295       var node = osmNode({ loc });
46296       var way = osmWay({ tags: defaultTags(loc) });
46297       context.perform(
46298         actionAddEntity(node),
46299         actionAddEntity(way),
46300         actionAddVertex(way.id, node.id),
46301         actionAddMidpoint({ loc, edge }, node)
46302       );
46303       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
46304     }
46305     function startFromNode(node) {
46306       var startGraph = context.graph();
46307       var way = osmWay({ tags: defaultTags(node.loc) });
46308       context.perform(
46309         actionAddEntity(way),
46310         actionAddVertex(way.id, node.id)
46311       );
46312       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
46313     }
46314     mode.enter = function() {
46315       context.install(behavior);
46316     };
46317     mode.exit = function() {
46318       context.uninstall(behavior);
46319     };
46320     return mode;
46321   }
46322
46323   // modules/modes/add_point.js
46324   function modeAddPoint(context, mode) {
46325     mode.id = "add-point";
46326     var behavior = behaviorDraw(context).on("click", add).on("clickWay", addWay).on("clickNode", addNode).on("cancel", cancel).on("finish", cancel);
46327     function defaultTags(loc) {
46328       var defaultTags2 = {};
46329       if (mode.preset) defaultTags2 = mode.preset.setTags(defaultTags2, "point", false, loc);
46330       return defaultTags2;
46331     }
46332     function add(loc) {
46333       var node = osmNode({ loc, tags: defaultTags(loc) });
46334       context.perform(
46335         actionAddEntity(node),
46336         _t("operations.add.annotation.point")
46337       );
46338       enterSelectMode(node);
46339     }
46340     function addWay(loc, edge) {
46341       var node = osmNode({ tags: defaultTags(loc) });
46342       context.perform(
46343         actionAddMidpoint({ loc, edge }, node),
46344         _t("operations.add.annotation.vertex")
46345       );
46346       enterSelectMode(node);
46347     }
46348     function enterSelectMode(node) {
46349       context.enter(
46350         modeSelect(context, [node.id]).newFeature(true)
46351       );
46352     }
46353     function addNode(node) {
46354       const _defaultTags = defaultTags(node.loc);
46355       if (Object.keys(_defaultTags).length === 0) {
46356         enterSelectMode(node);
46357         return;
46358       }
46359       var tags = Object.assign({}, node.tags);
46360       for (var key in _defaultTags) {
46361         tags[key] = _defaultTags[key];
46362       }
46363       context.perform(
46364         actionChangeTags(node.id, tags),
46365         _t("operations.add.annotation.point")
46366       );
46367       enterSelectMode(node);
46368     }
46369     function cancel() {
46370       context.enter(modeBrowse(context));
46371     }
46372     mode.enter = function() {
46373       context.install(behavior);
46374     };
46375     mode.exit = function() {
46376       context.uninstall(behavior);
46377     };
46378     return mode;
46379   }
46380
46381   // modules/ui/note_comments.js
46382   function uiNoteComments() {
46383     var _note;
46384     function noteComments(selection2) {
46385       if (_note.isNew()) return;
46386       var comments = selection2.selectAll(".comments-container").data([0]);
46387       comments = comments.enter().append("div").attr("class", "comments-container").merge(comments);
46388       var commentEnter = comments.selectAll(".comment").data(_note.comments).enter().append("div").attr("class", "comment");
46389       commentEnter.append("div").attr("class", function(d2) {
46390         return "comment-avatar user-" + d2.uid;
46391       }).call(svgIcon("#iD-icon-avatar", "comment-avatar-icon"));
46392       var mainEnter = commentEnter.append("div").attr("class", "comment-main");
46393       var metadataEnter = mainEnter.append("div").attr("class", "comment-metadata");
46394       metadataEnter.append("div").attr("class", "comment-author").each(function(d2) {
46395         var selection3 = select_default2(this);
46396         var osm = services.osm;
46397         if (osm && d2.user) {
46398           selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d2.user)).attr("target", "_blank");
46399         }
46400         if (d2.user) {
46401           selection3.text(d2.user);
46402         } else {
46403           selection3.call(_t.append("note.anonymous"));
46404         }
46405       });
46406       metadataEnter.append("div").attr("class", "comment-date").html(function(d2) {
46407         return _t.html("note.status." + d2.action, { when: localeDateString2(d2.date) });
46408       });
46409       mainEnter.append("div").attr("class", "comment-text").html(function(d2) {
46410         return d2.html;
46411       }).selectAll("a").attr("rel", "noopener nofollow").attr("target", "_blank");
46412       comments.call(replaceAvatars);
46413     }
46414     function replaceAvatars(selection2) {
46415       var showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true";
46416       var osm = services.osm;
46417       if (showThirdPartyIcons !== "true" || !osm) return;
46418       var uids = {};
46419       _note.comments.forEach(function(d2) {
46420         if (d2.uid) uids[d2.uid] = true;
46421       });
46422       Object.keys(uids).forEach(function(uid) {
46423         osm.loadUser(uid, function(err, user) {
46424           if (!user || !user.image_url) return;
46425           selection2.selectAll(".comment-avatar.user-" + uid).html("").append("img").attr("class", "icon comment-avatar-icon").attr("src", user.image_url).attr("alt", user.display_name);
46426         });
46427       });
46428     }
46429     function localeDateString2(s2) {
46430       if (!s2) return null;
46431       var options2 = { day: "numeric", month: "short", year: "numeric" };
46432       s2 = s2.replace(/-/g, "/");
46433       var d2 = new Date(s2);
46434       if (isNaN(d2.getTime())) return null;
46435       return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
46436     }
46437     noteComments.note = function(val) {
46438       if (!arguments.length) return _note;
46439       _note = val;
46440       return noteComments;
46441     };
46442     return noteComments;
46443   }
46444
46445   // modules/ui/note_header.js
46446   function uiNoteHeader() {
46447     var _note;
46448     function noteHeader(selection2) {
46449       var header = selection2.selectAll(".note-header").data(
46450         _note ? [_note] : [],
46451         function(d2) {
46452           return d2.status + d2.id;
46453         }
46454       );
46455       header.exit().remove();
46456       var headerEnter = header.enter().append("div").attr("class", "note-header");
46457       var iconEnter = headerEnter.append("div").attr("class", function(d2) {
46458         return "note-header-icon " + d2.status;
46459       }).classed("new", function(d2) {
46460         return d2.id < 0;
46461       });
46462       iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-note", "note-fill"));
46463       iconEnter.each(function(d2) {
46464         var statusIcon;
46465         if (d2.id < 0) {
46466           statusIcon = "#iD-icon-plus";
46467         } else if (d2.status === "open") {
46468           statusIcon = "#iD-icon-close";
46469         } else {
46470           statusIcon = "#iD-icon-apply";
46471         }
46472         iconEnter.append("div").attr("class", "note-icon-annotation").attr("title", _t("icons.close")).call(svgIcon(statusIcon, "icon-annotation"));
46473       });
46474       headerEnter.append("div").attr("class", "note-header-label").html(function(d2) {
46475         if (_note.isNew()) {
46476           return _t.html("note.new");
46477         }
46478         return _t.html("note.note") + " " + d2.id + " " + (d2.status === "closed" ? _t.html("note.closed") : "");
46479       });
46480     }
46481     noteHeader.note = function(val) {
46482       if (!arguments.length) return _note;
46483       _note = val;
46484       return noteHeader;
46485     };
46486     return noteHeader;
46487   }
46488
46489   // modules/ui/note_report.js
46490   function uiNoteReport() {
46491     var _note;
46492     function noteReport(selection2) {
46493       var url;
46494       if (services.osm && _note instanceof osmNote && !_note.isNew()) {
46495         url = services.osm.noteReportURL(_note);
46496       }
46497       var link3 = selection2.selectAll(".note-report").data(url ? [url] : []);
46498       link3.exit().remove();
46499       var linkEnter = link3.enter().append("a").attr("class", "note-report").attr("target", "_blank").attr("href", function(d2) {
46500         return d2;
46501       }).call(svgIcon("#iD-icon-out-link", "inline"));
46502       linkEnter.append("span").call(_t.append("note.report"));
46503     }
46504     noteReport.note = function(val) {
46505       if (!arguments.length) return _note;
46506       _note = val;
46507       return noteReport;
46508     };
46509     return noteReport;
46510   }
46511
46512   // modules/ui/view_on_osm.js
46513   function uiViewOnOSM(context) {
46514     var _what;
46515     function viewOnOSM(selection2) {
46516       var url;
46517       if (_what instanceof osmEntity) {
46518         url = context.connection().entityURL(_what);
46519       } else if (_what instanceof osmNote) {
46520         url = context.connection().noteURL(_what);
46521       }
46522       var data = !_what || _what.isNew() ? [] : [_what];
46523       var link3 = selection2.selectAll(".view-on-osm").data(data, function(d2) {
46524         return d2.id;
46525       });
46526       link3.exit().remove();
46527       var linkEnter = link3.enter().append("a").attr("class", "view-on-osm").attr("target", "_blank").attr("href", url).call(svgIcon("#iD-icon-out-link", "inline"));
46528       linkEnter.append("span").call(_t.append("inspector.view_on_osm"));
46529     }
46530     viewOnOSM.what = function(_2) {
46531       if (!arguments.length) return _what;
46532       _what = _2;
46533       return viewOnOSM;
46534     };
46535     return viewOnOSM;
46536   }
46537
46538   // modules/ui/note_editor.js
46539   function uiNoteEditor(context) {
46540     var dispatch14 = dispatch_default("change");
46541     var noteComments = uiNoteComments(context);
46542     var noteHeader = uiNoteHeader();
46543     var _note;
46544     var _newNote;
46545     function noteEditor(selection2) {
46546       var header = selection2.selectAll(".header").data([0]);
46547       var headerEnter = header.enter().append("div").attr("class", "header fillL");
46548       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
46549         context.enter(modeBrowse(context));
46550       }).call(svgIcon("#iD-icon-close"));
46551       headerEnter.append("h2").call(_t.append("note.title"));
46552       var body = selection2.selectAll(".body").data([0]);
46553       body = body.enter().append("div").attr("class", "body").merge(body);
46554       var editor = body.selectAll(".note-editor").data([0]);
46555       editor.enter().append("div").attr("class", "modal-section note-editor").merge(editor).call(noteHeader.note(_note)).call(noteComments.note(_note)).call(noteSaveSection);
46556       var footer = selection2.selectAll(".footer").data([0]);
46557       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOSM(context).what(_note)).call(uiNoteReport(context).note(_note));
46558       var osm = services.osm;
46559       if (osm) {
46560         osm.on("change.note-save", function() {
46561           selection2.call(noteEditor);
46562         });
46563       }
46564     }
46565     function noteSaveSection(selection2) {
46566       var isSelected = _note && _note.id === context.selectedNoteID();
46567       var noteSave = selection2.selectAll(".note-save").data(isSelected ? [_note] : [], function(d2) {
46568         return d2.status + d2.id;
46569       });
46570       noteSave.exit().remove();
46571       var noteSaveEnter = noteSave.enter().append("div").attr("class", "note-save save-section cf");
46572       noteSaveEnter.append("h4").attr("class", ".note-save-header").text("").each(function() {
46573         if (_note.isNew()) {
46574           _t.append("note.newDescription")(select_default2(this));
46575         } else {
46576           _t.append("note.newComment")(select_default2(this));
46577         }
46578       });
46579       var commentTextarea = noteSaveEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("note.inputPlaceholder")).attr("maxlength", 1e3).property("value", function(d2) {
46580         return d2.newComment;
46581       }).call(utilNoAuto).on("keydown.note-input", keydown).on("input.note-input", changeInput).on("blur.note-input", changeInput);
46582       if (!commentTextarea.empty() && _newNote) {
46583         commentTextarea.node().focus();
46584       }
46585       noteSave = noteSaveEnter.merge(noteSave).call(userDetails).call(noteSaveButtons);
46586       function keydown(d3_event) {
46587         if (!(d3_event.keyCode === 13 && // ↩ Return
46588         d3_event.metaKey)) return;
46589         var osm = services.osm;
46590         if (!osm) return;
46591         var hasAuth = osm.authenticated();
46592         if (!hasAuth) return;
46593         if (!_note.newComment) return;
46594         d3_event.preventDefault();
46595         select_default2(this).on("keydown.note-input", null);
46596         window.setTimeout(function() {
46597           if (_note.isNew()) {
46598             noteSave.selectAll(".save-button").node().focus();
46599             clickSave(_note);
46600           } else {
46601             noteSave.selectAll(".comment-button").node().focus();
46602             clickComment(_note);
46603           }
46604         }, 10);
46605       }
46606       function changeInput() {
46607         var input = select_default2(this);
46608         var val = input.property("value").trim() || void 0;
46609         _note = _note.update({ newComment: val });
46610         var osm = services.osm;
46611         if (osm) {
46612           osm.replaceNote(_note);
46613         }
46614         noteSave.call(noteSaveButtons);
46615       }
46616     }
46617     function userDetails(selection2) {
46618       var detailSection = selection2.selectAll(".detail-section").data([0]);
46619       detailSection = detailSection.enter().append("div").attr("class", "detail-section").merge(detailSection);
46620       var osm = services.osm;
46621       if (!osm) return;
46622       var hasAuth = osm.authenticated();
46623       var authWarning = detailSection.selectAll(".auth-warning").data(hasAuth ? [] : [0]);
46624       authWarning.exit().transition().duration(200).style("opacity", 0).remove();
46625       var authEnter = authWarning.enter().insert("div", ".tag-reference-body").attr("class", "field-warning auth-warning").style("opacity", 0);
46626       authEnter.call(svgIcon("#iD-icon-alert", "inline"));
46627       authEnter.append("span").call(_t.append("note.login"));
46628       authEnter.append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append("login")).on("click.note-login", function(d3_event) {
46629         d3_event.preventDefault();
46630         osm.authenticate();
46631       });
46632       authEnter.transition().duration(200).style("opacity", 1);
46633       var prose = detailSection.selectAll(".note-save-prose").data(hasAuth ? [0] : []);
46634       prose.exit().remove();
46635       prose = prose.enter().append("p").attr("class", "note-save-prose").call(_t.append("note.upload_explanation")).merge(prose);
46636       osm.userDetails(function(err, user) {
46637         if (err) return;
46638         var userLink = select_default2(document.createElement("div"));
46639         if (user.image_url) {
46640           userLink.append("img").attr("src", user.image_url).attr("class", "icon pre-text user-icon");
46641         }
46642         userLink.append("a").attr("class", "user-info").text(user.display_name).attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
46643         prose.html(_t.html("note.upload_explanation_with_user", { user: { html: userLink.html() } }));
46644       });
46645     }
46646     function noteSaveButtons(selection2) {
46647       var osm = services.osm;
46648       var hasAuth = osm && osm.authenticated();
46649       var isSelected = _note && _note.id === context.selectedNoteID();
46650       var buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_note] : [], function(d2) {
46651         return d2.status + d2.id;
46652       });
46653       buttonSection.exit().remove();
46654       var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
46655       if (_note.isNew()) {
46656         buttonEnter.append("button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
46657         buttonEnter.append("button").attr("class", "button save-button action").call(_t.append("note.save"));
46658       } else {
46659         buttonEnter.append("button").attr("class", "button status-button action");
46660         buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("note.comment"));
46661       }
46662       buttonSection = buttonSection.merge(buttonEnter);
46663       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
46664       buttonSection.select(".save-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
46665       buttonSection.select(".status-button").attr("disabled", hasAuth ? null : true).each(function(d2) {
46666         var action = d2.status === "open" ? "close" : "open";
46667         var andComment = d2.newComment ? "_comment" : "";
46668         _t.addOrUpdate("note." + action + andComment)(select_default2(this));
46669       }).on("click.status", clickStatus);
46670       buttonSection.select(".comment-button").attr("disabled", isSaveDisabled).on("click.comment", clickComment);
46671       function isSaveDisabled(d2) {
46672         return hasAuth && d2.status === "open" && d2.newComment ? null : true;
46673       }
46674     }
46675     function clickCancel(d3_event, d2) {
46676       this.blur();
46677       var osm = services.osm;
46678       if (osm) {
46679         osm.removeNote(d2);
46680       }
46681       context.enter(modeBrowse(context));
46682       dispatch14.call("change");
46683     }
46684     function clickSave(d3_event, d2) {
46685       this.blur();
46686       var osm = services.osm;
46687       if (osm) {
46688         osm.postNoteCreate(d2, function(err, note) {
46689           dispatch14.call("change", note);
46690         });
46691       }
46692     }
46693     function clickStatus(d3_event, d2) {
46694       this.blur();
46695       var osm = services.osm;
46696       if (osm) {
46697         var setStatus = d2.status === "open" ? "closed" : "open";
46698         osm.postNoteUpdate(d2, setStatus, function(err, note) {
46699           dispatch14.call("change", note);
46700         });
46701       }
46702     }
46703     function clickComment(d3_event, d2) {
46704       this.blur();
46705       var osm = services.osm;
46706       if (osm) {
46707         osm.postNoteUpdate(d2, d2.status, function(err, note) {
46708           dispatch14.call("change", note);
46709         });
46710       }
46711     }
46712     noteEditor.note = function(val) {
46713       if (!arguments.length) return _note;
46714       _note = val;
46715       return noteEditor;
46716     };
46717     noteEditor.newNote = function(val) {
46718       if (!arguments.length) return _newNote;
46719       _newNote = val;
46720       return noteEditor;
46721     };
46722     return utilRebind(noteEditor, dispatch14, "on");
46723   }
46724
46725   // modules/modes/select_note.js
46726   function modeSelectNote(context, selectedNoteID) {
46727     var mode = {
46728       id: "select-note",
46729       button: "browse"
46730     };
46731     var _keybinding = utilKeybinding("select-note");
46732     var _noteEditor = uiNoteEditor(context).on("change", function() {
46733       context.map().pan([0, 0]);
46734       var note = checkSelectedID();
46735       if (!note) return;
46736       context.ui().sidebar.show(_noteEditor.note(note));
46737     });
46738     var _behaviors = [
46739       behaviorBreathe(context),
46740       behaviorHover(context),
46741       behaviorSelect(context),
46742       behaviorLasso(context),
46743       modeDragNode(context).behavior,
46744       modeDragNote(context).behavior
46745     ];
46746     var _newFeature = false;
46747     function checkSelectedID() {
46748       if (!services.osm) return;
46749       var note = services.osm.getNote(selectedNoteID);
46750       if (!note) {
46751         context.enter(modeBrowse(context));
46752       }
46753       return note;
46754     }
46755     function selectNote(d3_event, drawn) {
46756       if (!checkSelectedID()) return;
46757       var selection2 = context.surface().selectAll(".layer-notes .note-" + selectedNoteID);
46758       if (selection2.empty()) {
46759         var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
46760         if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
46761           context.enter(modeBrowse(context));
46762         }
46763       } else {
46764         selection2.classed("selected", true);
46765         context.selectedNoteID(selectedNoteID);
46766       }
46767     }
46768     function esc() {
46769       if (context.container().select(".combobox").size()) return;
46770       context.enter(modeBrowse(context));
46771     }
46772     mode.zoomToSelected = function() {
46773       if (!services.osm) return;
46774       var note = services.osm.getNote(selectedNoteID);
46775       if (note) {
46776         context.map().centerZoomEase(note.loc, 20);
46777       }
46778     };
46779     mode.newFeature = function(val) {
46780       if (!arguments.length) return _newFeature;
46781       _newFeature = val;
46782       return mode;
46783     };
46784     mode.enter = function() {
46785       var note = checkSelectedID();
46786       if (!note) return;
46787       _behaviors.forEach(context.install);
46788       _keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
46789       select_default2(document).call(_keybinding);
46790       selectNote();
46791       var sidebar = context.ui().sidebar;
46792       sidebar.show(_noteEditor.note(note).newNote(_newFeature));
46793       sidebar.expand(sidebar.intersects(note.extent()));
46794       context.map().on("drawn.select", selectNote);
46795     };
46796     mode.exit = function() {
46797       _behaviors.forEach(context.uninstall);
46798       select_default2(document).call(_keybinding.unbind);
46799       context.surface().selectAll(".layer-notes .selected").classed("selected hover", false);
46800       context.map().on("drawn.select", null);
46801       context.ui().sidebar.hide();
46802       context.selectedNoteID(null);
46803     };
46804     return mode;
46805   }
46806
46807   // modules/modes/add_note.js
46808   function modeAddNote(context) {
46809     var mode = {
46810       id: "add-note",
46811       button: "note",
46812       description: _t.append("modes.add_note.description"),
46813       key: _t("modes.add_note.key")
46814     };
46815     var behavior = behaviorDraw(context).on("click", add).on("cancel", cancel).on("finish", cancel);
46816     function add(loc) {
46817       var osm = services.osm;
46818       if (!osm) return;
46819       var note = osmNote({ loc, status: "open", comments: [] });
46820       osm.replaceNote(note);
46821       context.map().pan([0, 0]);
46822       context.selectedNoteID(note.id).enter(modeSelectNote(context, note.id).newFeature(true));
46823     }
46824     function cancel() {
46825       context.enter(modeBrowse(context));
46826     }
46827     mode.enter = function() {
46828       context.install(behavior);
46829     };
46830     mode.exit = function() {
46831       context.uninstall(behavior);
46832     };
46833     return mode;
46834   }
46835
46836   // modules/util/jxon.js
46837   var JXON = new function() {
46838     var sValueProp = "keyValue", sAttributesProp = "keyAttributes", sAttrPref = "@", aCache = [], rIsNull = /^\s*$/, rIsBool = /^(?:true|false)$/i;
46839     function parseText(sValue) {
46840       if (rIsNull.test(sValue)) {
46841         return null;
46842       }
46843       if (rIsBool.test(sValue)) {
46844         return sValue.toLowerCase() === "true";
46845       }
46846       if (isFinite(sValue)) {
46847         return parseFloat(sValue);
46848       }
46849       if (isFinite(Date.parse(sValue))) {
46850         return new Date(sValue);
46851       }
46852       return sValue;
46853     }
46854     function EmptyTree() {
46855     }
46856     EmptyTree.prototype.toString = function() {
46857       return "null";
46858     };
46859     EmptyTree.prototype.valueOf = function() {
46860       return null;
46861     };
46862     function objectify(vValue) {
46863       return vValue === null ? new EmptyTree() : vValue instanceof Object ? vValue : new vValue.constructor(vValue);
46864     }
46865     function createObjTree(oParentNode, nVerb, bFreeze, bNesteAttr) {
46866       var nLevelStart = aCache.length, bChildren = oParentNode.hasChildNodes(), bAttributes = oParentNode.hasAttributes(), bHighVerb = Boolean(nVerb & 2);
46867       var sProp, vContent, nLength = 0, sCollectedTxt = "", vResult = bHighVerb ? {} : (
46868         /* put here the default value for empty nodes: */
46869         true
46870       );
46871       if (bChildren) {
46872         for (var oNode, nItem = 0; nItem < oParentNode.childNodes.length; nItem++) {
46873           oNode = oParentNode.childNodes.item(nItem);
46874           if (oNode.nodeType === 4) {
46875             sCollectedTxt += oNode.nodeValue;
46876           } else if (oNode.nodeType === 3) {
46877             sCollectedTxt += oNode.nodeValue.trim();
46878           } else if (oNode.nodeType === 1 && !oNode.prefix) {
46879             aCache.push(oNode);
46880           }
46881         }
46882       }
46883       var nLevelEnd = aCache.length, vBuiltVal = parseText(sCollectedTxt);
46884       if (!bHighVerb && (bChildren || bAttributes)) {
46885         vResult = nVerb === 0 ? objectify(vBuiltVal) : {};
46886       }
46887       for (var nElId = nLevelStart; nElId < nLevelEnd; nElId++) {
46888         sProp = aCache[nElId].nodeName.toLowerCase();
46889         vContent = createObjTree(aCache[nElId], nVerb, bFreeze, bNesteAttr);
46890         if (vResult.hasOwnProperty(sProp)) {
46891           if (vResult[sProp].constructor !== Array) {
46892             vResult[sProp] = [vResult[sProp]];
46893           }
46894           vResult[sProp].push(vContent);
46895         } else {
46896           vResult[sProp] = vContent;
46897           nLength++;
46898         }
46899       }
46900       if (bAttributes) {
46901         var nAttrLen = oParentNode.attributes.length, sAPrefix = bNesteAttr ? "" : sAttrPref, oAttrParent = bNesteAttr ? {} : vResult;
46902         for (var oAttrib, nAttrib = 0; nAttrib < nAttrLen; nLength++, nAttrib++) {
46903           oAttrib = oParentNode.attributes.item(nAttrib);
46904           oAttrParent[sAPrefix + oAttrib.name.toLowerCase()] = parseText(oAttrib.value.trim());
46905         }
46906         if (bNesteAttr) {
46907           if (bFreeze) {
46908             Object.freeze(oAttrParent);
46909           }
46910           vResult[sAttributesProp] = oAttrParent;
46911           nLength -= nAttrLen - 1;
46912         }
46913       }
46914       if (nVerb === 3 || (nVerb === 2 || nVerb === 1 && nLength > 0) && sCollectedTxt) {
46915         vResult[sValueProp] = vBuiltVal;
46916       } else if (!bHighVerb && nLength === 0 && sCollectedTxt) {
46917         vResult = vBuiltVal;
46918       }
46919       if (bFreeze && (bHighVerb || nLength > 0)) {
46920         Object.freeze(vResult);
46921       }
46922       aCache.length = nLevelStart;
46923       return vResult;
46924     }
46925     function loadObjTree(oXMLDoc, oParentEl, oParentObj) {
46926       var vValue, oChild;
46927       if (oParentObj instanceof String || oParentObj instanceof Number || oParentObj instanceof Boolean) {
46928         oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toString()));
46929       } else if (oParentObj.constructor === Date) {
46930         oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toGMTString()));
46931       }
46932       for (var sName in oParentObj) {
46933         vValue = oParentObj[sName];
46934         if (isFinite(sName) || vValue instanceof Function) {
46935           continue;
46936         }
46937         if (sName === sValueProp) {
46938           if (vValue !== null && vValue !== true) {
46939             oParentEl.appendChild(oXMLDoc.createTextNode(vValue.constructor === Date ? vValue.toGMTString() : String(vValue)));
46940           }
46941         } else if (sName === sAttributesProp) {
46942           for (var sAttrib in vValue) {
46943             oParentEl.setAttribute(sAttrib, vValue[sAttrib]);
46944           }
46945         } else if (sName.charAt(0) === sAttrPref) {
46946           oParentEl.setAttribute(sName.slice(1), vValue);
46947         } else if (vValue.constructor === Array) {
46948           for (var nItem = 0; nItem < vValue.length; nItem++) {
46949             oChild = oXMLDoc.createElement(sName);
46950             loadObjTree(oXMLDoc, oChild, vValue[nItem]);
46951             oParentEl.appendChild(oChild);
46952           }
46953         } else {
46954           oChild = oXMLDoc.createElement(sName);
46955           if (vValue instanceof Object) {
46956             loadObjTree(oXMLDoc, oChild, vValue);
46957           } else if (vValue !== null && vValue !== true) {
46958             oChild.appendChild(oXMLDoc.createTextNode(vValue.toString()));
46959           }
46960           oParentEl.appendChild(oChild);
46961         }
46962       }
46963     }
46964     this.build = function(oXMLParent, nVerbosity, bFreeze, bNesteAttributes) {
46965       var _nVerb = arguments.length > 1 && typeof nVerbosity === "number" ? nVerbosity & 3 : (
46966         /* put here the default verbosity level: */
46967         1
46968       );
46969       return createObjTree(oXMLParent, _nVerb, bFreeze || false, arguments.length > 3 ? bNesteAttributes : _nVerb === 3);
46970     };
46971     this.unbuild = function(oObjTree) {
46972       var oNewDoc = document.implementation.createDocument("", "", null);
46973       loadObjTree(oNewDoc, oNewDoc, oObjTree);
46974       return oNewDoc;
46975     };
46976     this.stringify = function(oObjTree) {
46977       return new XMLSerializer().serializeToString(JXON.unbuild(oObjTree));
46978     };
46979   }();
46980
46981   // modules/ui/conflicts.js
46982   function uiConflicts(context) {
46983     var dispatch14 = dispatch_default("cancel", "save");
46984     var keybinding = utilKeybinding("conflicts");
46985     var _origChanges;
46986     var _conflictList;
46987     var _shownConflictIndex;
46988     function keybindingOn() {
46989       select_default2(document).call(keybinding.on("\u238B", cancel, true));
46990     }
46991     function keybindingOff() {
46992       select_default2(document).call(keybinding.unbind);
46993     }
46994     function tryAgain() {
46995       keybindingOff();
46996       dispatch14.call("save");
46997     }
46998     function cancel() {
46999       keybindingOff();
47000       dispatch14.call("cancel");
47001     }
47002     function conflicts(selection2) {
47003       keybindingOn();
47004       var headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
47005       headerEnter.append("button").attr("class", "fr").attr("title", _t("icons.close")).on("click", cancel).call(svgIcon("#iD-icon-close"));
47006       headerEnter.append("h2").call(_t.append("save.conflict.header"));
47007       var bodyEnter = selection2.selectAll(".body").data([0]).enter().append("div").attr("class", "body fillL");
47008       var conflictsHelpEnter = bodyEnter.append("div").attr("class", "conflicts-help").call(_t.append("save.conflict.help"));
47009       var changeset = new osmChangeset();
47010       delete changeset.id;
47011       var data = JXON.stringify(changeset.osmChangeJXON(_origChanges));
47012       var blob = new Blob([data], { type: "text/xml;charset=utf-8;" });
47013       var fileName = "changes.osc";
47014       var linkEnter = conflictsHelpEnter.selectAll(".download-changes").append("a").attr("class", "download-changes");
47015       linkEnter.attr("href", window.URL.createObjectURL(blob)).attr("download", fileName);
47016       linkEnter.call(svgIcon("#iD-icon-load", "inline")).append("span").call(_t.append("save.conflict.download_changes"));
47017       bodyEnter.append("div").attr("class", "conflict-container fillL3").call(showConflict, 0);
47018       bodyEnter.append("div").attr("class", "conflicts-done").attr("opacity", 0).style("display", "none").call(_t.append("save.conflict.done"));
47019       var buttonsEnter = bodyEnter.append("div").attr("class", "buttons col12 joined conflicts-buttons");
47020       buttonsEnter.append("button").attr("disabled", _conflictList.length > 1).attr("class", "action conflicts-button col6").call(_t.append("save.title")).on("click.try_again", tryAgain);
47021       buttonsEnter.append("button").attr("class", "secondary-action conflicts-button col6").call(_t.append("confirm.cancel")).on("click.cancel", cancel);
47022     }
47023     function showConflict(selection2, index) {
47024       index = utilWrap(index, _conflictList.length);
47025       _shownConflictIndex = index;
47026       var parent = select_default2(selection2.node().parentNode);
47027       if (index === _conflictList.length - 1) {
47028         window.setTimeout(function() {
47029           parent.select(".conflicts-button").attr("disabled", null);
47030           parent.select(".conflicts-done").transition().attr("opacity", 1).style("display", "block");
47031         }, 250);
47032       }
47033       var conflict = selection2.selectAll(".conflict").data([_conflictList[index]]);
47034       conflict.exit().remove();
47035       var conflictEnter = conflict.enter().append("div").attr("class", "conflict");
47036       conflictEnter.append("h4").attr("class", "conflict-count").call(_t.append("save.conflict.count", { num: index + 1, total: _conflictList.length }));
47037       conflictEnter.append("a").attr("class", "conflict-description").attr("href", "#").text(function(d2) {
47038         return d2.name;
47039       }).on("click", function(d3_event, d2) {
47040         d3_event.preventDefault();
47041         zoomToEntity(d2.id);
47042       });
47043       var details = conflictEnter.append("div").attr("class", "conflict-detail-container");
47044       details.append("ul").attr("class", "conflict-detail-list").selectAll("li").data(function(d2) {
47045         return d2.details || [];
47046       }).enter().append("li").attr("class", "conflict-detail-item").html(function(d2) {
47047         return d2;
47048       });
47049       details.append("div").attr("class", "conflict-choices").call(addChoices);
47050       details.append("div").attr("class", "conflict-nav-buttons joined cf").selectAll("button").data(["previous", "next"]).enter().append("button").attr("class", "conflict-nav-button action col6").attr("disabled", function(d2, i3) {
47051         return i3 === 0 && index === 0 || i3 === 1 && index === _conflictList.length - 1 || null;
47052       }).on("click", function(d3_event, d2) {
47053         d3_event.preventDefault();
47054         var container = parent.selectAll(".conflict-container");
47055         var sign2 = d2 === "previous" ? -1 : 1;
47056         container.selectAll(".conflict").remove();
47057         container.call(showConflict, index + sign2);
47058       }).each(function(d2) {
47059         _t.append("save.conflict." + d2)(select_default2(this));
47060       });
47061     }
47062     function addChoices(selection2) {
47063       var choices = selection2.append("ul").attr("class", "layer-list").selectAll("li").data(function(d2) {
47064         return d2.choices || [];
47065       });
47066       var choicesEnter = choices.enter().append("li").attr("class", "layer");
47067       var labelEnter = choicesEnter.append("label");
47068       labelEnter.append("input").attr("type", "radio").attr("name", function(d2) {
47069         return d2.id;
47070       }).on("change", function(d3_event, d2) {
47071         var ul = this.parentNode.parentNode.parentNode;
47072         ul.__data__.chosen = d2.id;
47073         choose(d3_event, ul, d2);
47074       });
47075       labelEnter.append("span").text(function(d2) {
47076         return d2.text;
47077       });
47078       choicesEnter.merge(choices).each(function(d2) {
47079         var ul = this.parentNode;
47080         if (ul.__data__.chosen === d2.id) {
47081           choose(null, ul, d2);
47082         }
47083       });
47084     }
47085     function choose(d3_event, ul, datum2) {
47086       if (d3_event) d3_event.preventDefault();
47087       select_default2(ul).selectAll("li").classed("active", function(d2) {
47088         return d2 === datum2;
47089       }).selectAll("input").property("checked", function(d2) {
47090         return d2 === datum2;
47091       });
47092       var extent = geoExtent();
47093       var entity;
47094       entity = context.graph().hasEntity(datum2.id);
47095       if (entity) extent._extend(entity.extent(context.graph()));
47096       datum2.action();
47097       entity = context.graph().hasEntity(datum2.id);
47098       if (entity) extent._extend(entity.extent(context.graph()));
47099       zoomToEntity(datum2.id, extent);
47100     }
47101     function zoomToEntity(id2, extent) {
47102       context.surface().selectAll(".hover").classed("hover", false);
47103       var entity = context.graph().hasEntity(id2);
47104       if (entity) {
47105         if (extent) {
47106           context.map().trimmedExtent(extent);
47107         } else {
47108           context.map().zoomToEase(entity);
47109         }
47110         context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())).classed("hover", true);
47111       }
47112     }
47113     conflicts.conflictList = function(_2) {
47114       if (!arguments.length) return _conflictList;
47115       _conflictList = _2;
47116       return conflicts;
47117     };
47118     conflicts.origChanges = function(_2) {
47119       if (!arguments.length) return _origChanges;
47120       _origChanges = _2;
47121       return conflicts;
47122     };
47123     conflicts.shownEntityIds = function() {
47124       if (_conflictList && typeof _shownConflictIndex === "number") {
47125         return [_conflictList[_shownConflictIndex].id];
47126       }
47127       return [];
47128     };
47129     return utilRebind(conflicts, dispatch14, "on");
47130   }
47131
47132   // modules/ui/confirm.js
47133   function uiConfirm(selection2) {
47134     var modalSelection = uiModal(selection2);
47135     modalSelection.select(".modal").classed("modal-alert", true);
47136     var section = modalSelection.select(".content");
47137     section.append("div").attr("class", "modal-section header");
47138     section.append("div").attr("class", "modal-section message-text");
47139     var buttons = section.append("div").attr("class", "modal-section buttons cf");
47140     modalSelection.okButton = function() {
47141       buttons.append("button").attr("class", "button ok-button action").on("click.confirm", function() {
47142         modalSelection.remove();
47143       }).call(_t.append("confirm.okay")).node().focus();
47144       return modalSelection;
47145     };
47146     return modalSelection;
47147   }
47148
47149   // modules/ui/commit.js
47150   var import_fast_deep_equal10 = __toESM(require_fast_deep_equal());
47151
47152   // modules/ui/popover.js
47153   var _popoverID = 0;
47154   function uiPopover(klass) {
47155     var _id = _popoverID++;
47156     var _anchorSelection = select_default2(null);
47157     var popover = function(selection2) {
47158       _anchorSelection = selection2;
47159       selection2.each(setup);
47160     };
47161     var _animation = utilFunctor(false);
47162     var _placement = utilFunctor("top");
47163     var _alignment = utilFunctor("center");
47164     var _scrollContainer = utilFunctor(select_default2(null));
47165     var _content;
47166     var _displayType = utilFunctor("");
47167     var _hasArrow = utilFunctor(true);
47168     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
47169     popover.displayType = function(val) {
47170       if (arguments.length) {
47171         _displayType = utilFunctor(val);
47172         return popover;
47173       } else {
47174         return _displayType;
47175       }
47176     };
47177     popover.hasArrow = function(val) {
47178       if (arguments.length) {
47179         _hasArrow = utilFunctor(val);
47180         return popover;
47181       } else {
47182         return _hasArrow;
47183       }
47184     };
47185     popover.placement = function(val) {
47186       if (arguments.length) {
47187         _placement = utilFunctor(val);
47188         return popover;
47189       } else {
47190         return _placement;
47191       }
47192     };
47193     popover.alignment = function(val) {
47194       if (arguments.length) {
47195         _alignment = utilFunctor(val);
47196         return popover;
47197       } else {
47198         return _alignment;
47199       }
47200     };
47201     popover.scrollContainer = function(val) {
47202       if (arguments.length) {
47203         _scrollContainer = utilFunctor(val);
47204         return popover;
47205       } else {
47206         return _scrollContainer;
47207       }
47208     };
47209     popover.content = function(val) {
47210       if (arguments.length) {
47211         _content = val;
47212         return popover;
47213       } else {
47214         return _content;
47215       }
47216     };
47217     popover.isShown = function() {
47218       var popoverSelection = _anchorSelection.select(".popover-" + _id);
47219       return !popoverSelection.empty() && popoverSelection.classed("in");
47220     };
47221     popover.show = function() {
47222       _anchorSelection.each(show);
47223     };
47224     popover.updateContent = function() {
47225       _anchorSelection.each(updateContent);
47226     };
47227     popover.hide = function() {
47228       _anchorSelection.each(hide);
47229     };
47230     popover.toggle = function() {
47231       _anchorSelection.each(toggle);
47232     };
47233     popover.destroy = function(selection2, selector) {
47234       selector = selector || ".popover-" + _id;
47235       selection2.on(_pointerPrefix + "enter.popover", null).on(_pointerPrefix + "leave.popover", null).on(_pointerPrefix + "up.popover", null).on(_pointerPrefix + "down.popover", null).on("click.popover", null).attr("title", function() {
47236         return this.getAttribute("data-original-title") || this.getAttribute("title");
47237       }).attr("data-original-title", null).selectAll(selector).remove();
47238     };
47239     popover.destroyAny = function(selection2) {
47240       selection2.call(popover.destroy, ".popover");
47241     };
47242     function setup() {
47243       var anchor = select_default2(this);
47244       var animate = _animation.apply(this, arguments);
47245       var popoverSelection = anchor.selectAll(".popover-" + _id).data([0]);
47246       var enter = popoverSelection.enter().append("div").attr("class", "popover popover-" + _id + " " + (klass ? klass : "")).classed("arrowed", _hasArrow.apply(this, arguments));
47247       enter.append("div").attr("class", "popover-arrow");
47248       enter.append("div").attr("class", "popover-inner");
47249       popoverSelection = enter.merge(popoverSelection);
47250       if (animate) {
47251         popoverSelection.classed("fade", true);
47252       }
47253       var display = _displayType.apply(this, arguments);
47254       if (display === "hover") {
47255         var _lastNonMouseEnterTime;
47256         anchor.on(_pointerPrefix + "enter.popover", function(d3_event) {
47257           if (d3_event.pointerType) {
47258             if (d3_event.pointerType !== "mouse") {
47259               _lastNonMouseEnterTime = d3_event.timeStamp;
47260               return;
47261             } else if (_lastNonMouseEnterTime && d3_event.timeStamp - _lastNonMouseEnterTime < 1500) {
47262               return;
47263             }
47264           }
47265           if (d3_event.buttons !== 0) return;
47266           show.apply(this, arguments);
47267         }).on(_pointerPrefix + "leave.popover", function() {
47268           hide.apply(this, arguments);
47269         }).on("focus.popover", function() {
47270           show.apply(this, arguments);
47271         }).on("blur.popover", function() {
47272           hide.apply(this, arguments);
47273         });
47274       } else if (display === "clickFocus") {
47275         anchor.on(_pointerPrefix + "down.popover", function(d3_event) {
47276           d3_event.preventDefault();
47277           d3_event.stopPropagation();
47278         }).on(_pointerPrefix + "up.popover", function(d3_event) {
47279           d3_event.preventDefault();
47280           d3_event.stopPropagation();
47281         }).on("click.popover", toggle);
47282         popoverSelection.attr("tabindex", 0).on("blur.popover", function() {
47283           anchor.each(function() {
47284             hide.apply(this, arguments);
47285           });
47286         });
47287       }
47288     }
47289     function show() {
47290       var anchor = select_default2(this);
47291       var popoverSelection = anchor.selectAll(".popover-" + _id);
47292       if (popoverSelection.empty()) {
47293         anchor.call(popover.destroy);
47294         anchor.each(setup);
47295         popoverSelection = anchor.selectAll(".popover-" + _id);
47296       }
47297       popoverSelection.classed("in", true);
47298       var displayType = _displayType.apply(this, arguments);
47299       if (displayType === "clickFocus") {
47300         anchor.classed("active", true);
47301         popoverSelection.node().focus();
47302       }
47303       anchor.each(updateContent);
47304     }
47305     function updateContent() {
47306       var anchor = select_default2(this);
47307       if (_content) {
47308         anchor.selectAll(".popover-" + _id + " > .popover-inner").call(_content.apply(this, arguments));
47309       }
47310       updatePosition.apply(this, arguments);
47311       updatePosition.apply(this, arguments);
47312       updatePosition.apply(this, arguments);
47313     }
47314     function updatePosition() {
47315       var anchor = select_default2(this);
47316       var popoverSelection = anchor.selectAll(".popover-" + _id);
47317       var scrollContainer = _scrollContainer && _scrollContainer.apply(this, arguments);
47318       var scrollNode = scrollContainer && !scrollContainer.empty() && scrollContainer.node();
47319       var scrollLeft = scrollNode ? scrollNode.scrollLeft : 0;
47320       var scrollTop = scrollNode ? scrollNode.scrollTop : 0;
47321       var placement = _placement.apply(this, arguments);
47322       popoverSelection.classed("left", false).classed("right", false).classed("top", false).classed("bottom", false).classed(placement, true);
47323       var alignment = _alignment.apply(this, arguments);
47324       var alignFactor = 0.5;
47325       if (alignment === "leading") {
47326         alignFactor = 0;
47327       } else if (alignment === "trailing") {
47328         alignFactor = 1;
47329       }
47330       var anchorFrame = getFrame(anchor.node());
47331       var popoverFrame = getFrame(popoverSelection.node());
47332       var position;
47333       switch (placement) {
47334         case "top":
47335           position = {
47336             x: anchorFrame.x + (anchorFrame.w - popoverFrame.w) * alignFactor,
47337             y: anchorFrame.y - popoverFrame.h
47338           };
47339           break;
47340         case "bottom":
47341           position = {
47342             x: anchorFrame.x + (anchorFrame.w - popoverFrame.w) * alignFactor,
47343             y: anchorFrame.y + anchorFrame.h
47344           };
47345           break;
47346         case "left":
47347           position = {
47348             x: anchorFrame.x - popoverFrame.w,
47349             y: anchorFrame.y + (anchorFrame.h - popoverFrame.h) * alignFactor
47350           };
47351           break;
47352         case "right":
47353           position = {
47354             x: anchorFrame.x + anchorFrame.w,
47355             y: anchorFrame.y + (anchorFrame.h - popoverFrame.h) * alignFactor
47356           };
47357           break;
47358       }
47359       if (position) {
47360         if (scrollNode && (placement === "top" || placement === "bottom")) {
47361           var initialPosX = position.x;
47362           if (position.x + popoverFrame.w > scrollNode.offsetWidth - 10) {
47363             position.x = scrollNode.offsetWidth - 10 - popoverFrame.w;
47364           } else if (position.x < 10) {
47365             position.x = 10;
47366           }
47367           var arrow = anchor.selectAll(".popover-" + _id + " > .popover-arrow");
47368           var arrowPosX = Math.min(Math.max(popoverFrame.w / 2 - (position.x - initialPosX), 10), popoverFrame.w - 10);
47369           arrow.style("left", ~~arrowPosX + "px");
47370         }
47371         popoverSelection.style("left", ~~position.x + "px").style("top", ~~position.y + "px");
47372       } else {
47373         popoverSelection.style("left", null).style("top", null);
47374       }
47375       function getFrame(node) {
47376         var positionStyle = select_default2(node).style("position");
47377         if (positionStyle === "absolute" || positionStyle === "static") {
47378           return {
47379             x: node.offsetLeft - scrollLeft,
47380             y: node.offsetTop - scrollTop,
47381             w: node.offsetWidth,
47382             h: node.offsetHeight
47383           };
47384         } else {
47385           return {
47386             x: 0,
47387             y: 0,
47388             w: node.offsetWidth,
47389             h: node.offsetHeight
47390           };
47391         }
47392       }
47393     }
47394     function hide() {
47395       var anchor = select_default2(this);
47396       if (_displayType.apply(this, arguments) === "clickFocus") {
47397         anchor.classed("active", false);
47398       }
47399       anchor.selectAll(".popover-" + _id).classed("in", false);
47400     }
47401     function toggle() {
47402       if (select_default2(this).select(".popover-" + _id).classed("in")) {
47403         hide.apply(this, arguments);
47404       } else {
47405         show.apply(this, arguments);
47406       }
47407     }
47408     return popover;
47409   }
47410
47411   // modules/ui/tooltip.js
47412   function uiTooltip(klass) {
47413     var tooltip = uiPopover((klass || "") + " tooltip").displayType("hover");
47414     var _title = function() {
47415       var title = this.getAttribute("data-original-title");
47416       if (title) {
47417         return title;
47418       } else {
47419         title = this.getAttribute("title");
47420         this.removeAttribute("title");
47421         this.setAttribute("data-original-title", title);
47422       }
47423       return title;
47424     };
47425     var _heading = utilFunctor(null);
47426     var _keys = utilFunctor(null);
47427     tooltip.title = function(val) {
47428       if (!arguments.length) return _title;
47429       _title = utilFunctor(val);
47430       return tooltip;
47431     };
47432     tooltip.heading = function(val) {
47433       if (!arguments.length) return _heading;
47434       _heading = utilFunctor(val);
47435       return tooltip;
47436     };
47437     tooltip.keys = function(val) {
47438       if (!arguments.length) return _keys;
47439       _keys = utilFunctor(val);
47440       return tooltip;
47441     };
47442     tooltip.content(function() {
47443       var heading2 = _heading.apply(this, arguments);
47444       var text = _title.apply(this, arguments);
47445       var keys2 = _keys.apply(this, arguments);
47446       var headingCallback = typeof heading2 === "function" ? heading2 : (s2) => s2.text(heading2);
47447       var textCallback = typeof text === "function" ? text : (s2) => s2.text(text);
47448       return function(selection2) {
47449         var headingSelect = selection2.selectAll(".tooltip-heading").data(heading2 ? [heading2] : []);
47450         headingSelect.exit().remove();
47451         headingSelect.enter().append("div").attr("class", "tooltip-heading").merge(headingSelect).text("").call(headingCallback);
47452         var textSelect = selection2.selectAll(".tooltip-text").data(text ? [text] : []);
47453         textSelect.exit().remove();
47454         textSelect.enter().append("div").attr("class", "tooltip-text").merge(textSelect).text("").call(textCallback);
47455         var keyhintWrap = selection2.selectAll(".keyhint-wrap").data(keys2 && keys2.length ? [0] : []);
47456         keyhintWrap.exit().remove();
47457         var keyhintWrapEnter = keyhintWrap.enter().append("div").attr("class", "keyhint-wrap");
47458         keyhintWrapEnter.append("span").call(_t.append("tooltip_keyhint"));
47459         keyhintWrap = keyhintWrapEnter.merge(keyhintWrap);
47460         keyhintWrap.selectAll("kbd.shortcut").data(keys2 && keys2.length ? keys2 : []).enter().append("kbd").attr("class", "shortcut").text(function(d2) {
47461           return d2;
47462         });
47463       };
47464     });
47465     return tooltip;
47466   }
47467
47468   // modules/ui/combobox.js
47469   var _comboHideTimerID;
47470   function uiCombobox(context, klass) {
47471     var dispatch14 = dispatch_default("accept", "cancel", "update");
47472     var container = context.container();
47473     var _suggestions = [];
47474     var _data = [];
47475     var _fetched = {};
47476     var _selected = null;
47477     var _canAutocomplete = true;
47478     var _caseSensitive = false;
47479     var _cancelFetch = false;
47480     var _minItems = 2;
47481     var _tDown = 0;
47482     var _mouseEnterHandler, _mouseLeaveHandler;
47483     var _fetcher = function(val, cb) {
47484       cb(_data.filter(function(d2) {
47485         var terms = d2.terms || [];
47486         terms.push(d2.value);
47487         if (d2.key) {
47488           terms.push(d2.key);
47489         }
47490         return terms.some(function(term) {
47491           return term.toString().toLowerCase().indexOf(val.toLowerCase()) !== -1;
47492         });
47493       }));
47494     };
47495     var combobox = function(input, attachTo) {
47496       if (!input || input.empty()) return;
47497       input.classed("combobox-input", true).on("focus.combo-input", focus).on("blur.combo-input", blur).on("keydown.combo-input", keydown).on("keyup.combo-input", keyup).on("input.combo-input", change).on("mousedown.combo-input", mousedown).each(function() {
47498         var parent = this.parentNode;
47499         var sibling = this.nextSibling;
47500         select_default2(parent).selectAll(".combobox-caret").filter(function(d2) {
47501           return d2 === input.node();
47502         }).data([input.node()]).enter().insert("div", function() {
47503           return sibling;
47504         }).attr("class", "combobox-caret").on("mousedown.combo-caret", function(d3_event) {
47505           d3_event.preventDefault();
47506           input.node().focus();
47507           mousedown(d3_event);
47508         }).on("mouseup.combo-caret", function(d3_event) {
47509           d3_event.preventDefault();
47510           mouseup(d3_event);
47511         });
47512       });
47513       function mousedown(d3_event) {
47514         if (d3_event.button !== 0) return;
47515         if (input.classed("disabled")) return;
47516         _tDown = +/* @__PURE__ */ new Date();
47517         var start2 = input.property("selectionStart");
47518         var end = input.property("selectionEnd");
47519         if (start2 !== end) {
47520           var val = utilGetSetValue(input);
47521           input.node().setSelectionRange(val.length, val.length);
47522           return;
47523         }
47524         input.on("mouseup.combo-input", mouseup);
47525       }
47526       function mouseup(d3_event) {
47527         input.on("mouseup.combo-input", null);
47528         if (d3_event.button !== 0) return;
47529         if (input.classed("disabled")) return;
47530         if (input.node() !== document.activeElement) return;
47531         var start2 = input.property("selectionStart");
47532         var end = input.property("selectionEnd");
47533         if (start2 !== end) return;
47534         var combo = container.selectAll(".combobox");
47535         if (combo.empty() || combo.datum() !== input.node()) {
47536           var tOrig = _tDown;
47537           window.setTimeout(function() {
47538             if (tOrig !== _tDown) return;
47539             fetchComboData("", function() {
47540               show();
47541               render();
47542             });
47543           }, 250);
47544         } else {
47545           hide();
47546         }
47547       }
47548       function focus() {
47549         fetchComboData("");
47550       }
47551       function blur() {
47552         _comboHideTimerID = window.setTimeout(hide, 75);
47553       }
47554       function show() {
47555         hide();
47556         container.insert("div", ":first-child").datum(input.node()).attr("class", "combobox" + (klass ? " combobox-" + klass : "")).style("position", "absolute").style("display", "block").style("left", "0px").on("mousedown.combo-container", function(d3_event) {
47557           d3_event.preventDefault();
47558         });
47559         container.on("scroll.combo-scroll", render, true);
47560       }
47561       function hide() {
47562         if (_comboHideTimerID) {
47563           window.clearTimeout(_comboHideTimerID);
47564           _comboHideTimerID = void 0;
47565         }
47566         container.selectAll(".combobox").remove();
47567         container.on("scroll.combo-scroll", null);
47568       }
47569       function keydown(d3_event) {
47570         var shown = !container.selectAll(".combobox").empty();
47571         var tagName = input.node() ? input.node().tagName.toLowerCase() : "";
47572         switch (d3_event.keyCode) {
47573           case 8:
47574           // ⌫ Backspace
47575           case 46:
47576             d3_event.stopPropagation();
47577             _selected = null;
47578             render();
47579             input.on("input.combo-input", function() {
47580               var start2 = input.property("selectionStart");
47581               input.node().setSelectionRange(start2, start2);
47582               input.on("input.combo-input", change);
47583               change(false);
47584             });
47585             break;
47586           case 9:
47587             accept(d3_event);
47588             break;
47589           case 13:
47590             d3_event.preventDefault();
47591             d3_event.stopPropagation();
47592             accept(d3_event);
47593             break;
47594           case 38:
47595             if (tagName === "textarea" && !shown) return;
47596             d3_event.preventDefault();
47597             if (tagName === "input" && !shown) {
47598               show();
47599             }
47600             nav(-1);
47601             break;
47602           case 40:
47603             if (tagName === "textarea" && !shown) return;
47604             d3_event.preventDefault();
47605             if (tagName === "input" && !shown) {
47606               show();
47607             }
47608             nav(1);
47609             break;
47610         }
47611       }
47612       function keyup(d3_event) {
47613         switch (d3_event.keyCode) {
47614           case 27:
47615             cancel();
47616             break;
47617         }
47618       }
47619       function change(doAutoComplete) {
47620         if (doAutoComplete === void 0) doAutoComplete = true;
47621         fetchComboData(value(), function(skipAutosuggest) {
47622           _selected = null;
47623           var val = input.property("value");
47624           if (_suggestions.length) {
47625             if (doAutoComplete && !skipAutosuggest && input.property("selectionEnd") === val.length) {
47626               _selected = tryAutocomplete();
47627             }
47628             if (!_selected) {
47629               _selected = val;
47630             }
47631           }
47632           if (val.length) {
47633             var combo = container.selectAll(".combobox");
47634             if (combo.empty()) {
47635               show();
47636             }
47637           } else {
47638             hide();
47639           }
47640           render();
47641         });
47642       }
47643       function nav(dir) {
47644         if (_suggestions.length) {
47645           var index = -1;
47646           for (var i3 = 0; i3 < _suggestions.length; i3++) {
47647             if (_selected && _suggestions[i3].value === _selected) {
47648               index = i3;
47649               break;
47650             }
47651           }
47652           index = Math.max(Math.min(index + dir, _suggestions.length - 1), 0);
47653           _selected = _suggestions[index].value;
47654           utilGetSetValue(input, _selected);
47655           dispatch14.call("update");
47656         }
47657         render();
47658         ensureVisible();
47659       }
47660       function ensureVisible() {
47661         var _a4;
47662         var combo = container.selectAll(".combobox");
47663         if (combo.empty()) return;
47664         var containerRect = container.node().getBoundingClientRect();
47665         var comboRect = combo.node().getBoundingClientRect();
47666         if (comboRect.bottom > containerRect.bottom) {
47667           var node = attachTo ? attachTo.node() : input.node();
47668           node.scrollIntoView({ behavior: "instant", block: "center" });
47669           render();
47670         }
47671         var selected = combo.selectAll(".combobox-option.selected").node();
47672         if (selected) {
47673           (_a4 = selected.scrollIntoView) == null ? void 0 : _a4.call(selected, { behavior: "smooth", block: "nearest" });
47674         }
47675       }
47676       function value() {
47677         var value2 = input.property("value");
47678         var start2 = input.property("selectionStart");
47679         var end = input.property("selectionEnd");
47680         if (start2 && end) {
47681           value2 = value2.substring(0, start2);
47682         }
47683         return value2;
47684       }
47685       function fetchComboData(v2, cb) {
47686         _cancelFetch = false;
47687         _fetcher.call(input, v2, function(results, skipAutosuggest) {
47688           if (_cancelFetch) return;
47689           _suggestions = results;
47690           results.forEach(function(d2) {
47691             _fetched[d2.value] = d2;
47692           });
47693           if (cb) {
47694             cb(skipAutosuggest);
47695           }
47696         });
47697       }
47698       function tryAutocomplete() {
47699         if (!_canAutocomplete) return;
47700         var val = _caseSensitive ? value() : value().toLowerCase();
47701         if (!val) return;
47702         if (isFinite(val)) return;
47703         const suggestionValues = [];
47704         _suggestions.forEach((s2) => {
47705           suggestionValues.push(s2.value);
47706           if (s2.key && s2.key !== s2.value) {
47707             suggestionValues.push(s2.key);
47708           }
47709         });
47710         var bestIndex = -1;
47711         for (var i3 = 0; i3 < suggestionValues.length; i3++) {
47712           var suggestion = suggestionValues[i3];
47713           var compare2 = _caseSensitive ? suggestion : suggestion.toLowerCase();
47714           if (compare2 === val) {
47715             bestIndex = i3;
47716             break;
47717           } else if (bestIndex === -1 && compare2.indexOf(val) === 0) {
47718             bestIndex = i3;
47719           }
47720         }
47721         if (bestIndex !== -1) {
47722           var bestVal = suggestionValues[bestIndex];
47723           input.property("value", bestVal);
47724           input.node().setSelectionRange(val.length, bestVal.length);
47725           dispatch14.call("update");
47726           return bestVal;
47727         }
47728       }
47729       function render() {
47730         if (_suggestions.length < _minItems || document.activeElement !== input.node()) {
47731           hide();
47732           return;
47733         }
47734         var shown = !container.selectAll(".combobox").empty();
47735         if (!shown) return;
47736         var combo = container.selectAll(".combobox");
47737         var options2 = combo.selectAll(".combobox-option").data(_suggestions, function(d2) {
47738           return d2.value;
47739         });
47740         options2.exit().remove();
47741         options2.enter().append("a").attr("class", function(d2) {
47742           return "combobox-option " + (d2.klass || "");
47743         }).attr("title", function(d2) {
47744           return d2.title;
47745         }).each(function(d2) {
47746           if (d2.display) {
47747             d2.display(select_default2(this));
47748           } else {
47749             select_default2(this).text(d2.value);
47750           }
47751         }).on("mouseenter", _mouseEnterHandler).on("mouseleave", _mouseLeaveHandler).merge(options2).classed("selected", function(d2) {
47752           return d2.value === _selected || d2.key === _selected;
47753         }).on("click.combo-option", accept).order();
47754         var node = attachTo ? attachTo.node() : input.node();
47755         var containerRect = container.node().getBoundingClientRect();
47756         var rect = node.getBoundingClientRect();
47757         combo.style("left", rect.left + 5 - containerRect.left + "px").style("width", rect.width - 10 + "px").style("top", rect.height + rect.top - containerRect.top + "px");
47758       }
47759       function accept(d3_event, d2) {
47760         _cancelFetch = true;
47761         var thiz = input.node();
47762         if (d2) {
47763           utilGetSetValue(input, d2.value);
47764           utilTriggerEvent(input, "change");
47765         }
47766         var val = utilGetSetValue(input);
47767         thiz.setSelectionRange(val.length, val.length);
47768         if (!d2) {
47769           d2 = _fetched[val];
47770         }
47771         dispatch14.call("accept", thiz, d2, val);
47772         hide();
47773       }
47774       function cancel() {
47775         _cancelFetch = true;
47776         var thiz = input.node();
47777         var val = utilGetSetValue(input);
47778         var start2 = input.property("selectionStart");
47779         var end = input.property("selectionEnd");
47780         val = val.slice(0, start2) + val.slice(end);
47781         utilGetSetValue(input, val);
47782         thiz.setSelectionRange(val.length, val.length);
47783         dispatch14.call("cancel", thiz);
47784         hide();
47785       }
47786     };
47787     combobox.canAutocomplete = function(val) {
47788       if (!arguments.length) return _canAutocomplete;
47789       _canAutocomplete = val;
47790       return combobox;
47791     };
47792     combobox.caseSensitive = function(val) {
47793       if (!arguments.length) return _caseSensitive;
47794       _caseSensitive = val;
47795       return combobox;
47796     };
47797     combobox.data = function(val) {
47798       if (!arguments.length) return _data;
47799       _data = val;
47800       return combobox;
47801     };
47802     combobox.fetcher = function(val) {
47803       if (!arguments.length) return _fetcher;
47804       _fetcher = val;
47805       return combobox;
47806     };
47807     combobox.minItems = function(val) {
47808       if (!arguments.length) return _minItems;
47809       _minItems = val;
47810       return combobox;
47811     };
47812     combobox.itemsMouseEnter = function(val) {
47813       if (!arguments.length) return _mouseEnterHandler;
47814       _mouseEnterHandler = val;
47815       return combobox;
47816     };
47817     combobox.itemsMouseLeave = function(val) {
47818       if (!arguments.length) return _mouseLeaveHandler;
47819       _mouseLeaveHandler = val;
47820       return combobox;
47821     };
47822     return utilRebind(combobox, dispatch14, "on");
47823   }
47824   uiCombobox.off = function(input, context) {
47825     input.on("focus.combo-input", null).on("blur.combo-input", null).on("keydown.combo-input", null).on("keyup.combo-input", null).on("input.combo-input", null).on("mousedown.combo-input", null).on("mouseup.combo-input", null);
47826     context.container().on("scroll.combo-scroll", null);
47827   };
47828
47829   // modules/ui/intro/helper.js
47830   function pointBox(loc, context) {
47831     var rect = context.surfaceRect();
47832     var point = context.curtainProjection(loc);
47833     return {
47834       left: point[0] + rect.left - 40,
47835       top: point[1] + rect.top - 60,
47836       width: 80,
47837       height: 90
47838     };
47839   }
47840   function pad(locOrBox, padding, context) {
47841     var box;
47842     if (locOrBox instanceof Array) {
47843       var rect = context.surfaceRect();
47844       var point = context.curtainProjection(locOrBox);
47845       box = {
47846         left: point[0] + rect.left,
47847         top: point[1] + rect.top
47848       };
47849     } else {
47850       box = locOrBox;
47851     }
47852     return {
47853       left: box.left - padding,
47854       top: box.top - padding,
47855       width: (box.width || 0) + 2 * padding,
47856       height: (box.width || 0) + 2 * padding
47857     };
47858   }
47859   function icon(name, svgklass, useklass) {
47860     return '<svg class="icon ' + (svgklass || "") + '"><use xlink:href="' + name + '"' + (useklass ? ' class="' + useklass + '"' : "") + "></use></svg>";
47861   }
47862   var helpStringReplacements;
47863   function helpHtml(id2, replacements) {
47864     if (!helpStringReplacements) {
47865       helpStringReplacements = {
47866         // insert icons corresponding to various UI elements
47867         point_icon: icon("#iD-icon-point", "inline"),
47868         line_icon: icon("#iD-icon-line", "inline"),
47869         area_icon: icon("#iD-icon-area", "inline"),
47870         note_icon: icon("#iD-icon-note", "inline add-note"),
47871         plus: icon("#iD-icon-plus", "inline"),
47872         minus: icon("#iD-icon-minus", "inline"),
47873         layers_icon: icon("#iD-icon-layers", "inline"),
47874         data_icon: icon("#iD-icon-data", "inline"),
47875         inspect: icon("#iD-icon-inspect", "inline"),
47876         help_icon: icon("#iD-icon-help", "inline"),
47877         undo_icon: icon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-redo" : "#iD-icon-undo", "inline"),
47878         redo_icon: icon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-undo" : "#iD-icon-redo", "inline"),
47879         save_icon: icon("#iD-icon-save", "inline"),
47880         // operation icons
47881         circularize_icon: icon("#iD-operation-circularize", "inline operation"),
47882         continue_icon: icon("#iD-operation-continue", "inline operation"),
47883         copy_icon: icon("#iD-operation-copy", "inline operation"),
47884         delete_icon: icon("#iD-operation-delete", "inline operation"),
47885         disconnect_icon: icon("#iD-operation-disconnect", "inline operation"),
47886         downgrade_icon: icon("#iD-operation-downgrade", "inline operation"),
47887         extract_icon: icon("#iD-operation-extract", "inline operation"),
47888         merge_icon: icon("#iD-operation-merge", "inline operation"),
47889         move_icon: icon("#iD-operation-move", "inline operation"),
47890         orthogonalize_icon: icon("#iD-operation-orthogonalize", "inline operation"),
47891         paste_icon: icon("#iD-operation-paste", "inline operation"),
47892         reflect_long_icon: icon("#iD-operation-reflect-long", "inline operation"),
47893         reflect_short_icon: icon("#iD-operation-reflect-short", "inline operation"),
47894         reverse_icon: icon("#iD-operation-reverse", "inline operation"),
47895         rotate_icon: icon("#iD-operation-rotate", "inline operation"),
47896         split_icon: icon("#iD-operation-split", "inline operation"),
47897         straighten_icon: icon("#iD-operation-straighten", "inline operation"),
47898         // interaction icons
47899         leftclick: icon("#iD-walkthrough-mouse-left", "inline operation"),
47900         rightclick: icon("#iD-walkthrough-mouse-right", "inline operation"),
47901         mousewheel_icon: icon("#iD-walkthrough-mousewheel", "inline operation"),
47902         tap_icon: icon("#iD-walkthrough-tap", "inline operation"),
47903         doubletap_icon: icon("#iD-walkthrough-doubletap", "inline operation"),
47904         longpress_icon: icon("#iD-walkthrough-longpress", "inline operation"),
47905         touchdrag_icon: icon("#iD-walkthrough-touchdrag", "inline operation"),
47906         pinch_icon: icon("#iD-walkthrough-pinch-apart", "inline operation"),
47907         // insert keys; may be localized and platform-dependent
47908         shift: uiCmd.display("\u21E7"),
47909         alt: uiCmd.display("\u2325"),
47910         return: uiCmd.display("\u21B5"),
47911         esc: _t.html("shortcuts.key.esc"),
47912         space: _t.html("shortcuts.key.space"),
47913         add_note_key: _t.html("modes.add_note.key"),
47914         help_key: _t.html("help.key"),
47915         shortcuts_key: _t.html("shortcuts.toggle.key"),
47916         // reference localized UI labels directly so that they'll always match
47917         save: _t.html("save.title"),
47918         undo: _t.html("undo.title"),
47919         redo: _t.html("redo.title"),
47920         upload: _t.html("commit.save"),
47921         point: _t.html("modes.add_point.title"),
47922         line: _t.html("modes.add_line.title"),
47923         area: _t.html("modes.add_area.title"),
47924         note: _t.html("modes.add_note.label"),
47925         circularize: _t.html("operations.circularize.title"),
47926         continue: _t.html("operations.continue.title"),
47927         copy: _t.html("operations.copy.title"),
47928         delete: _t.html("operations.delete.title"),
47929         disconnect: _t.html("operations.disconnect.title"),
47930         downgrade: _t.html("operations.downgrade.title"),
47931         extract: _t.html("operations.extract.title"),
47932         merge: _t.html("operations.merge.title"),
47933         move: _t.html("operations.move.title"),
47934         orthogonalize: _t.html("operations.orthogonalize.title"),
47935         paste: _t.html("operations.paste.title"),
47936         reflect_long: _t.html("operations.reflect.title.long"),
47937         reflect_short: _t.html("operations.reflect.title.short"),
47938         reverse: _t.html("operations.reverse.title"),
47939         rotate: _t.html("operations.rotate.title"),
47940         split: _t.html("operations.split.title"),
47941         straighten: _t.html("operations.straighten.title"),
47942         map_data: _t.html("map_data.title"),
47943         osm_notes: _t.html("map_data.layers.notes.title"),
47944         fields: _t.html("inspector.fields"),
47945         tags: _t.html("inspector.tags"),
47946         relations: _t.html("inspector.relations"),
47947         new_relation: _t.html("inspector.new_relation"),
47948         turn_restrictions: _t.html("_tagging.presets.fields.restrictions.label"),
47949         background_settings: _t.html("background.description"),
47950         imagery_offset: _t.html("background.fix_misalignment"),
47951         start_the_walkthrough: _t.html("splash.walkthrough"),
47952         help: _t.html("help.title"),
47953         ok: _t.html("intro.ok")
47954       };
47955       for (var key in helpStringReplacements) {
47956         helpStringReplacements[key] = { html: helpStringReplacements[key] };
47957       }
47958     }
47959     var reps;
47960     if (replacements) {
47961       reps = Object.assign(replacements, helpStringReplacements);
47962     } else {
47963       reps = helpStringReplacements;
47964     }
47965     return _t.html(id2, reps).replace(/\`(.*?)\`/g, "<kbd>$1</kbd>");
47966   }
47967   function slugify(text) {
47968     return text.toString().toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
47969   }
47970   var missingStrings = {};
47971   function checkKey(key, text) {
47972     if (_t(key, { default: void 0 }) === void 0) {
47973       if (missingStrings.hasOwnProperty(key)) return;
47974       missingStrings[key] = text;
47975       var missing = key + ": " + text;
47976       if (typeof console !== "undefined") console.log(missing);
47977     }
47978   }
47979   function localize(obj) {
47980     var key;
47981     var name = obj.tags && obj.tags.name;
47982     if (name) {
47983       key = "intro.graph.name." + slugify(name);
47984       obj.tags.name = _t(key, { default: name });
47985       checkKey(key, name);
47986     }
47987     var street = obj.tags && obj.tags["addr:street"];
47988     if (street) {
47989       key = "intro.graph.name." + slugify(street);
47990       obj.tags["addr:street"] = _t(key, { default: street });
47991       checkKey(key, street);
47992       var addrTags = [
47993         "block_number",
47994         "city",
47995         "county",
47996         "district",
47997         "hamlet",
47998         "neighbourhood",
47999         "postcode",
48000         "province",
48001         "quarter",
48002         "state",
48003         "subdistrict",
48004         "suburb"
48005       ];
48006       addrTags.forEach(function(k2) {
48007         var key2 = "intro.graph." + k2;
48008         var tag2 = "addr:" + k2;
48009         var val = obj.tags && obj.tags[tag2];
48010         var str = _t(key2, { default: val });
48011         if (str) {
48012           if (str.match(/^<.*>$/) !== null) {
48013             delete obj.tags[tag2];
48014           } else {
48015             obj.tags[tag2] = str;
48016           }
48017         }
48018       });
48019     }
48020     return obj;
48021   }
48022   function isMostlySquare(points) {
48023     var threshold = 15;
48024     var lowerBound = Math.cos((90 - threshold) * Math.PI / 180);
48025     var upperBound = Math.cos(threshold * Math.PI / 180);
48026     for (var i3 = 0; i3 < points.length; i3++) {
48027       var a2 = points[(i3 - 1 + points.length) % points.length];
48028       var origin = points[i3];
48029       var b2 = points[(i3 + 1) % points.length];
48030       var dotp = geoVecNormalizedDot(a2, b2, origin);
48031       var mag = Math.abs(dotp);
48032       if (mag > lowerBound && mag < upperBound) {
48033         return false;
48034       }
48035     }
48036     return true;
48037   }
48038   function selectMenuItem(context, operation2) {
48039     return context.container().select(".edit-menu .edit-menu-item-" + operation2);
48040   }
48041   function transitionTime(point1, point2) {
48042     var distance = geoSphericalDistance(point1, point2);
48043     if (distance === 0) {
48044       return 0;
48045     } else if (distance < 80) {
48046       return 500;
48047     } else {
48048       return 1e3;
48049     }
48050   }
48051
48052   // modules/ui/field_help.js
48053   function uiFieldHelp(context, fieldName) {
48054     var fieldHelp = {};
48055     var _inspector = select_default2(null);
48056     var _wrap = select_default2(null);
48057     var _body = select_default2(null);
48058     var fieldHelpKeys = {
48059       restrictions: [
48060         ["about", [
48061           "about",
48062           "from_via_to",
48063           "maxdist",
48064           "maxvia"
48065         ]],
48066         ["inspecting", [
48067           "about",
48068           "from_shadow",
48069           "allow_shadow",
48070           "restrict_shadow",
48071           "only_shadow",
48072           "restricted",
48073           "only"
48074         ]],
48075         ["modifying", [
48076           "about",
48077           "indicators",
48078           "allow_turn",
48079           "restrict_turn",
48080           "only_turn"
48081         ]],
48082         ["tips", [
48083           "simple",
48084           "simple_example",
48085           "indirect",
48086           "indirect_example",
48087           "indirect_noedit"
48088         ]]
48089       ]
48090     };
48091     var fieldHelpHeadings = {};
48092     var replacements = {
48093       distField: { html: _t.html("restriction.controls.distance") },
48094       viaField: { html: _t.html("restriction.controls.via") },
48095       fromShadow: { html: icon("#iD-turn-shadow", "inline shadow from") },
48096       allowShadow: { html: icon("#iD-turn-shadow", "inline shadow allow") },
48097       restrictShadow: { html: icon("#iD-turn-shadow", "inline shadow restrict") },
48098       onlyShadow: { html: icon("#iD-turn-shadow", "inline shadow only") },
48099       allowTurn: { html: icon("#iD-turn-yes", "inline turn") },
48100       restrictTurn: { html: icon("#iD-turn-no", "inline turn") },
48101       onlyTurn: { html: icon("#iD-turn-only", "inline turn") }
48102     };
48103     var docs = fieldHelpKeys[fieldName].map(function(key) {
48104       var helpkey = "help.field." + fieldName + "." + key[0];
48105       var text = key[1].reduce(function(all, part) {
48106         var subkey = helpkey + "." + part;
48107         var depth = fieldHelpHeadings[subkey];
48108         var hhh = depth ? Array(depth + 1).join("#") + " " : "";
48109         return all + hhh + _t.html(subkey, replacements) + "\n\n";
48110       }, "");
48111       return {
48112         key: helpkey,
48113         title: _t.html(helpkey + ".title"),
48114         html: marked(text.trim())
48115       };
48116     });
48117     function show() {
48118       updatePosition();
48119       _body.classed("hide", false).style("opacity", "0").transition().duration(200).style("opacity", "1");
48120     }
48121     function hide() {
48122       _body.classed("hide", true).transition().duration(200).style("opacity", "0").on("end", function() {
48123         _body.classed("hide", true);
48124       });
48125     }
48126     function clickHelp(index) {
48127       var d2 = docs[index];
48128       var tkeys = fieldHelpKeys[fieldName][index][1];
48129       _body.selectAll(".field-help-nav-item").classed("active", function(d4, i3) {
48130         return i3 === index;
48131       });
48132       var content = _body.selectAll(".field-help-content").html(d2.html);
48133       content.selectAll("p").attr("class", function(d4, i3) {
48134         return tkeys[i3];
48135       });
48136       if (d2.key === "help.field.restrictions.inspecting") {
48137         content.insert("img", "p.from_shadow").attr("class", "field-help-image cf").attr("src", context.imagePath("tr_inspect.gif"));
48138       } else if (d2.key === "help.field.restrictions.modifying") {
48139         content.insert("img", "p.allow_turn").attr("class", "field-help-image cf").attr("src", context.imagePath("tr_modify.gif"));
48140       }
48141     }
48142     fieldHelp.button = function(selection2) {
48143       if (_body.empty()) return;
48144       var button = selection2.selectAll(".field-help-button").data([0]);
48145       button.enter().append("button").attr("class", "field-help-button").call(svgIcon("#iD-icon-help")).merge(button).on("click", function(d3_event) {
48146         d3_event.stopPropagation();
48147         d3_event.preventDefault();
48148         if (_body.classed("hide")) {
48149           show();
48150         } else {
48151           hide();
48152         }
48153       });
48154     };
48155     function updatePosition() {
48156       var wrap2 = _wrap.node();
48157       var inspector = _inspector.node();
48158       var wRect = wrap2.getBoundingClientRect();
48159       var iRect = inspector.getBoundingClientRect();
48160       _body.style("top", wRect.top + inspector.scrollTop - iRect.top + "px");
48161     }
48162     fieldHelp.body = function(selection2) {
48163       _wrap = selection2.selectAll(".form-field-input-wrap");
48164       if (_wrap.empty()) return;
48165       _inspector = context.container().select(".sidebar .entity-editor-pane .inspector-body");
48166       if (_inspector.empty()) return;
48167       _body = _inspector.selectAll(".field-help-body").data([0]);
48168       var enter = _body.enter().append("div").attr("class", "field-help-body hide");
48169       var titleEnter = enter.append("div").attr("class", "field-help-title cf");
48170       titleEnter.append("h2").attr("class", _mainLocalizer.textDirection() === "rtl" ? "fr" : "fl").call(_t.append("help.field." + fieldName + ".title"));
48171       titleEnter.append("button").attr("class", "fr close").attr("title", _t("icons.close")).on("click", function(d3_event) {
48172         d3_event.stopPropagation();
48173         d3_event.preventDefault();
48174         hide();
48175       }).call(svgIcon("#iD-icon-close"));
48176       var navEnter = enter.append("div").attr("class", "field-help-nav cf");
48177       var titles = docs.map(function(d2) {
48178         return d2.title;
48179       });
48180       navEnter.selectAll(".field-help-nav-item").data(titles).enter().append("div").attr("class", "field-help-nav-item").html(function(d2) {
48181         return d2;
48182       }).on("click", function(d3_event, d2) {
48183         d3_event.stopPropagation();
48184         d3_event.preventDefault();
48185         clickHelp(titles.indexOf(d2));
48186       });
48187       enter.append("div").attr("class", "field-help-content");
48188       _body = _body.merge(enter);
48189       clickHelp(0);
48190     };
48191     return fieldHelp;
48192   }
48193
48194   // modules/ui/fields/check.js
48195   function uiFieldCheck(field, context) {
48196     var dispatch14 = dispatch_default("change");
48197     var options2 = field.options;
48198     var values = [];
48199     var texts = [];
48200     var _tags;
48201     var input = select_default2(null);
48202     var text = select_default2(null);
48203     var label = select_default2(null);
48204     var reverser = select_default2(null);
48205     var _impliedYes;
48206     var _entityIDs = [];
48207     var _value;
48208     var stringsField = field.resolveReference("stringsCrossReference");
48209     if (!options2 && stringsField.options) {
48210       options2 = stringsField.options;
48211     }
48212     if (options2) {
48213       for (var i3 in options2) {
48214         var v2 = options2[i3];
48215         values.push(v2 === "undefined" ? void 0 : v2);
48216         texts.push(stringsField.t.html("options." + v2, { "default": v2 }));
48217       }
48218     } else {
48219       values = [void 0, "yes"];
48220       texts = [_t.html("inspector.unknown"), _t.html("inspector.check.yes")];
48221       if (field.type !== "defaultCheck") {
48222         values.push("no");
48223         texts.push(_t.html("inspector.check.no"));
48224       }
48225     }
48226     function checkImpliedYes() {
48227       _impliedYes = field.id === "oneway_yes";
48228       if (field.id === "oneway") {
48229         var entity = context.entity(_entityIDs[0]);
48230         for (var key in entity.tags) {
48231           if (key in osmOneWayTags && entity.tags[key] in osmOneWayTags[key]) {
48232             _impliedYes = true;
48233             texts[0] = _t.html("_tagging.presets.fields.oneway_yes.options.undefined");
48234             break;
48235           }
48236         }
48237       }
48238     }
48239     function reverserHidden() {
48240       if (!context.container().select("div.inspector-hover").empty()) return true;
48241       return !(_value === "yes" || _impliedYes && !_value);
48242     }
48243     function reverserSetText(selection2) {
48244       var entity = _entityIDs.length && context.hasEntity(_entityIDs[0]);
48245       if (reverserHidden() || !entity) return selection2;
48246       var first = entity.first();
48247       var last = entity.isClosed() ? entity.nodes[entity.nodes.length - 2] : entity.last();
48248       var pseudoDirection = first < last;
48249       var icon2 = pseudoDirection ? "#iD-icon-forward" : "#iD-icon-backward";
48250       selection2.selectAll(".reverser-span").html("").call(_t.append("inspector.check.reverser")).call(svgIcon(icon2, "inline"));
48251       return selection2;
48252     }
48253     var check = function(selection2) {
48254       checkImpliedYes();
48255       label = selection2.selectAll(".form-field-input-wrap").data([0]);
48256       var enter = label.enter().append("label").attr("class", "form-field-input-wrap form-field-input-check");
48257       enter.append("input").property("indeterminate", field.type !== "defaultCheck").attr("type", "checkbox").attr("id", field.domId);
48258       enter.append("span").html(texts[0]).attr("class", "value");
48259       if (field.type === "onewayCheck") {
48260         enter.append("button").attr("class", "reverser" + (reverserHidden() ? " hide" : "")).append("span").attr("class", "reverser-span");
48261       }
48262       label = label.merge(enter);
48263       input = label.selectAll("input");
48264       text = label.selectAll("span.value");
48265       input.on("click", function(d3_event) {
48266         d3_event.stopPropagation();
48267         var t2 = {};
48268         if (Array.isArray(_tags[field.key])) {
48269           if (values.indexOf("yes") !== -1) {
48270             t2[field.key] = "yes";
48271           } else {
48272             t2[field.key] = values[0];
48273           }
48274         } else {
48275           t2[field.key] = values[(values.indexOf(_value) + 1) % values.length];
48276         }
48277         if (t2[field.key] === "reversible" || t2[field.key] === "alternating") {
48278           t2[field.key] = values[0];
48279         }
48280         dispatch14.call("change", this, t2);
48281       });
48282       if (field.type === "onewayCheck") {
48283         reverser = label.selectAll(".reverser");
48284         reverser.call(reverserSetText).on("click", function(d3_event) {
48285           d3_event.preventDefault();
48286           d3_event.stopPropagation();
48287           context.perform(
48288             function(graph) {
48289               for (var i4 in _entityIDs) {
48290                 graph = actionReverse(_entityIDs[i4])(graph);
48291               }
48292               return graph;
48293             },
48294             _t("operations.reverse.annotation.line", { n: 1 })
48295           );
48296           context.validator().validate();
48297           select_default2(this).call(reverserSetText);
48298         });
48299       }
48300     };
48301     check.entityIDs = function(val) {
48302       if (!arguments.length) return _entityIDs;
48303       _entityIDs = val;
48304       return check;
48305     };
48306     check.tags = function(tags) {
48307       _tags = tags;
48308       function isChecked(val) {
48309         return val !== "no" && val !== "" && val !== void 0 && val !== null;
48310       }
48311       function textFor(val) {
48312         if (val === "") val = void 0;
48313         var index = values.indexOf(val);
48314         return index !== -1 ? texts[index] : '"' + val + '"';
48315       }
48316       checkImpliedYes();
48317       var isMixed = Array.isArray(tags[field.key]);
48318       _value = !isMixed && tags[field.key] && tags[field.key].toLowerCase();
48319       if (field.type === "onewayCheck" && (_value === "1" || _value === "-1")) {
48320         _value = "yes";
48321       }
48322       input.property("indeterminate", isMixed || field.type !== "defaultCheck" && !_value).property("checked", isChecked(_value));
48323       text.html(isMixed ? _t.html("inspector.multiple_values") : textFor(_value)).classed("mixed", isMixed);
48324       label.classed("set", !!_value);
48325       if (field.type === "onewayCheck") {
48326         reverser.classed("hide", reverserHidden()).call(reverserSetText);
48327       }
48328     };
48329     check.focus = function() {
48330       input.node().focus();
48331     };
48332     return utilRebind(check, dispatch14, "on");
48333   }
48334
48335   // modules/svg/areas.js
48336   var import_fast_deep_equal5 = __toESM(require_fast_deep_equal());
48337
48338   // modules/svg/helpers.js
48339   function svgPassiveVertex(node, graph, activeID) {
48340     if (!activeID) return 1;
48341     if (activeID === node.id) return 0;
48342     var parents = graph.parentWays(node);
48343     var i3, j2, nodes, isClosed, ix1, ix2, ix3, ix4, max3;
48344     for (i3 = 0; i3 < parents.length; i3++) {
48345       nodes = parents[i3].nodes;
48346       isClosed = parents[i3].isClosed();
48347       for (j2 = 0; j2 < nodes.length; j2++) {
48348         if (nodes[j2] === node.id) {
48349           ix1 = j2 - 2;
48350           ix2 = j2 - 1;
48351           ix3 = j2 + 1;
48352           ix4 = j2 + 2;
48353           if (isClosed) {
48354             max3 = nodes.length - 1;
48355             if (ix1 < 0) ix1 = max3 + ix1;
48356             if (ix2 < 0) ix2 = max3 + ix2;
48357             if (ix3 > max3) ix3 = ix3 - max3;
48358             if (ix4 > max3) ix4 = ix4 - max3;
48359           }
48360           if (nodes[ix1] === activeID) return 0;
48361           else if (nodes[ix2] === activeID) return 2;
48362           else if (nodes[ix3] === activeID) return 2;
48363           else if (nodes[ix4] === activeID) return 0;
48364           else if (isClosed && nodes.indexOf(activeID) !== -1) return 0;
48365         }
48366       }
48367     }
48368     return 1;
48369   }
48370   function svgMarkerSegments(projection2, graph, dt2, shouldReverse, bothDirections) {
48371     return function(entity) {
48372       var i3 = 0;
48373       var offset = dt2;
48374       var segments = [];
48375       var clip = identity_default2().clipExtent(projection2.clipExtent()).stream;
48376       var coordinates = graph.childNodes(entity).map(function(n3) {
48377         return n3.loc;
48378       });
48379       var a2, b2;
48380       if (shouldReverse(entity)) {
48381         coordinates.reverse();
48382       }
48383       stream_default({
48384         type: "LineString",
48385         coordinates
48386       }, projection2.stream(clip({
48387         lineStart: function() {
48388         },
48389         lineEnd: function() {
48390           a2 = null;
48391         },
48392         point: function(x2, y2) {
48393           b2 = [x2, y2];
48394           if (a2) {
48395             var span = geoVecLength(a2, b2) - offset;
48396             if (span >= 0) {
48397               var heading2 = geoVecAngle(a2, b2);
48398               var dx = dt2 * Math.cos(heading2);
48399               var dy = dt2 * Math.sin(heading2);
48400               var p2 = [
48401                 a2[0] + offset * Math.cos(heading2),
48402                 a2[1] + offset * Math.sin(heading2)
48403               ];
48404               var coord2 = [a2, p2];
48405               for (span -= dt2; span >= 0; span -= dt2) {
48406                 p2 = geoVecAdd(p2, [dx, dy]);
48407                 coord2.push(p2);
48408               }
48409               coord2.push(b2);
48410               var segment = "";
48411               var j2;
48412               for (j2 = 0; j2 < coord2.length; j2++) {
48413                 segment += (j2 === 0 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1];
48414               }
48415               segments.push({ id: entity.id, index: i3++, d: segment });
48416               if (bothDirections(entity)) {
48417                 segment = "";
48418                 for (j2 = coord2.length - 1; j2 >= 0; j2--) {
48419                   segment += (j2 === coord2.length - 1 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1];
48420                 }
48421                 segments.push({ id: entity.id, index: i3++, d: segment });
48422               }
48423             }
48424             offset = -span;
48425           }
48426           a2 = b2;
48427         }
48428       })));
48429       return segments;
48430     };
48431   }
48432   function svgPath(projection2, graph, isArea) {
48433     var cache = {};
48434     var padding = isArea ? 65 : 5;
48435     var viewport = projection2.clipExtent();
48436     var paddedExtent = [
48437       [viewport[0][0] - padding, viewport[0][1] - padding],
48438       [viewport[1][0] + padding, viewport[1][1] + padding]
48439     ];
48440     var clip = identity_default2().clipExtent(paddedExtent).stream;
48441     var project = projection2.stream;
48442     var path = path_default().projection({ stream: function(output) {
48443       return project(clip(output));
48444     } });
48445     var svgpath = function(entity) {
48446       if (entity.id in cache) {
48447         return cache[entity.id];
48448       } else {
48449         return cache[entity.id] = path(entity.asGeoJSON(graph));
48450       }
48451     };
48452     svgpath.geojson = function(d2) {
48453       if (d2.__featurehash__ !== void 0) {
48454         if (d2.__featurehash__ in cache) {
48455           return cache[d2.__featurehash__];
48456         } else {
48457           return cache[d2.__featurehash__] = path(d2);
48458         }
48459       } else {
48460         return path(d2);
48461       }
48462     };
48463     return svgpath;
48464   }
48465   function svgPointTransform(projection2) {
48466     var svgpoint = function(entity) {
48467       var pt2 = projection2(entity.loc);
48468       return "translate(" + pt2[0] + "," + pt2[1] + ")";
48469     };
48470     svgpoint.geojson = function(d2) {
48471       return svgpoint(d2.properties.entity);
48472     };
48473     return svgpoint;
48474   }
48475   function svgRelationMemberTags(graph) {
48476     return function(entity) {
48477       var tags = entity.tags;
48478       var shouldCopyMultipolygonTags = !entity.hasInterestingTags();
48479       graph.parentRelations(entity).forEach(function(relation) {
48480         var type2 = relation.tags.type;
48481         if (type2 === "multipolygon" && shouldCopyMultipolygonTags || type2 === "boundary") {
48482           tags = Object.assign({}, relation.tags, tags);
48483         }
48484       });
48485       return tags;
48486     };
48487   }
48488   function svgSegmentWay(way, graph, activeID) {
48489     if (activeID === void 0) {
48490       return graph.transient(way, "waySegments", getWaySegments);
48491     } else {
48492       return getWaySegments();
48493     }
48494     function getWaySegments() {
48495       var isActiveWay = way.nodes.indexOf(activeID) !== -1;
48496       var features = { passive: [], active: [] };
48497       var start2 = {};
48498       var end = {};
48499       var node, type2;
48500       for (var i3 = 0; i3 < way.nodes.length; i3++) {
48501         node = graph.entity(way.nodes[i3]);
48502         type2 = svgPassiveVertex(node, graph, activeID);
48503         end = { node, type: type2 };
48504         if (start2.type !== void 0) {
48505           if (start2.node.id === activeID || end.node.id === activeID) {
48506           } else if (isActiveWay && (start2.type === 2 || end.type === 2)) {
48507             pushActive(start2, end, i3);
48508           } else if (start2.type === 0 && end.type === 0) {
48509             pushActive(start2, end, i3);
48510           } else {
48511             pushPassive(start2, end, i3);
48512           }
48513         }
48514         start2 = end;
48515       }
48516       return features;
48517       function pushActive(start3, end2, index) {
48518         features.active.push({
48519           type: "Feature",
48520           id: way.id + "-" + index + "-nope",
48521           properties: {
48522             nope: true,
48523             target: true,
48524             entity: way,
48525             nodes: [start3.node, end2.node],
48526             index
48527           },
48528           geometry: {
48529             type: "LineString",
48530             coordinates: [start3.node.loc, end2.node.loc]
48531           }
48532         });
48533       }
48534       function pushPassive(start3, end2, index) {
48535         features.passive.push({
48536           type: "Feature",
48537           id: way.id + "-" + index,
48538           properties: {
48539             target: true,
48540             entity: way,
48541             nodes: [start3.node, end2.node],
48542             index
48543           },
48544           geometry: {
48545             type: "LineString",
48546             coordinates: [start3.node.loc, end2.node.loc]
48547           }
48548         });
48549       }
48550     }
48551   }
48552
48553   // modules/svg/tag_classes.js
48554   function svgTagClasses() {
48555     var primaries = [
48556       "building",
48557       "highway",
48558       "railway",
48559       "waterway",
48560       "aeroway",
48561       "aerialway",
48562       "piste:type",
48563       "boundary",
48564       "power",
48565       "amenity",
48566       "natural",
48567       "landuse",
48568       "leisure",
48569       "military",
48570       "place",
48571       "man_made",
48572       "route",
48573       "attraction",
48574       "roller_coaster",
48575       "building:part",
48576       "indoor"
48577     ];
48578     var statuses = Object.keys(osmLifecyclePrefixes);
48579     var secondaries = [
48580       "oneway",
48581       "bridge",
48582       "tunnel",
48583       "embankment",
48584       "cutting",
48585       "barrier",
48586       "surface",
48587       "tracktype",
48588       "footway",
48589       "crossing",
48590       "service",
48591       "sport",
48592       "public_transport",
48593       "location",
48594       "parking",
48595       "golf",
48596       "type",
48597       "leisure",
48598       "man_made",
48599       "indoor",
48600       "construction",
48601       "proposed"
48602     ];
48603     var _tags = function(entity) {
48604       return entity.tags;
48605     };
48606     var tagClasses = function(selection2) {
48607       selection2.each(function tagClassesEach(entity) {
48608         var value = this.className;
48609         if (value.baseVal !== void 0) {
48610           value = value.baseVal;
48611         }
48612         var t2 = _tags(entity);
48613         var computed = tagClasses.getClassesString(t2, value);
48614         if (computed !== value) {
48615           select_default2(this).attr("class", computed);
48616         }
48617       });
48618     };
48619     tagClasses.getClassesString = function(t2, value) {
48620       var primary, status;
48621       var i3, j2, k2, v2;
48622       var overrideGeometry;
48623       if (/\bstroke\b/.test(value)) {
48624         if (!!t2.barrier && t2.barrier !== "no") {
48625           overrideGeometry = "line";
48626         }
48627       }
48628       var classes = value.trim().split(/\s+/).filter(function(klass) {
48629         return klass.length && !/^tag-/.test(klass);
48630       }).map(function(klass) {
48631         return klass === "line" || klass === "area" ? overrideGeometry || klass : klass;
48632       });
48633       for (i3 = 0; i3 < primaries.length; i3++) {
48634         k2 = primaries[i3];
48635         v2 = t2[k2];
48636         if (!v2 || v2 === "no") continue;
48637         if (k2 === "piste:type") {
48638           k2 = "piste";
48639         } else if (k2 === "building:part") {
48640           k2 = "building_part";
48641         }
48642         primary = k2;
48643         if (statuses.indexOf(v2) !== -1) {
48644           status = v2;
48645           classes.push("tag-" + k2);
48646         } else {
48647           classes.push("tag-" + k2);
48648           classes.push("tag-" + k2 + "-" + v2);
48649         }
48650         break;
48651       }
48652       if (!primary) {
48653         for (i3 = 0; i3 < statuses.length; i3++) {
48654           for (j2 = 0; j2 < primaries.length; j2++) {
48655             k2 = statuses[i3] + ":" + primaries[j2];
48656             v2 = t2[k2];
48657             if (!v2 || v2 === "no") continue;
48658             status = statuses[i3];
48659             break;
48660           }
48661         }
48662       }
48663       if (!status) {
48664         for (i3 = 0; i3 < statuses.length; i3++) {
48665           k2 = statuses[i3];
48666           v2 = t2[k2];
48667           if (!v2 || v2 === "no") continue;
48668           if (v2 === "yes") {
48669             status = k2;
48670           } else if (primary && primary === v2) {
48671             status = k2;
48672           } else if (!primary && primaries.indexOf(v2) !== -1) {
48673             status = k2;
48674             primary = v2;
48675             classes.push("tag-" + v2);
48676           }
48677           if (status) break;
48678         }
48679       }
48680       if (status) {
48681         classes.push("tag-status");
48682         classes.push("tag-status-" + status);
48683       }
48684       for (i3 = 0; i3 < secondaries.length; i3++) {
48685         k2 = secondaries[i3];
48686         v2 = t2[k2];
48687         if (!v2 || v2 === "no" || k2 === primary) continue;
48688         classes.push("tag-" + k2);
48689         classes.push("tag-" + k2 + "-" + v2);
48690       }
48691       if (primary === "highway" && !osmPathHighwayTagValues[t2.highway] || primary === "aeroway") {
48692         var surface = t2.highway === "track" ? "unpaved" : "paved";
48693         for (k2 in t2) {
48694           v2 = t2[k2];
48695           if (k2 in osmPavedTags) {
48696             surface = osmPavedTags[k2][v2] ? "paved" : "unpaved";
48697           }
48698           if (k2 in osmSemipavedTags && !!osmSemipavedTags[k2][v2]) {
48699             surface = "semipaved";
48700           }
48701         }
48702         classes.push("tag-" + surface);
48703       }
48704       var qid = t2.wikidata || t2["flag:wikidata"] || t2["brand:wikidata"] || t2["network:wikidata"] || t2["operator:wikidata"];
48705       if (qid) {
48706         classes.push("tag-wikidata");
48707       }
48708       return classes.filter((klass) => /^[-_a-z0-9]+$/.test(klass)).join(" ").trim();
48709     };
48710     tagClasses.tags = function(val) {
48711       if (!arguments.length) return _tags;
48712       _tags = val;
48713       return tagClasses;
48714     };
48715     return tagClasses;
48716   }
48717
48718   // modules/svg/tag_pattern.js
48719   var patterns = {
48720     // tag - pattern name
48721     // -or-
48722     // tag - value - pattern name
48723     // -or-
48724     // tag - value - rules (optional tag-values, pattern name)
48725     // (matches earlier rules first, so fallback should be last entry)
48726     amenity: {
48727       grave_yard: "cemetery",
48728       fountain: "water_standing"
48729     },
48730     landuse: {
48731       cemetery: [
48732         { religion: "christian", pattern: "cemetery_christian" },
48733         { religion: "buddhist", pattern: "cemetery_buddhist" },
48734         { religion: "muslim", pattern: "cemetery_muslim" },
48735         { religion: "jewish", pattern: "cemetery_jewish" },
48736         { pattern: "cemetery" }
48737       ],
48738       construction: "construction",
48739       farmland: "farmland",
48740       farmyard: "farmyard",
48741       forest: [
48742         { leaf_type: "broadleaved", pattern: "forest_broadleaved" },
48743         { leaf_type: "needleleaved", pattern: "forest_needleleaved" },
48744         { leaf_type: "leafless", pattern: "forest_leafless" },
48745         { pattern: "forest" }
48746         // same as 'leaf_type:mixed'
48747       ],
48748       grave_yard: "cemetery",
48749       grass: "grass",
48750       landfill: "landfill",
48751       meadow: "meadow",
48752       military: "construction",
48753       orchard: "orchard",
48754       quarry: "quarry",
48755       vineyard: "vineyard"
48756     },
48757     leisure: {
48758       horse_riding: "farmyard"
48759     },
48760     natural: {
48761       beach: "beach",
48762       grassland: "grass",
48763       sand: "beach",
48764       scrub: "scrub",
48765       water: [
48766         { water: "pond", pattern: "pond" },
48767         { water: "reservoir", pattern: "water_standing" },
48768         { pattern: "waves" }
48769       ],
48770       wetland: [
48771         { wetland: "marsh", pattern: "wetland_marsh" },
48772         { wetland: "swamp", pattern: "wetland_swamp" },
48773         { wetland: "bog", pattern: "wetland_bog" },
48774         { wetland: "reedbed", pattern: "wetland_reedbed" },
48775         { pattern: "wetland" }
48776       ],
48777       wood: [
48778         { leaf_type: "broadleaved", pattern: "forest_broadleaved" },
48779         { leaf_type: "needleleaved", pattern: "forest_needleleaved" },
48780         { leaf_type: "leafless", pattern: "forest_leafless" },
48781         { pattern: "forest" }
48782         // same as 'leaf_type:mixed'
48783       ]
48784     },
48785     golf: {
48786       green: "golf_green",
48787       tee: "grass",
48788       fairway: "grass",
48789       rough: "scrub"
48790     },
48791     surface: {
48792       grass: "grass",
48793       sand: "beach"
48794     }
48795   };
48796   function svgTagPattern(tags) {
48797     if (tags.building && tags.building !== "no") {
48798       return null;
48799     }
48800     for (var tag2 in patterns) {
48801       var entityValue = tags[tag2];
48802       if (!entityValue) continue;
48803       if (typeof patterns[tag2] === "string") {
48804         return "pattern-" + patterns[tag2];
48805       } else {
48806         var values = patterns[tag2];
48807         for (var value in values) {
48808           if (entityValue !== value) continue;
48809           var rules = values[value];
48810           if (typeof rules === "string") {
48811             return "pattern-" + rules;
48812           }
48813           for (var ruleKey in rules) {
48814             var rule = rules[ruleKey];
48815             var pass = true;
48816             for (var criterion in rule) {
48817               if (criterion !== "pattern") {
48818                 var v2 = tags[criterion];
48819                 if (!v2 || v2 !== rule[criterion]) {
48820                   pass = false;
48821                   break;
48822                 }
48823               }
48824             }
48825             if (pass) {
48826               return "pattern-" + rule.pattern;
48827             }
48828           }
48829         }
48830       }
48831     }
48832     return null;
48833   }
48834
48835   // modules/svg/areas.js
48836   function svgAreas(projection2, context) {
48837     function getPatternStyle(tags) {
48838       var imageID = svgTagPattern(tags);
48839       if (imageID) {
48840         return 'url("#ideditor-' + imageID + '")';
48841       }
48842       return "";
48843     }
48844     function drawTargets(selection2, graph, entities, filter2) {
48845       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
48846       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
48847       var getPath = svgPath(projection2).geojson;
48848       var activeID = context.activeID();
48849       var base = context.history().base();
48850       var data = { targets: [], nopes: [] };
48851       entities.forEach(function(way) {
48852         var features = svgSegmentWay(way, graph, activeID);
48853         data.targets.push.apply(data.targets, features.passive);
48854         data.nopes.push.apply(data.nopes, features.active);
48855       });
48856       var targetData = data.targets.filter(getPath);
48857       var targets = selection2.selectAll(".area.target-allowed").filter(function(d2) {
48858         return filter2(d2.properties.entity);
48859       }).data(targetData, function key(d2) {
48860         return d2.id;
48861       });
48862       targets.exit().remove();
48863       var segmentWasEdited = function(d2) {
48864         var wayID = d2.properties.entity.id;
48865         if (!base.entities[wayID] || !(0, import_fast_deep_equal5.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) {
48866           return false;
48867         }
48868         return d2.properties.nodes.some(function(n3) {
48869           return !base.entities[n3.id] || !(0, import_fast_deep_equal5.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc);
48870         });
48871       };
48872       targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) {
48873         return "way area target target-allowed " + targetClass + d2.id;
48874       }).classed("segment-edited", segmentWasEdited);
48875       var nopeData = data.nopes.filter(getPath);
48876       var nopes = selection2.selectAll(".area.target-nope").filter(function(d2) {
48877         return filter2(d2.properties.entity);
48878       }).data(nopeData, function key(d2) {
48879         return d2.id;
48880       });
48881       nopes.exit().remove();
48882       nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) {
48883         return "way area target target-nope " + nopeClass + d2.id;
48884       }).classed("segment-edited", segmentWasEdited);
48885     }
48886     function drawAreas(selection2, graph, entities, filter2) {
48887       var path = svgPath(projection2, graph, true);
48888       var areas = {};
48889       var base = context.history().base();
48890       for (var i3 = 0; i3 < entities.length; i3++) {
48891         var entity = entities[i3];
48892         if (entity.geometry(graph) !== "area") continue;
48893         if (!areas[entity.id]) {
48894           areas[entity.id] = {
48895             entity,
48896             area: Math.abs(entity.area(graph))
48897           };
48898         }
48899       }
48900       var fills = Object.values(areas).filter(function hasPath(a2) {
48901         return path(a2.entity);
48902       });
48903       fills.sort(function areaSort(a2, b2) {
48904         return b2.area - a2.area;
48905       });
48906       fills = fills.map(function(a2) {
48907         return a2.entity;
48908       });
48909       var strokes = fills.filter(function(area) {
48910         return area.type === "way";
48911       });
48912       var data = {
48913         clip: fills,
48914         shadow: strokes,
48915         stroke: strokes,
48916         fill: fills
48917       };
48918       var clipPaths = context.surface().selectAll("defs").selectAll(".clipPath-osm").filter(filter2).data(data.clip, osmEntity.key);
48919       clipPaths.exit().remove();
48920       var clipPathsEnter = clipPaths.enter().append("clipPath").attr("class", "clipPath-osm").attr("id", function(entity2) {
48921         return "ideditor-" + entity2.id + "-clippath";
48922       });
48923       clipPathsEnter.append("path");
48924       clipPaths.merge(clipPathsEnter).selectAll("path").attr("d", path);
48925       var drawLayer = selection2.selectAll(".layer-osm.areas");
48926       var touchLayer = selection2.selectAll(".layer-touch.areas");
48927       var areagroup = drawLayer.selectAll("g.areagroup").data(["fill", "shadow", "stroke"]);
48928       areagroup = areagroup.enter().append("g").attr("class", function(d2) {
48929         return "areagroup area-" + d2;
48930       }).merge(areagroup);
48931       var paths = areagroup.selectAll("path").filter(filter2).data(function(layer) {
48932         return data[layer];
48933       }, osmEntity.key);
48934       paths.exit().remove();
48935       var fillpaths = selection2.selectAll(".area-fill path.area").nodes();
48936       var bisect = bisector(function(node) {
48937         return -node.__data__.area(graph);
48938       }).left;
48939       function sortedByArea(entity2) {
48940         if (this._parent.__data__ === "fill") {
48941           return fillpaths[bisect(fillpaths, -entity2.area(graph))];
48942         }
48943       }
48944       paths = paths.enter().insert("path", sortedByArea).merge(paths).each(function(entity2) {
48945         var layer = this.parentNode.__data__;
48946         this.setAttribute("class", entity2.type + " area " + layer + " " + entity2.id);
48947         if (layer === "fill") {
48948           this.setAttribute("clip-path", "url(#ideditor-" + entity2.id + "-clippath)");
48949           this.style.fill = this.style.stroke = getPatternStyle(entity2.tags);
48950         }
48951       }).classed("added", function(d2) {
48952         return !base.entities[d2.id];
48953       }).classed("geometry-edited", function(d2) {
48954         return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal5.default)(graph.entities[d2.id].nodes, base.entities[d2.id].nodes);
48955       }).classed("retagged", function(d2) {
48956         return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal5.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
48957       }).call(svgTagClasses()).attr("d", path);
48958       touchLayer.call(drawTargets, graph, data.stroke, filter2);
48959     }
48960     return drawAreas;
48961   }
48962
48963   // modules/svg/data.js
48964   var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify());
48965
48966   // node_modules/@tmcw/togeojson/dist/togeojson.es.mjs
48967   function $(element, tagName) {
48968     return Array.from(element.getElementsByTagName(tagName));
48969   }
48970   function normalizeId(id2) {
48971     return id2[0] === "#" ? id2 : "#".concat(id2);
48972   }
48973   function $ns(element, tagName, ns) {
48974     return Array.from(element.getElementsByTagNameNS(ns, tagName));
48975   }
48976   function nodeVal(node) {
48977     node == null ? void 0 : node.normalize();
48978     return (node == null ? void 0 : node.textContent) || "";
48979   }
48980   function get1(node, tagName, callback) {
48981     const n3 = node.getElementsByTagName(tagName);
48982     const result = n3.length ? n3[0] : null;
48983     if (result && callback)
48984       callback(result);
48985     return result;
48986   }
48987   function get3(node, tagName, callback) {
48988     const properties = {};
48989     if (!node)
48990       return properties;
48991     const n3 = node.getElementsByTagName(tagName);
48992     const result = n3.length ? n3[0] : null;
48993     if (result && callback) {
48994       return callback(result, properties);
48995     }
48996     return properties;
48997   }
48998   function val1(node, tagName, callback) {
48999     const val = nodeVal(get1(node, tagName));
49000     if (val && callback)
49001       return callback(val) || {};
49002     return {};
49003   }
49004   function $num(node, tagName, callback) {
49005     const val = Number.parseFloat(nodeVal(get1(node, tagName)));
49006     if (Number.isNaN(val))
49007       return void 0;
49008     if (val && callback)
49009       return callback(val) || {};
49010     return {};
49011   }
49012   function num1(node, tagName, callback) {
49013     const val = Number.parseFloat(nodeVal(get1(node, tagName)));
49014     if (Number.isNaN(val))
49015       return void 0;
49016     if (callback)
49017       callback(val);
49018     return val;
49019   }
49020   function getMulti(node, propertyNames) {
49021     const properties = {};
49022     for (const property of propertyNames) {
49023       val1(node, property, (val) => {
49024         properties[property] = val;
49025       });
49026     }
49027     return properties;
49028   }
49029   function isElement(node) {
49030     return (node == null ? void 0 : node.nodeType) === 1;
49031   }
49032   function getExtensions(node) {
49033     let values = [];
49034     if (node === null)
49035       return values;
49036     for (const child of Array.from(node.childNodes)) {
49037       if (!isElement(child))
49038         continue;
49039       const name = abbreviateName(child.nodeName);
49040       if (name === "gpxtpx:TrackPointExtension") {
49041         values = values.concat(getExtensions(child));
49042       } else {
49043         const val = nodeVal(child);
49044         values.push([name, parseNumeric(val)]);
49045       }
49046     }
49047     return values;
49048   }
49049   function abbreviateName(name) {
49050     return ["heart", "gpxtpx:hr", "hr"].includes(name) ? "heart" : name;
49051   }
49052   function parseNumeric(val) {
49053     const num = Number.parseFloat(val);
49054     return Number.isNaN(num) ? val : num;
49055   }
49056   function coordPair$1(node) {
49057     const ll = [
49058       Number.parseFloat(node.getAttribute("lon") || ""),
49059       Number.parseFloat(node.getAttribute("lat") || "")
49060     ];
49061     if (Number.isNaN(ll[0]) || Number.isNaN(ll[1])) {
49062       return null;
49063     }
49064     num1(node, "ele", (val) => {
49065       ll.push(val);
49066     });
49067     const time = get1(node, "time");
49068     return {
49069       coordinates: ll,
49070       time: time ? nodeVal(time) : null,
49071       extendedValues: getExtensions(get1(node, "extensions"))
49072     };
49073   }
49074   function getLineStyle(node) {
49075     return get3(node, "line", (lineStyle) => {
49076       const val = Object.assign({}, val1(lineStyle, "color", (color2) => {
49077         return { stroke: "#".concat(color2) };
49078       }), $num(lineStyle, "opacity", (opacity) => {
49079         return { "stroke-opacity": opacity };
49080       }), $num(lineStyle, "width", (width) => {
49081         return { "stroke-width": width * 96 / 25.4 };
49082       }));
49083       return val;
49084     });
49085   }
49086   function extractProperties(ns, node) {
49087     var _a4;
49088     const properties = getMulti(node, [
49089       "name",
49090       "cmt",
49091       "desc",
49092       "type",
49093       "time",
49094       "keywords"
49095     ]);
49096     for (const [n3, url] of ns) {
49097       for (const child of Array.from(node.getElementsByTagNameNS(url, "*"))) {
49098         properties[child.tagName.replace(":", "_")] = (_a4 = nodeVal(child)) == null ? void 0 : _a4.trim();
49099       }
49100     }
49101     const links = $(node, "link");
49102     if (links.length) {
49103       properties.links = links.map((link3) => Object.assign({ href: link3.getAttribute("href") }, getMulti(link3, ["text", "type"])));
49104     }
49105     return properties;
49106   }
49107   function getPoints$1(node, pointname) {
49108     const pts = $(node, pointname);
49109     const line = [];
49110     const times = [];
49111     const extendedValues = {};
49112     for (let i3 = 0; i3 < pts.length; i3++) {
49113       const c2 = coordPair$1(pts[i3]);
49114       if (!c2) {
49115         continue;
49116       }
49117       line.push(c2.coordinates);
49118       if (c2.time)
49119         times.push(c2.time);
49120       for (const [name, val] of c2.extendedValues) {
49121         const plural = name === "heart" ? name : "".concat(name.replace("gpxtpx:", ""), "s");
49122         if (!extendedValues[plural]) {
49123           extendedValues[plural] = Array(pts.length).fill(null);
49124         }
49125         extendedValues[plural][i3] = val;
49126       }
49127     }
49128     if (line.length < 2)
49129       return;
49130     return {
49131       line,
49132       times,
49133       extendedValues
49134     };
49135   }
49136   function getRoute(ns, node) {
49137     const line = getPoints$1(node, "rtept");
49138     if (!line)
49139       return;
49140     return {
49141       type: "Feature",
49142       properties: Object.assign({ _gpxType: "rte" }, extractProperties(ns, node), getLineStyle(get1(node, "extensions"))),
49143       geometry: {
49144         type: "LineString",
49145         coordinates: line.line
49146       }
49147     };
49148   }
49149   function getTrack(ns, node) {
49150     var _a4;
49151     const segments = $(node, "trkseg");
49152     const track = [];
49153     const times = [];
49154     const extractedLines = [];
49155     for (const segment of segments) {
49156       const line = getPoints$1(segment, "trkpt");
49157       if (line) {
49158         extractedLines.push(line);
49159         if ((_a4 = line.times) == null ? void 0 : _a4.length)
49160           times.push(line.times);
49161       }
49162     }
49163     if (extractedLines.length === 0)
49164       return null;
49165     const multi = extractedLines.length > 1;
49166     const properties = Object.assign({ _gpxType: "trk" }, extractProperties(ns, node), getLineStyle(get1(node, "extensions")), times.length ? {
49167       coordinateProperties: {
49168         times: multi ? times : times[0]
49169       }
49170     } : {});
49171     for (const line of extractedLines) {
49172       track.push(line.line);
49173       if (!properties.coordinateProperties) {
49174         properties.coordinateProperties = {};
49175       }
49176       const props = properties.coordinateProperties;
49177       const entries = Object.entries(line.extendedValues);
49178       for (let i3 = 0; i3 < entries.length; i3++) {
49179         const [name, val] = entries[i3];
49180         if (multi) {
49181           if (!props[name]) {
49182             props[name] = extractedLines.map((line2) => new Array(line2.line.length).fill(null));
49183           }
49184           props[name][i3] = val;
49185         } else {
49186           props[name] = val;
49187         }
49188       }
49189     }
49190     return {
49191       type: "Feature",
49192       properties,
49193       geometry: multi ? {
49194         type: "MultiLineString",
49195         coordinates: track
49196       } : {
49197         type: "LineString",
49198         coordinates: track[0]
49199       }
49200     };
49201   }
49202   function getPoint(ns, node) {
49203     const properties = Object.assign(extractProperties(ns, node), getMulti(node, ["sym"]));
49204     const pair3 = coordPair$1(node);
49205     if (!pair3)
49206       return null;
49207     return {
49208       type: "Feature",
49209       properties,
49210       geometry: {
49211         type: "Point",
49212         coordinates: pair3.coordinates
49213       }
49214     };
49215   }
49216   function* gpxGen(node) {
49217     var _a4, _b3;
49218     const GPXX = "gpxx";
49219     const GPXX_URI = "http://www.garmin.com/xmlschemas/GpxExtensions/v3";
49220     const ns = [[GPXX, GPXX_URI]];
49221     const attrs = (_a4 = node.getElementsByTagName("gpx")[0]) == null ? void 0 : _a4.attributes;
49222     if (attrs) {
49223       for (const attr of Array.from(attrs)) {
49224         if (((_b3 = attr.name) == null ? void 0 : _b3.startsWith("xmlns:")) && attr.value !== GPXX_URI) {
49225           ns.push([attr.name, attr.value]);
49226         }
49227       }
49228     }
49229     for (const track of $(node, "trk")) {
49230       const feature3 = getTrack(ns, track);
49231       if (feature3)
49232         yield feature3;
49233     }
49234     for (const route of $(node, "rte")) {
49235       const feature3 = getRoute(ns, route);
49236       if (feature3)
49237         yield feature3;
49238     }
49239     for (const waypoint of $(node, "wpt")) {
49240       const point = getPoint(ns, waypoint);
49241       if (point)
49242         yield point;
49243     }
49244   }
49245   function gpx(node) {
49246     return {
49247       type: "FeatureCollection",
49248       features: Array.from(gpxGen(node))
49249     };
49250   }
49251   function fixColor(v2, prefix) {
49252     const properties = {};
49253     const colorProp = prefix === "stroke" || prefix === "fill" ? prefix : "".concat(prefix, "-color");
49254     if (v2[0] === "#") {
49255       v2 = v2.substring(1);
49256     }
49257     if (v2.length === 6 || v2.length === 3) {
49258       properties[colorProp] = "#".concat(v2);
49259     } else if (v2.length === 8) {
49260       properties["".concat(prefix, "-opacity")] = Number.parseInt(v2.substring(0, 2), 16) / 255;
49261       properties[colorProp] = "#".concat(v2.substring(6, 8)).concat(v2.substring(4, 6)).concat(v2.substring(2, 4));
49262     }
49263     return properties;
49264   }
49265   function numericProperty(node, source, target) {
49266     const properties = {};
49267     num1(node, source, (val) => {
49268       properties[target] = val;
49269     });
49270     return properties;
49271   }
49272   function getColor(node, output) {
49273     return get3(node, "color", (elem) => fixColor(nodeVal(elem), output));
49274   }
49275   function extractIconHref(node) {
49276     return get3(node, "Icon", (icon2, properties) => {
49277       val1(icon2, "href", (href) => {
49278         properties.icon = href;
49279       });
49280       return properties;
49281     });
49282   }
49283   function extractIcon(node) {
49284     return get3(node, "IconStyle", (iconStyle) => {
49285       return Object.assign(getColor(iconStyle, "icon"), numericProperty(iconStyle, "scale", "icon-scale"), numericProperty(iconStyle, "heading", "icon-heading"), get3(iconStyle, "hotSpot", (hotspot) => {
49286         const left = Number.parseFloat(hotspot.getAttribute("x") || "");
49287         const top = Number.parseFloat(hotspot.getAttribute("y") || "");
49288         const xunits = hotspot.getAttribute("xunits") || "";
49289         const yunits = hotspot.getAttribute("yunits") || "";
49290         if (!Number.isNaN(left) && !Number.isNaN(top))
49291           return {
49292             "icon-offset": [left, top],
49293             "icon-offset-units": [xunits, yunits]
49294           };
49295         return {};
49296       }), extractIconHref(iconStyle));
49297     });
49298   }
49299   function extractLabel(node) {
49300     return get3(node, "LabelStyle", (labelStyle) => {
49301       return Object.assign(getColor(labelStyle, "label"), numericProperty(labelStyle, "scale", "label-scale"));
49302     });
49303   }
49304   function extractLine(node) {
49305     return get3(node, "LineStyle", (lineStyle) => {
49306       return Object.assign(getColor(lineStyle, "stroke"), numericProperty(lineStyle, "width", "stroke-width"));
49307     });
49308   }
49309   function extractPoly(node) {
49310     return get3(node, "PolyStyle", (polyStyle, properties) => {
49311       return Object.assign(properties, get3(polyStyle, "color", (elem) => fixColor(nodeVal(elem), "fill")), val1(polyStyle, "fill", (fill) => {
49312         if (fill === "0")
49313           return { "fill-opacity": 0 };
49314       }), val1(polyStyle, "outline", (outline) => {
49315         if (outline === "0")
49316           return { "stroke-opacity": 0 };
49317       }));
49318     });
49319   }
49320   function extractStyle(node) {
49321     return Object.assign({}, extractPoly(node), extractLine(node), extractLabel(node), extractIcon(node));
49322   }
49323   var removeSpace = /\s*/g;
49324   var trimSpace = /^\s*|\s*$/g;
49325   var splitSpace = /\s+/;
49326   function coord1(value) {
49327     return value.replace(removeSpace, "").split(",").map(Number.parseFloat).filter((num) => !Number.isNaN(num)).slice(0, 3);
49328   }
49329   function coord(value) {
49330     return value.replace(trimSpace, "").split(splitSpace).map(coord1).filter((coord2) => {
49331       return coord2.length >= 2;
49332     });
49333   }
49334   function gxCoords(node) {
49335     let elems = $(node, "coord");
49336     if (elems.length === 0) {
49337       elems = $ns(node, "coord", "*");
49338     }
49339     const coordinates = elems.map((elem) => {
49340       return nodeVal(elem).split(" ").map(Number.parseFloat);
49341     });
49342     if (coordinates.length === 0) {
49343       return null;
49344     }
49345     return {
49346       geometry: coordinates.length > 2 ? {
49347         type: "LineString",
49348         coordinates
49349       } : {
49350         type: "Point",
49351         coordinates: coordinates[0]
49352       },
49353       times: $(node, "when").map((elem) => nodeVal(elem))
49354     };
49355   }
49356   function fixRing(ring) {
49357     if (ring.length === 0)
49358       return ring;
49359     const first = ring[0];
49360     const last = ring[ring.length - 1];
49361     let equal = true;
49362     for (let i3 = 0; i3 < Math.max(first.length, last.length); i3++) {
49363       if (first[i3] !== last[i3]) {
49364         equal = false;
49365         break;
49366       }
49367     }
49368     if (!equal) {
49369       return ring.concat([ring[0]]);
49370     }
49371     return ring;
49372   }
49373   function getCoordinates(node) {
49374     return nodeVal(get1(node, "coordinates"));
49375   }
49376   function getGeometry(node) {
49377     let geometries = [];
49378     let coordTimes = [];
49379     for (let i3 = 0; i3 < node.childNodes.length; i3++) {
49380       const child = node.childNodes.item(i3);
49381       if (isElement(child)) {
49382         switch (child.tagName) {
49383           case "MultiGeometry":
49384           case "MultiTrack":
49385           case "gx:MultiTrack": {
49386             const childGeometries = getGeometry(child);
49387             geometries = geometries.concat(childGeometries.geometries);
49388             coordTimes = coordTimes.concat(childGeometries.coordTimes);
49389             break;
49390           }
49391           case "Point": {
49392             const coordinates = coord1(getCoordinates(child));
49393             if (coordinates.length >= 2) {
49394               geometries.push({
49395                 type: "Point",
49396                 coordinates
49397               });
49398             }
49399             break;
49400           }
49401           case "LinearRing":
49402           case "LineString": {
49403             const coordinates = coord(getCoordinates(child));
49404             if (coordinates.length >= 2) {
49405               geometries.push({
49406                 type: "LineString",
49407                 coordinates
49408               });
49409             }
49410             break;
49411           }
49412           case "Polygon": {
49413             const coords = [];
49414             for (const linearRing of $(child, "LinearRing")) {
49415               const ring = fixRing(coord(getCoordinates(linearRing)));
49416               if (ring.length >= 4) {
49417                 coords.push(ring);
49418               }
49419             }
49420             if (coords.length) {
49421               geometries.push({
49422                 type: "Polygon",
49423                 coordinates: coords
49424               });
49425             }
49426             break;
49427           }
49428           case "Track":
49429           case "gx:Track": {
49430             const gx = gxCoords(child);
49431             if (!gx)
49432               break;
49433             const { times, geometry } = gx;
49434             geometries.push(geometry);
49435             if (times.length)
49436               coordTimes.push(times);
49437             break;
49438           }
49439         }
49440       }
49441     }
49442     return {
49443       geometries,
49444       coordTimes
49445     };
49446   }
49447   var toNumber2 = (x2) => Number(x2);
49448   var typeConverters = {
49449     string: (x2) => x2,
49450     int: toNumber2,
49451     uint: toNumber2,
49452     short: toNumber2,
49453     ushort: toNumber2,
49454     float: toNumber2,
49455     double: toNumber2,
49456     bool: (x2) => Boolean(x2)
49457   };
49458   function extractExtendedData(node, schema) {
49459     return get3(node, "ExtendedData", (extendedData, properties) => {
49460       for (const data of $(extendedData, "Data")) {
49461         properties[data.getAttribute("name") || ""] = nodeVal(get1(data, "value"));
49462       }
49463       for (const simpleData of $(extendedData, "SimpleData")) {
49464         const name = simpleData.getAttribute("name") || "";
49465         const typeConverter = schema[name] || typeConverters.string;
49466         properties[name] = typeConverter(nodeVal(simpleData));
49467       }
49468       return properties;
49469     });
49470   }
49471   function getMaybeHTMLDescription(node) {
49472     const descriptionNode = get1(node, "description");
49473     for (const c2 of Array.from((descriptionNode == null ? void 0 : descriptionNode.childNodes) || [])) {
49474       if (c2.nodeType === 4) {
49475         return {
49476           description: {
49477             "@type": "html",
49478             value: nodeVal(c2)
49479           }
49480         };
49481       }
49482     }
49483     return {};
49484   }
49485   function extractTimeSpan(node) {
49486     return get3(node, "TimeSpan", (timeSpan) => {
49487       return {
49488         timespan: {
49489           begin: nodeVal(get1(timeSpan, "begin")),
49490           end: nodeVal(get1(timeSpan, "end"))
49491         }
49492       };
49493     });
49494   }
49495   function extractTimeStamp(node) {
49496     return get3(node, "TimeStamp", (timeStamp) => {
49497       return { timestamp: nodeVal(get1(timeStamp, "when")) };
49498     });
49499   }
49500   function extractCascadedStyle(node, styleMap) {
49501     return val1(node, "styleUrl", (styleUrl) => {
49502       styleUrl = normalizeId(styleUrl);
49503       if (styleMap[styleUrl]) {
49504         return Object.assign({ styleUrl }, styleMap[styleUrl]);
49505       }
49506       return { styleUrl };
49507     });
49508   }
49509   function getGroundOverlayBox(node) {
49510     const latLonQuad = get1(node, "gx:LatLonQuad");
49511     if (latLonQuad) {
49512       const ring = fixRing(coord(getCoordinates(node)));
49513       return {
49514         geometry: {
49515           type: "Polygon",
49516           coordinates: [ring]
49517         }
49518       };
49519     }
49520     return getLatLonBox(node);
49521   }
49522   var DEGREES_TO_RADIANS = Math.PI / 180;
49523   function rotateBox(bbox2, coordinates, rotation) {
49524     const center = [(bbox2[0] + bbox2[2]) / 2, (bbox2[1] + bbox2[3]) / 2];
49525     return [
49526       coordinates[0].map((coordinate) => {
49527         const dy = coordinate[1] - center[1];
49528         const dx = coordinate[0] - center[0];
49529         const distance = Math.sqrt(dy ** 2 + dx ** 2);
49530         const angle2 = Math.atan2(dy, dx) + rotation * DEGREES_TO_RADIANS;
49531         return [
49532           center[0] + Math.cos(angle2) * distance,
49533           center[1] + Math.sin(angle2) * distance
49534         ];
49535       })
49536     ];
49537   }
49538   function getLatLonBox(node) {
49539     const latLonBox = get1(node, "LatLonBox");
49540     if (latLonBox) {
49541       const north = num1(latLonBox, "north");
49542       const west = num1(latLonBox, "west");
49543       const east = num1(latLonBox, "east");
49544       const south = num1(latLonBox, "south");
49545       const rotation = num1(latLonBox, "rotation");
49546       if (typeof north === "number" && typeof south === "number" && typeof west === "number" && typeof east === "number") {
49547         const bbox2 = [west, south, east, north];
49548         let coordinates = [
49549           [
49550             [west, north],
49551             // top left
49552             [east, north],
49553             // top right
49554             [east, south],
49555             // top right
49556             [west, south],
49557             // bottom left
49558             [west, north]
49559             // top left (again)
49560           ]
49561         ];
49562         if (typeof rotation === "number") {
49563           coordinates = rotateBox(bbox2, coordinates, rotation);
49564         }
49565         return {
49566           bbox: bbox2,
49567           geometry: {
49568             type: "Polygon",
49569             coordinates
49570           }
49571         };
49572       }
49573     }
49574     return null;
49575   }
49576   function getGroundOverlay(node, styleMap, schema, options2) {
49577     var _a4;
49578     const box = getGroundOverlayBox(node);
49579     const geometry = (box == null ? void 0 : box.geometry) || null;
49580     if (!geometry && options2.skipNullGeometry) {
49581       return null;
49582     }
49583     const feature3 = {
49584       type: "Feature",
49585       geometry,
49586       properties: Object.assign(
49587         /**
49588          * Related to
49589          * https://gist.github.com/tmcw/037a1cb6660d74a392e9da7446540f46
49590          */
49591         { "@geometry-type": "groundoverlay" },
49592         getMulti(node, [
49593           "name",
49594           "address",
49595           "visibility",
49596           "open",
49597           "phoneNumber",
49598           "description"
49599         ]),
49600         getMaybeHTMLDescription(node),
49601         extractCascadedStyle(node, styleMap),
49602         extractStyle(node),
49603         extractIconHref(node),
49604         extractExtendedData(node, schema),
49605         extractTimeSpan(node),
49606         extractTimeStamp(node)
49607       )
49608     };
49609     if (box == null ? void 0 : box.bbox) {
49610       feature3.bbox = box.bbox;
49611     }
49612     if (((_a4 = feature3.properties) == null ? void 0 : _a4.visibility) !== void 0) {
49613       feature3.properties.visibility = feature3.properties.visibility !== "0";
49614     }
49615     const id2 = node.getAttribute("id");
49616     if (id2 !== null && id2 !== "")
49617       feature3.id = id2;
49618     return feature3;
49619   }
49620   function geometryListToGeometry(geometries) {
49621     return geometries.length === 0 ? null : geometries.length === 1 ? geometries[0] : {
49622       type: "GeometryCollection",
49623       geometries
49624     };
49625   }
49626   function getPlacemark(node, styleMap, schema, options2) {
49627     var _a4;
49628     const { coordTimes, geometries } = getGeometry(node);
49629     const geometry = geometryListToGeometry(geometries);
49630     if (!geometry && options2.skipNullGeometry) {
49631       return null;
49632     }
49633     const feature3 = {
49634       type: "Feature",
49635       geometry,
49636       properties: Object.assign(getMulti(node, [
49637         "name",
49638         "address",
49639         "visibility",
49640         "open",
49641         "phoneNumber",
49642         "description"
49643       ]), getMaybeHTMLDescription(node), extractCascadedStyle(node, styleMap), extractStyle(node), extractExtendedData(node, schema), extractTimeSpan(node), extractTimeStamp(node), coordTimes.length ? {
49644         coordinateProperties: {
49645           times: coordTimes.length === 1 ? coordTimes[0] : coordTimes
49646         }
49647       } : {})
49648     };
49649     if (((_a4 = feature3.properties) == null ? void 0 : _a4.visibility) !== void 0) {
49650       feature3.properties.visibility = feature3.properties.visibility !== "0";
49651     }
49652     const id2 = node.getAttribute("id");
49653     if (id2 !== null && id2 !== "")
49654       feature3.id = id2;
49655     return feature3;
49656   }
49657   function getStyleId(style) {
49658     let id2 = style.getAttribute("id");
49659     const parentNode = style.parentNode;
49660     if (!id2 && isElement(parentNode) && parentNode.localName === "CascadingStyle") {
49661       id2 = parentNode.getAttribute("kml:id") || parentNode.getAttribute("id");
49662     }
49663     return normalizeId(id2 || "");
49664   }
49665   function buildStyleMap(node) {
49666     const styleMap = {};
49667     for (const style of $(node, "Style")) {
49668       styleMap[getStyleId(style)] = extractStyle(style);
49669     }
49670     for (const map2 of $(node, "StyleMap")) {
49671       const id2 = normalizeId(map2.getAttribute("id") || "");
49672       val1(map2, "styleUrl", (styleUrl) => {
49673         styleUrl = normalizeId(styleUrl);
49674         if (styleMap[styleUrl]) {
49675           styleMap[id2] = styleMap[styleUrl];
49676         }
49677       });
49678     }
49679     return styleMap;
49680   }
49681   function buildSchema(node) {
49682     const schema = {};
49683     for (const field of $(node, "SimpleField")) {
49684       schema[field.getAttribute("name") || ""] = typeConverters[field.getAttribute("type") || ""] || typeConverters.string;
49685     }
49686     return schema;
49687   }
49688   function* kmlGen(node, options2 = {
49689     skipNullGeometry: false
49690   }) {
49691     const styleMap = buildStyleMap(node);
49692     const schema = buildSchema(node);
49693     for (const placemark of $(node, "Placemark")) {
49694       const feature3 = getPlacemark(placemark, styleMap, schema, options2);
49695       if (feature3)
49696         yield feature3;
49697     }
49698     for (const groundOverlay of $(node, "GroundOverlay")) {
49699       const feature3 = getGroundOverlay(groundOverlay, styleMap, schema, options2);
49700       if (feature3)
49701         yield feature3;
49702     }
49703   }
49704   function kml(node, options2 = {
49705     skipNullGeometry: false
49706   }) {
49707     return {
49708       type: "FeatureCollection",
49709       features: Array.from(kmlGen(node, options2))
49710     };
49711   }
49712
49713   // modules/svg/data.js
49714   var _initialized = false;
49715   var _enabled = false;
49716   var _geojson;
49717   function svgData(projection2, context, dispatch14) {
49718     var throttledRedraw = throttle_default(function() {
49719       dispatch14.call("change");
49720     }, 1e3);
49721     var _showLabels = true;
49722     var detected = utilDetect();
49723     var layer = select_default2(null);
49724     var _vtService;
49725     var _fileList;
49726     var _template;
49727     var _src;
49728     const supportedFormats = [
49729       ".gpx",
49730       ".kml",
49731       ".geojson",
49732       ".json"
49733     ];
49734     function init2() {
49735       if (_initialized) return;
49736       _geojson = {};
49737       _enabled = true;
49738       function over(d3_event) {
49739         d3_event.stopPropagation();
49740         d3_event.preventDefault();
49741         d3_event.dataTransfer.dropEffect = "copy";
49742       }
49743       context.container().attr("dropzone", "copy").on("drop.svgData", function(d3_event) {
49744         d3_event.stopPropagation();
49745         d3_event.preventDefault();
49746         if (!detected.filedrop) return;
49747         var f2 = d3_event.dataTransfer.files[0];
49748         var extension = getExtension(f2.name);
49749         if (!supportedFormats.includes(extension)) return;
49750         drawData.fileList(d3_event.dataTransfer.files);
49751       }).on("dragenter.svgData", over).on("dragexit.svgData", over).on("dragover.svgData", over);
49752       _initialized = true;
49753     }
49754     function getService() {
49755       if (services.vectorTile && !_vtService) {
49756         _vtService = services.vectorTile;
49757         _vtService.event.on("loadedData", throttledRedraw);
49758       } else if (!services.vectorTile && _vtService) {
49759         _vtService = null;
49760       }
49761       return _vtService;
49762     }
49763     function showLayer() {
49764       layerOn();
49765       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
49766         dispatch14.call("change");
49767       });
49768     }
49769     function hideLayer() {
49770       throttledRedraw.cancel();
49771       layer.transition().duration(250).style("opacity", 0).on("end", layerOff);
49772     }
49773     function layerOn() {
49774       layer.style("display", "block");
49775     }
49776     function layerOff() {
49777       layer.selectAll(".viewfield-group").remove();
49778       layer.style("display", "none");
49779     }
49780     function ensureIDs(gj) {
49781       if (!gj) return null;
49782       if (gj.type === "FeatureCollection") {
49783         for (var i3 = 0; i3 < gj.features.length; i3++) {
49784           ensureFeatureID(gj.features[i3]);
49785         }
49786       } else {
49787         ensureFeatureID(gj);
49788       }
49789       return gj;
49790     }
49791     function ensureFeatureID(feature3) {
49792       if (!feature3) return;
49793       feature3.__featurehash__ = utilHashcode((0, import_fast_json_stable_stringify.default)(feature3));
49794       return feature3;
49795     }
49796     function getFeatures(gj) {
49797       if (!gj) return [];
49798       if (gj.type === "FeatureCollection") {
49799         return gj.features;
49800       } else {
49801         return [gj];
49802       }
49803     }
49804     function featureKey(d2) {
49805       return d2.__featurehash__;
49806     }
49807     function isPolygon(d2) {
49808       return d2.geometry.type === "Polygon" || d2.geometry.type === "MultiPolygon";
49809     }
49810     function clipPathID(d2) {
49811       return "ideditor-data-" + d2.__featurehash__ + "-clippath";
49812     }
49813     function featureClasses(d2) {
49814       return [
49815         "data" + d2.__featurehash__,
49816         d2.geometry.type,
49817         isPolygon(d2) ? "area" : "",
49818         d2.__layerID__ || ""
49819       ].filter(Boolean).join(" ");
49820     }
49821     function drawData(selection2) {
49822       var vtService = getService();
49823       var getPath = svgPath(projection2).geojson;
49824       var getAreaPath = svgPath(projection2, null, true).geojson;
49825       var hasData = drawData.hasData();
49826       layer = selection2.selectAll(".layer-mapdata").data(_enabled && hasData ? [0] : []);
49827       layer.exit().remove();
49828       layer = layer.enter().append("g").attr("class", "layer-mapdata").merge(layer);
49829       var surface = context.surface();
49830       if (!surface || surface.empty()) return;
49831       var geoData, polygonData;
49832       if (_template && vtService) {
49833         var sourceID = _template;
49834         vtService.loadTiles(sourceID, _template, projection2);
49835         geoData = vtService.data(sourceID, projection2);
49836       } else {
49837         geoData = getFeatures(_geojson);
49838       }
49839       geoData = geoData.filter(getPath);
49840       polygonData = geoData.filter(isPolygon);
49841       var clipPaths = surface.selectAll("defs").selectAll(".clipPath-data").data(polygonData, featureKey);
49842       clipPaths.exit().remove();
49843       var clipPathsEnter = clipPaths.enter().append("clipPath").attr("class", "clipPath-data").attr("id", clipPathID);
49844       clipPathsEnter.append("path");
49845       clipPaths.merge(clipPathsEnter).selectAll("path").attr("d", getAreaPath);
49846       var datagroups = layer.selectAll("g.datagroup").data(["fill", "shadow", "stroke"]);
49847       datagroups = datagroups.enter().append("g").attr("class", function(d2) {
49848         return "datagroup datagroup-" + d2;
49849       }).merge(datagroups);
49850       var pathData = {
49851         fill: polygonData,
49852         shadow: geoData,
49853         stroke: geoData
49854       };
49855       var paths = datagroups.selectAll("path").data(function(layer2) {
49856         return pathData[layer2];
49857       }, featureKey);
49858       paths.exit().remove();
49859       paths = paths.enter().append("path").attr("class", function(d2) {
49860         var datagroup = this.parentNode.__data__;
49861         return "pathdata " + datagroup + " " + featureClasses(d2);
49862       }).attr("clip-path", function(d2) {
49863         var datagroup = this.parentNode.__data__;
49864         return datagroup === "fill" ? "url(#" + clipPathID(d2) + ")" : null;
49865       }).merge(paths).attr("d", function(d2) {
49866         var datagroup = this.parentNode.__data__;
49867         return datagroup === "fill" ? getAreaPath(d2) : getPath(d2);
49868       });
49869       layer.call(drawLabels, "label-halo", geoData).call(drawLabels, "label", geoData);
49870       function drawLabels(selection3, textClass, data) {
49871         var labelPath = path_default(projection2);
49872         var labelData = data.filter(function(d2) {
49873           return _showLabels && d2.properties && (d2.properties.desc || d2.properties.name);
49874         });
49875         var labels = selection3.selectAll("text." + textClass).data(labelData, featureKey);
49876         labels.exit().remove();
49877         labels = labels.enter().append("text").attr("class", function(d2) {
49878           return textClass + " " + featureClasses(d2);
49879         }).merge(labels).text(function(d2) {
49880           return d2.properties.desc || d2.properties.name;
49881         }).attr("x", function(d2) {
49882           var centroid = labelPath.centroid(d2);
49883           return centroid[0] + 11;
49884         }).attr("y", function(d2) {
49885           var centroid = labelPath.centroid(d2);
49886           return centroid[1];
49887         });
49888       }
49889     }
49890     function getExtension(fileName) {
49891       if (!fileName) return;
49892       var re3 = /\.(gpx|kml|(geo)?json|png)$/i;
49893       var match = fileName.toLowerCase().match(re3);
49894       return match && match.length && match[0];
49895     }
49896     function xmlToDom(textdata) {
49897       return new DOMParser().parseFromString(textdata, "text/xml");
49898     }
49899     function stringifyGeojsonProperties(feature3) {
49900       const properties = feature3.properties;
49901       for (const key in properties) {
49902         const property = properties[key];
49903         if (typeof property === "number" || typeof property === "boolean" || Array.isArray(property)) {
49904           properties[key] = property.toString();
49905         } else if (property === null) {
49906           properties[key] = "null";
49907         } else if (typeof property === "object") {
49908           properties[key] = JSON.stringify(property);
49909         }
49910       }
49911     }
49912     drawData.setFile = function(extension, data) {
49913       _template = null;
49914       _fileList = null;
49915       _geojson = null;
49916       _src = null;
49917       var gj;
49918       switch (extension) {
49919         case ".gpx":
49920           gj = gpx(xmlToDom(data));
49921           break;
49922         case ".kml":
49923           gj = kml(xmlToDom(data));
49924           break;
49925         case ".geojson":
49926         case ".json":
49927           gj = JSON.parse(data);
49928           if (gj.type === "FeatureCollection") {
49929             gj.features.forEach(stringifyGeojsonProperties);
49930           } else if (gj.type === "Feature") {
49931             stringifyGeojsonProperties(gj);
49932           }
49933           break;
49934       }
49935       gj = gj || {};
49936       if (Object.keys(gj).length) {
49937         _geojson = ensureIDs(gj);
49938         _src = extension + " data file";
49939         this.fitZoom();
49940       }
49941       dispatch14.call("change");
49942       return this;
49943     };
49944     drawData.showLabels = function(val) {
49945       if (!arguments.length) return _showLabels;
49946       _showLabels = val;
49947       return this;
49948     };
49949     drawData.enabled = function(val) {
49950       if (!arguments.length) return _enabled;
49951       _enabled = val;
49952       if (_enabled) {
49953         showLayer();
49954       } else {
49955         hideLayer();
49956       }
49957       dispatch14.call("change");
49958       return this;
49959     };
49960     drawData.hasData = function() {
49961       var gj = _geojson || {};
49962       return !!(_template || Object.keys(gj).length);
49963     };
49964     drawData.template = function(val, src) {
49965       if (!arguments.length) return _template;
49966       var osm = context.connection();
49967       if (osm) {
49968         var blocklists = osm.imageryBlocklists();
49969         var fail = false;
49970         var tested = 0;
49971         var regex;
49972         for (var i3 = 0; i3 < blocklists.length; i3++) {
49973           regex = blocklists[i3];
49974           fail = regex.test(val);
49975           tested++;
49976           if (fail) break;
49977         }
49978         if (!tested) {
49979           regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/;
49980           fail = regex.test(val);
49981         }
49982       }
49983       _template = val;
49984       _fileList = null;
49985       _geojson = null;
49986       _src = src || "vectortile:" + val.split(/[?#]/)[0];
49987       dispatch14.call("change");
49988       return this;
49989     };
49990     drawData.geojson = function(gj, src) {
49991       if (!arguments.length) return _geojson;
49992       _template = null;
49993       _fileList = null;
49994       _geojson = null;
49995       _src = null;
49996       gj = gj || {};
49997       if (Object.keys(gj).length) {
49998         _geojson = ensureIDs(gj);
49999         _src = src || "unknown.geojson";
50000       }
50001       dispatch14.call("change");
50002       return this;
50003     };
50004     drawData.fileList = function(fileList) {
50005       if (!arguments.length) return _fileList;
50006       _template = null;
50007       _geojson = null;
50008       _src = null;
50009       _fileList = fileList;
50010       if (!fileList || !fileList.length) return this;
50011       var f2 = fileList[0];
50012       var extension = getExtension(f2.name);
50013       var reader = new FileReader();
50014       reader.onload = /* @__PURE__ */ function() {
50015         return function(e3) {
50016           drawData.setFile(extension, e3.target.result);
50017         };
50018       }(f2);
50019       reader.readAsText(f2);
50020       return this;
50021     };
50022     drawData.url = function(url, defaultExtension) {
50023       _template = null;
50024       _fileList = null;
50025       _geojson = null;
50026       _src = null;
50027       var testUrl = url.split(/[?#]/)[0];
50028       var extension = getExtension(testUrl) || defaultExtension;
50029       if (extension) {
50030         _template = null;
50031         text_default3(url).then(function(data) {
50032           drawData.setFile(extension, data);
50033         }).catch(function() {
50034         });
50035       } else {
50036         drawData.template(url);
50037       }
50038       return this;
50039     };
50040     drawData.getSrc = function() {
50041       return _src || "";
50042     };
50043     drawData.fitZoom = function() {
50044       var features = getFeatures(_geojson);
50045       if (!features.length) return;
50046       var map2 = context.map();
50047       var viewport = map2.trimmedExtent().polygon();
50048       var coords = features.reduce(function(coords2, feature3) {
50049         var geom = feature3.geometry;
50050         if (!geom) return coords2;
50051         var c2 = geom.coordinates;
50052         switch (geom.type) {
50053           case "Point":
50054             c2 = [c2];
50055           case "MultiPoint":
50056           case "LineString":
50057             break;
50058           case "MultiPolygon":
50059             c2 = utilArrayFlatten(c2);
50060           case "Polygon":
50061           case "MultiLineString":
50062             c2 = utilArrayFlatten(c2);
50063             break;
50064         }
50065         return utilArrayUnion(coords2, c2);
50066       }, []);
50067       if (!geoPolygonIntersectsPolygon(viewport, coords, true)) {
50068         var extent = geoExtent(bounds_default({ type: "LineString", coordinates: coords }));
50069         map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent));
50070       }
50071       return this;
50072     };
50073     init2();
50074     return drawData;
50075   }
50076
50077   // modules/svg/debug.js
50078   function svgDebug(projection2, context) {
50079     function drawDebug(selection2) {
50080       const showTile = context.getDebug("tile");
50081       const showCollision = context.getDebug("collision");
50082       const showImagery = context.getDebug("imagery");
50083       const showTouchTargets = context.getDebug("target");
50084       const showDownloaded = context.getDebug("downloaded");
50085       let debugData = [];
50086       if (showTile) {
50087         debugData.push({ class: "red", label: "tile" });
50088       }
50089       if (showCollision) {
50090         debugData.push({ class: "yellow", label: "collision" });
50091       }
50092       if (showImagery) {
50093         debugData.push({ class: "orange", label: "imagery" });
50094       }
50095       if (showTouchTargets) {
50096         debugData.push({ class: "pink", label: "touchTargets" });
50097       }
50098       if (showDownloaded) {
50099         debugData.push({ class: "purple", label: "downloaded" });
50100       }
50101       let legend = context.container().select(".main-content").selectAll(".debug-legend").data(debugData.length ? [0] : []);
50102       legend.exit().remove();
50103       legend = legend.enter().append("div").attr("class", "fillD debug-legend").merge(legend);
50104       let legendItems = legend.selectAll(".debug-legend-item").data(debugData, (d2) => d2.label);
50105       legendItems.exit().remove();
50106       legendItems.enter().append("span").attr("class", (d2) => "debug-legend-item ".concat(d2.class)).text((d2) => d2.label);
50107       let layer = selection2.selectAll(".layer-debug").data(showImagery || showDownloaded ? [0] : []);
50108       layer.exit().remove();
50109       layer = layer.enter().append("g").attr("class", "layer-debug").merge(layer);
50110       const extent = context.map().extent();
50111       _mainFileFetcher.get("imagery").then((d2) => {
50112         const hits = showImagery && d2.query.bbox(extent.rectangle(), true) || [];
50113         const features = hits.map((d4) => d4.features[d4.id]);
50114         let imagery = layer.selectAll("path.debug-imagery").data(features);
50115         imagery.exit().remove();
50116         imagery.enter().append("path").attr("class", "debug-imagery debug orange");
50117       }).catch(() => {
50118       });
50119       const osm = context.connection();
50120       let dataDownloaded = [];
50121       if (osm && showDownloaded) {
50122         const rtree = osm.caches("get").tile.rtree;
50123         dataDownloaded = rtree.all().map((bbox2) => {
50124           return {
50125             type: "Feature",
50126             properties: { id: bbox2.id },
50127             geometry: {
50128               type: "Polygon",
50129               coordinates: [[
50130                 [bbox2.minX, bbox2.minY],
50131                 [bbox2.minX, bbox2.maxY],
50132                 [bbox2.maxX, bbox2.maxY],
50133                 [bbox2.maxX, bbox2.minY],
50134                 [bbox2.minX, bbox2.minY]
50135               ]]
50136             }
50137           };
50138         });
50139       }
50140       let downloaded = layer.selectAll("path.debug-downloaded").data(showDownloaded ? dataDownloaded : []);
50141       downloaded.exit().remove();
50142       downloaded.enter().append("path").attr("class", "debug-downloaded debug purple");
50143       layer.selectAll("path").attr("d", svgPath(projection2).geojson);
50144     }
50145     drawDebug.enabled = function() {
50146       if (!arguments.length) {
50147         return context.getDebug("tile") || context.getDebug("collision") || context.getDebug("imagery") || context.getDebug("target") || context.getDebug("downloaded");
50148       } else {
50149         return this;
50150       }
50151     };
50152     return drawDebug;
50153   }
50154
50155   // modules/svg/defs.js
50156   function svgDefs(context) {
50157     var _defsSelection = select_default2(null);
50158     var _spritesheetIds = [
50159       "iD-sprite",
50160       "maki-sprite",
50161       "temaki-sprite",
50162       "fa-sprite",
50163       "roentgen-sprite",
50164       "community-sprite"
50165     ];
50166     function drawDefs(selection2) {
50167       _defsSelection = selection2.append("defs");
50168       function addOnewayMarker(name, colour) {
50169         _defsSelection.append("marker").attr("id", "ideditor-oneway-marker-".concat(name)).attr("viewBox", "0 0 10 5").attr("refX", 2.5).attr("refY", 2.5).attr("markerWidth", 2).attr("markerHeight", 2).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("class", "oneway-marker-path").attr("d", "M 5,3 L 0,3 L 0,2 L 5,2 L 5,0 L 10,2.5 L 5,5 z").attr("stroke", "none").attr("fill", colour).attr("opacity", "0.75");
50170       }
50171       addOnewayMarker("black", "#000");
50172       addOnewayMarker("white", "#fff");
50173       addOnewayMarker("pink", "#eaf");
50174       function addSidedMarker(name, color2, offset) {
50175         _defsSelection.append("marker").attr("id", "ideditor-sided-marker-" + name).attr("viewBox", "0 0 2 2").attr("refX", 1).attr("refY", -offset).attr("markerWidth", 1.5).attr("markerHeight", 1.5).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("class", "sided-marker-path sided-marker-" + name + "-path").attr("d", "M 0,0 L 1,1 L 2,0 z").attr("stroke", "none").attr("fill", color2);
50176       }
50177       addSidedMarker("natural", "rgb(170, 170, 170)", 0);
50178       addSidedMarker("coastline", "#77dede", 1);
50179       addSidedMarker("waterway", "#77dede", 1);
50180       addSidedMarker("barrier", "#ddd", 1);
50181       addSidedMarker("man_made", "#fff", 0);
50182       _defsSelection.append("marker").attr("id", "ideditor-viewfield-marker").attr("viewBox", "0 0 16 16").attr("refX", 8).attr("refY", 16).attr("markerWidth", 4).attr("markerHeight", 4).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("class", "viewfield-marker-path").attr("d", "M 6,14 C 8,13.4 8,13.4 10,14 L 16,3 C 12,0 4,0 0,3 z").attr("fill", "#333").attr("fill-opacity", "0.75").attr("stroke", "#fff").attr("stroke-width", "0.5px").attr("stroke-opacity", "0.75");
50183       _defsSelection.append("marker").attr("id", "ideditor-viewfield-marker-wireframe").attr("viewBox", "0 0 16 16").attr("refX", 8).attr("refY", 16).attr("markerWidth", 4).attr("markerHeight", 4).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("class", "viewfield-marker-path").attr("d", "M 6,14 C 8,13.4 8,13.4 10,14 L 16,3 C 12,0 4,0 0,3 z").attr("fill", "none").attr("stroke", "#fff").attr("stroke-width", "0.5px").attr("stroke-opacity", "0.75");
50184       var patterns2 = _defsSelection.selectAll("pattern").data([
50185         // pattern name, pattern image name
50186         ["beach", "dots"],
50187         ["construction", "construction"],
50188         ["cemetery", "cemetery"],
50189         ["cemetery_christian", "cemetery_christian"],
50190         ["cemetery_buddhist", "cemetery_buddhist"],
50191         ["cemetery_muslim", "cemetery_muslim"],
50192         ["cemetery_jewish", "cemetery_jewish"],
50193         ["farmland", "farmland"],
50194         ["farmyard", "farmyard"],
50195         ["forest", "forest"],
50196         ["forest_broadleaved", "forest_broadleaved"],
50197         ["forest_needleleaved", "forest_needleleaved"],
50198         ["forest_leafless", "forest_leafless"],
50199         ["golf_green", "grass"],
50200         ["grass", "grass"],
50201         ["landfill", "landfill"],
50202         ["meadow", "grass"],
50203         ["orchard", "orchard"],
50204         ["pond", "pond"],
50205         ["quarry", "quarry"],
50206         ["scrub", "bushes"],
50207         ["vineyard", "vineyard"],
50208         ["water_standing", "lines"],
50209         ["waves", "waves"],
50210         ["wetland", "wetland"],
50211         ["wetland_marsh", "wetland_marsh"],
50212         ["wetland_swamp", "wetland_swamp"],
50213         ["wetland_bog", "wetland_bog"],
50214         ["wetland_reedbed", "wetland_reedbed"]
50215       ]).enter().append("pattern").attr("id", function(d2) {
50216         return "ideditor-pattern-" + d2[0];
50217       }).attr("width", 32).attr("height", 32).attr("patternUnits", "userSpaceOnUse");
50218       patterns2.append("rect").attr("x", 0).attr("y", 0).attr("width", 32).attr("height", 32).attr("class", function(d2) {
50219         return "pattern-color-" + d2[0];
50220       });
50221       patterns2.append("image").attr("x", 0).attr("y", 0).attr("width", 32).attr("height", 32).attr("xlink:href", function(d2) {
50222         return context.imagePath("pattern/" + d2[1] + ".png");
50223       });
50224       _defsSelection.selectAll("clipPath").data([12, 18, 20, 32, 45]).enter().append("clipPath").attr("id", function(d2) {
50225         return "ideditor-clip-square-" + d2;
50226       }).append("rect").attr("x", 0).attr("y", 0).attr("width", function(d2) {
50227         return d2;
50228       }).attr("height", function(d2) {
50229         return d2;
50230       });
50231       addSprites(_spritesheetIds, true);
50232     }
50233     function addSprites(ids, overrideColors) {
50234       _spritesheetIds = utilArrayUniq(_spritesheetIds.concat(ids));
50235       var spritesheets = _defsSelection.selectAll(".spritesheet").data(_spritesheetIds);
50236       spritesheets.enter().append("g").attr("class", function(d2) {
50237         return "spritesheet spritesheet-" + d2;
50238       }).each(function(d2) {
50239         var url = context.imagePath(d2 + ".svg");
50240         var node = select_default2(this).node();
50241         svg(url).then(function(svg2) {
50242           node.appendChild(
50243             select_default2(svg2.documentElement).attr("id", "ideditor-" + d2).node()
50244           );
50245           if (overrideColors && d2 !== "iD-sprite") {
50246             select_default2(node).selectAll("path").attr("fill", "currentColor");
50247           }
50248         }).catch(function() {
50249         });
50250       });
50251       spritesheets.exit().remove();
50252     }
50253     drawDefs.addSprites = addSprites;
50254     return drawDefs;
50255   }
50256
50257   // modules/svg/keepRight.js
50258   var _layerEnabled = false;
50259   var _qaService;
50260   function svgKeepRight(projection2, context, dispatch14) {
50261     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
50262     const minZoom5 = 12;
50263     let touchLayer = select_default2(null);
50264     let drawLayer = select_default2(null);
50265     let layerVisible = false;
50266     function markerPath(selection2, klass) {
50267       selection2.attr("class", klass).attr("transform", "translate(-4, -24)").attr("d", "M11.6,6.2H7.1l1.4-5.1C8.6,0.6,8.1,0,7.5,0H2.2C1.7,0,1.3,0.3,1.3,0.8L0,10.2c-0.1,0.6,0.4,1.1,0.9,1.1h4.6l-1.8,7.6C3.6,19.4,4.1,20,4.7,20c0.3,0,0.6-0.2,0.8-0.5l6.9-11.9C12.7,7,12.3,6.2,11.6,6.2z");
50268     }
50269     function getService() {
50270       if (services.keepRight && !_qaService) {
50271         _qaService = services.keepRight;
50272         _qaService.on("loaded", throttledRedraw);
50273       } else if (!services.keepRight && _qaService) {
50274         _qaService = null;
50275       }
50276       return _qaService;
50277     }
50278     function editOn() {
50279       if (!layerVisible) {
50280         layerVisible = true;
50281         drawLayer.style("display", "block");
50282       }
50283     }
50284     function editOff() {
50285       if (layerVisible) {
50286         layerVisible = false;
50287         drawLayer.style("display", "none");
50288         drawLayer.selectAll(".qaItem.keepRight").remove();
50289         touchLayer.selectAll(".qaItem.keepRight").remove();
50290       }
50291     }
50292     function layerOn() {
50293       editOn();
50294       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
50295     }
50296     function layerOff() {
50297       throttledRedraw.cancel();
50298       drawLayer.interrupt();
50299       touchLayer.selectAll(".qaItem.keepRight").remove();
50300       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
50301         editOff();
50302         dispatch14.call("change");
50303       });
50304     }
50305     function updateMarkers() {
50306       if (!layerVisible || !_layerEnabled) return;
50307       const service = getService();
50308       const selectedID = context.selectedErrorID();
50309       const data = service ? service.getItems(projection2) : [];
50310       const getTransform = svgPointTransform(projection2);
50311       const markers = drawLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id);
50312       markers.exit().remove();
50313       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.parentIssueType));
50314       markersEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
50315       markersEnter.append("path").call(markerPath, "shadow");
50316       markersEnter.append("use").attr("class", "qaItem-fill").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").attr("xlink:href", "#iD-icon-bolt");
50317       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
50318       if (touchLayer.empty()) return;
50319       const fillClass = context.getDebug("target") ? "pink " : "nocolor ";
50320       const targets = touchLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id);
50321       targets.exit().remove();
50322       targets.enter().append("rect").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").merge(targets).sort(sortY).attr("class", (d2) => "qaItem ".concat(d2.service, " target ").concat(fillClass, " itemId-").concat(d2.id)).attr("transform", getTransform);
50323       function sortY(a2, b2) {
50324         return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : a2.severity === "error" && b2.severity !== "error" ? 1 : b2.severity === "error" && a2.severity !== "error" ? -1 : b2.loc[1] - a2.loc[1];
50325       }
50326     }
50327     function drawKeepRight(selection2) {
50328       const service = getService();
50329       const surface = context.surface();
50330       if (surface && !surface.empty()) {
50331         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
50332       }
50333       drawLayer = selection2.selectAll(".layer-keepRight").data(service ? [0] : []);
50334       drawLayer.exit().remove();
50335       drawLayer = drawLayer.enter().append("g").attr("class", "layer-keepRight").style("display", _layerEnabled ? "block" : "none").merge(drawLayer);
50336       if (_layerEnabled) {
50337         if (service && ~~context.map().zoom() >= minZoom5) {
50338           editOn();
50339           service.loadIssues(projection2);
50340           updateMarkers();
50341         } else {
50342           editOff();
50343         }
50344       }
50345     }
50346     drawKeepRight.enabled = function(val) {
50347       if (!arguments.length) return _layerEnabled;
50348       _layerEnabled = val;
50349       if (_layerEnabled) {
50350         layerOn();
50351       } else {
50352         layerOff();
50353         if (context.selectedErrorID()) {
50354           context.enter(modeBrowse(context));
50355         }
50356       }
50357       dispatch14.call("change");
50358       return this;
50359     };
50360     drawKeepRight.supported = () => !!getService();
50361     return drawKeepRight;
50362   }
50363
50364   // modules/svg/geolocate.js
50365   function svgGeolocate(projection2) {
50366     var layer = select_default2(null);
50367     var _position;
50368     function init2() {
50369       if (svgGeolocate.initialized) return;
50370       svgGeolocate.enabled = false;
50371       svgGeolocate.initialized = true;
50372     }
50373     function showLayer() {
50374       layer.style("display", "block");
50375     }
50376     function hideLayer() {
50377       layer.transition().duration(250).style("opacity", 0);
50378     }
50379     function layerOn() {
50380       layer.style("opacity", 0).transition().duration(250).style("opacity", 1);
50381     }
50382     function layerOff() {
50383       layer.style("display", "none");
50384     }
50385     function transform2(d2) {
50386       return svgPointTransform(projection2)(d2);
50387     }
50388     function accuracy(accuracy2, loc) {
50389       var degreesRadius = geoMetersToLat(accuracy2), tangentLoc = [loc[0], loc[1] + degreesRadius], projectedTangent = projection2(tangentLoc), projectedLoc = projection2([loc[0], loc[1]]);
50390       return Math.round(projectedLoc[1] - projectedTangent[1]).toString();
50391     }
50392     function update() {
50393       var geolocation = { loc: [_position.coords.longitude, _position.coords.latitude] };
50394       var groups = layer.selectAll(".geolocations").selectAll(".geolocation").data([geolocation]);
50395       groups.exit().remove();
50396       var pointsEnter = groups.enter().append("g").attr("class", "geolocation");
50397       pointsEnter.append("circle").attr("class", "geolocate-radius").attr("dx", "0").attr("dy", "0").attr("fill", "rgb(15,128,225)").attr("fill-opacity", "0.3").attr("r", "0");
50398       pointsEnter.append("circle").attr("dx", "0").attr("dy", "0").attr("fill", "rgb(15,128,225)").attr("stroke", "white").attr("stroke-width", "1.5").attr("r", "6");
50399       groups.merge(pointsEnter).attr("transform", transform2);
50400       layer.select(".geolocate-radius").attr("r", accuracy(_position.coords.accuracy, geolocation.loc));
50401     }
50402     function drawLocation(selection2) {
50403       var enabled = svgGeolocate.enabled;
50404       layer = selection2.selectAll(".layer-geolocate").data([0]);
50405       layer.exit().remove();
50406       var layerEnter = layer.enter().append("g").attr("class", "layer-geolocate").style("display", enabled ? "block" : "none");
50407       layerEnter.append("g").attr("class", "geolocations");
50408       layer = layerEnter.merge(layer);
50409       if (enabled) {
50410         update();
50411       } else {
50412         layerOff();
50413       }
50414     }
50415     drawLocation.enabled = function(position, enabled) {
50416       if (!arguments.length) return svgGeolocate.enabled;
50417       _position = position;
50418       svgGeolocate.enabled = enabled;
50419       if (svgGeolocate.enabled) {
50420         showLayer();
50421         layerOn();
50422       } else {
50423         hideLayer();
50424       }
50425       return this;
50426     };
50427     init2();
50428     return drawLocation;
50429   }
50430
50431   // modules/svg/labels.js
50432   function svgLabels(projection2, context) {
50433     var path = path_default(projection2);
50434     var detected = utilDetect();
50435     var baselineHack = detected.ie || detected.browser.toLowerCase() === "edge" || detected.browser.toLowerCase() === "firefox" && detected.version >= 70;
50436     var _rdrawn = new RBush();
50437     var _rskipped = new RBush();
50438     var _textWidthCache = {};
50439     var _entitybboxes = {};
50440     var labelStack = [
50441       ["line", "aeroway", "*", 12],
50442       ["line", "highway", "motorway", 12],
50443       ["line", "highway", "trunk", 12],
50444       ["line", "highway", "primary", 12],
50445       ["line", "highway", "secondary", 12],
50446       ["line", "highway", "tertiary", 12],
50447       ["line", "highway", "*", 12],
50448       ["line", "railway", "*", 12],
50449       ["line", "waterway", "*", 12],
50450       ["area", "aeroway", "*", 12],
50451       ["area", "amenity", "*", 12],
50452       ["area", "building", "*", 12],
50453       ["area", "historic", "*", 12],
50454       ["area", "leisure", "*", 12],
50455       ["area", "man_made", "*", 12],
50456       ["area", "natural", "*", 12],
50457       ["area", "shop", "*", 12],
50458       ["area", "tourism", "*", 12],
50459       ["area", "camp_site", "*", 12],
50460       ["point", "aeroway", "*", 10],
50461       ["point", "amenity", "*", 10],
50462       ["point", "building", "*", 10],
50463       ["point", "historic", "*", 10],
50464       ["point", "leisure", "*", 10],
50465       ["point", "man_made", "*", 10],
50466       ["point", "natural", "*", 10],
50467       ["point", "shop", "*", 10],
50468       ["point", "tourism", "*", 10],
50469       ["point", "camp_site", "*", 10],
50470       ["line", "ref", "*", 12],
50471       ["area", "ref", "*", 12],
50472       ["point", "ref", "*", 10],
50473       ["line", "name", "*", 12],
50474       ["area", "name", "*", 12],
50475       ["point", "name", "*", 10]
50476     ];
50477     function shouldSkipIcon(preset) {
50478       var noIcons = ["building", "landuse", "natural"];
50479       return noIcons.some(function(s2) {
50480         return preset.id.indexOf(s2) >= 0;
50481       });
50482     }
50483     function get4(array2, prop) {
50484       return function(d2, i3) {
50485         return array2[i3][prop];
50486       };
50487     }
50488     function textWidth(text, size, elem) {
50489       var c2 = _textWidthCache[size];
50490       if (!c2) c2 = _textWidthCache[size] = {};
50491       if (c2[text]) {
50492         return c2[text];
50493       } else if (elem) {
50494         c2[text] = elem.getComputedTextLength();
50495         return c2[text];
50496       } else {
50497         var str = encodeURIComponent(text).match(/%[CDEFcdef]/g);
50498         if (str === null) {
50499           return size / 3 * 2 * text.length;
50500         } else {
50501           return size / 3 * (2 * text.length + str.length);
50502         }
50503       }
50504     }
50505     function drawLinePaths(selection2, entities, filter2, classes, labels) {
50506       var paths = selection2.selectAll("path").filter(filter2).data(entities, osmEntity.key);
50507       paths.exit().remove();
50508       paths.enter().append("path").style("stroke-width", get4(labels, "font-size")).attr("id", function(d2) {
50509         return "ideditor-labelpath-" + d2.id;
50510       }).attr("class", classes).merge(paths).attr("d", get4(labels, "lineString"));
50511     }
50512     function drawLineLabels(selection2, entities, filter2, classes, labels) {
50513       var texts = selection2.selectAll("text." + classes).filter(filter2).data(entities, osmEntity.key);
50514       texts.exit().remove();
50515       texts.enter().append("text").attr("class", function(d2, i3) {
50516         return classes + " " + labels[i3].classes + " " + d2.id;
50517       }).attr("dy", baselineHack ? "0.35em" : null).append("textPath").attr("class", "textpath");
50518       selection2.selectAll("text." + classes).selectAll(".textpath").filter(filter2).data(entities, osmEntity.key).attr("startOffset", "50%").attr("xlink:href", function(d2) {
50519         return "#ideditor-labelpath-" + d2.id;
50520       }).text(utilDisplayNameForPath);
50521     }
50522     function drawPointLabels(selection2, entities, filter2, classes, labels) {
50523       var texts = selection2.selectAll("text." + classes).filter(filter2).data(entities, osmEntity.key);
50524       texts.exit().remove();
50525       texts.enter().append("text").attr("class", function(d2, i3) {
50526         return classes + " " + labels[i3].classes + " " + d2.id;
50527       }).merge(texts).attr("x", get4(labels, "x")).attr("y", get4(labels, "y")).style("text-anchor", get4(labels, "textAnchor")).text(utilDisplayName).each(function(d2, i3) {
50528         textWidth(utilDisplayName(d2), labels[i3].height, this);
50529       });
50530     }
50531     function drawAreaLabels(selection2, entities, filter2, classes, labels) {
50532       entities = entities.filter(hasText);
50533       labels = labels.filter(hasText);
50534       drawPointLabels(selection2, entities, filter2, classes, labels);
50535       function hasText(d2, i3) {
50536         return labels[i3].hasOwnProperty("x") && labels[i3].hasOwnProperty("y");
50537       }
50538     }
50539     function drawAreaIcons(selection2, entities, filter2, classes, labels) {
50540       var icons = selection2.selectAll("use." + classes).filter(filter2).data(entities, osmEntity.key);
50541       icons.exit().remove();
50542       icons.enter().append("use").attr("class", "icon " + classes).attr("width", "17px").attr("height", "17px").merge(icons).attr("transform", get4(labels, "transform")).attr("xlink:href", function(d2) {
50543         var preset = _mainPresetIndex.match(d2, context.graph());
50544         var picon = preset && preset.icon;
50545         return picon ? "#" + picon : "";
50546       });
50547     }
50548     function drawCollisionBoxes(selection2, rtree, which) {
50549       var classes = "debug " + which + " " + (which === "debug-skipped" ? "orange" : "yellow");
50550       var gj = [];
50551       if (context.getDebug("collision")) {
50552         gj = rtree.all().map(function(d2) {
50553           return { type: "Polygon", coordinates: [[
50554             [d2.minX, d2.minY],
50555             [d2.maxX, d2.minY],
50556             [d2.maxX, d2.maxY],
50557             [d2.minX, d2.maxY],
50558             [d2.minX, d2.minY]
50559           ]] };
50560         });
50561       }
50562       var boxes = selection2.selectAll("." + which).data(gj);
50563       boxes.exit().remove();
50564       boxes.enter().append("path").attr("class", classes).merge(boxes).attr("d", path_default());
50565     }
50566     function drawLabels(selection2, graph, entities, filter2, dimensions, fullRedraw) {
50567       var wireframe = context.surface().classed("fill-wireframe");
50568       var zoom = geoScaleToZoom(projection2.scale());
50569       var labelable = [];
50570       var renderNodeAs = {};
50571       var i3, j2, k2, entity, geometry;
50572       for (i3 = 0; i3 < labelStack.length; i3++) {
50573         labelable.push([]);
50574       }
50575       if (fullRedraw) {
50576         _rdrawn.clear();
50577         _rskipped.clear();
50578         _entitybboxes = {};
50579       } else {
50580         for (i3 = 0; i3 < entities.length; i3++) {
50581           entity = entities[i3];
50582           var toRemove = [].concat(_entitybboxes[entity.id] || []).concat(_entitybboxes[entity.id + "I"] || []);
50583           for (j2 = 0; j2 < toRemove.length; j2++) {
50584             _rdrawn.remove(toRemove[j2]);
50585             _rskipped.remove(toRemove[j2]);
50586           }
50587         }
50588       }
50589       for (i3 = 0; i3 < entities.length; i3++) {
50590         entity = entities[i3];
50591         geometry = entity.geometry(graph);
50592         if (geometry === "point" || geometry === "vertex" && isInterestingVertex(entity)) {
50593           var hasDirections = entity.directions(graph, projection2).length;
50594           var markerPadding;
50595           if (!wireframe && geometry === "point" && !(zoom >= 18 && hasDirections)) {
50596             renderNodeAs[entity.id] = "point";
50597             markerPadding = 20;
50598           } else {
50599             renderNodeAs[entity.id] = "vertex";
50600             markerPadding = 0;
50601           }
50602           var coord2 = projection2(entity.loc);
50603           var nodePadding = 10;
50604           var bbox2 = {
50605             minX: coord2[0] - nodePadding,
50606             minY: coord2[1] - nodePadding - markerPadding,
50607             maxX: coord2[0] + nodePadding,
50608             maxY: coord2[1] + nodePadding
50609           };
50610           doInsert(bbox2, entity.id + "P");
50611         }
50612         if (geometry === "vertex") {
50613           geometry = "point";
50614         }
50615         var preset = geometry === "area" && _mainPresetIndex.match(entity, graph);
50616         var icon2 = preset && !shouldSkipIcon(preset) && preset.icon;
50617         if (!icon2 && !utilDisplayName(entity)) continue;
50618         for (k2 = 0; k2 < labelStack.length; k2++) {
50619           var matchGeom = labelStack[k2][0];
50620           var matchKey = labelStack[k2][1];
50621           var matchVal = labelStack[k2][2];
50622           var hasVal = entity.tags[matchKey];
50623           if (geometry === matchGeom && hasVal && (matchVal === "*" || matchVal === hasVal)) {
50624             labelable[k2].push(entity);
50625             break;
50626           }
50627         }
50628       }
50629       var positions = {
50630         point: [],
50631         line: [],
50632         area: []
50633       };
50634       var labelled = {
50635         point: [],
50636         line: [],
50637         area: []
50638       };
50639       for (k2 = 0; k2 < labelable.length; k2++) {
50640         var fontSize = labelStack[k2][3];
50641         for (i3 = 0; i3 < labelable[k2].length; i3++) {
50642           entity = labelable[k2][i3];
50643           geometry = entity.geometry(graph);
50644           var getName = geometry === "line" ? utilDisplayNameForPath : utilDisplayName;
50645           var name = getName(entity);
50646           var width = name && textWidth(name, fontSize);
50647           var p2 = null;
50648           if (geometry === "point" || geometry === "vertex") {
50649             if (wireframe) continue;
50650             var renderAs = renderNodeAs[entity.id];
50651             if (renderAs === "vertex" && zoom < 17) continue;
50652             p2 = getPointLabel(entity, width, fontSize, renderAs);
50653           } else if (geometry === "line") {
50654             p2 = getLineLabel(entity, width, fontSize);
50655           } else if (geometry === "area") {
50656             p2 = getAreaLabel(entity, width, fontSize);
50657           }
50658           if (p2) {
50659             if (geometry === "vertex") {
50660               geometry = "point";
50661             }
50662             p2.classes = geometry + " tag-" + labelStack[k2][1];
50663             positions[geometry].push(p2);
50664             labelled[geometry].push(entity);
50665           }
50666         }
50667       }
50668       function isInterestingVertex(entity2) {
50669         var selectedIDs = context.selectedIDs();
50670         return entity2.hasInterestingTags() || entity2.isEndpoint(graph) || entity2.isConnected(graph) || selectedIDs.indexOf(entity2.id) !== -1 || graph.parentWays(entity2).some(function(parent) {
50671           return selectedIDs.indexOf(parent.id) !== -1;
50672         });
50673       }
50674       function getPointLabel(entity2, width2, height, geometry2) {
50675         var y2 = geometry2 === "point" ? -12 : 0;
50676         var pointOffsets = {
50677           ltr: [15, y2, "start"],
50678           rtl: [-15, y2, "end"]
50679         };
50680         var textDirection = _mainLocalizer.textDirection();
50681         var coord3 = projection2(entity2.loc);
50682         var textPadding = 2;
50683         var offset = pointOffsets[textDirection];
50684         var p3 = {
50685           height,
50686           width: width2,
50687           x: coord3[0] + offset[0],
50688           y: coord3[1] + offset[1],
50689           textAnchor: offset[2]
50690         };
50691         var bbox3;
50692         if (textDirection === "rtl") {
50693           bbox3 = {
50694             minX: p3.x - width2 - textPadding,
50695             minY: p3.y - height / 2 - textPadding,
50696             maxX: p3.x + textPadding,
50697             maxY: p3.y + height / 2 + textPadding
50698           };
50699         } else {
50700           bbox3 = {
50701             minX: p3.x - textPadding,
50702             minY: p3.y - height / 2 - textPadding,
50703             maxX: p3.x + width2 + textPadding,
50704             maxY: p3.y + height / 2 + textPadding
50705           };
50706         }
50707         if (tryInsert([bbox3], entity2.id, true)) {
50708           return p3;
50709         }
50710       }
50711       function getLineLabel(entity2, width2, height) {
50712         var viewport = geoExtent(context.projection.clipExtent()).polygon();
50713         var points = graph.childNodes(entity2).map(function(node) {
50714           return projection2(node.loc);
50715         });
50716         var length2 = geoPathLength(points);
50717         if (length2 < width2 + 20) return;
50718         var lineOffsets = [
50719           50,
50720           45,
50721           55,
50722           40,
50723           60,
50724           35,
50725           65,
50726           30,
50727           70,
50728           25,
50729           75,
50730           20,
50731           80,
50732           15,
50733           95,
50734           10,
50735           90,
50736           5,
50737           95
50738         ];
50739         var padding = 3;
50740         for (var i4 = 0; i4 < lineOffsets.length; i4++) {
50741           var offset = lineOffsets[i4];
50742           var middle = offset / 100 * length2;
50743           var start2 = middle - width2 / 2;
50744           if (start2 < 0 || start2 + width2 > length2) continue;
50745           var sub = subpath(points, start2, start2 + width2);
50746           if (!sub || !geoPolygonIntersectsPolygon(viewport, sub, true)) {
50747             continue;
50748           }
50749           var isReverse = reverse(sub);
50750           if (isReverse) {
50751             sub = sub.reverse();
50752           }
50753           var bboxes = [];
50754           var boxsize = (height + 2) / 2;
50755           for (var j3 = 0; j3 < sub.length - 1; j3++) {
50756             var a2 = sub[j3];
50757             var b2 = sub[j3 + 1];
50758             var num = Math.max(1, Math.floor(geoVecLength(a2, b2) / boxsize / 2));
50759             for (var box = 0; box < num; box++) {
50760               var p3 = geoVecInterp(a2, b2, box / num);
50761               var x05 = p3[0] - boxsize - padding;
50762               var y05 = p3[1] - boxsize - padding;
50763               var x12 = p3[0] + boxsize + padding;
50764               var y12 = p3[1] + boxsize + padding;
50765               bboxes.push({
50766                 minX: Math.min(x05, x12),
50767                 minY: Math.min(y05, y12),
50768                 maxX: Math.max(x05, x12),
50769                 maxY: Math.max(y05, y12)
50770               });
50771             }
50772           }
50773           if (tryInsert(bboxes, entity2.id, false)) {
50774             return {
50775               "font-size": height + 2,
50776               lineString: lineString2(sub),
50777               startOffset: offset + "%"
50778             };
50779           }
50780         }
50781         function reverse(p4) {
50782           var angle2 = Math.atan2(p4[1][1] - p4[0][1], p4[1][0] - p4[0][0]);
50783           return !(p4[0][0] < p4[p4.length - 1][0] && angle2 < Math.PI / 2 && angle2 > -Math.PI / 2);
50784         }
50785         function lineString2(points2) {
50786           return "M" + points2.join("L");
50787         }
50788         function subpath(points2, from, to) {
50789           var sofar = 0;
50790           var start3, end, i0, i1;
50791           for (var i5 = 0; i5 < points2.length - 1; i5++) {
50792             var a3 = points2[i5];
50793             var b3 = points2[i5 + 1];
50794             var current = geoVecLength(a3, b3);
50795             var portion;
50796             if (!start3 && sofar + current >= from) {
50797               portion = (from - sofar) / current;
50798               start3 = [
50799                 a3[0] + portion * (b3[0] - a3[0]),
50800                 a3[1] + portion * (b3[1] - a3[1])
50801               ];
50802               i0 = i5 + 1;
50803             }
50804             if (!end && sofar + current >= to) {
50805               portion = (to - sofar) / current;
50806               end = [
50807                 a3[0] + portion * (b3[0] - a3[0]),
50808                 a3[1] + portion * (b3[1] - a3[1])
50809               ];
50810               i1 = i5 + 1;
50811             }
50812             sofar += current;
50813           }
50814           var result = points2.slice(i0, i1);
50815           result.unshift(start3);
50816           result.push(end);
50817           return result;
50818         }
50819       }
50820       function getAreaLabel(entity2, width2, height) {
50821         var centroid = path.centroid(entity2.asGeoJSON(graph));
50822         var extent = entity2.extent(graph);
50823         var areaWidth = projection2(extent[1])[0] - projection2(extent[0])[0];
50824         if (isNaN(centroid[0]) || areaWidth < 20) return;
50825         var preset2 = _mainPresetIndex.match(entity2, context.graph());
50826         var picon = preset2 && preset2.icon;
50827         var iconSize = 17;
50828         var padding = 2;
50829         var p3 = {};
50830         if (picon) {
50831           if (addIcon()) {
50832             addLabel(iconSize + padding);
50833             return p3;
50834           }
50835         } else {
50836           if (addLabel(0)) {
50837             return p3;
50838           }
50839         }
50840         function addIcon() {
50841           var iconX = centroid[0] - iconSize / 2;
50842           var iconY = centroid[1] - iconSize / 2;
50843           var bbox3 = {
50844             minX: iconX,
50845             minY: iconY,
50846             maxX: iconX + iconSize,
50847             maxY: iconY + iconSize
50848           };
50849           if (tryInsert([bbox3], entity2.id + "I", true)) {
50850             p3.transform = "translate(" + iconX + "," + iconY + ")";
50851             return true;
50852           }
50853           return false;
50854         }
50855         function addLabel(yOffset) {
50856           if (width2 && areaWidth >= width2 + 20) {
50857             var labelX = centroid[0];
50858             var labelY = centroid[1] + yOffset;
50859             var bbox3 = {
50860               minX: labelX - width2 / 2 - padding,
50861               minY: labelY - height / 2 - padding,
50862               maxX: labelX + width2 / 2 + padding,
50863               maxY: labelY + height / 2 + padding
50864             };
50865             if (tryInsert([bbox3], entity2.id, true)) {
50866               p3.x = labelX;
50867               p3.y = labelY;
50868               p3.textAnchor = "middle";
50869               p3.height = height;
50870               return true;
50871             }
50872           }
50873           return false;
50874         }
50875       }
50876       function doInsert(bbox3, id2) {
50877         bbox3.id = id2;
50878         var oldbox = _entitybboxes[id2];
50879         if (oldbox) {
50880           _rdrawn.remove(oldbox);
50881         }
50882         _entitybboxes[id2] = bbox3;
50883         _rdrawn.insert(bbox3);
50884       }
50885       function tryInsert(bboxes, id2, saveSkipped) {
50886         var skipped = false;
50887         for (var i4 = 0; i4 < bboxes.length; i4++) {
50888           var bbox3 = bboxes[i4];
50889           bbox3.id = id2;
50890           if (bbox3.minX < 0 || bbox3.minY < 0 || bbox3.maxX > dimensions[0] || bbox3.maxY > dimensions[1]) {
50891             skipped = true;
50892             break;
50893           }
50894           if (_rdrawn.collides(bbox3)) {
50895             skipped = true;
50896             break;
50897           }
50898         }
50899         _entitybboxes[id2] = bboxes;
50900         if (skipped) {
50901           if (saveSkipped) {
50902             _rskipped.load(bboxes);
50903           }
50904         } else {
50905           _rdrawn.load(bboxes);
50906         }
50907         return !skipped;
50908       }
50909       var layer = selection2.selectAll(".layer-osm.labels");
50910       layer.selectAll(".labels-group").data(["halo", "label", "debug"]).enter().append("g").attr("class", function(d2) {
50911         return "labels-group " + d2;
50912       });
50913       var halo = layer.selectAll(".labels-group.halo");
50914       var label = layer.selectAll(".labels-group.label");
50915       var debug2 = layer.selectAll(".labels-group.debug");
50916       drawPointLabels(label, labelled.point, filter2, "pointlabel", positions.point);
50917       drawPointLabels(halo, labelled.point, filter2, "pointlabel-halo", positions.point);
50918       drawLinePaths(layer, labelled.line, filter2, "", positions.line);
50919       drawLineLabels(label, labelled.line, filter2, "linelabel", positions.line);
50920       drawLineLabels(halo, labelled.line, filter2, "linelabel-halo", positions.line);
50921       drawAreaLabels(label, labelled.area, filter2, "arealabel", positions.area);
50922       drawAreaLabels(halo, labelled.area, filter2, "arealabel-halo", positions.area);
50923       drawAreaIcons(label, labelled.area, filter2, "areaicon", positions.area);
50924       drawAreaIcons(halo, labelled.area, filter2, "areaicon-halo", positions.area);
50925       drawCollisionBoxes(debug2, _rskipped, "debug-skipped");
50926       drawCollisionBoxes(debug2, _rdrawn, "debug-drawn");
50927       layer.call(filterLabels);
50928     }
50929     function filterLabels(selection2) {
50930       var drawLayer = selection2.selectAll(".layer-osm.labels");
50931       var layers = drawLayer.selectAll(".labels-group.halo, .labels-group.label");
50932       layers.selectAll(".nolabel").classed("nolabel", false);
50933       var mouse = context.map().mouse();
50934       var graph = context.graph();
50935       var selectedIDs = context.selectedIDs();
50936       var ids = [];
50937       var pad2, bbox2;
50938       if (mouse) {
50939         pad2 = 20;
50940         bbox2 = { minX: mouse[0] - pad2, minY: mouse[1] - pad2, maxX: mouse[0] + pad2, maxY: mouse[1] + pad2 };
50941         var nearMouse = _rdrawn.search(bbox2).map(function(entity2) {
50942           return entity2.id;
50943         });
50944         ids.push.apply(ids, nearMouse);
50945       }
50946       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
50947         var entity = graph.hasEntity(selectedIDs[i3]);
50948         if (entity && entity.type === "node") {
50949           ids.push(selectedIDs[i3]);
50950         }
50951       }
50952       layers.selectAll(utilEntitySelector(ids)).classed("nolabel", true);
50953       var debug2 = selection2.selectAll(".labels-group.debug");
50954       var gj = [];
50955       if (context.getDebug("collision")) {
50956         gj = bbox2 ? [{
50957           type: "Polygon",
50958           coordinates: [[
50959             [bbox2.minX, bbox2.minY],
50960             [bbox2.maxX, bbox2.minY],
50961             [bbox2.maxX, bbox2.maxY],
50962             [bbox2.minX, bbox2.maxY],
50963             [bbox2.minX, bbox2.minY]
50964           ]]
50965         }] : [];
50966       }
50967       var box = debug2.selectAll(".debug-mouse").data(gj);
50968       box.exit().remove();
50969       box.enter().append("path").attr("class", "debug debug-mouse yellow").merge(box).attr("d", path_default());
50970     }
50971     var throttleFilterLabels = throttle_default(filterLabels, 100);
50972     drawLabels.observe = function(selection2) {
50973       var listener = function() {
50974         throttleFilterLabels(selection2);
50975       };
50976       selection2.on("mousemove.hidelabels", listener);
50977       context.on("enter.hidelabels", listener);
50978     };
50979     drawLabels.off = function(selection2) {
50980       throttleFilterLabels.cancel();
50981       selection2.on("mousemove.hidelabels", null);
50982       context.on("enter.hidelabels", null);
50983     };
50984     return drawLabels;
50985   }
50986
50987   // node_modules/exifr/dist/full.esm.mjs
50988   var e = "undefined" != typeof self ? self : global;
50989   var t = "undefined" != typeof navigator;
50990   var i2 = t && "undefined" == typeof HTMLImageElement;
50991   var n2 = !("undefined" == typeof global || "undefined" == typeof process || !process.versions || !process.versions.node);
50992   var s = e.Buffer;
50993   var r = e.BigInt;
50994   var a = !!s;
50995   var o = (e3) => e3;
50996   function l(e3, t2 = o) {
50997     if (n2) try {
50998       return "function" == typeof __require ? Promise.resolve(t2(__require(e3))) : import(
50999         /* webpackIgnore: true */
51000         e3
51001       ).then(t2);
51002     } catch (t3) {
51003       console.warn("Couldn't load ".concat(e3));
51004     }
51005   }
51006   var h = e.fetch;
51007   var u = (e3) => h = e3;
51008   if (!e.fetch) {
51009     const e3 = l("http", (e4) => e4), t2 = l("https", (e4) => e4), i3 = (n3, { headers: s2 } = {}) => new Promise(async (r2, a2) => {
51010       let { port: o2, hostname: l2, pathname: h2, protocol: u2, search: c2 } = new URL(n3);
51011       const f2 = { method: "GET", hostname: l2, path: encodeURI(h2) + c2, headers: s2 };
51012       "" !== o2 && (f2.port = Number(o2));
51013       const d2 = ("https:" === u2 ? await t2 : await e3).request(f2, (e4) => {
51014         if (301 === e4.statusCode || 302 === e4.statusCode) {
51015           let t3 = new URL(e4.headers.location, n3).toString();
51016           return i3(t3, { headers: s2 }).then(r2).catch(a2);
51017         }
51018         r2({ status: e4.statusCode, arrayBuffer: () => new Promise((t3) => {
51019           let i4 = [];
51020           e4.on("data", (e6) => i4.push(e6)), e4.on("end", () => t3(Buffer.concat(i4)));
51021         }) });
51022       });
51023       d2.on("error", a2), d2.end();
51024     });
51025     u(i3);
51026   }
51027   function c(e3, t2, i3) {
51028     return t2 in e3 ? Object.defineProperty(e3, t2, { value: i3, enumerable: true, configurable: true, writable: true }) : e3[t2] = i3, e3;
51029   }
51030   var f = (e3) => p(e3) ? void 0 : e3;
51031   var d = (e3) => void 0 !== e3;
51032   function p(e3) {
51033     return void 0 === e3 || (e3 instanceof Map ? 0 === e3.size : 0 === Object.values(e3).filter(d).length);
51034   }
51035   function g2(e3) {
51036     let t2 = new Error(e3);
51037     throw delete t2.stack, t2;
51038   }
51039   function m(e3) {
51040     return "" === (e3 = function(e4) {
51041       for (; e4.endsWith("\0"); ) e4 = e4.slice(0, -1);
51042       return e4;
51043     }(e3).trim()) ? void 0 : e3;
51044   }
51045   function S(e3) {
51046     let t2 = function(e4) {
51047       let t3 = 0;
51048       return e4.ifd0.enabled && (t3 += 1024), e4.exif.enabled && (t3 += 2048), e4.makerNote && (t3 += 2048), e4.userComment && (t3 += 1024), e4.gps.enabled && (t3 += 512), e4.interop.enabled && (t3 += 100), e4.ifd1.enabled && (t3 += 1024), t3 + 2048;
51049     }(e3);
51050     return e3.jfif.enabled && (t2 += 50), e3.xmp.enabled && (t2 += 2e4), e3.iptc.enabled && (t2 += 14e3), e3.icc.enabled && (t2 += 6e3), t2;
51051   }
51052   var C = (e3) => String.fromCharCode.apply(null, e3);
51053   var y = "undefined" != typeof TextDecoder ? new TextDecoder("utf-8") : void 0;
51054   function b(e3) {
51055     return y ? y.decode(e3) : a ? Buffer.from(e3).toString("utf8") : decodeURIComponent(escape(C(e3)));
51056   }
51057   var I = class _I {
51058     static from(e3, t2) {
51059       return e3 instanceof this && e3.le === t2 ? e3 : new _I(e3, void 0, void 0, t2);
51060     }
51061     constructor(e3, t2 = 0, i3, n3) {
51062       if ("boolean" == typeof n3 && (this.le = n3), Array.isArray(e3) && (e3 = new Uint8Array(e3)), 0 === e3) this.byteOffset = 0, this.byteLength = 0;
51063       else if (e3 instanceof ArrayBuffer) {
51064         void 0 === i3 && (i3 = e3.byteLength - t2);
51065         let n4 = new DataView(e3, t2, i3);
51066         this._swapDataView(n4);
51067       } else if (e3 instanceof Uint8Array || e3 instanceof DataView || e3 instanceof _I) {
51068         void 0 === i3 && (i3 = e3.byteLength - t2), (t2 += e3.byteOffset) + i3 > e3.byteOffset + e3.byteLength && g2("Creating view outside of available memory in ArrayBuffer");
51069         let n4 = new DataView(e3.buffer, t2, i3);
51070         this._swapDataView(n4);
51071       } else if ("number" == typeof e3) {
51072         let t3 = new DataView(new ArrayBuffer(e3));
51073         this._swapDataView(t3);
51074       } else g2("Invalid input argument for BufferView: " + e3);
51075     }
51076     _swapArrayBuffer(e3) {
51077       this._swapDataView(new DataView(e3));
51078     }
51079     _swapBuffer(e3) {
51080       this._swapDataView(new DataView(e3.buffer, e3.byteOffset, e3.byteLength));
51081     }
51082     _swapDataView(e3) {
51083       this.dataView = e3, this.buffer = e3.buffer, this.byteOffset = e3.byteOffset, this.byteLength = e3.byteLength;
51084     }
51085     _lengthToEnd(e3) {
51086       return this.byteLength - e3;
51087     }
51088     set(e3, t2, i3 = _I) {
51089       return e3 instanceof DataView || e3 instanceof _I ? e3 = new Uint8Array(e3.buffer, e3.byteOffset, e3.byteLength) : e3 instanceof ArrayBuffer && (e3 = new Uint8Array(e3)), e3 instanceof Uint8Array || g2("BufferView.set(): Invalid data argument."), this.toUint8().set(e3, t2), new i3(this, t2, e3.byteLength);
51090     }
51091     subarray(e3, t2) {
51092       return t2 = t2 || this._lengthToEnd(e3), new _I(this, e3, t2);
51093     }
51094     toUint8() {
51095       return new Uint8Array(this.buffer, this.byteOffset, this.byteLength);
51096     }
51097     getUint8Array(e3, t2) {
51098       return new Uint8Array(this.buffer, this.byteOffset + e3, t2);
51099     }
51100     getString(e3 = 0, t2 = this.byteLength) {
51101       return b(this.getUint8Array(e3, t2));
51102     }
51103     getLatin1String(e3 = 0, t2 = this.byteLength) {
51104       let i3 = this.getUint8Array(e3, t2);
51105       return C(i3);
51106     }
51107     getUnicodeString(e3 = 0, t2 = this.byteLength) {
51108       const i3 = [];
51109       for (let n3 = 0; n3 < t2 && e3 + n3 < this.byteLength; n3 += 2) i3.push(this.getUint16(e3 + n3));
51110       return C(i3);
51111     }
51112     getInt8(e3) {
51113       return this.dataView.getInt8(e3);
51114     }
51115     getUint8(e3) {
51116       return this.dataView.getUint8(e3);
51117     }
51118     getInt16(e3, t2 = this.le) {
51119       return this.dataView.getInt16(e3, t2);
51120     }
51121     getInt32(e3, t2 = this.le) {
51122       return this.dataView.getInt32(e3, t2);
51123     }
51124     getUint16(e3, t2 = this.le) {
51125       return this.dataView.getUint16(e3, t2);
51126     }
51127     getUint32(e3, t2 = this.le) {
51128       return this.dataView.getUint32(e3, t2);
51129     }
51130     getFloat32(e3, t2 = this.le) {
51131       return this.dataView.getFloat32(e3, t2);
51132     }
51133     getFloat64(e3, t2 = this.le) {
51134       return this.dataView.getFloat64(e3, t2);
51135     }
51136     getFloat(e3, t2 = this.le) {
51137       return this.dataView.getFloat32(e3, t2);
51138     }
51139     getDouble(e3, t2 = this.le) {
51140       return this.dataView.getFloat64(e3, t2);
51141     }
51142     getUintBytes(e3, t2, i3) {
51143       switch (t2) {
51144         case 1:
51145           return this.getUint8(e3, i3);
51146         case 2:
51147           return this.getUint16(e3, i3);
51148         case 4:
51149           return this.getUint32(e3, i3);
51150         case 8:
51151           return this.getUint64 && this.getUint64(e3, i3);
51152       }
51153     }
51154     getUint(e3, t2, i3) {
51155       switch (t2) {
51156         case 8:
51157           return this.getUint8(e3, i3);
51158         case 16:
51159           return this.getUint16(e3, i3);
51160         case 32:
51161           return this.getUint32(e3, i3);
51162         case 64:
51163           return this.getUint64 && this.getUint64(e3, i3);
51164       }
51165     }
51166     toString(e3) {
51167       return this.dataView.toString(e3, this.constructor.name);
51168     }
51169     ensureChunk() {
51170     }
51171   };
51172   function P(e3, t2) {
51173     g2("".concat(e3, " '").concat(t2, "' was not loaded, try using full build of exifr."));
51174   }
51175   var k = class extends Map {
51176     constructor(e3) {
51177       super(), this.kind = e3;
51178     }
51179     get(e3, t2) {
51180       return this.has(e3) || P(this.kind, e3), t2 && (e3 in t2 || function(e4, t3) {
51181         g2("Unknown ".concat(e4, " '").concat(t3, "'."));
51182       }(this.kind, e3), t2[e3].enabled || P(this.kind, e3)), super.get(e3);
51183     }
51184     keyList() {
51185       return Array.from(this.keys());
51186     }
51187   };
51188   var w = new k("file parser");
51189   var T = new k("segment parser");
51190   var A = new k("file reader");
51191   function D(e3, n3) {
51192     return "string" == typeof e3 ? O(e3, n3) : t && !i2 && e3 instanceof HTMLImageElement ? O(e3.src, n3) : e3 instanceof Uint8Array || e3 instanceof ArrayBuffer || e3 instanceof DataView ? new I(e3) : t && e3 instanceof Blob ? x(e3, n3, "blob", R) : void g2("Invalid input argument");
51193   }
51194   function O(e3, i3) {
51195     return (s2 = e3).startsWith("data:") || s2.length > 1e4 ? v(e3, i3, "base64") : n2 && e3.includes("://") ? x(e3, i3, "url", M) : n2 ? v(e3, i3, "fs") : t ? x(e3, i3, "url", M) : void g2("Invalid input argument");
51196     var s2;
51197   }
51198   async function x(e3, t2, i3, n3) {
51199     return A.has(i3) ? v(e3, t2, i3) : n3 ? async function(e4, t3) {
51200       let i4 = await t3(e4);
51201       return new I(i4);
51202     }(e3, n3) : void g2("Parser ".concat(i3, " is not loaded"));
51203   }
51204   async function v(e3, t2, i3) {
51205     let n3 = new (A.get(i3))(e3, t2);
51206     return await n3.read(), n3;
51207   }
51208   var M = (e3) => h(e3).then((e4) => e4.arrayBuffer());
51209   var R = (e3) => new Promise((t2, i3) => {
51210     let n3 = new FileReader();
51211     n3.onloadend = () => t2(n3.result || new ArrayBuffer()), n3.onerror = i3, n3.readAsArrayBuffer(e3);
51212   });
51213   var L = class extends Map {
51214     get tagKeys() {
51215       return this.allKeys || (this.allKeys = Array.from(this.keys())), this.allKeys;
51216     }
51217     get tagValues() {
51218       return this.allValues || (this.allValues = Array.from(this.values())), this.allValues;
51219     }
51220   };
51221   function U(e3, t2, i3) {
51222     let n3 = new L();
51223     for (let [e4, t3] of i3) n3.set(e4, t3);
51224     if (Array.isArray(t2)) for (let i4 of t2) e3.set(i4, n3);
51225     else e3.set(t2, n3);
51226     return n3;
51227   }
51228   function F(e3, t2, i3) {
51229     let n3, s2 = e3.get(t2);
51230     for (n3 of i3) s2.set(n3[0], n3[1]);
51231   }
51232   var E = /* @__PURE__ */ new Map();
51233   var B = /* @__PURE__ */ new Map();
51234   var N = /* @__PURE__ */ new Map();
51235   var G = ["chunked", "firstChunkSize", "firstChunkSizeNode", "firstChunkSizeBrowser", "chunkSize", "chunkLimit"];
51236   var V = ["jfif", "xmp", "icc", "iptc", "ihdr"];
51237   var z = ["tiff", ...V];
51238   var H = ["ifd0", "ifd1", "exif", "gps", "interop"];
51239   var j = [...z, ...H];
51240   var W = ["makerNote", "userComment"];
51241   var K = ["translateKeys", "translateValues", "reviveValues", "multiSegment"];
51242   var X = [...K, "sanitize", "mergeOutput", "silentErrors"];
51243   var _ = class {
51244     get translate() {
51245       return this.translateKeys || this.translateValues || this.reviveValues;
51246     }
51247   };
51248   var Y = class extends _ {
51249     get needed() {
51250       return this.enabled || this.deps.size > 0;
51251     }
51252     constructor(e3, t2, i3, n3) {
51253       if (super(), c(this, "enabled", false), c(this, "skip", /* @__PURE__ */ new Set()), c(this, "pick", /* @__PURE__ */ new Set()), c(this, "deps", /* @__PURE__ */ new Set()), c(this, "translateKeys", false), c(this, "translateValues", false), c(this, "reviveValues", false), this.key = e3, this.enabled = t2, this.parse = this.enabled, this.applyInheritables(n3), this.canBeFiltered = H.includes(e3), this.canBeFiltered && (this.dict = E.get(e3)), void 0 !== i3) if (Array.isArray(i3)) this.parse = this.enabled = true, this.canBeFiltered && i3.length > 0 && this.translateTagSet(i3, this.pick);
51254       else if ("object" == typeof i3) {
51255         if (this.enabled = true, this.parse = false !== i3.parse, this.canBeFiltered) {
51256           let { pick: e4, skip: t3 } = i3;
51257           e4 && e4.length > 0 && this.translateTagSet(e4, this.pick), t3 && t3.length > 0 && this.translateTagSet(t3, this.skip);
51258         }
51259         this.applyInheritables(i3);
51260       } else true === i3 || false === i3 ? this.parse = this.enabled = i3 : g2("Invalid options argument: ".concat(i3));
51261     }
51262     applyInheritables(e3) {
51263       let t2, i3;
51264       for (t2 of K) i3 = e3[t2], void 0 !== i3 && (this[t2] = i3);
51265     }
51266     translateTagSet(e3, t2) {
51267       if (this.dict) {
51268         let i3, n3, { tagKeys: s2, tagValues: r2 } = this.dict;
51269         for (i3 of e3) "string" == typeof i3 ? (n3 = r2.indexOf(i3), -1 === n3 && (n3 = s2.indexOf(Number(i3))), -1 !== n3 && t2.add(Number(s2[n3]))) : t2.add(i3);
51270       } else for (let i3 of e3) t2.add(i3);
51271     }
51272     finalizeFilters() {
51273       !this.enabled && this.deps.size > 0 ? (this.enabled = true, ee(this.pick, this.deps)) : this.enabled && this.pick.size > 0 && ee(this.pick, this.deps);
51274     }
51275   };
51276   var $2 = { jfif: false, tiff: true, xmp: false, icc: false, iptc: false, ifd0: true, ifd1: false, exif: true, gps: true, interop: false, ihdr: void 0, makerNote: false, userComment: false, multiSegment: false, skip: [], pick: [], translateKeys: true, translateValues: true, reviveValues: true, sanitize: true, mergeOutput: true, silentErrors: true, chunked: true, firstChunkSize: void 0, firstChunkSizeNode: 512, firstChunkSizeBrowser: 65536, chunkSize: 65536, chunkLimit: 5 };
51277   var J = /* @__PURE__ */ new Map();
51278   var q = class extends _ {
51279     static useCached(e3) {
51280       let t2 = J.get(e3);
51281       return void 0 !== t2 || (t2 = new this(e3), J.set(e3, t2)), t2;
51282     }
51283     constructor(e3) {
51284       super(), true === e3 ? this.setupFromTrue() : void 0 === e3 ? this.setupFromUndefined() : Array.isArray(e3) ? this.setupFromArray(e3) : "object" == typeof e3 ? this.setupFromObject(e3) : g2("Invalid options argument ".concat(e3)), void 0 === this.firstChunkSize && (this.firstChunkSize = t ? this.firstChunkSizeBrowser : this.firstChunkSizeNode), this.mergeOutput && (this.ifd1.enabled = false), this.filterNestedSegmentTags(), this.traverseTiffDependencyTree(), this.checkLoadedPlugins();
51285     }
51286     setupFromUndefined() {
51287       let e3;
51288       for (e3 of G) this[e3] = $2[e3];
51289       for (e3 of X) this[e3] = $2[e3];
51290       for (e3 of W) this[e3] = $2[e3];
51291       for (e3 of j) this[e3] = new Y(e3, $2[e3], void 0, this);
51292     }
51293     setupFromTrue() {
51294       let e3;
51295       for (e3 of G) this[e3] = $2[e3];
51296       for (e3 of X) this[e3] = $2[e3];
51297       for (e3 of W) this[e3] = true;
51298       for (e3 of j) this[e3] = new Y(e3, true, void 0, this);
51299     }
51300     setupFromArray(e3) {
51301       let t2;
51302       for (t2 of G) this[t2] = $2[t2];
51303       for (t2 of X) this[t2] = $2[t2];
51304       for (t2 of W) this[t2] = $2[t2];
51305       for (t2 of j) this[t2] = new Y(t2, false, void 0, this);
51306       this.setupGlobalFilters(e3, void 0, H);
51307     }
51308     setupFromObject(e3) {
51309       let t2;
51310       for (t2 of (H.ifd0 = H.ifd0 || H.image, H.ifd1 = H.ifd1 || H.thumbnail, Object.assign(this, e3), G)) this[t2] = Z(e3[t2], $2[t2]);
51311       for (t2 of X) this[t2] = Z(e3[t2], $2[t2]);
51312       for (t2 of W) this[t2] = Z(e3[t2], $2[t2]);
51313       for (t2 of z) this[t2] = new Y(t2, $2[t2], e3[t2], this);
51314       for (t2 of H) this[t2] = new Y(t2, $2[t2], e3[t2], this.tiff);
51315       this.setupGlobalFilters(e3.pick, e3.skip, H, j), true === e3.tiff ? this.batchEnableWithBool(H, true) : false === e3.tiff ? this.batchEnableWithUserValue(H, e3) : Array.isArray(e3.tiff) ? this.setupGlobalFilters(e3.tiff, void 0, H) : "object" == typeof e3.tiff && this.setupGlobalFilters(e3.tiff.pick, e3.tiff.skip, H);
51316     }
51317     batchEnableWithBool(e3, t2) {
51318       for (let i3 of e3) this[i3].enabled = t2;
51319     }
51320     batchEnableWithUserValue(e3, t2) {
51321       for (let i3 of e3) {
51322         let e4 = t2[i3];
51323         this[i3].enabled = false !== e4 && void 0 !== e4;
51324       }
51325     }
51326     setupGlobalFilters(e3, t2, i3, n3 = i3) {
51327       if (e3 && e3.length) {
51328         for (let e4 of n3) this[e4].enabled = false;
51329         let t3 = Q(e3, i3);
51330         for (let [e4, i4] of t3) ee(this[e4].pick, i4), this[e4].enabled = true;
51331       } else if (t2 && t2.length) {
51332         let e4 = Q(t2, i3);
51333         for (let [t3, i4] of e4) ee(this[t3].skip, i4);
51334       }
51335     }
51336     filterNestedSegmentTags() {
51337       let { ifd0: e3, exif: t2, xmp: i3, iptc: n3, icc: s2 } = this;
51338       this.makerNote ? t2.deps.add(37500) : t2.skip.add(37500), this.userComment ? t2.deps.add(37510) : t2.skip.add(37510), i3.enabled || e3.skip.add(700), n3.enabled || e3.skip.add(33723), s2.enabled || e3.skip.add(34675);
51339     }
51340     traverseTiffDependencyTree() {
51341       let { ifd0: e3, exif: t2, gps: i3, interop: n3 } = this;
51342       n3.needed && (t2.deps.add(40965), e3.deps.add(40965)), t2.needed && e3.deps.add(34665), i3.needed && e3.deps.add(34853), this.tiff.enabled = H.some((e4) => true === this[e4].enabled) || this.makerNote || this.userComment;
51343       for (let e4 of H) this[e4].finalizeFilters();
51344     }
51345     get onlyTiff() {
51346       return !V.map((e3) => this[e3].enabled).some((e3) => true === e3) && this.tiff.enabled;
51347     }
51348     checkLoadedPlugins() {
51349       for (let e3 of z) this[e3].enabled && !T.has(e3) && P("segment parser", e3);
51350     }
51351   };
51352   function Q(e3, t2) {
51353     let i3, n3, s2, r2, a2 = [];
51354     for (s2 of t2) {
51355       for (r2 of (i3 = E.get(s2), n3 = [], i3)) (e3.includes(r2[0]) || e3.includes(r2[1])) && n3.push(r2[0]);
51356       n3.length && a2.push([s2, n3]);
51357     }
51358     return a2;
51359   }
51360   function Z(e3, t2) {
51361     return void 0 !== e3 ? e3 : void 0 !== t2 ? t2 : void 0;
51362   }
51363   function ee(e3, t2) {
51364     for (let i3 of t2) e3.add(i3);
51365   }
51366   c(q, "default", $2);
51367   var te = class {
51368     constructor(e3) {
51369       c(this, "parsers", {}), c(this, "output", {}), c(this, "errors", []), c(this, "pushToErrors", (e4) => this.errors.push(e4)), this.options = q.useCached(e3);
51370     }
51371     async read(e3) {
51372       this.file = await D(e3, this.options);
51373     }
51374     setup() {
51375       if (this.fileParser) return;
51376       let { file: e3 } = this, t2 = e3.getUint16(0);
51377       for (let [i3, n3] of w) if (n3.canHandle(e3, t2)) return this.fileParser = new n3(this.options, this.file, this.parsers), e3[i3] = true;
51378       this.file.close && this.file.close(), g2("Unknown file format");
51379     }
51380     async parse() {
51381       let { output: e3, errors: t2 } = this;
51382       return this.setup(), this.options.silentErrors ? (await this.executeParsers().catch(this.pushToErrors), t2.push(...this.fileParser.errors)) : await this.executeParsers(), this.file.close && this.file.close(), this.options.silentErrors && t2.length > 0 && (e3.errors = t2), f(e3);
51383     }
51384     async executeParsers() {
51385       let { output: e3 } = this;
51386       await this.fileParser.parse();
51387       let t2 = Object.values(this.parsers).map(async (t3) => {
51388         let i3 = await t3.parse();
51389         t3.assignToOutput(e3, i3);
51390       });
51391       this.options.silentErrors && (t2 = t2.map((e4) => e4.catch(this.pushToErrors))), await Promise.all(t2);
51392     }
51393     async extractThumbnail() {
51394       this.setup();
51395       let { options: e3, file: t2 } = this, i3 = T.get("tiff", e3);
51396       var n3;
51397       if (t2.tiff ? n3 = { start: 0, type: "tiff" } : t2.jpeg && (n3 = await this.fileParser.getOrFindSegment("tiff")), void 0 === n3) return;
51398       let s2 = await this.fileParser.ensureSegmentChunk(n3), r2 = this.parsers.tiff = new i3(s2, e3, t2), a2 = await r2.extractThumbnail();
51399       return t2.close && t2.close(), a2;
51400     }
51401   };
51402   async function ie(e3, t2) {
51403     let i3 = new te(t2);
51404     return await i3.read(e3), i3.parse();
51405   }
51406   var ne = Object.freeze({ __proto__: null, parse: ie, Exifr: te, fileParsers: w, segmentParsers: T, fileReaders: A, tagKeys: E, tagValues: B, tagRevivers: N, createDictionary: U, extendDictionary: F, fetchUrlAsArrayBuffer: M, readBlobAsArrayBuffer: R, chunkedProps: G, otherSegments: V, segments: z, tiffBlocks: H, segmentsAndBlocks: j, tiffExtractables: W, inheritables: K, allFormatters: X, Options: q });
51407   var se = class {
51408     constructor(e3, t2, i3) {
51409       c(this, "errors", []), c(this, "ensureSegmentChunk", async (e4) => {
51410         let t3 = e4.start, i4 = e4.size || 65536;
51411         if (this.file.chunked) if (this.file.available(t3, i4)) e4.chunk = this.file.subarray(t3, i4);
51412         else try {
51413           e4.chunk = await this.file.readChunk(t3, i4);
51414         } catch (t4) {
51415           g2("Couldn't read segment: ".concat(JSON.stringify(e4), ". ").concat(t4.message));
51416         }
51417         else this.file.byteLength > t3 + i4 ? e4.chunk = this.file.subarray(t3, i4) : void 0 === e4.size ? e4.chunk = this.file.subarray(t3) : g2("Segment unreachable: " + JSON.stringify(e4));
51418         return e4.chunk;
51419       }), this.extendOptions && this.extendOptions(e3), this.options = e3, this.file = t2, this.parsers = i3;
51420     }
51421     injectSegment(e3, t2) {
51422       this.options[e3].enabled && this.createParser(e3, t2);
51423     }
51424     createParser(e3, t2) {
51425       let i3 = new (T.get(e3))(t2, this.options, this.file);
51426       return this.parsers[e3] = i3;
51427     }
51428     createParsers(e3) {
51429       for (let t2 of e3) {
51430         let { type: e4, chunk: i3 } = t2, n3 = this.options[e4];
51431         if (n3 && n3.enabled) {
51432           let t3 = this.parsers[e4];
51433           t3 && t3.append || t3 || this.createParser(e4, i3);
51434         }
51435       }
51436     }
51437     async readSegments(e3) {
51438       let t2 = e3.map(this.ensureSegmentChunk);
51439       await Promise.all(t2);
51440     }
51441   };
51442   var re2 = class {
51443     static findPosition(e3, t2) {
51444       let i3 = e3.getUint16(t2 + 2) + 2, n3 = "function" == typeof this.headerLength ? this.headerLength(e3, t2, i3) : this.headerLength, s2 = t2 + n3, r2 = i3 - n3;
51445       return { offset: t2, length: i3, headerLength: n3, start: s2, size: r2, end: s2 + r2 };
51446     }
51447     static parse(e3, t2 = {}) {
51448       return new this(e3, new q({ [this.type]: t2 }), e3).parse();
51449     }
51450     normalizeInput(e3) {
51451       return e3 instanceof I ? e3 : new I(e3);
51452     }
51453     constructor(e3, t2 = {}, i3) {
51454       c(this, "errors", []), c(this, "raw", /* @__PURE__ */ new Map()), c(this, "handleError", (e4) => {
51455         if (!this.options.silentErrors) throw e4;
51456         this.errors.push(e4.message);
51457       }), this.chunk = this.normalizeInput(e3), this.file = i3, this.type = this.constructor.type, this.globalOptions = this.options = t2, this.localOptions = t2[this.type], this.canTranslate = this.localOptions && this.localOptions.translate;
51458     }
51459     translate() {
51460       this.canTranslate && (this.translated = this.translateBlock(this.raw, this.type));
51461     }
51462     get output() {
51463       return this.translated ? this.translated : this.raw ? Object.fromEntries(this.raw) : void 0;
51464     }
51465     translateBlock(e3, t2) {
51466       let i3 = N.get(t2), n3 = B.get(t2), s2 = E.get(t2), r2 = this.options[t2], a2 = r2.reviveValues && !!i3, o2 = r2.translateValues && !!n3, l2 = r2.translateKeys && !!s2, h2 = {};
51467       for (let [t3, r3] of e3) a2 && i3.has(t3) ? r3 = i3.get(t3)(r3) : o2 && n3.has(t3) && (r3 = this.translateValue(r3, n3.get(t3))), l2 && s2.has(t3) && (t3 = s2.get(t3) || t3), h2[t3] = r3;
51468       return h2;
51469     }
51470     translateValue(e3, t2) {
51471       return t2[e3] || t2.DEFAULT || e3;
51472     }
51473     assignToOutput(e3, t2) {
51474       this.assignObjectToOutput(e3, this.constructor.type, t2);
51475     }
51476     assignObjectToOutput(e3, t2, i3) {
51477       if (this.globalOptions.mergeOutput) return Object.assign(e3, i3);
51478       e3[t2] ? Object.assign(e3[t2], i3) : e3[t2] = i3;
51479     }
51480   };
51481   c(re2, "headerLength", 4), c(re2, "type", void 0), c(re2, "multiSegment", false), c(re2, "canHandle", () => false);
51482   function ae(e3) {
51483     return 192 === e3 || 194 === e3 || 196 === e3 || 219 === e3 || 221 === e3 || 218 === e3 || 254 === e3;
51484   }
51485   function oe(e3) {
51486     return e3 >= 224 && e3 <= 239;
51487   }
51488   function le(e3, t2, i3) {
51489     for (let [n3, s2] of T) if (s2.canHandle(e3, t2, i3)) return n3;
51490   }
51491   var he = class extends se {
51492     constructor(...e3) {
51493       super(...e3), c(this, "appSegments", []), c(this, "jpegSegments", []), c(this, "unknownSegments", []);
51494     }
51495     static canHandle(e3, t2) {
51496       return 65496 === t2;
51497     }
51498     async parse() {
51499       await this.findAppSegments(), await this.readSegments(this.appSegments), this.mergeMultiSegments(), this.createParsers(this.mergedAppSegments || this.appSegments);
51500     }
51501     setupSegmentFinderArgs(e3) {
51502       true === e3 ? (this.findAll = true, this.wanted = new Set(T.keyList())) : (e3 = void 0 === e3 ? T.keyList().filter((e4) => this.options[e4].enabled) : e3.filter((e4) => this.options[e4].enabled && T.has(e4)), this.findAll = false, this.remaining = new Set(e3), this.wanted = new Set(e3)), this.unfinishedMultiSegment = false;
51503     }
51504     async findAppSegments(e3 = 0, t2) {
51505       this.setupSegmentFinderArgs(t2);
51506       let { file: i3, findAll: n3, wanted: s2, remaining: r2 } = this;
51507       if (!n3 && this.file.chunked && (n3 = Array.from(s2).some((e4) => {
51508         let t3 = T.get(e4), i4 = this.options[e4];
51509         return t3.multiSegment && i4.multiSegment;
51510       }), n3 && await this.file.readWhole()), e3 = this.findAppSegmentsInRange(e3, i3.byteLength), !this.options.onlyTiff && i3.chunked) {
51511         let t3 = false;
51512         for (; r2.size > 0 && !t3 && (i3.canReadNextChunk || this.unfinishedMultiSegment); ) {
51513           let { nextChunkOffset: n4 } = i3, s3 = this.appSegments.some((e4) => !this.file.available(e4.offset || e4.start, e4.length || e4.size));
51514           if (t3 = e3 > n4 && !s3 ? !await i3.readNextChunk(e3) : !await i3.readNextChunk(n4), void 0 === (e3 = this.findAppSegmentsInRange(e3, i3.byteLength))) return;
51515         }
51516       }
51517     }
51518     findAppSegmentsInRange(e3, t2) {
51519       t2 -= 2;
51520       let i3, n3, s2, r2, a2, o2, { file: l2, findAll: h2, wanted: u2, remaining: c2, options: f2 } = this;
51521       for (; e3 < t2; e3++) if (255 === l2.getUint8(e3)) {
51522         if (i3 = l2.getUint8(e3 + 1), oe(i3)) {
51523           if (n3 = l2.getUint16(e3 + 2), s2 = le(l2, e3, n3), s2 && u2.has(s2) && (r2 = T.get(s2), a2 = r2.findPosition(l2, e3), o2 = f2[s2], a2.type = s2, this.appSegments.push(a2), !h2 && (r2.multiSegment && o2.multiSegment ? (this.unfinishedMultiSegment = a2.chunkNumber < a2.chunkCount, this.unfinishedMultiSegment || c2.delete(s2)) : c2.delete(s2), 0 === c2.size))) break;
51524           f2.recordUnknownSegments && (a2 = re2.findPosition(l2, e3), a2.marker = i3, this.unknownSegments.push(a2)), e3 += n3 + 1;
51525         } else if (ae(i3)) {
51526           if (n3 = l2.getUint16(e3 + 2), 218 === i3 && false !== f2.stopAfterSos) return;
51527           f2.recordJpegSegments && this.jpegSegments.push({ offset: e3, length: n3, marker: i3 }), e3 += n3 + 1;
51528         }
51529       }
51530       return e3;
51531     }
51532     mergeMultiSegments() {
51533       if (!this.appSegments.some((e4) => e4.multiSegment)) return;
51534       let e3 = function(e4, t2) {
51535         let i3, n3, s2, r2 = /* @__PURE__ */ new Map();
51536         for (let a2 = 0; a2 < e4.length; a2++) i3 = e4[a2], n3 = i3[t2], r2.has(n3) ? s2 = r2.get(n3) : r2.set(n3, s2 = []), s2.push(i3);
51537         return Array.from(r2);
51538       }(this.appSegments, "type");
51539       this.mergedAppSegments = e3.map(([e4, t2]) => {
51540         let i3 = T.get(e4, this.options);
51541         if (i3.handleMultiSegments) {
51542           return { type: e4, chunk: i3.handleMultiSegments(t2) };
51543         }
51544         return t2[0];
51545       });
51546     }
51547     getSegment(e3) {
51548       return this.appSegments.find((t2) => t2.type === e3);
51549     }
51550     async getOrFindSegment(e3) {
51551       let t2 = this.getSegment(e3);
51552       return void 0 === t2 && (await this.findAppSegments(0, [e3]), t2 = this.getSegment(e3)), t2;
51553     }
51554   };
51555   c(he, "type", "jpeg"), w.set("jpeg", he);
51556   var ue = [void 0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4];
51557   var ce = class extends re2 {
51558     parseHeader() {
51559       var e3 = this.chunk.getUint16();
51560       18761 === e3 ? this.le = true : 19789 === e3 && (this.le = false), this.chunk.le = this.le, this.headerParsed = true;
51561     }
51562     parseTags(e3, t2, i3 = /* @__PURE__ */ new Map()) {
51563       let { pick: n3, skip: s2 } = this.options[t2];
51564       n3 = new Set(n3);
51565       let r2 = n3.size > 0, a2 = 0 === s2.size, o2 = this.chunk.getUint16(e3);
51566       e3 += 2;
51567       for (let l2 = 0; l2 < o2; l2++) {
51568         let o3 = this.chunk.getUint16(e3);
51569         if (r2) {
51570           if (n3.has(o3) && (i3.set(o3, this.parseTag(e3, o3, t2)), n3.delete(o3), 0 === n3.size)) break;
51571         } else !a2 && s2.has(o3) || i3.set(o3, this.parseTag(e3, o3, t2));
51572         e3 += 12;
51573       }
51574       return i3;
51575     }
51576     parseTag(e3, t2, i3) {
51577       let { chunk: n3 } = this, s2 = n3.getUint16(e3 + 2), r2 = n3.getUint32(e3 + 4), a2 = ue[s2];
51578       if (a2 * r2 <= 4 ? e3 += 8 : e3 = n3.getUint32(e3 + 8), (s2 < 1 || s2 > 13) && g2("Invalid TIFF value type. block: ".concat(i3.toUpperCase(), ", tag: ").concat(t2.toString(16), ", type: ").concat(s2, ", offset ").concat(e3)), e3 > n3.byteLength && g2("Invalid TIFF value offset. block: ".concat(i3.toUpperCase(), ", tag: ").concat(t2.toString(16), ", type: ").concat(s2, ", offset ").concat(e3, " is outside of chunk size ").concat(n3.byteLength)), 1 === s2) return n3.getUint8Array(e3, r2);
51579       if (2 === s2) return m(n3.getString(e3, r2));
51580       if (7 === s2) return n3.getUint8Array(e3, r2);
51581       if (1 === r2) return this.parseTagValue(s2, e3);
51582       {
51583         let t3 = new (function(e4) {
51584           switch (e4) {
51585             case 1:
51586               return Uint8Array;
51587             case 3:
51588               return Uint16Array;
51589             case 4:
51590               return Uint32Array;
51591             case 5:
51592               return Array;
51593             case 6:
51594               return Int8Array;
51595             case 8:
51596               return Int16Array;
51597             case 9:
51598               return Int32Array;
51599             case 10:
51600               return Array;
51601             case 11:
51602               return Float32Array;
51603             case 12:
51604               return Float64Array;
51605             default:
51606               return Array;
51607           }
51608         }(s2))(r2), i4 = a2;
51609         for (let n4 = 0; n4 < r2; n4++) t3[n4] = this.parseTagValue(s2, e3), e3 += i4;
51610         return t3;
51611       }
51612     }
51613     parseTagValue(e3, t2) {
51614       let { chunk: i3 } = this;
51615       switch (e3) {
51616         case 1:
51617           return i3.getUint8(t2);
51618         case 3:
51619           return i3.getUint16(t2);
51620         case 4:
51621           return i3.getUint32(t2);
51622         case 5:
51623           return i3.getUint32(t2) / i3.getUint32(t2 + 4);
51624         case 6:
51625           return i3.getInt8(t2);
51626         case 8:
51627           return i3.getInt16(t2);
51628         case 9:
51629           return i3.getInt32(t2);
51630         case 10:
51631           return i3.getInt32(t2) / i3.getInt32(t2 + 4);
51632         case 11:
51633           return i3.getFloat(t2);
51634         case 12:
51635           return i3.getDouble(t2);
51636         case 13:
51637           return i3.getUint32(t2);
51638         default:
51639           g2("Invalid tiff type ".concat(e3));
51640       }
51641     }
51642   };
51643   var fe = class extends ce {
51644     static canHandle(e3, t2) {
51645       return 225 === e3.getUint8(t2 + 1) && 1165519206 === e3.getUint32(t2 + 4) && 0 === e3.getUint16(t2 + 8);
51646     }
51647     async parse() {
51648       this.parseHeader();
51649       let { options: e3 } = this;
51650       return e3.ifd0.enabled && await this.parseIfd0Block(), e3.exif.enabled && await this.safeParse("parseExifBlock"), e3.gps.enabled && await this.safeParse("parseGpsBlock"), e3.interop.enabled && await this.safeParse("parseInteropBlock"), e3.ifd1.enabled && await this.safeParse("parseThumbnailBlock"), this.createOutput();
51651     }
51652     safeParse(e3) {
51653       let t2 = this[e3]();
51654       return void 0 !== t2.catch && (t2 = t2.catch(this.handleError)), t2;
51655     }
51656     findIfd0Offset() {
51657       void 0 === this.ifd0Offset && (this.ifd0Offset = this.chunk.getUint32(4));
51658     }
51659     findIfd1Offset() {
51660       if (void 0 === this.ifd1Offset) {
51661         this.findIfd0Offset();
51662         let e3 = this.chunk.getUint16(this.ifd0Offset), t2 = this.ifd0Offset + 2 + 12 * e3;
51663         this.ifd1Offset = this.chunk.getUint32(t2);
51664       }
51665     }
51666     parseBlock(e3, t2) {
51667       let i3 = /* @__PURE__ */ new Map();
51668       return this[t2] = i3, this.parseTags(e3, t2, i3), i3;
51669     }
51670     async parseIfd0Block() {
51671       if (this.ifd0) return;
51672       let { file: e3 } = this;
51673       this.findIfd0Offset(), this.ifd0Offset < 8 && g2("Malformed EXIF data"), !e3.chunked && this.ifd0Offset > e3.byteLength && g2("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset, ", file.byteLength: ").concat(e3.byteLength)), e3.tiff && await e3.ensureChunk(this.ifd0Offset, S(this.options));
51674       let t2 = this.parseBlock(this.ifd0Offset, "ifd0");
51675       return 0 !== t2.size ? (this.exifOffset = t2.get(34665), this.interopOffset = t2.get(40965), this.gpsOffset = t2.get(34853), this.xmp = t2.get(700), this.iptc = t2.get(33723), this.icc = t2.get(34675), this.options.sanitize && (t2.delete(34665), t2.delete(40965), t2.delete(34853), t2.delete(700), t2.delete(33723), t2.delete(34675)), t2) : void 0;
51676     }
51677     async parseExifBlock() {
51678       if (this.exif) return;
51679       if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.exifOffset) return;
51680       this.file.tiff && await this.file.ensureChunk(this.exifOffset, S(this.options));
51681       let e3 = this.parseBlock(this.exifOffset, "exif");
51682       return this.interopOffset || (this.interopOffset = e3.get(40965)), this.makerNote = e3.get(37500), this.userComment = e3.get(37510), this.options.sanitize && (e3.delete(40965), e3.delete(37500), e3.delete(37510)), this.unpack(e3, 41728), this.unpack(e3, 41729), e3;
51683     }
51684     unpack(e3, t2) {
51685       let i3 = e3.get(t2);
51686       i3 && 1 === i3.length && e3.set(t2, i3[0]);
51687     }
51688     async parseGpsBlock() {
51689       if (this.gps) return;
51690       if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.gpsOffset) return;
51691       let e3 = this.parseBlock(this.gpsOffset, "gps");
51692       return e3 && e3.has(2) && e3.has(4) && (e3.set("latitude", de(...e3.get(2), e3.get(1))), e3.set("longitude", de(...e3.get(4), e3.get(3)))), e3;
51693     }
51694     async parseInteropBlock() {
51695       if (!this.interop && (this.ifd0 || await this.parseIfd0Block(), void 0 !== this.interopOffset || this.exif || await this.parseExifBlock(), void 0 !== this.interopOffset)) return this.parseBlock(this.interopOffset, "interop");
51696     }
51697     async parseThumbnailBlock(e3 = false) {
51698       if (!this.ifd1 && !this.ifd1Parsed && (!this.options.mergeOutput || e3)) return this.findIfd1Offset(), this.ifd1Offset > 0 && (this.parseBlock(this.ifd1Offset, "ifd1"), this.ifd1Parsed = true), this.ifd1;
51699     }
51700     async extractThumbnail() {
51701       if (this.headerParsed || this.parseHeader(), this.ifd1Parsed || await this.parseThumbnailBlock(true), void 0 === this.ifd1) return;
51702       let e3 = this.ifd1.get(513), t2 = this.ifd1.get(514);
51703       return this.chunk.getUint8Array(e3, t2);
51704     }
51705     get image() {
51706       return this.ifd0;
51707     }
51708     get thumbnail() {
51709       return this.ifd1;
51710     }
51711     createOutput() {
51712       let e3, t2, i3, n3 = {};
51713       for (t2 of H) if (e3 = this[t2], !p(e3)) if (i3 = this.canTranslate ? this.translateBlock(e3, t2) : Object.fromEntries(e3), this.options.mergeOutput) {
51714         if ("ifd1" === t2) continue;
51715         Object.assign(n3, i3);
51716       } else n3[t2] = i3;
51717       return this.makerNote && (n3.makerNote = this.makerNote), this.userComment && (n3.userComment = this.userComment), n3;
51718     }
51719     assignToOutput(e3, t2) {
51720       if (this.globalOptions.mergeOutput) Object.assign(e3, t2);
51721       else for (let [i3, n3] of Object.entries(t2)) this.assignObjectToOutput(e3, i3, n3);
51722     }
51723   };
51724   function de(e3, t2, i3, n3) {
51725     var s2 = e3 + t2 / 60 + i3 / 3600;
51726     return "S" !== n3 && "W" !== n3 || (s2 *= -1), s2;
51727   }
51728   c(fe, "type", "tiff"), c(fe, "headerLength", 10), T.set("tiff", fe);
51729   var pe = Object.freeze({ __proto__: null, default: ne, Exifr: te, fileParsers: w, segmentParsers: T, fileReaders: A, tagKeys: E, tagValues: B, tagRevivers: N, createDictionary: U, extendDictionary: F, fetchUrlAsArrayBuffer: M, readBlobAsArrayBuffer: R, chunkedProps: G, otherSegments: V, segments: z, tiffBlocks: H, segmentsAndBlocks: j, tiffExtractables: W, inheritables: K, allFormatters: X, Options: q, parse: ie });
51730   var ge = { ifd0: false, ifd1: false, exif: false, gps: false, interop: false, sanitize: false, reviveValues: true, translateKeys: false, translateValues: false, mergeOutput: false };
51731   var me = Object.assign({}, ge, { firstChunkSize: 4e4, gps: [1, 2, 3, 4] });
51732   async function Se(e3) {
51733     let t2 = new te(me);
51734     await t2.read(e3);
51735     let i3 = await t2.parse();
51736     if (i3 && i3.gps) {
51737       let { latitude: e4, longitude: t3 } = i3.gps;
51738       return { latitude: e4, longitude: t3 };
51739     }
51740   }
51741   var Ce = Object.assign({}, ge, { tiff: false, ifd1: true, mergeOutput: false });
51742   async function ye(e3) {
51743     let t2 = new te(Ce);
51744     await t2.read(e3);
51745     let i3 = await t2.extractThumbnail();
51746     return i3 && a ? s.from(i3) : i3;
51747   }
51748   async function be(e3) {
51749     let t2 = await this.thumbnail(e3);
51750     if (void 0 !== t2) {
51751       let e4 = new Blob([t2]);
51752       return URL.createObjectURL(e4);
51753     }
51754   }
51755   var Ie = Object.assign({}, ge, { firstChunkSize: 4e4, ifd0: [274] });
51756   async function Pe(e3) {
51757     let t2 = new te(Ie);
51758     await t2.read(e3);
51759     let i3 = await t2.parse();
51760     if (i3 && i3.ifd0) return i3.ifd0[274];
51761   }
51762   var ke = Object.freeze({ 1: { dimensionSwapped: false, scaleX: 1, scaleY: 1, deg: 0, rad: 0 }, 2: { dimensionSwapped: false, scaleX: -1, scaleY: 1, deg: 0, rad: 0 }, 3: { dimensionSwapped: false, scaleX: 1, scaleY: 1, deg: 180, rad: 180 * Math.PI / 180 }, 4: { dimensionSwapped: false, scaleX: -1, scaleY: 1, deg: 180, rad: 180 * Math.PI / 180 }, 5: { dimensionSwapped: true, scaleX: 1, scaleY: -1, deg: 90, rad: 90 * Math.PI / 180 }, 6: { dimensionSwapped: true, scaleX: 1, scaleY: 1, deg: 90, rad: 90 * Math.PI / 180 }, 7: { dimensionSwapped: true, scaleX: 1, scaleY: -1, deg: 270, rad: 270 * Math.PI / 180 }, 8: { dimensionSwapped: true, scaleX: 1, scaleY: 1, deg: 270, rad: 270 * Math.PI / 180 } });
51763   var we = true;
51764   var Te = true;
51765   if ("object" == typeof navigator) {
51766     let e3 = navigator.userAgent;
51767     if (e3.includes("iPad") || e3.includes("iPhone")) {
51768       let t2 = e3.match(/OS (\d+)_(\d+)/);
51769       if (t2) {
51770         let [, e4, i3] = t2, n3 = Number(e4) + 0.1 * Number(i3);
51771         we = n3 < 13.4, Te = false;
51772       }
51773     } else if (e3.includes("OS X 10")) {
51774       let [, t2] = e3.match(/OS X 10[_.](\d+)/);
51775       we = Te = Number(t2) < 15;
51776     }
51777     if (e3.includes("Chrome/")) {
51778       let [, t2] = e3.match(/Chrome\/(\d+)/);
51779       we = Te = Number(t2) < 81;
51780     } else if (e3.includes("Firefox/")) {
51781       let [, t2] = e3.match(/Firefox\/(\d+)/);
51782       we = Te = Number(t2) < 77;
51783     }
51784   }
51785   async function Ae(e3) {
51786     let t2 = await Pe(e3);
51787     return Object.assign({ canvas: we, css: Te }, ke[t2]);
51788   }
51789   var De = class extends I {
51790     constructor(...e3) {
51791       super(...e3), c(this, "ranges", new Oe()), 0 !== this.byteLength && this.ranges.add(0, this.byteLength);
51792     }
51793     _tryExtend(e3, t2, i3) {
51794       if (0 === e3 && 0 === this.byteLength && i3) {
51795         let e4 = new DataView(i3.buffer || i3, i3.byteOffset, i3.byteLength);
51796         this._swapDataView(e4);
51797       } else {
51798         let i4 = e3 + t2;
51799         if (i4 > this.byteLength) {
51800           let { dataView: e4 } = this._extend(i4);
51801           this._swapDataView(e4);
51802         }
51803       }
51804     }
51805     _extend(e3) {
51806       let t2;
51807       t2 = a ? s.allocUnsafe(e3) : new Uint8Array(e3);
51808       let i3 = new DataView(t2.buffer, t2.byteOffset, t2.byteLength);
51809       return t2.set(new Uint8Array(this.buffer, this.byteOffset, this.byteLength), 0), { uintView: t2, dataView: i3 };
51810     }
51811     subarray(e3, t2, i3 = false) {
51812       return t2 = t2 || this._lengthToEnd(e3), i3 && this._tryExtend(e3, t2), this.ranges.add(e3, t2), super.subarray(e3, t2);
51813     }
51814     set(e3, t2, i3 = false) {
51815       i3 && this._tryExtend(t2, e3.byteLength, e3);
51816       let n3 = super.set(e3, t2);
51817       return this.ranges.add(t2, n3.byteLength), n3;
51818     }
51819     async ensureChunk(e3, t2) {
51820       this.chunked && (this.ranges.available(e3, t2) || await this.readChunk(e3, t2));
51821     }
51822     available(e3, t2) {
51823       return this.ranges.available(e3, t2);
51824     }
51825   };
51826   var Oe = class {
51827     constructor() {
51828       c(this, "list", []);
51829     }
51830     get length() {
51831       return this.list.length;
51832     }
51833     add(e3, t2, i3 = 0) {
51834       let n3 = e3 + t2, s2 = this.list.filter((t3) => xe(e3, t3.offset, n3) || xe(e3, t3.end, n3));
51835       if (s2.length > 0) {
51836         e3 = Math.min(e3, ...s2.map((e4) => e4.offset)), n3 = Math.max(n3, ...s2.map((e4) => e4.end)), t2 = n3 - e3;
51837         let i4 = s2.shift();
51838         i4.offset = e3, i4.length = t2, i4.end = n3, this.list = this.list.filter((e4) => !s2.includes(e4));
51839       } else this.list.push({ offset: e3, length: t2, end: n3 });
51840     }
51841     available(e3, t2) {
51842       let i3 = e3 + t2;
51843       return this.list.some((t3) => t3.offset <= e3 && i3 <= t3.end);
51844     }
51845   };
51846   function xe(e3, t2, i3) {
51847     return e3 <= t2 && t2 <= i3;
51848   }
51849   var ve = class extends De {
51850     constructor(e3, t2) {
51851       super(0), c(this, "chunksRead", 0), this.input = e3, this.options = t2;
51852     }
51853     async readWhole() {
51854       this.chunked = false, await this.readChunk(this.nextChunkOffset);
51855     }
51856     async readChunked() {
51857       this.chunked = true, await this.readChunk(0, this.options.firstChunkSize);
51858     }
51859     async readNextChunk(e3 = this.nextChunkOffset) {
51860       if (this.fullyRead) return this.chunksRead++, false;
51861       let t2 = this.options.chunkSize, i3 = await this.readChunk(e3, t2);
51862       return !!i3 && i3.byteLength === t2;
51863     }
51864     async readChunk(e3, t2) {
51865       if (this.chunksRead++, 0 !== (t2 = this.safeWrapAddress(e3, t2))) return this._readChunk(e3, t2);
51866     }
51867     safeWrapAddress(e3, t2) {
51868       return void 0 !== this.size && e3 + t2 > this.size ? Math.max(0, this.size - e3) : t2;
51869     }
51870     get nextChunkOffset() {
51871       if (0 !== this.ranges.list.length) return this.ranges.list[0].length;
51872     }
51873     get canReadNextChunk() {
51874       return this.chunksRead < this.options.chunkLimit;
51875     }
51876     get fullyRead() {
51877       return void 0 !== this.size && this.nextChunkOffset === this.size;
51878     }
51879     read() {
51880       return this.options.chunked ? this.readChunked() : this.readWhole();
51881     }
51882     close() {
51883     }
51884   };
51885   A.set("blob", class extends ve {
51886     async readWhole() {
51887       this.chunked = false;
51888       let e3 = await R(this.input);
51889       this._swapArrayBuffer(e3);
51890     }
51891     readChunked() {
51892       return this.chunked = true, this.size = this.input.size, super.readChunked();
51893     }
51894     async _readChunk(e3, t2) {
51895       let i3 = t2 ? e3 + t2 : void 0, n3 = this.input.slice(e3, i3), s2 = await R(n3);
51896       return this.set(s2, e3, true);
51897     }
51898   });
51899   var Me = Object.freeze({ __proto__: null, default: pe, Exifr: te, fileParsers: w, segmentParsers: T, fileReaders: A, tagKeys: E, tagValues: B, tagRevivers: N, createDictionary: U, extendDictionary: F, fetchUrlAsArrayBuffer: M, readBlobAsArrayBuffer: R, chunkedProps: G, otherSegments: V, segments: z, tiffBlocks: H, segmentsAndBlocks: j, tiffExtractables: W, inheritables: K, allFormatters: X, Options: q, parse: ie, gpsOnlyOptions: me, gps: Se, thumbnailOnlyOptions: Ce, thumbnail: ye, thumbnailUrl: be, orientationOnlyOptions: Ie, orientation: Pe, rotations: ke, get rotateCanvas() {
51900     return we;
51901   }, get rotateCss() {
51902     return Te;
51903   }, rotation: Ae });
51904   A.set("url", class extends ve {
51905     async readWhole() {
51906       this.chunked = false;
51907       let e3 = await M(this.input);
51908       e3 instanceof ArrayBuffer ? this._swapArrayBuffer(e3) : e3 instanceof Uint8Array && this._swapBuffer(e3);
51909     }
51910     async _readChunk(e3, t2) {
51911       let i3 = t2 ? e3 + t2 - 1 : void 0, n3 = this.options.httpHeaders || {};
51912       (e3 || i3) && (n3.range = "bytes=".concat([e3, i3].join("-")));
51913       let s2 = await h(this.input, { headers: n3 }), r2 = await s2.arrayBuffer(), a2 = r2.byteLength;
51914       if (416 !== s2.status) return a2 !== t2 && (this.size = e3 + a2), this.set(r2, e3, true);
51915     }
51916   });
51917   I.prototype.getUint64 = function(e3) {
51918     let t2 = this.getUint32(e3), i3 = this.getUint32(e3 + 4);
51919     return t2 < 1048575 ? t2 << 32 | i3 : void 0 !== typeof r ? (console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."), r(t2) << r(32) | r(i3)) : void g2("Trying to read 64b value but JS can only handle 53b numbers.");
51920   };
51921   var Re = class extends se {
51922     parseBoxes(e3 = 0) {
51923       let t2 = [];
51924       for (; e3 < this.file.byteLength - 4; ) {
51925         let i3 = this.parseBoxHead(e3);
51926         if (t2.push(i3), 0 === i3.length) break;
51927         e3 += i3.length;
51928       }
51929       return t2;
51930     }
51931     parseSubBoxes(e3) {
51932       e3.boxes = this.parseBoxes(e3.start);
51933     }
51934     findBox(e3, t2) {
51935       return void 0 === e3.boxes && this.parseSubBoxes(e3), e3.boxes.find((e4) => e4.kind === t2);
51936     }
51937     parseBoxHead(e3) {
51938       let t2 = this.file.getUint32(e3), i3 = this.file.getString(e3 + 4, 4), n3 = e3 + 8;
51939       return 1 === t2 && (t2 = this.file.getUint64(e3 + 8), n3 += 8), { offset: e3, length: t2, kind: i3, start: n3 };
51940     }
51941     parseBoxFullHead(e3) {
51942       if (void 0 !== e3.version) return;
51943       let t2 = this.file.getUint32(e3.start);
51944       e3.version = t2 >> 24, e3.start += 4;
51945     }
51946   };
51947   var Le = class extends Re {
51948     static canHandle(e3, t2) {
51949       if (0 !== t2) return false;
51950       let i3 = e3.getUint16(2);
51951       if (i3 > 50) return false;
51952       let n3 = 16, s2 = [];
51953       for (; n3 < i3; ) s2.push(e3.getString(n3, 4)), n3 += 4;
51954       return s2.includes(this.type);
51955     }
51956     async parse() {
51957       let e3 = this.file.getUint32(0), t2 = this.parseBoxHead(e3);
51958       for (; "meta" !== t2.kind; ) e3 += t2.length, await this.file.ensureChunk(e3, 16), t2 = this.parseBoxHead(e3);
51959       await this.file.ensureChunk(t2.offset, t2.length), this.parseBoxFullHead(t2), this.parseSubBoxes(t2), this.options.icc.enabled && await this.findIcc(t2), this.options.tiff.enabled && await this.findExif(t2);
51960     }
51961     async registerSegment(e3, t2, i3) {
51962       await this.file.ensureChunk(t2, i3);
51963       let n3 = this.file.subarray(t2, i3);
51964       this.createParser(e3, n3);
51965     }
51966     async findIcc(e3) {
51967       let t2 = this.findBox(e3, "iprp");
51968       if (void 0 === t2) return;
51969       let i3 = this.findBox(t2, "ipco");
51970       if (void 0 === i3) return;
51971       let n3 = this.findBox(i3, "colr");
51972       void 0 !== n3 && await this.registerSegment("icc", n3.offset + 12, n3.length);
51973     }
51974     async findExif(e3) {
51975       let t2 = this.findBox(e3, "iinf");
51976       if (void 0 === t2) return;
51977       let i3 = this.findBox(e3, "iloc");
51978       if (void 0 === i3) return;
51979       let n3 = this.findExifLocIdInIinf(t2), s2 = this.findExtentInIloc(i3, n3);
51980       if (void 0 === s2) return;
51981       let [r2, a2] = s2;
51982       await this.file.ensureChunk(r2, a2);
51983       let o2 = 4 + this.file.getUint32(r2);
51984       r2 += o2, a2 -= o2, await this.registerSegment("tiff", r2, a2);
51985     }
51986     findExifLocIdInIinf(e3) {
51987       this.parseBoxFullHead(e3);
51988       let t2, i3, n3, s2, r2 = e3.start, a2 = this.file.getUint16(r2);
51989       for (r2 += 2; a2--; ) {
51990         if (t2 = this.parseBoxHead(r2), this.parseBoxFullHead(t2), i3 = t2.start, t2.version >= 2 && (n3 = 3 === t2.version ? 4 : 2, s2 = this.file.getString(i3 + n3 + 2, 4), "Exif" === s2)) return this.file.getUintBytes(i3, n3);
51991         r2 += t2.length;
51992       }
51993     }
51994     get8bits(e3) {
51995       let t2 = this.file.getUint8(e3);
51996       return [t2 >> 4, 15 & t2];
51997     }
51998     findExtentInIloc(e3, t2) {
51999       this.parseBoxFullHead(e3);
52000       let i3 = e3.start, [n3, s2] = this.get8bits(i3++), [r2, a2] = this.get8bits(i3++), o2 = 2 === e3.version ? 4 : 2, l2 = 1 === e3.version || 2 === e3.version ? 2 : 0, h2 = a2 + n3 + s2, u2 = 2 === e3.version ? 4 : 2, c2 = this.file.getUintBytes(i3, u2);
52001       for (i3 += u2; c2--; ) {
52002         let e4 = this.file.getUintBytes(i3, o2);
52003         i3 += o2 + l2 + 2 + r2;
52004         let u3 = this.file.getUint16(i3);
52005         if (i3 += 2, e4 === t2) return u3 > 1 && console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"), [this.file.getUintBytes(i3 + a2, n3), this.file.getUintBytes(i3 + a2 + n3, s2)];
52006         i3 += u3 * h2;
52007       }
52008     }
52009   };
52010   var Ue = class extends Le {
52011   };
52012   c(Ue, "type", "heic");
52013   var Fe = class extends Le {
52014   };
52015   c(Fe, "type", "avif"), w.set("heic", Ue), w.set("avif", Fe), U(E, ["ifd0", "ifd1"], [[256, "ImageWidth"], [257, "ImageHeight"], [258, "BitsPerSample"], [259, "Compression"], [262, "PhotometricInterpretation"], [270, "ImageDescription"], [271, "Make"], [272, "Model"], [273, "StripOffsets"], [274, "Orientation"], [277, "SamplesPerPixel"], [278, "RowsPerStrip"], [279, "StripByteCounts"], [282, "XResolution"], [283, "YResolution"], [284, "PlanarConfiguration"], [296, "ResolutionUnit"], [301, "TransferFunction"], [305, "Software"], [306, "ModifyDate"], [315, "Artist"], [316, "HostComputer"], [317, "Predictor"], [318, "WhitePoint"], [319, "PrimaryChromaticities"], [513, "ThumbnailOffset"], [514, "ThumbnailLength"], [529, "YCbCrCoefficients"], [530, "YCbCrSubSampling"], [531, "YCbCrPositioning"], [532, "ReferenceBlackWhite"], [700, "ApplicationNotes"], [33432, "Copyright"], [33723, "IPTC"], [34665, "ExifIFD"], [34675, "ICC"], [34853, "GpsIFD"], [330, "SubIFD"], [40965, "InteropIFD"], [40091, "XPTitle"], [40092, "XPComment"], [40093, "XPAuthor"], [40094, "XPKeywords"], [40095, "XPSubject"]]), U(E, "exif", [[33434, "ExposureTime"], [33437, "FNumber"], [34850, "ExposureProgram"], [34852, "SpectralSensitivity"], [34855, "ISO"], [34858, "TimeZoneOffset"], [34859, "SelfTimerMode"], [34864, "SensitivityType"], [34865, "StandardOutputSensitivity"], [34866, "RecommendedExposureIndex"], [34867, "ISOSpeed"], [34868, "ISOSpeedLatitudeyyy"], [34869, "ISOSpeedLatitudezzz"], [36864, "ExifVersion"], [36867, "DateTimeOriginal"], [36868, "CreateDate"], [36873, "GooglePlusUploadCode"], [36880, "OffsetTime"], [36881, "OffsetTimeOriginal"], [36882, "OffsetTimeDigitized"], [37121, "ComponentsConfiguration"], [37122, "CompressedBitsPerPixel"], [37377, "ShutterSpeedValue"], [37378, "ApertureValue"], [37379, "BrightnessValue"], [37380, "ExposureCompensation"], [37381, "MaxApertureValue"], [37382, "SubjectDistance"], [37383, "MeteringMode"], [37384, "LightSource"], [37385, "Flash"], [37386, "FocalLength"], [37393, "ImageNumber"], [37394, "SecurityClassification"], [37395, "ImageHistory"], [37396, "SubjectArea"], [37500, "MakerNote"], [37510, "UserComment"], [37520, "SubSecTime"], [37521, "SubSecTimeOriginal"], [37522, "SubSecTimeDigitized"], [37888, "AmbientTemperature"], [37889, "Humidity"], [37890, "Pressure"], [37891, "WaterDepth"], [37892, "Acceleration"], [37893, "CameraElevationAngle"], [40960, "FlashpixVersion"], [40961, "ColorSpace"], [40962, "ExifImageWidth"], [40963, "ExifImageHeight"], [40964, "RelatedSoundFile"], [41483, "FlashEnergy"], [41486, "FocalPlaneXResolution"], [41487, "FocalPlaneYResolution"], [41488, "FocalPlaneResolutionUnit"], [41492, "SubjectLocation"], [41493, "ExposureIndex"], [41495, "SensingMethod"], [41728, "FileSource"], [41729, "SceneType"], [41730, "CFAPattern"], [41985, "CustomRendered"], [41986, "ExposureMode"], [41987, "WhiteBalance"], [41988, "DigitalZoomRatio"], [41989, "FocalLengthIn35mmFormat"], [41990, "SceneCaptureType"], [41991, "GainControl"], [41992, "Contrast"], [41993, "Saturation"], [41994, "Sharpness"], [41996, "SubjectDistanceRange"], [42016, "ImageUniqueID"], [42032, "OwnerName"], [42033, "SerialNumber"], [42034, "LensInfo"], [42035, "LensMake"], [42036, "LensModel"], [42037, "LensSerialNumber"], [42080, "CompositeImage"], [42081, "CompositeImageCount"], [42082, "CompositeImageExposureTimes"], [42240, "Gamma"], [59932, "Padding"], [59933, "OffsetSchema"], [65e3, "OwnerName"], [65001, "SerialNumber"], [65002, "Lens"], [65100, "RawFile"], [65101, "Converter"], [65102, "WhiteBalance"], [65105, "Exposure"], [65106, "Shadows"], [65107, "Brightness"], [65108, "Contrast"], [65109, "Saturation"], [65110, "Sharpness"], [65111, "Smoothness"], [65112, "MoireFilter"], [40965, "InteropIFD"]]), U(E, "gps", [[0, "GPSVersionID"], [1, "GPSLatitudeRef"], [2, "GPSLatitude"], [3, "GPSLongitudeRef"], [4, "GPSLongitude"], [5, "GPSAltitudeRef"], [6, "GPSAltitude"], [7, "GPSTimeStamp"], [8, "GPSSatellites"], [9, "GPSStatus"], [10, "GPSMeasureMode"], [11, "GPSDOP"], [12, "GPSSpeedRef"], [13, "GPSSpeed"], [14, "GPSTrackRef"], [15, "GPSTrack"], [16, "GPSImgDirectionRef"], [17, "GPSImgDirection"], [18, "GPSMapDatum"], [19, "GPSDestLatitudeRef"], [20, "GPSDestLatitude"], [21, "GPSDestLongitudeRef"], [22, "GPSDestLongitude"], [23, "GPSDestBearingRef"], [24, "GPSDestBearing"], [25, "GPSDestDistanceRef"], [26, "GPSDestDistance"], [27, "GPSProcessingMethod"], [28, "GPSAreaInformation"], [29, "GPSDateStamp"], [30, "GPSDifferential"], [31, "GPSHPositioningError"]]), U(B, ["ifd0", "ifd1"], [[274, { 1: "Horizontal (normal)", 2: "Mirror horizontal", 3: "Rotate 180", 4: "Mirror vertical", 5: "Mirror horizontal and rotate 270 CW", 6: "Rotate 90 CW", 7: "Mirror horizontal and rotate 90 CW", 8: "Rotate 270 CW" }], [296, { 1: "None", 2: "inches", 3: "cm" }]]);
52016   var Ee = U(B, "exif", [[34850, { 0: "Not defined", 1: "Manual", 2: "Normal program", 3: "Aperture priority", 4: "Shutter priority", 5: "Creative program", 6: "Action program", 7: "Portrait mode", 8: "Landscape mode" }], [37121, { 0: "-", 1: "Y", 2: "Cb", 3: "Cr", 4: "R", 5: "G", 6: "B" }], [37383, { 0: "Unknown", 1: "Average", 2: "CenterWeightedAverage", 3: "Spot", 4: "MultiSpot", 5: "Pattern", 6: "Partial", 255: "Other" }], [37384, { 0: "Unknown", 1: "Daylight", 2: "Fluorescent", 3: "Tungsten (incandescent light)", 4: "Flash", 9: "Fine weather", 10: "Cloudy weather", 11: "Shade", 12: "Daylight fluorescent (D 5700 - 7100K)", 13: "Day white fluorescent (N 4600 - 5400K)", 14: "Cool white fluorescent (W 3900 - 4500K)", 15: "White fluorescent (WW 3200 - 3700K)", 17: "Standard light A", 18: "Standard light B", 19: "Standard light C", 20: "D55", 21: "D65", 22: "D75", 23: "D50", 24: "ISO studio tungsten", 255: "Other" }], [37385, { 0: "Flash did not fire", 1: "Flash fired", 5: "Strobe return light not detected", 7: "Strobe return light detected", 9: "Flash fired, compulsory flash mode", 13: "Flash fired, compulsory flash mode, return light not detected", 15: "Flash fired, compulsory flash mode, return light detected", 16: "Flash did not fire, compulsory flash mode", 24: "Flash did not fire, auto mode", 25: "Flash fired, auto mode", 29: "Flash fired, auto mode, return light not detected", 31: "Flash fired, auto mode, return light detected", 32: "No flash function", 65: "Flash fired, red-eye reduction mode", 69: "Flash fired, red-eye reduction mode, return light not detected", 71: "Flash fired, red-eye reduction mode, return light detected", 73: "Flash fired, compulsory flash mode, red-eye reduction mode", 77: "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected", 79: "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected", 89: "Flash fired, auto mode, red-eye reduction mode", 93: "Flash fired, auto mode, return light not detected, red-eye reduction mode", 95: "Flash fired, auto mode, return light detected, red-eye reduction mode" }], [41495, { 1: "Not defined", 2: "One-chip color area sensor", 3: "Two-chip color area sensor", 4: "Three-chip color area sensor", 5: "Color sequential area sensor", 7: "Trilinear sensor", 8: "Color sequential linear sensor" }], [41728, { 1: "Film Scanner", 2: "Reflection Print Scanner", 3: "Digital Camera" }], [41729, { 1: "Directly photographed" }], [41985, { 0: "Normal", 1: "Custom", 2: "HDR (no original saved)", 3: "HDR (original saved)", 4: "Original (for HDR)", 6: "Panorama", 7: "Portrait HDR", 8: "Portrait" }], [41986, { 0: "Auto", 1: "Manual", 2: "Auto bracket" }], [41987, { 0: "Auto", 1: "Manual" }], [41990, { 0: "Standard", 1: "Landscape", 2: "Portrait", 3: "Night", 4: "Other" }], [41991, { 0: "None", 1: "Low gain up", 2: "High gain up", 3: "Low gain down", 4: "High gain down" }], [41996, { 0: "Unknown", 1: "Macro", 2: "Close", 3: "Distant" }], [42080, { 0: "Unknown", 1: "Not a Composite Image", 2: "General Composite Image", 3: "Composite Image Captured While Shooting" }]]);
52017   var Be = { 1: "No absolute unit of measurement", 2: "Inch", 3: "Centimeter" };
52018   Ee.set(37392, Be), Ee.set(41488, Be);
52019   var Ne = { 0: "Normal", 1: "Low", 2: "High" };
52020   function Ge(e3) {
52021     return "object" == typeof e3 && void 0 !== e3.length ? e3[0] : e3;
52022   }
52023   function Ve(e3) {
52024     let t2 = Array.from(e3).slice(1);
52025     return t2[1] > 15 && (t2 = t2.map((e4) => String.fromCharCode(e4))), "0" !== t2[2] && 0 !== t2[2] || t2.pop(), t2.join(".");
52026   }
52027   function ze(e3) {
52028     if ("string" == typeof e3) {
52029       var [t2, i3, n3, s2, r2, a2] = e3.trim().split(/[-: ]/g).map(Number), o2 = new Date(t2, i3 - 1, n3);
52030       return Number.isNaN(s2) || Number.isNaN(r2) || Number.isNaN(a2) || (o2.setHours(s2), o2.setMinutes(r2), o2.setSeconds(a2)), Number.isNaN(+o2) ? e3 : o2;
52031     }
52032   }
52033   function He(e3) {
52034     if ("string" == typeof e3) return e3;
52035     let t2 = [];
52036     if (0 === e3[1] && 0 === e3[e3.length - 1]) for (let i3 = 0; i3 < e3.length; i3 += 2) t2.push(je(e3[i3 + 1], e3[i3]));
52037     else for (let i3 = 0; i3 < e3.length; i3 += 2) t2.push(je(e3[i3], e3[i3 + 1]));
52038     return m(String.fromCodePoint(...t2));
52039   }
52040   function je(e3, t2) {
52041     return e3 << 8 | t2;
52042   }
52043   Ee.set(41992, Ne), Ee.set(41993, Ne), Ee.set(41994, Ne), U(N, ["ifd0", "ifd1"], [[50827, function(e3) {
52044     return "string" != typeof e3 ? b(e3) : e3;
52045   }], [306, ze], [40091, He], [40092, He], [40093, He], [40094, He], [40095, He]]), U(N, "exif", [[40960, Ve], [36864, Ve], [36867, ze], [36868, ze], [40962, Ge], [40963, Ge]]), U(N, "gps", [[0, (e3) => Array.from(e3).join(".")], [7, (e3) => Array.from(e3).join(":")]]);
52046   var We = class extends re2 {
52047     static canHandle(e3, t2) {
52048       return 225 === e3.getUint8(t2 + 1) && 1752462448 === e3.getUint32(t2 + 4) && "http://ns.adobe.com/" === e3.getString(t2 + 4, "http://ns.adobe.com/".length);
52049     }
52050     static headerLength(e3, t2) {
52051       return "http://ns.adobe.com/xmp/extension/" === e3.getString(t2 + 4, "http://ns.adobe.com/xmp/extension/".length) ? 79 : 4 + "http://ns.adobe.com/xap/1.0/".length + 1;
52052     }
52053     static findPosition(e3, t2) {
52054       let i3 = super.findPosition(e3, t2);
52055       return i3.multiSegment = i3.extended = 79 === i3.headerLength, i3.multiSegment ? (i3.chunkCount = e3.getUint8(t2 + 72), i3.chunkNumber = e3.getUint8(t2 + 76), 0 !== e3.getUint8(t2 + 77) && i3.chunkNumber++) : (i3.chunkCount = 1 / 0, i3.chunkNumber = -1), i3;
52056     }
52057     static handleMultiSegments(e3) {
52058       return e3.map((e4) => e4.chunk.getString()).join("");
52059     }
52060     normalizeInput(e3) {
52061       return "string" == typeof e3 ? e3 : I.from(e3).getString();
52062     }
52063     parse(e3 = this.chunk) {
52064       if (!this.localOptions.parse) return e3;
52065       e3 = function(e4) {
52066         let t3 = {}, i4 = {};
52067         for (let e6 of Ze) t3[e6] = [], i4[e6] = 0;
52068         return e4.replace(et, (e6, n4, s2) => {
52069           if ("<" === n4) {
52070             let n5 = ++i4[s2];
52071             return t3[s2].push(n5), "".concat(e6, "#").concat(n5);
52072           }
52073           return "".concat(e6, "#").concat(t3[s2].pop());
52074         });
52075       }(e3);
52076       let t2 = Xe.findAll(e3, "rdf", "Description");
52077       0 === t2.length && t2.push(new Xe("rdf", "Description", void 0, e3));
52078       let i3, n3 = {};
52079       for (let e4 of t2) for (let t3 of e4.properties) i3 = Je(t3.ns, n3), _e(t3, i3);
52080       return function(e4) {
52081         let t3;
52082         for (let i4 in e4) t3 = e4[i4] = f(e4[i4]), void 0 === t3 && delete e4[i4];
52083         return f(e4);
52084       }(n3);
52085     }
52086     assignToOutput(e3, t2) {
52087       if (this.localOptions.parse) for (let [i3, n3] of Object.entries(t2)) switch (i3) {
52088         case "tiff":
52089           this.assignObjectToOutput(e3, "ifd0", n3);
52090           break;
52091         case "exif":
52092           this.assignObjectToOutput(e3, "exif", n3);
52093           break;
52094         case "xmlns":
52095           break;
52096         default:
52097           this.assignObjectToOutput(e3, i3, n3);
52098       }
52099       else e3.xmp = t2;
52100     }
52101   };
52102   c(We, "type", "xmp"), c(We, "multiSegment", true), T.set("xmp", We);
52103   var Ke = class _Ke {
52104     static findAll(e3) {
52105       return qe(e3, /([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(_Ke.unpackMatch);
52106     }
52107     static unpackMatch(e3) {
52108       let t2 = e3[1], i3 = e3[2], n3 = e3[3].slice(1, -1);
52109       return n3 = Qe(n3), new _Ke(t2, i3, n3);
52110     }
52111     constructor(e3, t2, i3) {
52112       this.ns = e3, this.name = t2, this.value = i3;
52113     }
52114     serialize() {
52115       return this.value;
52116     }
52117   };
52118   var Xe = class _Xe {
52119     static findAll(e3, t2, i3) {
52120       if (void 0 !== t2 || void 0 !== i3) {
52121         t2 = t2 || "[\\w\\d-]+", i3 = i3 || "[\\w\\d-]+";
52122         var n3 = new RegExp("<(".concat(t2, "):(").concat(i3, ")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"), "gm");
52123       } else n3 = /<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;
52124       return qe(e3, n3).map(_Xe.unpackMatch);
52125     }
52126     static unpackMatch(e3) {
52127       let t2 = e3[1], i3 = e3[2], n3 = e3[4], s2 = e3[8];
52128       return new _Xe(t2, i3, n3, s2);
52129     }
52130     constructor(e3, t2, i3, n3) {
52131       this.ns = e3, this.name = t2, this.attrString = i3, this.innerXml = n3, this.attrs = Ke.findAll(i3), this.children = _Xe.findAll(n3), this.value = 0 === this.children.length ? Qe(n3) : void 0, this.properties = [...this.attrs, ...this.children];
52132     }
52133     get isPrimitive() {
52134       return void 0 !== this.value && 0 === this.attrs.length && 0 === this.children.length;
52135     }
52136     get isListContainer() {
52137       return 1 === this.children.length && this.children[0].isList;
52138     }
52139     get isList() {
52140       let { ns: e3, name: t2 } = this;
52141       return "rdf" === e3 && ("Seq" === t2 || "Bag" === t2 || "Alt" === t2);
52142     }
52143     get isListItem() {
52144       return "rdf" === this.ns && "li" === this.name;
52145     }
52146     serialize() {
52147       if (0 === this.properties.length && void 0 === this.value) return;
52148       if (this.isPrimitive) return this.value;
52149       if (this.isListContainer) return this.children[0].serialize();
52150       if (this.isList) return $e(this.children.map(Ye));
52151       if (this.isListItem && 1 === this.children.length && 0 === this.attrs.length) return this.children[0].serialize();
52152       let e3 = {};
52153       for (let t2 of this.properties) _e(t2, e3);
52154       return void 0 !== this.value && (e3.value = this.value), f(e3);
52155     }
52156   };
52157   function _e(e3, t2) {
52158     let i3 = e3.serialize();
52159     void 0 !== i3 && (t2[e3.name] = i3);
52160   }
52161   var Ye = (e3) => e3.serialize();
52162   var $e = (e3) => 1 === e3.length ? e3[0] : e3;
52163   var Je = (e3, t2) => t2[e3] ? t2[e3] : t2[e3] = {};
52164   function qe(e3, t2) {
52165     let i3, n3 = [];
52166     if (!e3) return n3;
52167     for (; null !== (i3 = t2.exec(e3)); ) n3.push(i3);
52168     return n3;
52169   }
52170   function Qe(e3) {
52171     if (function(e4) {
52172       return null == e4 || "null" === e4 || "undefined" === e4 || "" === e4 || "" === e4.trim();
52173     }(e3)) return;
52174     let t2 = Number(e3);
52175     if (!Number.isNaN(t2)) return t2;
52176     let i3 = e3.toLowerCase();
52177     return "true" === i3 || "false" !== i3 && e3.trim();
52178   }
52179   var Ze = ["rdf:li", "rdf:Seq", "rdf:Bag", "rdf:Alt", "rdf:Description"];
52180   var et = new RegExp("(<|\\/)(".concat(Ze.join("|"), ")"), "g");
52181   var tt = Object.freeze({ __proto__: null, default: Me, Exifr: te, fileParsers: w, segmentParsers: T, fileReaders: A, tagKeys: E, tagValues: B, tagRevivers: N, createDictionary: U, extendDictionary: F, fetchUrlAsArrayBuffer: M, readBlobAsArrayBuffer: R, chunkedProps: G, otherSegments: V, segments: z, tiffBlocks: H, segmentsAndBlocks: j, tiffExtractables: W, inheritables: K, allFormatters: X, Options: q, parse: ie, gpsOnlyOptions: me, gps: Se, thumbnailOnlyOptions: Ce, thumbnail: ye, thumbnailUrl: be, orientationOnlyOptions: Ie, orientation: Pe, rotations: ke, get rotateCanvas() {
52182     return we;
52183   }, get rotateCss() {
52184     return Te;
52185   }, rotation: Ae });
52186   var at = l("fs", (e3) => e3.promises);
52187   A.set("fs", class extends ve {
52188     async readWhole() {
52189       this.chunked = false, this.fs = await at;
52190       let e3 = await this.fs.readFile(this.input);
52191       this._swapBuffer(e3);
52192     }
52193     async readChunked() {
52194       this.chunked = true, this.fs = await at, await this.open(), await this.readChunk(0, this.options.firstChunkSize);
52195     }
52196     async open() {
52197       void 0 === this.fh && (this.fh = await this.fs.open(this.input, "r"), this.size = (await this.fh.stat(this.input)).size);
52198     }
52199     async _readChunk(e3, t2) {
52200       void 0 === this.fh && await this.open(), e3 + t2 > this.size && (t2 = this.size - e3);
52201       var i3 = this.subarray(e3, t2, true);
52202       return await this.fh.read(i3.dataView, 0, t2, e3), i3;
52203     }
52204     async close() {
52205       if (this.fh) {
52206         let e3 = this.fh;
52207         this.fh = void 0, await e3.close();
52208       }
52209     }
52210   });
52211   A.set("base64", class extends ve {
52212     constructor(...e3) {
52213       super(...e3), this.input = this.input.replace(/^data:([^;]+);base64,/gim, ""), this.size = this.input.length / 4 * 3, this.input.endsWith("==") ? this.size -= 2 : this.input.endsWith("=") && (this.size -= 1);
52214     }
52215     async _readChunk(e3, t2) {
52216       let i3, n3, r2 = this.input;
52217       void 0 === e3 ? (e3 = 0, i3 = 0, n3 = 0) : (i3 = 4 * Math.floor(e3 / 3), n3 = e3 - i3 / 4 * 3), void 0 === t2 && (t2 = this.size);
52218       let o2 = e3 + t2, l2 = i3 + 4 * Math.ceil(o2 / 3);
52219       r2 = r2.slice(i3, l2);
52220       let h2 = Math.min(t2, this.size - e3);
52221       if (a) {
52222         let t3 = s.from(r2, "base64").slice(n3, n3 + h2);
52223         return this.set(t3, e3, true);
52224       }
52225       {
52226         let t3 = this.subarray(e3, h2, true), i4 = atob(r2), s2 = t3.toUint8();
52227         for (let e4 = 0; e4 < h2; e4++) s2[e4] = i4.charCodeAt(n3 + e4);
52228         return t3;
52229       }
52230     }
52231   });
52232   var ot = class extends se {
52233     static canHandle(e3, t2) {
52234       return 18761 === t2 || 19789 === t2;
52235     }
52236     extendOptions(e3) {
52237       let { ifd0: t2, xmp: i3, iptc: n3, icc: s2 } = e3;
52238       i3.enabled && t2.deps.add(700), n3.enabled && t2.deps.add(33723), s2.enabled && t2.deps.add(34675), t2.finalizeFilters();
52239     }
52240     async parse() {
52241       let { tiff: e3, xmp: t2, iptc: i3, icc: n3 } = this.options;
52242       if (e3.enabled || t2.enabled || i3.enabled || n3.enabled) {
52243         let e4 = Math.max(S(this.options), this.options.chunkSize);
52244         await this.file.ensureChunk(0, e4), this.createParser("tiff", this.file), this.parsers.tiff.parseHeader(), await this.parsers.tiff.parseIfd0Block(), this.adaptTiffPropAsSegment("xmp"), this.adaptTiffPropAsSegment("iptc"), this.adaptTiffPropAsSegment("icc");
52245       }
52246     }
52247     adaptTiffPropAsSegment(e3) {
52248       if (this.parsers.tiff[e3]) {
52249         let t2 = this.parsers.tiff[e3];
52250         this.injectSegment(e3, t2);
52251       }
52252     }
52253   };
52254   c(ot, "type", "tiff"), w.set("tiff", ot);
52255   var lt = l("zlib");
52256   var ht = ["ihdr", "iccp", "text", "itxt", "exif"];
52257   var ut = class extends se {
52258     constructor(...e3) {
52259       super(...e3), c(this, "catchError", (e4) => this.errors.push(e4)), c(this, "metaChunks", []), c(this, "unknownChunks", []);
52260     }
52261     static canHandle(e3, t2) {
52262       return 35152 === t2 && 2303741511 === e3.getUint32(0) && 218765834 === e3.getUint32(4);
52263     }
52264     async parse() {
52265       let { file: e3 } = this;
52266       await this.findPngChunksInRange("\x89PNG\r\n\1a\n".length, e3.byteLength), await this.readSegments(this.metaChunks), this.findIhdr(), this.parseTextChunks(), await this.findExif().catch(this.catchError), await this.findXmp().catch(this.catchError), await this.findIcc().catch(this.catchError);
52267     }
52268     async findPngChunksInRange(e3, t2) {
52269       let { file: i3 } = this;
52270       for (; e3 < t2; ) {
52271         let t3 = i3.getUint32(e3), n3 = i3.getUint32(e3 + 4), s2 = i3.getString(e3 + 4, 4).toLowerCase(), r2 = t3 + 4 + 4 + 4, a2 = { type: s2, offset: e3, length: r2, start: e3 + 4 + 4, size: t3, marker: n3 };
52272         ht.includes(s2) ? this.metaChunks.push(a2) : this.unknownChunks.push(a2), e3 += r2;
52273       }
52274     }
52275     parseTextChunks() {
52276       let e3 = this.metaChunks.filter((e4) => "text" === e4.type);
52277       for (let t2 of e3) {
52278         let [e4, i3] = this.file.getString(t2.start, t2.size).split("\0");
52279         this.injectKeyValToIhdr(e4, i3);
52280       }
52281     }
52282     injectKeyValToIhdr(e3, t2) {
52283       let i3 = this.parsers.ihdr;
52284       i3 && i3.raw.set(e3, t2);
52285     }
52286     findIhdr() {
52287       let e3 = this.metaChunks.find((e4) => "ihdr" === e4.type);
52288       e3 && false !== this.options.ihdr.enabled && this.createParser("ihdr", e3.chunk);
52289     }
52290     async findExif() {
52291       let e3 = this.metaChunks.find((e4) => "exif" === e4.type);
52292       e3 && this.injectSegment("tiff", e3.chunk);
52293     }
52294     async findXmp() {
52295       let e3 = this.metaChunks.filter((e4) => "itxt" === e4.type);
52296       for (let t2 of e3) {
52297         "XML:com.adobe.xmp" === t2.chunk.getString(0, "XML:com.adobe.xmp".length) && this.injectSegment("xmp", t2.chunk);
52298       }
52299     }
52300     async findIcc() {
52301       let e3 = this.metaChunks.find((e4) => "iccp" === e4.type);
52302       if (!e3) return;
52303       let { chunk: t2 } = e3, i3 = t2.getUint8Array(0, 81), s2 = 0;
52304       for (; s2 < 80 && 0 !== i3[s2]; ) s2++;
52305       let r2 = s2 + 2, a2 = t2.getString(0, s2);
52306       if (this.injectKeyValToIhdr("ProfileName", a2), n2) {
52307         let e4 = await lt, i4 = t2.getUint8Array(r2);
52308         i4 = e4.inflateSync(i4), this.injectSegment("icc", i4);
52309       }
52310     }
52311   };
52312   c(ut, "type", "png"), w.set("png", ut), U(E, "interop", [[1, "InteropIndex"], [2, "InteropVersion"], [4096, "RelatedImageFileFormat"], [4097, "RelatedImageWidth"], [4098, "RelatedImageHeight"]]), F(E, "ifd0", [[11, "ProcessingSoftware"], [254, "SubfileType"], [255, "OldSubfileType"], [263, "Thresholding"], [264, "CellWidth"], [265, "CellLength"], [266, "FillOrder"], [269, "DocumentName"], [280, "MinSampleValue"], [281, "MaxSampleValue"], [285, "PageName"], [286, "XPosition"], [287, "YPosition"], [290, "GrayResponseUnit"], [297, "PageNumber"], [321, "HalftoneHints"], [322, "TileWidth"], [323, "TileLength"], [332, "InkSet"], [337, "TargetPrinter"], [18246, "Rating"], [18249, "RatingPercent"], [33550, "PixelScale"], [34264, "ModelTransform"], [34377, "PhotoshopSettings"], [50706, "DNGVersion"], [50707, "DNGBackwardVersion"], [50708, "UniqueCameraModel"], [50709, "LocalizedCameraModel"], [50736, "DNGLensInfo"], [50739, "ShadowScale"], [50740, "DNGPrivateData"], [33920, "IntergraphMatrix"], [33922, "ModelTiePoint"], [34118, "SEMInfo"], [34735, "GeoTiffDirectory"], [34736, "GeoTiffDoubleParams"], [34737, "GeoTiffAsciiParams"], [50341, "PrintIM"], [50721, "ColorMatrix1"], [50722, "ColorMatrix2"], [50723, "CameraCalibration1"], [50724, "CameraCalibration2"], [50725, "ReductionMatrix1"], [50726, "ReductionMatrix2"], [50727, "AnalogBalance"], [50728, "AsShotNeutral"], [50729, "AsShotWhiteXY"], [50730, "BaselineExposure"], [50731, "BaselineNoise"], [50732, "BaselineSharpness"], [50734, "LinearResponseLimit"], [50735, "CameraSerialNumber"], [50741, "MakerNoteSafety"], [50778, "CalibrationIlluminant1"], [50779, "CalibrationIlluminant2"], [50781, "RawDataUniqueID"], [50827, "OriginalRawFileName"], [50828, "OriginalRawFileData"], [50831, "AsShotICCProfile"], [50832, "AsShotPreProfileMatrix"], [50833, "CurrentICCProfile"], [50834, "CurrentPreProfileMatrix"], [50879, "ColorimetricReference"], [50885, "SRawType"], [50898, "PanasonicTitle"], [50899, "PanasonicTitle2"], [50931, "CameraCalibrationSig"], [50932, "ProfileCalibrationSig"], [50933, "ProfileIFD"], [50934, "AsShotProfileName"], [50936, "ProfileName"], [50937, "ProfileHueSatMapDims"], [50938, "ProfileHueSatMapData1"], [50939, "ProfileHueSatMapData2"], [50940, "ProfileToneCurve"], [50941, "ProfileEmbedPolicy"], [50942, "ProfileCopyright"], [50964, "ForwardMatrix1"], [50965, "ForwardMatrix2"], [50966, "PreviewApplicationName"], [50967, "PreviewApplicationVersion"], [50968, "PreviewSettingsName"], [50969, "PreviewSettingsDigest"], [50970, "PreviewColorSpace"], [50971, "PreviewDateTime"], [50972, "RawImageDigest"], [50973, "OriginalRawFileDigest"], [50981, "ProfileLookTableDims"], [50982, "ProfileLookTableData"], [51043, "TimeCodes"], [51044, "FrameRate"], [51058, "TStop"], [51081, "ReelName"], [51089, "OriginalDefaultFinalSize"], [51090, "OriginalBestQualitySize"], [51091, "OriginalDefaultCropSize"], [51105, "CameraLabel"], [51107, "ProfileHueSatMapEncoding"], [51108, "ProfileLookTableEncoding"], [51109, "BaselineExposureOffset"], [51110, "DefaultBlackRender"], [51111, "NewRawImageDigest"], [51112, "RawToPreviewGain"]]);
52313   var ct = [[273, "StripOffsets"], [279, "StripByteCounts"], [288, "FreeOffsets"], [289, "FreeByteCounts"], [291, "GrayResponseCurve"], [292, "T4Options"], [293, "T6Options"], [300, "ColorResponseUnit"], [320, "ColorMap"], [324, "TileOffsets"], [325, "TileByteCounts"], [326, "BadFaxLines"], [327, "CleanFaxData"], [328, "ConsecutiveBadFaxLines"], [330, "SubIFD"], [333, "InkNames"], [334, "NumberofInks"], [336, "DotRange"], [338, "ExtraSamples"], [339, "SampleFormat"], [340, "SMinSampleValue"], [341, "SMaxSampleValue"], [342, "TransferRange"], [343, "ClipPath"], [344, "XClipPathUnits"], [345, "YClipPathUnits"], [346, "Indexed"], [347, "JPEGTables"], [351, "OPIProxy"], [400, "GlobalParametersIFD"], [401, "ProfileType"], [402, "FaxProfile"], [403, "CodingMethods"], [404, "VersionYear"], [405, "ModeNumber"], [433, "Decode"], [434, "DefaultImageColor"], [435, "T82Options"], [437, "JPEGTables"], [512, "JPEGProc"], [515, "JPEGRestartInterval"], [517, "JPEGLosslessPredictors"], [518, "JPEGPointTransforms"], [519, "JPEGQTables"], [520, "JPEGDCTables"], [521, "JPEGACTables"], [559, "StripRowCounts"], [999, "USPTOMiscellaneous"], [18247, "XP_DIP_XML"], [18248, "StitchInfo"], [28672, "SonyRawFileType"], [28688, "SonyToneCurve"], [28721, "VignettingCorrection"], [28722, "VignettingCorrParams"], [28724, "ChromaticAberrationCorrection"], [28725, "ChromaticAberrationCorrParams"], [28726, "DistortionCorrection"], [28727, "DistortionCorrParams"], [29895, "SonyCropTopLeft"], [29896, "SonyCropSize"], [32781, "ImageID"], [32931, "WangTag1"], [32932, "WangAnnotation"], [32933, "WangTag3"], [32934, "WangTag4"], [32953, "ImageReferencePoints"], [32954, "RegionXformTackPoint"], [32955, "WarpQuadrilateral"], [32956, "AffineTransformMat"], [32995, "Matteing"], [32996, "DataType"], [32997, "ImageDepth"], [32998, "TileDepth"], [33300, "ImageFullWidth"], [33301, "ImageFullHeight"], [33302, "TextureFormat"], [33303, "WrapModes"], [33304, "FovCot"], [33305, "MatrixWorldToScreen"], [33306, "MatrixWorldToCamera"], [33405, "Model2"], [33421, "CFARepeatPatternDim"], [33422, "CFAPattern2"], [33423, "BatteryLevel"], [33424, "KodakIFD"], [33445, "MDFileTag"], [33446, "MDScalePixel"], [33447, "MDColorTable"], [33448, "MDLabName"], [33449, "MDSampleInfo"], [33450, "MDPrepDate"], [33451, "MDPrepTime"], [33452, "MDFileUnits"], [33589, "AdventScale"], [33590, "AdventRevision"], [33628, "UIC1Tag"], [33629, "UIC2Tag"], [33630, "UIC3Tag"], [33631, "UIC4Tag"], [33918, "IntergraphPacketData"], [33919, "IntergraphFlagRegisters"], [33921, "INGRReserved"], [34016, "Site"], [34017, "ColorSequence"], [34018, "IT8Header"], [34019, "RasterPadding"], [34020, "BitsPerRunLength"], [34021, "BitsPerExtendedRunLength"], [34022, "ColorTable"], [34023, "ImageColorIndicator"], [34024, "BackgroundColorIndicator"], [34025, "ImageColorValue"], [34026, "BackgroundColorValue"], [34027, "PixelIntensityRange"], [34028, "TransparencyIndicator"], [34029, "ColorCharacterization"], [34030, "HCUsage"], [34031, "TrapIndicator"], [34032, "CMYKEquivalent"], [34152, "AFCP_IPTC"], [34232, "PixelMagicJBIGOptions"], [34263, "JPLCartoIFD"], [34306, "WB_GRGBLevels"], [34310, "LeafData"], [34687, "TIFF_FXExtensions"], [34688, "MultiProfiles"], [34689, "SharedData"], [34690, "T88Options"], [34732, "ImageLayer"], [34750, "JBIGOptions"], [34856, "Opto-ElectricConvFactor"], [34857, "Interlace"], [34908, "FaxRecvParams"], [34909, "FaxSubAddress"], [34910, "FaxRecvTime"], [34929, "FedexEDR"], [34954, "LeafSubIFD"], [37387, "FlashEnergy"], [37388, "SpatialFrequencyResponse"], [37389, "Noise"], [37390, "FocalPlaneXResolution"], [37391, "FocalPlaneYResolution"], [37392, "FocalPlaneResolutionUnit"], [37397, "ExposureIndex"], [37398, "TIFF-EPStandardID"], [37399, "SensingMethod"], [37434, "CIP3DataFile"], [37435, "CIP3Sheet"], [37436, "CIP3Side"], [37439, "StoNits"], [37679, "MSDocumentText"], [37680, "MSPropertySetStorage"], [37681, "MSDocumentTextPosition"], [37724, "ImageSourceData"], [40965, "InteropIFD"], [40976, "SamsungRawPointersOffset"], [40977, "SamsungRawPointersLength"], [41217, "SamsungRawByteOrder"], [41218, "SamsungRawUnknown"], [41484, "SpatialFrequencyResponse"], [41485, "Noise"], [41489, "ImageNumber"], [41490, "SecurityClassification"], [41491, "ImageHistory"], [41494, "TIFF-EPStandardID"], [41995, "DeviceSettingDescription"], [42112, "GDALMetadata"], [42113, "GDALNoData"], [44992, "ExpandSoftware"], [44993, "ExpandLens"], [44994, "ExpandFilm"], [44995, "ExpandFilterLens"], [44996, "ExpandScanner"], [44997, "ExpandFlashLamp"], [46275, "HasselbladRawImage"], [48129, "PixelFormat"], [48130, "Transformation"], [48131, "Uncompressed"], [48132, "ImageType"], [48256, "ImageWidth"], [48257, "ImageHeight"], [48258, "WidthResolution"], [48259, "HeightResolution"], [48320, "ImageOffset"], [48321, "ImageByteCount"], [48322, "AlphaOffset"], [48323, "AlphaByteCount"], [48324, "ImageDataDiscard"], [48325, "AlphaDataDiscard"], [50215, "OceScanjobDesc"], [50216, "OceApplicationSelector"], [50217, "OceIDNumber"], [50218, "OceImageLogic"], [50255, "Annotations"], [50459, "HasselbladExif"], [50547, "OriginalFileName"], [50560, "USPTOOriginalContentType"], [50656, "CR2CFAPattern"], [50710, "CFAPlaneColor"], [50711, "CFALayout"], [50712, "LinearizationTable"], [50713, "BlackLevelRepeatDim"], [50714, "BlackLevel"], [50715, "BlackLevelDeltaH"], [50716, "BlackLevelDeltaV"], [50717, "WhiteLevel"], [50718, "DefaultScale"], [50719, "DefaultCropOrigin"], [50720, "DefaultCropSize"], [50733, "BayerGreenSplit"], [50737, "ChromaBlurRadius"], [50738, "AntiAliasStrength"], [50752, "RawImageSegmentation"], [50780, "BestQualityScale"], [50784, "AliasLayerMetadata"], [50829, "ActiveArea"], [50830, "MaskedAreas"], [50935, "NoiseReductionApplied"], [50974, "SubTileBlockSize"], [50975, "RowInterleaveFactor"], [51008, "OpcodeList1"], [51009, "OpcodeList2"], [51022, "OpcodeList3"], [51041, "NoiseProfile"], [51114, "CacheVersion"], [51125, "DefaultUserCrop"], [51157, "NikonNEFInfo"], [65024, "KdcIFD"]];
52314   F(E, "ifd0", ct), F(E, "exif", ct), U(B, "gps", [[23, { M: "Magnetic North", T: "True North" }], [25, { K: "Kilometers", M: "Miles", N: "Nautical Miles" }]]);
52315   var ft = class extends re2 {
52316     static canHandle(e3, t2) {
52317       return 224 === e3.getUint8(t2 + 1) && 1246120262 === e3.getUint32(t2 + 4) && 0 === e3.getUint8(t2 + 8);
52318     }
52319     parse() {
52320       return this.parseTags(), this.translate(), this.output;
52321     }
52322     parseTags() {
52323       this.raw = /* @__PURE__ */ new Map([[0, this.chunk.getUint16(0)], [2, this.chunk.getUint8(2)], [3, this.chunk.getUint16(3)], [5, this.chunk.getUint16(5)], [7, this.chunk.getUint8(7)], [8, this.chunk.getUint8(8)]]);
52324     }
52325   };
52326   c(ft, "type", "jfif"), c(ft, "headerLength", 9), T.set("jfif", ft), U(E, "jfif", [[0, "JFIFVersion"], [2, "ResolutionUnit"], [3, "XResolution"], [5, "YResolution"], [7, "ThumbnailWidth"], [8, "ThumbnailHeight"]]);
52327   var dt = class extends re2 {
52328     parse() {
52329       return this.parseTags(), this.translate(), this.output;
52330     }
52331     parseTags() {
52332       this.raw = new Map([[0, this.chunk.getUint32(0)], [4, this.chunk.getUint32(4)], [8, this.chunk.getUint8(8)], [9, this.chunk.getUint8(9)], [10, this.chunk.getUint8(10)], [11, this.chunk.getUint8(11)], [12, this.chunk.getUint8(12)], ...Array.from(this.raw)]);
52333     }
52334   };
52335   c(dt, "type", "ihdr"), T.set("ihdr", dt), U(E, "ihdr", [[0, "ImageWidth"], [4, "ImageHeight"], [8, "BitDepth"], [9, "ColorType"], [10, "Compression"], [11, "Filter"], [12, "Interlace"]]), U(B, "ihdr", [[9, { 0: "Grayscale", 2: "RGB", 3: "Palette", 4: "Grayscale with Alpha", 6: "RGB with Alpha", DEFAULT: "Unknown" }], [10, { 0: "Deflate/Inflate", DEFAULT: "Unknown" }], [11, { 0: "Adaptive", DEFAULT: "Unknown" }], [12, { 0: "Noninterlaced", 1: "Adam7 Interlace", DEFAULT: "Unknown" }]]);
52336   var pt = class extends re2 {
52337     static canHandle(e3, t2) {
52338       return 226 === e3.getUint8(t2 + 1) && 1229144927 === e3.getUint32(t2 + 4);
52339     }
52340     static findPosition(e3, t2) {
52341       let i3 = super.findPosition(e3, t2);
52342       return i3.chunkNumber = e3.getUint8(t2 + 16), i3.chunkCount = e3.getUint8(t2 + 17), i3.multiSegment = i3.chunkCount > 1, i3;
52343     }
52344     static handleMultiSegments(e3) {
52345       return function(e4) {
52346         let t2 = function(e6) {
52347           let t3 = e6[0].constructor, i3 = 0;
52348           for (let t4 of e6) i3 += t4.length;
52349           let n3 = new t3(i3), s2 = 0;
52350           for (let t4 of e6) n3.set(t4, s2), s2 += t4.length;
52351           return n3;
52352         }(e4.map((e6) => e6.chunk.toUint8()));
52353         return new I(t2);
52354       }(e3);
52355     }
52356     parse() {
52357       return this.raw = /* @__PURE__ */ new Map(), this.parseHeader(), this.parseTags(), this.translate(), this.output;
52358     }
52359     parseHeader() {
52360       let { raw: e3 } = this;
52361       this.chunk.byteLength < 84 && g2("ICC header is too short");
52362       for (let [t2, i3] of Object.entries(gt)) {
52363         t2 = parseInt(t2, 10);
52364         let n3 = i3(this.chunk, t2);
52365         "\0\0\0\0" !== n3 && e3.set(t2, n3);
52366       }
52367     }
52368     parseTags() {
52369       let e3, t2, i3, n3, s2, { raw: r2 } = this, a2 = this.chunk.getUint32(128), o2 = 132, l2 = this.chunk.byteLength;
52370       for (; a2--; ) {
52371         if (e3 = this.chunk.getString(o2, 4), t2 = this.chunk.getUint32(o2 + 4), i3 = this.chunk.getUint32(o2 + 8), n3 = this.chunk.getString(t2, 4), t2 + i3 > l2) return void console.warn("reached the end of the first ICC chunk. Enable options.tiff.multiSegment to read all ICC segments.");
52372         s2 = this.parseTag(n3, t2, i3), void 0 !== s2 && "\0\0\0\0" !== s2 && r2.set(e3, s2), o2 += 12;
52373       }
52374     }
52375     parseTag(e3, t2, i3) {
52376       switch (e3) {
52377         case "desc":
52378           return this.parseDesc(t2);
52379         case "mluc":
52380           return this.parseMluc(t2);
52381         case "text":
52382           return this.parseText(t2, i3);
52383         case "sig ":
52384           return this.parseSig(t2);
52385       }
52386       if (!(t2 + i3 > this.chunk.byteLength)) return this.chunk.getUint8Array(t2, i3);
52387     }
52388     parseDesc(e3) {
52389       let t2 = this.chunk.getUint32(e3 + 8) - 1;
52390       return m(this.chunk.getString(e3 + 12, t2));
52391     }
52392     parseText(e3, t2) {
52393       return m(this.chunk.getString(e3 + 8, t2 - 8));
52394     }
52395     parseSig(e3) {
52396       return m(this.chunk.getString(e3 + 8, 4));
52397     }
52398     parseMluc(e3) {
52399       let { chunk: t2 } = this, i3 = t2.getUint32(e3 + 8), n3 = t2.getUint32(e3 + 12), s2 = e3 + 16, r2 = [];
52400       for (let a2 = 0; a2 < i3; a2++) {
52401         let i4 = t2.getString(s2 + 0, 2), a3 = t2.getString(s2 + 2, 2), o2 = t2.getUint32(s2 + 4), l2 = t2.getUint32(s2 + 8) + e3, h2 = m(t2.getUnicodeString(l2, o2));
52402         r2.push({ lang: i4, country: a3, text: h2 }), s2 += n3;
52403       }
52404       return 1 === i3 ? r2[0].text : r2;
52405     }
52406     translateValue(e3, t2) {
52407       return "string" == typeof e3 ? t2[e3] || t2[e3.toLowerCase()] || e3 : t2[e3] || e3;
52408     }
52409   };
52410   c(pt, "type", "icc"), c(pt, "multiSegment", true), c(pt, "headerLength", 18);
52411   var gt = { 4: mt, 8: function(e3, t2) {
52412     return [e3.getUint8(t2), e3.getUint8(t2 + 1) >> 4, e3.getUint8(t2 + 1) % 16].map((e4) => e4.toString(10)).join(".");
52413   }, 12: mt, 16: mt, 20: mt, 24: function(e3, t2) {
52414     const i3 = e3.getUint16(t2), n3 = e3.getUint16(t2 + 2) - 1, s2 = e3.getUint16(t2 + 4), r2 = e3.getUint16(t2 + 6), a2 = e3.getUint16(t2 + 8), o2 = e3.getUint16(t2 + 10);
52415     return new Date(Date.UTC(i3, n3, s2, r2, a2, o2));
52416   }, 36: mt, 40: mt, 48: mt, 52: mt, 64: (e3, t2) => e3.getUint32(t2), 80: mt };
52417   function mt(e3, t2) {
52418     return m(e3.getString(t2, 4));
52419   }
52420   T.set("icc", pt), U(E, "icc", [[4, "ProfileCMMType"], [8, "ProfileVersion"], [12, "ProfileClass"], [16, "ColorSpaceData"], [20, "ProfileConnectionSpace"], [24, "ProfileDateTime"], [36, "ProfileFileSignature"], [40, "PrimaryPlatform"], [44, "CMMFlags"], [48, "DeviceManufacturer"], [52, "DeviceModel"], [56, "DeviceAttributes"], [64, "RenderingIntent"], [68, "ConnectionSpaceIlluminant"], [80, "ProfileCreator"], [84, "ProfileID"], ["Header", "ProfileHeader"], ["MS00", "WCSProfiles"], ["bTRC", "BlueTRC"], ["bXYZ", "BlueMatrixColumn"], ["bfd", "UCRBG"], ["bkpt", "MediaBlackPoint"], ["calt", "CalibrationDateTime"], ["chad", "ChromaticAdaptation"], ["chrm", "Chromaticity"], ["ciis", "ColorimetricIntentImageState"], ["clot", "ColorantTableOut"], ["clro", "ColorantOrder"], ["clrt", "ColorantTable"], ["cprt", "ProfileCopyright"], ["crdi", "CRDInfo"], ["desc", "ProfileDescription"], ["devs", "DeviceSettings"], ["dmdd", "DeviceModelDesc"], ["dmnd", "DeviceMfgDesc"], ["dscm", "ProfileDescriptionML"], ["fpce", "FocalPlaneColorimetryEstimates"], ["gTRC", "GreenTRC"], ["gXYZ", "GreenMatrixColumn"], ["gamt", "Gamut"], ["kTRC", "GrayTRC"], ["lumi", "Luminance"], ["meas", "Measurement"], ["meta", "Metadata"], ["mmod", "MakeAndModel"], ["ncl2", "NamedColor2"], ["ncol", "NamedColor"], ["ndin", "NativeDisplayInfo"], ["pre0", "Preview0"], ["pre1", "Preview1"], ["pre2", "Preview2"], ["ps2i", "PS2RenderingIntent"], ["ps2s", "PostScript2CSA"], ["psd0", "PostScript2CRD0"], ["psd1", "PostScript2CRD1"], ["psd2", "PostScript2CRD2"], ["psd3", "PostScript2CRD3"], ["pseq", "ProfileSequenceDesc"], ["psid", "ProfileSequenceIdentifier"], ["psvm", "PS2CRDVMSize"], ["rTRC", "RedTRC"], ["rXYZ", "RedMatrixColumn"], ["resp", "OutputResponse"], ["rhoc", "ReflectionHardcopyOrigColorimetry"], ["rig0", "PerceptualRenderingIntentGamut"], ["rig2", "SaturationRenderingIntentGamut"], ["rpoc", "ReflectionPrintOutputColorimetry"], ["sape", "SceneAppearanceEstimates"], ["scoe", "SceneColorimetryEstimates"], ["scrd", "ScreeningDesc"], ["scrn", "Screening"], ["targ", "CharTarget"], ["tech", "Technology"], ["vcgt", "VideoCardGamma"], ["view", "ViewingConditions"], ["vued", "ViewingCondDesc"], ["wtpt", "MediaWhitePoint"]]);
52421   var St = { "4d2p": "Erdt Systems", AAMA: "Aamazing Technologies", ACER: "Acer", ACLT: "Acolyte Color Research", ACTI: "Actix Sytems", ADAR: "Adara Technology", ADBE: "Adobe", ADI: "ADI Systems", AGFA: "Agfa Graphics", ALMD: "Alps Electric", ALPS: "Alps Electric", ALWN: "Alwan Color Expertise", AMTI: "Amiable Technologies", AOC: "AOC International", APAG: "Apago", APPL: "Apple Computer", AST: "AST", "AT&T": "AT&T", BAEL: "BARBIERI electronic", BRCO: "Barco NV", BRKP: "Breakpoint", BROT: "Brother", BULL: "Bull", BUS: "Bus Computer Systems", "C-IT": "C-Itoh", CAMR: "Intel", CANO: "Canon", CARR: "Carroll Touch", CASI: "Casio", CBUS: "Colorbus PL", CEL: "Crossfield", CELx: "Crossfield", CGS: "CGS Publishing Technologies International", CHM: "Rochester Robotics", CIGL: "Colour Imaging Group, London", CITI: "Citizen", CL00: "Candela", CLIQ: "Color IQ", CMCO: "Chromaco", CMiX: "CHROMiX", COLO: "Colorgraphic Communications", COMP: "Compaq", COMp: "Compeq/Focus Technology", CONR: "Conrac Display Products", CORD: "Cordata Technologies", CPQ: "Compaq", CPRO: "ColorPro", CRN: "Cornerstone", CTX: "CTX International", CVIS: "ColorVision", CWC: "Fujitsu Laboratories", DARI: "Darius Technology", DATA: "Dataproducts", DCP: "Dry Creek Photo", DCRC: "Digital Contents Resource Center, Chung-Ang University", DELL: "Dell Computer", DIC: "Dainippon Ink and Chemicals", DICO: "Diconix", DIGI: "Digital", "DL&C": "Digital Light & Color", DPLG: "Doppelganger", DS: "Dainippon Screen", DSOL: "DOOSOL", DUPN: "DuPont", EPSO: "Epson", ESKO: "Esko-Graphics", ETRI: "Electronics and Telecommunications Research Institute", EVER: "Everex Systems", EXAC: "ExactCODE", Eizo: "Eizo", FALC: "Falco Data Products", FF: "Fuji Photo Film", FFEI: "FujiFilm Electronic Imaging", FNRD: "Fnord Software", FORA: "Fora", FORE: "Forefront Technology", FP: "Fujitsu", FPA: "WayTech Development", FUJI: "Fujitsu", FX: "Fuji Xerox", GCC: "GCC Technologies", GGSL: "Global Graphics Software", GMB: "Gretagmacbeth", GMG: "GMG", GOLD: "GoldStar Technology", GOOG: "Google", GPRT: "Giantprint", GTMB: "Gretagmacbeth", GVC: "WayTech Development", GW2K: "Sony", HCI: "HCI", HDM: "Heidelberger Druckmaschinen", HERM: "Hermes", HITA: "Hitachi America", HP: "Hewlett-Packard", HTC: "Hitachi", HiTi: "HiTi Digital", IBM: "IBM", IDNT: "Scitex", IEC: "Hewlett-Packard", IIYA: "Iiyama North America", IKEG: "Ikegami Electronics", IMAG: "Image Systems", IMI: "Ingram Micro", INTC: "Intel", INTL: "N/A (INTL)", INTR: "Intra Electronics", IOCO: "Iocomm International Technology", IPS: "InfoPrint Solutions Company", IRIS: "Scitex", ISL: "Ichikawa Soft Laboratory", ITNL: "N/A (ITNL)", IVM: "IVM", IWAT: "Iwatsu Electric", Idnt: "Scitex", Inca: "Inca Digital Printers", Iris: "Scitex", JPEG: "Joint Photographic Experts Group", JSFT: "Jetsoft Development", JVC: "JVC Information Products", KART: "Scitex", KFC: "KFC Computek Components", KLH: "KLH Computers", KMHD: "Konica Minolta", KNCA: "Konica", KODA: "Kodak", KYOC: "Kyocera", Kart: "Scitex", LCAG: "Leica", LCCD: "Leeds Colour", LDAK: "Left Dakota", LEAD: "Leading Technology", LEXM: "Lexmark International", LINK: "Link Computer", LINO: "Linotronic", LITE: "Lite-On", Leaf: "Leaf", Lino: "Linotronic", MAGC: "Mag Computronic", MAGI: "MAG Innovision", MANN: "Mannesmann", MICN: "Micron Technology", MICR: "Microtek", MICV: "Microvitec", MINO: "Minolta", MITS: "Mitsubishi Electronics America", MITs: "Mitsuba", MNLT: "Minolta", MODG: "Modgraph", MONI: "Monitronix", MONS: "Monaco Systems", MORS: "Morse Technology", MOTI: "Motive Systems", MSFT: "Microsoft", MUTO: "MUTOH INDUSTRIES", Mits: "Mitsubishi Electric", NANA: "NANAO", NEC: "NEC", NEXP: "NexPress Solutions", NISS: "Nissei Sangyo America", NKON: "Nikon", NONE: "none", OCE: "Oce Technologies", OCEC: "OceColor", OKI: "Oki", OKID: "Okidata", OKIP: "Okidata", OLIV: "Olivetti", OLYM: "Olympus", ONYX: "Onyx Graphics", OPTI: "Optiquest", PACK: "Packard Bell", PANA: "Matsushita Electric Industrial", PANT: "Pantone", PBN: "Packard Bell", PFU: "PFU", PHIL: "Philips Consumer Electronics", PNTX: "HOYA", POne: "Phase One A/S", PREM: "Premier Computer Innovations", PRIN: "Princeton Graphic Systems", PRIP: "Princeton Publishing Labs", QLUX: "Hong Kong", QMS: "QMS", QPCD: "QPcard AB", QUAD: "QuadLaser", QUME: "Qume", RADI: "Radius", RDDx: "Integrated Color Solutions", RDG: "Roland DG", REDM: "REDMS Group", RELI: "Relisys", RGMS: "Rolf Gierling Multitools", RICO: "Ricoh", RNLD: "Edmund Ronald", ROYA: "Royal", RPC: "Ricoh Printing Systems", RTL: "Royal Information Electronics", SAMP: "Sampo", SAMS: "Samsung", SANT: "Jaime Santana Pomares", SCIT: "Scitex", SCRN: "Dainippon Screen", SDP: "Scitex", SEC: "Samsung", SEIK: "Seiko Instruments", SEIk: "Seikosha", SGUY: "ScanGuy.com", SHAR: "Sharp Laboratories", SICC: "International Color Consortium", SONY: "Sony", SPCL: "SpectraCal", STAR: "Star", STC: "Sampo Technology", Scit: "Scitex", Sdp: "Scitex", Sony: "Sony", TALO: "Talon Technology", TAND: "Tandy", TATU: "Tatung", TAXA: "TAXAN America", TDS: "Tokyo Denshi Sekei", TECO: "TECO Information Systems", TEGR: "Tegra", TEKT: "Tektronix", TI: "Texas Instruments", TMKR: "TypeMaker", TOSB: "Toshiba", TOSH: "Toshiba", TOTK: "TOTOKU ELECTRIC", TRIU: "Triumph", TSBT: "Toshiba", TTX: "TTX Computer Products", TVM: "TVM Professional Monitor", TW: "TW Casper", ULSX: "Ulead Systems", UNIS: "Unisys", UTZF: "Utz Fehlau & Sohn", VARI: "Varityper", VIEW: "Viewsonic", VISL: "Visual communication", VIVO: "Vivo Mobile Communication", WANG: "Wang", WLBR: "Wilbur Imaging", WTG2: "Ware To Go", WYSE: "WYSE Technology", XERX: "Xerox", XRIT: "X-Rite", ZRAN: "Zoran", Zebr: "Zebra Technologies", appl: "Apple Computer", bICC: "basICColor", berg: "bergdesign", ceyd: "Integrated Color Solutions", clsp: "MacDermid ColorSpan", ds: "Dainippon Screen", dupn: "DuPont", ffei: "FujiFilm Electronic Imaging", flux: "FluxData", iris: "Scitex", kart: "Scitex", lcms: "Little CMS", lino: "Linotronic", none: "none", ob4d: "Erdt Systems", obic: "Medigraph", quby: "Qubyx Sarl", scit: "Scitex", scrn: "Dainippon Screen", sdp: "Scitex", siwi: "SIWI GRAFIKA", yxym: "YxyMaster" };
52422   var Ct = { scnr: "Scanner", mntr: "Monitor", prtr: "Printer", link: "Device Link", abst: "Abstract", spac: "Color Space Conversion Profile", nmcl: "Named Color", cenc: "ColorEncodingSpace profile", mid: "MultiplexIdentification profile", mlnk: "MultiplexLink profile", mvis: "MultiplexVisualization profile", nkpf: "Nikon Input Device Profile (NON-STANDARD!)" };
52423   U(B, "icc", [[4, St], [12, Ct], [40, Object.assign({}, St, Ct)], [48, St], [80, St], [64, { 0: "Perceptual", 1: "Relative Colorimetric", 2: "Saturation", 3: "Absolute Colorimetric" }], ["tech", { amd: "Active Matrix Display", crt: "Cathode Ray Tube Display", kpcd: "Photo CD", pmd: "Passive Matrix Display", dcam: "Digital Camera", dcpj: "Digital Cinema Projector", dmpc: "Digital Motion Picture Camera", dsub: "Dye Sublimation Printer", epho: "Electrophotographic Printer", esta: "Electrostatic Printer", flex: "Flexography", fprn: "Film Writer", fscn: "Film Scanner", grav: "Gravure", ijet: "Ink Jet Printer", imgs: "Photo Image Setter", mpfr: "Motion Picture Film Recorder", mpfs: "Motion Picture Film Scanner", offs: "Offset Lithography", pjtv: "Projection Television", rpho: "Photographic Paper Printer", rscn: "Reflective Scanner", silk: "Silkscreen", twax: "Thermal Wax Printer", vidc: "Video Camera", vidm: "Video Monitor" }]]);
52424   var yt = class extends re2 {
52425     static canHandle(e3, t2, i3) {
52426       return 237 === e3.getUint8(t2 + 1) && "Photoshop" === e3.getString(t2 + 4, 9) && void 0 !== this.containsIptc8bim(e3, t2, i3);
52427     }
52428     static headerLength(e3, t2, i3) {
52429       let n3, s2 = this.containsIptc8bim(e3, t2, i3);
52430       if (void 0 !== s2) return n3 = e3.getUint8(t2 + s2 + 7), n3 % 2 != 0 && (n3 += 1), 0 === n3 && (n3 = 4), s2 + 8 + n3;
52431     }
52432     static containsIptc8bim(e3, t2, i3) {
52433       for (let n3 = 0; n3 < i3; n3++) if (this.isIptcSegmentHead(e3, t2 + n3)) return n3;
52434     }
52435     static isIptcSegmentHead(e3, t2) {
52436       return 56 === e3.getUint8(t2) && 943868237 === e3.getUint32(t2) && 1028 === e3.getUint16(t2 + 4);
52437     }
52438     parse() {
52439       let { raw: e3 } = this, t2 = this.chunk.byteLength - 1, i3 = false;
52440       for (let n3 = 0; n3 < t2; n3++) if (28 === this.chunk.getUint8(n3) && 2 === this.chunk.getUint8(n3 + 1)) {
52441         i3 = true;
52442         let t3 = this.chunk.getUint16(n3 + 3), s2 = this.chunk.getUint8(n3 + 2), r2 = this.chunk.getLatin1String(n3 + 5, t3);
52443         e3.set(s2, this.pluralizeValue(e3.get(s2), r2)), n3 += 4 + t3;
52444       } else if (i3) break;
52445       return this.translate(), this.output;
52446     }
52447     pluralizeValue(e3, t2) {
52448       return void 0 !== e3 ? e3 instanceof Array ? (e3.push(t2), e3) : [e3, t2] : t2;
52449     }
52450   };
52451   c(yt, "type", "iptc"), c(yt, "translateValues", false), c(yt, "reviveValues", false), T.set("iptc", yt), U(E, "iptc", [[0, "ApplicationRecordVersion"], [3, "ObjectTypeReference"], [4, "ObjectAttributeReference"], [5, "ObjectName"], [7, "EditStatus"], [8, "EditorialUpdate"], [10, "Urgency"], [12, "SubjectReference"], [15, "Category"], [20, "SupplementalCategories"], [22, "FixtureIdentifier"], [25, "Keywords"], [26, "ContentLocationCode"], [27, "ContentLocationName"], [30, "ReleaseDate"], [35, "ReleaseTime"], [37, "ExpirationDate"], [38, "ExpirationTime"], [40, "SpecialInstructions"], [42, "ActionAdvised"], [45, "ReferenceService"], [47, "ReferenceDate"], [50, "ReferenceNumber"], [55, "DateCreated"], [60, "TimeCreated"], [62, "DigitalCreationDate"], [63, "DigitalCreationTime"], [65, "OriginatingProgram"], [70, "ProgramVersion"], [75, "ObjectCycle"], [80, "Byline"], [85, "BylineTitle"], [90, "City"], [92, "Sublocation"], [95, "State"], [100, "CountryCode"], [101, "Country"], [103, "OriginalTransmissionReference"], [105, "Headline"], [110, "Credit"], [115, "Source"], [116, "CopyrightNotice"], [118, "Contact"], [120, "Caption"], [121, "LocalCaption"], [122, "Writer"], [125, "RasterizedCaption"], [130, "ImageType"], [131, "ImageOrientation"], [135, "LanguageIdentifier"], [150, "AudioType"], [151, "AudioSamplingRate"], [152, "AudioSamplingResolution"], [153, "AudioDuration"], [154, "AudioOutcue"], [184, "JobID"], [185, "MasterDocumentID"], [186, "ShortDocumentID"], [187, "UniqueDocumentID"], [188, "OwnerID"], [200, "ObjectPreviewFileFormat"], [201, "ObjectPreviewFileVersion"], [202, "ObjectPreviewData"], [221, "Prefs"], [225, "ClassifyState"], [228, "SimilarityIndex"], [230, "DocumentNotes"], [231, "DocumentHistory"], [232, "ExifCameraInfo"], [255, "CatalogSets"]]), U(B, "iptc", [[10, { 0: "0 (reserved)", 1: "1 (most urgent)", 2: "2", 3: "3", 4: "4", 5: "5 (normal urgency)", 6: "6", 7: "7", 8: "8 (least urgent)", 9: "9 (user-defined priority)" }], [75, { a: "Morning", b: "Both Morning and Evening", p: "Evening" }], [131, { L: "Landscape", P: "Portrait", S: "Square" }]]);
52452   var full_esm_default = tt;
52453
52454   // modules/services/plane_photo.js
52455   var dispatch5 = dispatch_default("viewerChanged");
52456   var _photo;
52457   var _wrapper;
52458   var imgZoom;
52459   var _widthOverflow;
52460   function zoomPan(d3_event) {
52461     let t2 = d3_event.transform;
52462     _photo.call(utilSetTransform, t2.x, t2.y, t2.k);
52463   }
52464   function zoomBeahvior() {
52465     const { width: wrapperWidth, height: wrapperHeight } = _wrapper.node().getBoundingClientRect();
52466     const { naturalHeight, naturalWidth } = _photo.node();
52467     const intrinsicRatio = naturalWidth / naturalHeight;
52468     _widthOverflow = wrapperHeight * intrinsicRatio - wrapperWidth;
52469     return zoom_default2().extent([[0, 0], [wrapperWidth, wrapperHeight]]).translateExtent([[0, 0], [wrapperWidth + _widthOverflow, wrapperHeight]]).scaleExtent([1, 15]).on("zoom", zoomPan);
52470   }
52471   function loadImage(selection2, path) {
52472     return new Promise((resolve) => {
52473       selection2.attr("src", path);
52474       selection2.on("load", () => {
52475         resolve(selection2);
52476       });
52477     });
52478   }
52479   var plane_photo_default = {
52480     init: async function(context, selection2) {
52481       this.event = utilRebind(this, dispatch5, "on");
52482       _wrapper = selection2.append("div").attr("class", "photo-frame plane-frame").classed("hide", true);
52483       _photo = _wrapper.append("img").attr("class", "plane-photo");
52484       context.ui().photoviewer.on("resize.plane", () => {
52485         imgZoom = zoomBeahvior();
52486         _wrapper.call(imgZoom);
52487       });
52488       await Promise.resolve();
52489       return this;
52490     },
52491     showPhotoFrame: function(context) {
52492       const isHidden = context.selectAll(".photo-frame.plane-frame.hide").size();
52493       if (isHidden) {
52494         context.selectAll(".photo-frame:not(.plane-frame)").classed("hide", true);
52495         context.selectAll(".photo-frame.plane-frame").classed("hide", false);
52496       }
52497       return this;
52498     },
52499     hidePhotoFrame: function(context) {
52500       context.select("photo-frame.plane-frame").classed("hide", false);
52501       return this;
52502     },
52503     selectPhoto: function(data) {
52504       dispatch5.call("viewerChanged");
52505       loadImage(_photo, "");
52506       loadImage(_photo, data.image_path).then(() => {
52507         imgZoom = zoomBeahvior();
52508         _wrapper.call(imgZoom);
52509         _wrapper.call(imgZoom.transform, identity2.translate(-_widthOverflow / 2, 0));
52510       });
52511       return this;
52512     },
52513     getYaw: function() {
52514       return 0;
52515     }
52516   };
52517
52518   // modules/svg/local_photos.js
52519   var _initialized2 = false;
52520   var _enabled2 = false;
52521   var minViewfieldZoom = 16;
52522   function svgLocalPhotos(projection2, context, dispatch14) {
52523     const detected = utilDetect();
52524     let layer = select_default2(null);
52525     let _fileList;
52526     let _photos = [];
52527     let _idAutoinc = 0;
52528     let _photoFrame;
52529     function init2() {
52530       if (_initialized2) return;
52531       _enabled2 = true;
52532       function over(d3_event) {
52533         d3_event.stopPropagation();
52534         d3_event.preventDefault();
52535         d3_event.dataTransfer.dropEffect = "copy";
52536       }
52537       context.container().attr("dropzone", "copy").on("drop.svgLocalPhotos", function(d3_event) {
52538         d3_event.stopPropagation();
52539         d3_event.preventDefault();
52540         if (!detected.filedrop) return;
52541         drawPhotos.fileList(d3_event.dataTransfer.files, (loaded) => {
52542           if (loaded.length > 0) {
52543             drawPhotos.fitZoom(false);
52544           }
52545         });
52546       }).on("dragenter.svgLocalPhotos", over).on("dragexit.svgLocalPhotos", over).on("dragover.svgLocalPhotos", over);
52547       _initialized2 = true;
52548     }
52549     function ensureViewerLoaded(context2) {
52550       if (_photoFrame) {
52551         return Promise.resolve(_photoFrame);
52552       }
52553       const viewer = context2.container().select(".photoviewer").selectAll(".local-photos-wrapper").data([0]);
52554       const viewerEnter = viewer.enter().append("div").attr("class", "photo-wrapper local-photos-wrapper").classed("hide", true);
52555       viewerEnter.append("div").attr("class", "photo-attribution photo-attribution-dual fillD");
52556       return plane_photo_default.init(context2, viewerEnter).then((planePhotoFrame) => {
52557         _photoFrame = planePhotoFrame;
52558       });
52559     }
52560     function click(d3_event, image, zoomTo) {
52561       ensureViewerLoaded(context).then(() => {
52562         const viewer = context.container().select(".photoviewer").datum(image).classed("hide", false);
52563         const viewerWrap = viewer.select(".local-photos-wrapper").classed("hide", false);
52564         const attribution = viewerWrap.selectAll(".photo-attribution").text("");
52565         if (image.date) {
52566           attribution.append("span").text(image.date.toLocaleString());
52567         }
52568         if (image.name) {
52569           attribution.append("span").classed("filename", true).text(image.name);
52570         }
52571         _photoFrame.selectPhoto({ image_path: "" });
52572         image.getSrc().then((src) => {
52573           _photoFrame.selectPhoto({ image_path: src }).showPhotoFrame(viewerWrap);
52574           setStyles();
52575         });
52576       });
52577       if (zoomTo) {
52578         context.map().centerEase(image.loc);
52579       }
52580     }
52581     function transform2(d2) {
52582       var svgpoint = projection2(d2.loc);
52583       return "translate(" + svgpoint[0] + "," + svgpoint[1] + ")";
52584     }
52585     function setStyles(hovered) {
52586       const viewer = context.container().select(".photoviewer");
52587       const selected = viewer.empty() ? void 0 : viewer.datum();
52588       context.container().selectAll(".layer-local-photos .viewfield-group").classed("hovered", (d2) => d2.id === (hovered == null ? void 0 : hovered.id)).classed("highlighted", (d2) => d2.id === (hovered == null ? void 0 : hovered.id) || d2.id === (selected == null ? void 0 : selected.id)).classed("currentView", (d2) => d2.id === (selected == null ? void 0 : selected.id));
52589     }
52590     function display_markers(imageList) {
52591       imageList = imageList.filter((image) => isArray_default(image.loc) && isNumber_default(image.loc[0]) && isNumber_default(image.loc[1]));
52592       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(imageList, function(d2) {
52593         return d2.id;
52594       });
52595       groups.exit().remove();
52596       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", (d3_event, d2) => setStyles(d2)).on("mouseleave", () => setStyles(null)).on("click", click);
52597       groupsEnter.append("g").attr("class", "viewfield-scale");
52598       const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale");
52599       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
52600       const showViewfields = context.map().zoom() >= minViewfieldZoom;
52601       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
52602       viewfields.exit().remove();
52603       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", function() {
52604         var _a4;
52605         const d2 = this.parentNode.__data__;
52606         return "rotate(".concat(Math.round((_a4 = d2.direction) != null ? _a4 : 0), ",0,0),scale(1.5,1.5),translate(-8,-13)");
52607       }).attr("d", "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z").style("visibility", function() {
52608         const d2 = this.parentNode.__data__;
52609         return isNumber_default(d2.direction) ? "visible" : "hidden";
52610       });
52611     }
52612     function drawPhotos(selection2) {
52613       layer = selection2.selectAll(".layer-local-photos").data(_photos ? [0] : []);
52614       layer.exit().remove();
52615       const layerEnter = layer.enter().append("g").attr("class", "layer-local-photos");
52616       layerEnter.append("g").attr("class", "markers");
52617       layer = layerEnter.merge(layer);
52618       if (_photos) {
52619         display_markers(_photos);
52620       }
52621     }
52622     function readFileAsDataURL(file) {
52623       return new Promise((resolve, reject) => {
52624         const reader = new FileReader();
52625         reader.onload = () => resolve(reader.result);
52626         reader.onerror = (error) => reject(error);
52627         reader.readAsDataURL(file);
52628       });
52629     }
52630     async function readmultifiles(files, callback) {
52631       const loaded = [];
52632       for (const file of files) {
52633         try {
52634           const exifData = await full_esm_default.parse(file);
52635           const photo = {
52636             id: _idAutoinc++,
52637             name: file.name,
52638             getSrc: () => readFileAsDataURL(file),
52639             file,
52640             loc: [exifData.longitude, exifData.latitude],
52641             direction: exifData.GPSImgDirection,
52642             date: exifData.CreateDate || exifData.DateTimeOriginal || exifData.ModifyDate
52643           };
52644           loaded.push(photo);
52645           const sameName = _photos.filter((i3) => i3.name === photo.name);
52646           if (sameName.length === 0) {
52647             _photos.push(photo);
52648           } else {
52649             const thisContent = await photo.getSrc();
52650             const sameNameContent = await Promise.allSettled(sameName.map((i3) => i3.getSrc()));
52651             if (!sameNameContent.some((i3) => i3.value === thisContent)) {
52652               _photos.push(photo);
52653             }
52654           }
52655         } catch (e3) {
52656         }
52657       }
52658       if (typeof callback === "function") callback(loaded);
52659       dispatch14.call("change");
52660     }
52661     drawPhotos.setFiles = function(fileList, callback) {
52662       readmultifiles(Array.from(fileList), callback);
52663       return this;
52664     };
52665     drawPhotos.fileList = function(fileList, callback) {
52666       if (!arguments.length) return _fileList;
52667       _fileList = fileList;
52668       if (!fileList || !fileList.length) return this;
52669       drawPhotos.setFiles(_fileList, callback);
52670       return this;
52671     };
52672     drawPhotos.getPhotos = function() {
52673       return _photos;
52674     };
52675     drawPhotos.removePhoto = function(id2) {
52676       _photos = _photos.filter((i3) => i3.id !== id2);
52677       dispatch14.call("change");
52678       return _photos;
52679     };
52680     drawPhotos.openPhoto = click;
52681     drawPhotos.fitZoom = function(force) {
52682       const coords = _photos.map((image) => image.loc).filter((l2) => isArray_default(l2) && isNumber_default(l2[0]) && isNumber_default(l2[1]));
52683       if (coords.length === 0) return;
52684       const extent = coords.map((l2) => geoExtent(l2, l2)).reduce((a2, b2) => a2.extend(b2));
52685       const map2 = context.map();
52686       var viewport = map2.trimmedExtent().polygon();
52687       if (force !== false || !geoPolygonIntersectsPolygon(viewport, coords, true)) {
52688         map2.centerZoom(extent.center(), Math.min(18, map2.trimmedExtentZoom(extent)));
52689       }
52690     };
52691     function showLayer() {
52692       layer.style("display", "block");
52693       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
52694         dispatch14.call("change");
52695       });
52696     }
52697     function hideLayer() {
52698       layer.transition().duration(250).style("opacity", 0).on("end", () => {
52699         layer.selectAll(".viewfield-group").remove();
52700         layer.style("display", "none");
52701       });
52702     }
52703     drawPhotos.enabled = function(val) {
52704       if (!arguments.length) return _enabled2;
52705       _enabled2 = val;
52706       if (_enabled2) {
52707         showLayer();
52708       } else {
52709         hideLayer();
52710       }
52711       dispatch14.call("change");
52712       return this;
52713     };
52714     drawPhotos.hasData = function() {
52715       return isArray_default(_photos) && _photos.length > 0;
52716     };
52717     init2();
52718     return drawPhotos;
52719   }
52720
52721   // modules/svg/osmose.js
52722   var _layerEnabled2 = false;
52723   var _qaService2;
52724   function svgOsmose(projection2, context, dispatch14) {
52725     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
52726     const minZoom5 = 12;
52727     let touchLayer = select_default2(null);
52728     let drawLayer = select_default2(null);
52729     let layerVisible = false;
52730     function markerPath(selection2, klass) {
52731       selection2.attr("class", klass).attr("transform", "translate(-10, -28)").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6");
52732     }
52733     function getService() {
52734       if (services.osmose && !_qaService2) {
52735         _qaService2 = services.osmose;
52736         _qaService2.on("loaded", throttledRedraw);
52737       } else if (!services.osmose && _qaService2) {
52738         _qaService2 = null;
52739       }
52740       return _qaService2;
52741     }
52742     function editOn() {
52743       if (!layerVisible) {
52744         layerVisible = true;
52745         drawLayer.style("display", "block");
52746       }
52747     }
52748     function editOff() {
52749       if (layerVisible) {
52750         layerVisible = false;
52751         drawLayer.style("display", "none");
52752         drawLayer.selectAll(".qaItem.osmose").remove();
52753         touchLayer.selectAll(".qaItem.osmose").remove();
52754       }
52755     }
52756     function layerOn() {
52757       editOn();
52758       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
52759     }
52760     function layerOff() {
52761       throttledRedraw.cancel();
52762       drawLayer.interrupt();
52763       touchLayer.selectAll(".qaItem.osmose").remove();
52764       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
52765         editOff();
52766         dispatch14.call("change");
52767       });
52768     }
52769     function updateMarkers() {
52770       if (!layerVisible || !_layerEnabled2) return;
52771       const service = getService();
52772       const selectedID = context.selectedErrorID();
52773       const data = service ? service.getItems(projection2) : [];
52774       const getTransform = svgPointTransform(projection2);
52775       const markers = drawLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id);
52776       markers.exit().remove();
52777       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
52778       markersEnter.append("polygon").call(markerPath, "shadow");
52779       markersEnter.append("ellipse").attr("cx", 0).attr("cy", 0).attr("rx", 4.5).attr("ry", 2).attr("class", "stroke");
52780       markersEnter.append("polygon").attr("fill", (d2) => service.getColor(d2.item)).call(markerPath, "qaItem-fill");
52781       markersEnter.append("use").attr("class", "icon-annotation").attr("transform", "translate(-6, -22)").attr("width", "12px").attr("height", "12px").attr("xlink:href", (d2) => d2.icon ? "#" + d2.icon : "");
52782       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
52783       if (touchLayer.empty()) return;
52784       const fillClass = context.getDebug("target") ? "pink" : "nocolor";
52785       const targets = touchLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id);
52786       targets.exit().remove();
52787       targets.enter().append("rect").attr("width", "20px").attr("height", "30px").attr("x", "-10px").attr("y", "-28px").merge(targets).sort(sortY).attr("class", (d2) => "qaItem ".concat(d2.service, " target ").concat(fillClass, " itemId-").concat(d2.id)).attr("transform", getTransform);
52788       function sortY(a2, b2) {
52789         return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : b2.loc[1] - a2.loc[1];
52790       }
52791     }
52792     function drawOsmose(selection2) {
52793       const service = getService();
52794       const surface = context.surface();
52795       if (surface && !surface.empty()) {
52796         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
52797       }
52798       drawLayer = selection2.selectAll(".layer-osmose").data(service ? [0] : []);
52799       drawLayer.exit().remove();
52800       drawLayer = drawLayer.enter().append("g").attr("class", "layer-osmose").style("display", _layerEnabled2 ? "block" : "none").merge(drawLayer);
52801       if (_layerEnabled2) {
52802         if (service && ~~context.map().zoom() >= minZoom5) {
52803           editOn();
52804           service.loadIssues(projection2);
52805           updateMarkers();
52806         } else {
52807           editOff();
52808         }
52809       }
52810     }
52811     drawOsmose.enabled = function(val) {
52812       if (!arguments.length) return _layerEnabled2;
52813       _layerEnabled2 = val;
52814       if (_layerEnabled2) {
52815         getService().loadStrings().then(layerOn).catch((err) => {
52816           console.log(err);
52817         });
52818       } else {
52819         layerOff();
52820         if (context.selectedErrorID()) {
52821           context.enter(modeBrowse(context));
52822         }
52823       }
52824       dispatch14.call("change");
52825       return this;
52826     };
52827     drawOsmose.supported = () => !!getService();
52828     return drawOsmose;
52829   }
52830
52831   // modules/svg/streetside.js
52832   function svgStreetside(projection2, context, dispatch14) {
52833     var throttledRedraw = throttle_default(function() {
52834       dispatch14.call("change");
52835     }, 1e3);
52836     var minZoom5 = 14;
52837     var minMarkerZoom = 16;
52838     var minViewfieldZoom2 = 18;
52839     var layer = select_default2(null);
52840     var _viewerYaw = 0;
52841     var _selectedSequence = null;
52842     var _streetside;
52843     function init2() {
52844       if (svgStreetside.initialized) return;
52845       svgStreetside.enabled = false;
52846       svgStreetside.initialized = true;
52847     }
52848     function getService() {
52849       if (services.streetside && !_streetside) {
52850         _streetside = services.streetside;
52851         _streetside.event.on("viewerChanged.svgStreetside", viewerChanged).on("loadedImages.svgStreetside", throttledRedraw);
52852       } else if (!services.streetside && _streetside) {
52853         _streetside = null;
52854       }
52855       return _streetside;
52856     }
52857     function showLayer() {
52858       var service = getService();
52859       if (!service) return;
52860       editOn();
52861       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
52862         dispatch14.call("change");
52863       });
52864     }
52865     function hideLayer() {
52866       throttledRedraw.cancel();
52867       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
52868     }
52869     function editOn() {
52870       layer.style("display", "block");
52871     }
52872     function editOff() {
52873       layer.selectAll(".viewfield-group").remove();
52874       layer.style("display", "none");
52875     }
52876     function click(d3_event, d2) {
52877       var service = getService();
52878       if (!service) return;
52879       if (d2.sequenceKey !== _selectedSequence) {
52880         _viewerYaw = 0;
52881       }
52882       _selectedSequence = d2.sequenceKey;
52883       service.ensureViewerLoaded(context).then(function() {
52884         service.selectImage(context, d2.key).yaw(_viewerYaw).showViewer(context);
52885       });
52886       context.map().centerEase(d2.loc);
52887     }
52888     function mouseover(d3_event, d2) {
52889       var service = getService();
52890       if (service) service.setStyles(context, d2);
52891     }
52892     function mouseout() {
52893       var service = getService();
52894       if (service) service.setStyles(context, null);
52895     }
52896     function transform2(d2) {
52897       var t2 = svgPointTransform(projection2)(d2);
52898       var rot = d2.ca + _viewerYaw;
52899       if (rot) {
52900         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
52901       }
52902       return t2;
52903     }
52904     function viewerChanged() {
52905       var service = getService();
52906       if (!service) return;
52907       var viewer = service.viewer();
52908       if (!viewer) return;
52909       _viewerYaw = viewer.getYaw();
52910       if (context.map().isTransformed()) return;
52911       layer.selectAll(".viewfield-group.currentView").attr("transform", transform2);
52912     }
52913     function filterBubbles(bubbles) {
52914       var fromDate = context.photos().fromDate();
52915       var toDate = context.photos().toDate();
52916       var usernames = context.photos().usernames();
52917       if (fromDate) {
52918         var fromTimestamp = new Date(fromDate).getTime();
52919         bubbles = bubbles.filter(function(bubble) {
52920           return new Date(bubble.captured_at).getTime() >= fromTimestamp;
52921         });
52922       }
52923       if (toDate) {
52924         var toTimestamp = new Date(toDate).getTime();
52925         bubbles = bubbles.filter(function(bubble) {
52926           return new Date(bubble.captured_at).getTime() <= toTimestamp;
52927         });
52928       }
52929       if (usernames) {
52930         bubbles = bubbles.filter(function(bubble) {
52931           return usernames.indexOf(bubble.captured_by) !== -1;
52932         });
52933       }
52934       return bubbles;
52935     }
52936     function filterSequences(sequences) {
52937       var fromDate = context.photos().fromDate();
52938       var toDate = context.photos().toDate();
52939       var usernames = context.photos().usernames();
52940       if (fromDate) {
52941         var fromTimestamp = new Date(fromDate).getTime();
52942         sequences = sequences.filter(function(sequences2) {
52943           return new Date(sequences2.properties.captured_at).getTime() >= fromTimestamp;
52944         });
52945       }
52946       if (toDate) {
52947         var toTimestamp = new Date(toDate).getTime();
52948         sequences = sequences.filter(function(sequences2) {
52949           return new Date(sequences2.properties.captured_at).getTime() <= toTimestamp;
52950         });
52951       }
52952       if (usernames) {
52953         sequences = sequences.filter(function(sequences2) {
52954           return usernames.indexOf(sequences2.properties.captured_by) !== -1;
52955         });
52956       }
52957       return sequences;
52958     }
52959     function update() {
52960       var viewer = context.container().select(".photoviewer");
52961       var selected = viewer.empty() ? void 0 : viewer.datum();
52962       var z2 = ~~context.map().zoom();
52963       var showMarkers = z2 >= minMarkerZoom;
52964       var showViewfields = z2 >= minViewfieldZoom2;
52965       var service = getService();
52966       var sequences = [];
52967       var bubbles = [];
52968       if (context.photos().showsPanoramic()) {
52969         sequences = service ? service.sequences(projection2) : [];
52970         bubbles = service && showMarkers ? service.bubbles(projection2) : [];
52971         sequences = filterSequences(sequences);
52972         bubbles = filterBubbles(bubbles);
52973       }
52974       var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
52975         return d2.properties.key;
52976       });
52977       traces.exit().remove();
52978       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
52979       var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(bubbles, function(d2) {
52980         return d2.key + (d2.sequenceKey ? "v1" : "v0");
52981       });
52982       groups.exit().remove();
52983       var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
52984       groupsEnter.append("g").attr("class", "viewfield-scale");
52985       var markers = groups.merge(groupsEnter).sort(function(a2, b2) {
52986         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
52987       }).attr("transform", transform2).select(".viewfield-scale");
52988       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
52989       var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
52990       viewfields.exit().remove();
52991       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
52992       function viewfieldPath() {
52993         var d2 = this.parentNode.__data__;
52994         if (d2.pano) {
52995           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
52996         } else {
52997           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
52998         }
52999       }
53000     }
53001     function drawImages(selection2) {
53002       var enabled = svgStreetside.enabled;
53003       var service = getService();
53004       layer = selection2.selectAll(".layer-streetside-images").data(service ? [0] : []);
53005       layer.exit().remove();
53006       var layerEnter = layer.enter().append("g").attr("class", "layer-streetside-images").style("display", enabled ? "block" : "none");
53007       layerEnter.append("g").attr("class", "sequences");
53008       layerEnter.append("g").attr("class", "markers");
53009       layer = layerEnter.merge(layer);
53010       if (enabled) {
53011         if (service && ~~context.map().zoom() >= minZoom5) {
53012           editOn();
53013           update();
53014           service.loadBubbles(projection2);
53015         } else {
53016           editOff();
53017         }
53018       }
53019     }
53020     drawImages.enabled = function(_2) {
53021       if (!arguments.length) return svgStreetside.enabled;
53022       svgStreetside.enabled = _2;
53023       if (svgStreetside.enabled) {
53024         showLayer();
53025         context.photos().on("change.streetside", update);
53026       } else {
53027         hideLayer();
53028         context.photos().on("change.streetside", null);
53029       }
53030       dispatch14.call("change");
53031       return this;
53032     };
53033     drawImages.supported = function() {
53034       return !!getService();
53035     };
53036     drawImages.rendered = function(zoom) {
53037       return zoom >= minZoom5;
53038     };
53039     init2();
53040     return drawImages;
53041   }
53042
53043   // modules/svg/vegbilder.js
53044   function svgVegbilder(projection2, context, dispatch14) {
53045     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
53046     const minZoom5 = 14;
53047     const minMarkerZoom = 16;
53048     const minViewfieldZoom2 = 18;
53049     let layer = select_default2(null);
53050     let _viewerYaw = 0;
53051     let _vegbilder;
53052     function init2() {
53053       if (svgVegbilder.initialized) return;
53054       svgVegbilder.enabled = false;
53055       svgVegbilder.initialized = true;
53056     }
53057     function getService() {
53058       if (services.vegbilder && !_vegbilder) {
53059         _vegbilder = services.vegbilder;
53060         _vegbilder.event.on("viewerChanged.svgVegbilder", viewerChanged).on("loadedImages.svgVegbilder", throttledRedraw);
53061       } else if (!services.vegbilder && _vegbilder) {
53062         _vegbilder = null;
53063       }
53064       return _vegbilder;
53065     }
53066     function showLayer() {
53067       const service = getService();
53068       if (!service) return;
53069       editOn();
53070       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", () => dispatch14.call("change"));
53071     }
53072     function hideLayer() {
53073       throttledRedraw.cancel();
53074       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
53075     }
53076     function editOn() {
53077       layer.style("display", "block");
53078     }
53079     function editOff() {
53080       layer.selectAll(".viewfield-group").remove();
53081       layer.style("display", "none");
53082     }
53083     function click(d3_event, d2) {
53084       const service = getService();
53085       if (!service) return;
53086       service.ensureViewerLoaded(context).then(() => {
53087         service.selectImage(context, d2.key).showViewer(context);
53088       });
53089       context.map().centerEase(d2.loc);
53090     }
53091     function mouseover(d3_event, d2) {
53092       const service = getService();
53093       if (service) service.setStyles(context, d2);
53094     }
53095     function mouseout() {
53096       const service = getService();
53097       if (service) service.setStyles(context, null);
53098     }
53099     function transform2(d2, selected) {
53100       let t2 = svgPointTransform(projection2)(d2);
53101       let rot = d2.ca;
53102       if (d2 === selected) {
53103         rot += _viewerYaw;
53104       }
53105       if (rot) {
53106         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
53107       }
53108       return t2;
53109     }
53110     function viewerChanged() {
53111       const service = getService();
53112       if (!service) return;
53113       const frame2 = service.photoFrame();
53114       _viewerYaw = frame2.getYaw();
53115       if (context.map().isTransformed()) return;
53116       layer.selectAll(".viewfield-group.currentView").attr("transform", (d2) => transform2(d2, d2));
53117     }
53118     function filterImages(images) {
53119       const photoContext = context.photos();
53120       const fromDateString = photoContext.fromDate();
53121       const toDateString = photoContext.toDate();
53122       const showsFlat = photoContext.showsFlat();
53123       const showsPano = photoContext.showsPanoramic();
53124       if (fromDateString) {
53125         const fromDate = new Date(fromDateString);
53126         images = images.filter((image) => image.captured_at.getTime() >= fromDate.getTime());
53127       }
53128       if (toDateString) {
53129         const toDate = new Date(toDateString);
53130         images = images.filter((image) => image.captured_at.getTime() <= toDate.getTime());
53131       }
53132       if (!showsPano) {
53133         images = images.filter((image) => !image.is_sphere);
53134       }
53135       if (!showsFlat) {
53136         images = images.filter((image) => image.is_sphere);
53137       }
53138       return images;
53139     }
53140     function filterSequences(sequences) {
53141       const photoContext = context.photos();
53142       const fromDateString = photoContext.fromDate();
53143       const toDateString = photoContext.toDate();
53144       const showsFlat = photoContext.showsFlat();
53145       const showsPano = photoContext.showsPanoramic();
53146       if (fromDateString) {
53147         const fromDate = new Date(fromDateString);
53148         sequences = sequences.filter(({ images }) => images[0].captured_at.getTime() >= fromDate.getTime());
53149       }
53150       if (toDateString) {
53151         const toDate = new Date(toDateString);
53152         sequences = sequences.filter(({ images }) => images[images.length - 1].captured_at.getTime() <= toDate.getTime());
53153       }
53154       if (!showsPano) {
53155         sequences = sequences.filter(({ images }) => !images[0].is_sphere);
53156       }
53157       if (!showsFlat) {
53158         sequences = sequences.filter(({ images }) => images[0].is_sphere);
53159       }
53160       return sequences;
53161     }
53162     function update() {
53163       const viewer = context.container().select(".photoviewer");
53164       const selected = viewer.empty() ? void 0 : viewer.datum();
53165       const z2 = ~~context.map().zoom();
53166       const showMarkers = z2 >= minMarkerZoom;
53167       const showViewfields = z2 >= minViewfieldZoom2;
53168       const service = getService();
53169       let sequences = [];
53170       let images = [];
53171       if (service) {
53172         service.loadImages(context);
53173         sequences = service.sequences(projection2);
53174         images = showMarkers ? service.images(projection2) : [];
53175         images = filterImages(images);
53176         sequences = filterSequences(sequences);
53177       }
53178       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, (d2) => d2.key);
53179       traces.exit().remove();
53180       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
53181       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, (d2) => d2.key);
53182       groups.exit().remove();
53183       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
53184       groupsEnter.append("g").attr("class", "viewfield-scale");
53185       const markers = groups.merge(groupsEnter).sort((a2, b2) => {
53186         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
53187       }).attr("transform", (d2) => transform2(d2, selected)).select(".viewfield-scale");
53188       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
53189       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
53190       viewfields.exit().remove();
53191       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
53192       function viewfieldPath() {
53193         const d2 = this.parentNode.__data__;
53194         if (d2.is_sphere) {
53195           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
53196         } else {
53197           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
53198         }
53199       }
53200     }
53201     function drawImages(selection2) {
53202       const enabled = svgVegbilder.enabled;
53203       const service = getService();
53204       layer = selection2.selectAll(".layer-vegbilder").data(service ? [0] : []);
53205       layer.exit().remove();
53206       const layerEnter = layer.enter().append("g").attr("class", "layer-vegbilder").style("display", enabled ? "block" : "none");
53207       layerEnter.append("g").attr("class", "sequences");
53208       layerEnter.append("g").attr("class", "markers");
53209       layer = layerEnter.merge(layer);
53210       if (enabled) {
53211         if (service && ~~context.map().zoom() >= minZoom5) {
53212           editOn();
53213           update();
53214           service.loadImages(context);
53215         } else {
53216           editOff();
53217         }
53218       }
53219     }
53220     drawImages.enabled = function(_2) {
53221       if (!arguments.length) return svgVegbilder.enabled;
53222       svgVegbilder.enabled = _2;
53223       if (svgVegbilder.enabled) {
53224         showLayer();
53225         context.photos().on("change.vegbilder", update);
53226       } else {
53227         hideLayer();
53228         context.photos().on("change.vegbilder", null);
53229       }
53230       dispatch14.call("change");
53231       return this;
53232     };
53233     drawImages.supported = function() {
53234       return !!getService();
53235     };
53236     drawImages.rendered = function(zoom) {
53237       return zoom >= minZoom5;
53238     };
53239     drawImages.validHere = function(extent, zoom) {
53240       return zoom >= minZoom5 - 2 && getService().validHere(extent);
53241     };
53242     init2();
53243     return drawImages;
53244   }
53245
53246   // modules/svg/mapillary_images.js
53247   function svgMapillaryImages(projection2, context, dispatch14) {
53248     const throttledRedraw = throttle_default(function() {
53249       dispatch14.call("change");
53250     }, 1e3);
53251     const minZoom5 = 12;
53252     const minMarkerZoom = 16;
53253     const minViewfieldZoom2 = 18;
53254     let layer = select_default2(null);
53255     let _mapillary;
53256     function init2() {
53257       if (svgMapillaryImages.initialized) return;
53258       svgMapillaryImages.enabled = false;
53259       svgMapillaryImages.initialized = true;
53260     }
53261     function getService() {
53262       if (services.mapillary && !_mapillary) {
53263         _mapillary = services.mapillary;
53264         _mapillary.event.on("loadedImages", throttledRedraw);
53265       } else if (!services.mapillary && _mapillary) {
53266         _mapillary = null;
53267       }
53268       return _mapillary;
53269     }
53270     function showLayer() {
53271       const service = getService();
53272       if (!service) return;
53273       editOn();
53274       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
53275         dispatch14.call("change");
53276       });
53277     }
53278     function hideLayer() {
53279       throttledRedraw.cancel();
53280       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
53281     }
53282     function editOn() {
53283       layer.style("display", "block");
53284     }
53285     function editOff() {
53286       layer.selectAll(".viewfield-group").remove();
53287       layer.style("display", "none");
53288     }
53289     function click(d3_event, image) {
53290       const service = getService();
53291       if (!service) return;
53292       service.ensureViewerLoaded(context).then(function() {
53293         service.selectImage(context, image.id).showViewer(context);
53294       });
53295       context.map().centerEase(image.loc);
53296     }
53297     function mouseover(d3_event, image) {
53298       const service = getService();
53299       if (service) service.setStyles(context, image);
53300     }
53301     function mouseout() {
53302       const service = getService();
53303       if (service) service.setStyles(context, null);
53304     }
53305     function transform2(d2) {
53306       let t2 = svgPointTransform(projection2)(d2);
53307       if (d2.ca) {
53308         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
53309       }
53310       return t2;
53311     }
53312     function filterImages(images) {
53313       const showsPano = context.photos().showsPanoramic();
53314       const showsFlat = context.photos().showsFlat();
53315       const fromDate = context.photos().fromDate();
53316       const toDate = context.photos().toDate();
53317       if (!showsPano || !showsFlat) {
53318         images = images.filter(function(image) {
53319           if (image.is_pano) return showsPano;
53320           return showsFlat;
53321         });
53322       }
53323       if (fromDate) {
53324         images = images.filter(function(image) {
53325           return new Date(image.captured_at).getTime() >= new Date(fromDate).getTime();
53326         });
53327       }
53328       if (toDate) {
53329         images = images.filter(function(image) {
53330           return new Date(image.captured_at).getTime() <= new Date(toDate).getTime();
53331         });
53332       }
53333       return images;
53334     }
53335     function filterSequences(sequences) {
53336       const showsPano = context.photos().showsPanoramic();
53337       const showsFlat = context.photos().showsFlat();
53338       const fromDate = context.photos().fromDate();
53339       const toDate = context.photos().toDate();
53340       if (!showsPano || !showsFlat) {
53341         sequences = sequences.filter(function(sequence) {
53342           if (sequence.properties.hasOwnProperty("is_pano")) {
53343             if (sequence.properties.is_pano) return showsPano;
53344             return showsFlat;
53345           }
53346           return false;
53347         });
53348       }
53349       if (fromDate) {
53350         sequences = sequences.filter(function(sequence) {
53351           return new Date(sequence.properties.captured_at).getTime() >= new Date(fromDate).getTime().toString();
53352         });
53353       }
53354       if (toDate) {
53355         sequences = sequences.filter(function(sequence) {
53356           return new Date(sequence.properties.captured_at).getTime() <= new Date(toDate).getTime().toString();
53357         });
53358       }
53359       return sequences;
53360     }
53361     function update() {
53362       const z2 = ~~context.map().zoom();
53363       const showMarkers = z2 >= minMarkerZoom;
53364       const showViewfields = z2 >= minViewfieldZoom2;
53365       const service = getService();
53366       let sequences = service ? service.sequences(projection2) : [];
53367       let images = service && showMarkers ? service.images(projection2) : [];
53368       images = filterImages(images);
53369       sequences = filterSequences(sequences, service);
53370       service.filterViewer(context);
53371       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
53372         return d2.properties.id;
53373       });
53374       traces.exit().remove();
53375       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
53376       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
53377         return d2.id;
53378       });
53379       groups.exit().remove();
53380       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
53381       groupsEnter.append("g").attr("class", "viewfield-scale");
53382       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
53383         return b2.loc[1] - a2.loc[1];
53384       }).attr("transform", transform2).select(".viewfield-scale");
53385       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
53386       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
53387       viewfields.exit().remove();
53388       viewfields.enter().insert("path", "circle").attr("class", "viewfield").classed("pano", function() {
53389         return this.parentNode.__data__.is_pano;
53390       }).attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
53391       function viewfieldPath() {
53392         if (this.parentNode.__data__.is_pano) {
53393           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
53394         } else {
53395           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
53396         }
53397       }
53398     }
53399     function drawImages(selection2) {
53400       const enabled = svgMapillaryImages.enabled;
53401       const service = getService();
53402       layer = selection2.selectAll(".layer-mapillary").data(service ? [0] : []);
53403       layer.exit().remove();
53404       const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary").style("display", enabled ? "block" : "none");
53405       layerEnter.append("g").attr("class", "sequences");
53406       layerEnter.append("g").attr("class", "markers");
53407       layer = layerEnter.merge(layer);
53408       if (enabled) {
53409         if (service && ~~context.map().zoom() >= minZoom5) {
53410           editOn();
53411           update();
53412           service.loadImages(projection2);
53413         } else {
53414           editOff();
53415         }
53416       }
53417     }
53418     drawImages.enabled = function(_2) {
53419       if (!arguments.length) return svgMapillaryImages.enabled;
53420       svgMapillaryImages.enabled = _2;
53421       if (svgMapillaryImages.enabled) {
53422         showLayer();
53423         context.photos().on("change.mapillary_images", update);
53424       } else {
53425         hideLayer();
53426         context.photos().on("change.mapillary_images", null);
53427       }
53428       dispatch14.call("change");
53429       return this;
53430     };
53431     drawImages.supported = function() {
53432       return !!getService();
53433     };
53434     drawImages.rendered = function(zoom) {
53435       return zoom >= minZoom5;
53436     };
53437     init2();
53438     return drawImages;
53439   }
53440
53441   // modules/svg/mapillary_position.js
53442   function svgMapillaryPosition(projection2, context) {
53443     const throttledRedraw = throttle_default(function() {
53444       update();
53445     }, 1e3);
53446     const minZoom5 = 12;
53447     const minViewfieldZoom2 = 18;
53448     let layer = select_default2(null);
53449     let _mapillary;
53450     let viewerCompassAngle;
53451     function init2() {
53452       if (svgMapillaryPosition.initialized) return;
53453       svgMapillaryPosition.initialized = true;
53454     }
53455     function getService() {
53456       if (services.mapillary && !_mapillary) {
53457         _mapillary = services.mapillary;
53458         _mapillary.event.on("imageChanged", throttledRedraw);
53459         _mapillary.event.on("bearingChanged", function(e3) {
53460           viewerCompassAngle = e3.bearing;
53461           if (context.map().isTransformed()) return;
53462           layer.selectAll(".viewfield-group.currentView").filter(function(d2) {
53463             return d2.is_pano;
53464           }).attr("transform", transform2);
53465         });
53466       } else if (!services.mapillary && _mapillary) {
53467         _mapillary = null;
53468       }
53469       return _mapillary;
53470     }
53471     function editOn() {
53472       layer.style("display", "block");
53473     }
53474     function editOff() {
53475       layer.selectAll(".viewfield-group").remove();
53476       layer.style("display", "none");
53477     }
53478     function transform2(d2) {
53479       let t2 = svgPointTransform(projection2)(d2);
53480       if (d2.is_pano && viewerCompassAngle !== null && isFinite(viewerCompassAngle)) {
53481         t2 += " rotate(" + Math.floor(viewerCompassAngle) + ",0,0)";
53482       } else if (d2.ca) {
53483         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
53484       }
53485       return t2;
53486     }
53487     function update() {
53488       const z2 = ~~context.map().zoom();
53489       const showViewfields = z2 >= minViewfieldZoom2;
53490       const service = getService();
53491       const image = service && service.getActiveImage();
53492       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(image ? [image] : [], function(d2) {
53493         return d2.id;
53494       });
53495       groups.exit().remove();
53496       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group currentView highlighted");
53497       groupsEnter.append("g").attr("class", "viewfield-scale");
53498       const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale");
53499       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
53500       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
53501       viewfields.exit().remove();
53502       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z");
53503     }
53504     function drawImages(selection2) {
53505       const service = getService();
53506       layer = selection2.selectAll(".layer-mapillary-position").data(service ? [0] : []);
53507       layer.exit().remove();
53508       const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary-position");
53509       layerEnter.append("g").attr("class", "markers");
53510       layer = layerEnter.merge(layer);
53511       if (service && ~~context.map().zoom() >= minZoom5) {
53512         editOn();
53513         update();
53514       } else {
53515         editOff();
53516       }
53517     }
53518     drawImages.enabled = function() {
53519       update();
53520       return this;
53521     };
53522     drawImages.supported = function() {
53523       return !!getService();
53524     };
53525     drawImages.rendered = function(zoom) {
53526       return zoom >= minZoom5;
53527     };
53528     init2();
53529     return drawImages;
53530   }
53531
53532   // modules/svg/mapillary_signs.js
53533   function svgMapillarySigns(projection2, context, dispatch14) {
53534     const throttledRedraw = throttle_default(function() {
53535       dispatch14.call("change");
53536     }, 1e3);
53537     const minZoom5 = 12;
53538     let layer = select_default2(null);
53539     let _mapillary;
53540     function init2() {
53541       if (svgMapillarySigns.initialized) return;
53542       svgMapillarySigns.enabled = false;
53543       svgMapillarySigns.initialized = true;
53544     }
53545     function getService() {
53546       if (services.mapillary && !_mapillary) {
53547         _mapillary = services.mapillary;
53548         _mapillary.event.on("loadedSigns", throttledRedraw);
53549       } else if (!services.mapillary && _mapillary) {
53550         _mapillary = null;
53551       }
53552       return _mapillary;
53553     }
53554     function showLayer() {
53555       const service = getService();
53556       if (!service) return;
53557       service.loadSignResources(context);
53558       editOn();
53559     }
53560     function hideLayer() {
53561       throttledRedraw.cancel();
53562       editOff();
53563     }
53564     function editOn() {
53565       layer.style("display", "block");
53566     }
53567     function editOff() {
53568       layer.selectAll(".icon-sign").remove();
53569       layer.style("display", "none");
53570     }
53571     function click(d3_event, d2) {
53572       const service = getService();
53573       if (!service) return;
53574       context.map().centerEase(d2.loc);
53575       const selectedImageId = service.getActiveImage() && service.getActiveImage().id;
53576       service.getDetections(d2.id).then((detections) => {
53577         if (detections.length) {
53578           const imageId = detections[0].image.id;
53579           if (imageId === selectedImageId) {
53580             service.highlightDetection(detections[0]).selectImage(context, imageId);
53581           } else {
53582             service.ensureViewerLoaded(context).then(function() {
53583               service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context);
53584             });
53585           }
53586         }
53587       });
53588     }
53589     function filterData(detectedFeatures) {
53590       var fromDate = context.photos().fromDate();
53591       var toDate = context.photos().toDate();
53592       if (fromDate) {
53593         var fromTimestamp = new Date(fromDate).getTime();
53594         detectedFeatures = detectedFeatures.filter(function(feature3) {
53595           return new Date(feature3.last_seen_at).getTime() >= fromTimestamp;
53596         });
53597       }
53598       if (toDate) {
53599         var toTimestamp = new Date(toDate).getTime();
53600         detectedFeatures = detectedFeatures.filter(function(feature3) {
53601           return new Date(feature3.first_seen_at).getTime() <= toTimestamp;
53602         });
53603       }
53604       return detectedFeatures;
53605     }
53606     function update() {
53607       const service = getService();
53608       let data = service ? service.signs(projection2) : [];
53609       data = filterData(data);
53610       const transform2 = svgPointTransform(projection2);
53611       const signs = layer.selectAll(".icon-sign").data(data, function(d2) {
53612         return d2.id;
53613       });
53614       signs.exit().remove();
53615       const enter = signs.enter().append("g").attr("class", "icon-sign icon-detected").on("click", click);
53616       enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) {
53617         return "#" + d2.value;
53618       });
53619       enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px");
53620       signs.merge(enter).attr("transform", transform2);
53621     }
53622     function drawSigns(selection2) {
53623       const enabled = svgMapillarySigns.enabled;
53624       const service = getService();
53625       layer = selection2.selectAll(".layer-mapillary-signs").data(service ? [0] : []);
53626       layer.exit().remove();
53627       layer = layer.enter().append("g").attr("class", "layer-mapillary-signs layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer);
53628       if (enabled) {
53629         if (service && ~~context.map().zoom() >= minZoom5) {
53630           editOn();
53631           update();
53632           service.loadSigns(projection2);
53633           service.showSignDetections(true);
53634         } else {
53635           editOff();
53636         }
53637       } else if (service) {
53638         service.showSignDetections(false);
53639       }
53640     }
53641     drawSigns.enabled = function(_2) {
53642       if (!arguments.length) return svgMapillarySigns.enabled;
53643       svgMapillarySigns.enabled = _2;
53644       if (svgMapillarySigns.enabled) {
53645         showLayer();
53646         context.photos().on("change.mapillary_signs", update);
53647       } else {
53648         hideLayer();
53649         context.photos().on("change.mapillary_signs", null);
53650       }
53651       dispatch14.call("change");
53652       return this;
53653     };
53654     drawSigns.supported = function() {
53655       return !!getService();
53656     };
53657     drawSigns.rendered = function(zoom) {
53658       return zoom >= minZoom5;
53659     };
53660     init2();
53661     return drawSigns;
53662   }
53663
53664   // modules/svg/mapillary_map_features.js
53665   function svgMapillaryMapFeatures(projection2, context, dispatch14) {
53666     const throttledRedraw = throttle_default(function() {
53667       dispatch14.call("change");
53668     }, 1e3);
53669     const minZoom5 = 12;
53670     let layer = select_default2(null);
53671     let _mapillary;
53672     function init2() {
53673       if (svgMapillaryMapFeatures.initialized) return;
53674       svgMapillaryMapFeatures.enabled = false;
53675       svgMapillaryMapFeatures.initialized = true;
53676     }
53677     function getService() {
53678       if (services.mapillary && !_mapillary) {
53679         _mapillary = services.mapillary;
53680         _mapillary.event.on("loadedMapFeatures", throttledRedraw);
53681       } else if (!services.mapillary && _mapillary) {
53682         _mapillary = null;
53683       }
53684       return _mapillary;
53685     }
53686     function showLayer() {
53687       const service = getService();
53688       if (!service) return;
53689       service.loadObjectResources(context);
53690       editOn();
53691     }
53692     function hideLayer() {
53693       throttledRedraw.cancel();
53694       editOff();
53695     }
53696     function editOn() {
53697       layer.style("display", "block");
53698     }
53699     function editOff() {
53700       layer.selectAll(".icon-map-feature").remove();
53701       layer.style("display", "none");
53702     }
53703     function click(d3_event, d2) {
53704       const service = getService();
53705       if (!service) return;
53706       context.map().centerEase(d2.loc);
53707       const selectedImageId = service.getActiveImage() && service.getActiveImage().id;
53708       service.getDetections(d2.id).then((detections) => {
53709         if (detections.length) {
53710           const imageId = detections[0].image.id;
53711           if (imageId === selectedImageId) {
53712             service.highlightDetection(detections[0]).selectImage(context, imageId);
53713           } else {
53714             service.ensureViewerLoaded(context).then(function() {
53715               service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context);
53716             });
53717           }
53718         }
53719       });
53720     }
53721     function filterData(detectedFeatures) {
53722       const fromDate = context.photos().fromDate();
53723       const toDate = context.photos().toDate();
53724       if (fromDate) {
53725         detectedFeatures = detectedFeatures.filter(function(feature3) {
53726           return new Date(feature3.last_seen_at).getTime() >= new Date(fromDate).getTime();
53727         });
53728       }
53729       if (toDate) {
53730         detectedFeatures = detectedFeatures.filter(function(feature3) {
53731           return new Date(feature3.first_seen_at).getTime() <= new Date(toDate).getTime();
53732         });
53733       }
53734       return detectedFeatures;
53735     }
53736     function update() {
53737       const service = getService();
53738       let data = service ? service.mapFeatures(projection2) : [];
53739       data = filterData(data);
53740       const transform2 = svgPointTransform(projection2);
53741       const mapFeatures = layer.selectAll(".icon-map-feature").data(data, function(d2) {
53742         return d2.id;
53743       });
53744       mapFeatures.exit().remove();
53745       const enter = mapFeatures.enter().append("g").attr("class", "icon-map-feature icon-detected").on("click", click);
53746       enter.append("title").text(function(d2) {
53747         var id2 = d2.value.replace(/--/g, ".").replace(/-/g, "_");
53748         return _t("mapillary_map_features." + id2);
53749       });
53750       enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) {
53751         if (d2.value === "object--billboard") {
53752           return "#object--sign--advertisement";
53753         }
53754         return "#" + d2.value;
53755       });
53756       enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px");
53757       mapFeatures.merge(enter).attr("transform", transform2);
53758     }
53759     function drawMapFeatures(selection2) {
53760       const enabled = svgMapillaryMapFeatures.enabled;
53761       const service = getService();
53762       layer = selection2.selectAll(".layer-mapillary-map-features").data(service ? [0] : []);
53763       layer.exit().remove();
53764       layer = layer.enter().append("g").attr("class", "layer-mapillary-map-features layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer);
53765       if (enabled) {
53766         if (service && ~~context.map().zoom() >= minZoom5) {
53767           editOn();
53768           update();
53769           service.loadMapFeatures(projection2);
53770           service.showFeatureDetections(true);
53771         } else {
53772           editOff();
53773         }
53774       } else if (service) {
53775         service.showFeatureDetections(false);
53776       }
53777     }
53778     drawMapFeatures.enabled = function(_2) {
53779       if (!arguments.length) return svgMapillaryMapFeatures.enabled;
53780       svgMapillaryMapFeatures.enabled = _2;
53781       if (svgMapillaryMapFeatures.enabled) {
53782         showLayer();
53783         context.photos().on("change.mapillary_map_features", update);
53784       } else {
53785         hideLayer();
53786         context.photos().on("change.mapillary_map_features", null);
53787       }
53788       dispatch14.call("change");
53789       return this;
53790     };
53791     drawMapFeatures.supported = function() {
53792       return !!getService();
53793     };
53794     drawMapFeatures.rendered = function(zoom) {
53795       return zoom >= minZoom5;
53796     };
53797     init2();
53798     return drawMapFeatures;
53799   }
53800
53801   // modules/svg/kartaview_images.js
53802   function svgKartaviewImages(projection2, context, dispatch14) {
53803     var throttledRedraw = throttle_default(function() {
53804       dispatch14.call("change");
53805     }, 1e3);
53806     var minZoom5 = 12;
53807     var minMarkerZoom = 16;
53808     var minViewfieldZoom2 = 18;
53809     var layer = select_default2(null);
53810     var _kartaview;
53811     function init2() {
53812       if (svgKartaviewImages.initialized) return;
53813       svgKartaviewImages.enabled = false;
53814       svgKartaviewImages.initialized = true;
53815     }
53816     function getService() {
53817       if (services.kartaview && !_kartaview) {
53818         _kartaview = services.kartaview;
53819         _kartaview.event.on("loadedImages", throttledRedraw);
53820       } else if (!services.kartaview && _kartaview) {
53821         _kartaview = null;
53822       }
53823       return _kartaview;
53824     }
53825     function showLayer() {
53826       var service = getService();
53827       if (!service) return;
53828       editOn();
53829       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
53830         dispatch14.call("change");
53831       });
53832     }
53833     function hideLayer() {
53834       throttledRedraw.cancel();
53835       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
53836     }
53837     function editOn() {
53838       layer.style("display", "block");
53839     }
53840     function editOff() {
53841       layer.selectAll(".viewfield-group").remove();
53842       layer.style("display", "none");
53843     }
53844     function click(d3_event, d2) {
53845       var service = getService();
53846       if (!service) return;
53847       service.ensureViewerLoaded(context).then(function() {
53848         service.selectImage(context, d2.key).showViewer(context);
53849       });
53850       context.map().centerEase(d2.loc);
53851     }
53852     function mouseover(d3_event, d2) {
53853       var service = getService();
53854       if (service) service.setStyles(context, d2);
53855     }
53856     function mouseout() {
53857       var service = getService();
53858       if (service) service.setStyles(context, null);
53859     }
53860     function transform2(d2) {
53861       var t2 = svgPointTransform(projection2)(d2);
53862       if (d2.ca) {
53863         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
53864       }
53865       return t2;
53866     }
53867     function filterImages(images) {
53868       var fromDate = context.photos().fromDate();
53869       var toDate = context.photos().toDate();
53870       var usernames = context.photos().usernames();
53871       if (fromDate) {
53872         var fromTimestamp = new Date(fromDate).getTime();
53873         images = images.filter(function(item) {
53874           return new Date(item.captured_at).getTime() >= fromTimestamp;
53875         });
53876       }
53877       if (toDate) {
53878         var toTimestamp = new Date(toDate).getTime();
53879         images = images.filter(function(item) {
53880           return new Date(item.captured_at).getTime() <= toTimestamp;
53881         });
53882       }
53883       if (usernames) {
53884         images = images.filter(function(item) {
53885           return usernames.indexOf(item.captured_by) !== -1;
53886         });
53887       }
53888       return images;
53889     }
53890     function filterSequences(sequences) {
53891       var fromDate = context.photos().fromDate();
53892       var toDate = context.photos().toDate();
53893       var usernames = context.photos().usernames();
53894       if (fromDate) {
53895         var fromTimestamp = new Date(fromDate).getTime();
53896         sequences = sequences.filter(function(image) {
53897           return new Date(image.properties.captured_at).getTime() >= fromTimestamp;
53898         });
53899       }
53900       if (toDate) {
53901         var toTimestamp = new Date(toDate).getTime();
53902         sequences = sequences.filter(function(image) {
53903           return new Date(image.properties.captured_at).getTime() <= toTimestamp;
53904         });
53905       }
53906       if (usernames) {
53907         sequences = sequences.filter(function(image) {
53908           return usernames.indexOf(image.properties.captured_by) !== -1;
53909         });
53910       }
53911       return sequences;
53912     }
53913     function update() {
53914       var viewer = context.container().select(".photoviewer");
53915       var selected = viewer.empty() ? void 0 : viewer.datum();
53916       var z2 = ~~context.map().zoom();
53917       var showMarkers = z2 >= minMarkerZoom;
53918       var showViewfields = z2 >= minViewfieldZoom2;
53919       var service = getService();
53920       var sequences = [];
53921       var images = [];
53922       if (context.photos().showsFlat()) {
53923         sequences = service ? service.sequences(projection2) : [];
53924         images = service && showMarkers ? service.images(projection2) : [];
53925         sequences = filterSequences(sequences);
53926         images = filterImages(images);
53927       }
53928       var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
53929         return d2.properties.key;
53930       });
53931       traces.exit().remove();
53932       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
53933       var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
53934         return d2.key;
53935       });
53936       groups.exit().remove();
53937       var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
53938       groupsEnter.append("g").attr("class", "viewfield-scale");
53939       var markers = groups.merge(groupsEnter).sort(function(a2, b2) {
53940         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
53941       }).attr("transform", transform2).select(".viewfield-scale");
53942       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
53943       var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
53944       viewfields.exit().remove();
53945       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z");
53946     }
53947     function drawImages(selection2) {
53948       var enabled = svgKartaviewImages.enabled, service = getService();
53949       layer = selection2.selectAll(".layer-kartaview").data(service ? [0] : []);
53950       layer.exit().remove();
53951       var layerEnter = layer.enter().append("g").attr("class", "layer-kartaview").style("display", enabled ? "block" : "none");
53952       layerEnter.append("g").attr("class", "sequences");
53953       layerEnter.append("g").attr("class", "markers");
53954       layer = layerEnter.merge(layer);
53955       if (enabled) {
53956         if (service && ~~context.map().zoom() >= minZoom5) {
53957           editOn();
53958           update();
53959           service.loadImages(projection2);
53960         } else {
53961           editOff();
53962         }
53963       }
53964     }
53965     drawImages.enabled = function(_2) {
53966       if (!arguments.length) return svgKartaviewImages.enabled;
53967       svgKartaviewImages.enabled = _2;
53968       if (svgKartaviewImages.enabled) {
53969         showLayer();
53970         context.photos().on("change.kartaview_images", update);
53971       } else {
53972         hideLayer();
53973         context.photos().on("change.kartaview_images", null);
53974       }
53975       dispatch14.call("change");
53976       return this;
53977     };
53978     drawImages.supported = function() {
53979       return !!getService();
53980     };
53981     drawImages.rendered = function(zoom) {
53982       return zoom >= minZoom5;
53983     };
53984     init2();
53985     return drawImages;
53986   }
53987
53988   // modules/svg/mapilio_images.js
53989   function svgMapilioImages(projection2, context, dispatch14) {
53990     const throttledRedraw = throttle_default(function() {
53991       dispatch14.call("change");
53992     }, 1e3);
53993     const minZoom5 = 12;
53994     let layer = select_default2(null);
53995     let _mapilio;
53996     const viewFieldZoomLevel = 18;
53997     function init2() {
53998       if (svgMapilioImages.initialized) return;
53999       svgMapilioImages.enabled = false;
54000       svgMapilioImages.initialized = true;
54001     }
54002     function getService() {
54003       if (services.mapilio && !_mapilio) {
54004         _mapilio = services.mapilio;
54005         _mapilio.event.on("loadedImages", throttledRedraw);
54006       } else if (!services.mapilio && _mapilio) {
54007         _mapilio = null;
54008       }
54009       return _mapilio;
54010     }
54011     function showLayer() {
54012       const service = getService();
54013       if (!service) return;
54014       editOn();
54015       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54016         dispatch14.call("change");
54017       });
54018     }
54019     function hideLayer() {
54020       throttledRedraw.cancel();
54021       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54022     }
54023     function transform2(d2) {
54024       let t2 = svgPointTransform(projection2)(d2);
54025       if (d2.heading) {
54026         t2 += " rotate(" + Math.floor(d2.heading) + ",0,0)";
54027       }
54028       return t2;
54029     }
54030     function editOn() {
54031       layer.style("display", "block");
54032     }
54033     function editOff() {
54034       layer.selectAll(".viewfield-group").remove();
54035       layer.style("display", "none");
54036     }
54037     function click(d3_event, image) {
54038       const service = getService();
54039       if (!service) return;
54040       service.ensureViewerLoaded(context, image.id).then(function() {
54041         service.selectImage(context, image.id).showViewer(context);
54042       });
54043       context.map().centerEase(image.loc);
54044     }
54045     function mouseover(d3_event, image) {
54046       const service = getService();
54047       if (service) service.setStyles(context, image);
54048     }
54049     function mouseout() {
54050       const service = getService();
54051       if (service) service.setStyles(context, null);
54052     }
54053     function update() {
54054       const z2 = ~~context.map().zoom();
54055       const showViewfields = z2 >= viewFieldZoomLevel;
54056       const service = getService();
54057       let sequences = service ? service.sequences(projection2) : [];
54058       let images = service ? service.images(projection2) : [];
54059       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54060         return d2.properties.id;
54061       });
54062       traces.exit().remove();
54063       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54064       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
54065         return d2.id;
54066       });
54067       groups.exit().remove();
54068       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54069       groupsEnter.append("g").attr("class", "viewfield-scale");
54070       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
54071         return b2.loc[1] - a2.loc[1];
54072       }).attr("transform", transform2).select(".viewfield-scale");
54073       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54074       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54075       viewfields.exit().remove();
54076       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54077       function viewfieldPath() {
54078         if (this.parentNode.__data__.isPano) {
54079           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54080         } else {
54081           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54082         }
54083       }
54084     }
54085     function drawImages(selection2) {
54086       const enabled = svgMapilioImages.enabled;
54087       const service = getService();
54088       layer = selection2.selectAll(".layer-mapilio").data(service ? [0] : []);
54089       layer.exit().remove();
54090       const layerEnter = layer.enter().append("g").attr("class", "layer-mapilio").style("display", enabled ? "block" : "none");
54091       layerEnter.append("g").attr("class", "sequences");
54092       layerEnter.append("g").attr("class", "markers");
54093       layer = layerEnter.merge(layer);
54094       if (enabled) {
54095         if (service && ~~context.map().zoom() >= minZoom5) {
54096           editOn();
54097           update();
54098           service.loadImages(projection2);
54099           service.loadLines(projection2);
54100         } else {
54101           editOff();
54102         }
54103       }
54104     }
54105     drawImages.enabled = function(_2) {
54106       if (!arguments.length) return svgMapilioImages.enabled;
54107       svgMapilioImages.enabled = _2;
54108       if (svgMapilioImages.enabled) {
54109         showLayer();
54110         context.photos().on("change.mapilio_images", update);
54111       } else {
54112         hideLayer();
54113         context.photos().on("change.mapilio_images", null);
54114       }
54115       dispatch14.call("change");
54116       return this;
54117     };
54118     drawImages.supported = function() {
54119       return !!getService();
54120     };
54121     drawImages.rendered = function(zoom) {
54122       return zoom >= minZoom5;
54123     };
54124     init2();
54125     return drawImages;
54126   }
54127
54128   // modules/svg/panoramax_images.js
54129   function svgPanoramaxImages(projection2, context, dispatch14) {
54130     const throttledRedraw = throttle_default(function() {
54131       dispatch14.call("change");
54132     }, 1e3);
54133     const imageMinZoom2 = 15;
54134     const lineMinZoom2 = 10;
54135     const viewFieldZoomLevel = 18;
54136     let layer = select_default2(null);
54137     let _panoramax;
54138     let _viewerYaw = 0;
54139     let _selectedSequence;
54140     let _activeUsernameFilter;
54141     let _activeIds;
54142     function init2() {
54143       if (svgPanoramaxImages.initialized) return;
54144       svgPanoramaxImages.enabled = false;
54145       svgPanoramaxImages.initialized = true;
54146     }
54147     function getService() {
54148       if (services.panoramax && !_panoramax) {
54149         _panoramax = services.panoramax;
54150         _panoramax.event.on("viewerChanged", viewerChanged).on("loadedLines", throttledRedraw).on("loadedImages", throttledRedraw);
54151       } else if (!services.panoramax && _panoramax) {
54152         _panoramax = null;
54153       }
54154       return _panoramax;
54155     }
54156     async function filterImages(images) {
54157       const showsPano = context.photos().showsPanoramic();
54158       const showsFlat = context.photos().showsFlat();
54159       const fromDate = context.photos().fromDate();
54160       const toDate = context.photos().toDate();
54161       const username = context.photos().usernames();
54162       const service = getService();
54163       if (!showsPano || !showsFlat) {
54164         images = images.filter(function(image) {
54165           if (image.isPano) return showsPano;
54166           return showsFlat;
54167         });
54168       }
54169       if (fromDate) {
54170         images = images.filter(function(image) {
54171           return new Date(image.capture_time).getTime() >= new Date(fromDate).getTime();
54172         });
54173       }
54174       if (toDate) {
54175         images = images.filter(function(image) {
54176           return new Date(image.capture_time).getTime() <= new Date(toDate).getTime();
54177         });
54178       }
54179       if (username && service) {
54180         if (_activeUsernameFilter !== username) {
54181           _activeUsernameFilter = username;
54182           const tempIds = await service.getUserIds(username);
54183           _activeIds = {};
54184           tempIds.forEach((id2) => {
54185             _activeIds[id2] = true;
54186           });
54187         }
54188         images = images.filter(function(image) {
54189           return _activeIds[image.account_id];
54190         });
54191       }
54192       return images;
54193     }
54194     async function filterSequences(sequences) {
54195       const showsPano = context.photos().showsPanoramic();
54196       const showsFlat = context.photos().showsFlat();
54197       const fromDate = context.photos().fromDate();
54198       const toDate = context.photos().toDate();
54199       const username = context.photos().usernames();
54200       const service = getService();
54201       if (!showsPano || !showsFlat) {
54202         sequences = sequences.filter(function(sequence) {
54203           if (sequence.properties.type === "equirectangular") return showsPano;
54204           return showsFlat;
54205         });
54206       }
54207       if (fromDate) {
54208         sequences = sequences.filter(function(sequence) {
54209           return new Date(sequence.properties.date).getTime() >= new Date(fromDate).getTime().toString();
54210         });
54211       }
54212       if (toDate) {
54213         sequences = sequences.filter(function(sequence) {
54214           return new Date(sequence.properties.date).getTime() <= new Date(toDate).getTime().toString();
54215         });
54216       }
54217       if (username && service) {
54218         if (_activeUsernameFilter !== username) {
54219           _activeUsernameFilter = username;
54220           const tempIds = await service.getUserIds(username);
54221           _activeIds = {};
54222           tempIds.forEach((id2) => {
54223             _activeIds[id2] = true;
54224           });
54225         }
54226         sequences = sequences.filter(function(sequence) {
54227           return _activeIds[sequence.properties.account_id];
54228         });
54229       }
54230       return sequences;
54231     }
54232     function showLayer() {
54233       const service = getService();
54234       if (!service) return;
54235       editOn();
54236       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54237         dispatch14.call("change");
54238       });
54239     }
54240     function hideLayer() {
54241       throttledRedraw.cancel();
54242       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54243     }
54244     function transform2(d2, selectedImageId) {
54245       let t2 = svgPointTransform(projection2)(d2);
54246       let rot = d2.heading;
54247       if (d2.id === selectedImageId) {
54248         rot += _viewerYaw;
54249       }
54250       if (rot) {
54251         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
54252       }
54253       return t2;
54254     }
54255     function editOn() {
54256       layer.style("display", "block");
54257     }
54258     function editOff() {
54259       layer.selectAll(".viewfield-group").remove();
54260       layer.style("display", "none");
54261     }
54262     function click(d3_event, image) {
54263       const service = getService();
54264       if (!service) return;
54265       if (image.sequence_id !== _selectedSequence) {
54266         _viewerYaw = 0;
54267       }
54268       _selectedSequence = image.sequence_id;
54269       service.ensureViewerLoaded(context).then(function() {
54270         service.selectImage(context, image.id).showViewer(context);
54271       });
54272       context.map().centerEase(image.loc);
54273     }
54274     function mouseover(d3_event, image) {
54275       const service = getService();
54276       if (service) service.setStyles(context, image);
54277     }
54278     function mouseout() {
54279       const service = getService();
54280       if (service) service.setStyles(context, null);
54281     }
54282     async function update() {
54283       var _a4;
54284       const zoom = ~~context.map().zoom();
54285       const showViewfields = zoom >= viewFieldZoomLevel;
54286       const service = getService();
54287       let sequences = service ? service.sequences(projection2, zoom) : [];
54288       let images = service && zoom >= imageMinZoom2 ? service.images(projection2) : [];
54289       images = await filterImages(images);
54290       sequences = await filterSequences(sequences, service);
54291       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54292         return d2.properties.id;
54293       });
54294       traces.exit().remove();
54295       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54296       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
54297         return d2.id;
54298       });
54299       groups.exit().remove();
54300       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54301       groupsEnter.append("g").attr("class", "viewfield-scale");
54302       const activeImageId = (_a4 = service.getActiveImage()) == null ? void 0 : _a4.id;
54303       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
54304         if (a2.id === activeImageId) return 1;
54305         if (b2.id === activeImageId) return -1;
54306         return a2.capture_time_parsed - b2.capture_time_parsed;
54307       }).attr("transform", (d2) => transform2(d2, activeImageId)).select(".viewfield-scale");
54308       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54309       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54310       viewfields.exit().remove();
54311       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54312       service.setStyles(context, null);
54313       function viewfieldPath() {
54314         if (this.parentNode.__data__.isPano) {
54315           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54316         } else {
54317           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54318         }
54319       }
54320     }
54321     function viewerChanged() {
54322       const service = getService();
54323       if (!service) return;
54324       const frame2 = service.photoFrame();
54325       if (!frame2) return;
54326       _viewerYaw = frame2.getYaw();
54327       if (context.map().isTransformed()) return;
54328       layer.selectAll(".viewfield-group.currentView").attr("transform", (d2) => transform2(d2, d2.id));
54329     }
54330     function drawImages(selection2) {
54331       const enabled = svgPanoramaxImages.enabled;
54332       const service = getService();
54333       layer = selection2.selectAll(".layer-panoramax").data(service ? [0] : []);
54334       layer.exit().remove();
54335       const layerEnter = layer.enter().append("g").attr("class", "layer-panoramax").style("display", enabled ? "block" : "none");
54336       layerEnter.append("g").attr("class", "sequences");
54337       layerEnter.append("g").attr("class", "markers");
54338       layer = layerEnter.merge(layer);
54339       if (enabled) {
54340         let zoom = ~~context.map().zoom();
54341         if (service) {
54342           if (zoom >= imageMinZoom2) {
54343             editOn();
54344             update();
54345             service.loadImages(projection2);
54346           } else if (zoom >= lineMinZoom2) {
54347             editOn();
54348             update();
54349             service.loadLines(projection2, zoom);
54350           } else {
54351             editOff();
54352           }
54353         } else {
54354           editOff();
54355         }
54356       }
54357     }
54358     drawImages.enabled = function(_2) {
54359       if (!arguments.length) return svgPanoramaxImages.enabled;
54360       svgPanoramaxImages.enabled = _2;
54361       if (svgPanoramaxImages.enabled) {
54362         showLayer();
54363         context.photos().on("change.panoramax_images", update);
54364       } else {
54365         hideLayer();
54366         context.photos().on("change.panoramax_images", null);
54367       }
54368       dispatch14.call("change");
54369       return this;
54370     };
54371     drawImages.supported = function() {
54372       return !!getService();
54373     };
54374     drawImages.rendered = function(zoom) {
54375       return zoom >= lineMinZoom2;
54376     };
54377     init2();
54378     return drawImages;
54379   }
54380
54381   // modules/svg/osm.js
54382   function svgOsm(projection2, context, dispatch14) {
54383     var enabled = true;
54384     function drawOsm(selection2) {
54385       selection2.selectAll(".layer-osm").data(["covered", "areas", "lines", "points", "labels"]).enter().append("g").attr("class", function(d2) {
54386         return "layer-osm " + d2;
54387       });
54388       selection2.selectAll(".layer-osm.points").selectAll(".points-group").data(["points", "midpoints", "vertices", "turns"]).enter().append("g").attr("class", function(d2) {
54389         return "points-group " + d2;
54390       });
54391     }
54392     function showLayer() {
54393       var layer = context.surface().selectAll(".data-layer.osm");
54394       layer.interrupt();
54395       layer.classed("disabled", false).style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() {
54396         dispatch14.call("change");
54397       });
54398     }
54399     function hideLayer() {
54400       var layer = context.surface().selectAll(".data-layer.osm");
54401       layer.interrupt();
54402       layer.transition().duration(250).style("opacity", 0).on("end interrupt", function() {
54403         layer.classed("disabled", true);
54404         dispatch14.call("change");
54405       });
54406     }
54407     drawOsm.enabled = function(val) {
54408       if (!arguments.length) return enabled;
54409       enabled = val;
54410       if (enabled) {
54411         showLayer();
54412       } else {
54413         hideLayer();
54414       }
54415       dispatch14.call("change");
54416       return this;
54417     };
54418     return drawOsm;
54419   }
54420
54421   // modules/svg/notes.js
54422   var hash = utilStringQs(window.location.hash);
54423   var _notesEnabled = !!hash.notes;
54424   var _osmService;
54425   function svgNotes(projection2, context, dispatch14) {
54426     if (!dispatch14) {
54427       dispatch14 = dispatch_default("change");
54428     }
54429     var throttledRedraw = throttle_default(function() {
54430       dispatch14.call("change");
54431     }, 1e3);
54432     var minZoom5 = 12;
54433     var touchLayer = select_default2(null);
54434     var drawLayer = select_default2(null);
54435     var _notesVisible = false;
54436     function markerPath(selection2, klass) {
54437       selection2.attr("class", klass).attr("transform", "translate(-8, -22)").attr("d", "m17.5,0l-15,0c-1.37,0 -2.5,1.12 -2.5,2.5l0,11.25c0,1.37 1.12,2.5 2.5,2.5l3.75,0l0,3.28c0,0.38 0.43,0.6 0.75,0.37l4.87,-3.65l5.62,0c1.37,0 2.5,-1.12 2.5,-2.5l0,-11.25c0,-1.37 -1.12,-2.5 -2.5,-2.5z");
54438     }
54439     function getService() {
54440       if (services.osm && !_osmService) {
54441         _osmService = services.osm;
54442         _osmService.on("loadedNotes", throttledRedraw);
54443       } else if (!services.osm && _osmService) {
54444         _osmService = null;
54445       }
54446       return _osmService;
54447     }
54448     function editOn() {
54449       if (!_notesVisible) {
54450         _notesVisible = true;
54451         drawLayer.style("display", "block");
54452       }
54453     }
54454     function editOff() {
54455       if (_notesVisible) {
54456         _notesVisible = false;
54457         drawLayer.style("display", "none");
54458         drawLayer.selectAll(".note").remove();
54459         touchLayer.selectAll(".note").remove();
54460       }
54461     }
54462     function layerOn() {
54463       editOn();
54464       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() {
54465         dispatch14.call("change");
54466       });
54467     }
54468     function layerOff() {
54469       throttledRedraw.cancel();
54470       drawLayer.interrupt();
54471       touchLayer.selectAll(".note").remove();
54472       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", function() {
54473         editOff();
54474         dispatch14.call("change");
54475       });
54476     }
54477     function updateMarkers() {
54478       if (!_notesVisible || !_notesEnabled) return;
54479       var service = getService();
54480       var selectedID = context.selectedNoteID();
54481       var data = service ? service.notes(projection2) : [];
54482       var getTransform = svgPointTransform(projection2);
54483       var notes = drawLayer.selectAll(".note").data(data, function(d2) {
54484         return d2.status + d2.id;
54485       });
54486       notes.exit().remove();
54487       var notesEnter = notes.enter().append("g").attr("class", function(d2) {
54488         return "note note-" + d2.id + " " + d2.status;
54489       }).classed("new", function(d2) {
54490         return d2.id < 0;
54491       });
54492       notesEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
54493       notesEnter.append("path").call(markerPath, "shadow");
54494       notesEnter.append("use").attr("class", "note-fill").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").attr("xlink:href", "#iD-icon-note");
54495       notesEnter.selectAll(".icon-annotation").data(function(d2) {
54496         return [d2];
54497       }).enter().append("use").attr("class", "icon-annotation").attr("width", "10px").attr("height", "10px").attr("x", "-3px").attr("y", "-19px").attr("xlink:href", function(d2) {
54498         if (d2.id < 0) return "#iD-icon-plus";
54499         if (d2.status === "open") return "#iD-icon-close";
54500         return "#iD-icon-apply";
54501       });
54502       notes.merge(notesEnter).sort(sortY).classed("selected", function(d2) {
54503         var mode = context.mode();
54504         var isMoving = mode && mode.id === "drag-note";
54505         return !isMoving && d2.id === selectedID;
54506       }).attr("transform", getTransform);
54507       if (touchLayer.empty()) return;
54508       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
54509       var targets = touchLayer.selectAll(".note").data(data, function(d2) {
54510         return d2.id;
54511       });
54512       targets.exit().remove();
54513       targets.enter().append("rect").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").merge(targets).sort(sortY).attr("class", function(d2) {
54514         var newClass = d2.id < 0 ? "new" : "";
54515         return "note target note-" + d2.id + " " + fillClass + newClass;
54516       }).attr("transform", getTransform);
54517       function sortY(a2, b2) {
54518         if (a2.id === selectedID) return 1;
54519         if (b2.id === selectedID) return -1;
54520         return b2.loc[1] - a2.loc[1];
54521       }
54522     }
54523     function drawNotes(selection2) {
54524       var service = getService();
54525       var surface = context.surface();
54526       if (surface && !surface.empty()) {
54527         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
54528       }
54529       drawLayer = selection2.selectAll(".layer-notes").data(service ? [0] : []);
54530       drawLayer.exit().remove();
54531       drawLayer = drawLayer.enter().append("g").attr("class", "layer-notes").style("display", _notesEnabled ? "block" : "none").merge(drawLayer);
54532       if (_notesEnabled) {
54533         if (service && ~~context.map().zoom() >= minZoom5) {
54534           editOn();
54535           service.loadNotes(projection2);
54536           updateMarkers();
54537         } else {
54538           editOff();
54539         }
54540       }
54541     }
54542     drawNotes.enabled = function(val) {
54543       if (!arguments.length) return _notesEnabled;
54544       _notesEnabled = val;
54545       if (_notesEnabled) {
54546         layerOn();
54547       } else {
54548         layerOff();
54549         if (context.selectedNoteID()) {
54550           context.enter(modeBrowse(context));
54551         }
54552       }
54553       dispatch14.call("change");
54554       return this;
54555     };
54556     return drawNotes;
54557   }
54558
54559   // modules/svg/touch.js
54560   function svgTouch() {
54561     function drawTouch(selection2) {
54562       selection2.selectAll(".layer-touch").data(["areas", "lines", "points", "turns", "markers"]).enter().append("g").attr("class", function(d2) {
54563         return "layer-touch " + d2;
54564       });
54565     }
54566     return drawTouch;
54567   }
54568
54569   // modules/util/dimensions.js
54570   function refresh(selection2, node) {
54571     var cr = node.getBoundingClientRect();
54572     var prop = [cr.width, cr.height];
54573     selection2.property("__dimensions__", prop);
54574     return prop;
54575   }
54576   function utilGetDimensions(selection2, force) {
54577     if (!selection2 || selection2.empty()) {
54578       return [0, 0];
54579     }
54580     var node = selection2.node(), cached = selection2.property("__dimensions__");
54581     return !cached || force ? refresh(selection2, node) : cached;
54582   }
54583   function utilSetDimensions(selection2, dimensions) {
54584     if (!selection2 || selection2.empty()) {
54585       return selection2;
54586     }
54587     var node = selection2.node();
54588     if (dimensions === null) {
54589       refresh(selection2, node);
54590       return selection2;
54591     }
54592     return selection2.property("__dimensions__", [dimensions[0], dimensions[1]]).attr("width", dimensions[0]).attr("height", dimensions[1]);
54593   }
54594
54595   // modules/svg/layers.js
54596   function svgLayers(projection2, context) {
54597     var dispatch14 = dispatch_default("change");
54598     var svg2 = select_default2(null);
54599     var _layers = [
54600       { id: "osm", layer: svgOsm(projection2, context, dispatch14) },
54601       { id: "notes", layer: svgNotes(projection2, context, dispatch14) },
54602       { id: "data", layer: svgData(projection2, context, dispatch14) },
54603       { id: "keepRight", layer: svgKeepRight(projection2, context, dispatch14) },
54604       { id: "osmose", layer: svgOsmose(projection2, context, dispatch14) },
54605       { id: "streetside", layer: svgStreetside(projection2, context, dispatch14) },
54606       { id: "mapillary", layer: svgMapillaryImages(projection2, context, dispatch14) },
54607       { id: "mapillary-position", layer: svgMapillaryPosition(projection2, context, dispatch14) },
54608       { id: "mapillary-map-features", layer: svgMapillaryMapFeatures(projection2, context, dispatch14) },
54609       { id: "mapillary-signs", layer: svgMapillarySigns(projection2, context, dispatch14) },
54610       { id: "kartaview", layer: svgKartaviewImages(projection2, context, dispatch14) },
54611       { id: "mapilio", layer: svgMapilioImages(projection2, context, dispatch14) },
54612       { id: "vegbilder", layer: svgVegbilder(projection2, context, dispatch14) },
54613       { id: "panoramax", layer: svgPanoramaxImages(projection2, context, dispatch14) },
54614       { id: "local-photos", layer: svgLocalPhotos(projection2, context, dispatch14) },
54615       { id: "debug", layer: svgDebug(projection2, context, dispatch14) },
54616       { id: "geolocate", layer: svgGeolocate(projection2, context, dispatch14) },
54617       { id: "touch", layer: svgTouch(projection2, context, dispatch14) }
54618     ];
54619     function drawLayers(selection2) {
54620       svg2 = selection2.selectAll(".surface").data([0]);
54621       svg2 = svg2.enter().append("svg").attr("class", "surface").merge(svg2);
54622       var defs = svg2.selectAll(".surface-defs").data([0]);
54623       defs.enter().append("defs").attr("class", "surface-defs");
54624       var groups = svg2.selectAll(".data-layer").data(_layers);
54625       groups.exit().remove();
54626       groups.enter().append("g").attr("class", function(d2) {
54627         return "data-layer " + d2.id;
54628       }).merge(groups).each(function(d2) {
54629         select_default2(this).call(d2.layer);
54630       });
54631     }
54632     drawLayers.all = function() {
54633       return _layers;
54634     };
54635     drawLayers.layer = function(id2) {
54636       var obj = _layers.find(function(o2) {
54637         return o2.id === id2;
54638       });
54639       return obj && obj.layer;
54640     };
54641     drawLayers.only = function(what) {
54642       var arr = [].concat(what);
54643       var all = _layers.map(function(layer) {
54644         return layer.id;
54645       });
54646       return drawLayers.remove(utilArrayDifference(all, arr));
54647     };
54648     drawLayers.remove = function(what) {
54649       var arr = [].concat(what);
54650       arr.forEach(function(id2) {
54651         _layers = _layers.filter(function(o2) {
54652           return o2.id !== id2;
54653         });
54654       });
54655       dispatch14.call("change");
54656       return this;
54657     };
54658     drawLayers.add = function(what) {
54659       var arr = [].concat(what);
54660       arr.forEach(function(obj) {
54661         if ("id" in obj && "layer" in obj) {
54662           _layers.push(obj);
54663         }
54664       });
54665       dispatch14.call("change");
54666       return this;
54667     };
54668     drawLayers.dimensions = function(val) {
54669       if (!arguments.length) return utilGetDimensions(svg2);
54670       utilSetDimensions(svg2, val);
54671       return this;
54672     };
54673     return utilRebind(drawLayers, dispatch14, "on");
54674   }
54675
54676   // modules/svg/lines.js
54677   var import_fast_deep_equal6 = __toESM(require_fast_deep_equal());
54678   function onewayArrowColour(tags) {
54679     if (tags.highway === "construction" && tags.bridge) return "white";
54680     if (tags.highway === "pedestrian" && tags.bridge) return "pink";
54681     if (tags.railway) return "black";
54682     if (tags.aeroway === "runway") return "pink";
54683     return "black";
54684   }
54685   function svgLines(projection2, context) {
54686     var detected = utilDetect();
54687     var highway_stack = {
54688       motorway: 0,
54689       motorway_link: 1,
54690       trunk: 2,
54691       trunk_link: 3,
54692       primary: 4,
54693       primary_link: 5,
54694       secondary: 6,
54695       tertiary: 7,
54696       unclassified: 8,
54697       residential: 9,
54698       service: 10,
54699       busway: 11,
54700       footway: 12
54701     };
54702     function drawTargets(selection2, graph, entities, filter2) {
54703       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
54704       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
54705       var getPath = svgPath(projection2).geojson;
54706       var activeID = context.activeID();
54707       var base = context.history().base();
54708       var data = { targets: [], nopes: [] };
54709       entities.forEach(function(way) {
54710         var features = svgSegmentWay(way, graph, activeID);
54711         data.targets.push.apply(data.targets, features.passive);
54712         data.nopes.push.apply(data.nopes, features.active);
54713       });
54714       var targetData = data.targets.filter(getPath);
54715       var targets = selection2.selectAll(".line.target-allowed").filter(function(d2) {
54716         return filter2(d2.properties.entity);
54717       }).data(targetData, function key(d2) {
54718         return d2.id;
54719       });
54720       targets.exit().remove();
54721       var segmentWasEdited = function(d2) {
54722         var wayID = d2.properties.entity.id;
54723         if (!base.entities[wayID] || !(0, import_fast_deep_equal6.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) {
54724           return false;
54725         }
54726         return d2.properties.nodes.some(function(n3) {
54727           return !base.entities[n3.id] || !(0, import_fast_deep_equal6.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc);
54728         });
54729       };
54730       targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) {
54731         return "way line target target-allowed " + targetClass + d2.id;
54732       }).classed("segment-edited", segmentWasEdited);
54733       var nopeData = data.nopes.filter(getPath);
54734       var nopes = selection2.selectAll(".line.target-nope").filter(function(d2) {
54735         return filter2(d2.properties.entity);
54736       }).data(nopeData, function key(d2) {
54737         return d2.id;
54738       });
54739       nopes.exit().remove();
54740       nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) {
54741         return "way line target target-nope " + nopeClass + d2.id;
54742       }).classed("segment-edited", segmentWasEdited);
54743     }
54744     function drawLines(selection2, graph, entities, filter2) {
54745       var base = context.history().base();
54746       function waystack(a2, b2) {
54747         var selected = context.selectedIDs();
54748         var scoreA = selected.indexOf(a2.id) !== -1 ? 20 : 0;
54749         var scoreB = selected.indexOf(b2.id) !== -1 ? 20 : 0;
54750         if (a2.tags.highway) {
54751           scoreA -= highway_stack[a2.tags.highway];
54752         }
54753         if (b2.tags.highway) {
54754           scoreB -= highway_stack[b2.tags.highway];
54755         }
54756         return scoreA - scoreB;
54757       }
54758       function drawLineGroup(selection3, klass, isSelected) {
54759         var mode = context.mode();
54760         var isDrawing = mode && /^draw/.test(mode.id);
54761         var selectedClass = !isDrawing && isSelected ? "selected " : "";
54762         var lines = selection3.selectAll("path").filter(filter2).data(getPathData(isSelected), osmEntity.key);
54763         lines.exit().remove();
54764         lines.enter().append("path").attr("class", function(d2) {
54765           var prefix = "way line";
54766           if (!d2.hasInterestingTags()) {
54767             var parentRelations = graph.parentRelations(d2);
54768             var parentMultipolygons = parentRelations.filter(function(relation) {
54769               return relation.isMultipolygon();
54770             });
54771             if (parentMultipolygons.length > 0 && // and only multipolygon relations
54772             parentRelations.length === parentMultipolygons.length) {
54773               prefix = "relation area";
54774             }
54775           }
54776           var oldMPClass = oldMultiPolygonOuters[d2.id] ? "old-multipolygon " : "";
54777           return prefix + " " + klass + " " + selectedClass + oldMPClass + d2.id;
54778         }).classed("added", function(d2) {
54779           return !base.entities[d2.id];
54780         }).classed("geometry-edited", function(d2) {
54781           return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal6.default)(graph.entities[d2.id].nodes, base.entities[d2.id].nodes);
54782         }).classed("retagged", function(d2) {
54783           return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal6.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
54784         }).call(svgTagClasses()).merge(lines).sort(waystack).attr("d", getPath).call(svgTagClasses().tags(svgRelationMemberTags(graph)));
54785         return selection3;
54786       }
54787       function getPathData(isSelected) {
54788         return function() {
54789           var layer = this.parentNode.__data__;
54790           var data = pathdata[layer] || [];
54791           return data.filter(function(d2) {
54792             if (isSelected) {
54793               return context.selectedIDs().indexOf(d2.id) !== -1;
54794             } else {
54795               return context.selectedIDs().indexOf(d2.id) === -1;
54796             }
54797           });
54798         };
54799       }
54800       function addMarkers(layergroup, pathclass, groupclass, groupdata, marker) {
54801         var markergroup = layergroup.selectAll("g." + groupclass).data([pathclass]);
54802         markergroup = markergroup.enter().append("g").attr("class", groupclass).merge(markergroup);
54803         var markers = markergroup.selectAll("path").filter(filter2).data(
54804           function data() {
54805             return groupdata[this.parentNode.__data__] || [];
54806           },
54807           function key(d2) {
54808             return [d2.id, d2.index];
54809           }
54810         );
54811         markers.exit().remove();
54812         markers = markers.enter().append("path").attr("class", pathclass).merge(markers).attr("marker-mid", marker).attr("d", function(d2) {
54813           return d2.d;
54814         });
54815         if (detected.ie) {
54816           markers.each(function() {
54817             this.parentNode.insertBefore(this, this);
54818           });
54819         }
54820       }
54821       var getPath = svgPath(projection2, graph);
54822       var ways = [];
54823       var onewaydata = {};
54824       var sideddata = {};
54825       var oldMultiPolygonOuters = {};
54826       for (var i3 = 0; i3 < entities.length; i3++) {
54827         var entity = entities[i3];
54828         if (entity.geometry(graph) === "line" || entity.geometry(graph) === "area" && entity.sidednessIdentifier && entity.sidednessIdentifier() === "coastline") {
54829           ways.push(entity);
54830         }
54831       }
54832       ways = ways.filter(getPath);
54833       const pathdata = utilArrayGroupBy(ways, (way) => Math.trunc(way.layer()));
54834       Object.keys(pathdata).forEach(function(k2) {
54835         var v2 = pathdata[k2];
54836         var onewayArr = v2.filter(function(d2) {
54837           return d2.isOneWay();
54838         });
54839         var onewaySegments = svgMarkerSegments(
54840           projection2,
54841           graph,
54842           35,
54843           function shouldReverse(entity2) {
54844             return entity2.tags.oneway === "-1" || entity2.tags.conveying === "backward";
54845           },
54846           function bothDirections(entity2) {
54847             return entity2.tags.oneway === "alternating" || entity2.tags.oneway === "reversible" || entity2.tags.conveying === "reversible";
54848           }
54849         );
54850         onewaydata[k2] = utilArrayFlatten(onewayArr.map(onewaySegments));
54851         var sidedArr = v2.filter(function(d2) {
54852           return d2.isSided();
54853         });
54854         var sidedSegments = svgMarkerSegments(
54855           projection2,
54856           graph,
54857           30,
54858           function shouldReverse() {
54859             return false;
54860           },
54861           function bothDirections() {
54862             return false;
54863           }
54864         );
54865         sideddata[k2] = utilArrayFlatten(sidedArr.map(sidedSegments));
54866       });
54867       var covered = selection2.selectAll(".layer-osm.covered");
54868       var uncovered = selection2.selectAll(".layer-osm.lines");
54869       var touchLayer = selection2.selectAll(".layer-touch.lines");
54870       [covered, uncovered].forEach(function(selection3) {
54871         var range3 = selection3 === covered ? range(-10, 0) : range(0, 11);
54872         var layergroup = selection3.selectAll("g.layergroup").data(range3);
54873         layergroup = layergroup.enter().append("g").attr("class", function(d2) {
54874           return "layergroup layer" + String(d2);
54875         }).merge(layergroup);
54876         layergroup.selectAll("g.linegroup").data(["shadow", "casing", "stroke", "shadow-highlighted", "casing-highlighted", "stroke-highlighted"]).enter().append("g").attr("class", function(d2) {
54877           return "linegroup line-" + d2;
54878         });
54879         layergroup.selectAll("g.line-shadow").call(drawLineGroup, "shadow", false);
54880         layergroup.selectAll("g.line-casing").call(drawLineGroup, "casing", false);
54881         layergroup.selectAll("g.line-stroke").call(drawLineGroup, "stroke", false);
54882         layergroup.selectAll("g.line-shadow-highlighted").call(drawLineGroup, "shadow", true);
54883         layergroup.selectAll("g.line-casing-highlighted").call(drawLineGroup, "casing", true);
54884         layergroup.selectAll("g.line-stroke-highlighted").call(drawLineGroup, "stroke", true);
54885         addMarkers(layergroup, "oneway", "onewaygroup", onewaydata, (d2) => {
54886           const category = onewayArrowColour(graph.entity(d2.id).tags);
54887           return "url(#ideditor-oneway-marker-".concat(category, ")");
54888         });
54889         addMarkers(
54890           layergroup,
54891           "sided",
54892           "sidedgroup",
54893           sideddata,
54894           function marker(d2) {
54895             var category = graph.entity(d2.id).sidednessIdentifier();
54896             return "url(#ideditor-sided-marker-" + category + ")";
54897           }
54898         );
54899       });
54900       touchLayer.call(drawTargets, graph, ways, filter2);
54901     }
54902     return drawLines;
54903   }
54904
54905   // modules/svg/midpoints.js
54906   function svgMidpoints(projection2, context) {
54907     var targetRadius = 8;
54908     function drawTargets(selection2, graph, entities, filter2) {
54909       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
54910       var getTransform = svgPointTransform(projection2).geojson;
54911       var data = entities.map(function(midpoint) {
54912         return {
54913           type: "Feature",
54914           id: midpoint.id,
54915           properties: {
54916             target: true,
54917             entity: midpoint
54918           },
54919           geometry: {
54920             type: "Point",
54921             coordinates: midpoint.loc
54922           }
54923         };
54924       });
54925       var targets = selection2.selectAll(".midpoint.target").filter(function(d2) {
54926         return filter2(d2.properties.entity);
54927       }).data(data, function key(d2) {
54928         return d2.id;
54929       });
54930       targets.exit().remove();
54931       targets.enter().append("circle").attr("r", targetRadius).merge(targets).attr("class", function(d2) {
54932         return "node midpoint target " + fillClass + d2.id;
54933       }).attr("transform", getTransform);
54934     }
54935     function drawMidpoints(selection2, graph, entities, filter2, extent) {
54936       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.midpoints");
54937       var touchLayer = selection2.selectAll(".layer-touch.points");
54938       var mode = context.mode();
54939       if (mode && mode.id !== "select" || !context.map().withinEditableZoom()) {
54940         drawLayer.selectAll(".midpoint").remove();
54941         touchLayer.selectAll(".midpoint.target").remove();
54942         return;
54943       }
54944       var poly = extent.polygon();
54945       var midpoints = {};
54946       for (var i3 = 0; i3 < entities.length; i3++) {
54947         var entity = entities[i3];
54948         if (entity.type !== "way") continue;
54949         if (!filter2(entity)) continue;
54950         if (context.selectedIDs().indexOf(entity.id) < 0) continue;
54951         var nodes = graph.childNodes(entity);
54952         for (var j2 = 0; j2 < nodes.length - 1; j2++) {
54953           var a2 = nodes[j2];
54954           var b2 = nodes[j2 + 1];
54955           var id2 = [a2.id, b2.id].sort().join("-");
54956           if (midpoints[id2]) {
54957             midpoints[id2].parents.push(entity);
54958           } else if (geoVecLength(projection2(a2.loc), projection2(b2.loc)) > 40) {
54959             var point = geoVecInterp(a2.loc, b2.loc, 0.5);
54960             var loc = null;
54961             if (extent.intersects(point)) {
54962               loc = point;
54963             } else {
54964               for (var k2 = 0; k2 < 4; k2++) {
54965                 point = geoLineIntersection([a2.loc, b2.loc], [poly[k2], poly[k2 + 1]]);
54966                 if (point && geoVecLength(projection2(a2.loc), projection2(point)) > 20 && geoVecLength(projection2(b2.loc), projection2(point)) > 20) {
54967                   loc = point;
54968                   break;
54969                 }
54970               }
54971             }
54972             if (loc) {
54973               midpoints[id2] = {
54974                 type: "midpoint",
54975                 id: id2,
54976                 loc,
54977                 edge: [a2.id, b2.id],
54978                 parents: [entity]
54979               };
54980             }
54981           }
54982         }
54983       }
54984       function midpointFilter(d2) {
54985         if (midpoints[d2.id]) return true;
54986         for (var i4 = 0; i4 < d2.parents.length; i4++) {
54987           if (filter2(d2.parents[i4])) {
54988             return true;
54989           }
54990         }
54991         return false;
54992       }
54993       var groups = drawLayer.selectAll(".midpoint").filter(midpointFilter).data(Object.values(midpoints), function(d2) {
54994         return d2.id;
54995       });
54996       groups.exit().remove();
54997       var enter = groups.enter().insert("g", ":first-child").attr("class", "midpoint");
54998       enter.append("polygon").attr("points", "-6,8 10,0 -6,-8").attr("class", "shadow");
54999       enter.append("polygon").attr("points", "-3,4 5,0 -3,-4").attr("class", "fill");
55000       groups = groups.merge(enter).attr("transform", function(d2) {
55001         var translate = svgPointTransform(projection2);
55002         var a3 = graph.entity(d2.edge[0]);
55003         var b3 = graph.entity(d2.edge[1]);
55004         var angle2 = geoAngle(a3, b3, projection2) * (180 / Math.PI);
55005         return translate(d2) + " rotate(" + angle2 + ")";
55006       }).call(svgTagClasses().tags(
55007         function(d2) {
55008           return d2.parents[0].tags;
55009         }
55010       ));
55011       groups.select("polygon.shadow");
55012       groups.select("polygon.fill");
55013       touchLayer.call(drawTargets, graph, Object.values(midpoints), midpointFilter);
55014     }
55015     return drawMidpoints;
55016   }
55017
55018   // modules/svg/points.js
55019   var import_fast_deep_equal7 = __toESM(require_fast_deep_equal());
55020   function svgPoints(projection2, context) {
55021     function markerPath(selection2, klass) {
55022       selection2.attr("class", klass).attr("transform", "translate(-8, -23)").attr("d", "M 17,8 C 17,13 11,21 8.5,23.5 C 6,21 0,13 0,8 C 0,4 4,-0.5 8.5,-0.5 C 13,-0.5 17,4 17,8 z");
55023     }
55024     function sortY(a2, b2) {
55025       return b2.loc[1] - a2.loc[1];
55026     }
55027     function fastEntityKey(d2) {
55028       var mode = context.mode();
55029       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
55030       return isMoving ? d2.id : osmEntity.key(d2);
55031     }
55032     function drawTargets(selection2, graph, entities, filter2) {
55033       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
55034       var getTransform = svgPointTransform(projection2).geojson;
55035       var activeID = context.activeID();
55036       var data = [];
55037       entities.forEach(function(node) {
55038         if (activeID === node.id) return;
55039         data.push({
55040           type: "Feature",
55041           id: node.id,
55042           properties: {
55043             target: true,
55044             entity: node
55045           },
55046           geometry: node.asGeoJSON()
55047         });
55048       });
55049       var targets = selection2.selectAll(".point.target").filter(function(d2) {
55050         return filter2(d2.properties.entity);
55051       }).data(data, function key(d2) {
55052         return d2.id;
55053       });
55054       targets.exit().remove();
55055       targets.enter().append("rect").attr("x", -10).attr("y", -26).attr("width", 20).attr("height", 30).merge(targets).attr("class", function(d2) {
55056         return "node point target " + fillClass + d2.id;
55057       }).attr("transform", getTransform);
55058     }
55059     function drawPoints(selection2, graph, entities, filter2) {
55060       var wireframe = context.surface().classed("fill-wireframe");
55061       var zoom = geoScaleToZoom(projection2.scale());
55062       var base = context.history().base();
55063       function renderAsPoint(entity) {
55064         return entity.geometry(graph) === "point" && !(zoom >= 18 && entity.directions(graph, projection2).length);
55065       }
55066       var points = wireframe ? [] : entities.filter(renderAsPoint);
55067       points.sort(sortY);
55068       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.points");
55069       var touchLayer = selection2.selectAll(".layer-touch.points");
55070       var groups = drawLayer.selectAll("g.point").filter(filter2).data(points, fastEntityKey);
55071       groups.exit().remove();
55072       var enter = groups.enter().append("g").attr("class", function(d2) {
55073         return "node point " + d2.id;
55074       }).order();
55075       enter.append("path").call(markerPath, "shadow");
55076       enter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
55077       enter.append("path").call(markerPath, "stroke");
55078       enter.append("use").attr("transform", "translate(-5.5, -20)").attr("class", "icon").attr("width", "12px").attr("height", "12px");
55079       groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("added", function(d2) {
55080         return !base.entities[d2.id];
55081       }).classed("moved", function(d2) {
55082         return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc);
55083       }).classed("retagged", function(d2) {
55084         return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
55085       }).call(svgTagClasses());
55086       groups.select(".shadow");
55087       groups.select(".stroke");
55088       groups.select(".icon").attr("xlink:href", function(entity) {
55089         var preset = _mainPresetIndex.match(entity, graph);
55090         var picon = preset && preset.icon;
55091         return picon ? "#" + picon : "";
55092       });
55093       touchLayer.call(drawTargets, graph, points, filter2);
55094     }
55095     return drawPoints;
55096   }
55097
55098   // modules/svg/turns.js
55099   function svgTurns(projection2, context) {
55100     function icon2(turn) {
55101       var u2 = turn.u ? "-u" : "";
55102       if (turn.no) return "#iD-turn-no" + u2;
55103       if (turn.only) return "#iD-turn-only" + u2;
55104       return "#iD-turn-yes" + u2;
55105     }
55106     function drawTurns(selection2, graph, turns) {
55107       function turnTransform(d2) {
55108         var pxRadius = 50;
55109         var toWay = graph.entity(d2.to.way);
55110         var toPoints = graph.childNodes(toWay).map(function(n3) {
55111           return n3.loc;
55112         }).map(projection2);
55113         var toLength = geoPathLength(toPoints);
55114         var mid = toLength / 2;
55115         var toNode = graph.entity(d2.to.node);
55116         var toVertex = graph.entity(d2.to.vertex);
55117         var a2 = geoAngle(toVertex, toNode, projection2);
55118         var o2 = projection2(toVertex.loc);
55119         var r2 = d2.u ? 0 : !toWay.__via ? pxRadius : Math.min(mid, pxRadius);
55120         return "translate(" + (r2 * Math.cos(a2) + o2[0]) + "," + (r2 * Math.sin(a2) + o2[1]) + ") rotate(" + a2 * 180 / Math.PI + ")";
55121       }
55122       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.turns");
55123       var touchLayer = selection2.selectAll(".layer-touch.turns");
55124       var groups = drawLayer.selectAll("g.turn").data(turns, function(d2) {
55125         return d2.key;
55126       });
55127       groups.exit().remove();
55128       var groupsEnter = groups.enter().append("g").attr("class", function(d2) {
55129         return "turn " + d2.key;
55130       });
55131       var turnsEnter = groupsEnter.filter(function(d2) {
55132         return !d2.u;
55133       });
55134       turnsEnter.append("rect").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
55135       turnsEnter.append("use").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
55136       var uEnter = groupsEnter.filter(function(d2) {
55137         return d2.u;
55138       });
55139       uEnter.append("circle").attr("r", "16");
55140       uEnter.append("use").attr("transform", "translate(-16, -16)").attr("width", "32").attr("height", "32");
55141       groups = groups.merge(groupsEnter).attr("opacity", function(d2) {
55142         return d2.direct === false ? "0.7" : null;
55143       }).attr("transform", turnTransform);
55144       groups.select("use").attr("xlink:href", icon2);
55145       groups.select("rect");
55146       groups.select("circle");
55147       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
55148       groups = touchLayer.selectAll("g.turn").data(turns, function(d2) {
55149         return d2.key;
55150       });
55151       groups.exit().remove();
55152       groupsEnter = groups.enter().append("g").attr("class", function(d2) {
55153         return "turn " + d2.key;
55154       });
55155       turnsEnter = groupsEnter.filter(function(d2) {
55156         return !d2.u;
55157       });
55158       turnsEnter.append("rect").attr("class", "target " + fillClass).attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
55159       uEnter = groupsEnter.filter(function(d2) {
55160         return d2.u;
55161       });
55162       uEnter.append("circle").attr("class", "target " + fillClass).attr("r", "16");
55163       groups = groups.merge(groupsEnter).attr("transform", turnTransform);
55164       groups.select("rect");
55165       groups.select("circle");
55166       return this;
55167     }
55168     return drawTurns;
55169   }
55170
55171   // modules/svg/vertices.js
55172   var import_fast_deep_equal8 = __toESM(require_fast_deep_equal());
55173   function svgVertices(projection2, context) {
55174     var radiuses = {
55175       //       z16-, z17,   z18+,  w/icon
55176       shadow: [6, 7.5, 7.5, 12],
55177       stroke: [2.5, 3.5, 3.5, 8],
55178       fill: [1, 1.5, 1.5, 1.5]
55179     };
55180     var _currHoverTarget;
55181     var _currPersistent = {};
55182     var _currHover = {};
55183     var _prevHover = {};
55184     var _currSelected = {};
55185     var _prevSelected = {};
55186     var _radii = {};
55187     function sortY(a2, b2) {
55188       return b2.loc[1] - a2.loc[1];
55189     }
55190     function fastEntityKey(d2) {
55191       var mode = context.mode();
55192       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
55193       return isMoving ? d2.id : osmEntity.key(d2);
55194     }
55195     function draw(selection2, graph, vertices, sets2, filter2) {
55196       sets2 = sets2 || { selected: {}, important: {}, hovered: {} };
55197       var icons = {};
55198       var directions = {};
55199       var wireframe = context.surface().classed("fill-wireframe");
55200       var zoom = geoScaleToZoom(projection2.scale());
55201       var z2 = zoom < 17 ? 0 : zoom < 18 ? 1 : 2;
55202       var activeID = context.activeID();
55203       var base = context.history().base();
55204       function getIcon(d2) {
55205         var entity = graph.entity(d2.id);
55206         if (entity.id in icons) return icons[entity.id];
55207         icons[entity.id] = entity.hasInterestingTags() && _mainPresetIndex.match(entity, graph).icon;
55208         return icons[entity.id];
55209       }
55210       function getDirections(entity) {
55211         if (entity.id in directions) return directions[entity.id];
55212         var angles = entity.directions(graph, projection2);
55213         directions[entity.id] = angles.length ? angles : false;
55214         return angles;
55215       }
55216       function updateAttributes(selection3) {
55217         ["shadow", "stroke", "fill"].forEach(function(klass) {
55218           var rads = radiuses[klass];
55219           selection3.selectAll("." + klass).each(function(entity) {
55220             var i3 = z2 && getIcon(entity);
55221             var r2 = rads[i3 ? 3 : z2];
55222             if (entity.id !== activeID && entity.isEndpoint(graph) && !entity.isConnected(graph)) {
55223               r2 += 1.5;
55224             }
55225             if (klass === "shadow") {
55226               _radii[entity.id] = r2;
55227             }
55228             select_default2(this).attr("r", r2).attr("visibility", i3 && klass === "fill" ? "hidden" : null);
55229           });
55230         });
55231       }
55232       vertices.sort(sortY);
55233       var groups = selection2.selectAll("g.vertex").filter(filter2).data(vertices, fastEntityKey);
55234       groups.exit().remove();
55235       var enter = groups.enter().append("g").attr("class", function(d2) {
55236         return "node vertex " + d2.id;
55237       }).order();
55238       enter.append("circle").attr("class", "shadow");
55239       enter.append("circle").attr("class", "stroke");
55240       enter.filter(function(d2) {
55241         return d2.hasInterestingTags();
55242       }).append("circle").attr("class", "fill");
55243       groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("sibling", function(d2) {
55244         return d2.id in sets2.selected;
55245       }).classed("shared", function(d2) {
55246         return graph.isShared(d2);
55247       }).classed("endpoint", function(d2) {
55248         return d2.isEndpoint(graph);
55249       }).classed("added", function(d2) {
55250         return !base.entities[d2.id];
55251       }).classed("moved", function(d2) {
55252         return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc);
55253       }).classed("retagged", function(d2) {
55254         return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
55255       }).call(svgTagClasses()).call(updateAttributes);
55256       var iconUse = groups.selectAll(".icon").data(function data(d2) {
55257         return zoom >= 17 && getIcon(d2) ? [d2] : [];
55258       }, fastEntityKey);
55259       iconUse.exit().remove();
55260       iconUse.enter().append("use").attr("class", "icon").attr("width", "12px").attr("height", "12px").attr("transform", "translate(-6, -6)").attr("xlink:href", function(d2) {
55261         var picon = getIcon(d2);
55262         return picon ? "#" + picon : "";
55263       });
55264       var dgroups = groups.selectAll(".viewfieldgroup").data(function data(d2) {
55265         return zoom >= 18 && getDirections(d2) ? [d2] : [];
55266       }, fastEntityKey);
55267       dgroups.exit().remove();
55268       dgroups = dgroups.enter().insert("g", ".shadow").attr("class", "viewfieldgroup").merge(dgroups);
55269       var viewfields = dgroups.selectAll(".viewfield").data(getDirections, function key(d2) {
55270         return osmEntity.key(d2);
55271       });
55272       viewfields.exit().remove();
55273       viewfields.enter().append("path").attr("class", "viewfield").attr("d", "M0,0H0").merge(viewfields).attr("marker-start", "url(#ideditor-viewfield-marker" + (wireframe ? "-wireframe" : "") + ")").attr("transform", function(d2) {
55274         return "rotate(" + d2 + ")";
55275       });
55276     }
55277     function drawTargets(selection2, graph, entities, filter2) {
55278       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
55279       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
55280       var getTransform = svgPointTransform(projection2).geojson;
55281       var activeID = context.activeID();
55282       var data = { targets: [], nopes: [] };
55283       entities.forEach(function(node) {
55284         if (activeID === node.id) return;
55285         var vertexType = svgPassiveVertex(node, graph, activeID);
55286         if (vertexType !== 0) {
55287           data.targets.push({
55288             type: "Feature",
55289             id: node.id,
55290             properties: {
55291               target: true,
55292               entity: node
55293             },
55294             geometry: node.asGeoJSON()
55295           });
55296         } else {
55297           data.nopes.push({
55298             type: "Feature",
55299             id: node.id + "-nope",
55300             properties: {
55301               nope: true,
55302               target: true,
55303               entity: node
55304             },
55305             geometry: node.asGeoJSON()
55306           });
55307         }
55308       });
55309       var targets = selection2.selectAll(".vertex.target-allowed").filter(function(d2) {
55310         return filter2(d2.properties.entity);
55311       }).data(data.targets, function key(d2) {
55312         return d2.id;
55313       });
55314       targets.exit().remove();
55315       targets.enter().append("circle").attr("r", function(d2) {
55316         return _radii[d2.id] || radiuses.shadow[3];
55317       }).merge(targets).attr("class", function(d2) {
55318         return "node vertex target target-allowed " + targetClass + d2.id;
55319       }).attr("transform", getTransform);
55320       var nopes = selection2.selectAll(".vertex.target-nope").filter(function(d2) {
55321         return filter2(d2.properties.entity);
55322       }).data(data.nopes, function key(d2) {
55323         return d2.id;
55324       });
55325       nopes.exit().remove();
55326       nopes.enter().append("circle").attr("r", function(d2) {
55327         return _radii[d2.properties.entity.id] || radiuses.shadow[3];
55328       }).merge(nopes).attr("class", function(d2) {
55329         return "node vertex target target-nope " + nopeClass + d2.id;
55330       }).attr("transform", getTransform);
55331     }
55332     function renderAsVertex(entity, graph, wireframe, zoom) {
55333       var geometry = entity.geometry(graph);
55334       return geometry === "vertex" || geometry === "point" && (wireframe || zoom >= 18 && entity.directions(graph, projection2).length);
55335     }
55336     function isEditedNode(node, base, head) {
55337       var baseNode = base.entities[node.id];
55338       var headNode = head.entities[node.id];
55339       return !headNode || !baseNode || !(0, import_fast_deep_equal8.default)(headNode.tags, baseNode.tags) || !(0, import_fast_deep_equal8.default)(headNode.loc, baseNode.loc);
55340     }
55341     function getSiblingAndChildVertices(ids, graph, wireframe, zoom) {
55342       var results = {};
55343       var seenIds = {};
55344       function addChildVertices(entity) {
55345         if (seenIds[entity.id]) return;
55346         seenIds[entity.id] = true;
55347         var geometry = entity.geometry(graph);
55348         if (!context.features().isHiddenFeature(entity, graph, geometry)) {
55349           var i3;
55350           if (entity.type === "way") {
55351             for (i3 = 0; i3 < entity.nodes.length; i3++) {
55352               var child = graph.hasEntity(entity.nodes[i3]);
55353               if (child) {
55354                 addChildVertices(child);
55355               }
55356             }
55357           } else if (entity.type === "relation") {
55358             for (i3 = 0; i3 < entity.members.length; i3++) {
55359               var member = graph.hasEntity(entity.members[i3].id);
55360               if (member) {
55361                 addChildVertices(member);
55362               }
55363             }
55364           } else if (renderAsVertex(entity, graph, wireframe, zoom)) {
55365             results[entity.id] = entity;
55366           }
55367         }
55368       }
55369       ids.forEach(function(id2) {
55370         var entity = graph.hasEntity(id2);
55371         if (!entity) return;
55372         if (entity.type === "node") {
55373           if (renderAsVertex(entity, graph, wireframe, zoom)) {
55374             results[entity.id] = entity;
55375             graph.parentWays(entity).forEach(function(entity2) {
55376               addChildVertices(entity2);
55377             });
55378           }
55379         } else {
55380           addChildVertices(entity);
55381         }
55382       });
55383       return results;
55384     }
55385     function drawVertices(selection2, graph, entities, filter2, extent, fullRedraw) {
55386       var wireframe = context.surface().classed("fill-wireframe");
55387       var visualDiff = context.surface().classed("highlight-edited");
55388       var zoom = geoScaleToZoom(projection2.scale());
55389       var mode = context.mode();
55390       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
55391       var base = context.history().base();
55392       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.vertices");
55393       var touchLayer = selection2.selectAll(".layer-touch.points");
55394       if (fullRedraw) {
55395         _currPersistent = {};
55396         _radii = {};
55397       }
55398       for (var i3 = 0; i3 < entities.length; i3++) {
55399         var entity = entities[i3];
55400         var geometry = entity.geometry(graph);
55401         var keep = false;
55402         if (geometry === "point" && renderAsVertex(entity, graph, wireframe, zoom)) {
55403           _currPersistent[entity.id] = entity;
55404           keep = true;
55405         } else if (geometry === "vertex" && (entity.hasInterestingTags() || entity.isEndpoint(graph) || entity.isConnected(graph) || visualDiff && isEditedNode(entity, base, graph))) {
55406           _currPersistent[entity.id] = entity;
55407           keep = true;
55408         }
55409         if (!keep && !fullRedraw) {
55410           delete _currPersistent[entity.id];
55411         }
55412       }
55413       var sets2 = {
55414         persistent: _currPersistent,
55415         // persistent = important vertices (render always)
55416         selected: _currSelected,
55417         // selected + siblings of selected (render always)
55418         hovered: _currHover
55419         // hovered + siblings of hovered (render only in draw modes)
55420       };
55421       var all = Object.assign({}, isMoving ? _currHover : {}, _currSelected, _currPersistent);
55422       var filterRendered = function(d2) {
55423         return d2.id in _currPersistent || d2.id in _currSelected || d2.id in _currHover || filter2(d2);
55424       };
55425       drawLayer.call(draw, graph, currentVisible(all), sets2, filterRendered);
55426       var filterTouch = function(d2) {
55427         return isMoving ? true : filterRendered(d2);
55428       };
55429       touchLayer.call(drawTargets, graph, currentVisible(all), filterTouch);
55430       function currentVisible(which) {
55431         return Object.keys(which).map(graph.hasEntity, graph).filter(function(entity2) {
55432           return entity2 && entity2.intersects(extent, graph);
55433         });
55434       }
55435     }
55436     drawVertices.drawSelected = function(selection2, graph, extent) {
55437       var wireframe = context.surface().classed("fill-wireframe");
55438       var zoom = geoScaleToZoom(projection2.scale());
55439       _prevSelected = _currSelected || {};
55440       if (context.map().isInWideSelection()) {
55441         _currSelected = {};
55442         context.selectedIDs().forEach(function(id2) {
55443           var entity = graph.hasEntity(id2);
55444           if (!entity) return;
55445           if (entity.type === "node") {
55446             if (renderAsVertex(entity, graph, wireframe, zoom)) {
55447               _currSelected[entity.id] = entity;
55448             }
55449           }
55450         });
55451       } else {
55452         _currSelected = getSiblingAndChildVertices(context.selectedIDs(), graph, wireframe, zoom);
55453       }
55454       var filter2 = function(d2) {
55455         return d2.id in _prevSelected;
55456       };
55457       drawVertices(selection2, graph, Object.values(_prevSelected), filter2, extent, false);
55458     };
55459     drawVertices.drawHover = function(selection2, graph, target, extent) {
55460       if (target === _currHoverTarget) return;
55461       var wireframe = context.surface().classed("fill-wireframe");
55462       var zoom = geoScaleToZoom(projection2.scale());
55463       _prevHover = _currHover || {};
55464       _currHoverTarget = target;
55465       var entity = target && target.properties && target.properties.entity;
55466       if (entity) {
55467         _currHover = getSiblingAndChildVertices([entity.id], graph, wireframe, zoom);
55468       } else {
55469         _currHover = {};
55470       }
55471       var filter2 = function(d2) {
55472         return d2.id in _prevHover;
55473       };
55474       drawVertices(selection2, graph, Object.values(_prevHover), filter2, extent, false);
55475     };
55476     return drawVertices;
55477   }
55478
55479   // modules/ui/length_indicator.js
55480   function uiLengthIndicator(maxChars) {
55481     var _wrap = select_default2(null);
55482     var _tooltip = uiPopover("tooltip max-length-warning").placement("bottom").hasArrow(true).content(() => (selection2) => {
55483       selection2.text("");
55484       selection2.call(svgIcon("#iD-icon-alert", "inline"));
55485       selection2.call(_t.append("inspector.max_length_reached", { maxChars }));
55486     });
55487     var _silent = false;
55488     var lengthIndicator = function(selection2) {
55489       _wrap = selection2.selectAll("span.length-indicator-wrap").data([0]);
55490       _wrap = _wrap.enter().append("span").merge(_wrap).classed("length-indicator-wrap", true);
55491       selection2.call(_tooltip);
55492     };
55493     lengthIndicator.update = function(val) {
55494       const strLen = utilUnicodeCharsCount(utilCleanOsmString(val, Number.POSITIVE_INFINITY));
55495       let indicator = _wrap.selectAll("span.length-indicator").data([strLen]);
55496       indicator.enter().append("span").merge(indicator).classed("length-indicator", true).classed("limit-reached", (d2) => d2 > maxChars).style("border-right-width", (d2) => "".concat(Math.abs(maxChars - d2) * 2, "px")).style("margin-right", (d2) => d2 > maxChars ? "".concat((maxChars - d2) * 2, "px") : 0).style("opacity", (d2) => d2 > maxChars * 0.8 ? Math.min(1, (d2 / maxChars - 0.8) / (1 - 0.8)) : 0).style("pointer-events", (d2) => d2 > maxChars * 0.8 ? null : "none");
55497       if (_silent) return;
55498       if (strLen > maxChars) {
55499         _tooltip.show();
55500       } else {
55501         _tooltip.hide();
55502       }
55503     };
55504     lengthIndicator.silent = function(val) {
55505       if (!arguments.length) return _silent;
55506       _silent = val;
55507       return lengthIndicator;
55508     };
55509     return lengthIndicator;
55510   }
55511
55512   // modules/ui/fields/combo.js
55513   function uiFieldCombo(field, context) {
55514     var dispatch14 = dispatch_default("change");
55515     var _isMulti = field.type === "multiCombo" || field.type === "manyCombo";
55516     var _isNetwork = field.type === "networkCombo";
55517     var _isSemi = field.type === "semiCombo";
55518     var _showTagInfoSuggestions = field.type !== "manyCombo" && field.autoSuggestions !== false;
55519     var _allowCustomValues = field.type !== "manyCombo" && field.customValues !== false;
55520     var _snake_case = field.snake_case || field.snake_case === void 0;
55521     var _combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(field.caseSensitive).minItems(1);
55522     var _container = select_default2(null);
55523     var _inputWrap = select_default2(null);
55524     var _input = select_default2(null);
55525     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
55526     var _comboData = [];
55527     var _multiData = [];
55528     var _entityIDs = [];
55529     var _tags;
55530     var _countryCode;
55531     var _staticPlaceholder;
55532     var _dataDeprecated = [];
55533     _mainFileFetcher.get("deprecated").then(function(d2) {
55534       _dataDeprecated = d2;
55535     }).catch(function() {
55536     });
55537     if (_isMulti && field.key && /[^:]$/.test(field.key)) {
55538       field.key += ":";
55539     }
55540     function snake(s2) {
55541       return s2.replace(/\s+/g, "_");
55542     }
55543     function clean2(s2) {
55544       return s2.split(";").map(function(s3) {
55545         return s3.trim();
55546       }).join(";");
55547     }
55548     function tagValue(dval) {
55549       dval = clean2(dval || "");
55550       var found = getOptions(true).find(function(o2) {
55551         return o2.key && clean2(o2.value) === dval;
55552       });
55553       if (found) return found.key;
55554       if (field.type === "typeCombo" && !dval) {
55555         return "yes";
55556       }
55557       return restrictTagValueSpelling(dval) || void 0;
55558     }
55559     function restrictTagValueSpelling(dval) {
55560       if (_snake_case) {
55561         dval = snake(dval);
55562       }
55563       if (!field.caseSensitive) {
55564         dval = dval.toLowerCase();
55565       }
55566       return dval;
55567     }
55568     function getLabelId(field2, v2) {
55569       return field2.hasTextForStringId("options.".concat(v2, ".title")) ? "options.".concat(v2, ".title") : "options.".concat(v2);
55570     }
55571     function displayValue(tval) {
55572       tval = tval || "";
55573       var stringsField = field.resolveReference("stringsCrossReference");
55574       const labelId = getLabelId(stringsField, tval);
55575       if (stringsField.hasTextForStringId(labelId)) {
55576         return stringsField.t(labelId, { default: tval });
55577       }
55578       if (field.type === "typeCombo" && tval.toLowerCase() === "yes") {
55579         return "";
55580       }
55581       return tval;
55582     }
55583     function renderValue(tval) {
55584       tval = tval || "";
55585       var stringsField = field.resolveReference("stringsCrossReference");
55586       const labelId = getLabelId(stringsField, tval);
55587       if (stringsField.hasTextForStringId(labelId)) {
55588         return stringsField.t.append(labelId, { default: tval });
55589       }
55590       if (field.type === "typeCombo" && tval.toLowerCase() === "yes") {
55591         tval = "";
55592       }
55593       return (selection2) => selection2.text(tval);
55594     }
55595     function objectDifference(a2, b2) {
55596       return a2.filter(function(d1) {
55597         return !b2.some(function(d2) {
55598           return d1.value === d2.value;
55599         });
55600       });
55601     }
55602     function initCombo(selection2, attachTo) {
55603       if (!_allowCustomValues) {
55604         selection2.attr("readonly", "readonly");
55605       }
55606       if (_showTagInfoSuggestions && services.taginfo) {
55607         selection2.call(_combobox.fetcher(setTaginfoValues), attachTo);
55608         setTaginfoValues("", setPlaceholder);
55609       } else {
55610         selection2.call(_combobox, attachTo);
55611         setTimeout(() => setStaticValues(setPlaceholder), 0);
55612       }
55613     }
55614     function getOptions(allOptions) {
55615       var stringsField = field.resolveReference("stringsCrossReference");
55616       if (!(field.options || stringsField.options)) return [];
55617       let options2;
55618       if (allOptions !== true) {
55619         options2 = field.options || stringsField.options;
55620       } else {
55621         options2 = [].concat(field.options, stringsField.options).filter(Boolean);
55622       }
55623       return options2.map(function(v2) {
55624         const labelId = getLabelId(stringsField, v2);
55625         return {
55626           key: v2,
55627           value: stringsField.t(labelId, { default: v2 }),
55628           title: stringsField.t("options.".concat(v2, ".description"), { default: v2 }),
55629           display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2),
55630           klass: stringsField.hasTextForStringId(labelId) ? "" : "raw-option"
55631         };
55632       });
55633     }
55634     function hasStaticValues() {
55635       return getOptions().length > 0;
55636     }
55637     function setStaticValues(callback, filter2) {
55638       _comboData = getOptions();
55639       if (filter2 !== void 0) {
55640         _comboData = _comboData.filter(filter2);
55641       }
55642       _comboData = objectDifference(_comboData, _multiData);
55643       _combobox.data(_comboData);
55644       if (callback) callback(_comboData);
55645     }
55646     function setTaginfoValues(q2, callback) {
55647       var queryFilter = (d2) => d2.value.toLowerCase().includes(q2.toLowerCase()) || d2.key.toLowerCase().includes(q2.toLowerCase());
55648       if (hasStaticValues()) {
55649         setStaticValues(callback, queryFilter);
55650       }
55651       var stringsField = field.resolveReference("stringsCrossReference");
55652       var fn = _isMulti ? "multikeys" : "values";
55653       var query = (_isMulti ? field.key : "") + q2;
55654       var hasCountryPrefix = _isNetwork && _countryCode && _countryCode.indexOf(q2.toLowerCase()) === 0;
55655       if (hasCountryPrefix) {
55656         query = _countryCode + ":";
55657       }
55658       var params = {
55659         debounce: q2 !== "",
55660         key: field.key,
55661         query
55662       };
55663       if (_entityIDs.length) {
55664         params.geometry = context.graph().geometry(_entityIDs[0]);
55665       }
55666       services.taginfo[fn](params, function(err, data) {
55667         if (err) return;
55668         data = data.filter((d2) => field.type !== "typeCombo" || d2.value !== "yes");
55669         data = data.filter((d2) => {
55670           var value = d2.value;
55671           if (_isMulti) {
55672             value = value.slice(field.key.length);
55673           }
55674           return value === restrictTagValueSpelling(value);
55675         });
55676         var deprecatedValues = osmEntity.deprecatedTagValuesByKey(_dataDeprecated)[field.key];
55677         if (deprecatedValues) {
55678           data = data.filter((d2) => !deprecatedValues.includes(d2.value));
55679         }
55680         if (hasCountryPrefix) {
55681           data = data.filter((d2) => d2.value.toLowerCase().indexOf(_countryCode + ":") === 0);
55682         }
55683         const additionalOptions = (field.options || stringsField.options || []).filter((v2) => !data.some((dv) => dv.value === (_isMulti ? field.key + v2 : v2))).map((v2) => ({ value: v2 }));
55684         _container.classed("empty-combobox", data.length === 0);
55685         _comboData = data.concat(additionalOptions).map(function(d2) {
55686           var v2 = d2.value;
55687           if (_isMulti) v2 = v2.replace(field.key, "");
55688           const labelId = getLabelId(stringsField, v2);
55689           var isLocalizable = stringsField.hasTextForStringId(labelId);
55690           var label = stringsField.t(labelId, { default: v2 });
55691           return {
55692             key: v2,
55693             value: label,
55694             title: stringsField.t("options.".concat(v2, ".description"), { default: isLocalizable ? v2 : d2.title !== label ? d2.title : "" }),
55695             display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2),
55696             klass: isLocalizable ? "" : "raw-option"
55697           };
55698         });
55699         _comboData = _comboData.filter(queryFilter);
55700         _comboData = objectDifference(_comboData, _multiData);
55701         if (callback) callback(_comboData, hasStaticValues());
55702       });
55703     }
55704     function addComboboxIcons(disp, value) {
55705       const iconsField = field.resolveReference("iconsCrossReference");
55706       if (iconsField.icons) {
55707         return function(selection2) {
55708           var span = selection2.insert("span", ":first-child").attr("class", "tag-value-icon");
55709           if (iconsField.icons[value]) {
55710             span.call(svgIcon("#".concat(iconsField.icons[value])));
55711           }
55712           disp.call(this, selection2);
55713         };
55714       }
55715       return disp;
55716     }
55717     function setPlaceholder(values) {
55718       if (_isMulti || _isSemi) {
55719         _staticPlaceholder = field.placeholder() || _t("inspector.add");
55720       } else {
55721         var vals = values.map(function(d2) {
55722           return d2.value;
55723         }).filter(function(s2) {
55724           return s2.length < 20;
55725         });
55726         var placeholders = vals.length > 1 ? vals : values.map(function(d2) {
55727           return d2.key;
55728         });
55729         _staticPlaceholder = field.placeholder() || placeholders.slice(0, 3).join(", ");
55730       }
55731       if (!/(…|\.\.\.)$/.test(_staticPlaceholder)) {
55732         _staticPlaceholder += "\u2026";
55733       }
55734       var ph;
55735       if (!_isMulti && !_isSemi && _tags && Array.isArray(_tags[field.key])) {
55736         ph = _t("inspector.multiple_values");
55737       } else {
55738         ph = _staticPlaceholder;
55739       }
55740       _container.selectAll("input").attr("placeholder", ph);
55741       var hideAdd = !_allowCustomValues && !values.length;
55742       _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null);
55743     }
55744     function change() {
55745       var t2 = {};
55746       var val;
55747       if (_isMulti || _isSemi) {
55748         var vals;
55749         if (_isMulti) {
55750           vals = [tagValue(utilGetSetValue(_input))];
55751         } else if (_isSemi) {
55752           val = tagValue(utilGetSetValue(_input)) || "";
55753           val = val.replace(/,/g, ";");
55754           vals = val.split(";");
55755         }
55756         vals = vals.filter(Boolean);
55757         if (!vals.length) return;
55758         _container.classed("active", false);
55759         utilGetSetValue(_input, "");
55760         if (_isMulti) {
55761           utilArrayUniq(vals).forEach(function(v2) {
55762             var key = (field.key || "") + v2;
55763             if (_tags) {
55764               var old = _tags[key];
55765               if (typeof old === "string" && old.toLowerCase() !== "no") return;
55766             }
55767             key = context.cleanTagKey(key);
55768             field.keys.push(key);
55769             t2[key] = "yes";
55770           });
55771         } else if (_isSemi) {
55772           var arr = _multiData.map(function(d2) {
55773             return d2.key;
55774           });
55775           arr = arr.concat(vals);
55776           t2[field.key] = context.cleanTagValue(utilArrayUniq(arr).filter(Boolean).join(";"));
55777         }
55778         window.setTimeout(function() {
55779           _input.node().focus();
55780         }, 10);
55781       } else {
55782         var rawValue = utilGetSetValue(_input);
55783         if (!rawValue && Array.isArray(_tags[field.key])) return;
55784         val = context.cleanTagValue(tagValue(rawValue));
55785         t2[field.key] = val || void 0;
55786       }
55787       dispatch14.call("change", this, t2);
55788     }
55789     function removeMultikey(d3_event, d2) {
55790       d3_event.preventDefault();
55791       d3_event.stopPropagation();
55792       var t2 = {};
55793       if (_isMulti) {
55794         t2[d2.key] = void 0;
55795       } else if (_isSemi) {
55796         var arr = _multiData.map(function(md) {
55797           return md.key === d2.key ? null : md.key;
55798         }).filter(Boolean);
55799         arr = utilArrayUniq(arr);
55800         t2[field.key] = arr.length ? arr.join(";") : void 0;
55801         _lengthIndicator.update(t2[field.key]);
55802       }
55803       dispatch14.call("change", this, t2);
55804     }
55805     function invertMultikey(d3_event, d2) {
55806       d3_event.preventDefault();
55807       d3_event.stopPropagation();
55808       var t2 = {};
55809       if (_isMulti) {
55810         t2[d2.key] = _tags[d2.key] === "yes" ? "no" : "yes";
55811       }
55812       dispatch14.call("change", this, t2);
55813     }
55814     function combo(selection2) {
55815       _container = selection2.selectAll(".form-field-input-wrap").data([0]);
55816       var type2 = _isMulti || _isSemi ? "multicombo" : "combo";
55817       _container = _container.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + type2).merge(_container);
55818       if (_isMulti || _isSemi) {
55819         _container = _container.selectAll(".chiplist").data([0]);
55820         var listClass = "chiplist";
55821         if (field.key === "destination" || field.key === "via") {
55822           listClass += " full-line-chips";
55823         }
55824         _container = _container.enter().append("ul").attr("class", listClass).on("click", function() {
55825           window.setTimeout(function() {
55826             _input.node().focus();
55827           }, 10);
55828         }).merge(_container);
55829         _inputWrap = _container.selectAll(".input-wrap").data([0]);
55830         _inputWrap = _inputWrap.enter().append("li").attr("class", "input-wrap").merge(_inputWrap);
55831         var hideAdd = !_allowCustomValues && !_comboData.length;
55832         _inputWrap.style("display", hideAdd ? "none" : null);
55833         _input = _inputWrap.selectAll("input").data([0]);
55834       } else {
55835         _input = _container.selectAll("input").data([0]);
55836       }
55837       _input = _input.enter().append("input").attr("type", "text").attr("id", field.domId).call(utilNoAuto).call(initCombo, _container).merge(_input);
55838       if (_isSemi) {
55839         _inputWrap.call(_lengthIndicator);
55840       } else if (!_isMulti) {
55841         _container.call(_lengthIndicator);
55842       }
55843       if (_isNetwork) {
55844         var extent = combinedEntityExtent();
55845         var countryCode = extent && iso1A2Code(extent.center());
55846         _countryCode = countryCode && countryCode.toLowerCase();
55847       }
55848       _input.on("change", change).on("blur", change).on("input", function() {
55849         let val = utilGetSetValue(_input);
55850         updateIcon(val);
55851         if (_isSemi && _tags[field.key]) {
55852           val += ";" + _tags[field.key];
55853         }
55854         _lengthIndicator.update(val);
55855       });
55856       _input.on("keydown.field", function(d3_event) {
55857         switch (d3_event.keyCode) {
55858           case 13:
55859             _input.node().blur();
55860             d3_event.stopPropagation();
55861             break;
55862         }
55863       });
55864       if (_isMulti || _isSemi) {
55865         _combobox.on("accept", function() {
55866           _input.node().blur();
55867           _input.node().focus();
55868         });
55869         _input.on("focus", function() {
55870           _container.classed("active", true);
55871         });
55872       }
55873       _combobox.on("cancel", function() {
55874         _input.node().blur();
55875       }).on("update", function() {
55876         updateIcon(utilGetSetValue(_input));
55877       });
55878     }
55879     function updateIcon(value) {
55880       value = tagValue(value);
55881       let container = _container;
55882       if (field.type === "multiCombo" || field.type === "semiCombo") {
55883         container = _container.select(".input-wrap");
55884       }
55885       const iconsField = field.resolveReference("iconsCrossReference");
55886       if (iconsField.icons) {
55887         container.selectAll(".tag-value-icon").remove();
55888         if (iconsField.icons[value]) {
55889           container.selectAll(".tag-value-icon").data([value]).enter().insert("div", "input").attr("class", "tag-value-icon").call(svgIcon("#".concat(iconsField.icons[value])));
55890         }
55891       }
55892     }
55893     combo.tags = function(tags) {
55894       _tags = tags;
55895       var stringsField = field.resolveReference("stringsCrossReference");
55896       var isMixed = Array.isArray(tags[field.key]);
55897       var showsValue = (value) => !isMixed && value && !(field.type === "typeCombo" && value === "yes");
55898       var isRawValue = (value) => showsValue(value) && !stringsField.hasTextForStringId("options.".concat(value)) && !stringsField.hasTextForStringId("options.".concat(value, ".title"));
55899       var isKnownValue = (value) => showsValue(value) && !isRawValue(value);
55900       var isReadOnly = !_allowCustomValues;
55901       if (_isMulti || _isSemi) {
55902         _multiData = [];
55903         var maxLength;
55904         if (_isMulti) {
55905           for (var k2 in tags) {
55906             if (field.key && k2.indexOf(field.key) !== 0) continue;
55907             if (!field.key && field.keys.indexOf(k2) === -1) continue;
55908             var v2 = tags[k2];
55909             var suffix = field.key ? k2.slice(field.key.length) : k2;
55910             _multiData.push({
55911               key: k2,
55912               value: displayValue(suffix),
55913               display: addComboboxIcons(renderValue(suffix), suffix),
55914               state: typeof v2 === "string" ? v2.toLowerCase() : "",
55915               isMixed: Array.isArray(v2)
55916             });
55917           }
55918           if (field.key) {
55919             field.keys = _multiData.map(function(d2) {
55920               return d2.key;
55921             });
55922             maxLength = context.maxCharsForTagKey() - utilUnicodeCharsCount(field.key);
55923           } else {
55924             maxLength = context.maxCharsForTagKey();
55925           }
55926         } else if (_isSemi) {
55927           var allValues = [];
55928           var commonValues;
55929           if (Array.isArray(tags[field.key])) {
55930             tags[field.key].forEach(function(tagVal) {
55931               var thisVals = utilArrayUniq((tagVal || "").split(";")).filter(Boolean);
55932               allValues = allValues.concat(thisVals);
55933               if (!commonValues) {
55934                 commonValues = thisVals;
55935               } else {
55936                 commonValues = commonValues.filter((value) => thisVals.includes(value));
55937               }
55938             });
55939             allValues = utilArrayUniq(allValues).filter(Boolean);
55940           } else {
55941             allValues = utilArrayUniq((tags[field.key] || "").split(";")).filter(Boolean);
55942             commonValues = allValues;
55943           }
55944           _multiData = allValues.map(function(v3) {
55945             return {
55946               key: v3,
55947               value: displayValue(v3),
55948               display: addComboboxIcons(renderValue(v3), v3),
55949               isMixed: !commonValues.includes(v3)
55950             };
55951           });
55952           var currLength = utilUnicodeCharsCount(commonValues.join(";"));
55953           maxLength = context.maxCharsForTagValue() - currLength;
55954           if (currLength > 0) {
55955             maxLength -= 1;
55956           }
55957         }
55958         maxLength = Math.max(0, maxLength);
55959         var hideAdd = maxLength <= 0 || !_allowCustomValues && !_comboData.length;
55960         _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null);
55961         var allowDragAndDrop = _isSemi && !Array.isArray(tags[field.key]);
55962         var chips = _container.selectAll(".chip").data(_multiData);
55963         chips.exit().remove();
55964         var enter = chips.enter().insert("li", ".input-wrap").attr("class", "chip");
55965         enter.append("span");
55966         const field_buttons = enter.append("div").attr("class", "field_buttons");
55967         field_buttons.append("a").attr("class", "remove");
55968         chips = chips.merge(enter).order().classed("raw-value", function(d2) {
55969           var k3 = d2.key;
55970           if (_isMulti) k3 = k3.replace(field.key, "");
55971           return !stringsField.hasTextForStringId("options." + k3);
55972         }).classed("draggable", allowDragAndDrop).classed("mixed", function(d2) {
55973           return d2.isMixed;
55974         }).attr("title", function(d2) {
55975           if (d2.isMixed) {
55976             return _t("inspector.unshared_value_tooltip");
55977           }
55978           if (!["yes", "no"].includes(d2.state)) {
55979             return d2.state;
55980           }
55981           return null;
55982         }).classed("negated", (d2) => d2.state === "no");
55983         if (!_isSemi) {
55984           chips.selectAll("input[type=checkbox]").remove();
55985           chips.insert("input", "span").attr("type", "checkbox").property("checked", (d2) => d2.state === "yes").property("indeterminate", (d2) => d2.isMixed || !["yes", "no"].includes(d2.state)).on("click", invertMultikey);
55986         }
55987         if (allowDragAndDrop) {
55988           registerDragAndDrop(chips);
55989         }
55990         chips.each(function(d2) {
55991           const selection2 = select_default2(this);
55992           const text_span = selection2.select("span");
55993           const field_buttons2 = selection2.select(".field_buttons");
55994           const clean_value = d2.value.trim();
55995           text_span.text("");
55996           if (!field_buttons2.select("button").empty()) {
55997             field_buttons2.select("button").remove();
55998           }
55999           if (clean_value.startsWith("https://")) {
56000             text_span.text(clean_value);
56001             field_buttons2.append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", () => _t("icons.visit_website")).attr("aria-label", () => _t("icons.visit_website")).on("click", function(d3_event) {
56002               d3_event.preventDefault();
56003               window.open(clean_value, "_blank");
56004             });
56005             return;
56006           }
56007           if (d2.display) {
56008             d2.display(text_span);
56009             return;
56010           }
56011           text_span.text(d2.value);
56012         });
56013         chips.select("a.remove").attr("href", "#").on("click", removeMultikey).attr("class", "remove").text("\xD7");
56014         updateIcon("");
56015       } else {
56016         var mixedValues = isMixed && tags[field.key].map(function(val) {
56017           return displayValue(val);
56018         }).filter(Boolean);
56019         utilGetSetValue(_input, !isMixed ? displayValue(tags[field.key]) : "").data([tags[field.key]]).classed("raw-value", isRawValue).classed("known-value", isKnownValue).attr("readonly", isReadOnly ? "readonly" : void 0).attr("title", isMixed ? mixedValues.join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : _staticPlaceholder || "").classed("mixed", isMixed).on("keydown.deleteCapture", function(d3_event) {
56020           if (isReadOnly && isKnownValue(tags[field.key]) && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) {
56021             d3_event.preventDefault();
56022             d3_event.stopPropagation();
56023             var t2 = {};
56024             t2[field.key] = void 0;
56025             dispatch14.call("change", this, t2);
56026           }
56027         });
56028         if (!Array.isArray(tags[field.key])) {
56029           updateIcon(tags[field.key]);
56030         }
56031         if (!isMixed) {
56032           _lengthIndicator.update(tags[field.key]);
56033         }
56034       }
56035       const refreshStyles = () => {
56036         _input.data([tagValue(utilGetSetValue(_input))]).classed("raw-value", isRawValue).classed("known-value", isKnownValue);
56037       };
56038       _input.on("input.refreshStyles", refreshStyles);
56039       _combobox.on("update.refreshStyles", refreshStyles);
56040       refreshStyles();
56041     };
56042     function registerDragAndDrop(selection2) {
56043       var dragOrigin, targetIndex;
56044       selection2.call(
56045         drag_default().on("start", function(d3_event) {
56046           dragOrigin = {
56047             x: d3_event.x,
56048             y: d3_event.y
56049           };
56050           targetIndex = null;
56051         }).on("drag", function(d3_event) {
56052           var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y;
56053           if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold
56054           Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5) return;
56055           var index = selection2.nodes().indexOf(this);
56056           select_default2(this).classed("dragging", true);
56057           targetIndex = null;
56058           var targetIndexOffsetTop = null;
56059           var draggedTagWidth = select_default2(this).node().offsetWidth;
56060           if (field.key === "destination" || field.key === "via") {
56061             _container.selectAll(".chip").style("transform", function(d2, index2) {
56062               var node = select_default2(this).node();
56063               if (index === index2) {
56064                 return "translate(" + x2 + "px, " + y2 + "px)";
56065               } else if (index2 > index && d3_event.y > node.offsetTop) {
56066                 if (targetIndex === null || index2 > targetIndex) {
56067                   targetIndex = index2;
56068                 }
56069                 return "translateY(-100%)";
56070               } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) {
56071                 if (targetIndex === null || index2 < targetIndex) {
56072                   targetIndex = index2;
56073                 }
56074                 return "translateY(100%)";
56075               }
56076               return null;
56077             });
56078           } else {
56079             _container.selectAll(".chip").each(function(d2, index2) {
56080               var node = select_default2(this).node();
56081               if (index !== index2 && d3_event.x < node.offsetLeft + node.offsetWidth + 5 && d3_event.x > node.offsetLeft && d3_event.y < node.offsetTop + node.offsetHeight && d3_event.y > node.offsetTop) {
56082                 targetIndex = index2;
56083                 targetIndexOffsetTop = node.offsetTop;
56084               }
56085             }).style("transform", function(d2, index2) {
56086               var node = select_default2(this).node();
56087               if (index === index2) {
56088                 return "translate(" + x2 + "px, " + y2 + "px)";
56089               }
56090               if (node.offsetTop === targetIndexOffsetTop) {
56091                 if (index2 < index && index2 >= targetIndex) {
56092                   return "translateX(" + draggedTagWidth + "px)";
56093                 } else if (index2 > index && index2 <= targetIndex) {
56094                   return "translateX(-" + draggedTagWidth + "px)";
56095                 }
56096               }
56097               return null;
56098             });
56099           }
56100         }).on("end", function() {
56101           if (!select_default2(this).classed("dragging")) {
56102             return;
56103           }
56104           var index = selection2.nodes().indexOf(this);
56105           select_default2(this).classed("dragging", false);
56106           _container.selectAll(".chip").style("transform", null);
56107           if (typeof targetIndex === "number") {
56108             var element = _multiData[index];
56109             _multiData.splice(index, 1);
56110             _multiData.splice(targetIndex, 0, element);
56111             var t2 = {};
56112             if (_multiData.length) {
56113               t2[field.key] = _multiData.map(function(element2) {
56114                 return element2.key;
56115               }).join(";");
56116             } else {
56117               t2[field.key] = void 0;
56118             }
56119             dispatch14.call("change", this, t2);
56120           }
56121           dragOrigin = void 0;
56122           targetIndex = void 0;
56123         })
56124       );
56125     }
56126     combo.focus = function() {
56127       _input.node().focus();
56128     };
56129     combo.entityIDs = function(val) {
56130       if (!arguments.length) return _entityIDs;
56131       _entityIDs = val;
56132       return combo;
56133     };
56134     function combinedEntityExtent() {
56135       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
56136     }
56137     return utilRebind(combo, dispatch14, "on");
56138   }
56139
56140   // modules/ui/account.js
56141   function uiAccount(context) {
56142     const osm = context.connection();
56143     function updateUserDetails(selection2) {
56144       if (!osm) return;
56145       if (!osm.authenticated()) {
56146         render(selection2, null);
56147       } else {
56148         osm.userDetails((err, user) => render(selection2, user));
56149       }
56150     }
56151     function render(selection2, user) {
56152       let userInfo = selection2.select(".userInfo");
56153       let loginLogout = selection2.select(".loginLogout");
56154       if (user) {
56155         userInfo.html("").classed("hide", false);
56156         let userLink = userInfo.append("a").attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
56157         if (user.image_url) {
56158           userLink.append("img").attr("class", "icon pre-text user-icon").attr("src", user.image_url);
56159         } else {
56160           userLink.call(svgIcon("#iD-icon-avatar", "pre-text light"));
56161         }
56162         userLink.append("span").attr("class", "label").text(user.display_name);
56163         loginLogout.classed("hide", false).select("a").text(_t("logout")).on("click", (e3) => {
56164           e3.preventDefault();
56165           osm.logout();
56166           osm.authenticate(void 0, { switchUser: true });
56167         });
56168       } else {
56169         userInfo.html("").classed("hide", true);
56170         loginLogout.classed("hide", false).select("a").text(_t("login")).on("click", (e3) => {
56171           e3.preventDefault();
56172           osm.authenticate();
56173         });
56174       }
56175     }
56176     return function(selection2) {
56177       if (!osm) return;
56178       selection2.append("li").attr("class", "userInfo").classed("hide", true);
56179       selection2.append("li").attr("class", "loginLogout").classed("hide", true).append("a").attr("href", "#");
56180       osm.on("change.account", () => updateUserDetails(selection2));
56181       updateUserDetails(selection2);
56182     };
56183   }
56184
56185   // modules/ui/attribution.js
56186   function uiAttribution(context) {
56187     let _selection = select_default2(null);
56188     function render(selection2, data, klass) {
56189       let div = selection2.selectAll(".".concat(klass)).data([0]);
56190       div = div.enter().append("div").attr("class", klass).merge(div);
56191       let attributions = div.selectAll(".attribution").data(data, (d2) => d2.id);
56192       attributions.exit().remove();
56193       attributions = attributions.enter().append("span").attr("class", "attribution").each((d2, i3, nodes) => {
56194         let attribution = select_default2(nodes[i3]);
56195         if (d2.terms_html) {
56196           attribution.html(d2.terms_html);
56197           return;
56198         }
56199         if (d2.terms_url) {
56200           attribution = attribution.append("a").attr("href", d2.terms_url).attr("target", "_blank");
56201         }
56202         const sourceID = d2.id.replace(/\./g, "<TX_DOT>");
56203         const terms_text = _t(
56204           "imagery.".concat(sourceID, ".attribution.text"),
56205           { default: d2.terms_text || d2.id || d2.name() }
56206         );
56207         if (d2.icon && !d2.overlay) {
56208           attribution.append("img").attr("class", "source-image").attr("src", d2.icon);
56209         }
56210         attribution.append("span").attr("class", "attribution-text").text(terms_text);
56211       }).merge(attributions);
56212       let copyright = attributions.selectAll(".copyright-notice").data((d2) => {
56213         let notice = d2.copyrightNotices(context.map().zoom(), context.map().extent());
56214         return notice ? [notice] : [];
56215       });
56216       copyright.exit().remove();
56217       copyright = copyright.enter().append("span").attr("class", "copyright-notice").merge(copyright);
56218       copyright.text(String);
56219     }
56220     function update() {
56221       let baselayer = context.background().baseLayerSource();
56222       _selection.call(render, baselayer ? [baselayer] : [], "base-layer-attribution");
56223       const z2 = context.map().zoom();
56224       let overlays = context.background().overlayLayerSources() || [];
56225       _selection.call(render, overlays.filter((s2) => s2.validZoom(z2)), "overlay-layer-attribution");
56226     }
56227     return function(selection2) {
56228       _selection = selection2;
56229       context.background().on("change.attribution", update);
56230       context.map().on("move.attribution", throttle_default(update, 400, { leading: false }));
56231       update();
56232     };
56233   }
56234
56235   // modules/ui/contributors.js
56236   function uiContributors(context) {
56237     var osm = context.connection(), debouncedUpdate = debounce_default(function() {
56238       update();
56239     }, 1e3), limit = 4, hidden = false, wrap2 = select_default2(null);
56240     function update() {
56241       if (!osm) return;
56242       var users = {}, entities = context.history().intersects(context.map().extent());
56243       entities.forEach(function(entity) {
56244         if (entity && entity.user) users[entity.user] = true;
56245       });
56246       var u2 = Object.keys(users), subset = u2.slice(0, u2.length > limit ? limit - 1 : limit);
56247       wrap2.html("").call(svgIcon("#iD-icon-nearby", "pre-text light"));
56248       var userList = select_default2(document.createElement("span"));
56249       userList.selectAll().data(subset).enter().append("a").attr("class", "user-link").attr("href", function(d2) {
56250         return osm.userURL(d2);
56251       }).attr("target", "_blank").text(String);
56252       if (u2.length > limit) {
56253         var count = select_default2(document.createElement("span"));
56254         var othersNum = u2.length - limit + 1;
56255         count.append("a").attr("target", "_blank").attr("href", function() {
56256           return osm.changesetsURL(context.map().center(), context.map().zoom());
56257         }).text(othersNum);
56258         wrap2.append("span").html(_t.html("contributors.truncated_list", { n: othersNum, users: { html: userList.html() }, count: { html: count.html() } }));
56259       } else {
56260         wrap2.append("span").html(_t.html("contributors.list", { users: { html: userList.html() } }));
56261       }
56262       if (!u2.length) {
56263         hidden = true;
56264         wrap2.transition().style("opacity", 0);
56265       } else if (hidden) {
56266         wrap2.transition().style("opacity", 1);
56267       }
56268     }
56269     return function(selection2) {
56270       if (!osm) return;
56271       wrap2 = selection2;
56272       update();
56273       osm.on("loaded.contributors", debouncedUpdate);
56274       context.map().on("move.contributors", debouncedUpdate);
56275     };
56276   }
56277
56278   // modules/ui/edit_menu.js
56279   function uiEditMenu(context) {
56280     var dispatch14 = dispatch_default("toggled");
56281     var _menu = select_default2(null);
56282     var _operations = [];
56283     var _anchorLoc = [0, 0];
56284     var _anchorLocLonLat = [0, 0];
56285     var _triggerType = "";
56286     var _vpTopMargin = 85;
56287     var _vpBottomMargin = 45;
56288     var _vpSideMargin = 35;
56289     var _menuTop = false;
56290     var _menuHeight;
56291     var _menuWidth;
56292     var _verticalPadding = 4;
56293     var _tooltipWidth = 210;
56294     var _menuSideMargin = 10;
56295     var _tooltips = [];
56296     var editMenu = function(selection2) {
56297       var isTouchMenu = _triggerType.includes("touch") || _triggerType.includes("pen");
56298       var ops = _operations.filter(function(op) {
56299         return !isTouchMenu || !op.mouseOnly;
56300       });
56301       if (!ops.length) return;
56302       _tooltips = [];
56303       _menuTop = isTouchMenu;
56304       var showLabels = isTouchMenu;
56305       var buttonHeight = showLabels ? 32 : 34;
56306       if (showLabels) {
56307         _menuWidth = 52 + Math.min(120, 6 * Math.max.apply(Math, ops.map(function(op) {
56308           return op.title.length;
56309         })));
56310       } else {
56311         _menuWidth = 44;
56312       }
56313       _menuHeight = _verticalPadding * 2 + ops.length * buttonHeight;
56314       _menu = selection2.append("div").attr("class", "edit-menu").classed("touch-menu", isTouchMenu).style("padding", _verticalPadding + "px 0");
56315       var buttons = _menu.selectAll(".edit-menu-item").data(ops);
56316       var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
56317         return "edit-menu-item edit-menu-item-" + d2.id;
56318       }).style("height", buttonHeight + "px").on("click", click).on("pointerup", pointerup).on("pointerdown mousedown", function pointerdown(d3_event) {
56319         d3_event.stopPropagation();
56320       }).on("mouseenter.highlight", function(d3_event, d2) {
56321         if (!d2.relatedEntityIds || select_default2(this).classed("disabled")) return;
56322         utilHighlightEntities(d2.relatedEntityIds(), true, context);
56323       }).on("mouseleave.highlight", function(d3_event, d2) {
56324         if (!d2.relatedEntityIds) return;
56325         utilHighlightEntities(d2.relatedEntityIds(), false, context);
56326       });
56327       buttonsEnter.each(function(d2) {
56328         var tooltip = uiTooltip().heading(() => d2.title).title(d2.tooltip).keys([d2.keys[0]]);
56329         _tooltips.push(tooltip);
56330         select_default2(this).call(tooltip).append("div").attr("class", "icon-wrap").call(svgIcon(d2.icon && d2.icon() || "#iD-operation-" + d2.id, "operation"));
56331       });
56332       if (showLabels) {
56333         buttonsEnter.append("span").attr("class", "label").each(function(d2) {
56334           select_default2(this).call(d2.title);
56335         });
56336       }
56337       buttonsEnter.merge(buttons).classed("disabled", function(d2) {
56338         return d2.disabled();
56339       });
56340       updatePosition();
56341       var initialScale = context.projection.scale();
56342       context.map().on("move.edit-menu", function() {
56343         if (initialScale !== context.projection.scale()) {
56344           editMenu.close();
56345         }
56346       }).on("drawn.edit-menu", function(info) {
56347         if (info.full) updatePosition();
56348       });
56349       var lastPointerUpType;
56350       function pointerup(d3_event) {
56351         lastPointerUpType = d3_event.pointerType;
56352       }
56353       function click(d3_event, operation2) {
56354         d3_event.stopPropagation();
56355         if (operation2.relatedEntityIds) {
56356           utilHighlightEntities(operation2.relatedEntityIds(), false, context);
56357         }
56358         if (operation2.disabled()) {
56359           if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
56360             context.ui().flash.duration(4e3).iconName("#iD-operation-" + operation2.id).iconClass("operation disabled").label(operation2.tooltip())();
56361           }
56362         } else {
56363           if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
56364             context.ui().flash.duration(2e3).iconName("#iD-operation-" + operation2.id).iconClass("operation").label(operation2.annotation() || operation2.title)();
56365           }
56366           operation2();
56367           editMenu.close();
56368         }
56369         lastPointerUpType = null;
56370       }
56371       dispatch14.call("toggled", this, true);
56372     };
56373     function updatePosition() {
56374       if (!_menu || _menu.empty()) return;
56375       var anchorLoc = context.projection(_anchorLocLonLat);
56376       var viewport = context.surfaceRect();
56377       if (anchorLoc[0] < 0 || anchorLoc[0] > viewport.width || anchorLoc[1] < 0 || anchorLoc[1] > viewport.height) {
56378         editMenu.close();
56379         return;
56380       }
56381       var menuLeft = displayOnLeft(viewport);
56382       var offset = [0, 0];
56383       offset[0] = menuLeft ? -1 * (_menuSideMargin + _menuWidth) : _menuSideMargin;
56384       if (_menuTop) {
56385         if (anchorLoc[1] - _menuHeight < _vpTopMargin) {
56386           offset[1] = -anchorLoc[1] + _vpTopMargin;
56387         } else {
56388           offset[1] = -_menuHeight;
56389         }
56390       } else {
56391         if (anchorLoc[1] + _menuHeight > viewport.height - _vpBottomMargin) {
56392           offset[1] = -anchorLoc[1] - _menuHeight + viewport.height - _vpBottomMargin;
56393         } else {
56394           offset[1] = 0;
56395         }
56396       }
56397       var origin = geoVecAdd(anchorLoc, offset);
56398       var _verticalOffset = parseFloat(utilGetDimensions(select_default2(".top-toolbar-wrap"))[1]);
56399       origin[1] -= _verticalOffset;
56400       _menu.style("left", origin[0] + "px").style("top", origin[1] + "px");
56401       var tooltipSide = tooltipPosition(viewport, menuLeft);
56402       _tooltips.forEach(function(tooltip) {
56403         tooltip.placement(tooltipSide);
56404       });
56405       function displayOnLeft(viewport2) {
56406         if (_mainLocalizer.textDirection() === "ltr") {
56407           if (anchorLoc[0] + _menuSideMargin + _menuWidth > viewport2.width - _vpSideMargin) {
56408             return true;
56409           }
56410           return false;
56411         } else {
56412           if (anchorLoc[0] - _menuSideMargin - _menuWidth < _vpSideMargin) {
56413             return false;
56414           }
56415           return true;
56416         }
56417       }
56418       function tooltipPosition(viewport2, menuLeft2) {
56419         if (_mainLocalizer.textDirection() === "ltr") {
56420           if (menuLeft2) {
56421             return "left";
56422           }
56423           if (anchorLoc[0] + _menuSideMargin + _menuWidth + _tooltipWidth > viewport2.width - _vpSideMargin) {
56424             return "left";
56425           }
56426           return "right";
56427         } else {
56428           if (!menuLeft2) {
56429             return "right";
56430           }
56431           if (anchorLoc[0] - _menuSideMargin - _menuWidth - _tooltipWidth < _vpSideMargin) {
56432             return "right";
56433           }
56434           return "left";
56435         }
56436       }
56437     }
56438     editMenu.close = function() {
56439       context.map().on("move.edit-menu", null).on("drawn.edit-menu", null);
56440       _menu.remove();
56441       _tooltips = [];
56442       dispatch14.call("toggled", this, false);
56443     };
56444     editMenu.anchorLoc = function(val) {
56445       if (!arguments.length) return _anchorLoc;
56446       _anchorLoc = val;
56447       _anchorLocLonLat = context.projection.invert(_anchorLoc);
56448       return editMenu;
56449     };
56450     editMenu.triggerType = function(val) {
56451       if (!arguments.length) return _triggerType;
56452       _triggerType = val;
56453       return editMenu;
56454     };
56455     editMenu.operations = function(val) {
56456       if (!arguments.length) return _operations;
56457       _operations = val;
56458       return editMenu;
56459     };
56460     return utilRebind(editMenu, dispatch14, "on");
56461   }
56462
56463   // modules/ui/feature_info.js
56464   function uiFeatureInfo(context) {
56465     function update(selection2) {
56466       var features = context.features();
56467       var stats = features.stats();
56468       var count = 0;
56469       var hiddenList = features.hidden().map(function(k2) {
56470         if (stats[k2]) {
56471           count += stats[k2];
56472           return _t.append("inspector.title_count", {
56473             title: _t("feature." + k2 + ".description"),
56474             count: stats[k2]
56475           });
56476         }
56477         return null;
56478       }).filter(Boolean);
56479       selection2.text("");
56480       if (hiddenList.length) {
56481         var tooltipBehavior = uiTooltip().placement("top").title(function() {
56482           return (selection3) => {
56483             hiddenList.forEach((hiddenFeature) => {
56484               selection3.append("div").call(hiddenFeature);
56485             });
56486           };
56487         });
56488         selection2.append("a").attr("class", "chip").attr("href", "#").call(_t.append("feature_info.hidden_warning", { count })).call(tooltipBehavior).on("click", function(d3_event) {
56489           tooltipBehavior.hide();
56490           d3_event.preventDefault();
56491           context.ui().togglePanes(context.container().select(".map-panes .map-data-pane"));
56492         });
56493       }
56494       selection2.classed("hide", !hiddenList.length);
56495     }
56496     return function(selection2) {
56497       update(selection2);
56498       context.features().on("change.feature_info", function() {
56499         update(selection2);
56500       });
56501     };
56502   }
56503
56504   // modules/ui/flash.js
56505   function uiFlash(context) {
56506     var _flashTimer;
56507     var _duration = 2e3;
56508     var _iconName = "#iD-icon-no";
56509     var _iconClass = "disabled";
56510     var _label = (s2) => s2.text("");
56511     function flash() {
56512       if (_flashTimer) {
56513         _flashTimer.stop();
56514       }
56515       context.container().select(".main-footer-wrap").classed("footer-hide", true).classed("footer-show", false);
56516       context.container().select(".flash-wrap").classed("footer-hide", false).classed("footer-show", true);
56517       var content = context.container().select(".flash-wrap").selectAll(".flash-content").data([0]);
56518       var contentEnter = content.enter().append("div").attr("class", "flash-content");
56519       var iconEnter = contentEnter.append("svg").attr("class", "flash-icon icon").append("g").attr("transform", "translate(10,10)");
56520       iconEnter.append("circle").attr("r", 9);
56521       iconEnter.append("use").attr("transform", "translate(-7,-7)").attr("width", "14").attr("height", "14");
56522       contentEnter.append("div").attr("class", "flash-text");
56523       content = content.merge(contentEnter);
56524       content.selectAll(".flash-icon").attr("class", "icon flash-icon " + (_iconClass || ""));
56525       content.selectAll(".flash-icon use").attr("xlink:href", _iconName);
56526       content.selectAll(".flash-text").attr("class", "flash-text").call(_label);
56527       _flashTimer = timeout_default(function() {
56528         _flashTimer = null;
56529         context.container().select(".main-footer-wrap").classed("footer-hide", false).classed("footer-show", true);
56530         context.container().select(".flash-wrap").classed("footer-hide", true).classed("footer-show", false);
56531       }, _duration);
56532       return content;
56533     }
56534     flash.duration = function(_2) {
56535       if (!arguments.length) return _duration;
56536       _duration = _2;
56537       return flash;
56538     };
56539     flash.label = function(_2) {
56540       if (!arguments.length) return _label;
56541       if (typeof _2 !== "function") {
56542         _label = (selection2) => selection2.text(_2);
56543       } else {
56544         _label = (selection2) => selection2.text("").call(_2);
56545       }
56546       return flash;
56547     };
56548     flash.iconName = function(_2) {
56549       if (!arguments.length) return _iconName;
56550       _iconName = _2;
56551       return flash;
56552     };
56553     flash.iconClass = function(_2) {
56554       if (!arguments.length) return _iconClass;
56555       _iconClass = _2;
56556       return flash;
56557     };
56558     return flash;
56559   }
56560
56561   // modules/ui/full_screen.js
56562   function uiFullScreen(context) {
56563     var element = context.container().node();
56564     function getFullScreenFn() {
56565       if (element.requestFullscreen) {
56566         return element.requestFullscreen;
56567       } else if (element.msRequestFullscreen) {
56568         return element.msRequestFullscreen;
56569       } else if (element.mozRequestFullScreen) {
56570         return element.mozRequestFullScreen;
56571       } else if (element.webkitRequestFullscreen) {
56572         return element.webkitRequestFullscreen;
56573       }
56574     }
56575     function getExitFullScreenFn() {
56576       if (document.exitFullscreen) {
56577         return document.exitFullscreen;
56578       } else if (document.msExitFullscreen) {
56579         return document.msExitFullscreen;
56580       } else if (document.mozCancelFullScreen) {
56581         return document.mozCancelFullScreen;
56582       } else if (document.webkitExitFullscreen) {
56583         return document.webkitExitFullscreen;
56584       }
56585     }
56586     function isFullScreen() {
56587       return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement;
56588     }
56589     function isSupported() {
56590       return !!getFullScreenFn();
56591     }
56592     function fullScreen(d3_event) {
56593       d3_event.preventDefault();
56594       if (!isFullScreen()) {
56595         getFullScreenFn().apply(element);
56596       } else {
56597         getExitFullScreenFn().apply(document);
56598       }
56599     }
56600     return function() {
56601       if (!isSupported()) return;
56602       var detected = utilDetect();
56603       var keys2 = detected.os === "mac" ? [uiCmd("\u2303\u2318F"), "f11"] : ["f11"];
56604       context.keybinding().on(keys2, fullScreen);
56605     };
56606   }
56607
56608   // modules/ui/geolocate.js
56609   function uiGeolocate(context) {
56610     var _geolocationOptions = {
56611       // prioritize speed and power usage over precision
56612       enableHighAccuracy: false,
56613       // don't hang indefinitely getting the location
56614       timeout: 6e3
56615       // 6sec
56616     };
56617     var _locating = uiLoading(context).message(_t.html("geolocate.locating")).blocking(true);
56618     var _layer = context.layers().layer("geolocate");
56619     var _position;
56620     var _extent;
56621     var _timeoutID;
56622     var _button = select_default2(null);
56623     function click() {
56624       if (context.inIntro()) return;
56625       if (!_layer.enabled() && !_locating.isShown()) {
56626         _timeoutID = setTimeout(
56627           error,
56628           1e4
56629           /* 10sec */
56630         );
56631         context.container().call(_locating);
56632         navigator.geolocation.getCurrentPosition(success, error, _geolocationOptions);
56633       } else {
56634         _locating.close();
56635         _layer.enabled(null, false);
56636         updateButtonState();
56637       }
56638     }
56639     function zoomTo() {
56640       context.enter(modeBrowse(context));
56641       var map2 = context.map();
56642       _layer.enabled(_position, true);
56643       updateButtonState();
56644       map2.centerZoomEase(_extent.center(), Math.min(20, map2.extentZoom(_extent)));
56645     }
56646     function success(geolocation) {
56647       _position = geolocation;
56648       var coords = _position.coords;
56649       _extent = geoExtent([coords.longitude, coords.latitude]).padByMeters(coords.accuracy);
56650       zoomTo();
56651       finish();
56652     }
56653     function error() {
56654       if (_position) {
56655         zoomTo();
56656       } else {
56657         context.ui().flash.label(_t.append("geolocate.location_unavailable")).iconName("#iD-icon-geolocate")();
56658       }
56659       finish();
56660     }
56661     function finish() {
56662       _locating.close();
56663       if (_timeoutID) {
56664         clearTimeout(_timeoutID);
56665       }
56666       _timeoutID = void 0;
56667     }
56668     function updateButtonState() {
56669       _button.classed("active", _layer.enabled());
56670       _button.attr("aria-pressed", _layer.enabled());
56671     }
56672     return function(selection2) {
56673       if (!navigator.geolocation || !navigator.geolocation.getCurrentPosition) return;
56674       _button = selection2.append("button").on("click", click).attr("aria-pressed", false).call(svgIcon("#iD-icon-geolocate", "light")).call(
56675         uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _t.append("geolocate.title"))
56676       );
56677     };
56678   }
56679
56680   // modules/ui/panels/background.js
56681   function uiPanelBackground(context) {
56682     var background = context.background();
56683     var _currSourceName = null;
56684     var _metadata = {};
56685     var _metadataKeys = [
56686       "zoom",
56687       "vintage",
56688       "source",
56689       "description",
56690       "resolution",
56691       "accuracy"
56692     ];
56693     var debouncedRedraw = debounce_default(redraw, 250);
56694     function redraw(selection2) {
56695       var source = background.baseLayerSource();
56696       if (!source) return;
56697       var isDG = source.id.match(/^DigitalGlobe/i) !== null;
56698       var sourceLabel = source.label();
56699       if (_currSourceName !== sourceLabel) {
56700         _currSourceName = sourceLabel;
56701         _metadata = {};
56702       }
56703       selection2.text("");
56704       var list2 = selection2.append("ul").attr("class", "background-info");
56705       list2.append("li").call(_currSourceName);
56706       _metadataKeys.forEach(function(k2) {
56707         if (isDG && k2 === "vintage") return;
56708         list2.append("li").attr("class", "background-info-list-" + k2).classed("hide", !_metadata[k2]).call(_t.append("info_panels.background." + k2, { suffix: ":" })).append("span").attr("class", "background-info-span-" + k2).text(_metadata[k2]);
56709       });
56710       debouncedGetMetadata(selection2);
56711       var toggleTiles = context.getDebug("tile") ? "hide_tiles" : "show_tiles";
56712       selection2.append("a").call(_t.append("info_panels.background." + toggleTiles)).attr("href", "#").attr("class", "button button-toggle-tiles").on("click", function(d3_event) {
56713         d3_event.preventDefault();
56714         context.setDebug("tile", !context.getDebug("tile"));
56715         selection2.call(redraw);
56716       });
56717       if (isDG) {
56718         var key = source.id + "-vintage";
56719         var sourceVintage = context.background().findSource(key);
56720         var showsVintage = context.background().showsLayer(sourceVintage);
56721         var toggleVintage = showsVintage ? "hide_vintage" : "show_vintage";
56722         selection2.append("a").call(_t.append("info_panels.background." + toggleVintage)).attr("href", "#").attr("class", "button button-toggle-vintage").on("click", function(d3_event) {
56723           d3_event.preventDefault();
56724           context.background().toggleOverlayLayer(sourceVintage);
56725           selection2.call(redraw);
56726         });
56727       }
56728       ["DigitalGlobe-Premium", "DigitalGlobe-Standard"].forEach(function(layerId) {
56729         if (source.id !== layerId) {
56730           var key2 = layerId + "-vintage";
56731           var sourceVintage2 = context.background().findSource(key2);
56732           if (context.background().showsLayer(sourceVintage2)) {
56733             context.background().toggleOverlayLayer(sourceVintage2);
56734           }
56735         }
56736       });
56737     }
56738     var debouncedGetMetadata = debounce_default(getMetadata, 250);
56739     function getMetadata(selection2) {
56740       var tile = context.container().select(".layer-background img.tile-center");
56741       if (tile.empty()) return;
56742       var sourceName = _currSourceName;
56743       var d2 = tile.datum();
56744       var zoom = d2 && d2.length >= 3 && d2[2] || Math.floor(context.map().zoom());
56745       var center = context.map().center();
56746       _metadata.zoom = String(zoom);
56747       selection2.selectAll(".background-info-list-zoom").classed("hide", false).selectAll(".background-info-span-zoom").text(_metadata.zoom);
56748       if (!d2 || !d2.length >= 3) return;
56749       background.baseLayerSource().getMetadata(center, d2, function(err, result) {
56750         if (err || _currSourceName !== sourceName) return;
56751         var vintage = result.vintage;
56752         _metadata.vintage = vintage && vintage.range || _t("info_panels.background.unknown");
56753         selection2.selectAll(".background-info-list-vintage").classed("hide", false).selectAll(".background-info-span-vintage").text(_metadata.vintage);
56754         _metadataKeys.forEach(function(k2) {
56755           if (k2 === "zoom" || k2 === "vintage") return;
56756           var val = result[k2];
56757           _metadata[k2] = val;
56758           selection2.selectAll(".background-info-list-" + k2).classed("hide", !val).selectAll(".background-info-span-" + k2).text(val);
56759         });
56760       });
56761     }
56762     var panel = function(selection2) {
56763       selection2.call(redraw);
56764       context.map().on("drawn.info-background", function() {
56765         selection2.call(debouncedRedraw);
56766       }).on("move.info-background", function() {
56767         selection2.call(debouncedGetMetadata);
56768       });
56769     };
56770     panel.off = function() {
56771       context.map().on("drawn.info-background", null).on("move.info-background", null);
56772     };
56773     panel.id = "background";
56774     panel.label = _t.append("info_panels.background.title");
56775     panel.key = _t("info_panels.background.key");
56776     return panel;
56777   }
56778
56779   // modules/ui/panels/history.js
56780   function uiPanelHistory(context) {
56781     var osm;
56782     function displayTimestamp(timestamp) {
56783       if (!timestamp) return _t("info_panels.history.unknown");
56784       var options2 = {
56785         day: "numeric",
56786         month: "short",
56787         year: "numeric",
56788         hour: "numeric",
56789         minute: "numeric",
56790         second: "numeric"
56791       };
56792       var d2 = new Date(timestamp);
56793       if (isNaN(d2.getTime())) return _t("info_panels.history.unknown");
56794       return d2.toLocaleString(_mainLocalizer.localeCode(), options2);
56795     }
56796     function displayUser(selection2, userName) {
56797       if (!userName) {
56798         selection2.append("span").call(_t.append("info_panels.history.unknown"));
56799         return;
56800       }
56801       selection2.append("span").attr("class", "user-name").text(userName);
56802       var links = selection2.append("div").attr("class", "links");
56803       if (osm) {
56804         links.append("a").attr("class", "user-osm-link").attr("href", osm.userURL(userName)).attr("target", "_blank").call(_t.append("info_panels.history.profile_link"));
56805       }
56806       links.append("a").attr("class", "user-hdyc-link").attr("href", "https://hdyc.neis-one.org/?" + userName).attr("target", "_blank").attr("tabindex", -1).text("HDYC");
56807     }
56808     function displayChangeset(selection2, changeset) {
56809       if (!changeset) {
56810         selection2.append("span").call(_t.append("info_panels.history.unknown"));
56811         return;
56812       }
56813       selection2.append("span").attr("class", "changeset-id").text(changeset);
56814       var links = selection2.append("div").attr("class", "links");
56815       if (osm) {
56816         links.append("a").attr("class", "changeset-osm-link").attr("href", osm.changesetURL(changeset)).attr("target", "_blank").call(_t.append("info_panels.history.changeset_link"));
56817       }
56818       links.append("a").attr("class", "changeset-osmcha-link").attr("href", "https://osmcha.org/changesets/" + changeset).attr("target", "_blank").text("OSMCha");
56819       links.append("a").attr("class", "changeset-achavi-link").attr("href", "https://overpass-api.de/achavi/?changeset=" + changeset).attr("target", "_blank").text("Achavi");
56820     }
56821     function redraw(selection2) {
56822       var selectedNoteID = context.selectedNoteID();
56823       osm = context.connection();
56824       var selected, note, entity;
56825       if (selectedNoteID && osm) {
56826         selected = [_t.html("note.note") + " " + selectedNoteID];
56827         note = osm.getNote(selectedNoteID);
56828       } else {
56829         selected = context.selectedIDs().filter(function(e3) {
56830           return context.hasEntity(e3);
56831         });
56832         if (selected.length) {
56833           entity = context.entity(selected[0]);
56834         }
56835       }
56836       var singular = selected.length === 1 ? selected[0] : null;
56837       selection2.html("");
56838       if (singular) {
56839         selection2.append("h4").attr("class", "history-heading").html(singular);
56840       } else {
56841         selection2.append("h4").attr("class", "history-heading").call(_t.append("info_panels.selected", { n: selected.length }));
56842       }
56843       if (!singular) return;
56844       if (entity) {
56845         selection2.call(redrawEntity, entity);
56846       } else if (note) {
56847         selection2.call(redrawNote, note);
56848       }
56849     }
56850     function redrawNote(selection2, note) {
56851       if (!note || note.isNew()) {
56852         selection2.append("div").call(_t.append("info_panels.history.note_no_history"));
56853         return;
56854       }
56855       var list2 = selection2.append("ul");
56856       list2.append("li").call(_t.append("info_panels.history.note_comments", { suffix: ":" })).append("span").text(note.comments.length);
56857       if (note.comments.length) {
56858         list2.append("li").call(_t.append("info_panels.history.note_created_date", { suffix: ":" })).append("span").text(displayTimestamp(note.comments[0].date));
56859         list2.append("li").call(_t.append("info_panels.history.note_created_user", { suffix: ":" })).call(displayUser, note.comments[0].user);
56860       }
56861       if (osm) {
56862         selection2.append("a").attr("class", "view-history-on-osm").attr("target", "_blank").attr("href", osm.noteURL(note)).call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append("info_panels.history.note_link_text"));
56863       }
56864     }
56865     function redrawEntity(selection2, entity) {
56866       if (!entity || entity.isNew()) {
56867         selection2.append("div").call(_t.append("info_panels.history.no_history"));
56868         return;
56869       }
56870       var links = selection2.append("div").attr("class", "links");
56871       if (osm) {
56872         links.append("a").attr("class", "view-history-on-osm").attr("href", osm.historyURL(entity)).attr("target", "_blank").call(_t.append("info_panels.history.history_link"));
56873       }
56874       links.append("a").attr("class", "pewu-history-viewer-link").attr("href", "https://pewu.github.io/osm-history/#/" + entity.type + "/" + entity.osmId()).attr("target", "_blank").attr("tabindex", -1).text("PeWu");
56875       var list2 = selection2.append("ul");
56876       list2.append("li").call(_t.append("info_panels.history.version", { suffix: ":" })).append("span").text(entity.version);
56877       list2.append("li").call(_t.append("info_panels.history.last_edit", { suffix: ":" })).append("span").text(displayTimestamp(entity.timestamp));
56878       list2.append("li").call(_t.append("info_panels.history.edited_by", { suffix: ":" })).call(displayUser, entity.user);
56879       list2.append("li").call(_t.append("info_panels.history.changeset", { suffix: ":" })).call(displayChangeset, entity.changeset);
56880     }
56881     var panel = function(selection2) {
56882       selection2.call(redraw);
56883       context.map().on("drawn.info-history", function() {
56884         selection2.call(redraw);
56885       });
56886       context.on("enter.info-history", function() {
56887         selection2.call(redraw);
56888       });
56889     };
56890     panel.off = function() {
56891       context.map().on("drawn.info-history", null);
56892       context.on("enter.info-history", null);
56893     };
56894     panel.id = "history";
56895     panel.label = _t.append("info_panels.history.title");
56896     panel.key = _t("info_panels.history.key");
56897     return panel;
56898   }
56899
56900   // modules/ui/panels/location.js
56901   function uiPanelLocation(context) {
56902     var currLocation = "";
56903     function redraw(selection2) {
56904       selection2.html("");
56905       var list2 = selection2.append("ul");
56906       var coord2 = context.map().mouseCoordinates();
56907       if (coord2.some(isNaN)) {
56908         coord2 = context.map().center();
56909       }
56910       list2.append("li").text(dmsCoordinatePair(coord2)).append("li").text(decimalCoordinatePair(coord2));
56911       selection2.append("div").attr("class", "location-info").text(currLocation || " ");
56912       debouncedGetLocation(selection2, coord2);
56913     }
56914     var debouncedGetLocation = debounce_default(getLocation, 250);
56915     function getLocation(selection2, coord2) {
56916       if (!services.geocoder) {
56917         currLocation = _t("info_panels.location.unknown_location");
56918         selection2.selectAll(".location-info").text(currLocation);
56919       } else {
56920         services.geocoder.reverse(coord2, function(err, result) {
56921           currLocation = result ? result.display_name : _t("info_panels.location.unknown_location");
56922           selection2.selectAll(".location-info").text(currLocation);
56923         });
56924       }
56925     }
56926     var panel = function(selection2) {
56927       selection2.call(redraw);
56928       context.surface().on(("PointerEvent" in window ? "pointer" : "mouse") + "move.info-location", function() {
56929         selection2.call(redraw);
56930       });
56931     };
56932     panel.off = function() {
56933       context.surface().on(".info-location", null);
56934     };
56935     panel.id = "location";
56936     panel.label = _t.append("info_panels.location.title");
56937     panel.key = _t("info_panels.location.key");
56938     return panel;
56939   }
56940
56941   // modules/ui/panels/measurement.js
56942   function uiPanelMeasurement(context) {
56943     function radiansToMeters(r2) {
56944       return r2 * 63710071809e-4;
56945     }
56946     function steradiansToSqmeters(r2) {
56947       return r2 / (4 * Math.PI) * 510065621724e3;
56948     }
56949     function toLineString(feature3) {
56950       if (feature3.type === "LineString") return feature3;
56951       var result = { type: "LineString", coordinates: [] };
56952       if (feature3.type === "Polygon") {
56953         result.coordinates = feature3.coordinates[0];
56954       } else if (feature3.type === "MultiPolygon") {
56955         result.coordinates = feature3.coordinates[0][0];
56956       }
56957       return result;
56958     }
56959     var _isImperial = !_mainLocalizer.usesMetric();
56960     function redraw(selection2) {
56961       var graph = context.graph();
56962       var selectedNoteID = context.selectedNoteID();
56963       var osm = services.osm;
56964       var localeCode = _mainLocalizer.localeCode();
56965       var heading2;
56966       var center, location, centroid;
56967       var closed, geometry;
56968       var totalNodeCount, length2 = 0, area = 0, distance;
56969       if (selectedNoteID && osm) {
56970         var note = osm.getNote(selectedNoteID);
56971         heading2 = _t.html("note.note") + " " + selectedNoteID;
56972         location = note.loc;
56973         geometry = "note";
56974       } else {
56975         var selectedIDs = context.selectedIDs().filter(function(id2) {
56976           return context.hasEntity(id2);
56977         });
56978         var selected = selectedIDs.map(function(id2) {
56979           return context.entity(id2);
56980         });
56981         heading2 = selected.length === 1 ? selected[0].id : _t.html("info_panels.selected", { n: selected.length });
56982         if (selected.length) {
56983           var extent = geoExtent();
56984           for (var i3 in selected) {
56985             var entity = selected[i3];
56986             extent._extend(entity.extent(graph));
56987             geometry = entity.geometry(graph);
56988             if (geometry === "line" || geometry === "area") {
56989               closed = entity.type === "relation" || entity.isClosed() && !entity.isDegenerate();
56990               var feature3 = entity.asGeoJSON(graph);
56991               length2 += radiansToMeters(length_default(toLineString(feature3)));
56992               centroid = path_default(context.projection).centroid(entity.asGeoJSON(graph));
56993               centroid = centroid && context.projection.invert(centroid);
56994               if (!centroid || !isFinite(centroid[0]) || !isFinite(centroid[1])) {
56995                 centroid = entity.extent(graph).center();
56996               }
56997               if (closed) {
56998                 area += steradiansToSqmeters(entity.area(graph));
56999               }
57000             }
57001           }
57002           if (selected.length > 1) {
57003             geometry = null;
57004             closed = null;
57005             centroid = null;
57006           }
57007           if (selected.length === 2 && selected[0].type === "node" && selected[1].type === "node") {
57008             distance = geoSphericalDistance(selected[0].loc, selected[1].loc);
57009           }
57010           if (selected.length === 1 && selected[0].type === "node") {
57011             location = selected[0].loc;
57012           } else {
57013             totalNodeCount = utilGetAllNodes(selectedIDs, context.graph()).length;
57014           }
57015           if (!location && !centroid) {
57016             center = extent.center();
57017           }
57018         }
57019       }
57020       selection2.html("");
57021       if (heading2) {
57022         selection2.append("h4").attr("class", "measurement-heading").html(heading2);
57023       }
57024       var list2 = selection2.append("ul");
57025       var coordItem;
57026       if (geometry) {
57027         list2.append("li").call(_t.append("info_panels.measurement.geometry", { suffix: ":" })).append("span").html(
57028           closed ? _t.html("info_panels.measurement.closed_" + geometry) : _t.html("geometry." + geometry)
57029         );
57030       }
57031       if (totalNodeCount) {
57032         list2.append("li").call(_t.append("info_panels.measurement.node_count", { suffix: ":" })).append("span").text(totalNodeCount.toLocaleString(localeCode));
57033       }
57034       if (area) {
57035         list2.append("li").call(_t.append("info_panels.measurement.area", { suffix: ":" })).append("span").text(displayArea(area, _isImperial));
57036       }
57037       if (length2) {
57038         list2.append("li").call(_t.append("info_panels.measurement." + (closed ? "perimeter" : "length"), { suffix: ":" })).append("span").text(displayLength(length2, _isImperial));
57039       }
57040       if (typeof distance === "number") {
57041         list2.append("li").call(_t.append("info_panels.measurement.distance", { suffix: ":" })).append("span").text(displayLength(distance, _isImperial));
57042       }
57043       if (location) {
57044         coordItem = list2.append("li").call(_t.append("info_panels.measurement.location", { suffix: ":" }));
57045         coordItem.append("span").text(dmsCoordinatePair(location));
57046         coordItem.append("span").text(decimalCoordinatePair(location));
57047       }
57048       if (centroid) {
57049         coordItem = list2.append("li").call(_t.append("info_panels.measurement.centroid", { suffix: ":" }));
57050         coordItem.append("span").text(dmsCoordinatePair(centroid));
57051         coordItem.append("span").text(decimalCoordinatePair(centroid));
57052       }
57053       if (center) {
57054         coordItem = list2.append("li").call(_t.append("info_panels.measurement.center", { suffix: ":" }));
57055         coordItem.append("span").text(dmsCoordinatePair(center));
57056         coordItem.append("span").text(decimalCoordinatePair(center));
57057       }
57058       if (length2 || area || typeof distance === "number") {
57059         var toggle = _isImperial ? "imperial" : "metric";
57060         selection2.append("a").call(_t.append("info_panels.measurement." + toggle)).attr("href", "#").attr("class", "button button-toggle-units").on("click", function(d3_event) {
57061           d3_event.preventDefault();
57062           _isImperial = !_isImperial;
57063           selection2.call(redraw);
57064         });
57065       }
57066     }
57067     var panel = function(selection2) {
57068       selection2.call(redraw);
57069       context.map().on("drawn.info-measurement", function() {
57070         selection2.call(redraw);
57071       });
57072       context.on("enter.info-measurement", function() {
57073         selection2.call(redraw);
57074       });
57075     };
57076     panel.off = function() {
57077       context.map().on("drawn.info-measurement", null);
57078       context.on("enter.info-measurement", null);
57079     };
57080     panel.id = "measurement";
57081     panel.label = _t.append("info_panels.measurement.title");
57082     panel.key = _t("info_panels.measurement.key");
57083     return panel;
57084   }
57085
57086   // modules/ui/panels/index.js
57087   var uiInfoPanels = {
57088     background: uiPanelBackground,
57089     history: uiPanelHistory,
57090     location: uiPanelLocation,
57091     measurement: uiPanelMeasurement
57092   };
57093
57094   // modules/ui/info.js
57095   function uiInfo(context) {
57096     var ids = Object.keys(uiInfoPanels);
57097     var wasActive = ["measurement"];
57098     var panels = {};
57099     var active = {};
57100     ids.forEach(function(k2) {
57101       if (!panels[k2]) {
57102         panels[k2] = uiInfoPanels[k2](context);
57103         active[k2] = false;
57104       }
57105     });
57106     function info(selection2) {
57107       function redraw() {
57108         var activeids = ids.filter(function(k2) {
57109           return active[k2];
57110         }).sort();
57111         var containers = infoPanels.selectAll(".panel-container").data(activeids, function(k2) {
57112           return k2;
57113         });
57114         containers.exit().style("opacity", 1).transition().duration(200).style("opacity", 0).on("end", function(d2) {
57115           select_default2(this).call(panels[d2].off).remove();
57116         });
57117         var enter = containers.enter().append("div").attr("class", function(d2) {
57118           return "fillD2 panel-container panel-container-" + d2;
57119         });
57120         enter.style("opacity", 0).transition().duration(200).style("opacity", 1);
57121         var title = enter.append("div").attr("class", "panel-title fillD2");
57122         title.append("h3").each(function(d2) {
57123           return panels[d2].label(select_default2(this));
57124         });
57125         title.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function(d3_event, d2) {
57126           d3_event.stopImmediatePropagation();
57127           d3_event.preventDefault();
57128           info.toggle(d2);
57129         }).call(svgIcon("#iD-icon-close"));
57130         enter.append("div").attr("class", function(d2) {
57131           return "panel-content panel-content-" + d2;
57132         });
57133         infoPanels.selectAll(".panel-content").each(function(d2) {
57134           select_default2(this).call(panels[d2]);
57135         });
57136       }
57137       info.toggle = function(which) {
57138         var activeids = ids.filter(function(k2) {
57139           return active[k2];
57140         });
57141         if (which) {
57142           active[which] = !active[which];
57143           if (activeids.length === 1 && activeids[0] === which) {
57144             wasActive = [which];
57145           }
57146           context.container().select("." + which + "-panel-toggle-item").classed("active", active[which]).select("input").property("checked", active[which]);
57147         } else {
57148           if (activeids.length) {
57149             wasActive = activeids;
57150             activeids.forEach(function(k2) {
57151               active[k2] = false;
57152             });
57153           } else {
57154             wasActive.forEach(function(k2) {
57155               active[k2] = true;
57156             });
57157           }
57158         }
57159         redraw();
57160       };
57161       var infoPanels = selection2.selectAll(".info-panels").data([0]);
57162       infoPanels = infoPanels.enter().append("div").attr("class", "info-panels").merge(infoPanels);
57163       redraw();
57164       context.keybinding().on(uiCmd("\u2318" + _t("info_panels.key")), function(d3_event) {
57165         d3_event.stopImmediatePropagation();
57166         d3_event.preventDefault();
57167         info.toggle();
57168       });
57169       ids.forEach(function(k2) {
57170         var key = _t("info_panels." + k2 + ".key", { default: null });
57171         if (!key) return;
57172         context.keybinding().on(uiCmd("\u2318\u21E7" + key), function(d3_event) {
57173           d3_event.stopImmediatePropagation();
57174           d3_event.preventDefault();
57175           info.toggle(k2);
57176         });
57177       });
57178     }
57179     return info;
57180   }
57181
57182   // modules/ui/toggle.js
57183   function uiToggle(show, callback) {
57184     return function(selection2) {
57185       selection2.style("opacity", show ? 0 : 1).classed("hide", false).transition().style("opacity", show ? 1 : 0).on("end", function() {
57186         select_default2(this).classed("hide", !show).style("opacity", null);
57187         if (callback) callback.apply(this);
57188       });
57189     };
57190   }
57191
57192   // modules/ui/curtain.js
57193   function uiCurtain(containerNode) {
57194     var surface = select_default2(null), tooltip = select_default2(null), darkness = select_default2(null);
57195     function curtain(selection2) {
57196       surface = selection2.append("svg").attr("class", "curtain").style("top", 0).style("left", 0);
57197       darkness = surface.append("path").attr("x", 0).attr("y", 0).attr("class", "curtain-darkness");
57198       select_default2(window).on("resize.curtain", resize);
57199       tooltip = selection2.append("div").attr("class", "tooltip");
57200       tooltip.append("div").attr("class", "popover-arrow");
57201       tooltip.append("div").attr("class", "popover-inner");
57202       resize();
57203       function resize() {
57204         surface.attr("width", containerNode.clientWidth).attr("height", containerNode.clientHeight);
57205         curtain.cut(darkness.datum());
57206       }
57207     }
57208     curtain.reveal = function(box, html3, options2) {
57209       options2 = options2 || {};
57210       if (typeof box === "string") {
57211         box = select_default2(box).node();
57212       }
57213       if (box && box.getBoundingClientRect) {
57214         box = copyBox(box.getBoundingClientRect());
57215       }
57216       if (box) {
57217         var containerRect = containerNode.getBoundingClientRect();
57218         box.top -= containerRect.top;
57219         box.left -= containerRect.left;
57220       }
57221       if (box && options2.padding) {
57222         box.top -= options2.padding;
57223         box.left -= options2.padding;
57224         box.bottom += options2.padding;
57225         box.right += options2.padding;
57226         box.height += options2.padding * 2;
57227         box.width += options2.padding * 2;
57228       }
57229       var tooltipBox;
57230       if (options2.tooltipBox) {
57231         tooltipBox = options2.tooltipBox;
57232         if (typeof tooltipBox === "string") {
57233           tooltipBox = select_default2(tooltipBox).node();
57234         }
57235         if (tooltipBox && tooltipBox.getBoundingClientRect) {
57236           tooltipBox = copyBox(tooltipBox.getBoundingClientRect());
57237         }
57238       } else {
57239         tooltipBox = box;
57240       }
57241       if (tooltipBox && html3) {
57242         if (html3.indexOf("**") !== -1) {
57243           if (html3.indexOf("<span") === 0) {
57244             html3 = html3.replace(/^(<span.*?>)(.+?)(\*\*)/, "$1<span>$2</span>$3");
57245           } else {
57246             html3 = html3.replace(/^(.+?)(\*\*)/, "<span>$1</span>$2");
57247           }
57248           html3 = html3.replace(/\*\*(.*?)\*\*/g, '<span class="instruction">$1</span>');
57249         }
57250         html3 = html3.replace(/\*(.*?)\*/g, "<em>$1</em>");
57251         html3 = html3.replace(/\{br\}/g, "<br/><br/>");
57252         if (options2.buttonText && options2.buttonCallback) {
57253           html3 += '<div class="button-section"><button href="#" class="button action">' + options2.buttonText + "</button></div>";
57254         }
57255         var classes = "curtain-tooltip popover tooltip arrowed in " + (options2.tooltipClass || "");
57256         tooltip.classed(classes, true).selectAll(".popover-inner").html(html3);
57257         if (options2.buttonText && options2.buttonCallback) {
57258           var button = tooltip.selectAll(".button-section .button.action");
57259           button.on("click", function(d3_event) {
57260             d3_event.preventDefault();
57261             options2.buttonCallback();
57262           });
57263         }
57264         var tip = copyBox(tooltip.node().getBoundingClientRect()), w2 = containerNode.clientWidth, h2 = containerNode.clientHeight, tooltipWidth = 200, tooltipArrow = 5, side, pos;
57265         if (options2.tooltipClass === "intro-mouse") {
57266           tip.height += 80;
57267         }
57268         if (tooltipBox.top + tooltipBox.height > h2) {
57269           tooltipBox.height -= tooltipBox.top + tooltipBox.height - h2;
57270         }
57271         if (tooltipBox.left + tooltipBox.width > w2) {
57272           tooltipBox.width -= tooltipBox.left + tooltipBox.width - w2;
57273         }
57274         const onLeftOrRightEdge = tooltipBox.left + tooltipBox.width / 2 > w2 - 100 || tooltipBox.left + tooltipBox.width / 2 < 100;
57275         if (tooltipBox.top + tooltipBox.height < 100 && !onLeftOrRightEdge) {
57276           side = "bottom";
57277           pos = [
57278             tooltipBox.left + tooltipBox.width / 2 - tip.width / 2,
57279             tooltipBox.top + tooltipBox.height
57280           ];
57281         } else if (tooltipBox.top > h2 - 140 && !onLeftOrRightEdge) {
57282           side = "top";
57283           pos = [
57284             tooltipBox.left + tooltipBox.width / 2 - tip.width / 2,
57285             tooltipBox.top - tip.height
57286           ];
57287         } else {
57288           var tipY = tooltipBox.top + tooltipBox.height / 2 - tip.height / 2;
57289           if (_mainLocalizer.textDirection() === "rtl") {
57290             if (tooltipBox.left - tooltipWidth - tooltipArrow < 70) {
57291               side = "right";
57292               pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY];
57293             } else {
57294               side = "left";
57295               pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY];
57296             }
57297           } else {
57298             if (tooltipBox.left + tooltipBox.width + tooltipArrow + tooltipWidth > w2 - 70) {
57299               side = "left";
57300               pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY];
57301             } else {
57302               side = "right";
57303               pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY];
57304             }
57305           }
57306         }
57307         if (options2.duration !== 0 || !tooltip.classed(side)) {
57308           tooltip.call(uiToggle(true));
57309         }
57310         tooltip.style("top", pos[1] + "px").style("left", pos[0] + "px").attr("class", classes + " " + side);
57311         var shiftY = 0;
57312         if (side === "left" || side === "right") {
57313           if (pos[1] < 60) {
57314             shiftY = 60 - pos[1];
57315           } else if (pos[1] + tip.height > h2 - 100) {
57316             shiftY = h2 - pos[1] - tip.height - 100;
57317           }
57318         }
57319         tooltip.selectAll(".popover-inner").style("top", shiftY + "px");
57320       } else {
57321         tooltip.classed("in", false).call(uiToggle(false));
57322       }
57323       curtain.cut(box, options2.duration);
57324       return tooltip;
57325     };
57326     curtain.cut = function(datum2, duration) {
57327       darkness.datum(datum2).interrupt();
57328       var selection2;
57329       if (duration === 0) {
57330         selection2 = darkness;
57331       } else {
57332         selection2 = darkness.transition().duration(duration || 600).ease(linear2);
57333       }
57334       selection2.attr("d", function(d2) {
57335         var containerWidth = containerNode.clientWidth;
57336         var containerHeight = containerNode.clientHeight;
57337         var string = "M 0,0 L 0," + containerHeight + " L " + containerWidth + "," + containerHeight + "L" + containerWidth + ",0 Z";
57338         if (!d2) return string;
57339         return string + "M" + d2.left + "," + d2.top + "L" + d2.left + "," + (d2.top + d2.height) + "L" + (d2.left + d2.width) + "," + (d2.top + d2.height) + "L" + (d2.left + d2.width) + "," + d2.top + "Z";
57340       });
57341     };
57342     curtain.remove = function() {
57343       surface.remove();
57344       tooltip.remove();
57345       select_default2(window).on("resize.curtain", null);
57346     };
57347     function copyBox(src) {
57348       return {
57349         top: src.top,
57350         right: src.right,
57351         bottom: src.bottom,
57352         left: src.left,
57353         width: src.width,
57354         height: src.height
57355       };
57356     }
57357     return curtain;
57358   }
57359
57360   // modules/ui/intro/welcome.js
57361   function uiIntroWelcome(context, reveal) {
57362     var dispatch14 = dispatch_default("done");
57363     var chapter = {
57364       title: "intro.welcome.title"
57365     };
57366     function welcome() {
57367       context.map().centerZoom([-85.63591, 41.94285], 19);
57368       reveal(
57369         ".intro-nav-wrap .chapter-welcome",
57370         helpHtml("intro.welcome.welcome"),
57371         { buttonText: _t.html("intro.ok"), buttonCallback: practice }
57372       );
57373     }
57374     function practice() {
57375       reveal(
57376         ".intro-nav-wrap .chapter-welcome",
57377         helpHtml("intro.welcome.practice"),
57378         { buttonText: _t.html("intro.ok"), buttonCallback: words }
57379       );
57380     }
57381     function words() {
57382       reveal(
57383         ".intro-nav-wrap .chapter-welcome",
57384         helpHtml("intro.welcome.words"),
57385         { buttonText: _t.html("intro.ok"), buttonCallback: chapters }
57386       );
57387     }
57388     function chapters() {
57389       dispatch14.call("done");
57390       reveal(
57391         ".intro-nav-wrap .chapter-navigation",
57392         helpHtml("intro.welcome.chapters", { next: _t("intro.navigation.title") })
57393       );
57394     }
57395     chapter.enter = function() {
57396       welcome();
57397     };
57398     chapter.exit = function() {
57399       context.container().select(".curtain-tooltip.intro-mouse").selectAll(".counter").remove();
57400     };
57401     chapter.restart = function() {
57402       chapter.exit();
57403       chapter.enter();
57404     };
57405     return utilRebind(chapter, dispatch14, "on");
57406   }
57407
57408   // modules/ui/intro/navigation.js
57409   function uiIntroNavigation(context, reveal) {
57410     var dispatch14 = dispatch_default("done");
57411     var timeouts = [];
57412     var hallId = "n2061";
57413     var townHall = [-85.63591, 41.94285];
57414     var springStreetId = "w397";
57415     var springStreetEndId = "n1834";
57416     var springStreet = [-85.63582, 41.94255];
57417     var onewayField = _mainPresetIndex.field("oneway");
57418     var maxspeedField = _mainPresetIndex.field("maxspeed");
57419     var chapter = {
57420       title: "intro.navigation.title"
57421     };
57422     function timeout2(f2, t2) {
57423       timeouts.push(window.setTimeout(f2, t2));
57424     }
57425     function eventCancel(d3_event) {
57426       d3_event.stopPropagation();
57427       d3_event.preventDefault();
57428     }
57429     function isTownHallSelected() {
57430       var ids = context.selectedIDs();
57431       return ids.length === 1 && ids[0] === hallId;
57432     }
57433     function dragMap() {
57434       context.enter(modeBrowse(context));
57435       context.history().reset("initial");
57436       var msec = transitionTime(townHall, context.map().center());
57437       if (msec) {
57438         reveal(null, null, { duration: 0 });
57439       }
57440       context.map().centerZoomEase(townHall, 19, msec);
57441       timeout2(function() {
57442         var centerStart = context.map().center();
57443         var textId = context.lastPointerType() === "mouse" ? "drag" : "drag_touch";
57444         var dragString = helpHtml("intro.navigation.map_info") + "{br}" + helpHtml("intro.navigation." + textId);
57445         reveal(".main-map .surface", dragString);
57446         context.map().on("drawn.intro", function() {
57447           reveal(".main-map .surface", dragString, { duration: 0 });
57448         });
57449         context.map().on("move.intro", function() {
57450           var centerNow = context.map().center();
57451           if (centerStart[0] !== centerNow[0] || centerStart[1] !== centerNow[1]) {
57452             context.map().on("move.intro", null);
57453             timeout2(function() {
57454               continueTo(zoomMap);
57455             }, 3e3);
57456           }
57457         });
57458       }, msec + 100);
57459       function continueTo(nextStep) {
57460         context.map().on("move.intro drawn.intro", null);
57461         nextStep();
57462       }
57463     }
57464     function zoomMap() {
57465       var zoomStart = context.map().zoom();
57466       var textId = context.lastPointerType() === "mouse" ? "zoom" : "zoom_touch";
57467       var zoomString = helpHtml("intro.navigation." + textId);
57468       reveal(".main-map .surface", zoomString);
57469       context.map().on("drawn.intro", function() {
57470         reveal(".main-map .surface", zoomString, { duration: 0 });
57471       });
57472       context.map().on("move.intro", function() {
57473         if (context.map().zoom() !== zoomStart) {
57474           context.map().on("move.intro", null);
57475           timeout2(function() {
57476             continueTo(features);
57477           }, 3e3);
57478         }
57479       });
57480       function continueTo(nextStep) {
57481         context.map().on("move.intro drawn.intro", null);
57482         nextStep();
57483       }
57484     }
57485     function features() {
57486       var onClick = function() {
57487         continueTo(pointsLinesAreas);
57488       };
57489       reveal(
57490         ".main-map .surface",
57491         helpHtml("intro.navigation.features"),
57492         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57493       );
57494       context.map().on("drawn.intro", function() {
57495         reveal(
57496           ".main-map .surface",
57497           helpHtml("intro.navigation.features"),
57498           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57499         );
57500       });
57501       function continueTo(nextStep) {
57502         context.map().on("drawn.intro", null);
57503         nextStep();
57504       }
57505     }
57506     function pointsLinesAreas() {
57507       var onClick = function() {
57508         continueTo(nodesWays);
57509       };
57510       reveal(
57511         ".main-map .surface",
57512         helpHtml("intro.navigation.points_lines_areas"),
57513         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57514       );
57515       context.map().on("drawn.intro", function() {
57516         reveal(
57517           ".main-map .surface",
57518           helpHtml("intro.navigation.points_lines_areas"),
57519           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57520         );
57521       });
57522       function continueTo(nextStep) {
57523         context.map().on("drawn.intro", null);
57524         nextStep();
57525       }
57526     }
57527     function nodesWays() {
57528       var onClick = function() {
57529         continueTo(clickTownHall);
57530       };
57531       reveal(
57532         ".main-map .surface",
57533         helpHtml("intro.navigation.nodes_ways"),
57534         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57535       );
57536       context.map().on("drawn.intro", function() {
57537         reveal(
57538           ".main-map .surface",
57539           helpHtml("intro.navigation.nodes_ways"),
57540           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57541         );
57542       });
57543       function continueTo(nextStep) {
57544         context.map().on("drawn.intro", null);
57545         nextStep();
57546       }
57547     }
57548     function clickTownHall() {
57549       context.enter(modeBrowse(context));
57550       context.history().reset("initial");
57551       var entity = context.hasEntity(hallId);
57552       if (!entity) return;
57553       reveal(null, null, { duration: 0 });
57554       context.map().centerZoomEase(entity.loc, 19, 500);
57555       timeout2(function() {
57556         var entity2 = context.hasEntity(hallId);
57557         if (!entity2) return;
57558         var box = pointBox(entity2.loc, context);
57559         var textId = context.lastPointerType() === "mouse" ? "click_townhall" : "tap_townhall";
57560         reveal(box, helpHtml("intro.navigation." + textId));
57561         context.map().on("move.intro drawn.intro", function() {
57562           var entity3 = context.hasEntity(hallId);
57563           if (!entity3) return;
57564           var box2 = pointBox(entity3.loc, context);
57565           reveal(box2, helpHtml("intro.navigation." + textId), { duration: 0 });
57566         });
57567         context.on("enter.intro", function() {
57568           if (isTownHallSelected()) continueTo(selectedTownHall);
57569         });
57570       }, 550);
57571       context.history().on("change.intro", function() {
57572         if (!context.hasEntity(hallId)) {
57573           continueTo(clickTownHall);
57574         }
57575       });
57576       function continueTo(nextStep) {
57577         context.on("enter.intro", null);
57578         context.map().on("move.intro drawn.intro", null);
57579         context.history().on("change.intro", null);
57580         nextStep();
57581       }
57582     }
57583     function selectedTownHall() {
57584       if (!isTownHallSelected()) return clickTownHall();
57585       var entity = context.hasEntity(hallId);
57586       if (!entity) return clickTownHall();
57587       var box = pointBox(entity.loc, context);
57588       var onClick = function() {
57589         continueTo(editorTownHall);
57590       };
57591       reveal(
57592         box,
57593         helpHtml("intro.navigation.selected_townhall"),
57594         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57595       );
57596       context.map().on("move.intro drawn.intro", function() {
57597         var entity2 = context.hasEntity(hallId);
57598         if (!entity2) return;
57599         var box2 = pointBox(entity2.loc, context);
57600         reveal(
57601           box2,
57602           helpHtml("intro.navigation.selected_townhall"),
57603           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57604         );
57605       });
57606       context.history().on("change.intro", function() {
57607         if (!context.hasEntity(hallId)) {
57608           continueTo(clickTownHall);
57609         }
57610       });
57611       function continueTo(nextStep) {
57612         context.map().on("move.intro drawn.intro", null);
57613         context.history().on("change.intro", null);
57614         nextStep();
57615       }
57616     }
57617     function editorTownHall() {
57618       if (!isTownHallSelected()) return clickTownHall();
57619       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
57620       var onClick = function() {
57621         continueTo(presetTownHall);
57622       };
57623       reveal(
57624         ".entity-editor-pane",
57625         helpHtml("intro.navigation.editor_townhall"),
57626         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57627       );
57628       context.on("exit.intro", function() {
57629         continueTo(clickTownHall);
57630       });
57631       context.history().on("change.intro", function() {
57632         if (!context.hasEntity(hallId)) {
57633           continueTo(clickTownHall);
57634         }
57635       });
57636       function continueTo(nextStep) {
57637         context.on("exit.intro", null);
57638         context.history().on("change.intro", null);
57639         context.container().select(".inspector-wrap").on("wheel.intro", null);
57640         nextStep();
57641       }
57642     }
57643     function presetTownHall() {
57644       if (!isTownHallSelected()) return clickTownHall();
57645       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
57646       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
57647       var entity = context.entity(context.selectedIDs()[0]);
57648       var preset = _mainPresetIndex.match(entity, context.graph());
57649       var onClick = function() {
57650         continueTo(fieldsTownHall);
57651       };
57652       reveal(
57653         ".entity-editor-pane .section-feature-type",
57654         helpHtml("intro.navigation.preset_townhall", { preset: preset.name() }),
57655         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57656       );
57657       context.on("exit.intro", function() {
57658         continueTo(clickTownHall);
57659       });
57660       context.history().on("change.intro", function() {
57661         if (!context.hasEntity(hallId)) {
57662           continueTo(clickTownHall);
57663         }
57664       });
57665       function continueTo(nextStep) {
57666         context.on("exit.intro", null);
57667         context.history().on("change.intro", null);
57668         context.container().select(".inspector-wrap").on("wheel.intro", null);
57669         nextStep();
57670       }
57671     }
57672     function fieldsTownHall() {
57673       if (!isTownHallSelected()) return clickTownHall();
57674       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
57675       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
57676       var onClick = function() {
57677         continueTo(closeTownHall);
57678       };
57679       reveal(
57680         ".entity-editor-pane .section-preset-fields",
57681         helpHtml("intro.navigation.fields_townhall"),
57682         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57683       );
57684       context.on("exit.intro", function() {
57685         continueTo(clickTownHall);
57686       });
57687       context.history().on("change.intro", function() {
57688         if (!context.hasEntity(hallId)) {
57689           continueTo(clickTownHall);
57690         }
57691       });
57692       function continueTo(nextStep) {
57693         context.on("exit.intro", null);
57694         context.history().on("change.intro", null);
57695         context.container().select(".inspector-wrap").on("wheel.intro", null);
57696         nextStep();
57697       }
57698     }
57699     function closeTownHall() {
57700       if (!isTownHallSelected()) return clickTownHall();
57701       var selector = ".entity-editor-pane button.close svg use";
57702       var href = select_default2(selector).attr("href") || "#iD-icon-close";
57703       reveal(
57704         ".entity-editor-pane",
57705         helpHtml("intro.navigation.close_townhall", { button: { html: icon(href, "inline") } })
57706       );
57707       context.on("exit.intro", function() {
57708         continueTo(searchStreet);
57709       });
57710       context.history().on("change.intro", function() {
57711         var selector2 = ".entity-editor-pane button.close svg use";
57712         var href2 = select_default2(selector2).attr("href") || "#iD-icon-close";
57713         reveal(
57714           ".entity-editor-pane",
57715           helpHtml("intro.navigation.close_townhall", { button: { html: icon(href2, "inline") } }),
57716           { duration: 0 }
57717         );
57718       });
57719       function continueTo(nextStep) {
57720         context.on("exit.intro", null);
57721         context.history().on("change.intro", null);
57722         nextStep();
57723       }
57724     }
57725     function searchStreet() {
57726       context.enter(modeBrowse(context));
57727       context.history().reset("initial");
57728       var msec = transitionTime(springStreet, context.map().center());
57729       if (msec) {
57730         reveal(null, null, { duration: 0 });
57731       }
57732       context.map().centerZoomEase(springStreet, 19, msec);
57733       timeout2(function() {
57734         reveal(
57735           ".search-header input",
57736           helpHtml("intro.navigation.search_street", { name: _t("intro.graph.name.spring-street") })
57737         );
57738         context.container().select(".search-header input").on("keyup.intro", checkSearchResult);
57739       }, msec + 100);
57740     }
57741     function checkSearchResult() {
57742       var first = context.container().select(".feature-list-item:nth-child(0n+2)");
57743       var firstName = first.select(".entity-name");
57744       var name = _t("intro.graph.name.spring-street");
57745       if (!firstName.empty() && firstName.html() === name) {
57746         reveal(
57747           first.node(),
57748           helpHtml("intro.navigation.choose_street", { name }),
57749           { duration: 300 }
57750         );
57751         context.on("exit.intro", function() {
57752           continueTo(selectedStreet);
57753         });
57754         context.container().select(".search-header input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
57755       }
57756       function continueTo(nextStep) {
57757         context.on("exit.intro", null);
57758         context.container().select(".search-header input").on("keydown.intro", null).on("keyup.intro", null);
57759         nextStep();
57760       }
57761     }
57762     function selectedStreet() {
57763       if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) {
57764         return searchStreet();
57765       }
57766       var onClick = function() {
57767         continueTo(editorStreet);
57768       };
57769       var entity = context.entity(springStreetEndId);
57770       var box = pointBox(entity.loc, context);
57771       box.height = 500;
57772       reveal(
57773         box,
57774         helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }),
57775         { duration: 600, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57776       );
57777       timeout2(function() {
57778         context.map().on("move.intro drawn.intro", function() {
57779           var entity2 = context.hasEntity(springStreetEndId);
57780           if (!entity2) return;
57781           var box2 = pointBox(entity2.loc, context);
57782           box2.height = 500;
57783           reveal(
57784             box2,
57785             helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }),
57786             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
57787           );
57788         });
57789       }, 600);
57790       context.on("enter.intro", function(mode) {
57791         if (!context.hasEntity(springStreetId)) {
57792           return continueTo(searchStreet);
57793         }
57794         var ids = context.selectedIDs();
57795         if (mode.id !== "select" || !ids.length || ids[0] !== springStreetId) {
57796           context.enter(modeSelect(context, [springStreetId]));
57797         }
57798       });
57799       context.history().on("change.intro", function() {
57800         if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) {
57801           timeout2(function() {
57802             continueTo(searchStreet);
57803           }, 300);
57804         }
57805       });
57806       function continueTo(nextStep) {
57807         context.map().on("move.intro drawn.intro", null);
57808         context.on("enter.intro", null);
57809         context.history().on("change.intro", null);
57810         nextStep();
57811       }
57812     }
57813     function editorStreet() {
57814       var selector = ".entity-editor-pane button.close svg use";
57815       var href = select_default2(selector).attr("href") || "#iD-icon-close";
57816       reveal(".entity-editor-pane", helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", {
57817         button: { html: icon(href, "inline") },
57818         field1: onewayField.title(),
57819         field2: maxspeedField.title()
57820       }));
57821       context.on("exit.intro", function() {
57822         continueTo(play);
57823       });
57824       context.history().on("change.intro", function() {
57825         var selector2 = ".entity-editor-pane button.close svg use";
57826         var href2 = select_default2(selector2).attr("href") || "#iD-icon-close";
57827         reveal(
57828           ".entity-editor-pane",
57829           helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", {
57830             button: { html: icon(href2, "inline") },
57831             field1: onewayField.title(),
57832             field2: maxspeedField.title()
57833           }),
57834           { duration: 0 }
57835         );
57836       });
57837       function continueTo(nextStep) {
57838         context.on("exit.intro", null);
57839         context.history().on("change.intro", null);
57840         nextStep();
57841       }
57842     }
57843     function play() {
57844       dispatch14.call("done");
57845       reveal(
57846         ".ideditor",
57847         helpHtml("intro.navigation.play", { next: _t("intro.points.title") }),
57848         {
57849           tooltipBox: ".intro-nav-wrap .chapter-point",
57850           buttonText: _t.html("intro.ok"),
57851           buttonCallback: function() {
57852             reveal(".ideditor");
57853           }
57854         }
57855       );
57856     }
57857     chapter.enter = function() {
57858       dragMap();
57859     };
57860     chapter.exit = function() {
57861       timeouts.forEach(window.clearTimeout);
57862       context.on("enter.intro exit.intro", null);
57863       context.map().on("move.intro drawn.intro", null);
57864       context.history().on("change.intro", null);
57865       context.container().select(".inspector-wrap").on("wheel.intro", null);
57866       context.container().select(".search-header input").on("keydown.intro keyup.intro", null);
57867     };
57868     chapter.restart = function() {
57869       chapter.exit();
57870       chapter.enter();
57871     };
57872     return utilRebind(chapter, dispatch14, "on");
57873   }
57874
57875   // modules/ui/intro/point.js
57876   function uiIntroPoint(context, reveal) {
57877     var dispatch14 = dispatch_default("done");
57878     var timeouts = [];
57879     var intersection2 = [-85.63279, 41.94394];
57880     var building = [-85.632422, 41.944045];
57881     var cafePreset = _mainPresetIndex.item("amenity/cafe");
57882     var _pointID = null;
57883     var chapter = {
57884       title: "intro.points.title"
57885     };
57886     function timeout2(f2, t2) {
57887       timeouts.push(window.setTimeout(f2, t2));
57888     }
57889     function eventCancel(d3_event) {
57890       d3_event.stopPropagation();
57891       d3_event.preventDefault();
57892     }
57893     function addPoint() {
57894       context.enter(modeBrowse(context));
57895       context.history().reset("initial");
57896       var msec = transitionTime(intersection2, context.map().center());
57897       if (msec) {
57898         reveal(null, null, { duration: 0 });
57899       }
57900       context.map().centerZoomEase(intersection2, 19, msec);
57901       timeout2(function() {
57902         var tooltip = reveal(
57903           "button.add-point",
57904           helpHtml("intro.points.points_info") + "{br}" + helpHtml("intro.points.add_point")
57905         );
57906         _pointID = null;
57907         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-points");
57908         context.on("enter.intro", function(mode) {
57909           if (mode.id !== "add-point") return;
57910           continueTo(placePoint);
57911         });
57912       }, msec + 100);
57913       function continueTo(nextStep) {
57914         context.on("enter.intro", null);
57915         nextStep();
57916       }
57917     }
57918     function placePoint() {
57919       if (context.mode().id !== "add-point") {
57920         return chapter.restart();
57921       }
57922       var pointBox2 = pad(building, 150, context);
57923       var textId = context.lastPointerType() === "mouse" ? "place_point" : "place_point_touch";
57924       reveal(pointBox2, helpHtml("intro.points." + textId));
57925       context.map().on("move.intro drawn.intro", function() {
57926         pointBox2 = pad(building, 150, context);
57927         reveal(pointBox2, helpHtml("intro.points." + textId), { duration: 0 });
57928       });
57929       context.on("enter.intro", function(mode) {
57930         if (mode.id !== "select") return chapter.restart();
57931         _pointID = context.mode().selectedIDs()[0];
57932         if (context.graph().geometry(_pointID) === "vertex") {
57933           context.map().on("move.intro drawn.intro", null);
57934           context.on("enter.intro", null);
57935           reveal(pointBox2, helpHtml("intro.points.place_point_error"), {
57936             buttonText: _t.html("intro.ok"),
57937             buttonCallback: function() {
57938               return chapter.restart();
57939             }
57940           });
57941         } else {
57942           continueTo(searchPreset);
57943         }
57944       });
57945       function continueTo(nextStep) {
57946         context.map().on("move.intro drawn.intro", null);
57947         context.on("enter.intro", null);
57948         nextStep();
57949       }
57950     }
57951     function searchPreset() {
57952       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
57953         return addPoint();
57954       }
57955       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
57956       context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
57957       reveal(
57958         ".preset-search-input",
57959         helpHtml("intro.points.search_cafe", { preset: cafePreset.name() })
57960       );
57961       context.on("enter.intro", function(mode) {
57962         if (!_pointID || !context.hasEntity(_pointID)) {
57963           return continueTo(addPoint);
57964         }
57965         var ids = context.selectedIDs();
57966         if (mode.id !== "select" || !ids.length || ids[0] !== _pointID) {
57967           context.enter(modeSelect(context, [_pointID]));
57968           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
57969           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
57970           reveal(
57971             ".preset-search-input",
57972             helpHtml("intro.points.search_cafe", { preset: cafePreset.name() })
57973           );
57974           context.history().on("change.intro", null);
57975         }
57976       });
57977       function checkPresetSearch() {
57978         var first = context.container().select(".preset-list-item:first-child");
57979         if (first.classed("preset-amenity-cafe")) {
57980           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
57981           reveal(
57982             first.select(".preset-list-button").node(),
57983             helpHtml("intro.points.choose_cafe", { preset: cafePreset.name() }),
57984             { duration: 300 }
57985           );
57986           context.history().on("change.intro", function() {
57987             continueTo(aboutFeatureEditor);
57988           });
57989         }
57990       }
57991       function continueTo(nextStep) {
57992         context.on("enter.intro", null);
57993         context.history().on("change.intro", null);
57994         context.container().select(".inspector-wrap").on("wheel.intro", null);
57995         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
57996         nextStep();
57997       }
57998     }
57999     function aboutFeatureEditor() {
58000       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
58001         return addPoint();
58002       }
58003       timeout2(function() {
58004         reveal(".entity-editor-pane", helpHtml("intro.points.feature_editor"), {
58005           tooltipClass: "intro-points-describe",
58006           buttonText: _t.html("intro.ok"),
58007           buttonCallback: function() {
58008             continueTo(addName);
58009           }
58010         });
58011       }, 400);
58012       context.on("exit.intro", function() {
58013         continueTo(reselectPoint);
58014       });
58015       function continueTo(nextStep) {
58016         context.on("exit.intro", null);
58017         nextStep();
58018       }
58019     }
58020     function addName() {
58021       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
58022         return addPoint();
58023       }
58024       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58025       var addNameString = helpHtml("intro.points.fields_info") + "{br}" + helpHtml("intro.points.add_name") + "{br}" + helpHtml("intro.points.add_reminder");
58026       timeout2(function() {
58027         var entity = context.entity(_pointID);
58028         if (entity.tags.name) {
58029           var tooltip = reveal(".entity-editor-pane", addNameString, {
58030             tooltipClass: "intro-points-describe",
58031             buttonText: _t.html("intro.ok"),
58032             buttonCallback: function() {
58033               continueTo(addCloseEditor);
58034             }
58035           });
58036           tooltip.select(".instruction").style("display", "none");
58037         } else {
58038           reveal(
58039             ".entity-editor-pane",
58040             addNameString,
58041             { tooltipClass: "intro-points-describe" }
58042           );
58043         }
58044       }, 400);
58045       context.history().on("change.intro", function() {
58046         continueTo(addCloseEditor);
58047       });
58048       context.on("exit.intro", function() {
58049         continueTo(reselectPoint);
58050       });
58051       function continueTo(nextStep) {
58052         context.on("exit.intro", null);
58053         context.history().on("change.intro", null);
58054         nextStep();
58055       }
58056     }
58057     function addCloseEditor() {
58058       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58059       var selector = ".entity-editor-pane button.close svg use";
58060       var href = select_default2(selector).attr("href") || "#iD-icon-close";
58061       context.on("exit.intro", function() {
58062         continueTo(reselectPoint);
58063       });
58064       reveal(
58065         ".entity-editor-pane",
58066         helpHtml("intro.points.add_close", { button: { html: icon(href, "inline") } })
58067       );
58068       function continueTo(nextStep) {
58069         context.on("exit.intro", null);
58070         nextStep();
58071       }
58072     }
58073     function reselectPoint() {
58074       if (!_pointID) return chapter.restart();
58075       var entity = context.hasEntity(_pointID);
58076       if (!entity) return chapter.restart();
58077       var oldPreset = _mainPresetIndex.match(entity, context.graph());
58078       context.replace(actionChangePreset(_pointID, oldPreset, cafePreset));
58079       context.enter(modeBrowse(context));
58080       var msec = transitionTime(entity.loc, context.map().center());
58081       if (msec) {
58082         reveal(null, null, { duration: 0 });
58083       }
58084       context.map().centerEase(entity.loc, msec);
58085       timeout2(function() {
58086         var box = pointBox(entity.loc, context);
58087         reveal(box, helpHtml("intro.points.reselect"), { duration: 600 });
58088         timeout2(function() {
58089           context.map().on("move.intro drawn.intro", function() {
58090             var entity2 = context.hasEntity(_pointID);
58091             if (!entity2) return chapter.restart();
58092             var box2 = pointBox(entity2.loc, context);
58093             reveal(box2, helpHtml("intro.points.reselect"), { duration: 0 });
58094           });
58095         }, 600);
58096         context.on("enter.intro", function(mode) {
58097           if (mode.id !== "select") return;
58098           continueTo(updatePoint);
58099         });
58100       }, msec + 100);
58101       function continueTo(nextStep) {
58102         context.map().on("move.intro drawn.intro", null);
58103         context.on("enter.intro", null);
58104         nextStep();
58105       }
58106     }
58107     function updatePoint() {
58108       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
58109         return continueTo(reselectPoint);
58110       }
58111       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58112       context.on("exit.intro", function() {
58113         continueTo(reselectPoint);
58114       });
58115       context.history().on("change.intro", function() {
58116         continueTo(updateCloseEditor);
58117       });
58118       timeout2(function() {
58119         reveal(
58120           ".entity-editor-pane",
58121           helpHtml("intro.points.update"),
58122           { tooltipClass: "intro-points-describe" }
58123         );
58124       }, 400);
58125       function continueTo(nextStep) {
58126         context.on("exit.intro", null);
58127         context.history().on("change.intro", null);
58128         nextStep();
58129       }
58130     }
58131     function updateCloseEditor() {
58132       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
58133         return continueTo(reselectPoint);
58134       }
58135       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58136       context.on("exit.intro", function() {
58137         continueTo(rightClickPoint);
58138       });
58139       timeout2(function() {
58140         reveal(
58141           ".entity-editor-pane",
58142           helpHtml("intro.points.update_close", { button: { html: icon("#iD-icon-close", "inline") } })
58143         );
58144       }, 500);
58145       function continueTo(nextStep) {
58146         context.on("exit.intro", null);
58147         nextStep();
58148       }
58149     }
58150     function rightClickPoint() {
58151       if (!_pointID) return chapter.restart();
58152       var entity = context.hasEntity(_pointID);
58153       if (!entity) return chapter.restart();
58154       context.enter(modeBrowse(context));
58155       var box = pointBox(entity.loc, context);
58156       var textId = context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch";
58157       reveal(box, helpHtml("intro.points." + textId), { duration: 600 });
58158       timeout2(function() {
58159         context.map().on("move.intro", function() {
58160           var entity2 = context.hasEntity(_pointID);
58161           if (!entity2) return chapter.restart();
58162           var box2 = pointBox(entity2.loc, context);
58163           reveal(box2, helpHtml("intro.points." + textId), { duration: 0 });
58164         });
58165       }, 600);
58166       context.on("enter.intro", function(mode) {
58167         if (mode.id !== "select") return;
58168         var ids = context.selectedIDs();
58169         if (ids.length !== 1 || ids[0] !== _pointID) return;
58170         timeout2(function() {
58171           var node = selectMenuItem(context, "delete").node();
58172           if (!node) return;
58173           continueTo(enterDelete);
58174         }, 50);
58175       });
58176       function continueTo(nextStep) {
58177         context.on("enter.intro", null);
58178         context.map().on("move.intro", null);
58179         nextStep();
58180       }
58181     }
58182     function enterDelete() {
58183       if (!_pointID) return chapter.restart();
58184       var entity = context.hasEntity(_pointID);
58185       if (!entity) return chapter.restart();
58186       var node = selectMenuItem(context, "delete").node();
58187       if (!node) {
58188         return continueTo(rightClickPoint);
58189       }
58190       reveal(
58191         ".edit-menu",
58192         helpHtml("intro.points.delete"),
58193         { padding: 50 }
58194       );
58195       timeout2(function() {
58196         context.map().on("move.intro", function() {
58197           if (selectMenuItem(context, "delete").empty()) {
58198             return continueTo(rightClickPoint);
58199           }
58200           reveal(
58201             ".edit-menu",
58202             helpHtml("intro.points.delete"),
58203             { duration: 0, padding: 50 }
58204           );
58205         });
58206       }, 300);
58207       context.on("exit.intro", function() {
58208         if (!_pointID) return chapter.restart();
58209         var entity2 = context.hasEntity(_pointID);
58210         if (entity2) return continueTo(rightClickPoint);
58211       });
58212       context.history().on("change.intro", function(changed) {
58213         if (changed.deleted().length) {
58214           continueTo(undo);
58215         }
58216       });
58217       function continueTo(nextStep) {
58218         context.map().on("move.intro", null);
58219         context.history().on("change.intro", null);
58220         context.on("exit.intro", null);
58221         nextStep();
58222       }
58223     }
58224     function undo() {
58225       context.history().on("change.intro", function() {
58226         continueTo(play);
58227       });
58228       reveal(
58229         ".top-toolbar button.undo-button",
58230         helpHtml("intro.points.undo")
58231       );
58232       function continueTo(nextStep) {
58233         context.history().on("change.intro", null);
58234         nextStep();
58235       }
58236     }
58237     function play() {
58238       dispatch14.call("done");
58239       reveal(
58240         ".ideditor",
58241         helpHtml("intro.points.play", { next: _t("intro.areas.title") }),
58242         {
58243           tooltipBox: ".intro-nav-wrap .chapter-area",
58244           buttonText: _t.html("intro.ok"),
58245           buttonCallback: function() {
58246             reveal(".ideditor");
58247           }
58248         }
58249       );
58250     }
58251     chapter.enter = function() {
58252       addPoint();
58253     };
58254     chapter.exit = function() {
58255       timeouts.forEach(window.clearTimeout);
58256       context.on("enter.intro exit.intro", null);
58257       context.map().on("move.intro drawn.intro", null);
58258       context.history().on("change.intro", null);
58259       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58260       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
58261     };
58262     chapter.restart = function() {
58263       chapter.exit();
58264       chapter.enter();
58265     };
58266     return utilRebind(chapter, dispatch14, "on");
58267   }
58268
58269   // modules/ui/intro/area.js
58270   function uiIntroArea(context, reveal) {
58271     var dispatch14 = dispatch_default("done");
58272     var playground = [-85.63552, 41.94159];
58273     var playgroundPreset = _mainPresetIndex.item("leisure/playground");
58274     var nameField = _mainPresetIndex.field("name");
58275     var descriptionField = _mainPresetIndex.field("description");
58276     var timeouts = [];
58277     var _areaID;
58278     var chapter = {
58279       title: "intro.areas.title"
58280     };
58281     function timeout2(f2, t2) {
58282       timeouts.push(window.setTimeout(f2, t2));
58283     }
58284     function eventCancel(d3_event) {
58285       d3_event.stopPropagation();
58286       d3_event.preventDefault();
58287     }
58288     function revealPlayground(center, text, options2) {
58289       var padding = 180 * Math.pow(2, context.map().zoom() - 19.5);
58290       var box = pad(center, padding, context);
58291       reveal(box, text, options2);
58292     }
58293     function addArea() {
58294       context.enter(modeBrowse(context));
58295       context.history().reset("initial");
58296       _areaID = null;
58297       var msec = transitionTime(playground, context.map().center());
58298       if (msec) {
58299         reveal(null, null, { duration: 0 });
58300       }
58301       context.map().centerZoomEase(playground, 19, msec);
58302       timeout2(function() {
58303         var tooltip = reveal(
58304           "button.add-area",
58305           helpHtml("intro.areas.add_playground")
58306         );
58307         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-areas");
58308         context.on("enter.intro", function(mode) {
58309           if (mode.id !== "add-area") return;
58310           continueTo(startPlayground);
58311         });
58312       }, msec + 100);
58313       function continueTo(nextStep) {
58314         context.on("enter.intro", null);
58315         nextStep();
58316       }
58317     }
58318     function startPlayground() {
58319       if (context.mode().id !== "add-area") {
58320         return chapter.restart();
58321       }
58322       _areaID = null;
58323       context.map().zoomEase(19.5, 500);
58324       timeout2(function() {
58325         var textId = context.lastPointerType() === "mouse" ? "starting_node_click" : "starting_node_tap";
58326         var startDrawString = helpHtml("intro.areas.start_playground") + helpHtml("intro.areas." + textId);
58327         revealPlayground(
58328           playground,
58329           startDrawString,
58330           { duration: 250 }
58331         );
58332         timeout2(function() {
58333           context.map().on("move.intro drawn.intro", function() {
58334             revealPlayground(
58335               playground,
58336               startDrawString,
58337               { duration: 0 }
58338             );
58339           });
58340           context.on("enter.intro", function(mode) {
58341             if (mode.id !== "draw-area") return chapter.restart();
58342             continueTo(continuePlayground);
58343           });
58344         }, 250);
58345       }, 550);
58346       function continueTo(nextStep) {
58347         context.map().on("move.intro drawn.intro", null);
58348         context.on("enter.intro", null);
58349         nextStep();
58350       }
58351     }
58352     function continuePlayground() {
58353       if (context.mode().id !== "draw-area") {
58354         return chapter.restart();
58355       }
58356       _areaID = null;
58357       revealPlayground(
58358         playground,
58359         helpHtml("intro.areas.continue_playground"),
58360         { duration: 250 }
58361       );
58362       timeout2(function() {
58363         context.map().on("move.intro drawn.intro", function() {
58364           revealPlayground(
58365             playground,
58366             helpHtml("intro.areas.continue_playground"),
58367             { duration: 0 }
58368           );
58369         });
58370       }, 250);
58371       context.on("enter.intro", function(mode) {
58372         if (mode.id === "draw-area") {
58373           var entity = context.hasEntity(context.selectedIDs()[0]);
58374           if (entity && entity.nodes.length >= 6) {
58375             return continueTo(finishPlayground);
58376           } else {
58377             return;
58378           }
58379         } else if (mode.id === "select") {
58380           _areaID = context.selectedIDs()[0];
58381           return continueTo(searchPresets);
58382         } else {
58383           return chapter.restart();
58384         }
58385       });
58386       function continueTo(nextStep) {
58387         context.map().on("move.intro drawn.intro", null);
58388         context.on("enter.intro", null);
58389         nextStep();
58390       }
58391     }
58392     function finishPlayground() {
58393       if (context.mode().id !== "draw-area") {
58394         return chapter.restart();
58395       }
58396       _areaID = null;
58397       var finishString = helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.areas.finish_playground");
58398       revealPlayground(
58399         playground,
58400         finishString,
58401         { duration: 250 }
58402       );
58403       timeout2(function() {
58404         context.map().on("move.intro drawn.intro", function() {
58405           revealPlayground(
58406             playground,
58407             finishString,
58408             { duration: 0 }
58409           );
58410         });
58411       }, 250);
58412       context.on("enter.intro", function(mode) {
58413         if (mode.id === "draw-area") {
58414           return;
58415         } else if (mode.id === "select") {
58416           _areaID = context.selectedIDs()[0];
58417           return continueTo(searchPresets);
58418         } else {
58419           return chapter.restart();
58420         }
58421       });
58422       function continueTo(nextStep) {
58423         context.map().on("move.intro drawn.intro", null);
58424         context.on("enter.intro", null);
58425         nextStep();
58426       }
58427     }
58428     function searchPresets() {
58429       if (!_areaID || !context.hasEntity(_areaID)) {
58430         return addArea();
58431       }
58432       var ids = context.selectedIDs();
58433       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
58434         context.enter(modeSelect(context, [_areaID]));
58435       }
58436       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58437       timeout2(function() {
58438         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
58439         context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
58440         reveal(
58441           ".preset-search-input",
58442           helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() })
58443         );
58444       }, 400);
58445       context.on("enter.intro", function(mode) {
58446         if (!_areaID || !context.hasEntity(_areaID)) {
58447           return continueTo(addArea);
58448         }
58449         var ids2 = context.selectedIDs();
58450         if (mode.id !== "select" || !ids2.length || ids2[0] !== _areaID) {
58451           context.enter(modeSelect(context, [_areaID]));
58452           context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
58453           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58454           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
58455           reveal(
58456             ".preset-search-input",
58457             helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() })
58458           );
58459           context.history().on("change.intro", null);
58460         }
58461       });
58462       function checkPresetSearch() {
58463         var first = context.container().select(".preset-list-item:first-child");
58464         if (first.classed("preset-leisure-playground")) {
58465           reveal(
58466             first.select(".preset-list-button").node(),
58467             helpHtml("intro.areas.choose_playground", { preset: playgroundPreset.name() }),
58468             { duration: 300 }
58469           );
58470           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
58471           context.history().on("change.intro", function() {
58472             continueTo(clickAddField);
58473           });
58474         }
58475       }
58476       function continueTo(nextStep) {
58477         context.container().select(".inspector-wrap").on("wheel.intro", null);
58478         context.on("enter.intro", null);
58479         context.history().on("change.intro", null);
58480         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
58481         nextStep();
58482       }
58483     }
58484     function clickAddField() {
58485       if (!_areaID || !context.hasEntity(_areaID)) {
58486         return addArea();
58487       }
58488       var ids = context.selectedIDs();
58489       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
58490         return searchPresets();
58491       }
58492       if (!context.container().select(".form-field-description").empty()) {
58493         return continueTo(describePlayground);
58494       }
58495       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58496       timeout2(function() {
58497         context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58498         var entity = context.entity(_areaID);
58499         if (entity.tags.description) {
58500           return continueTo(play);
58501         }
58502         var box = context.container().select(".more-fields").node().getBoundingClientRect();
58503         if (box.top > 300) {
58504           var pane = context.container().select(".entity-editor-pane .inspector-body");
58505           var start2 = pane.node().scrollTop;
58506           var end = start2 + (box.top - 300);
58507           pane.transition().duration(250).tween("scroll.inspector", function() {
58508             var node = this;
58509             var i3 = number_default(start2, end);
58510             return function(t2) {
58511               node.scrollTop = i3(t2);
58512             };
58513           });
58514         }
58515         timeout2(function() {
58516           reveal(
58517             ".more-fields .combobox-input",
58518             helpHtml("intro.areas.add_field", {
58519               name: nameField.title(),
58520               description: descriptionField.title()
58521             }),
58522             { duration: 300 }
58523           );
58524           context.container().select(".more-fields .combobox-input").on("click.intro", function() {
58525             var watcher;
58526             watcher = window.setInterval(function() {
58527               if (!context.container().select("div.combobox").empty()) {
58528                 window.clearInterval(watcher);
58529                 continueTo(chooseDescriptionField);
58530               }
58531             }, 300);
58532           });
58533         }, 300);
58534       }, 400);
58535       context.on("exit.intro", function() {
58536         return continueTo(searchPresets);
58537       });
58538       function continueTo(nextStep) {
58539         context.container().select(".inspector-wrap").on("wheel.intro", null);
58540         context.container().select(".more-fields .combobox-input").on("click.intro", null);
58541         context.on("exit.intro", null);
58542         nextStep();
58543       }
58544     }
58545     function chooseDescriptionField() {
58546       if (!_areaID || !context.hasEntity(_areaID)) {
58547         return addArea();
58548       }
58549       var ids = context.selectedIDs();
58550       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
58551         return searchPresets();
58552       }
58553       if (!context.container().select(".form-field-description").empty()) {
58554         return continueTo(describePlayground);
58555       }
58556       if (context.container().select("div.combobox").empty()) {
58557         return continueTo(clickAddField);
58558       }
58559       var watcher;
58560       watcher = window.setInterval(function() {
58561         if (context.container().select("div.combobox").empty()) {
58562           window.clearInterval(watcher);
58563           timeout2(function() {
58564             if (context.container().select(".form-field-description").empty()) {
58565               continueTo(retryChooseDescription);
58566             } else {
58567               continueTo(describePlayground);
58568             }
58569           }, 300);
58570         }
58571       }, 300);
58572       reveal(
58573         "div.combobox",
58574         helpHtml("intro.areas.choose_field", { field: descriptionField.title() }),
58575         { duration: 300 }
58576       );
58577       context.on("exit.intro", function() {
58578         return continueTo(searchPresets);
58579       });
58580       function continueTo(nextStep) {
58581         if (watcher) window.clearInterval(watcher);
58582         context.on("exit.intro", null);
58583         nextStep();
58584       }
58585     }
58586     function describePlayground() {
58587       if (!_areaID || !context.hasEntity(_areaID)) {
58588         return addArea();
58589       }
58590       var ids = context.selectedIDs();
58591       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
58592         return searchPresets();
58593       }
58594       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58595       if (context.container().select(".form-field-description").empty()) {
58596         return continueTo(retryChooseDescription);
58597       }
58598       context.on("exit.intro", function() {
58599         continueTo(play);
58600       });
58601       reveal(
58602         ".entity-editor-pane",
58603         helpHtml("intro.areas.describe_playground", { button: { html: icon("#iD-icon-close", "inline") } }),
58604         { duration: 300 }
58605       );
58606       function continueTo(nextStep) {
58607         context.on("exit.intro", null);
58608         nextStep();
58609       }
58610     }
58611     function retryChooseDescription() {
58612       if (!_areaID || !context.hasEntity(_areaID)) {
58613         return addArea();
58614       }
58615       var ids = context.selectedIDs();
58616       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
58617         return searchPresets();
58618       }
58619       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
58620       reveal(
58621         ".entity-editor-pane",
58622         helpHtml("intro.areas.retry_add_field", { field: descriptionField.title() }),
58623         {
58624           buttonText: _t.html("intro.ok"),
58625           buttonCallback: function() {
58626             continueTo(clickAddField);
58627           }
58628         }
58629       );
58630       context.on("exit.intro", function() {
58631         return continueTo(searchPresets);
58632       });
58633       function continueTo(nextStep) {
58634         context.on("exit.intro", null);
58635         nextStep();
58636       }
58637     }
58638     function play() {
58639       dispatch14.call("done");
58640       reveal(
58641         ".ideditor",
58642         helpHtml("intro.areas.play", { next: _t("intro.lines.title") }),
58643         {
58644           tooltipBox: ".intro-nav-wrap .chapter-line",
58645           buttonText: _t.html("intro.ok"),
58646           buttonCallback: function() {
58647             reveal(".ideditor");
58648           }
58649         }
58650       );
58651     }
58652     chapter.enter = function() {
58653       addArea();
58654     };
58655     chapter.exit = function() {
58656       timeouts.forEach(window.clearTimeout);
58657       context.on("enter.intro exit.intro", null);
58658       context.map().on("move.intro drawn.intro", null);
58659       context.history().on("change.intro", null);
58660       context.container().select(".inspector-wrap").on("wheel.intro", null);
58661       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
58662       context.container().select(".more-fields .combobox-input").on("click.intro", null);
58663     };
58664     chapter.restart = function() {
58665       chapter.exit();
58666       chapter.enter();
58667     };
58668     return utilRebind(chapter, dispatch14, "on");
58669   }
58670
58671   // modules/ui/intro/line.js
58672   function uiIntroLine(context, reveal) {
58673     var dispatch14 = dispatch_default("done");
58674     var timeouts = [];
58675     var _tulipRoadID = null;
58676     var flowerRoadID = "w646";
58677     var tulipRoadStart = [-85.6297754121684, 41.95805253325314];
58678     var tulipRoadMidpoint = [-85.62975395449628, 41.95787501510204];
58679     var tulipRoadIntersection = [-85.62974496187628, 41.95742515554585];
58680     var roadCategory = _mainPresetIndex.item("category-road_minor");
58681     var residentialPreset = _mainPresetIndex.item("highway/residential");
58682     var woodRoadID = "w525";
58683     var woodRoadEndID = "n2862";
58684     var woodRoadAddNode = [-85.62390110349587, 41.95397111462291];
58685     var woodRoadDragEndpoint = [-85.623867390213, 41.95466987786487];
58686     var woodRoadDragMidpoint = [-85.62386254803509, 41.95430395953872];
58687     var washingtonStreetID = "w522";
58688     var twelfthAvenueID = "w1";
58689     var eleventhAvenueEndID = "n3550";
58690     var twelfthAvenueEndID = "n5";
58691     var _washingtonSegmentID = null;
58692     var eleventhAvenueEnd = context.entity(eleventhAvenueEndID).loc;
58693     var twelfthAvenueEnd = context.entity(twelfthAvenueEndID).loc;
58694     var deleteLinesLoc = [-85.6219395542764, 41.95228033922477];
58695     var twelfthAvenue = [-85.62219310052491, 41.952505413152956];
58696     var chapter = {
58697       title: "intro.lines.title"
58698     };
58699     function timeout2(f2, t2) {
58700       timeouts.push(window.setTimeout(f2, t2));
58701     }
58702     function eventCancel(d3_event) {
58703       d3_event.stopPropagation();
58704       d3_event.preventDefault();
58705     }
58706     function addLine() {
58707       context.enter(modeBrowse(context));
58708       context.history().reset("initial");
58709       var msec = transitionTime(tulipRoadStart, context.map().center());
58710       if (msec) {
58711         reveal(null, null, { duration: 0 });
58712       }
58713       context.map().centerZoomEase(tulipRoadStart, 18.5, msec);
58714       timeout2(function() {
58715         var tooltip = reveal(
58716           "button.add-line",
58717           helpHtml("intro.lines.add_line")
58718         );
58719         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-lines");
58720         context.on("enter.intro", function(mode) {
58721           if (mode.id !== "add-line") return;
58722           continueTo(startLine);
58723         });
58724       }, msec + 100);
58725       function continueTo(nextStep) {
58726         context.on("enter.intro", null);
58727         nextStep();
58728       }
58729     }
58730     function startLine() {
58731       if (context.mode().id !== "add-line") return chapter.restart();
58732       _tulipRoadID = null;
58733       var padding = 70 * Math.pow(2, context.map().zoom() - 18);
58734       var box = pad(tulipRoadStart, padding, context);
58735       box.height = box.height + 100;
58736       var textId = context.lastPointerType() === "mouse" ? "start_line" : "start_line_tap";
58737       var startLineString = helpHtml("intro.lines.missing_road") + "{br}" + helpHtml("intro.lines.line_draw_info") + helpHtml("intro.lines." + textId);
58738       reveal(box, startLineString);
58739       context.map().on("move.intro drawn.intro", function() {
58740         padding = 70 * Math.pow(2, context.map().zoom() - 18);
58741         box = pad(tulipRoadStart, padding, context);
58742         box.height = box.height + 100;
58743         reveal(box, startLineString, { duration: 0 });
58744       });
58745       context.on("enter.intro", function(mode) {
58746         if (mode.id !== "draw-line") return chapter.restart();
58747         continueTo(drawLine);
58748       });
58749       function continueTo(nextStep) {
58750         context.map().on("move.intro drawn.intro", null);
58751         context.on("enter.intro", null);
58752         nextStep();
58753       }
58754     }
58755     function drawLine() {
58756       if (context.mode().id !== "draw-line") return chapter.restart();
58757       _tulipRoadID = context.mode().selectedIDs()[0];
58758       context.map().centerEase(tulipRoadMidpoint, 500);
58759       timeout2(function() {
58760         var padding = 200 * Math.pow(2, context.map().zoom() - 18.5);
58761         var box = pad(tulipRoadMidpoint, padding, context);
58762         box.height = box.height * 2;
58763         reveal(
58764           box,
58765           helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") })
58766         );
58767         context.map().on("move.intro drawn.intro", function() {
58768           padding = 200 * Math.pow(2, context.map().zoom() - 18.5);
58769           box = pad(tulipRoadMidpoint, padding, context);
58770           box.height = box.height * 2;
58771           reveal(
58772             box,
58773             helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") }),
58774             { duration: 0 }
58775           );
58776         });
58777       }, 550);
58778       context.history().on("change.intro", function() {
58779         if (isLineConnected()) {
58780           continueTo(continueLine);
58781         }
58782       });
58783       context.on("enter.intro", function(mode) {
58784         if (mode.id === "draw-line") {
58785           return;
58786         } else if (mode.id === "select") {
58787           continueTo(retryIntersect);
58788           return;
58789         } else {
58790           return chapter.restart();
58791         }
58792       });
58793       function continueTo(nextStep) {
58794         context.map().on("move.intro drawn.intro", null);
58795         context.history().on("change.intro", null);
58796         context.on("enter.intro", null);
58797         nextStep();
58798       }
58799     }
58800     function isLineConnected() {
58801       var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
58802       if (!entity) return false;
58803       var drawNodes = context.graph().childNodes(entity);
58804       return drawNodes.some(function(node) {
58805         return context.graph().parentWays(node).some(function(parent) {
58806           return parent.id === flowerRoadID;
58807         });
58808       });
58809     }
58810     function retryIntersect() {
58811       select_default2(window).on("pointerdown.intro mousedown.intro", eventCancel, true);
58812       var box = pad(tulipRoadIntersection, 80, context);
58813       reveal(
58814         box,
58815         helpHtml("intro.lines.retry_intersect", { name: _t("intro.graph.name.flower-street") })
58816       );
58817       timeout2(chapter.restart, 3e3);
58818     }
58819     function continueLine() {
58820       if (context.mode().id !== "draw-line") return chapter.restart();
58821       var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
58822       if (!entity) return chapter.restart();
58823       context.map().centerEase(tulipRoadIntersection, 500);
58824       var continueLineText = helpHtml("intro.lines.continue_line") + "{br}" + helpHtml("intro.lines.finish_line_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.lines.finish_road");
58825       reveal(".main-map .surface", continueLineText);
58826       context.on("enter.intro", function(mode) {
58827         if (mode.id === "draw-line") {
58828           return;
58829         } else if (mode.id === "select") {
58830           return continueTo(chooseCategoryRoad);
58831         } else {
58832           return chapter.restart();
58833         }
58834       });
58835       function continueTo(nextStep) {
58836         context.on("enter.intro", null);
58837         nextStep();
58838       }
58839     }
58840     function chooseCategoryRoad() {
58841       if (context.mode().id !== "select") return chapter.restart();
58842       context.on("exit.intro", function() {
58843         return chapter.restart();
58844       });
58845       var button = context.container().select(".preset-category-road_minor .preset-list-button");
58846       if (button.empty()) return chapter.restart();
58847       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58848       timeout2(function() {
58849         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
58850         reveal(
58851           button.node(),
58852           helpHtml("intro.lines.choose_category_road", { category: roadCategory.name() })
58853         );
58854         button.on("click.intro", function() {
58855           continueTo(choosePresetResidential);
58856         });
58857       }, 400);
58858       function continueTo(nextStep) {
58859         context.container().select(".inspector-wrap").on("wheel.intro", null);
58860         context.container().select(".preset-list-button").on("click.intro", null);
58861         context.on("exit.intro", null);
58862         nextStep();
58863       }
58864     }
58865     function choosePresetResidential() {
58866       if (context.mode().id !== "select") return chapter.restart();
58867       context.on("exit.intro", function() {
58868         return chapter.restart();
58869       });
58870       var subgrid = context.container().select(".preset-category-road_minor .subgrid");
58871       if (subgrid.empty()) return chapter.restart();
58872       subgrid.selectAll(":not(.preset-highway-residential) .preset-list-button").on("click.intro", function() {
58873         continueTo(retryPresetResidential);
58874       });
58875       subgrid.selectAll(".preset-highway-residential .preset-list-button").on("click.intro", function() {
58876         continueTo(nameRoad);
58877       });
58878       timeout2(function() {
58879         reveal(
58880           subgrid.node(),
58881           helpHtml("intro.lines.choose_preset_residential", { preset: residentialPreset.name() }),
58882           { tooltipBox: ".preset-highway-residential .preset-list-button", duration: 300 }
58883         );
58884       }, 300);
58885       function continueTo(nextStep) {
58886         context.container().select(".preset-list-button").on("click.intro", null);
58887         context.on("exit.intro", null);
58888         nextStep();
58889       }
58890     }
58891     function retryPresetResidential() {
58892       if (context.mode().id !== "select") return chapter.restart();
58893       context.on("exit.intro", function() {
58894         return chapter.restart();
58895       });
58896       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
58897       timeout2(function() {
58898         var button = context.container().select(".entity-editor-pane .preset-list-button");
58899         reveal(
58900           button.node(),
58901           helpHtml("intro.lines.retry_preset_residential", { preset: residentialPreset.name() })
58902         );
58903         button.on("click.intro", function() {
58904           continueTo(chooseCategoryRoad);
58905         });
58906       }, 500);
58907       function continueTo(nextStep) {
58908         context.container().select(".inspector-wrap").on("wheel.intro", null);
58909         context.container().select(".preset-list-button").on("click.intro", null);
58910         context.on("exit.intro", null);
58911         nextStep();
58912       }
58913     }
58914     function nameRoad() {
58915       context.on("exit.intro", function() {
58916         continueTo(didNameRoad);
58917       });
58918       timeout2(function() {
58919         reveal(
58920           ".entity-editor-pane",
58921           helpHtml("intro.lines.name_road", { button: { html: icon("#iD-icon-close", "inline") } }),
58922           { tooltipClass: "intro-lines-name_road" }
58923         );
58924       }, 500);
58925       function continueTo(nextStep) {
58926         context.on("exit.intro", null);
58927         nextStep();
58928       }
58929     }
58930     function didNameRoad() {
58931       context.history().checkpoint("doneAddLine");
58932       timeout2(function() {
58933         reveal(".main-map .surface", helpHtml("intro.lines.did_name_road"), {
58934           buttonText: _t.html("intro.ok"),
58935           buttonCallback: function() {
58936             continueTo(updateLine);
58937           }
58938         });
58939       }, 500);
58940       function continueTo(nextStep) {
58941         nextStep();
58942       }
58943     }
58944     function updateLine() {
58945       context.history().reset("doneAddLine");
58946       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
58947         return chapter.restart();
58948       }
58949       var msec = transitionTime(woodRoadDragMidpoint, context.map().center());
58950       if (msec) {
58951         reveal(null, null, { duration: 0 });
58952       }
58953       context.map().centerZoomEase(woodRoadDragMidpoint, 19, msec);
58954       timeout2(function() {
58955         var padding = 250 * Math.pow(2, context.map().zoom() - 19);
58956         var box = pad(woodRoadDragMidpoint, padding, context);
58957         var advance = function() {
58958           continueTo(addNode);
58959         };
58960         reveal(
58961           box,
58962           helpHtml("intro.lines.update_line"),
58963           { buttonText: _t.html("intro.ok"), buttonCallback: advance }
58964         );
58965         context.map().on("move.intro drawn.intro", function() {
58966           var padding2 = 250 * Math.pow(2, context.map().zoom() - 19);
58967           var box2 = pad(woodRoadDragMidpoint, padding2, context);
58968           reveal(
58969             box2,
58970             helpHtml("intro.lines.update_line"),
58971             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
58972           );
58973         });
58974       }, msec + 100);
58975       function continueTo(nextStep) {
58976         context.map().on("move.intro drawn.intro", null);
58977         nextStep();
58978       }
58979     }
58980     function addNode() {
58981       context.history().reset("doneAddLine");
58982       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
58983         return chapter.restart();
58984       }
58985       var padding = 40 * Math.pow(2, context.map().zoom() - 19);
58986       var box = pad(woodRoadAddNode, padding, context);
58987       var addNodeString = helpHtml("intro.lines.add_node" + (context.lastPointerType() === "mouse" ? "" : "_touch"));
58988       reveal(box, addNodeString);
58989       context.map().on("move.intro drawn.intro", function() {
58990         var padding2 = 40 * Math.pow(2, context.map().zoom() - 19);
58991         var box2 = pad(woodRoadAddNode, padding2, context);
58992         reveal(box2, addNodeString, { duration: 0 });
58993       });
58994       context.history().on("change.intro", function(changed) {
58995         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
58996           return continueTo(updateLine);
58997         }
58998         if (changed.created().length === 1) {
58999           timeout2(function() {
59000             continueTo(startDragEndpoint);
59001           }, 500);
59002         }
59003       });
59004       context.on("enter.intro", function(mode) {
59005         if (mode.id !== "select") {
59006           continueTo(updateLine);
59007         }
59008       });
59009       function continueTo(nextStep) {
59010         context.map().on("move.intro drawn.intro", null);
59011         context.history().on("change.intro", null);
59012         context.on("enter.intro", null);
59013         nextStep();
59014       }
59015     }
59016     function startDragEndpoint() {
59017       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59018         return continueTo(updateLine);
59019       }
59020       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
59021       var box = pad(woodRoadDragEndpoint, padding, context);
59022       var startDragString = helpHtml("intro.lines.start_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch")) + helpHtml("intro.lines.drag_to_intersection");
59023       reveal(box, startDragString);
59024       context.map().on("move.intro drawn.intro", function() {
59025         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59026           return continueTo(updateLine);
59027         }
59028         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
59029         var box2 = pad(woodRoadDragEndpoint, padding2, context);
59030         reveal(box2, startDragString, { duration: 0 });
59031         var entity = context.entity(woodRoadEndID);
59032         if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) <= 4) {
59033           continueTo(finishDragEndpoint);
59034         }
59035       });
59036       function continueTo(nextStep) {
59037         context.map().on("move.intro drawn.intro", null);
59038         nextStep();
59039       }
59040     }
59041     function finishDragEndpoint() {
59042       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59043         return continueTo(updateLine);
59044       }
59045       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
59046       var box = pad(woodRoadDragEndpoint, padding, context);
59047       var finishDragString = helpHtml("intro.lines.spot_looks_good") + helpHtml("intro.lines.finish_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch"));
59048       reveal(box, finishDragString);
59049       context.map().on("move.intro drawn.intro", function() {
59050         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59051           return continueTo(updateLine);
59052         }
59053         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
59054         var box2 = pad(woodRoadDragEndpoint, padding2, context);
59055         reveal(box2, finishDragString, { duration: 0 });
59056         var entity = context.entity(woodRoadEndID);
59057         if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) > 4) {
59058           continueTo(startDragEndpoint);
59059         }
59060       });
59061       context.on("enter.intro", function() {
59062         continueTo(startDragMidpoint);
59063       });
59064       function continueTo(nextStep) {
59065         context.map().on("move.intro drawn.intro", null);
59066         context.on("enter.intro", null);
59067         nextStep();
59068       }
59069     }
59070     function startDragMidpoint() {
59071       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59072         return continueTo(updateLine);
59073       }
59074       if (context.selectedIDs().indexOf(woodRoadID) === -1) {
59075         context.enter(modeSelect(context, [woodRoadID]));
59076       }
59077       var padding = 80 * Math.pow(2, context.map().zoom() - 19);
59078       var box = pad(woodRoadDragMidpoint, padding, context);
59079       reveal(box, helpHtml("intro.lines.start_drag_midpoint"));
59080       context.map().on("move.intro drawn.intro", function() {
59081         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59082           return continueTo(updateLine);
59083         }
59084         var padding2 = 80 * Math.pow(2, context.map().zoom() - 19);
59085         var box2 = pad(woodRoadDragMidpoint, padding2, context);
59086         reveal(box2, helpHtml("intro.lines.start_drag_midpoint"), { duration: 0 });
59087       });
59088       context.history().on("change.intro", function(changed) {
59089         if (changed.created().length === 1) {
59090           continueTo(continueDragMidpoint);
59091         }
59092       });
59093       context.on("enter.intro", function(mode) {
59094         if (mode.id !== "select") {
59095           context.enter(modeSelect(context, [woodRoadID]));
59096         }
59097       });
59098       function continueTo(nextStep) {
59099         context.map().on("move.intro drawn.intro", null);
59100         context.history().on("change.intro", null);
59101         context.on("enter.intro", null);
59102         nextStep();
59103       }
59104     }
59105     function continueDragMidpoint() {
59106       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59107         return continueTo(updateLine);
59108       }
59109       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
59110       var box = pad(woodRoadDragEndpoint, padding, context);
59111       box.height += 400;
59112       var advance = function() {
59113         context.history().checkpoint("doneUpdateLine");
59114         continueTo(deleteLines);
59115       };
59116       reveal(
59117         box,
59118         helpHtml("intro.lines.continue_drag_midpoint"),
59119         { buttonText: _t.html("intro.ok"), buttonCallback: advance }
59120       );
59121       context.map().on("move.intro drawn.intro", function() {
59122         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
59123           return continueTo(updateLine);
59124         }
59125         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
59126         var box2 = pad(woodRoadDragEndpoint, padding2, context);
59127         box2.height += 400;
59128         reveal(
59129           box2,
59130           helpHtml("intro.lines.continue_drag_midpoint"),
59131           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
59132         );
59133       });
59134       function continueTo(nextStep) {
59135         context.map().on("move.intro drawn.intro", null);
59136         nextStep();
59137       }
59138     }
59139     function deleteLines() {
59140       context.history().reset("doneUpdateLine");
59141       context.enter(modeBrowse(context));
59142       if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59143         return chapter.restart();
59144       }
59145       var msec = transitionTime(deleteLinesLoc, context.map().center());
59146       if (msec) {
59147         reveal(null, null, { duration: 0 });
59148       }
59149       context.map().centerZoomEase(deleteLinesLoc, 18, msec);
59150       timeout2(function() {
59151         var padding = 200 * Math.pow(2, context.map().zoom() - 18);
59152         var box = pad(deleteLinesLoc, padding, context);
59153         box.top -= 200;
59154         box.height += 400;
59155         var advance = function() {
59156           continueTo(rightClickIntersection);
59157         };
59158         reveal(
59159           box,
59160           helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }),
59161           { buttonText: _t.html("intro.ok"), buttonCallback: advance }
59162         );
59163         context.map().on("move.intro drawn.intro", function() {
59164           var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
59165           var box2 = pad(deleteLinesLoc, padding2, context);
59166           box2.top -= 200;
59167           box2.height += 400;
59168           reveal(
59169             box2,
59170             helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }),
59171             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
59172           );
59173         });
59174         context.history().on("change.intro", function() {
59175           timeout2(function() {
59176             continueTo(deleteLines);
59177           }, 500);
59178         });
59179       }, msec + 100);
59180       function continueTo(nextStep) {
59181         context.map().on("move.intro drawn.intro", null);
59182         context.history().on("change.intro", null);
59183         nextStep();
59184       }
59185     }
59186     function rightClickIntersection() {
59187       context.history().reset("doneUpdateLine");
59188       context.enter(modeBrowse(context));
59189       context.map().centerZoomEase(eleventhAvenueEnd, 18, 500);
59190       var rightClickString = helpHtml("intro.lines.split_street", {
59191         street1: _t("intro.graph.name.11th-avenue"),
59192         street2: _t("intro.graph.name.washington-street")
59193       }) + helpHtml("intro.lines." + (context.lastPointerType() === "mouse" ? "rightclick_intersection" : "edit_menu_intersection_touch"));
59194       timeout2(function() {
59195         var padding = 60 * Math.pow(2, context.map().zoom() - 18);
59196         var box = pad(eleventhAvenueEnd, padding, context);
59197         reveal(box, rightClickString);
59198         context.map().on("move.intro drawn.intro", function() {
59199           var padding2 = 60 * Math.pow(2, context.map().zoom() - 18);
59200           var box2 = pad(eleventhAvenueEnd, padding2, context);
59201           reveal(
59202             box2,
59203             rightClickString,
59204             { duration: 0 }
59205           );
59206         });
59207         context.on("enter.intro", function(mode) {
59208           if (mode.id !== "select") return;
59209           var ids = context.selectedIDs();
59210           if (ids.length !== 1 || ids[0] !== eleventhAvenueEndID) return;
59211           timeout2(function() {
59212             var node = selectMenuItem(context, "split").node();
59213             if (!node) return;
59214             continueTo(splitIntersection);
59215           }, 50);
59216         });
59217         context.history().on("change.intro", function() {
59218           timeout2(function() {
59219             continueTo(deleteLines);
59220           }, 300);
59221         });
59222       }, 600);
59223       function continueTo(nextStep) {
59224         context.map().on("move.intro drawn.intro", null);
59225         context.on("enter.intro", null);
59226         context.history().on("change.intro", null);
59227         nextStep();
59228       }
59229     }
59230     function splitIntersection() {
59231       if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59232         return continueTo(deleteLines);
59233       }
59234       var node = selectMenuItem(context, "split").node();
59235       if (!node) {
59236         return continueTo(rightClickIntersection);
59237       }
59238       var wasChanged = false;
59239       _washingtonSegmentID = null;
59240       reveal(
59241         ".edit-menu",
59242         helpHtml(
59243           "intro.lines.split_intersection",
59244           { street: _t("intro.graph.name.washington-street") }
59245         ),
59246         { padding: 50 }
59247       );
59248       context.map().on("move.intro drawn.intro", function() {
59249         var node2 = selectMenuItem(context, "split").node();
59250         if (!wasChanged && !node2) {
59251           return continueTo(rightClickIntersection);
59252         }
59253         reveal(
59254           ".edit-menu",
59255           helpHtml(
59256             "intro.lines.split_intersection",
59257             { street: _t("intro.graph.name.washington-street") }
59258           ),
59259           { duration: 0, padding: 50 }
59260         );
59261       });
59262       context.history().on("change.intro", function(changed) {
59263         wasChanged = true;
59264         timeout2(function() {
59265           if (context.history().undoAnnotation() === _t("operations.split.annotation.line", { n: 1 })) {
59266             _washingtonSegmentID = changed.created()[0].id;
59267             continueTo(didSplit);
59268           } else {
59269             _washingtonSegmentID = null;
59270             continueTo(retrySplit);
59271           }
59272         }, 300);
59273       });
59274       function continueTo(nextStep) {
59275         context.map().on("move.intro drawn.intro", null);
59276         context.history().on("change.intro", null);
59277         nextStep();
59278       }
59279     }
59280     function retrySplit() {
59281       context.enter(modeBrowse(context));
59282       context.map().centerZoomEase(eleventhAvenueEnd, 18, 500);
59283       var advance = function() {
59284         continueTo(rightClickIntersection);
59285       };
59286       var padding = 60 * Math.pow(2, context.map().zoom() - 18);
59287       var box = pad(eleventhAvenueEnd, padding, context);
59288       reveal(
59289         box,
59290         helpHtml("intro.lines.retry_split"),
59291         { buttonText: _t.html("intro.ok"), buttonCallback: advance }
59292       );
59293       context.map().on("move.intro drawn.intro", function() {
59294         var padding2 = 60 * Math.pow(2, context.map().zoom() - 18);
59295         var box2 = pad(eleventhAvenueEnd, padding2, context);
59296         reveal(
59297           box2,
59298           helpHtml("intro.lines.retry_split"),
59299           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
59300         );
59301       });
59302       function continueTo(nextStep) {
59303         context.map().on("move.intro drawn.intro", null);
59304         nextStep();
59305       }
59306     }
59307     function didSplit() {
59308       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59309         return continueTo(rightClickIntersection);
59310       }
59311       var ids = context.selectedIDs();
59312       var string = "intro.lines.did_split_" + (ids.length > 1 ? "multi" : "single");
59313       var street = _t("intro.graph.name.washington-street");
59314       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
59315       var box = pad(twelfthAvenue, padding, context);
59316       box.width = box.width / 2;
59317       reveal(
59318         box,
59319         helpHtml(string, { street1: street, street2: street }),
59320         { duration: 500 }
59321       );
59322       timeout2(function() {
59323         context.map().centerZoomEase(twelfthAvenue, 18, 500);
59324         context.map().on("move.intro drawn.intro", function() {
59325           var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
59326           var box2 = pad(twelfthAvenue, padding2, context);
59327           box2.width = box2.width / 2;
59328           reveal(
59329             box2,
59330             helpHtml(string, { street1: street, street2: street }),
59331             { duration: 0 }
59332           );
59333         });
59334       }, 600);
59335       context.on("enter.intro", function() {
59336         var ids2 = context.selectedIDs();
59337         if (ids2.length === 1 && ids2[0] === _washingtonSegmentID) {
59338           continueTo(multiSelect2);
59339         }
59340       });
59341       context.history().on("change.intro", function() {
59342         if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59343           return continueTo(rightClickIntersection);
59344         }
59345       });
59346       function continueTo(nextStep) {
59347         context.map().on("move.intro drawn.intro", null);
59348         context.on("enter.intro", null);
59349         context.history().on("change.intro", null);
59350         nextStep();
59351       }
59352     }
59353     function multiSelect2() {
59354       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59355         return continueTo(rightClickIntersection);
59356       }
59357       var ids = context.selectedIDs();
59358       var hasWashington = ids.indexOf(_washingtonSegmentID) !== -1;
59359       var hasTwelfth = ids.indexOf(twelfthAvenueID) !== -1;
59360       if (hasWashington && hasTwelfth) {
59361         return continueTo(multiRightClick);
59362       } else if (!hasWashington && !hasTwelfth) {
59363         return continueTo(didSplit);
59364       }
59365       context.map().centerZoomEase(twelfthAvenue, 18, 500);
59366       timeout2(function() {
59367         var selected, other2, padding, box;
59368         if (hasWashington) {
59369           selected = _t("intro.graph.name.washington-street");
59370           other2 = _t("intro.graph.name.12th-avenue");
59371           padding = 60 * Math.pow(2, context.map().zoom() - 18);
59372           box = pad(twelfthAvenueEnd, padding, context);
59373           box.width *= 3;
59374         } else {
59375           selected = _t("intro.graph.name.12th-avenue");
59376           other2 = _t("intro.graph.name.washington-street");
59377           padding = 200 * Math.pow(2, context.map().zoom() - 18);
59378           box = pad(twelfthAvenue, padding, context);
59379           box.width /= 2;
59380         }
59381         reveal(
59382           box,
59383           helpHtml(
59384             "intro.lines.multi_select",
59385             { selected, other1: other2 }
59386           ) + " " + helpHtml(
59387             "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"),
59388             { selected, other2 }
59389           )
59390         );
59391         context.map().on("move.intro drawn.intro", function() {
59392           if (hasWashington) {
59393             selected = _t("intro.graph.name.washington-street");
59394             other2 = _t("intro.graph.name.12th-avenue");
59395             padding = 60 * Math.pow(2, context.map().zoom() - 18);
59396             box = pad(twelfthAvenueEnd, padding, context);
59397             box.width *= 3;
59398           } else {
59399             selected = _t("intro.graph.name.12th-avenue");
59400             other2 = _t("intro.graph.name.washington-street");
59401             padding = 200 * Math.pow(2, context.map().zoom() - 18);
59402             box = pad(twelfthAvenue, padding, context);
59403             box.width /= 2;
59404           }
59405           reveal(
59406             box,
59407             helpHtml(
59408               "intro.lines.multi_select",
59409               { selected, other1: other2 }
59410             ) + " " + helpHtml(
59411               "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"),
59412               { selected, other2 }
59413             ),
59414             { duration: 0 }
59415           );
59416         });
59417         context.on("enter.intro", function() {
59418           continueTo(multiSelect2);
59419         });
59420         context.history().on("change.intro", function() {
59421           if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59422             return continueTo(rightClickIntersection);
59423           }
59424         });
59425       }, 600);
59426       function continueTo(nextStep) {
59427         context.map().on("move.intro drawn.intro", null);
59428         context.on("enter.intro", null);
59429         context.history().on("change.intro", null);
59430         nextStep();
59431       }
59432     }
59433     function multiRightClick() {
59434       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59435         return continueTo(rightClickIntersection);
59436       }
59437       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
59438       var box = pad(twelfthAvenue, padding, context);
59439       var rightClickString = helpHtml("intro.lines.multi_select_success") + helpHtml("intro.lines.multi_" + (context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch"));
59440       reveal(box, rightClickString);
59441       context.map().on("move.intro drawn.intro", function() {
59442         var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
59443         var box2 = pad(twelfthAvenue, padding2, context);
59444         reveal(box2, rightClickString, { duration: 0 });
59445       });
59446       context.ui().editMenu().on("toggled.intro", function(open) {
59447         if (!open) return;
59448         timeout2(function() {
59449           var ids = context.selectedIDs();
59450           if (ids.length === 2 && ids.indexOf(twelfthAvenueID) !== -1 && ids.indexOf(_washingtonSegmentID) !== -1) {
59451             var node = selectMenuItem(context, "delete").node();
59452             if (!node) return;
59453             continueTo(multiDelete);
59454           } else if (ids.length === 1 && ids.indexOf(_washingtonSegmentID) !== -1) {
59455             return continueTo(multiSelect2);
59456           } else {
59457             return continueTo(didSplit);
59458           }
59459         }, 300);
59460       });
59461       context.history().on("change.intro", function() {
59462         if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59463           return continueTo(rightClickIntersection);
59464         }
59465       });
59466       function continueTo(nextStep) {
59467         context.map().on("move.intro drawn.intro", null);
59468         context.ui().editMenu().on("toggled.intro", null);
59469         context.history().on("change.intro", null);
59470         nextStep();
59471       }
59472     }
59473     function multiDelete() {
59474       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
59475         return continueTo(rightClickIntersection);
59476       }
59477       var node = selectMenuItem(context, "delete").node();
59478       if (!node) return continueTo(multiRightClick);
59479       reveal(
59480         ".edit-menu",
59481         helpHtml("intro.lines.multi_delete"),
59482         { padding: 50 }
59483       );
59484       context.map().on("move.intro drawn.intro", function() {
59485         if (selectMenuItem(context, "delete").empty()) {
59486           return continueTo(multiRightClick);
59487         }
59488         reveal(
59489           ".edit-menu",
59490           helpHtml("intro.lines.multi_delete"),
59491           { duration: 0, padding: 50 }
59492         );
59493       });
59494       context.on("exit.intro", function() {
59495         if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
59496           return continueTo(multiSelect2);
59497         }
59498       });
59499       context.history().on("change.intro", function() {
59500         if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
59501           continueTo(retryDelete);
59502         } else {
59503           continueTo(play);
59504         }
59505       });
59506       function continueTo(nextStep) {
59507         context.map().on("move.intro drawn.intro", null);
59508         context.on("exit.intro", null);
59509         context.history().on("change.intro", null);
59510         nextStep();
59511       }
59512     }
59513     function retryDelete() {
59514       context.enter(modeBrowse(context));
59515       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
59516       var box = pad(twelfthAvenue, padding, context);
59517       reveal(box, helpHtml("intro.lines.retry_delete"), {
59518         buttonText: _t.html("intro.ok"),
59519         buttonCallback: function() {
59520           continueTo(multiSelect2);
59521         }
59522       });
59523       function continueTo(nextStep) {
59524         nextStep();
59525       }
59526     }
59527     function play() {
59528       dispatch14.call("done");
59529       reveal(
59530         ".ideditor",
59531         helpHtml("intro.lines.play", { next: _t("intro.buildings.title") }),
59532         {
59533           tooltipBox: ".intro-nav-wrap .chapter-building",
59534           buttonText: _t.html("intro.ok"),
59535           buttonCallback: function() {
59536             reveal(".ideditor");
59537           }
59538         }
59539       );
59540     }
59541     chapter.enter = function() {
59542       addLine();
59543     };
59544     chapter.exit = function() {
59545       timeouts.forEach(window.clearTimeout);
59546       select_default2(window).on("pointerdown.intro mousedown.intro", null, true);
59547       context.on("enter.intro exit.intro", null);
59548       context.map().on("move.intro drawn.intro", null);
59549       context.history().on("change.intro", null);
59550       context.container().select(".inspector-wrap").on("wheel.intro", null);
59551       context.container().select(".preset-list-button").on("click.intro", null);
59552     };
59553     chapter.restart = function() {
59554       chapter.exit();
59555       chapter.enter();
59556     };
59557     return utilRebind(chapter, dispatch14, "on");
59558   }
59559
59560   // modules/ui/intro/building.js
59561   function uiIntroBuilding(context, reveal) {
59562     var dispatch14 = dispatch_default("done");
59563     var house = [-85.62815, 41.95638];
59564     var tank = [-85.62732, 41.95347];
59565     var buildingCatetory = _mainPresetIndex.item("category-building");
59566     var housePreset = _mainPresetIndex.item("building/house");
59567     var tankPreset = _mainPresetIndex.item("man_made/storage_tank");
59568     var timeouts = [];
59569     var _houseID = null;
59570     var _tankID = null;
59571     var chapter = {
59572       title: "intro.buildings.title"
59573     };
59574     function timeout2(f2, t2) {
59575       timeouts.push(window.setTimeout(f2, t2));
59576     }
59577     function eventCancel(d3_event) {
59578       d3_event.stopPropagation();
59579       d3_event.preventDefault();
59580     }
59581     function revealHouse(center, text, options2) {
59582       var padding = 160 * Math.pow(2, context.map().zoom() - 20);
59583       var box = pad(center, padding, context);
59584       reveal(box, text, options2);
59585     }
59586     function revealTank(center, text, options2) {
59587       var padding = 190 * Math.pow(2, context.map().zoom() - 19.5);
59588       var box = pad(center, padding, context);
59589       reveal(box, text, options2);
59590     }
59591     function addHouse() {
59592       context.enter(modeBrowse(context));
59593       context.history().reset("initial");
59594       _houseID = null;
59595       var msec = transitionTime(house, context.map().center());
59596       if (msec) {
59597         reveal(null, null, { duration: 0 });
59598       }
59599       context.map().centerZoomEase(house, 19, msec);
59600       timeout2(function() {
59601         var tooltip = reveal(
59602           "button.add-area",
59603           helpHtml("intro.buildings.add_building")
59604         );
59605         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-buildings");
59606         context.on("enter.intro", function(mode) {
59607           if (mode.id !== "add-area") return;
59608           continueTo(startHouse);
59609         });
59610       }, msec + 100);
59611       function continueTo(nextStep) {
59612         context.on("enter.intro", null);
59613         nextStep();
59614       }
59615     }
59616     function startHouse() {
59617       if (context.mode().id !== "add-area") {
59618         return continueTo(addHouse);
59619       }
59620       _houseID = null;
59621       context.map().zoomEase(20, 500);
59622       timeout2(function() {
59623         var startString = helpHtml("intro.buildings.start_building") + helpHtml("intro.buildings.building_corner_" + (context.lastPointerType() === "mouse" ? "click" : "tap"));
59624         revealHouse(house, startString);
59625         context.map().on("move.intro drawn.intro", function() {
59626           revealHouse(house, startString, { duration: 0 });
59627         });
59628         context.on("enter.intro", function(mode) {
59629           if (mode.id !== "draw-area") return chapter.restart();
59630           continueTo(continueHouse);
59631         });
59632       }, 550);
59633       function continueTo(nextStep) {
59634         context.map().on("move.intro drawn.intro", null);
59635         context.on("enter.intro", null);
59636         nextStep();
59637       }
59638     }
59639     function continueHouse() {
59640       if (context.mode().id !== "draw-area") {
59641         return continueTo(addHouse);
59642       }
59643       _houseID = null;
59644       var continueString = helpHtml("intro.buildings.continue_building") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_building");
59645       revealHouse(house, continueString);
59646       context.map().on("move.intro drawn.intro", function() {
59647         revealHouse(house, continueString, { duration: 0 });
59648       });
59649       context.on("enter.intro", function(mode) {
59650         if (mode.id === "draw-area") {
59651           return;
59652         } else if (mode.id === "select") {
59653           var graph = context.graph();
59654           var way = context.entity(context.selectedIDs()[0]);
59655           var nodes = graph.childNodes(way);
59656           var points = utilArrayUniq(nodes).map(function(n3) {
59657             return context.projection(n3.loc);
59658           });
59659           if (isMostlySquare(points)) {
59660             _houseID = way.id;
59661             return continueTo(chooseCategoryBuilding);
59662           } else {
59663             return continueTo(retryHouse);
59664           }
59665         } else {
59666           return chapter.restart();
59667         }
59668       });
59669       function continueTo(nextStep) {
59670         context.map().on("move.intro drawn.intro", null);
59671         context.on("enter.intro", null);
59672         nextStep();
59673       }
59674     }
59675     function retryHouse() {
59676       var onClick = function() {
59677         continueTo(addHouse);
59678       };
59679       revealHouse(
59680         house,
59681         helpHtml("intro.buildings.retry_building"),
59682         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
59683       );
59684       context.map().on("move.intro drawn.intro", function() {
59685         revealHouse(
59686           house,
59687           helpHtml("intro.buildings.retry_building"),
59688           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
59689         );
59690       });
59691       function continueTo(nextStep) {
59692         context.map().on("move.intro drawn.intro", null);
59693         nextStep();
59694       }
59695     }
59696     function chooseCategoryBuilding() {
59697       if (!_houseID || !context.hasEntity(_houseID)) {
59698         return addHouse();
59699       }
59700       var ids = context.selectedIDs();
59701       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
59702         context.enter(modeSelect(context, [_houseID]));
59703       }
59704       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
59705       timeout2(function() {
59706         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
59707         var button = context.container().select(".preset-category-building .preset-list-button");
59708         reveal(
59709           button.node(),
59710           helpHtml("intro.buildings.choose_category_building", { category: buildingCatetory.name() })
59711         );
59712         button.on("click.intro", function() {
59713           button.on("click.intro", null);
59714           continueTo(choosePresetHouse);
59715         });
59716       }, 400);
59717       context.on("enter.intro", function(mode) {
59718         if (!_houseID || !context.hasEntity(_houseID)) {
59719           return continueTo(addHouse);
59720         }
59721         var ids2 = context.selectedIDs();
59722         if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) {
59723           return continueTo(chooseCategoryBuilding);
59724         }
59725       });
59726       function continueTo(nextStep) {
59727         context.container().select(".inspector-wrap").on("wheel.intro", null);
59728         context.container().select(".preset-list-button").on("click.intro", null);
59729         context.on("enter.intro", null);
59730         nextStep();
59731       }
59732     }
59733     function choosePresetHouse() {
59734       if (!_houseID || !context.hasEntity(_houseID)) {
59735         return addHouse();
59736       }
59737       var ids = context.selectedIDs();
59738       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
59739         context.enter(modeSelect(context, [_houseID]));
59740       }
59741       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
59742       timeout2(function() {
59743         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
59744         var button = context.container().select(".preset-building-house .preset-list-button");
59745         reveal(
59746           button.node(),
59747           helpHtml("intro.buildings.choose_preset_house", { preset: housePreset.name() }),
59748           { duration: 300 }
59749         );
59750         button.on("click.intro", function() {
59751           button.on("click.intro", null);
59752           continueTo(closeEditorHouse);
59753         });
59754       }, 400);
59755       context.on("enter.intro", function(mode) {
59756         if (!_houseID || !context.hasEntity(_houseID)) {
59757           return continueTo(addHouse);
59758         }
59759         var ids2 = context.selectedIDs();
59760         if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) {
59761           return continueTo(chooseCategoryBuilding);
59762         }
59763       });
59764       function continueTo(nextStep) {
59765         context.container().select(".inspector-wrap").on("wheel.intro", null);
59766         context.container().select(".preset-list-button").on("click.intro", null);
59767         context.on("enter.intro", null);
59768         nextStep();
59769       }
59770     }
59771     function closeEditorHouse() {
59772       if (!_houseID || !context.hasEntity(_houseID)) {
59773         return addHouse();
59774       }
59775       var ids = context.selectedIDs();
59776       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
59777         context.enter(modeSelect(context, [_houseID]));
59778       }
59779       context.history().checkpoint("hasHouse");
59780       context.on("exit.intro", function() {
59781         continueTo(rightClickHouse);
59782       });
59783       timeout2(function() {
59784         reveal(
59785           ".entity-editor-pane",
59786           helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } })
59787         );
59788       }, 500);
59789       function continueTo(nextStep) {
59790         context.on("exit.intro", null);
59791         nextStep();
59792       }
59793     }
59794     function rightClickHouse() {
59795       if (!_houseID) return chapter.restart();
59796       context.enter(modeBrowse(context));
59797       context.history().reset("hasHouse");
59798       var zoom = context.map().zoom();
59799       if (zoom < 20) {
59800         zoom = 20;
59801       }
59802       context.map().centerZoomEase(house, zoom, 500);
59803       context.on("enter.intro", function(mode) {
59804         if (mode.id !== "select") return;
59805         var ids = context.selectedIDs();
59806         if (ids.length !== 1 || ids[0] !== _houseID) return;
59807         timeout2(function() {
59808           var node = selectMenuItem(context, "orthogonalize").node();
59809           if (!node) return;
59810           continueTo(clickSquare);
59811         }, 50);
59812       });
59813       context.map().on("move.intro drawn.intro", function() {
59814         var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_building" : "edit_menu_building_touch"));
59815         revealHouse(house, rightclickString, { duration: 0 });
59816       });
59817       context.history().on("change.intro", function() {
59818         continueTo(rightClickHouse);
59819       });
59820       function continueTo(nextStep) {
59821         context.on("enter.intro", null);
59822         context.map().on("move.intro drawn.intro", null);
59823         context.history().on("change.intro", null);
59824         nextStep();
59825       }
59826     }
59827     function clickSquare() {
59828       if (!_houseID) return chapter.restart();
59829       var entity = context.hasEntity(_houseID);
59830       if (!entity) return continueTo(rightClickHouse);
59831       var node = selectMenuItem(context, "orthogonalize").node();
59832       if (!node) {
59833         return continueTo(rightClickHouse);
59834       }
59835       var wasChanged = false;
59836       reveal(
59837         ".edit-menu",
59838         helpHtml("intro.buildings.square_building"),
59839         { padding: 50 }
59840       );
59841       context.on("enter.intro", function(mode) {
59842         if (mode.id === "browse") {
59843           continueTo(rightClickHouse);
59844         } else if (mode.id === "move" || mode.id === "rotate") {
59845           continueTo(retryClickSquare);
59846         }
59847       });
59848       context.map().on("move.intro", function() {
59849         var node2 = selectMenuItem(context, "orthogonalize").node();
59850         if (!wasChanged && !node2) {
59851           return continueTo(rightClickHouse);
59852         }
59853         reveal(
59854           ".edit-menu",
59855           helpHtml("intro.buildings.square_building"),
59856           { duration: 0, padding: 50 }
59857         );
59858       });
59859       context.history().on("change.intro", function() {
59860         wasChanged = true;
59861         context.history().on("change.intro", null);
59862         timeout2(function() {
59863           if (context.history().undoAnnotation() === _t("operations.orthogonalize.annotation.feature", { n: 1 })) {
59864             continueTo(doneSquare);
59865           } else {
59866             continueTo(retryClickSquare);
59867           }
59868         }, 500);
59869       });
59870       function continueTo(nextStep) {
59871         context.on("enter.intro", null);
59872         context.map().on("move.intro", null);
59873         context.history().on("change.intro", null);
59874         nextStep();
59875       }
59876     }
59877     function retryClickSquare() {
59878       context.enter(modeBrowse(context));
59879       revealHouse(house, helpHtml("intro.buildings.retry_square"), {
59880         buttonText: _t.html("intro.ok"),
59881         buttonCallback: function() {
59882           continueTo(rightClickHouse);
59883         }
59884       });
59885       function continueTo(nextStep) {
59886         nextStep();
59887       }
59888     }
59889     function doneSquare() {
59890       context.history().checkpoint("doneSquare");
59891       revealHouse(house, helpHtml("intro.buildings.done_square"), {
59892         buttonText: _t.html("intro.ok"),
59893         buttonCallback: function() {
59894           continueTo(addTank);
59895         }
59896       });
59897       function continueTo(nextStep) {
59898         nextStep();
59899       }
59900     }
59901     function addTank() {
59902       context.enter(modeBrowse(context));
59903       context.history().reset("doneSquare");
59904       _tankID = null;
59905       var msec = transitionTime(tank, context.map().center());
59906       if (msec) {
59907         reveal(null, null, { duration: 0 });
59908       }
59909       context.map().centerZoomEase(tank, 19.5, msec);
59910       timeout2(function() {
59911         reveal(
59912           "button.add-area",
59913           helpHtml("intro.buildings.add_tank")
59914         );
59915         context.on("enter.intro", function(mode) {
59916           if (mode.id !== "add-area") return;
59917           continueTo(startTank);
59918         });
59919       }, msec + 100);
59920       function continueTo(nextStep) {
59921         context.on("enter.intro", null);
59922         nextStep();
59923       }
59924     }
59925     function startTank() {
59926       if (context.mode().id !== "add-area") {
59927         return continueTo(addTank);
59928       }
59929       _tankID = null;
59930       timeout2(function() {
59931         var startString = helpHtml("intro.buildings.start_tank") + helpHtml("intro.buildings.tank_edge_" + (context.lastPointerType() === "mouse" ? "click" : "tap"));
59932         revealTank(tank, startString);
59933         context.map().on("move.intro drawn.intro", function() {
59934           revealTank(tank, startString, { duration: 0 });
59935         });
59936         context.on("enter.intro", function(mode) {
59937           if (mode.id !== "draw-area") return chapter.restart();
59938           continueTo(continueTank);
59939         });
59940       }, 550);
59941       function continueTo(nextStep) {
59942         context.map().on("move.intro drawn.intro", null);
59943         context.on("enter.intro", null);
59944         nextStep();
59945       }
59946     }
59947     function continueTank() {
59948       if (context.mode().id !== "draw-area") {
59949         return continueTo(addTank);
59950       }
59951       _tankID = null;
59952       var continueString = helpHtml("intro.buildings.continue_tank") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_tank");
59953       revealTank(tank, continueString);
59954       context.map().on("move.intro drawn.intro", function() {
59955         revealTank(tank, continueString, { duration: 0 });
59956       });
59957       context.on("enter.intro", function(mode) {
59958         if (mode.id === "draw-area") {
59959           return;
59960         } else if (mode.id === "select") {
59961           _tankID = context.selectedIDs()[0];
59962           return continueTo(searchPresetTank);
59963         } else {
59964           return continueTo(addTank);
59965         }
59966       });
59967       function continueTo(nextStep) {
59968         context.map().on("move.intro drawn.intro", null);
59969         context.on("enter.intro", null);
59970         nextStep();
59971       }
59972     }
59973     function searchPresetTank() {
59974       if (!_tankID || !context.hasEntity(_tankID)) {
59975         return addTank();
59976       }
59977       var ids = context.selectedIDs();
59978       if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) {
59979         context.enter(modeSelect(context, [_tankID]));
59980       }
59981       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
59982       timeout2(function() {
59983         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
59984         context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
59985         reveal(
59986           ".preset-search-input",
59987           helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() })
59988         );
59989       }, 400);
59990       context.on("enter.intro", function(mode) {
59991         if (!_tankID || !context.hasEntity(_tankID)) {
59992           return continueTo(addTank);
59993         }
59994         var ids2 = context.selectedIDs();
59995         if (mode.id !== "select" || !ids2.length || ids2[0] !== _tankID) {
59996           context.enter(modeSelect(context, [_tankID]));
59997           context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
59998           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
59999           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
60000           reveal(
60001             ".preset-search-input",
60002             helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() })
60003           );
60004           context.history().on("change.intro", null);
60005         }
60006       });
60007       function checkPresetSearch() {
60008         var first = context.container().select(".preset-list-item:first-child");
60009         if (first.classed("preset-man_made-storage_tank")) {
60010           reveal(
60011             first.select(".preset-list-button").node(),
60012             helpHtml("intro.buildings.choose_tank", { preset: tankPreset.name() }),
60013             { duration: 300 }
60014           );
60015           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
60016           context.history().on("change.intro", function() {
60017             continueTo(closeEditorTank);
60018           });
60019         }
60020       }
60021       function continueTo(nextStep) {
60022         context.container().select(".inspector-wrap").on("wheel.intro", null);
60023         context.on("enter.intro", null);
60024         context.history().on("change.intro", null);
60025         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
60026         nextStep();
60027       }
60028     }
60029     function closeEditorTank() {
60030       if (!_tankID || !context.hasEntity(_tankID)) {
60031         return addTank();
60032       }
60033       var ids = context.selectedIDs();
60034       if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) {
60035         context.enter(modeSelect(context, [_tankID]));
60036       }
60037       context.history().checkpoint("hasTank");
60038       context.on("exit.intro", function() {
60039         continueTo(rightClickTank);
60040       });
60041       timeout2(function() {
60042         reveal(
60043           ".entity-editor-pane",
60044           helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } })
60045         );
60046       }, 500);
60047       function continueTo(nextStep) {
60048         context.on("exit.intro", null);
60049         nextStep();
60050       }
60051     }
60052     function rightClickTank() {
60053       if (!_tankID) return continueTo(addTank);
60054       context.enter(modeBrowse(context));
60055       context.history().reset("hasTank");
60056       context.map().centerEase(tank, 500);
60057       timeout2(function() {
60058         context.on("enter.intro", function(mode) {
60059           if (mode.id !== "select") return;
60060           var ids = context.selectedIDs();
60061           if (ids.length !== 1 || ids[0] !== _tankID) return;
60062           timeout2(function() {
60063             var node = selectMenuItem(context, "circularize").node();
60064             if (!node) return;
60065             continueTo(clickCircle);
60066           }, 50);
60067         });
60068         var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_tank" : "edit_menu_tank_touch"));
60069         revealTank(tank, rightclickString);
60070         context.map().on("move.intro drawn.intro", function() {
60071           revealTank(tank, rightclickString, { duration: 0 });
60072         });
60073         context.history().on("change.intro", function() {
60074           continueTo(rightClickTank);
60075         });
60076       }, 600);
60077       function continueTo(nextStep) {
60078         context.on("enter.intro", null);
60079         context.map().on("move.intro drawn.intro", null);
60080         context.history().on("change.intro", null);
60081         nextStep();
60082       }
60083     }
60084     function clickCircle() {
60085       if (!_tankID) return chapter.restart();
60086       var entity = context.hasEntity(_tankID);
60087       if (!entity) return continueTo(rightClickTank);
60088       var node = selectMenuItem(context, "circularize").node();
60089       if (!node) {
60090         return continueTo(rightClickTank);
60091       }
60092       var wasChanged = false;
60093       reveal(
60094         ".edit-menu",
60095         helpHtml("intro.buildings.circle_tank"),
60096         { padding: 50 }
60097       );
60098       context.on("enter.intro", function(mode) {
60099         if (mode.id === "browse") {
60100           continueTo(rightClickTank);
60101         } else if (mode.id === "move" || mode.id === "rotate") {
60102           continueTo(retryClickCircle);
60103         }
60104       });
60105       context.map().on("move.intro", function() {
60106         var node2 = selectMenuItem(context, "circularize").node();
60107         if (!wasChanged && !node2) {
60108           return continueTo(rightClickTank);
60109         }
60110         reveal(
60111           ".edit-menu",
60112           helpHtml("intro.buildings.circle_tank"),
60113           { duration: 0, padding: 50 }
60114         );
60115       });
60116       context.history().on("change.intro", function() {
60117         wasChanged = true;
60118         context.history().on("change.intro", null);
60119         timeout2(function() {
60120           if (context.history().undoAnnotation() === _t("operations.circularize.annotation.feature", { n: 1 })) {
60121             continueTo(play);
60122           } else {
60123             continueTo(retryClickCircle);
60124           }
60125         }, 500);
60126       });
60127       function continueTo(nextStep) {
60128         context.on("enter.intro", null);
60129         context.map().on("move.intro", null);
60130         context.history().on("change.intro", null);
60131         nextStep();
60132       }
60133     }
60134     function retryClickCircle() {
60135       context.enter(modeBrowse(context));
60136       revealTank(tank, helpHtml("intro.buildings.retry_circle"), {
60137         buttonText: _t.html("intro.ok"),
60138         buttonCallback: function() {
60139           continueTo(rightClickTank);
60140         }
60141       });
60142       function continueTo(nextStep) {
60143         nextStep();
60144       }
60145     }
60146     function play() {
60147       dispatch14.call("done");
60148       reveal(
60149         ".ideditor",
60150         helpHtml("intro.buildings.play", { next: _t("intro.startediting.title") }),
60151         {
60152           tooltipBox: ".intro-nav-wrap .chapter-startEditing",
60153           buttonText: _t.html("intro.ok"),
60154           buttonCallback: function() {
60155             reveal(".ideditor");
60156           }
60157         }
60158       );
60159     }
60160     chapter.enter = function() {
60161       addHouse();
60162     };
60163     chapter.exit = function() {
60164       timeouts.forEach(window.clearTimeout);
60165       context.on("enter.intro exit.intro", null);
60166       context.map().on("move.intro drawn.intro", null);
60167       context.history().on("change.intro", null);
60168       context.container().select(".inspector-wrap").on("wheel.intro", null);
60169       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
60170       context.container().select(".more-fields .combobox-input").on("click.intro", null);
60171     };
60172     chapter.restart = function() {
60173       chapter.exit();
60174       chapter.enter();
60175     };
60176     return utilRebind(chapter, dispatch14, "on");
60177   }
60178
60179   // modules/ui/intro/start_editing.js
60180   function uiIntroStartEditing(context, reveal) {
60181     var dispatch14 = dispatch_default("done", "startEditing");
60182     var modalSelection = select_default2(null);
60183     var chapter = {
60184       title: "intro.startediting.title"
60185     };
60186     function showHelp() {
60187       reveal(
60188         ".map-control.help-control",
60189         helpHtml("intro.startediting.help"),
60190         {
60191           buttonText: _t.html("intro.ok"),
60192           buttonCallback: function() {
60193             shortcuts();
60194           }
60195         }
60196       );
60197     }
60198     function shortcuts() {
60199       reveal(
60200         ".map-control.help-control",
60201         helpHtml("intro.startediting.shortcuts"),
60202         {
60203           buttonText: _t.html("intro.ok"),
60204           buttonCallback: function() {
60205             showSave();
60206           }
60207         }
60208       );
60209     }
60210     function showSave() {
60211       context.container().selectAll(".shaded").remove();
60212       reveal(
60213         ".top-toolbar button.save",
60214         helpHtml("intro.startediting.save"),
60215         {
60216           buttonText: _t.html("intro.ok"),
60217           buttonCallback: function() {
60218             showStart();
60219           }
60220         }
60221       );
60222     }
60223     function showStart() {
60224       context.container().selectAll(".shaded").remove();
60225       modalSelection = uiModal(context.container());
60226       modalSelection.select(".modal").attr("class", "modal-splash modal");
60227       modalSelection.selectAll(".close").remove();
60228       var startbutton = modalSelection.select(".content").attr("class", "fillL").append("button").attr("class", "modal-section huge-modal-button").on("click", function() {
60229         modalSelection.remove();
60230       });
60231       startbutton.append("svg").attr("class", "illustration").append("use").attr("xlink:href", "#iD-logo-walkthrough");
60232       startbutton.append("h2").call(_t.append("intro.startediting.start"));
60233       dispatch14.call("startEditing");
60234     }
60235     chapter.enter = function() {
60236       showHelp();
60237     };
60238     chapter.exit = function() {
60239       modalSelection.remove();
60240       context.container().selectAll(".shaded").remove();
60241     };
60242     return utilRebind(chapter, dispatch14, "on");
60243   }
60244
60245   // modules/ui/intro/intro.js
60246   var chapterUi = {
60247     welcome: uiIntroWelcome,
60248     navigation: uiIntroNavigation,
60249     point: uiIntroPoint,
60250     area: uiIntroArea,
60251     line: uiIntroLine,
60252     building: uiIntroBuilding,
60253     startEditing: uiIntroStartEditing
60254   };
60255   var chapterFlow = [
60256     "welcome",
60257     "navigation",
60258     "point",
60259     "area",
60260     "line",
60261     "building",
60262     "startEditing"
60263   ];
60264   function uiIntro(context) {
60265     const INTRO_IMAGERY = "EsriWorldImageryClarity";
60266     let _introGraph = {};
60267     let _currChapter;
60268     function intro(selection2) {
60269       _mainFileFetcher.get("intro_graph").then((dataIntroGraph) => {
60270         for (let id2 in dataIntroGraph) {
60271           if (!_introGraph[id2]) {
60272             _introGraph[id2] = osmEntity(localize(dataIntroGraph[id2]));
60273           }
60274         }
60275         selection2.call(startIntro);
60276       }).catch(function() {
60277       });
60278     }
60279     function startIntro(selection2) {
60280       context.enter(modeBrowse(context));
60281       let osm = context.connection();
60282       let history = context.history().toJSON();
60283       let hash2 = window.location.hash;
60284       let center = context.map().center();
60285       let zoom = context.map().zoom();
60286       let background = context.background().baseLayerSource();
60287       let overlays = context.background().overlayLayerSources();
60288       let opacity = context.container().selectAll(".main-map .layer-background").style("opacity");
60289       let caches = osm && osm.caches();
60290       let baseEntities = context.history().graph().base().entities;
60291       context.ui().sidebar.expand();
60292       context.container().selectAll("button.sidebar-toggle").classed("disabled", true);
60293       context.inIntro(true);
60294       if (osm) {
60295         osm.toggle(false).reset();
60296       }
60297       context.history().reset();
60298       context.history().merge(Object.values(coreGraph().load(_introGraph).entities));
60299       context.history().checkpoint("initial");
60300       let imagery = context.background().findSource(INTRO_IMAGERY);
60301       if (imagery) {
60302         context.background().baseLayerSource(imagery);
60303       } else {
60304         context.background().bing();
60305       }
60306       overlays.forEach((d2) => context.background().toggleOverlayLayer(d2));
60307       let layers = context.layers();
60308       layers.all().forEach((item) => {
60309         if (typeof item.layer.enabled === "function") {
60310           item.layer.enabled(item.id === "osm");
60311         }
60312       });
60313       context.container().selectAll(".main-map .layer-background").style("opacity", 1);
60314       let curtain = uiCurtain(context.container().node());
60315       selection2.call(curtain);
60316       corePreferences("walkthrough_started", "yes");
60317       let storedProgress = corePreferences("walkthrough_progress") || "";
60318       let progress = storedProgress.split(";").filter(Boolean);
60319       let chapters = chapterFlow.map((chapter, i3) => {
60320         let s2 = chapterUi[chapter](context, curtain.reveal).on("done", () => {
60321           buttons.filter((d2) => d2.title === s2.title).classed("finished", true);
60322           if (i3 < chapterFlow.length - 1) {
60323             const next = chapterFlow[i3 + 1];
60324             context.container().select("button.chapter-".concat(next)).classed("next", true);
60325           }
60326           progress.push(chapter);
60327           corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";"));
60328         });
60329         return s2;
60330       });
60331       chapters[chapters.length - 1].on("startEditing", () => {
60332         progress.push("startEditing");
60333         corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";"));
60334         let incomplete = utilArrayDifference(chapterFlow, progress);
60335         if (!incomplete.length) {
60336           corePreferences("walkthrough_completed", "yes");
60337         }
60338         curtain.remove();
60339         navwrap.remove();
60340         context.container().selectAll(".main-map .layer-background").style("opacity", opacity);
60341         context.container().selectAll("button.sidebar-toggle").classed("disabled", false);
60342         if (osm) {
60343           osm.toggle(true).reset().caches(caches);
60344         }
60345         context.history().reset().merge(Object.values(baseEntities));
60346         context.background().baseLayerSource(background);
60347         overlays.forEach((d2) => context.background().toggleOverlayLayer(d2));
60348         if (history) {
60349           context.history().fromJSON(history, false);
60350         }
60351         context.map().centerZoom(center, zoom);
60352         window.location.replace(hash2);
60353         context.inIntro(false);
60354       });
60355       let navwrap = selection2.append("div").attr("class", "intro-nav-wrap fillD");
60356       navwrap.append("svg").attr("class", "intro-nav-wrap-logo").append("use").attr("xlink:href", "#iD-logo-walkthrough");
60357       let buttonwrap = navwrap.append("div").attr("class", "joined").selectAll("button.chapter");
60358       let buttons = buttonwrap.data(chapters).enter().append("button").attr("class", (d2, i3) => "chapter chapter-".concat(chapterFlow[i3])).on("click", enterChapter);
60359       buttons.append("span").html((d2) => _t.html(d2.title));
60360       buttons.append("span").attr("class", "status").call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward", "inline"));
60361       enterChapter(null, chapters[0]);
60362       function enterChapter(d3_event, newChapter) {
60363         if (_currChapter) {
60364           _currChapter.exit();
60365         }
60366         context.enter(modeBrowse(context));
60367         _currChapter = newChapter;
60368         _currChapter.enter();
60369         buttons.classed("next", false).classed("active", (d2) => d2.title === _currChapter.title);
60370       }
60371     }
60372     return intro;
60373   }
60374
60375   // modules/ui/issues_info.js
60376   function uiIssuesInfo(context) {
60377     var warningsItem = {
60378       id: "warnings",
60379       count: 0,
60380       iconID: "iD-icon-alert",
60381       descriptionID: "issues.warnings_and_errors"
60382     };
60383     var resolvedItem = {
60384       id: "resolved",
60385       count: 0,
60386       iconID: "iD-icon-apply",
60387       descriptionID: "issues.user_resolved_issues"
60388     };
60389     function update(selection2) {
60390       var shownItems = [];
60391       var liveIssues = context.validator().getIssues({
60392         what: corePreferences("validate-what") || "edited",
60393         where: corePreferences("validate-where") || "all"
60394       });
60395       if (liveIssues.length) {
60396         warningsItem.count = liveIssues.length;
60397         shownItems.push(warningsItem);
60398       }
60399       if (corePreferences("validate-what") === "all") {
60400         var resolvedIssues = context.validator().getResolvedIssues();
60401         if (resolvedIssues.length) {
60402           resolvedItem.count = resolvedIssues.length;
60403           shownItems.push(resolvedItem);
60404         }
60405       }
60406       var chips = selection2.selectAll(".chip").data(shownItems, function(d2) {
60407         return d2.id;
60408       });
60409       chips.exit().remove();
60410       var enter = chips.enter().append("a").attr("class", function(d2) {
60411         return "chip " + d2.id + "-count";
60412       }).attr("href", "#").each(function(d2) {
60413         var chipSelection = select_default2(this);
60414         var tooltipBehavior = uiTooltip().placement("top").title(() => _t.append(d2.descriptionID));
60415         chipSelection.call(tooltipBehavior).on("click", function(d3_event) {
60416           d3_event.preventDefault();
60417           tooltipBehavior.hide(select_default2(this));
60418           context.ui().togglePanes(context.container().select(".map-panes .issues-pane"));
60419         });
60420         chipSelection.call(svgIcon("#" + d2.iconID));
60421       });
60422       enter.append("span").attr("class", "count");
60423       enter.merge(chips).selectAll("span.count").text(function(d2) {
60424         return d2.count.toString();
60425       });
60426     }
60427     return function(selection2) {
60428       update(selection2);
60429       context.validator().on("validated.infobox", function() {
60430         update(selection2);
60431       });
60432     };
60433   }
60434
60435   // modules/renderer/background_source.js
60436   var import_lodash4 = __toESM(require_lodash());
60437
60438   // modules/util/IntervalTasksQueue.js
60439   var IntervalTasksQueue = class {
60440     /**
60441      * Interval in milliseconds inside which only 1 task can execute.
60442      * e.g. if interval is 200ms, and 5 async tasks are unqueued,
60443      * they will complete in ~1s if not cleared
60444      * @param {number} intervalInMs
60445      */
60446     constructor(intervalInMs) {
60447       this.intervalInMs = intervalInMs;
60448       this.pendingHandles = [];
60449       this.time = 0;
60450     }
60451     enqueue(task) {
60452       let taskTimeout = this.time;
60453       this.time += this.intervalInMs;
60454       this.pendingHandles.push(setTimeout(() => {
60455         this.time -= this.intervalInMs;
60456         task();
60457       }, taskTimeout));
60458     }
60459     clear() {
60460       this.pendingHandles.forEach((timeoutHandle) => {
60461         clearTimeout(timeoutHandle);
60462       });
60463       this.pendingHandles = [];
60464       this.time = 0;
60465     }
60466   };
60467
60468   // modules/renderer/background_source.js
60469   var isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2;
60470   var _a3;
60471   (_a3 = window.matchMedia) == null ? void 0 : _a3.call(window, "\n        (-webkit-min-device-pixel-ratio: 2), /* Safari */\n        (min-resolution: 2dppx),             /* standard */\n        (min-resolution: 192dpi)             /* fallback */\n    ").addListener(function() {
60472     isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2;
60473   });
60474   function localeDateString(s2) {
60475     if (!s2) return null;
60476     var options2 = { day: "numeric", month: "short", year: "numeric" };
60477     var d2 = new Date(s2);
60478     if (isNaN(d2.getTime())) return null;
60479     return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
60480   }
60481   function vintageRange(vintage) {
60482     var s2;
60483     if (vintage.start || vintage.end) {
60484       s2 = vintage.start || "?";
60485       if (vintage.start !== vintage.end) {
60486         s2 += " - " + (vintage.end || "?");
60487       }
60488     }
60489     return s2;
60490   }
60491   function rendererBackgroundSource(data) {
60492     var source = Object.assign({}, data);
60493     var _offset = [0, 0];
60494     var _name = source.name;
60495     var _description = source.description;
60496     var _best = !!source.best;
60497     var _template = source.encrypted ? utilAesDecrypt(source.template) : source.template;
60498     source.tileSize = data.tileSize || 256;
60499     source.zoomExtent = data.zoomExtent || [0, 22];
60500     source.overzoom = data.overzoom !== false;
60501     source.offset = function(val) {
60502       if (!arguments.length) return _offset;
60503       _offset = val;
60504       return source;
60505     };
60506     source.nudge = function(val, zoomlevel) {
60507       _offset[0] += val[0] / Math.pow(2, zoomlevel);
60508       _offset[1] += val[1] / Math.pow(2, zoomlevel);
60509       return source;
60510     };
60511     source.name = function() {
60512       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
60513       return _t("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) });
60514     };
60515     source.label = function() {
60516       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
60517       return _t.append("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) });
60518     };
60519     source.hasDescription = function() {
60520       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
60521       var descriptionText = _mainLocalizer.tInfo("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) }).text;
60522       return descriptionText !== "";
60523     };
60524     source.description = function() {
60525       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
60526       return _t.append("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) });
60527     };
60528     source.best = function() {
60529       return _best;
60530     };
60531     source.area = function() {
60532       if (!data.polygon) return Number.MAX_VALUE;
60533       var area = area_default({ type: "MultiPolygon", coordinates: [data.polygon] });
60534       return isNaN(area) ? 0 : area;
60535     };
60536     source.imageryUsed = function() {
60537       return _name || source.id;
60538     };
60539     source.template = function(val) {
60540       if (!arguments.length) return _template;
60541       if (source.id === "custom" || source.id === "Bing") {
60542         _template = val;
60543       }
60544       return source;
60545     };
60546     source.url = function(coord2) {
60547       var result = _template.replace(new RegExp("#[\\s\\S]*", "u"), "");
60548       if (result === "") return result;
60549       if (!source.type || source.id === "custom") {
60550         if (/SERVICE=WMS|\{(proj|wkid|bbox)\}/.test(result)) {
60551           source.type = "wms";
60552           source.projection = "EPSG:3857";
60553         } else if (/\{(x|y)\}/.test(result)) {
60554           source.type = "tms";
60555         } else if (/\{u\}/.test(result)) {
60556           source.type = "bing";
60557         }
60558       }
60559       if (source.type === "wms") {
60560         var tileToProjectedCoords = function(x2, y2, z2) {
60561           var zoomSize = Math.pow(2, z2);
60562           var lon = x2 / zoomSize * Math.PI * 2 - Math.PI;
60563           var lat = Math.atan(Math.sinh(Math.PI * (1 - 2 * y2 / zoomSize)));
60564           switch (source.projection) {
60565             case "EPSG:4326":
60566               return {
60567                 x: lon * 180 / Math.PI,
60568                 y: lat * 180 / Math.PI
60569               };
60570             default:
60571               var mercCoords = mercatorRaw(lon, lat);
60572               return {
60573                 x: 2003750834e-2 / Math.PI * mercCoords[0],
60574                 y: 2003750834e-2 / Math.PI * mercCoords[1]
60575               };
60576           }
60577         };
60578         var tileSize = source.tileSize;
60579         var projection2 = source.projection;
60580         var minXmaxY = tileToProjectedCoords(coord2[0], coord2[1], coord2[2]);
60581         var maxXminY = tileToProjectedCoords(coord2[0] + 1, coord2[1] + 1, coord2[2]);
60582         result = result.replace(/\{(\w+)\}/g, function(token, key) {
60583           switch (key) {
60584             case "width":
60585             case "height":
60586               return tileSize;
60587             case "proj":
60588               return projection2;
60589             case "wkid":
60590               return projection2.replace(/^EPSG:/, "");
60591             case "bbox":
60592               if (projection2 === "EPSG:4326" && // The CRS parameter implies version 1.3 (prior versions use SRS)
60593               /VERSION=1.3|CRS={proj}/.test(source.template().toUpperCase())) {
60594                 return maxXminY.y + "," + minXmaxY.x + "," + minXmaxY.y + "," + maxXminY.x;
60595               } else {
60596                 return minXmaxY.x + "," + maxXminY.y + "," + maxXminY.x + "," + minXmaxY.y;
60597               }
60598             case "w":
60599               return minXmaxY.x;
60600             case "s":
60601               return maxXminY.y;
60602             case "n":
60603               return maxXminY.x;
60604             case "e":
60605               return minXmaxY.y;
60606             default:
60607               return token;
60608           }
60609         });
60610       } else if (source.type === "tms") {
60611         result = result.replace("{x}", coord2[0]).replace("{y}", coord2[1]).replace(/\{[t-]y\}/, Math.pow(2, coord2[2]) - coord2[1] - 1).replace(/\{z(oom)?\}/, coord2[2]).replace(/\{@2x\}|\{r\}/, isRetina ? "@2x" : "");
60612       } else if (source.type === "bing") {
60613         result = result.replace("{u}", function() {
60614           var u2 = "";
60615           for (var zoom = coord2[2]; zoom > 0; zoom--) {
60616             var b2 = 0;
60617             var mask = 1 << zoom - 1;
60618             if ((coord2[0] & mask) !== 0) b2++;
60619             if ((coord2[1] & mask) !== 0) b2 += 2;
60620             u2 += b2.toString();
60621           }
60622           return u2;
60623         });
60624       }
60625       result = result.replace(/\{switch:([^}]+)\}/, function(s2, r2) {
60626         var subdomains = r2.split(",");
60627         return subdomains[(coord2[0] + coord2[1]) % subdomains.length];
60628       });
60629       return result;
60630     };
60631     source.validZoom = function(z2, underzoom) {
60632       if (underzoom === void 0) underzoom = 0;
60633       return source.zoomExtent[0] - underzoom <= z2 && (source.overzoom || source.zoomExtent[1] > z2);
60634     };
60635     source.isLocatorOverlay = function() {
60636       return source.id === "mapbox_locator_overlay";
60637     };
60638     source.isHidden = function() {
60639       return source.id === "DigitalGlobe-Premium-vintage" || source.id === "DigitalGlobe-Standard-vintage";
60640     };
60641     source.copyrightNotices = function() {
60642     };
60643     source.getMetadata = function(center, tileCoord, callback) {
60644       var vintage = {
60645         start: localeDateString(source.startDate),
60646         end: localeDateString(source.endDate)
60647       };
60648       vintage.range = vintageRange(vintage);
60649       var metadata = { vintage };
60650       callback(null, metadata);
60651     };
60652     return source;
60653   }
60654   rendererBackgroundSource.Bing = function(data, dispatch14) {
60655     data.template = "https://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{u}.jpeg?g=1&pr=odbl&n=z";
60656     var bing = rendererBackgroundSource(data);
60657     var key = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0");
60658     const strictParam = "n";
60659     var url = "https://dev.virtualearth.net/REST/v1/Imagery/Metadata/AerialOSM?include=ImageryProviders&uriScheme=https&key=" + key;
60660     var cache = {};
60661     var inflight = {};
60662     var providers = [];
60663     var taskQueue = new IntervalTasksQueue(250);
60664     var metadataLastZoom = -1;
60665     json_default(url).then(function(json) {
60666       let imageryResource = json.resourceSets[0].resources[0];
60667       let template = imageryResource.imageUrl;
60668       let subDomains = imageryResource.imageUrlSubdomains;
60669       let subDomainNumbers = subDomains.map((subDomain) => {
60670         return subDomain.substring(1);
60671       }).join(",");
60672       template = template.replace("{subdomain}", "t{switch:".concat(subDomainNumbers, "}")).replace("{quadkey}", "{u}");
60673       if (!new URLSearchParams(template).has(strictParam)) {
60674         template += "&".concat(strictParam, "=z");
60675       }
60676       bing.template(template);
60677       providers = imageryResource.imageryProviders.map(function(provider) {
60678         return {
60679           attribution: provider.attribution,
60680           areas: provider.coverageAreas.map(function(area) {
60681             return {
60682               zoom: [area.zoomMin, area.zoomMax],
60683               extent: geoExtent([area.bbox[1], area.bbox[0]], [area.bbox[3], area.bbox[2]])
60684             };
60685           })
60686         };
60687       });
60688       dispatch14.call("change");
60689     }).catch(function() {
60690     });
60691     bing.copyrightNotices = function(zoom, extent) {
60692       zoom = Math.min(zoom, 21);
60693       return providers.filter(function(provider) {
60694         return provider.areas.some(function(area) {
60695           return extent.intersects(area.extent) && area.zoom[0] <= zoom && area.zoom[1] >= zoom;
60696         });
60697       }).map(function(provider) {
60698         return provider.attribution;
60699       }).join(", ");
60700     };
60701     bing.getMetadata = function(center, tileCoord, callback) {
60702       var tileID = tileCoord.slice(0, 3).join("/");
60703       var zoom = Math.min(tileCoord[2], 21);
60704       var centerPoint = center[1] + "," + center[0];
60705       var url2 = "https://dev.virtualearth.net/REST/v1/Imagery/BasicMetadata/AerialOSM/" + centerPoint + "?zl=" + zoom + "&key=" + key;
60706       if (inflight[tileID]) return;
60707       if (!cache[tileID]) {
60708         cache[tileID] = {};
60709       }
60710       if (cache[tileID] && cache[tileID].metadata) {
60711         return callback(null, cache[tileID].metadata);
60712       }
60713       inflight[tileID] = true;
60714       if (metadataLastZoom !== tileCoord[2]) {
60715         metadataLastZoom = tileCoord[2];
60716         taskQueue.clear();
60717       }
60718       taskQueue.enqueue(() => {
60719         json_default(url2).then(function(result) {
60720           delete inflight[tileID];
60721           if (!result) {
60722             throw new Error("Unknown Error");
60723           }
60724           var vintage = {
60725             start: localeDateString(result.resourceSets[0].resources[0].vintageStart),
60726             end: localeDateString(result.resourceSets[0].resources[0].vintageEnd)
60727           };
60728           vintage.range = vintageRange(vintage);
60729           var metadata = { vintage };
60730           cache[tileID].metadata = metadata;
60731           if (callback) callback(null, metadata);
60732         }).catch(function(err) {
60733           delete inflight[tileID];
60734           if (callback) callback(err.message);
60735         });
60736       });
60737     };
60738     bing.terms_url = "https://blog.openstreetmap.org/2010/11/30/microsoft-imagery-details";
60739     return bing;
60740   };
60741   rendererBackgroundSource.Esri = function(data) {
60742     if (data.template.match(/blankTile/) === null) {
60743       data.template = data.template + "?blankTile=false";
60744     }
60745     var esri = rendererBackgroundSource(data);
60746     var cache = {};
60747     var inflight = {};
60748     var _prevCenter;
60749     esri.fetchTilemap = function(center) {
60750       if (_prevCenter && geoSphericalDistance(center, _prevCenter) < 5e3) return;
60751       _prevCenter = center;
60752       var z2 = 20;
60753       var dummyUrl = esri.url([1, 2, 3]);
60754       var x2 = Math.floor((center[0] + 180) / 360 * Math.pow(2, z2));
60755       var y2 = Math.floor((1 - Math.log(Math.tan(center[1] * Math.PI / 180) + 1 / Math.cos(center[1] * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, z2));
60756       var tilemapUrl = dummyUrl.replace(/tile\/[0-9]+\/[0-9]+\/[0-9]+\?blankTile=false/, "tilemap") + "/" + z2 + "/" + y2 + "/" + x2 + "/8/8";
60757       json_default(tilemapUrl).then(function(tilemap) {
60758         if (!tilemap) {
60759           throw new Error("Unknown Error");
60760         }
60761         var hasTiles = true;
60762         for (var i3 = 0; i3 < tilemap.data.length; i3++) {
60763           if (!tilemap.data[i3]) {
60764             hasTiles = false;
60765             break;
60766           }
60767         }
60768         esri.zoomExtent[1] = hasTiles ? 22 : 19;
60769       }).catch(function() {
60770       });
60771     };
60772     esri.getMetadata = function(center, tileCoord, callback) {
60773       if (esri.id !== "EsriWorldImagery") {
60774         return callback(null, {});
60775       }
60776       var tileID = tileCoord.slice(0, 3).join("/");
60777       var zoom = Math.min(tileCoord[2], esri.zoomExtent[1]);
60778       var centerPoint = center[0] + "," + center[1];
60779       var unknown = _t("info_panels.background.unknown");
60780       var vintage = {};
60781       var metadata = {};
60782       if (inflight[tileID]) return;
60783       var url = "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/4/query";
60784       url += "?returnGeometry=false&geometry=" + centerPoint + "&inSR=4326&geometryType=esriGeometryPoint&outFields=*&f=json";
60785       if (!cache[tileID]) {
60786         cache[tileID] = {};
60787       }
60788       if (cache[tileID] && cache[tileID].metadata) {
60789         return callback(null, cache[tileID].metadata);
60790       }
60791       inflight[tileID] = true;
60792       json_default(url).then(function(result) {
60793         delete inflight[tileID];
60794         result = result.features.map((f2) => f2.attributes).filter((a2) => a2.MinMapLevel <= zoom && a2.MaxMapLevel >= zoom)[0];
60795         if (!result) {
60796           throw new Error("Unknown Error");
60797         } else if (result.features && result.features.length < 1) {
60798           throw new Error("No Results");
60799         } else if (result.error && result.error.message) {
60800           throw new Error(result.error.message);
60801         }
60802         var captureDate = localeDateString(result.SRC_DATE2);
60803         vintage = {
60804           start: captureDate,
60805           end: captureDate,
60806           range: captureDate
60807         };
60808         metadata = {
60809           vintage,
60810           source: clean2(result.NICE_NAME),
60811           description: clean2(result.NICE_DESC),
60812           resolution: clean2(+Number(result.SRC_RES).toFixed(4)),
60813           accuracy: clean2(+Number(result.SRC_ACC).toFixed(4))
60814         };
60815         if (isFinite(metadata.resolution)) {
60816           metadata.resolution += " m";
60817         }
60818         if (isFinite(metadata.accuracy)) {
60819           metadata.accuracy += " m";
60820         }
60821         cache[tileID].metadata = metadata;
60822         if (callback) callback(null, metadata);
60823       }).catch(function(err) {
60824         delete inflight[tileID];
60825         if (callback) callback(err.message);
60826       });
60827       function clean2(val) {
60828         return String(val).trim() || unknown;
60829       }
60830     };
60831     return esri;
60832   };
60833   rendererBackgroundSource.None = function() {
60834     var source = rendererBackgroundSource({ id: "none", template: "" });
60835     source.name = function() {
60836       return _t("background.none");
60837     };
60838     source.label = function() {
60839       return _t.append("background.none");
60840     };
60841     source.imageryUsed = function() {
60842       return null;
60843     };
60844     source.area = function() {
60845       return -1;
60846     };
60847     return source;
60848   };
60849   rendererBackgroundSource.Custom = function(template) {
60850     var source = rendererBackgroundSource({ id: "custom", template });
60851     source.name = function() {
60852       return _t("background.custom");
60853     };
60854     source.label = function() {
60855       return _t.append("background.custom");
60856     };
60857     source.imageryUsed = function() {
60858       var cleaned = source.template();
60859       if (cleaned.indexOf("?") !== -1) {
60860         var parts = cleaned.split("?", 2);
60861         var qs = utilStringQs(parts[1]);
60862         ["access_token", "connectId", "token", "Signature"].forEach(function(param) {
60863           if (qs[param]) {
60864             qs[param] = "{apikey}";
60865           }
60866         });
60867         cleaned = parts[0] + "?" + utilQsString(qs, true);
60868       }
60869       cleaned = cleaned.replace(/token\/(\w+)/, "token/{apikey}").replace(/key=(\w+)/, "key={apikey}");
60870       return "Custom (" + cleaned + " )";
60871     };
60872     source.area = function() {
60873       return -2;
60874     };
60875     return source;
60876   };
60877
60878   // node_modules/@turf/helpers/dist/esm/index.js
60879   var earthRadius = 63710088e-1;
60880   var factors = {
60881     centimeters: earthRadius * 100,
60882     centimetres: earthRadius * 100,
60883     degrees: 360 / (2 * Math.PI),
60884     feet: earthRadius * 3.28084,
60885     inches: earthRadius * 39.37,
60886     kilometers: earthRadius / 1e3,
60887     kilometres: earthRadius / 1e3,
60888     meters: earthRadius,
60889     metres: earthRadius,
60890     miles: earthRadius / 1609.344,
60891     millimeters: earthRadius * 1e3,
60892     millimetres: earthRadius * 1e3,
60893     nauticalmiles: earthRadius / 1852,
60894     radians: 1,
60895     yards: earthRadius * 1.0936
60896   };
60897   function feature2(geom, properties, options2 = {}) {
60898     const feat = { type: "Feature" };
60899     if (options2.id === 0 || options2.id) {
60900       feat.id = options2.id;
60901     }
60902     if (options2.bbox) {
60903       feat.bbox = options2.bbox;
60904     }
60905     feat.properties = properties || {};
60906     feat.geometry = geom;
60907     return feat;
60908   }
60909   function polygon(coordinates, properties, options2 = {}) {
60910     for (const ring of coordinates) {
60911       if (ring.length < 4) {
60912         throw new Error(
60913           "Each LinearRing of a Polygon must have 4 or more Positions."
60914         );
60915       }
60916       if (ring[ring.length - 1].length !== ring[0].length) {
60917         throw new Error("First and last Position are not equivalent.");
60918       }
60919       for (let j2 = 0; j2 < ring[ring.length - 1].length; j2++) {
60920         if (ring[ring.length - 1][j2] !== ring[0][j2]) {
60921           throw new Error("First and last Position are not equivalent.");
60922         }
60923       }
60924     }
60925     const geom = {
60926       type: "Polygon",
60927       coordinates
60928     };
60929     return feature2(geom, properties, options2);
60930   }
60931   function lineString(coordinates, properties, options2 = {}) {
60932     if (coordinates.length < 2) {
60933       throw new Error("coordinates must be an array of two or more positions");
60934     }
60935     const geom = {
60936       type: "LineString",
60937       coordinates
60938     };
60939     return feature2(geom, properties, options2);
60940   }
60941   function multiLineString(coordinates, properties, options2 = {}) {
60942     const geom = {
60943       type: "MultiLineString",
60944       coordinates
60945     };
60946     return feature2(geom, properties, options2);
60947   }
60948   function multiPolygon(coordinates, properties, options2 = {}) {
60949     const geom = {
60950       type: "MultiPolygon",
60951       coordinates
60952     };
60953     return feature2(geom, properties, options2);
60954   }
60955
60956   // node_modules/@turf/invariant/dist/esm/index.js
60957   function getGeom(geojson) {
60958     if (geojson.type === "Feature") {
60959       return geojson.geometry;
60960     }
60961     return geojson;
60962   }
60963
60964   // node_modules/@turf/bbox-clip/dist/esm/index.js
60965   function lineclip(points, bbox2, result) {
60966     var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i3, codeB, lastCode;
60967     let a2;
60968     let b2;
60969     if (!result) result = [];
60970     for (i3 = 1; i3 < len; i3++) {
60971       a2 = points[i3 - 1];
60972       b2 = points[i3];
60973       codeB = lastCode = bitCode(b2, bbox2);
60974       while (true) {
60975         if (!(codeA | codeB)) {
60976           part.push(a2);
60977           if (codeB !== lastCode) {
60978             part.push(b2);
60979             if (i3 < len - 1) {
60980               result.push(part);
60981               part = [];
60982             }
60983           } else if (i3 === len - 1) {
60984             part.push(b2);
60985           }
60986           break;
60987         } else if (codeA & codeB) {
60988           break;
60989         } else if (codeA) {
60990           a2 = intersect(a2, b2, codeA, bbox2);
60991           codeA = bitCode(a2, bbox2);
60992         } else {
60993           b2 = intersect(a2, b2, codeB, bbox2);
60994           codeB = bitCode(b2, bbox2);
60995         }
60996       }
60997       codeA = lastCode;
60998     }
60999     if (part.length) result.push(part);
61000     return result;
61001   }
61002   function polygonclip(points, bbox2) {
61003     var result, edge, prev, prevInside, i3, p2, inside;
61004     for (edge = 1; edge <= 8; edge *= 2) {
61005       result = [];
61006       prev = points[points.length - 1];
61007       prevInside = !(bitCode(prev, bbox2) & edge);
61008       for (i3 = 0; i3 < points.length; i3++) {
61009         p2 = points[i3];
61010         inside = !(bitCode(p2, bbox2) & edge);
61011         if (inside !== prevInside) result.push(intersect(prev, p2, edge, bbox2));
61012         if (inside) result.push(p2);
61013         prev = p2;
61014         prevInside = inside;
61015       }
61016       points = result;
61017       if (!points.length) break;
61018     }
61019     return result;
61020   }
61021   function intersect(a2, b2, edge, bbox2) {
61022     return edge & 8 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[3] - a2[1]) / (b2[1] - a2[1]), bbox2[3]] : edge & 4 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[1] - a2[1]) / (b2[1] - a2[1]), bbox2[1]] : edge & 2 ? [bbox2[2], a2[1] + (b2[1] - a2[1]) * (bbox2[2] - a2[0]) / (b2[0] - a2[0])] : edge & 1 ? [bbox2[0], a2[1] + (b2[1] - a2[1]) * (bbox2[0] - a2[0]) / (b2[0] - a2[0])] : null;
61023   }
61024   function bitCode(p2, bbox2) {
61025     var code = 0;
61026     if (p2[0] < bbox2[0]) code |= 1;
61027     else if (p2[0] > bbox2[2]) code |= 2;
61028     if (p2[1] < bbox2[1]) code |= 4;
61029     else if (p2[1] > bbox2[3]) code |= 8;
61030     return code;
61031   }
61032   function bboxClip(feature3, bbox2) {
61033     const geom = getGeom(feature3);
61034     const type2 = geom.type;
61035     const properties = feature3.type === "Feature" ? feature3.properties : {};
61036     let coords = geom.coordinates;
61037     switch (type2) {
61038       case "LineString":
61039       case "MultiLineString": {
61040         const lines = [];
61041         if (type2 === "LineString") {
61042           coords = [coords];
61043         }
61044         coords.forEach((line) => {
61045           lineclip(line, bbox2, lines);
61046         });
61047         if (lines.length === 1) {
61048           return lineString(lines[0], properties);
61049         }
61050         return multiLineString(lines, properties);
61051       }
61052       case "Polygon":
61053         return polygon(clipPolygon(coords, bbox2), properties);
61054       case "MultiPolygon":
61055         return multiPolygon(
61056           coords.map((poly) => {
61057             return clipPolygon(poly, bbox2);
61058           }),
61059           properties
61060         );
61061       default:
61062         throw new Error("geometry " + type2 + " not supported");
61063     }
61064   }
61065   function clipPolygon(rings, bbox2) {
61066     const outRings = [];
61067     for (const ring of rings) {
61068       const clipped = polygonclip(ring, bbox2);
61069       if (clipped.length > 0) {
61070         if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
61071           clipped.push(clipped[0]);
61072         }
61073         if (clipped.length >= 4) {
61074           outRings.push(clipped);
61075         }
61076       }
61077     }
61078     return outRings;
61079   }
61080   var turf_bbox_clip_default = bboxClip;
61081
61082   // node_modules/@turf/meta/dist/esm/index.js
61083   function coordEach(geojson, callback, excludeWrapCoord) {
61084     if (geojson === null) return;
61085     var j2, k2, l2, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type2 = geojson.type, isFeatureCollection = type2 === "FeatureCollection", isFeature = type2 === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
61086     for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
61087       geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
61088       isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
61089       stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
61090       for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
61091         var multiFeatureIndex = 0;
61092         var geometryIndex = 0;
61093         geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
61094         if (geometry === null) continue;
61095         coords = geometry.coordinates;
61096         var geomType = geometry.type;
61097         wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
61098         switch (geomType) {
61099           case null:
61100             break;
61101           case "Point":
61102             if (callback(
61103               coords,
61104               coordIndex,
61105               featureIndex,
61106               multiFeatureIndex,
61107               geometryIndex
61108             ) === false)
61109               return false;
61110             coordIndex++;
61111             multiFeatureIndex++;
61112             break;
61113           case "LineString":
61114           case "MultiPoint":
61115             for (j2 = 0; j2 < coords.length; j2++) {
61116               if (callback(
61117                 coords[j2],
61118                 coordIndex,
61119                 featureIndex,
61120                 multiFeatureIndex,
61121                 geometryIndex
61122               ) === false)
61123                 return false;
61124               coordIndex++;
61125               if (geomType === "MultiPoint") multiFeatureIndex++;
61126             }
61127             if (geomType === "LineString") multiFeatureIndex++;
61128             break;
61129           case "Polygon":
61130           case "MultiLineString":
61131             for (j2 = 0; j2 < coords.length; j2++) {
61132               for (k2 = 0; k2 < coords[j2].length - wrapShrink; k2++) {
61133                 if (callback(
61134                   coords[j2][k2],
61135                   coordIndex,
61136                   featureIndex,
61137                   multiFeatureIndex,
61138                   geometryIndex
61139                 ) === false)
61140                   return false;
61141                 coordIndex++;
61142               }
61143               if (geomType === "MultiLineString") multiFeatureIndex++;
61144               if (geomType === "Polygon") geometryIndex++;
61145             }
61146             if (geomType === "Polygon") multiFeatureIndex++;
61147             break;
61148           case "MultiPolygon":
61149             for (j2 = 0; j2 < coords.length; j2++) {
61150               geometryIndex = 0;
61151               for (k2 = 0; k2 < coords[j2].length; k2++) {
61152                 for (l2 = 0; l2 < coords[j2][k2].length - wrapShrink; l2++) {
61153                   if (callback(
61154                     coords[j2][k2][l2],
61155                     coordIndex,
61156                     featureIndex,
61157                     multiFeatureIndex,
61158                     geometryIndex
61159                   ) === false)
61160                     return false;
61161                   coordIndex++;
61162                 }
61163                 geometryIndex++;
61164               }
61165               multiFeatureIndex++;
61166             }
61167             break;
61168           case "GeometryCollection":
61169             for (j2 = 0; j2 < geometry.geometries.length; j2++)
61170               if (coordEach(geometry.geometries[j2], callback, excludeWrapCoord) === false)
61171                 return false;
61172             break;
61173           default:
61174             throw new Error("Unknown Geometry Type");
61175         }
61176       }
61177     }
61178   }
61179
61180   // node_modules/@turf/bbox/dist/esm/index.js
61181   function bbox(geojson, options2 = {}) {
61182     if (geojson.bbox != null && true !== options2.recompute) {
61183       return geojson.bbox;
61184     }
61185     const result = [Infinity, Infinity, -Infinity, -Infinity];
61186     coordEach(geojson, (coord2) => {
61187       if (result[0] > coord2[0]) {
61188         result[0] = coord2[0];
61189       }
61190       if (result[1] > coord2[1]) {
61191         result[1] = coord2[1];
61192       }
61193       if (result[2] < coord2[0]) {
61194         result[2] = coord2[0];
61195       }
61196       if (result[3] < coord2[1]) {
61197         result[3] = coord2[1];
61198       }
61199     });
61200     return result;
61201   }
61202   var turf_bbox_default = bbox;
61203
61204   // modules/renderer/background.js
61205   var import_which_polygon3 = __toESM(require_which_polygon());
61206
61207   // modules/renderer/tile_layer.js
61208   function rendererTileLayer(context) {
61209     var transformProp = utilPrefixCSSProperty("Transform");
61210     var tiler8 = utilTiler();
61211     var _tileSize = 256;
61212     var _projection;
61213     var _cache5 = {};
61214     var _tileOrigin;
61215     var _zoom;
61216     var _source;
61217     var _underzoom = 0;
61218     var _epsilon = 0;
61219     if (window.chrome) {
61220       updateEpsilon();
61221       window.addEventListener("resize", updateEpsilon);
61222     }
61223     function updateEpsilon() {
61224       const pageZoom = Math.round(window.devicePixelRatio * 100);
61225       if (pageZoom % 25 === 0) {
61226         _epsilon = 0;
61227       } else if (pageZoom === 90) {
61228         _epsilon = 5e-3;
61229       } else if (pageZoom === 110) {
61230         _epsilon = 2e-3;
61231       } else {
61232         _epsilon = 3e-3;
61233       }
61234     }
61235     function tileSizeAtZoom(d2, z2) {
61236       return d2.tileSize * Math.pow(2, z2 - d2[2]) / d2.tileSize + _epsilon;
61237     }
61238     function atZoom(t2, distance) {
61239       var power = Math.pow(2, distance);
61240       return [
61241         Math.floor(t2[0] * power),
61242         Math.floor(t2[1] * power),
61243         t2[2] + distance
61244       ];
61245     }
61246     function lookUp(d2) {
61247       for (var up = -1; up > -d2[2]; up--) {
61248         var tile = atZoom(d2, up);
61249         if (_cache5[_source.url(tile)] !== false) {
61250           return tile;
61251         }
61252       }
61253     }
61254     function uniqueBy(a2, n3) {
61255       var o2 = [];
61256       var seen = {};
61257       for (var i3 = 0; i3 < a2.length; i3++) {
61258         if (seen[a2[i3][n3]] === void 0) {
61259           o2.push(a2[i3]);
61260           seen[a2[i3][n3]] = true;
61261         }
61262       }
61263       return o2;
61264     }
61265     function addSource(d2) {
61266       d2.url = _source.url(d2);
61267       d2.tileSize = _tileSize;
61268       return d2;
61269     }
61270     function background(selection2) {
61271       _zoom = geoScaleToZoom(_projection.scale(), _tileSize);
61272       var pixelOffset;
61273       if (_source) {
61274         pixelOffset = [
61275           _source.offset()[0] * Math.pow(2, _zoom),
61276           _source.offset()[1] * Math.pow(2, _zoom)
61277         ];
61278       } else {
61279         pixelOffset = [0, 0];
61280       }
61281       var translate = [
61282         _projection.translate()[0] + pixelOffset[0],
61283         _projection.translate()[1] + pixelOffset[1]
61284       ];
61285       tiler8.scale(_projection.scale() * 2 * Math.PI).translate(translate);
61286       _tileOrigin = [
61287         _projection.scale() * Math.PI - translate[0],
61288         _projection.scale() * Math.PI - translate[1]
61289       ];
61290       render(selection2);
61291     }
61292     function render(selection2) {
61293       if (!_source) return;
61294       var requests = [];
61295       var showDebug = context.getDebug("tile") && !_source.overlay;
61296       if (_source.validZoom(_zoom, _underzoom)) {
61297         tiler8.skipNullIsland(!!_source.overlay);
61298         tiler8().forEach(function(d2) {
61299           addSource(d2);
61300           if (d2.url === "") return;
61301           if (typeof d2.url !== "string") return;
61302           requests.push(d2);
61303           if (_cache5[d2.url] === false && lookUp(d2)) {
61304             requests.push(addSource(lookUp(d2)));
61305           }
61306         });
61307         requests = uniqueBy(requests, "url").filter(function(r2) {
61308           return _cache5[r2.url] !== false;
61309         });
61310       }
61311       function load(d3_event, d2) {
61312         _cache5[d2.url] = true;
61313         select_default2(this).on("error", null).on("load", null);
61314         render(selection2);
61315       }
61316       function error(d3_event, d2) {
61317         _cache5[d2.url] = false;
61318         select_default2(this).on("error", null).on("load", null).remove();
61319         render(selection2);
61320       }
61321       function imageTransform(d2) {
61322         var ts = d2.tileSize * Math.pow(2, _zoom - d2[2]);
61323         var scale = tileSizeAtZoom(d2, _zoom);
61324         return "translate(" + (d2[0] * ts * _tileSize / d2.tileSize - _tileOrigin[0]) + "px," + (d2[1] * ts * _tileSize / d2.tileSize - _tileOrigin[1]) + "px) scale(" + scale * _tileSize / d2.tileSize + "," + scale * _tileSize / d2.tileSize + ")";
61325       }
61326       function tileCenter(d2) {
61327         var ts = d2.tileSize * Math.pow(2, _zoom - d2[2]);
61328         return [
61329           d2[0] * ts - _tileOrigin[0] + ts / 2,
61330           d2[1] * ts - _tileOrigin[1] + ts / 2
61331         ];
61332       }
61333       function debugTransform(d2) {
61334         var coord2 = tileCenter(d2);
61335         return "translate(" + coord2[0] + "px," + coord2[1] + "px)";
61336       }
61337       var dims = tiler8.size();
61338       var mapCenter = [dims[0] / 2, dims[1] / 2];
61339       var minDist = Math.max(dims[0], dims[1]);
61340       var nearCenter;
61341       requests.forEach(function(d2) {
61342         var c2 = tileCenter(d2);
61343         var dist = geoVecLength(c2, mapCenter);
61344         if (dist < minDist) {
61345           minDist = dist;
61346           nearCenter = d2;
61347         }
61348       });
61349       var image = selection2.selectAll("img").data(requests, function(d2) {
61350         return d2.url;
61351       });
61352       image.exit().style(transformProp, imageTransform).classed("tile-removing", true).classed("tile-center", false).each(function() {
61353         var tile = select_default2(this);
61354         window.setTimeout(function() {
61355           if (tile.classed("tile-removing")) {
61356             tile.remove();
61357           }
61358         }, 250);
61359       });
61360       image.enter().append("img").attr("class", "tile").attr("alt", "").attr("draggable", "false").style("width", _tileSize + "px").style("height", _tileSize + "px").attr("src", function(d2) {
61361         return d2.url;
61362       }).on("error", error).on("load", load).merge(image).style(transformProp, imageTransform).classed("tile-debug", showDebug).classed("tile-removing", false).classed("tile-center", function(d2) {
61363         return d2 === nearCenter;
61364       });
61365       var debug2 = selection2.selectAll(".tile-label-debug").data(showDebug ? requests : [], function(d2) {
61366         return d2.url;
61367       });
61368       debug2.exit().remove();
61369       if (showDebug) {
61370         var debugEnter = debug2.enter().append("div").attr("class", "tile-label-debug");
61371         debugEnter.append("div").attr("class", "tile-label-debug-coord");
61372         debugEnter.append("div").attr("class", "tile-label-debug-vintage");
61373         debug2 = debug2.merge(debugEnter);
61374         debug2.style(transformProp, debugTransform);
61375         debug2.selectAll(".tile-label-debug-coord").text(function(d2) {
61376           return d2[2] + " / " + d2[0] + " / " + d2[1];
61377         });
61378         debug2.selectAll(".tile-label-debug-vintage").each(function(d2) {
61379           var span = select_default2(this);
61380           var center = context.projection.invert(tileCenter(d2));
61381           _source.getMetadata(center, d2, function(err, result) {
61382             if (result && result.vintage && result.vintage.range) {
61383               span.text(result.vintage.range);
61384             } else {
61385               span.text("");
61386               span.call(_t.append("info_panels.background.vintage"));
61387               span.append("span").text(": ");
61388               span.call(_t.append("info_panels.background.unknown"));
61389             }
61390           });
61391         });
61392       }
61393     }
61394     background.projection = function(val) {
61395       if (!arguments.length) return _projection;
61396       _projection = val;
61397       return background;
61398     };
61399     background.dimensions = function(val) {
61400       if (!arguments.length) return tiler8.size();
61401       tiler8.size(val);
61402       return background;
61403     };
61404     background.source = function(val) {
61405       if (!arguments.length) return _source;
61406       _source = val;
61407       _tileSize = _source.tileSize;
61408       _cache5 = {};
61409       tiler8.tileSize(_source.tileSize).zoomExtent(_source.zoomExtent);
61410       return background;
61411     };
61412     background.underzoom = function(amount) {
61413       if (!arguments.length) return _underzoom;
61414       _underzoom = amount;
61415       return background;
61416     };
61417     return background;
61418   }
61419
61420   // modules/renderer/background.js
61421   var _imageryIndex = null;
61422   function rendererBackground(context) {
61423     const dispatch14 = dispatch_default("change");
61424     const baseLayer = rendererTileLayer(context).projection(context.projection);
61425     let _checkedBlocklists = [];
61426     let _isValid = true;
61427     let _overlayLayers = [];
61428     let _brightness = 1;
61429     let _contrast = 1;
61430     let _saturation = 1;
61431     let _sharpness = 1;
61432     function ensureImageryIndex() {
61433       return _mainFileFetcher.get("imagery").then((sources) => {
61434         if (_imageryIndex) return _imageryIndex;
61435         _imageryIndex = {
61436           imagery: sources,
61437           features: {}
61438         };
61439         const features = sources.map((source) => {
61440           if (!source.polygon) return null;
61441           const rings = source.polygon.map((ring) => [ring]);
61442           const feature3 = {
61443             type: "Feature",
61444             properties: { id: source.id },
61445             geometry: { type: "MultiPolygon", coordinates: rings }
61446           };
61447           _imageryIndex.features[source.id] = feature3;
61448           return feature3;
61449         }).filter(Boolean);
61450         _imageryIndex.query = (0, import_which_polygon3.default)({ type: "FeatureCollection", features });
61451         _imageryIndex.backgrounds = sources.map((source) => {
61452           if (source.type === "bing") {
61453             return rendererBackgroundSource.Bing(source, dispatch14);
61454           } else if (/^EsriWorldImagery/.test(source.id)) {
61455             return rendererBackgroundSource.Esri(source);
61456           } else {
61457             return rendererBackgroundSource(source);
61458           }
61459         });
61460         _imageryIndex.backgrounds.unshift(rendererBackgroundSource.None());
61461         let template = corePreferences("background-custom-template") || "";
61462         const custom = rendererBackgroundSource.Custom(template);
61463         _imageryIndex.backgrounds.unshift(custom);
61464         return _imageryIndex;
61465       });
61466     }
61467     function background(selection2) {
61468       const currSource = baseLayer.source();
61469       if (context.map().zoom() > 18) {
61470         if (currSource && /^EsriWorldImagery/.test(currSource.id)) {
61471           const center = context.map().center();
61472           currSource.fetchTilemap(center);
61473         }
61474       }
61475       const sources = background.sources(context.map().extent());
61476       const wasValid = _isValid;
61477       _isValid = !!sources.filter((d2) => d2 === currSource).length;
61478       if (wasValid !== _isValid) {
61479         background.updateImagery();
61480       }
61481       let baseFilter = "";
61482       if (_brightness !== 1) {
61483         baseFilter += " brightness(".concat(_brightness, ")");
61484       }
61485       if (_contrast !== 1) {
61486         baseFilter += " contrast(".concat(_contrast, ")");
61487       }
61488       if (_saturation !== 1) {
61489         baseFilter += " saturate(".concat(_saturation, ")");
61490       }
61491       if (_sharpness < 1) {
61492         const blur = number_default(0.5, 5)(1 - _sharpness);
61493         baseFilter += " blur(".concat(blur, "px)");
61494       }
61495       let base = selection2.selectAll(".layer-background").data([0]);
61496       base = base.enter().insert("div", ".layer-data").attr("class", "layer layer-background").merge(base);
61497       base.style("filter", baseFilter || null);
61498       let imagery = base.selectAll(".layer-imagery").data([0]);
61499       imagery.enter().append("div").attr("class", "layer layer-imagery").merge(imagery).call(baseLayer);
61500       let maskFilter = "";
61501       let mixBlendMode = "";
61502       if (_sharpness > 1) {
61503         mixBlendMode = "overlay";
61504         maskFilter = "saturate(0) blur(3px) invert(1)";
61505         let contrast = _sharpness - 1;
61506         maskFilter += " contrast(".concat(contrast, ")");
61507         let brightness = number_default(1, 0.85)(_sharpness - 1);
61508         maskFilter += " brightness(".concat(brightness, ")");
61509       }
61510       let mask = base.selectAll(".layer-unsharp-mask").data(_sharpness > 1 ? [0] : []);
61511       mask.exit().remove();
61512       mask.enter().append("div").attr("class", "layer layer-mask layer-unsharp-mask").merge(mask).call(baseLayer).style("filter", maskFilter || null).style("mix-blend-mode", mixBlendMode || null);
61513       let overlays = selection2.selectAll(".layer-overlay").data(_overlayLayers, (d2) => d2.source().name());
61514       overlays.exit().remove();
61515       overlays.enter().insert("div", ".layer-data").attr("class", "layer layer-overlay").merge(overlays).each((layer, i3, nodes) => select_default2(nodes[i3]).call(layer));
61516     }
61517     background.updateImagery = function() {
61518       let currSource = baseLayer.source();
61519       if (context.inIntro() || !currSource) return;
61520       let o2 = _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).map((d2) => d2.source().id).join(",");
61521       const meters = geoOffsetToMeters(currSource.offset());
61522       const EPSILON = 0.01;
61523       const x2 = +meters[0].toFixed(2);
61524       const y2 = +meters[1].toFixed(2);
61525       let hash2 = utilStringQs(window.location.hash);
61526       let id2 = currSource.id;
61527       if (id2 === "custom") {
61528         id2 = "custom:".concat(currSource.template());
61529       }
61530       if (id2) {
61531         hash2.background = id2;
61532       } else {
61533         delete hash2.background;
61534       }
61535       if (o2) {
61536         hash2.overlays = o2;
61537       } else {
61538         delete hash2.overlays;
61539       }
61540       if (Math.abs(x2) > EPSILON || Math.abs(y2) > EPSILON) {
61541         hash2.offset = "".concat(x2, ",").concat(y2);
61542       } else {
61543         delete hash2.offset;
61544       }
61545       if (!window.mocha) {
61546         window.location.replace("#" + utilQsString(hash2, true));
61547       }
61548       let imageryUsed = [];
61549       let photoOverlaysUsed = [];
61550       const currUsed = currSource.imageryUsed();
61551       if (currUsed && _isValid) {
61552         imageryUsed.push(currUsed);
61553       }
61554       _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).forEach((d2) => imageryUsed.push(d2.source().imageryUsed()));
61555       const dataLayer = context.layers().layer("data");
61556       if (dataLayer && dataLayer.enabled() && dataLayer.hasData()) {
61557         imageryUsed.push(dataLayer.getSrc());
61558       }
61559       const photoOverlayLayers = {
61560         streetside: "Bing Streetside",
61561         mapillary: "Mapillary Images",
61562         "mapillary-map-features": "Mapillary Map Features",
61563         "mapillary-signs": "Mapillary Signs",
61564         kartaview: "KartaView Images",
61565         vegbilder: "Norwegian Road Administration Images",
61566         mapilio: "Mapilio Images",
61567         panoramax: "Panoramax Images"
61568       };
61569       for (let layerID in photoOverlayLayers) {
61570         const layer = context.layers().layer(layerID);
61571         if (layer && layer.enabled()) {
61572           photoOverlaysUsed.push(layerID);
61573           imageryUsed.push(photoOverlayLayers[layerID]);
61574         }
61575       }
61576       context.history().imageryUsed(imageryUsed);
61577       context.history().photoOverlaysUsed(photoOverlaysUsed);
61578     };
61579     background.sources = (extent, zoom, includeCurrent) => {
61580       if (!_imageryIndex) return [];
61581       let visible = {};
61582       (_imageryIndex.query.bbox(extent.rectangle(), true) || []).forEach((d2) => visible[d2.id] = true);
61583       const currSource = baseLayer.source();
61584       const osm = context.connection();
61585       const blocklists = osm && osm.imageryBlocklists() || [];
61586       const blocklistChanged = blocklists.length !== _checkedBlocklists.length || blocklists.some((regex, index) => String(regex) !== _checkedBlocklists[index]);
61587       if (blocklistChanged) {
61588         _imageryIndex.backgrounds.forEach((source) => {
61589           source.isBlocked = blocklists.some((regex) => regex.test(source.template()));
61590         });
61591         _checkedBlocklists = blocklists.map((regex) => String(regex));
61592       }
61593       return _imageryIndex.backgrounds.filter((source) => {
61594         if (includeCurrent && currSource === source) return true;
61595         if (source.isBlocked) return false;
61596         if (!source.polygon) return true;
61597         if (zoom && zoom < 6) return false;
61598         return visible[source.id];
61599       });
61600     };
61601     background.dimensions = (val) => {
61602       if (!val) return;
61603       baseLayer.dimensions(val);
61604       _overlayLayers.forEach((layer) => layer.dimensions(val));
61605     };
61606     background.baseLayerSource = function(d2) {
61607       if (!arguments.length) return baseLayer.source();
61608       const osm = context.connection();
61609       if (!osm) return background;
61610       const blocklists = osm.imageryBlocklists();
61611       const template = d2.template();
61612       let fail = false;
61613       let tested = 0;
61614       let regex;
61615       for (let i3 = 0; i3 < blocklists.length; i3++) {
61616         regex = blocklists[i3];
61617         fail = regex.test(template);
61618         tested++;
61619         if (fail) break;
61620       }
61621       if (!tested) {
61622         regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/;
61623         fail = regex.test(template);
61624       }
61625       baseLayer.source(!fail ? d2 : background.findSource("none"));
61626       dispatch14.call("change");
61627       background.updateImagery();
61628       return background;
61629     };
61630     background.findSource = (id2) => {
61631       if (!id2 || !_imageryIndex) return null;
61632       return _imageryIndex.backgrounds.find((d2) => d2.id && d2.id === id2);
61633     };
61634     background.bing = () => {
61635       background.baseLayerSource(background.findSource("Bing"));
61636     };
61637     background.showsLayer = (d2) => {
61638       const currSource = baseLayer.source();
61639       if (!d2 || !currSource) return false;
61640       return d2.id === currSource.id || _overlayLayers.some((layer) => d2.id === layer.source().id);
61641     };
61642     background.overlayLayerSources = () => {
61643       return _overlayLayers.map((layer) => layer.source());
61644     };
61645     background.toggleOverlayLayer = (d2) => {
61646       let layer;
61647       for (let i3 = 0; i3 < _overlayLayers.length; i3++) {
61648         layer = _overlayLayers[i3];
61649         if (layer.source() === d2) {
61650           _overlayLayers.splice(i3, 1);
61651           dispatch14.call("change");
61652           background.updateImagery();
61653           return;
61654         }
61655       }
61656       layer = rendererTileLayer(context).source(d2).projection(context.projection).dimensions(
61657         baseLayer.dimensions()
61658       );
61659       _overlayLayers.push(layer);
61660       dispatch14.call("change");
61661       background.updateImagery();
61662     };
61663     background.nudge = (d2, zoom) => {
61664       const currSource = baseLayer.source();
61665       if (currSource) {
61666         currSource.nudge(d2, zoom);
61667         dispatch14.call("change");
61668         background.updateImagery();
61669       }
61670       return background;
61671     };
61672     background.offset = function(d2) {
61673       const currSource = baseLayer.source();
61674       if (!arguments.length) {
61675         return currSource && currSource.offset() || [0, 0];
61676       }
61677       if (currSource) {
61678         currSource.offset(d2);
61679         dispatch14.call("change");
61680         background.updateImagery();
61681       }
61682       return background;
61683     };
61684     background.brightness = function(d2) {
61685       if (!arguments.length) return _brightness;
61686       _brightness = d2;
61687       if (context.mode()) dispatch14.call("change");
61688       return background;
61689     };
61690     background.contrast = function(d2) {
61691       if (!arguments.length) return _contrast;
61692       _contrast = d2;
61693       if (context.mode()) dispatch14.call("change");
61694       return background;
61695     };
61696     background.saturation = function(d2) {
61697       if (!arguments.length) return _saturation;
61698       _saturation = d2;
61699       if (context.mode()) dispatch14.call("change");
61700       return background;
61701     };
61702     background.sharpness = function(d2) {
61703       if (!arguments.length) return _sharpness;
61704       _sharpness = d2;
61705       if (context.mode()) dispatch14.call("change");
61706       return background;
61707     };
61708     let _loadPromise;
61709     background.ensureLoaded = () => {
61710       if (_loadPromise) return _loadPromise;
61711       return _loadPromise = ensureImageryIndex();
61712     };
61713     background.init = () => {
61714       const loadPromise = background.ensureLoaded();
61715       const hash2 = utilStringQs(window.location.hash);
61716       const requestedBackground = hash2.background || hash2.layer;
61717       const lastUsedBackground = corePreferences("background-last-used");
61718       return loadPromise.then((imageryIndex) => {
61719         const extent = context.map().extent();
61720         const validBackgrounds = background.sources(extent).filter((d2) => d2.id !== "none" && d2.id !== "custom");
61721         const first = validBackgrounds.length && validBackgrounds[0];
61722         const isLastUsedValid = !!validBackgrounds.find((d2) => d2.id && d2.id === lastUsedBackground);
61723         let best;
61724         if (!requestedBackground && extent) {
61725           const viewArea = extent.area();
61726           best = validBackgrounds.find((s2) => {
61727             if (!s2.best() || s2.overlay) return false;
61728             let bbox2 = turf_bbox_default(turf_bbox_clip_default(
61729               { type: "MultiPolygon", coordinates: [s2.polygon || [extent.polygon()]] },
61730               extent.rectangle()
61731             ));
61732             let area = geoExtent(bbox2.slice(0, 2), bbox2.slice(2, 4)).area();
61733             return area / viewArea > 0.5;
61734           });
61735         }
61736         if (requestedBackground && requestedBackground.indexOf("custom:") === 0) {
61737           const template = requestedBackground.replace(/^custom:/, "");
61738           const custom = background.findSource("custom");
61739           background.baseLayerSource(custom.template(template));
61740           corePreferences("background-custom-template", template);
61741         } else {
61742           background.baseLayerSource(
61743             background.findSource(requestedBackground) || best || isLastUsedValid && background.findSource(lastUsedBackground) || background.findSource("Bing") || first || background.findSource("none")
61744           );
61745         }
61746         const locator = imageryIndex.backgrounds.find((d2) => d2.overlay && d2.default);
61747         if (locator) {
61748           background.toggleOverlayLayer(locator);
61749         }
61750         const overlays = (hash2.overlays || "").split(",");
61751         overlays.forEach((overlay) => {
61752           overlay = background.findSource(overlay);
61753           if (overlay) {
61754             background.toggleOverlayLayer(overlay);
61755           }
61756         });
61757         if (hash2.gpx) {
61758           const gpx2 = context.layers().layer("data");
61759           if (gpx2) {
61760             gpx2.url(hash2.gpx, ".gpx");
61761           }
61762         }
61763         if (hash2.offset) {
61764           const offset = hash2.offset.replace(/;/g, ",").split(",").map((n3) => !isNaN(n3) && n3);
61765           if (offset.length === 2) {
61766             background.offset(geoMetersToOffset(offset));
61767           }
61768         }
61769       }).catch((err) => {
61770         console.error(err);
61771       });
61772     };
61773     return utilRebind(background, dispatch14, "on");
61774   }
61775
61776   // modules/renderer/features.js
61777   function rendererFeatures(context) {
61778     var dispatch14 = dispatch_default("change", "redraw");
61779     var features = utilRebind({}, dispatch14, "on");
61780     var _deferred2 = /* @__PURE__ */ new Set();
61781     var traffic_roads = {
61782       "motorway": true,
61783       "motorway_link": true,
61784       "trunk": true,
61785       "trunk_link": true,
61786       "primary": true,
61787       "primary_link": true,
61788       "secondary": true,
61789       "secondary_link": true,
61790       "tertiary": true,
61791       "tertiary_link": true,
61792       "residential": true,
61793       "unclassified": true,
61794       "living_street": true,
61795       "busway": true
61796     };
61797     var service_roads = {
61798       "service": true,
61799       "road": true,
61800       "track": true
61801     };
61802     var paths = {
61803       "path": true,
61804       "footway": true,
61805       "cycleway": true,
61806       "bridleway": true,
61807       "steps": true,
61808       "ladder": true,
61809       "pedestrian": true
61810     };
61811     var _cullFactor = 1;
61812     var _cache5 = {};
61813     var _rules = {};
61814     var _stats = {};
61815     var _keys = [];
61816     var _hidden = [];
61817     var _forceVisible = {};
61818     function update() {
61819       if (!window.mocha) {
61820         var hash2 = utilStringQs(window.location.hash);
61821         var disabled = features.disabled();
61822         if (disabled.length) {
61823           hash2.disable_features = disabled.join(",");
61824         } else {
61825           delete hash2.disable_features;
61826         }
61827         window.location.replace("#" + utilQsString(hash2, true));
61828         corePreferences("disabled-features", disabled.join(","));
61829       }
61830       _hidden = features.hidden();
61831       dispatch14.call("change");
61832       dispatch14.call("redraw");
61833     }
61834     function defineRule(k2, filter2, max3) {
61835       var isEnabled = true;
61836       _keys.push(k2);
61837       _rules[k2] = {
61838         filter: filter2,
61839         enabled: isEnabled,
61840         // whether the user wants it enabled..
61841         count: 0,
61842         currentMax: max3 || Infinity,
61843         defaultMax: max3 || Infinity,
61844         enable: function() {
61845           this.enabled = true;
61846           this.currentMax = this.defaultMax;
61847         },
61848         disable: function() {
61849           this.enabled = false;
61850           this.currentMax = 0;
61851         },
61852         hidden: function() {
61853           return this.count === 0 && !this.enabled || this.count > this.currentMax * _cullFactor;
61854         },
61855         autoHidden: function() {
61856           return this.hidden() && this.currentMax > 0;
61857         }
61858       };
61859     }
61860     defineRule("points", function isPoint(tags, geometry) {
61861       return geometry === "point";
61862     }, 200);
61863     defineRule("traffic_roads", function isTrafficRoad(tags) {
61864       return traffic_roads[tags.highway];
61865     });
61866     defineRule("service_roads", function isServiceRoad(tags) {
61867       return service_roads[tags.highway];
61868     });
61869     defineRule("paths", function isPath(tags) {
61870       return paths[tags.highway];
61871     });
61872     defineRule("buildings", function isBuilding(tags) {
61873       return !!tags.building && tags.building !== "no" || tags.parking === "multi-storey" || tags.parking === "sheds" || tags.parking === "carports" || tags.parking === "garage_boxes";
61874     }, 250);
61875     defineRule("building_parts", function isBuildingPart(tags) {
61876       return !!tags["building:part"];
61877     });
61878     defineRule("indoor", function isIndoor(tags) {
61879       return !!tags.indoor;
61880     });
61881     defineRule("landuse", function isLanduse(tags, geometry) {
61882       return geometry === "area" && (!!tags.landuse || !!tags.natural || !!tags.leisure || !!tags.amenity) && !_rules.buildings.filter(tags) && !_rules.building_parts.filter(tags) && !_rules.indoor.filter(tags) && !_rules.water.filter(tags) && !_rules.pistes.filter(tags);
61883     });
61884     defineRule("boundaries", function isBoundary(tags, geometry) {
61885       return (geometry === "line" && !!tags.boundary || geometry === "relation" && tags.type === "boundary") && !(traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway] || tags.waterway || tags.railway || tags.landuse || tags.natural || tags.building || tags.power);
61886     });
61887     defineRule("water", function isWater(tags) {
61888       return !!tags.waterway || tags.natural === "water" || tags.natural === "coastline" || tags.natural === "bay" || tags.landuse === "pond" || tags.landuse === "basin" || tags.landuse === "reservoir" || tags.landuse === "salt_pond";
61889     });
61890     defineRule("rail", function isRail(tags) {
61891       return (!!tags.railway || tags.landuse === "railway") && !(traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]);
61892     });
61893     defineRule("pistes", function isPiste(tags) {
61894       return tags["piste:type"];
61895     });
61896     defineRule("aerialways", function isAerialways(tags) {
61897       return !!(tags == null ? void 0 : tags.aerialway) && tags.aerialway !== "yes" && tags.aerialway !== "station";
61898     });
61899     defineRule("power", function isPower(tags) {
61900       return !!tags.power;
61901     });
61902     defineRule("past_future", function isPastFuture(tags) {
61903       if (traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]) {
61904         return false;
61905       }
61906       const keys2 = Object.keys(tags);
61907       for (let i3 = 0; i3 < keys2.length; i3++) {
61908         const key = keys2[i3];
61909         const s2 = key.split(":")[0];
61910         if (osmLifecyclePrefixes[s2] || osmLifecyclePrefixes[tags[key]]) return true;
61911       }
61912       return false;
61913     });
61914     defineRule("others", function isOther(tags, geometry) {
61915       return geometry === "line" || geometry === "area";
61916     });
61917     features.features = function() {
61918       return _rules;
61919     };
61920     features.keys = function() {
61921       return _keys;
61922     };
61923     features.enabled = function(k2) {
61924       if (!arguments.length) {
61925         return _keys.filter(function(k3) {
61926           return _rules[k3].enabled;
61927         });
61928       }
61929       return _rules[k2] && _rules[k2].enabled;
61930     };
61931     features.disabled = function(k2) {
61932       if (!arguments.length) {
61933         return _keys.filter(function(k3) {
61934           return !_rules[k3].enabled;
61935         });
61936       }
61937       return _rules[k2] && !_rules[k2].enabled;
61938     };
61939     features.hidden = function(k2) {
61940       var _a4;
61941       if (!arguments.length) {
61942         return _keys.filter(function(k3) {
61943           return _rules[k3].hidden();
61944         });
61945       }
61946       return (_a4 = _rules[k2]) == null ? void 0 : _a4.hidden();
61947     };
61948     features.autoHidden = function(k2) {
61949       if (!arguments.length) {
61950         return _keys.filter(function(k3) {
61951           return _rules[k3].autoHidden();
61952         });
61953       }
61954       return _rules[k2] && _rules[k2].autoHidden();
61955     };
61956     features.enable = function(k2) {
61957       if (_rules[k2] && !_rules[k2].enabled) {
61958         _rules[k2].enable();
61959         update();
61960       }
61961     };
61962     features.enableAll = function() {
61963       var didEnable = false;
61964       for (var k2 in _rules) {
61965         if (!_rules[k2].enabled) {
61966           didEnable = true;
61967           _rules[k2].enable();
61968         }
61969       }
61970       if (didEnable) update();
61971     };
61972     features.disable = function(k2) {
61973       if (_rules[k2] && _rules[k2].enabled) {
61974         _rules[k2].disable();
61975         update();
61976       }
61977     };
61978     features.disableAll = function() {
61979       var didDisable = false;
61980       for (var k2 in _rules) {
61981         if (_rules[k2].enabled) {
61982           didDisable = true;
61983           _rules[k2].disable();
61984         }
61985       }
61986       if (didDisable) update();
61987     };
61988     features.toggle = function(k2) {
61989       if (_rules[k2]) {
61990         (function(f2) {
61991           return f2.enabled ? f2.disable() : f2.enable();
61992         })(_rules[k2]);
61993         update();
61994       }
61995     };
61996     features.resetStats = function() {
61997       for (var i3 = 0; i3 < _keys.length; i3++) {
61998         _rules[_keys[i3]].count = 0;
61999       }
62000       dispatch14.call("change");
62001     };
62002     features.gatherStats = function(d2, resolver, dimensions) {
62003       var needsRedraw = false;
62004       var types = utilArrayGroupBy(d2, "type");
62005       var entities = [].concat(types.relation || [], types.way || [], types.node || []);
62006       var currHidden, geometry, matches, i3, j2;
62007       for (i3 = 0; i3 < _keys.length; i3++) {
62008         _rules[_keys[i3]].count = 0;
62009       }
62010       _cullFactor = dimensions[0] * dimensions[1] / 1e6;
62011       for (i3 = 0; i3 < entities.length; i3++) {
62012         geometry = entities[i3].geometry(resolver);
62013         matches = Object.keys(features.getMatches(entities[i3], resolver, geometry));
62014         for (j2 = 0; j2 < matches.length; j2++) {
62015           _rules[matches[j2]].count++;
62016         }
62017       }
62018       currHidden = features.hidden();
62019       if (currHidden !== _hidden) {
62020         _hidden = currHidden;
62021         needsRedraw = true;
62022         dispatch14.call("change");
62023       }
62024       return needsRedraw;
62025     };
62026     features.stats = function() {
62027       for (var i3 = 0; i3 < _keys.length; i3++) {
62028         _stats[_keys[i3]] = _rules[_keys[i3]].count;
62029       }
62030       return _stats;
62031     };
62032     features.clear = function(d2) {
62033       for (var i3 = 0; i3 < d2.length; i3++) {
62034         features.clearEntity(d2[i3]);
62035       }
62036     };
62037     features.clearEntity = function(entity) {
62038       delete _cache5[osmEntity.key(entity)];
62039     };
62040     features.reset = function() {
62041       Array.from(_deferred2).forEach(function(handle) {
62042         window.cancelIdleCallback(handle);
62043         _deferred2.delete(handle);
62044       });
62045       _cache5 = {};
62046     };
62047     function relationShouldBeChecked(relation) {
62048       return relation.tags.type === "boundary";
62049     }
62050     features.getMatches = function(entity, resolver, geometry) {
62051       if (geometry === "vertex" || geometry === "relation" && !relationShouldBeChecked(entity)) return {};
62052       var ent = osmEntity.key(entity);
62053       if (!_cache5[ent]) {
62054         _cache5[ent] = {};
62055       }
62056       if (!_cache5[ent].matches) {
62057         var matches = {};
62058         var hasMatch = false;
62059         for (var i3 = 0; i3 < _keys.length; i3++) {
62060           if (_keys[i3] === "others") {
62061             if (hasMatch) continue;
62062             if (entity.type === "way") {
62063               var parents = features.getParents(entity, resolver, geometry);
62064               if (parents.length === 1 && parents[0].isMultipolygon() || // 2b. or belongs only to boundary relations
62065               parents.length > 0 && parents.every(function(parent) {
62066                 return parent.tags.type === "boundary";
62067               })) {
62068                 var pkey = osmEntity.key(parents[0]);
62069                 if (_cache5[pkey] && _cache5[pkey].matches) {
62070                   matches = Object.assign({}, _cache5[pkey].matches);
62071                   continue;
62072                 }
62073               }
62074             }
62075           }
62076           if (_rules[_keys[i3]].filter(entity.tags, geometry)) {
62077             matches[_keys[i3]] = hasMatch = true;
62078           }
62079         }
62080         _cache5[ent].matches = matches;
62081       }
62082       return _cache5[ent].matches;
62083     };
62084     features.getParents = function(entity, resolver, geometry) {
62085       if (geometry === "point") return [];
62086       var ent = osmEntity.key(entity);
62087       if (!_cache5[ent]) {
62088         _cache5[ent] = {};
62089       }
62090       if (!_cache5[ent].parents) {
62091         var parents = [];
62092         if (geometry === "vertex") {
62093           parents = resolver.parentWays(entity);
62094         } else {
62095           parents = resolver.parentRelations(entity);
62096         }
62097         _cache5[ent].parents = parents;
62098       }
62099       return _cache5[ent].parents;
62100     };
62101     features.isHiddenPreset = function(preset, geometry) {
62102       if (!_hidden.length) return false;
62103       if (!preset.tags) return false;
62104       var test = preset.setTags({}, geometry);
62105       for (var key in _rules) {
62106         if (_rules[key].filter(test, geometry)) {
62107           if (_hidden.indexOf(key) !== -1) {
62108             return key;
62109           }
62110           return false;
62111         }
62112       }
62113       return false;
62114     };
62115     features.isHiddenFeature = function(entity, resolver, geometry) {
62116       if (!_hidden.length) return false;
62117       if (!entity.version) return false;
62118       if (_forceVisible[entity.id]) return false;
62119       var matches = Object.keys(features.getMatches(entity, resolver, geometry));
62120       return matches.length && matches.every(function(k2) {
62121         return features.hidden(k2);
62122       });
62123     };
62124     features.isHiddenChild = function(entity, resolver, geometry) {
62125       if (!_hidden.length) return false;
62126       if (!entity.version || geometry === "point") return false;
62127       if (_forceVisible[entity.id]) return false;
62128       var parents = features.getParents(entity, resolver, geometry);
62129       if (!parents.length) return false;
62130       for (var i3 = 0; i3 < parents.length; i3++) {
62131         if (!features.isHidden(parents[i3], resolver, parents[i3].geometry(resolver))) {
62132           return false;
62133         }
62134       }
62135       return true;
62136     };
62137     features.hasHiddenConnections = function(entity, resolver) {
62138       if (!_hidden.length) return false;
62139       var childNodes, connections;
62140       if (entity.type === "midpoint") {
62141         childNodes = [resolver.entity(entity.edge[0]), resolver.entity(entity.edge[1])];
62142         connections = [];
62143       } else {
62144         childNodes = entity.nodes ? resolver.childNodes(entity) : [];
62145         connections = features.getParents(entity, resolver, entity.geometry(resolver));
62146       }
62147       connections = childNodes.reduce(function(result, e3) {
62148         return resolver.isShared(e3) ? utilArrayUnion(result, resolver.parentWays(e3)) : result;
62149       }, connections);
62150       return connections.some(function(e3) {
62151         return features.isHidden(e3, resolver, e3.geometry(resolver));
62152       });
62153     };
62154     features.isHidden = function(entity, resolver, geometry) {
62155       if (!_hidden.length) return false;
62156       if (!entity.version) return false;
62157       var fn = geometry === "vertex" ? features.isHiddenChild : features.isHiddenFeature;
62158       return fn(entity, resolver, geometry);
62159     };
62160     features.filter = function(d2, resolver) {
62161       if (!_hidden.length) return d2;
62162       var result = [];
62163       for (var i3 = 0; i3 < d2.length; i3++) {
62164         var entity = d2[i3];
62165         if (!features.isHidden(entity, resolver, entity.geometry(resolver))) {
62166           result.push(entity);
62167         }
62168       }
62169       return result;
62170     };
62171     features.forceVisible = function(entityIDs) {
62172       if (!arguments.length) return Object.keys(_forceVisible);
62173       _forceVisible = {};
62174       for (var i3 = 0; i3 < entityIDs.length; i3++) {
62175         _forceVisible[entityIDs[i3]] = true;
62176         var entity = context.hasEntity(entityIDs[i3]);
62177         if (entity && entity.type === "relation") {
62178           for (var j2 in entity.members) {
62179             _forceVisible[entity.members[j2].id] = true;
62180           }
62181         }
62182       }
62183       return features;
62184     };
62185     features.init = function() {
62186       var storage = corePreferences("disabled-features");
62187       if (storage) {
62188         var storageDisabled = storage.replace(/;/g, ",").split(",");
62189         storageDisabled.forEach(features.disable);
62190       }
62191       var hash2 = utilStringQs(window.location.hash);
62192       if (hash2.disable_features) {
62193         var hashDisabled = hash2.disable_features.replace(/;/g, ",").split(",");
62194         hashDisabled.forEach(features.disable);
62195       }
62196     };
62197     context.history().on("merge.features", function(newEntities) {
62198       if (!newEntities) return;
62199       var handle = window.requestIdleCallback(function() {
62200         var graph = context.graph();
62201         var types = utilArrayGroupBy(newEntities, "type");
62202         var entities = [].concat(types.relation || [], types.way || [], types.node || []);
62203         for (var i3 = 0; i3 < entities.length; i3++) {
62204           var geometry = entities[i3].geometry(graph);
62205           features.getMatches(entities[i3], graph, geometry);
62206         }
62207       });
62208       _deferred2.add(handle);
62209     });
62210     return features;
62211   }
62212
62213   // modules/util/bind_once.js
62214   function utilBindOnce(target, type2, listener, capture) {
62215     var typeOnce = type2 + ".once";
62216     function one2() {
62217       target.on(typeOnce, null);
62218       listener.apply(this, arguments);
62219     }
62220     target.on(typeOnce, one2, capture);
62221     return this;
62222   }
62223
62224   // modules/util/zoom_pan.js
62225   function defaultFilter3(d3_event) {
62226     return !d3_event.ctrlKey && !d3_event.button;
62227   }
62228   function defaultExtent2() {
62229     var e3 = this;
62230     if (e3 instanceof SVGElement) {
62231       e3 = e3.ownerSVGElement || e3;
62232       if (e3.hasAttribute("viewBox")) {
62233         e3 = e3.viewBox.baseVal;
62234         return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]];
62235       }
62236       return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]];
62237     }
62238     return [[0, 0], [e3.clientWidth, e3.clientHeight]];
62239   }
62240   function defaultWheelDelta2(d3_event) {
62241     return -d3_event.deltaY * (d3_event.deltaMode === 1 ? 0.05 : d3_event.deltaMode ? 1 : 2e-3);
62242   }
62243   function defaultConstrain2(transform2, extent, translateExtent) {
62244     var dx0 = transform2.invertX(extent[0][0]) - translateExtent[0][0], dx1 = transform2.invertX(extent[1][0]) - translateExtent[1][0], dy0 = transform2.invertY(extent[0][1]) - translateExtent[0][1], dy1 = transform2.invertY(extent[1][1]) - translateExtent[1][1];
62245     return transform2.translate(
62246       dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
62247       dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
62248     );
62249   }
62250   function utilZoomPan() {
62251     var filter2 = defaultFilter3, extent = defaultExtent2, constrain = defaultConstrain2, wheelDelta = defaultWheelDelta2, scaleExtent = [0, Infinity], translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]], interpolate = zoom_default, dispatch14 = dispatch_default("start", "zoom", "end"), _wheelDelay = 150, _transform = identity2, _activeGesture;
62252     function zoom(selection2) {
62253       selection2.on("pointerdown.zoom", pointerdown).on("wheel.zoom", wheeled).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
62254       select_default2(window).on("pointermove.zoompan", pointermove).on("pointerup.zoompan pointercancel.zoompan", pointerup);
62255     }
62256     zoom.transform = function(collection, transform2, point) {
62257       var selection2 = collection.selection ? collection.selection() : collection;
62258       if (collection !== selection2) {
62259         schedule(collection, transform2, point);
62260       } else {
62261         selection2.interrupt().each(function() {
62262           gesture(this, arguments).start(null).zoom(null, null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end(null);
62263         });
62264       }
62265     };
62266     zoom.scaleBy = function(selection2, k2, p2) {
62267       zoom.scaleTo(selection2, function() {
62268         var k0 = _transform.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
62269         return k0 * k1;
62270       }, p2);
62271     };
62272     zoom.scaleTo = function(selection2, k2, p2) {
62273       zoom.transform(selection2, function() {
62274         var e3 = extent.apply(this, arguments), t0 = _transform, p02 = !p2 ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2, p1 = t0.invert(p02), k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
62275         return constrain(translate(scale(t0, k1), p02, p1), e3, translateExtent);
62276       }, p2);
62277     };
62278     zoom.translateBy = function(selection2, x2, y2) {
62279       zoom.transform(selection2, function() {
62280         return constrain(_transform.translate(
62281           typeof x2 === "function" ? x2.apply(this, arguments) : x2,
62282           typeof y2 === "function" ? y2.apply(this, arguments) : y2
62283         ), extent.apply(this, arguments), translateExtent);
62284       });
62285     };
62286     zoom.translateTo = function(selection2, x2, y2, p2) {
62287       zoom.transform(selection2, function() {
62288         var e3 = extent.apply(this, arguments), t2 = _transform, p02 = !p2 ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2;
62289         return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate(
62290           typeof x2 === "function" ? -x2.apply(this, arguments) : -x2,
62291           typeof y2 === "function" ? -y2.apply(this, arguments) : -y2
62292         ), e3, translateExtent);
62293       }, p2);
62294     };
62295     function scale(transform2, k2) {
62296       k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2));
62297       return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y);
62298     }
62299     function translate(transform2, p02, p1) {
62300       var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k;
62301       return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2);
62302     }
62303     function centroid(extent2) {
62304       return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
62305     }
62306     function schedule(transition2, transform2, point) {
62307       transition2.on("start.zoom", function() {
62308         gesture(this, arguments).start(null);
62309       }).on("interrupt.zoom end.zoom", function() {
62310         gesture(this, arguments).end(null);
62311       }).tween("zoom", function() {
62312         var that = this, args = arguments, g3 = gesture(that, args), e3 = extent.apply(that, args), p2 = !point ? centroid(e3) : typeof point === "function" ? point.apply(that, args) : point, w2 = Math.max(e3[1][0] - e3[0][0], e3[1][1] - e3[0][1]), a2 = _transform, b2 = typeof transform2 === "function" ? transform2.apply(that, args) : transform2, i3 = interpolate(a2.invert(p2).concat(w2 / a2.k), b2.invert(p2).concat(w2 / b2.k));
62313         return function(t2) {
62314           if (t2 === 1) {
62315             t2 = b2;
62316           } else {
62317             var l2 = i3(t2);
62318             var k2 = w2 / l2[2];
62319             t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2);
62320           }
62321           g3.zoom(null, null, t2);
62322         };
62323       });
62324     }
62325     function gesture(that, args, clean2) {
62326       return !clean2 && _activeGesture || new Gesture(that, args);
62327     }
62328     function Gesture(that, args) {
62329       this.that = that;
62330       this.args = args;
62331       this.active = 0;
62332       this.extent = extent.apply(that, args);
62333     }
62334     Gesture.prototype = {
62335       start: function(d3_event) {
62336         if (++this.active === 1) {
62337           _activeGesture = this;
62338           dispatch14.call("start", this, d3_event);
62339         }
62340         return this;
62341       },
62342       zoom: function(d3_event, key, transform2) {
62343         if (this.mouse && key !== "mouse") this.mouse[1] = transform2.invert(this.mouse[0]);
62344         if (this.pointer0 && key !== "touch") this.pointer0[1] = transform2.invert(this.pointer0[0]);
62345         if (this.pointer1 && key !== "touch") this.pointer1[1] = transform2.invert(this.pointer1[0]);
62346         _transform = transform2;
62347         dispatch14.call("zoom", this, d3_event, key, transform2);
62348         return this;
62349       },
62350       end: function(d3_event) {
62351         if (--this.active === 0) {
62352           _activeGesture = null;
62353           dispatch14.call("end", this, d3_event);
62354         }
62355         return this;
62356       }
62357     };
62358     function wheeled(d3_event) {
62359       if (!filter2.apply(this, arguments)) return;
62360       var g3 = gesture(this, arguments), t2 = _transform, k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t2.k * Math.pow(2, wheelDelta.apply(this, arguments)))), p2 = utilFastMouse(this)(d3_event);
62361       if (g3.wheel) {
62362         if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) {
62363           g3.mouse[1] = t2.invert(g3.mouse[0] = p2);
62364         }
62365         clearTimeout(g3.wheel);
62366       } else {
62367         g3.mouse = [p2, t2.invert(p2)];
62368         interrupt_default(this);
62369         g3.start(d3_event);
62370       }
62371       d3_event.preventDefault();
62372       d3_event.stopImmediatePropagation();
62373       g3.wheel = setTimeout(wheelidled, _wheelDelay);
62374       g3.zoom(d3_event, "mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent));
62375       function wheelidled() {
62376         g3.wheel = null;
62377         g3.end(d3_event);
62378       }
62379     }
62380     var _downPointerIDs = /* @__PURE__ */ new Set();
62381     var _pointerLocGetter;
62382     function pointerdown(d3_event) {
62383       _downPointerIDs.add(d3_event.pointerId);
62384       if (!filter2.apply(this, arguments)) return;
62385       var g3 = gesture(this, arguments, _downPointerIDs.size === 1);
62386       var started;
62387       d3_event.stopImmediatePropagation();
62388       _pointerLocGetter = utilFastMouse(this);
62389       var loc = _pointerLocGetter(d3_event);
62390       var p2 = [loc, _transform.invert(loc), d3_event.pointerId];
62391       if (!g3.pointer0) {
62392         g3.pointer0 = p2;
62393         started = true;
62394       } else if (!g3.pointer1 && g3.pointer0[2] !== p2[2]) {
62395         g3.pointer1 = p2;
62396       }
62397       if (started) {
62398         interrupt_default(this);
62399         g3.start(d3_event);
62400       }
62401     }
62402     function pointermove(d3_event) {
62403       if (!_downPointerIDs.has(d3_event.pointerId)) return;
62404       if (!_activeGesture || !_pointerLocGetter) return;
62405       var g3 = gesture(this, arguments);
62406       var isPointer0 = g3.pointer0 && g3.pointer0[2] === d3_event.pointerId;
62407       var isPointer1 = !isPointer0 && g3.pointer1 && g3.pointer1[2] === d3_event.pointerId;
62408       if ((isPointer0 || isPointer1) && "buttons" in d3_event && !d3_event.buttons) {
62409         if (g3.pointer0) _downPointerIDs.delete(g3.pointer0[2]);
62410         if (g3.pointer1) _downPointerIDs.delete(g3.pointer1[2]);
62411         g3.end(d3_event);
62412         return;
62413       }
62414       d3_event.preventDefault();
62415       d3_event.stopImmediatePropagation();
62416       var loc = _pointerLocGetter(d3_event);
62417       var t2, p2, l2;
62418       if (isPointer0) g3.pointer0[0] = loc;
62419       else if (isPointer1) g3.pointer1[0] = loc;
62420       t2 = _transform;
62421       if (g3.pointer1) {
62422         var p02 = g3.pointer0[0], l0 = g3.pointer0[1], p1 = g3.pointer1[0], l1 = g3.pointer1[1], dp = (dp = p1[0] - p02[0]) * dp + (dp = p1[1] - p02[1]) * dp, dl = (dl = l1[0] - l0[0]) * dl + (dl = l1[1] - l0[1]) * dl;
62423         t2 = scale(t2, Math.sqrt(dp / dl));
62424         p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2];
62425         l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
62426       } else if (g3.pointer0) {
62427         p2 = g3.pointer0[0];
62428         l2 = g3.pointer0[1];
62429       } else {
62430         return;
62431       }
62432       g3.zoom(d3_event, "touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent));
62433     }
62434     function pointerup(d3_event) {
62435       if (!_downPointerIDs.has(d3_event.pointerId)) return;
62436       _downPointerIDs.delete(d3_event.pointerId);
62437       if (!_activeGesture) return;
62438       var g3 = gesture(this, arguments);
62439       d3_event.stopImmediatePropagation();
62440       if (g3.pointer0 && g3.pointer0[2] === d3_event.pointerId) delete g3.pointer0;
62441       else if (g3.pointer1 && g3.pointer1[2] === d3_event.pointerId) delete g3.pointer1;
62442       if (g3.pointer1 && !g3.pointer0) {
62443         g3.pointer0 = g3.pointer1;
62444         delete g3.pointer1;
62445       }
62446       if (g3.pointer0) {
62447         g3.pointer0[1] = _transform.invert(g3.pointer0[0]);
62448       } else {
62449         g3.end(d3_event);
62450       }
62451     }
62452     zoom.wheelDelta = function(_2) {
62453       return arguments.length ? (wheelDelta = utilFunctor(+_2), zoom) : wheelDelta;
62454     };
62455     zoom.filter = function(_2) {
62456       return arguments.length ? (filter2 = utilFunctor(!!_2), zoom) : filter2;
62457     };
62458     zoom.extent = function(_2) {
62459       return arguments.length ? (extent = utilFunctor([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent;
62460     };
62461     zoom.scaleExtent = function(_2) {
62462       return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]];
62463     };
62464     zoom.translateExtent = function(_2) {
62465       return arguments.length ? (translateExtent[0][0] = +_2[0][0], translateExtent[1][0] = +_2[1][0], translateExtent[0][1] = +_2[0][1], translateExtent[1][1] = +_2[1][1], zoom) : [[translateExtent[0][0], translateExtent[0][1]], [translateExtent[1][0], translateExtent[1][1]]];
62466     };
62467     zoom.constrain = function(_2) {
62468       return arguments.length ? (constrain = _2, zoom) : constrain;
62469     };
62470     zoom.interpolate = function(_2) {
62471       return arguments.length ? (interpolate = _2, zoom) : interpolate;
62472     };
62473     zoom._transform = function(_2) {
62474       return arguments.length ? (_transform = _2, zoom) : _transform;
62475     };
62476     return utilRebind(zoom, dispatch14, "on");
62477   }
62478
62479   // modules/util/double_up.js
62480   function utilDoubleUp() {
62481     var dispatch14 = dispatch_default("doubleUp");
62482     var _maxTimespan = 500;
62483     var _maxDistance = 20;
62484     var _pointer;
62485     function pointerIsValidFor(loc) {
62486       return (/* @__PURE__ */ new Date()).getTime() - _pointer.startTime <= _maxTimespan && // all pointer events must occur within a small distance of the first pointerdown
62487       geoVecLength(_pointer.startLoc, loc) <= _maxDistance;
62488     }
62489     function pointerdown(d3_event) {
62490       if (d3_event.ctrlKey || d3_event.button === 2) return;
62491       var loc = [d3_event.clientX, d3_event.clientY];
62492       if (_pointer && !pointerIsValidFor(loc)) {
62493         _pointer = void 0;
62494       }
62495       if (!_pointer) {
62496         _pointer = {
62497           startLoc: loc,
62498           startTime: (/* @__PURE__ */ new Date()).getTime(),
62499           upCount: 0,
62500           pointerId: d3_event.pointerId
62501         };
62502       } else {
62503         _pointer.pointerId = d3_event.pointerId;
62504       }
62505     }
62506     function pointerup(d3_event) {
62507       if (d3_event.ctrlKey || d3_event.button === 2) return;
62508       if (!_pointer || _pointer.pointerId !== d3_event.pointerId) return;
62509       _pointer.upCount += 1;
62510       if (_pointer.upCount === 2) {
62511         var loc = [d3_event.clientX, d3_event.clientY];
62512         if (pointerIsValidFor(loc)) {
62513           var locInThis = utilFastMouse(this)(d3_event);
62514           dispatch14.call("doubleUp", this, d3_event, locInThis);
62515         }
62516         _pointer = void 0;
62517       }
62518     }
62519     function doubleUp(selection2) {
62520       if ("PointerEvent" in window) {
62521         selection2.on("pointerdown.doubleUp", pointerdown).on("pointerup.doubleUp", pointerup);
62522       } else {
62523         selection2.on("dblclick.doubleUp", function(d3_event) {
62524           dispatch14.call("doubleUp", this, d3_event, utilFastMouse(this)(d3_event));
62525         });
62526       }
62527     }
62528     doubleUp.off = function(selection2) {
62529       selection2.on("pointerdown.doubleUp", null).on("pointerup.doubleUp", null).on("dblclick.doubleUp", null);
62530     };
62531     return utilRebind(doubleUp, dispatch14, "on");
62532   }
62533
62534   // modules/renderer/map.js
62535   var TILESIZE = 256;
62536   var minZoom2 = 2;
62537   var maxZoom = 24;
62538   var kMin = geoZoomToScale(minZoom2, TILESIZE);
62539   var kMax = geoZoomToScale(maxZoom, TILESIZE);
62540   function clamp2(num, min3, max3) {
62541     return Math.max(min3, Math.min(num, max3));
62542   }
62543   function rendererMap(context) {
62544     var dispatch14 = dispatch_default(
62545       "move",
62546       "drawn",
62547       "crossEditableZoom",
62548       "hitMinZoom",
62549       "changeHighlighting",
62550       "changeAreaFill"
62551     );
62552     var projection2 = context.projection;
62553     var curtainProjection = context.curtainProjection;
62554     var drawLayers;
62555     var drawPoints;
62556     var drawVertices;
62557     var drawLines;
62558     var drawAreas;
62559     var drawMidpoints;
62560     var drawLabels;
62561     var _selection = select_default2(null);
62562     var supersurface = select_default2(null);
62563     var wrapper = select_default2(null);
62564     var surface = select_default2(null);
62565     var _dimensions = [1, 1];
62566     var _dblClickZoomEnabled = true;
62567     var _redrawEnabled = true;
62568     var _gestureTransformStart;
62569     var _transformStart = projection2.transform();
62570     var _transformLast;
62571     var _isTransformed = false;
62572     var _minzoom = 0;
62573     var _getMouseCoords;
62574     var _lastPointerEvent;
62575     var _lastWithinEditableZoom;
62576     var _pointerDown = false;
62577     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
62578     var _zoomerPannerFunction = "PointerEvent" in window ? utilZoomPan : zoom_default2;
62579     var _zoomerPanner = _zoomerPannerFunction().scaleExtent([kMin, kMax]).interpolate(value_default).filter(zoomEventFilter).on("zoom.map", zoomPan2).on("start.map", function(d3_event) {
62580       _pointerDown = d3_event && (d3_event.type === "pointerdown" || d3_event.sourceEvent && d3_event.sourceEvent.type === "pointerdown");
62581     }).on("end.map", function() {
62582       _pointerDown = false;
62583     });
62584     var _doubleUpHandler = utilDoubleUp();
62585     var scheduleRedraw = throttle_default(redraw, 750);
62586     function cancelPendingRedraw() {
62587       scheduleRedraw.cancel();
62588     }
62589     function map2(selection2) {
62590       _selection = selection2;
62591       context.on("change.map", immediateRedraw);
62592       var osm = context.connection();
62593       if (osm) {
62594         osm.on("change.map", immediateRedraw);
62595       }
62596       function didUndoOrRedo(targetTransform) {
62597         var mode = context.mode().id;
62598         if (mode !== "browse" && mode !== "select") return;
62599         if (targetTransform) {
62600           map2.transformEase(targetTransform);
62601         }
62602       }
62603       context.history().on("merge.map", function() {
62604         scheduleRedraw();
62605       }).on("change.map", immediateRedraw).on("undone.map", function(stack, fromStack) {
62606         didUndoOrRedo(fromStack.transform);
62607       }).on("redone.map", function(stack) {
62608         didUndoOrRedo(stack.transform);
62609       });
62610       context.background().on("change.map", immediateRedraw);
62611       context.features().on("redraw.map", immediateRedraw);
62612       drawLayers.on("change.map", function() {
62613         context.background().updateImagery();
62614         immediateRedraw();
62615       });
62616       selection2.on("wheel.map mousewheel.map", function(d3_event) {
62617         d3_event.preventDefault();
62618       }).call(_zoomerPanner).call(_zoomerPanner.transform, projection2.transform()).on("dblclick.zoom", null);
62619       map2.supersurface = supersurface = selection2.append("div").attr("class", "supersurface").call(utilSetTransform, 0, 0);
62620       wrapper = supersurface.append("div").attr("class", "layer layer-data");
62621       map2.surface = surface = wrapper.call(drawLayers).selectAll(".surface");
62622       surface.call(drawLabels.observe).call(_doubleUpHandler).on(_pointerPrefix + "down.zoom", function(d3_event) {
62623         _lastPointerEvent = d3_event;
62624         if (d3_event.button === 2) {
62625           d3_event.stopPropagation();
62626         }
62627       }, true).on(_pointerPrefix + "up.zoom", function(d3_event) {
62628         _lastPointerEvent = d3_event;
62629         if (resetTransform()) {
62630           immediateRedraw();
62631         }
62632       }).on(_pointerPrefix + "move.map", function(d3_event) {
62633         _lastPointerEvent = d3_event;
62634       }).on(_pointerPrefix + "over.vertices", function(d3_event) {
62635         if (map2.editableDataEnabled() && !_isTransformed) {
62636           var hover = d3_event.target.__data__;
62637           surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent());
62638           dispatch14.call("drawn", this, { full: false });
62639         }
62640       }).on(_pointerPrefix + "out.vertices", function(d3_event) {
62641         if (map2.editableDataEnabled() && !_isTransformed) {
62642           var hover = d3_event.relatedTarget && d3_event.relatedTarget.__data__;
62643           surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent());
62644           dispatch14.call("drawn", this, { full: false });
62645         }
62646       });
62647       var detected = utilDetect();
62648       if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping,
62649       // but we only need to do this on desktop Safari anyway. – #7694
62650       !detected.isMobileWebKit) {
62651         surface.on("gesturestart.surface", function(d3_event) {
62652           d3_event.preventDefault();
62653           _gestureTransformStart = projection2.transform();
62654         }).on("gesturechange.surface", gestureChange);
62655       }
62656       updateAreaFill();
62657       _doubleUpHandler.on("doubleUp.map", function(d3_event, p02) {
62658         if (!_dblClickZoomEnabled) return;
62659         if (typeof d3_event.target.__data__ === "object" && // or area fills
62660         !select_default2(d3_event.target).classed("fill")) return;
62661         var zoomOut2 = d3_event.shiftKey;
62662         var t2 = projection2.transform();
62663         var p1 = t2.invert(p02);
62664         t2 = t2.scale(zoomOut2 ? 0.5 : 2);
62665         t2.x = p02[0] - p1[0] * t2.k;
62666         t2.y = p02[1] - p1[1] * t2.k;
62667         map2.transformEase(t2);
62668       });
62669       context.on("enter.map", function() {
62670         if (!map2.editableDataEnabled(
62671           true
62672           /* skip zoom check */
62673         )) return;
62674         if (_isTransformed) return;
62675         var graph = context.graph();
62676         var selectedAndParents = {};
62677         context.selectedIDs().forEach(function(id2) {
62678           var entity = graph.hasEntity(id2);
62679           if (entity) {
62680             selectedAndParents[entity.id] = entity;
62681             if (entity.type === "node") {
62682               graph.parentWays(entity).forEach(function(parent) {
62683                 selectedAndParents[parent.id] = parent;
62684               });
62685             }
62686           }
62687         });
62688         var data = Object.values(selectedAndParents);
62689         var filter2 = function(d2) {
62690           return d2.id in selectedAndParents;
62691         };
62692         data = context.features().filter(data, graph);
62693         surface.call(drawVertices.drawSelected, graph, map2.extent()).call(drawLines, graph, data, filter2).call(drawAreas, graph, data, filter2).call(drawMidpoints, graph, data, filter2, map2.trimmedExtent());
62694         dispatch14.call("drawn", this, { full: false });
62695         scheduleRedraw();
62696       });
62697       map2.dimensions(utilGetDimensions(selection2));
62698     }
62699     function zoomEventFilter(d3_event) {
62700       if (d3_event.type === "mousedown") {
62701         var hasOrphan = false;
62702         var listeners = window.__on;
62703         for (var i3 = 0; i3 < listeners.length; i3++) {
62704           var listener = listeners[i3];
62705           if (listener.name === "zoom" && listener.type === "mouseup") {
62706             hasOrphan = true;
62707             break;
62708           }
62709         }
62710         if (hasOrphan) {
62711           var event = window.CustomEvent;
62712           if (event) {
62713             event = new event("mouseup");
62714           } else {
62715             event = window.document.createEvent("Event");
62716             event.initEvent("mouseup", false, false);
62717           }
62718           event.view = window;
62719           window.dispatchEvent(event);
62720         }
62721       }
62722       return d3_event.button !== 2;
62723     }
62724     function pxCenter() {
62725       return [_dimensions[0] / 2, _dimensions[1] / 2];
62726     }
62727     function drawEditable(difference2, extent) {
62728       var mode = context.mode();
62729       var graph = context.graph();
62730       var features = context.features();
62731       var all = context.history().intersects(map2.extent());
62732       var fullRedraw = false;
62733       var data;
62734       var set4;
62735       var filter2;
62736       var applyFeatureLayerFilters = true;
62737       if (map2.isInWideSelection()) {
62738         data = [];
62739         utilEntityAndDeepMemberIDs(mode.selectedIDs(), context.graph()).forEach(function(id2) {
62740           var entity = context.hasEntity(id2);
62741           if (entity) data.push(entity);
62742         });
62743         fullRedraw = true;
62744         filter2 = utilFunctor(true);
62745         applyFeatureLayerFilters = false;
62746       } else if (difference2) {
62747         var complete = difference2.complete(map2.extent());
62748         data = Object.values(complete).filter(Boolean);
62749         set4 = new Set(Object.keys(complete));
62750         filter2 = function(d2) {
62751           return set4.has(d2.id);
62752         };
62753         features.clear(data);
62754       } else {
62755         if (features.gatherStats(all, graph, _dimensions)) {
62756           extent = void 0;
62757         }
62758         if (extent) {
62759           data = context.history().intersects(map2.extent().intersection(extent));
62760           set4 = new Set(data.map(function(entity) {
62761             return entity.id;
62762           }));
62763           filter2 = function(d2) {
62764             return set4.has(d2.id);
62765           };
62766         } else {
62767           data = all;
62768           fullRedraw = true;
62769           filter2 = utilFunctor(true);
62770         }
62771       }
62772       if (applyFeatureLayerFilters) {
62773         data = features.filter(data, graph);
62774       } else {
62775         context.features().resetStats();
62776       }
62777       if (mode && mode.id === "select") {
62778         surface.call(drawVertices.drawSelected, graph, map2.extent());
62779       }
62780       surface.call(drawVertices, graph, data, filter2, map2.extent(), fullRedraw).call(drawLines, graph, data, filter2).call(drawAreas, graph, data, filter2).call(drawMidpoints, graph, data, filter2, map2.trimmedExtent()).call(drawLabels, graph, data, filter2, _dimensions, fullRedraw).call(drawPoints, graph, data, filter2);
62781       dispatch14.call("drawn", this, { full: true });
62782     }
62783     map2.init = function() {
62784       drawLayers = svgLayers(projection2, context);
62785       drawPoints = svgPoints(projection2, context);
62786       drawVertices = svgVertices(projection2, context);
62787       drawLines = svgLines(projection2, context);
62788       drawAreas = svgAreas(projection2, context);
62789       drawMidpoints = svgMidpoints(projection2, context);
62790       drawLabels = svgLabels(projection2, context);
62791     };
62792     function editOff() {
62793       context.features().resetStats();
62794       surface.selectAll(".layer-osm *").remove();
62795       surface.selectAll(".layer-touch:not(.markers) *").remove();
62796       var allowed = {
62797         "browse": true,
62798         "save": true,
62799         "select-note": true,
62800         "select-data": true,
62801         "select-error": true
62802       };
62803       var mode = context.mode();
62804       if (mode && !allowed[mode.id]) {
62805         context.enter(modeBrowse(context));
62806       }
62807       dispatch14.call("drawn", this, { full: true });
62808     }
62809     function gestureChange(d3_event) {
62810       var e3 = d3_event;
62811       e3.preventDefault();
62812       var props = {
62813         deltaMode: 0,
62814         // dummy values to ignore in zoomPan
62815         deltaY: 1,
62816         // dummy values to ignore in zoomPan
62817         clientX: e3.clientX,
62818         clientY: e3.clientY,
62819         screenX: e3.screenX,
62820         screenY: e3.screenY,
62821         x: e3.x,
62822         y: e3.y
62823       };
62824       var e22 = new WheelEvent("wheel", props);
62825       e22._scale = e3.scale;
62826       e22._rotation = e3.rotation;
62827       _selection.node().dispatchEvent(e22);
62828     }
62829     function zoomPan2(event, key, transform2) {
62830       var source = event && event.sourceEvent || event;
62831       var eventTransform = transform2 || event && event.transform;
62832       var x2 = eventTransform.x;
62833       var y2 = eventTransform.y;
62834       var k2 = eventTransform.k;
62835       if (source && source.type === "wheel") {
62836         if (_pointerDown) return;
62837         var detected = utilDetect();
62838         var dX = source.deltaX;
62839         var dY = source.deltaY;
62840         var x22 = x2;
62841         var y22 = y2;
62842         var k22 = k2;
62843         var t0, p02, p1;
62844         if (source.deltaMode === 1) {
62845           var lines = Math.abs(source.deltaY);
62846           var sign2 = source.deltaY > 0 ? 1 : -1;
62847           dY = sign2 * clamp2(
62848             Math.exp((lines - 1) * 0.75) * 4.000244140625,
62849             4.000244140625,
62850             // min
62851             350.000244140625
62852             // max
62853           );
62854           if (detected.os !== "mac") {
62855             dY *= 5;
62856           }
62857           t0 = _isTransformed ? _transformLast : _transformStart;
62858           p02 = _getMouseCoords(source);
62859           p1 = t0.invert(p02);
62860           k22 = t0.k * Math.pow(2, -dY / 500);
62861           k22 = clamp2(k22, kMin, kMax);
62862           x22 = p02[0] - p1[0] * k22;
62863           y22 = p02[1] - p1[1] * k22;
62864         } else if (source._scale) {
62865           t0 = _gestureTransformStart;
62866           p02 = _getMouseCoords(source);
62867           p1 = t0.invert(p02);
62868           k22 = t0.k * source._scale;
62869           k22 = clamp2(k22, kMin, kMax);
62870           x22 = p02[0] - p1[0] * k22;
62871           y22 = p02[1] - p1[1] * k22;
62872         } else if (source.ctrlKey && !isInteger(dY)) {
62873           dY *= 6;
62874           t0 = _isTransformed ? _transformLast : _transformStart;
62875           p02 = _getMouseCoords(source);
62876           p1 = t0.invert(p02);
62877           k22 = t0.k * Math.pow(2, -dY / 500);
62878           k22 = clamp2(k22, kMin, kMax);
62879           x22 = p02[0] - p1[0] * k22;
62880           y22 = p02[1] - p1[1] * k22;
62881         } else if ((source.altKey || source.shiftKey) && isInteger(dY)) {
62882           t0 = _isTransformed ? _transformLast : _transformStart;
62883           p02 = _getMouseCoords(source);
62884           p1 = t0.invert(p02);
62885           k22 = t0.k * Math.pow(2, -dY / 500);
62886           k22 = clamp2(k22, kMin, kMax);
62887           x22 = p02[0] - p1[0] * k22;
62888           y22 = p02[1] - p1[1] * k22;
62889         } else if (detected.os === "mac" && detected.browser !== "Firefox" && !source.ctrlKey && isInteger(dX) && isInteger(dY)) {
62890           p1 = projection2.translate();
62891           x22 = p1[0] - dX;
62892           y22 = p1[1] - dY;
62893           k22 = projection2.scale();
62894           k22 = clamp2(k22, kMin, kMax);
62895         }
62896         if (x22 !== x2 || y22 !== y2 || k22 !== k2) {
62897           x2 = x22;
62898           y2 = y22;
62899           k2 = k22;
62900           eventTransform = identity2.translate(x22, y22).scale(k22);
62901           if (_zoomerPanner._transform) {
62902             _zoomerPanner._transform(eventTransform);
62903           } else {
62904             _selection.node().__zoom = eventTransform;
62905           }
62906         }
62907       }
62908       if (_transformStart.x === x2 && _transformStart.y === y2 && _transformStart.k === k2) {
62909         return;
62910       }
62911       if (geoScaleToZoom(k2, TILESIZE) < _minzoom) {
62912         surface.interrupt();
62913         dispatch14.call("hitMinZoom", this, map2);
62914         setCenterZoom(map2.center(), context.minEditableZoom(), 0, true);
62915         scheduleRedraw();
62916         dispatch14.call("move", this, map2);
62917         return;
62918       }
62919       projection2.transform(eventTransform);
62920       var withinEditableZoom = map2.withinEditableZoom();
62921       if (_lastWithinEditableZoom !== withinEditableZoom) {
62922         if (_lastWithinEditableZoom !== void 0) {
62923           dispatch14.call("crossEditableZoom", this, withinEditableZoom);
62924         }
62925         _lastWithinEditableZoom = withinEditableZoom;
62926       }
62927       var scale = k2 / _transformStart.k;
62928       var tX = (x2 / scale - _transformStart.x) * scale;
62929       var tY = (y2 / scale - _transformStart.y) * scale;
62930       if (context.inIntro()) {
62931         curtainProjection.transform({
62932           x: x2 - tX,
62933           y: y2 - tY,
62934           k: k2
62935         });
62936       }
62937       if (source) {
62938         _lastPointerEvent = event;
62939       }
62940       _isTransformed = true;
62941       _transformLast = eventTransform;
62942       utilSetTransform(supersurface, tX, tY, scale);
62943       scheduleRedraw();
62944       dispatch14.call("move", this, map2);
62945       function isInteger(val) {
62946         return typeof val === "number" && isFinite(val) && Math.floor(val) === val;
62947       }
62948     }
62949     function resetTransform() {
62950       if (!_isTransformed) return false;
62951       utilSetTransform(supersurface, 0, 0);
62952       _isTransformed = false;
62953       if (context.inIntro()) {
62954         curtainProjection.transform(projection2.transform());
62955       }
62956       return true;
62957     }
62958     function redraw(difference2, extent) {
62959       if (typeof window === "undefined") return;
62960       if (surface.empty() || !_redrawEnabled) return;
62961       if (resetTransform()) {
62962         difference2 = extent = void 0;
62963       }
62964       var zoom = map2.zoom();
62965       var z2 = String(~~zoom);
62966       if (surface.attr("data-zoom") !== z2) {
62967         surface.attr("data-zoom", z2);
62968       }
62969       var lat = map2.center()[1];
62970       var lowzoom = linear3().domain([-60, 0, 60]).range([17, 18.5, 17]).clamp(true);
62971       surface.classed("low-zoom", zoom <= lowzoom(lat));
62972       if (!difference2) {
62973         supersurface.call(context.background());
62974         wrapper.call(drawLayers);
62975       }
62976       if (map2.editableDataEnabled() || map2.isInWideSelection()) {
62977         context.loadTiles(projection2);
62978         drawEditable(difference2, extent);
62979       } else {
62980         editOff();
62981       }
62982       _transformStart = projection2.transform();
62983       return map2;
62984     }
62985     var immediateRedraw = function(difference2, extent) {
62986       if (!difference2 && !extent) cancelPendingRedraw();
62987       redraw(difference2, extent);
62988     };
62989     map2.lastPointerEvent = function() {
62990       return _lastPointerEvent;
62991     };
62992     map2.mouse = function(d3_event) {
62993       var event = d3_event || _lastPointerEvent;
62994       if (event) {
62995         var s2;
62996         while (s2 = event.sourceEvent) {
62997           event = s2;
62998         }
62999         return _getMouseCoords(event);
63000       }
63001       return null;
63002     };
63003     map2.mouseCoordinates = function() {
63004       var coord2 = map2.mouse() || pxCenter();
63005       return projection2.invert(coord2);
63006     };
63007     map2.dblclickZoomEnable = function(val) {
63008       if (!arguments.length) return _dblClickZoomEnabled;
63009       _dblClickZoomEnabled = val;
63010       return map2;
63011     };
63012     map2.redrawEnable = function(val) {
63013       if (!arguments.length) return _redrawEnabled;
63014       _redrawEnabled = val;
63015       return map2;
63016     };
63017     map2.isTransformed = function() {
63018       return _isTransformed;
63019     };
63020     function setTransform(t2, duration, force) {
63021       var t3 = projection2.transform();
63022       if (!force && t2.k === t3.k && t2.x === t3.x && t2.y === t3.y) return false;
63023       if (duration) {
63024         _selection.transition().duration(duration).on("start", function() {
63025           map2.startEase();
63026         }).call(_zoomerPanner.transform, identity2.translate(t2.x, t2.y).scale(t2.k));
63027       } else {
63028         projection2.transform(t2);
63029         _transformStart = t2;
63030         _selection.call(_zoomerPanner.transform, _transformStart);
63031       }
63032       return true;
63033     }
63034     function setCenterZoom(loc2, z2, duration, force) {
63035       var c2 = map2.center();
63036       var z3 = map2.zoom();
63037       if (loc2[0] === c2[0] && loc2[1] === c2[1] && z2 === z3 && !force) return false;
63038       var proj = geoRawMercator().transform(projection2.transform());
63039       var k2 = clamp2(geoZoomToScale(z2, TILESIZE), kMin, kMax);
63040       proj.scale(k2);
63041       var t2 = proj.translate();
63042       var point = proj(loc2);
63043       var center = pxCenter();
63044       t2[0] += center[0] - point[0];
63045       t2[1] += center[1] - point[1];
63046       return setTransform(identity2.translate(t2[0], t2[1]).scale(k2), duration, force);
63047     }
63048     map2.pan = function(delta, duration) {
63049       var t2 = projection2.translate();
63050       var k2 = projection2.scale();
63051       t2[0] += delta[0];
63052       t2[1] += delta[1];
63053       if (duration) {
63054         _selection.transition().duration(duration).on("start", function() {
63055           map2.startEase();
63056         }).call(_zoomerPanner.transform, identity2.translate(t2[0], t2[1]).scale(k2));
63057       } else {
63058         projection2.translate(t2);
63059         _transformStart = projection2.transform();
63060         _selection.call(_zoomerPanner.transform, _transformStart);
63061         dispatch14.call("move", this, map2);
63062         immediateRedraw();
63063       }
63064       return map2;
63065     };
63066     map2.dimensions = function(val) {
63067       if (!arguments.length) return _dimensions;
63068       _dimensions = val;
63069       drawLayers.dimensions(_dimensions);
63070       context.background().dimensions(_dimensions);
63071       projection2.clipExtent([[0, 0], _dimensions]);
63072       _getMouseCoords = utilFastMouse(supersurface.node());
63073       scheduleRedraw();
63074       return map2;
63075     };
63076     function zoomIn(delta) {
63077       setCenterZoom(map2.center(), ~~map2.zoom() + delta, 250, true);
63078     }
63079     function zoomOut(delta) {
63080       setCenterZoom(map2.center(), ~~map2.zoom() - delta, 250, true);
63081     }
63082     map2.zoomIn = function() {
63083       zoomIn(1);
63084     };
63085     map2.zoomInFurther = function() {
63086       zoomIn(4);
63087     };
63088     map2.canZoomIn = function() {
63089       return map2.zoom() < maxZoom;
63090     };
63091     map2.zoomOut = function() {
63092       zoomOut(1);
63093     };
63094     map2.zoomOutFurther = function() {
63095       zoomOut(4);
63096     };
63097     map2.canZoomOut = function() {
63098       return map2.zoom() > minZoom2;
63099     };
63100     map2.center = function(loc2) {
63101       if (!arguments.length) {
63102         return projection2.invert(pxCenter());
63103       }
63104       if (setCenterZoom(loc2, map2.zoom())) {
63105         dispatch14.call("move", this, map2);
63106       }
63107       scheduleRedraw();
63108       return map2;
63109     };
63110     map2.unobscuredCenterZoomEase = function(loc, zoom) {
63111       var offset = map2.unobscuredOffsetPx();
63112       var proj = geoRawMercator().transform(projection2.transform());
63113       proj.scale(geoZoomToScale(zoom, TILESIZE));
63114       var locPx = proj(loc);
63115       var offsetLocPx = [locPx[0] + offset[0], locPx[1] + offset[1]];
63116       var offsetLoc = proj.invert(offsetLocPx);
63117       map2.centerZoomEase(offsetLoc, zoom);
63118     };
63119     map2.unobscuredOffsetPx = function() {
63120       var openPane = context.container().select(".map-panes .map-pane.shown");
63121       if (!openPane.empty()) {
63122         return [openPane.node().offsetWidth / 2, 0];
63123       }
63124       return [0, 0];
63125     };
63126     map2.zoom = function(z2) {
63127       if (!arguments.length) {
63128         return Math.max(geoScaleToZoom(projection2.scale(), TILESIZE), 0);
63129       }
63130       if (z2 < _minzoom) {
63131         surface.interrupt();
63132         dispatch14.call("hitMinZoom", this, map2);
63133         z2 = context.minEditableZoom();
63134       }
63135       if (setCenterZoom(map2.center(), z2)) {
63136         dispatch14.call("move", this, map2);
63137       }
63138       scheduleRedraw();
63139       return map2;
63140     };
63141     map2.centerZoom = function(loc2, z2) {
63142       if (setCenterZoom(loc2, z2)) {
63143         dispatch14.call("move", this, map2);
63144       }
63145       scheduleRedraw();
63146       return map2;
63147     };
63148     map2.zoomTo = function(entities) {
63149       if (!isArray_default(entities)) {
63150         entities = [entities];
63151       }
63152       if (entities.length === 0) return map2;
63153       var extent = entities.map((entity) => entity.extent(context.graph())).reduce((a2, b2) => a2.extend(b2));
63154       if (!isFinite(extent.area())) return map2;
63155       var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20);
63156       return map2.centerZoom(extent.center(), z2);
63157     };
63158     map2.centerEase = function(loc2, duration) {
63159       duration = duration || 250;
63160       setCenterZoom(loc2, map2.zoom(), duration);
63161       return map2;
63162     };
63163     map2.zoomEase = function(z2, duration) {
63164       duration = duration || 250;
63165       setCenterZoom(map2.center(), z2, duration, false);
63166       return map2;
63167     };
63168     map2.centerZoomEase = function(loc2, z2, duration) {
63169       duration = duration || 250;
63170       setCenterZoom(loc2, z2, duration, false);
63171       return map2;
63172     };
63173     map2.transformEase = function(t2, duration) {
63174       duration = duration || 250;
63175       setTransform(
63176         t2,
63177         duration,
63178         false
63179         /* don't force */
63180       );
63181       return map2;
63182     };
63183     map2.zoomToEase = function(obj, duration) {
63184       var extent;
63185       if (Array.isArray(obj)) {
63186         obj.forEach(function(entity) {
63187           var entityExtent = entity.extent(context.graph());
63188           if (!extent) {
63189             extent = entityExtent;
63190           } else {
63191             extent = extent.extend(entityExtent);
63192           }
63193         });
63194       } else {
63195         extent = obj.extent(context.graph());
63196       }
63197       if (!isFinite(extent.area())) return map2;
63198       var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20);
63199       return map2.centerZoomEase(extent.center(), z2, duration);
63200     };
63201     map2.startEase = function() {
63202       utilBindOnce(surface, _pointerPrefix + "down.ease", function() {
63203         map2.cancelEase();
63204       });
63205       return map2;
63206     };
63207     map2.cancelEase = function() {
63208       _selection.interrupt();
63209       return map2;
63210     };
63211     map2.extent = function(val) {
63212       if (!arguments.length) {
63213         return new geoExtent(
63214           projection2.invert([0, _dimensions[1]]),
63215           projection2.invert([_dimensions[0], 0])
63216         );
63217       } else {
63218         var extent = geoExtent(val);
63219         map2.centerZoom(extent.center(), map2.extentZoom(extent));
63220       }
63221     };
63222     map2.trimmedExtent = function(val) {
63223       if (!arguments.length) {
63224         var headerY = 71;
63225         var footerY = 30;
63226         var pad2 = 10;
63227         return new geoExtent(
63228           projection2.invert([pad2, _dimensions[1] - footerY - pad2]),
63229           projection2.invert([_dimensions[0] - pad2, headerY + pad2])
63230         );
63231       } else {
63232         var extent = geoExtent(val);
63233         map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent));
63234       }
63235     };
63236     function calcExtentZoom(extent, dim) {
63237       var tl = projection2([extent[0][0], extent[1][1]]);
63238       var br2 = projection2([extent[1][0], extent[0][1]]);
63239       var hFactor = (br2[0] - tl[0]) / dim[0];
63240       var vFactor = (br2[1] - tl[1]) / dim[1];
63241       var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
63242       var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
63243       var newZoom = map2.zoom() - Math.max(hZoomDiff, vZoomDiff);
63244       return newZoom;
63245     }
63246     map2.extentZoom = function(val) {
63247       return calcExtentZoom(geoExtent(val), _dimensions);
63248     };
63249     map2.trimmedExtentZoom = function(val) {
63250       var trimY = 120;
63251       var trimX = 40;
63252       var trimmed = [_dimensions[0] - trimX, _dimensions[1] - trimY];
63253       return calcExtentZoom(geoExtent(val), trimmed);
63254     };
63255     map2.withinEditableZoom = function() {
63256       return map2.zoom() >= context.minEditableZoom();
63257     };
63258     map2.isInWideSelection = function() {
63259       return !map2.withinEditableZoom() && context.selectedIDs().length;
63260     };
63261     map2.editableDataEnabled = function(skipZoomCheck) {
63262       var layer = context.layers().layer("osm");
63263       if (!layer || !layer.enabled()) return false;
63264       return skipZoomCheck || map2.withinEditableZoom();
63265     };
63266     map2.notesEditable = function() {
63267       var layer = context.layers().layer("notes");
63268       if (!layer || !layer.enabled()) return false;
63269       return map2.withinEditableZoom();
63270     };
63271     map2.minzoom = function(val) {
63272       if (!arguments.length) return _minzoom;
63273       _minzoom = val;
63274       return map2;
63275     };
63276     map2.toggleHighlightEdited = function() {
63277       surface.classed("highlight-edited", !surface.classed("highlight-edited"));
63278       map2.pan([0, 0]);
63279       dispatch14.call("changeHighlighting", this);
63280     };
63281     map2.areaFillOptions = ["wireframe", "partial", "full"];
63282     map2.activeAreaFill = function(val) {
63283       if (!arguments.length) return corePreferences("area-fill") || "partial";
63284       corePreferences("area-fill", val);
63285       if (val !== "wireframe") {
63286         corePreferences("area-fill-toggle", val);
63287       }
63288       updateAreaFill();
63289       map2.pan([0, 0]);
63290       dispatch14.call("changeAreaFill", this);
63291       return map2;
63292     };
63293     map2.toggleWireframe = function() {
63294       var activeFill = map2.activeAreaFill();
63295       if (activeFill === "wireframe") {
63296         activeFill = corePreferences("area-fill-toggle") || "partial";
63297       } else {
63298         activeFill = "wireframe";
63299       }
63300       map2.activeAreaFill(activeFill);
63301     };
63302     function updateAreaFill() {
63303       var activeFill = map2.activeAreaFill();
63304       map2.areaFillOptions.forEach(function(opt) {
63305         surface.classed("fill-" + opt, Boolean(opt === activeFill));
63306       });
63307     }
63308     map2.layers = () => drawLayers;
63309     map2.doubleUpHandler = function() {
63310       return _doubleUpHandler;
63311     };
63312     return utilRebind(map2, dispatch14, "on");
63313   }
63314
63315   // modules/renderer/photos.js
63316   function rendererPhotos(context) {
63317     var dispatch14 = dispatch_default("change");
63318     var _layerIDs = ["streetside", "mapillary", "mapillary-map-features", "mapillary-signs", "kartaview", "mapilio", "vegbilder", "panoramax"];
63319     var _allPhotoTypes = ["flat", "panoramic"];
63320     var _shownPhotoTypes = _allPhotoTypes.slice();
63321     var _dateFilters = ["fromDate", "toDate"];
63322     var _fromDate;
63323     var _toDate;
63324     var _usernames;
63325     function photos() {
63326     }
63327     function updateStorage() {
63328       if (window.mocha) return;
63329       var hash2 = utilStringQs(window.location.hash);
63330       var enabled = context.layers().all().filter(function(d2) {
63331         return _layerIDs.indexOf(d2.id) !== -1 && d2.layer && d2.layer.supported() && d2.layer.enabled();
63332       }).map(function(d2) {
63333         return d2.id;
63334       });
63335       if (enabled.length) {
63336         hash2.photo_overlay = enabled.join(",");
63337       } else {
63338         delete hash2.photo_overlay;
63339       }
63340       window.location.replace("#" + utilQsString(hash2, true));
63341     }
63342     photos.overlayLayerIDs = function() {
63343       return _layerIDs;
63344     };
63345     photos.allPhotoTypes = function() {
63346       return _allPhotoTypes;
63347     };
63348     photos.dateFilters = function() {
63349       return _dateFilters;
63350     };
63351     photos.dateFilterValue = function(val) {
63352       return val === _dateFilters[0] ? _fromDate : _toDate;
63353     };
63354     photos.setDateFilter = function(type2, val, updateUrl) {
63355       var date = val && new Date(val);
63356       if (date && !isNaN(date)) {
63357         val = date.toISOString().slice(0, 10);
63358       } else {
63359         val = null;
63360       }
63361       if (type2 === _dateFilters[0]) {
63362         _fromDate = val;
63363         if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) {
63364           _toDate = _fromDate;
63365         }
63366       }
63367       if (type2 === _dateFilters[1]) {
63368         _toDate = val;
63369         if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) {
63370           _fromDate = _toDate;
63371         }
63372       }
63373       dispatch14.call("change", this);
63374       if (updateUrl) {
63375         var rangeString;
63376         if (_fromDate || _toDate) {
63377           rangeString = (_fromDate || "") + "_" + (_toDate || "");
63378         }
63379         setUrlFilterValue("photo_dates", rangeString);
63380       }
63381     };
63382     photos.setUsernameFilter = function(val, updateUrl) {
63383       if (val && typeof val === "string") val = val.replace(/;/g, ",").split(",");
63384       if (val) {
63385         val = val.map((d2) => d2.trim()).filter(Boolean);
63386         if (!val.length) {
63387           val = null;
63388         }
63389       }
63390       _usernames = val;
63391       dispatch14.call("change", this);
63392       if (updateUrl) {
63393         var hashString;
63394         if (_usernames) {
63395           hashString = _usernames.join(",");
63396         }
63397         setUrlFilterValue("photo_username", hashString);
63398       }
63399     };
63400     function setUrlFilterValue(property, val) {
63401       if (!window.mocha) {
63402         var hash2 = utilStringQs(window.location.hash);
63403         if (val) {
63404           if (hash2[property] === val) return;
63405           hash2[property] = val;
63406         } else {
63407           if (!(property in hash2)) return;
63408           delete hash2[property];
63409         }
63410         window.location.replace("#" + utilQsString(hash2, true));
63411       }
63412     }
63413     function showsLayer(id2) {
63414       var layer = context.layers().layer(id2);
63415       return layer && layer.supported() && layer.enabled();
63416     }
63417     photos.shouldFilterByDate = function() {
63418       return showsLayer("mapillary") || showsLayer("kartaview") || showsLayer("streetside") || showsLayer("vegbilder") || showsLayer("panoramax");
63419     };
63420     photos.shouldFilterByPhotoType = function() {
63421       return showsLayer("mapillary") || showsLayer("streetside") && showsLayer("kartaview") || showsLayer("vegbilder") || showsLayer("panoramax");
63422     };
63423     photos.shouldFilterByUsername = function() {
63424       return !showsLayer("mapillary") && showsLayer("kartaview") && !showsLayer("streetside") || showsLayer("panoramax");
63425     };
63426     photos.showsPhotoType = function(val) {
63427       if (!photos.shouldFilterByPhotoType()) return true;
63428       return _shownPhotoTypes.indexOf(val) !== -1;
63429     };
63430     photos.showsFlat = function() {
63431       return photos.showsPhotoType("flat");
63432     };
63433     photos.showsPanoramic = function() {
63434       return photos.showsPhotoType("panoramic");
63435     };
63436     photos.fromDate = function() {
63437       return _fromDate;
63438     };
63439     photos.toDate = function() {
63440       return _toDate;
63441     };
63442     photos.togglePhotoType = function(val) {
63443       var index = _shownPhotoTypes.indexOf(val);
63444       if (index !== -1) {
63445         _shownPhotoTypes.splice(index, 1);
63446       } else {
63447         _shownPhotoTypes.push(val);
63448       }
63449       dispatch14.call("change", this);
63450       return photos;
63451     };
63452     photos.usernames = function() {
63453       return _usernames;
63454     };
63455     photos.init = function() {
63456       var hash2 = utilStringQs(window.location.hash);
63457       if (hash2.photo_dates) {
63458         var parts = /^(.*)[–_](.*)$/g.exec(hash2.photo_dates.trim());
63459         this.setDateFilter("fromDate", parts && parts.length >= 2 && parts[1], false);
63460         this.setDateFilter("toDate", parts && parts.length >= 3 && parts[2], false);
63461       }
63462       if (hash2.photo_username) {
63463         this.setUsernameFilter(hash2.photo_username, false);
63464       }
63465       if (hash2.photo_overlay) {
63466         var hashOverlayIDs = hash2.photo_overlay.replace(/;/g, ",").split(",");
63467         hashOverlayIDs.forEach(function(id2) {
63468           if (id2 === "openstreetcam") id2 = "kartaview";
63469           var layer2 = _layerIDs.indexOf(id2) !== -1 && context.layers().layer(id2);
63470           if (layer2 && !layer2.enabled()) layer2.enabled(true);
63471         });
63472       }
63473       if (hash2.photo) {
63474         var photoIds = hash2.photo.replace(/;/g, ",").split(",");
63475         var photoId = photoIds.length && photoIds[0].trim();
63476         var results = /(.*)\/(.*)/g.exec(photoId);
63477         if (results && results.length >= 3) {
63478           var serviceId = results[1];
63479           if (serviceId === "openstreetcam") serviceId = "kartaview";
63480           var photoKey = results[2];
63481           var service = services[serviceId];
63482           if (service && service.ensureViewerLoaded) {
63483             var layer = _layerIDs.indexOf(serviceId) !== -1 && context.layers().layer(serviceId);
63484             if (layer && !layer.enabled()) layer.enabled(true);
63485             var baselineTime = Date.now();
63486             service.on("loadedImages.rendererPhotos", function() {
63487               if (Date.now() - baselineTime > 45e3) {
63488                 service.on("loadedImages.rendererPhotos", null);
63489                 return;
63490               }
63491               if (!service.cachedImage(photoKey)) return;
63492               service.on("loadedImages.rendererPhotos", null);
63493               service.ensureViewerLoaded(context).then(function() {
63494                 service.selectImage(context, photoKey).showViewer(context);
63495               });
63496             });
63497           }
63498         }
63499       }
63500       context.layers().on("change.rendererPhotos", updateStorage);
63501     };
63502     return utilRebind(photos, dispatch14, "on");
63503   }
63504
63505   // modules/ui/map_in_map.js
63506   function uiMapInMap(context) {
63507     function mapInMap(selection2) {
63508       var backgroundLayer = rendererTileLayer(context).underzoom(2);
63509       var overlayLayers = {};
63510       var projection2 = geoRawMercator();
63511       var dataLayer = svgData(projection2, context).showLabels(false);
63512       var debugLayer = svgDebug(projection2, context);
63513       var zoom = zoom_default2().scaleExtent([geoZoomToScale(0.5), geoZoomToScale(24)]).on("start", zoomStarted).on("zoom", zoomed).on("end", zoomEnded);
63514       var wrap2 = select_default2(null);
63515       var tiles = select_default2(null);
63516       var viewport = select_default2(null);
63517       var _isTransformed = false;
63518       var _isHidden = true;
63519       var _skipEvents = false;
63520       var _gesture = null;
63521       var _zDiff = 6;
63522       var _dMini;
63523       var _cMini;
63524       var _tStart;
63525       var _tCurr;
63526       var _timeoutID;
63527       function zoomStarted() {
63528         if (_skipEvents) return;
63529         _tStart = _tCurr = projection2.transform();
63530         _gesture = null;
63531       }
63532       function zoomed(d3_event) {
63533         if (_skipEvents) return;
63534         var x2 = d3_event.transform.x;
63535         var y2 = d3_event.transform.y;
63536         var k2 = d3_event.transform.k;
63537         var isZooming = k2 !== _tStart.k;
63538         var isPanning = x2 !== _tStart.x || y2 !== _tStart.y;
63539         if (!isZooming && !isPanning) {
63540           return;
63541         }
63542         if (!_gesture) {
63543           _gesture = isZooming ? "zoom" : "pan";
63544         }
63545         var tMini = projection2.transform();
63546         var tX, tY, scale;
63547         if (_gesture === "zoom") {
63548           scale = k2 / tMini.k;
63549           tX = (_cMini[0] / scale - _cMini[0]) * scale;
63550           tY = (_cMini[1] / scale - _cMini[1]) * scale;
63551         } else {
63552           k2 = tMini.k;
63553           scale = 1;
63554           tX = x2 - tMini.x;
63555           tY = y2 - tMini.y;
63556         }
63557         utilSetTransform(tiles, tX, tY, scale);
63558         utilSetTransform(viewport, 0, 0, scale);
63559         _isTransformed = true;
63560         _tCurr = identity2.translate(x2, y2).scale(k2);
63561         var zMain = geoScaleToZoom(context.projection.scale());
63562         var zMini = geoScaleToZoom(k2);
63563         _zDiff = zMain - zMini;
63564         queueRedraw();
63565       }
63566       function zoomEnded() {
63567         if (_skipEvents) return;
63568         if (_gesture !== "pan") return;
63569         updateProjection();
63570         _gesture = null;
63571         context.map().center(projection2.invert(_cMini));
63572       }
63573       function updateProjection() {
63574         var loc = context.map().center();
63575         var tMain = context.projection.transform();
63576         var zMain = geoScaleToZoom(tMain.k);
63577         var zMini = Math.max(zMain - _zDiff, 0.5);
63578         var kMini = geoZoomToScale(zMini);
63579         projection2.translate([tMain.x, tMain.y]).scale(kMini);
63580         var point = projection2(loc);
63581         var mouse = _gesture === "pan" ? geoVecSubtract([_tCurr.x, _tCurr.y], [_tStart.x, _tStart.y]) : [0, 0];
63582         var xMini = _cMini[0] - point[0] + tMain.x + mouse[0];
63583         var yMini = _cMini[1] - point[1] + tMain.y + mouse[1];
63584         projection2.translate([xMini, yMini]).clipExtent([[0, 0], _dMini]);
63585         _tCurr = projection2.transform();
63586         if (_isTransformed) {
63587           utilSetTransform(tiles, 0, 0);
63588           utilSetTransform(viewport, 0, 0);
63589           _isTransformed = false;
63590         }
63591         zoom.scaleExtent([geoZoomToScale(0.5), geoZoomToScale(zMain - 3)]);
63592         _skipEvents = true;
63593         wrap2.call(zoom.transform, _tCurr);
63594         _skipEvents = false;
63595       }
63596       function redraw() {
63597         clearTimeout(_timeoutID);
63598         if (_isHidden) return;
63599         updateProjection();
63600         var zMini = geoScaleToZoom(projection2.scale());
63601         tiles = wrap2.selectAll(".map-in-map-tiles").data([0]);
63602         tiles = tiles.enter().append("div").attr("class", "map-in-map-tiles").merge(tiles);
63603         backgroundLayer.source(context.background().baseLayerSource()).projection(projection2).dimensions(_dMini);
63604         var background = tiles.selectAll(".map-in-map-background").data([0]);
63605         background.enter().append("div").attr("class", "map-in-map-background").merge(background).call(backgroundLayer);
63606         var overlaySources = context.background().overlayLayerSources();
63607         var activeOverlayLayers = [];
63608         for (var i3 = 0; i3 < overlaySources.length; i3++) {
63609           if (overlaySources[i3].validZoom(zMini)) {
63610             if (!overlayLayers[i3]) overlayLayers[i3] = rendererTileLayer(context);
63611             activeOverlayLayers.push(overlayLayers[i3].source(overlaySources[i3]).projection(projection2).dimensions(_dMini));
63612           }
63613         }
63614         var overlay = tiles.selectAll(".map-in-map-overlay").data([0]);
63615         overlay = overlay.enter().append("div").attr("class", "map-in-map-overlay").merge(overlay);
63616         var overlays = overlay.selectAll("div").data(activeOverlayLayers, function(d2) {
63617           return d2.source().name();
63618         });
63619         overlays.exit().remove();
63620         overlays = overlays.enter().append("div").merge(overlays).each(function(layer) {
63621           select_default2(this).call(layer);
63622         });
63623         var dataLayers = tiles.selectAll(".map-in-map-data").data([0]);
63624         dataLayers.exit().remove();
63625         dataLayers = dataLayers.enter().append("svg").attr("class", "map-in-map-data").merge(dataLayers).call(dataLayer).call(debugLayer);
63626         if (_gesture !== "pan") {
63627           var getPath = path_default(projection2);
63628           var bbox2 = { type: "Polygon", coordinates: [context.map().extent().polygon()] };
63629           viewport = wrap2.selectAll(".map-in-map-viewport").data([0]);
63630           viewport = viewport.enter().append("svg").attr("class", "map-in-map-viewport").merge(viewport);
63631           var path = viewport.selectAll(".map-in-map-bbox").data([bbox2]);
63632           path.enter().append("path").attr("class", "map-in-map-bbox").merge(path).attr("d", getPath).classed("thick", function(d2) {
63633             return getPath.area(d2) < 30;
63634           });
63635         }
63636       }
63637       function queueRedraw() {
63638         clearTimeout(_timeoutID);
63639         _timeoutID = setTimeout(function() {
63640           redraw();
63641         }, 750);
63642       }
63643       function toggle(d3_event) {
63644         if (d3_event) d3_event.preventDefault();
63645         _isHidden = !_isHidden;
63646         context.container().select(".minimap-toggle-item").classed("active", !_isHidden).select("input").property("checked", !_isHidden);
63647         if (_isHidden) {
63648           wrap2.style("display", "block").style("opacity", "1").transition().duration(200).style("opacity", "0").on("end", function() {
63649             selection2.selectAll(".map-in-map").style("display", "none");
63650           });
63651         } else {
63652           wrap2.style("display", "block").style("opacity", "0").transition().duration(200).style("opacity", "1").on("end", function() {
63653             redraw();
63654           });
63655         }
63656       }
63657       uiMapInMap.toggle = toggle;
63658       wrap2 = selection2.selectAll(".map-in-map").data([0]);
63659       wrap2 = wrap2.enter().append("div").attr("class", "map-in-map").style("display", _isHidden ? "none" : "block").call(zoom).on("dblclick.zoom", null).merge(wrap2);
63660       _dMini = [200, 150];
63661       _cMini = geoVecScale(_dMini, 0.5);
63662       context.map().on("drawn.map-in-map", function(drawn) {
63663         if (drawn.full === true) {
63664           redraw();
63665         }
63666       });
63667       redraw();
63668       context.keybinding().on(_t("background.minimap.key"), toggle);
63669     }
63670     return mapInMap;
63671   }
63672
63673   // modules/ui/notice.js
63674   function uiNotice(context) {
63675     return function(selection2) {
63676       var div = selection2.append("div").attr("class", "notice");
63677       var button = div.append("button").attr("class", "zoom-to notice fillD").on("click", function() {
63678         context.map().zoomEase(context.minEditableZoom());
63679       }).on("wheel", function(d3_event) {
63680         var e22 = new WheelEvent(d3_event.type, d3_event);
63681         context.surface().node().dispatchEvent(e22);
63682       });
63683       button.call(svgIcon("#iD-icon-plus", "pre-text")).append("span").attr("class", "label").call(_t.append("zoom_in_edit"));
63684       function disableTooHigh() {
63685         var canEdit = context.map().zoom() >= context.minEditableZoom();
63686         div.style("display", canEdit ? "none" : "block");
63687       }
63688       context.map().on("move.notice", debounce_default(disableTooHigh, 500));
63689       disableTooHigh();
63690     };
63691   }
63692
63693   // modules/ui/photoviewer.js
63694   function uiPhotoviewer(context) {
63695     var dispatch14 = dispatch_default("resize");
63696     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
63697     function photoviewer(selection2) {
63698       selection2.append("button").attr("class", "thumb-hide").attr("title", _t("icons.close")).on("click", function() {
63699         if (services.streetside) {
63700           services.streetside.hideViewer(context);
63701         }
63702         if (services.mapillary) {
63703           services.mapillary.hideViewer(context);
63704         }
63705         if (services.kartaview) {
63706           services.kartaview.hideViewer(context);
63707         }
63708         if (services.mapilio) {
63709           services.mapilio.hideViewer(context);
63710         }
63711         if (services.panoramax) {
63712           services.panoramax.hideViewer(context);
63713         }
63714         if (services.vegbilder) {
63715           services.vegbilder.hideViewer(context);
63716         }
63717       }).append("div").call(svgIcon("#iD-icon-close"));
63718       function preventDefault(d3_event) {
63719         d3_event.preventDefault();
63720       }
63721       selection2.append("button").attr("class", "resize-handle-xy").on("touchstart touchdown touchend", preventDefault).on(
63722         _pointerPrefix + "down",
63723         buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true, resizeOnY: true })
63724       );
63725       selection2.append("button").attr("class", "resize-handle-x").on("touchstart touchdown touchend", preventDefault).on(
63726         _pointerPrefix + "down",
63727         buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true })
63728       );
63729       selection2.append("button").attr("class", "resize-handle-y").on("touchstart touchdown touchend", preventDefault).on(
63730         _pointerPrefix + "down",
63731         buildResizeListener(selection2, "resize", dispatch14, { resizeOnY: true })
63732       );
63733       context.features().on("change.setPhotoFromViewer", function() {
63734         setPhotoFromViewerButton();
63735       });
63736       context.history().on("change.setPhotoFromViewer", function() {
63737         setPhotoFromViewerButton();
63738       });
63739       function setPhotoFromViewerButton() {
63740         if (services.mapillary.isViewerOpen()) {
63741           let setMapillaryPhotoId2 = function() {
63742             const service = services.mapillary;
63743             const image = service.getActiveImage();
63744             const action = (graph) => context.selectedIDs().reduce((graph2, entityID) => {
63745               const tags = graph2.entity(entityID).tags;
63746               const action2 = actionChangeTags(entityID, __spreadProps(__spreadValues({}, tags), { mapillary: image.id }));
63747               return action2(graph2);
63748             }, graph);
63749             const annotation = _t("operations.change_tags.annotation");
63750             context.perform(action, annotation);
63751           };
63752           var setMapillaryPhotoId = setMapillaryPhotoId2;
63753           if (context.mode().id !== "select" || !(layerStatus("mapillary") && getServiceId() === "mapillary")) {
63754             buttonRemove();
63755           } else {
63756             if (selection2.select(".set-photo-from-viewer").empty()) {
63757               const button = buttonCreate();
63758               button.on("click", function(e3) {
63759                 e3.preventDefault();
63760                 e3.stopPropagation();
63761                 setMapillaryPhotoId2();
63762                 buttonDisable("already_set");
63763               });
63764             }
63765             buttonShowHide();
63766           }
63767         }
63768         function layerStatus(which) {
63769           const layers = context.layers();
63770           const layer = layers.layer(which);
63771           return layer.enabled();
63772         }
63773         function getServiceId() {
63774           const hash2 = utilStringQs(window.location.hash);
63775           let serviceId;
63776           if (hash2.photo) {
63777             let result = hash2.photo.split("/");
63778             serviceId = result[0];
63779           }
63780           return serviceId;
63781         }
63782         function buttonCreate() {
63783           const button = selection2.selectAll(".set-photo-from-viewer").data([0]);
63784           const buttonEnter = button.enter().append("button").attr("class", "set-photo-from-viewer").call(svgIcon("#iD-icon-plus")).call(
63785             uiTooltip().title(() => _t.append("inspector.set_photo_from_viewer.enable")).placement("right")
63786           );
63787           buttonEnter.select(".tooltip").classed("dark", true).style("width", "300px");
63788           return buttonEnter;
63789         }
63790         function buttonRemove() {
63791           const button = selection2.selectAll(".set-photo-from-viewer").data([0]);
63792           button.remove();
63793         }
63794         function buttonShowHide() {
63795           const activeImage = services.mapillary.getActiveImage();
63796           const graph = context.graph();
63797           const entities = context.selectedIDs().map((id2) => graph.entity(id2));
63798           if (entities.map((entity) => entity.tags.mapillary).every((value) => value === (activeImage == null ? void 0 : activeImage.id))) {
63799             buttonDisable("already_set");
63800           } else if (activeImage && entities.map((entity) => entity.extent(context.graph()).center()).every((loc) => geoSphericalDistance(loc, activeImage.loc) > 100)) {
63801             buttonDisable("too_far");
63802           } else {
63803             buttonDisable(false);
63804           }
63805         }
63806         function buttonDisable(reason) {
63807           const disabled = reason !== false;
63808           const button = selection2.selectAll(".set-photo-from-viewer").data([0]);
63809           button.attr("disabled", disabled ? "true" : null);
63810           button.classed("disabled", disabled);
63811           button.call(uiTooltip().destroyAny);
63812           if (disabled) {
63813             button.call(
63814               uiTooltip().title(() => _t.append("inspector.set_photo_from_viewer.disable.".concat(reason))).placement("right")
63815             );
63816           } else {
63817             button.call(
63818               uiTooltip().title(() => _t.append("inspector.set_photo_from_viewer.enable")).placement("right")
63819             );
63820           }
63821           button.select(".tooltip").classed("dark", true).style("width", "300px");
63822         }
63823       }
63824       function buildResizeListener(target, eventName, dispatch15, options2) {
63825         var resizeOnX = !!options2.resizeOnX;
63826         var resizeOnY = !!options2.resizeOnY;
63827         var minHeight = options2.minHeight || 240;
63828         var minWidth = options2.minWidth || 320;
63829         var pointerId;
63830         var startX;
63831         var startY;
63832         var startWidth;
63833         var startHeight;
63834         function startResize(d3_event) {
63835           if (pointerId !== (d3_event.pointerId || "mouse")) return;
63836           d3_event.preventDefault();
63837           d3_event.stopPropagation();
63838           var mapSize = context.map().dimensions();
63839           if (resizeOnX) {
63840             var mapWidth = mapSize[0];
63841             const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-left"), 10);
63842             var newWidth = clamp3(startWidth + d3_event.clientX - startX, minWidth, mapWidth - viewerMargin * 2);
63843             target.style("width", newWidth + "px");
63844           }
63845           if (resizeOnY) {
63846             const menuHeight = utilGetDimensions(select_default2(".top-toolbar"))[1] + utilGetDimensions(select_default2(".map-footer"))[1];
63847             const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-bottom"), 10);
63848             var maxHeight = mapSize[1] - menuHeight - viewerMargin * 2;
63849             var newHeight = clamp3(startHeight + startY - d3_event.clientY, minHeight, maxHeight);
63850             target.style("height", newHeight + "px");
63851           }
63852           dispatch15.call(eventName, target, subtractPadding(utilGetDimensions(target, true), target));
63853         }
63854         function clamp3(num, min3, max3) {
63855           return Math.max(min3, Math.min(num, max3));
63856         }
63857         function stopResize(d3_event) {
63858           if (pointerId !== (d3_event.pointerId || "mouse")) return;
63859           d3_event.preventDefault();
63860           d3_event.stopPropagation();
63861           select_default2(window).on("." + eventName, null);
63862         }
63863         return function initResize(d3_event) {
63864           d3_event.preventDefault();
63865           d3_event.stopPropagation();
63866           pointerId = d3_event.pointerId || "mouse";
63867           startX = d3_event.clientX;
63868           startY = d3_event.clientY;
63869           var targetRect = target.node().getBoundingClientRect();
63870           startWidth = targetRect.width;
63871           startHeight = targetRect.height;
63872           select_default2(window).on(_pointerPrefix + "move." + eventName, startResize, false).on(_pointerPrefix + "up." + eventName, stopResize, false);
63873           if (_pointerPrefix === "pointer") {
63874             select_default2(window).on("pointercancel." + eventName, stopResize, false);
63875           }
63876         };
63877       }
63878     }
63879     photoviewer.onMapResize = function() {
63880       var photoviewer2 = context.container().select(".photoviewer");
63881       var content = context.container().select(".main-content");
63882       var mapDimensions = utilGetDimensions(content, true);
63883       const menuHeight = utilGetDimensions(select_default2(".top-toolbar"))[1] + utilGetDimensions(select_default2(".map-footer"))[1];
63884       const viewerMargin = parseInt(select_default2(".photoviewer").style("margin-bottom"), 10);
63885       var photoDimensions = utilGetDimensions(photoviewer2, true);
63886       if (photoDimensions[0] > mapDimensions[0] || photoDimensions[1] > mapDimensions[1] - menuHeight - viewerMargin * 2) {
63887         var setPhotoDimensions = [
63888           Math.min(photoDimensions[0], mapDimensions[0]),
63889           Math.min(photoDimensions[1], mapDimensions[1] - menuHeight - viewerMargin * 2)
63890         ];
63891         photoviewer2.style("width", setPhotoDimensions[0] + "px").style("height", setPhotoDimensions[1] + "px");
63892         dispatch14.call("resize", photoviewer2, subtractPadding(setPhotoDimensions, photoviewer2));
63893       }
63894     };
63895     function subtractPadding(dimensions, selection2) {
63896       return [
63897         dimensions[0] - parseFloat(selection2.style("padding-left")) - parseFloat(selection2.style("padding-right")),
63898         dimensions[1] - parseFloat(selection2.style("padding-top")) - parseFloat(selection2.style("padding-bottom"))
63899       ];
63900     }
63901     return utilRebind(photoviewer, dispatch14, "on");
63902   }
63903
63904   // modules/ui/restore.js
63905   function uiRestore(context) {
63906     return function(selection2) {
63907       if (!context.history().hasRestorableChanges()) return;
63908       let modalSelection = uiModal(selection2, true);
63909       modalSelection.select(".modal").attr("class", "modal fillL");
63910       let introModal = modalSelection.select(".content");
63911       introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("restore.heading"));
63912       introModal.append("div").attr("class", "modal-section").append("p").call(_t.append("restore.description"));
63913       let buttonWrap = introModal.append("div").attr("class", "modal-actions");
63914       let restore = buttonWrap.append("button").attr("class", "restore").on("click", () => {
63915         context.history().restore();
63916         modalSelection.remove();
63917       });
63918       restore.append("svg").attr("class", "logo logo-restore").append("use").attr("xlink:href", "#iD-logo-restore");
63919       restore.append("div").call(_t.append("restore.restore"));
63920       let reset = buttonWrap.append("button").attr("class", "reset").on("click", () => {
63921         context.history().clearSaved();
63922         modalSelection.remove();
63923       });
63924       reset.append("svg").attr("class", "logo logo-reset").append("use").attr("xlink:href", "#iD-logo-reset");
63925       reset.append("div").call(_t.append("restore.reset"));
63926       restore.node().focus();
63927     };
63928   }
63929
63930   // modules/ui/scale.js
63931   function uiScale(context) {
63932     var projection2 = context.projection, isImperial = !_mainLocalizer.usesMetric(), maxLength = 180, tickHeight = 8;
63933     function scaleDefs(loc1, loc2) {
63934       var lat = (loc2[1] + loc1[1]) / 2, conversion = isImperial ? 3.28084 : 1, dist = geoLonToMeters(loc2[0] - loc1[0], lat) * conversion, scale = { dist: 0, px: 0, text: "" }, buckets, i3, val, dLon;
63935       if (isImperial) {
63936         buckets = [528e4, 528e3, 52800, 5280, 500, 50, 5, 1];
63937       } else {
63938         buckets = [5e6, 5e5, 5e4, 5e3, 500, 50, 5, 1];
63939       }
63940       for (i3 = 0; i3 < buckets.length; i3++) {
63941         val = buckets[i3];
63942         if (dist >= val) {
63943           scale.dist = Math.floor(dist / val) * val;
63944           break;
63945         } else {
63946           scale.dist = +dist.toFixed(2);
63947         }
63948       }
63949       dLon = geoMetersToLon(scale.dist / conversion, lat);
63950       scale.px = Math.round(projection2([loc1[0] + dLon, loc1[1]])[0]);
63951       scale.text = displayLength(scale.dist / conversion, isImperial);
63952       return scale;
63953     }
63954     function update(selection2) {
63955       var dims = context.map().dimensions(), loc1 = projection2.invert([0, dims[1]]), loc2 = projection2.invert([maxLength, dims[1]]), scale = scaleDefs(loc1, loc2);
63956       selection2.select(".scale-path").attr("d", "M0.5,0.5v" + tickHeight + "h" + scale.px + "v-" + tickHeight);
63957       selection2.select(".scale-text").style(_mainLocalizer.textDirection() === "ltr" ? "left" : "right", scale.px + 16 + "px").text(scale.text);
63958     }
63959     return function(selection2) {
63960       function switchUnits() {
63961         isImperial = !isImperial;
63962         selection2.call(update);
63963       }
63964       var scalegroup = selection2.append("svg").attr("class", "scale").on("click", switchUnits).append("g").attr("transform", "translate(10,11)");
63965       scalegroup.append("path").attr("class", "scale-path");
63966       selection2.append("div").attr("class", "scale-text");
63967       selection2.call(update);
63968       context.map().on("move.scale", function() {
63969         update(selection2);
63970       });
63971     };
63972   }
63973
63974   // modules/ui/shortcuts.js
63975   function uiShortcuts(context) {
63976     var detected = utilDetect();
63977     var _activeTab = 0;
63978     var _modalSelection;
63979     var _selection = select_default2(null);
63980     var _dataShortcuts;
63981     function shortcutsModal(_modalSelection2) {
63982       _modalSelection2.select(".modal").classed("modal-shortcuts", true);
63983       var content = _modalSelection2.select(".content");
63984       content.append("div").attr("class", "modal-section header").append("h2").call(_t.append("shortcuts.title"));
63985       _mainFileFetcher.get("shortcuts").then(function(data) {
63986         _dataShortcuts = data;
63987         content.call(render);
63988       }).catch(function() {
63989       });
63990     }
63991     function render(selection2) {
63992       if (!_dataShortcuts) return;
63993       var wrapper = selection2.selectAll(".wrapper").data([0]);
63994       var wrapperEnter = wrapper.enter().append("div").attr("class", "wrapper modal-section");
63995       var tabsBar = wrapperEnter.append("div").attr("class", "tabs-bar");
63996       var shortcutsList = wrapperEnter.append("div").attr("class", "shortcuts-list");
63997       wrapper = wrapper.merge(wrapperEnter);
63998       var tabs = tabsBar.selectAll(".tab").data(_dataShortcuts);
63999       var tabsEnter = tabs.enter().append("a").attr("class", "tab").attr("href", "#").on("click", function(d3_event, d2) {
64000         d3_event.preventDefault();
64001         var i3 = _dataShortcuts.indexOf(d2);
64002         _activeTab = i3;
64003         render(selection2);
64004       });
64005       tabsEnter.append("span").html(function(d2) {
64006         return _t.html(d2.text);
64007       });
64008       wrapper.selectAll(".tab").classed("active", function(d2, i3) {
64009         return i3 === _activeTab;
64010       });
64011       var shortcuts = shortcutsList.selectAll(".shortcut-tab").data(_dataShortcuts);
64012       var shortcutsEnter = shortcuts.enter().append("div").attr("class", function(d2) {
64013         return "shortcut-tab shortcut-tab-" + d2.tab;
64014       });
64015       var columnsEnter = shortcutsEnter.selectAll(".shortcut-column").data(function(d2) {
64016         return d2.columns;
64017       }).enter().append("table").attr("class", "shortcut-column");
64018       var rowsEnter = columnsEnter.selectAll(".shortcut-row").data(function(d2) {
64019         return d2.rows;
64020       }).enter().append("tr").attr("class", "shortcut-row");
64021       var sectionRows = rowsEnter.filter(function(d2) {
64022         return !d2.shortcuts;
64023       });
64024       sectionRows.append("td");
64025       sectionRows.append("td").attr("class", "shortcut-section").append("h3").html(function(d2) {
64026         return _t.html(d2.text);
64027       });
64028       var shortcutRows = rowsEnter.filter(function(d2) {
64029         return d2.shortcuts;
64030       });
64031       var shortcutKeys = shortcutRows.append("td").attr("class", "shortcut-keys");
64032       var modifierKeys = shortcutKeys.filter(function(d2) {
64033         return d2.modifiers;
64034       });
64035       modifierKeys.selectAll("kbd.modifier").data(function(d2) {
64036         if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") {
64037           return ["\u2318"];
64038         } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") {
64039           return [];
64040         } else {
64041           return d2.modifiers;
64042         }
64043       }).enter().each(function() {
64044         var selection3 = select_default2(this);
64045         selection3.append("kbd").attr("class", "modifier").text(function(d2) {
64046           return uiCmd.display(d2);
64047         });
64048         selection3.append("span").text("+");
64049       });
64050       shortcutKeys.selectAll("kbd.shortcut").data(function(d2) {
64051         var arr = d2.shortcuts;
64052         if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") {
64053           arr = ["Y"];
64054         } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") {
64055           arr = ["F11"];
64056         }
64057         arr = arr.map(function(s2) {
64058           return uiCmd.display(s2.indexOf(".") !== -1 ? _t(s2) : s2);
64059         });
64060         return utilArrayUniq(arr).map(function(s2) {
64061           return {
64062             shortcut: s2,
64063             separator: d2.separator,
64064             suffix: d2.suffix
64065           };
64066         });
64067       }).enter().each(function(d2, i3, nodes) {
64068         var selection3 = select_default2(this);
64069         var click = d2.shortcut.toLowerCase().match(/(.*).click/);
64070         if (click && click[1]) {
64071           selection3.call(svgIcon("#iD-walkthrough-mouse-" + click[1], "operation"));
64072         } else if (d2.shortcut.toLowerCase() === "long-press") {
64073           selection3.call(svgIcon("#iD-walkthrough-longpress", "longpress operation"));
64074         } else if (d2.shortcut.toLowerCase() === "tap") {
64075           selection3.call(svgIcon("#iD-walkthrough-tap", "tap operation"));
64076         } else {
64077           selection3.append("kbd").attr("class", "shortcut").text(function(d4) {
64078             return d4.shortcut;
64079           });
64080         }
64081         if (i3 < nodes.length - 1) {
64082           selection3.append("span").html(d2.separator || "\xA0" + _t.html("shortcuts.or") + "\xA0");
64083         } else if (i3 === nodes.length - 1 && d2.suffix) {
64084           selection3.append("span").text(d2.suffix);
64085         }
64086       });
64087       shortcutKeys.filter(function(d2) {
64088         return d2.gesture;
64089       }).each(function() {
64090         var selection3 = select_default2(this);
64091         selection3.append("span").text("+");
64092         selection3.append("span").attr("class", "gesture").html(function(d2) {
64093           return _t.html(d2.gesture);
64094         });
64095       });
64096       shortcutRows.append("td").attr("class", "shortcut-desc").html(function(d2) {
64097         return d2.text ? _t.html(d2.text) : "\xA0";
64098       });
64099       wrapper.selectAll(".shortcut-tab").style("display", function(d2, i3) {
64100         return i3 === _activeTab ? "flex" : "none";
64101       });
64102     }
64103     return function(selection2, show) {
64104       _selection = selection2;
64105       if (show) {
64106         _modalSelection = uiModal(selection2);
64107         _modalSelection.call(shortcutsModal);
64108       } else {
64109         context.keybinding().on([_t("shortcuts.toggle.key"), "?"], function() {
64110           if (context.container().selectAll(".modal-shortcuts").size()) {
64111             if (_modalSelection) {
64112               _modalSelection.close();
64113               _modalSelection = null;
64114             }
64115           } else {
64116             _modalSelection = uiModal(_selection);
64117             _modalSelection.call(shortcutsModal);
64118           }
64119         });
64120       }
64121     };
64122   }
64123
64124   // modules/ui/data_header.js
64125   function uiDataHeader() {
64126     var _datum;
64127     function dataHeader(selection2) {
64128       var header = selection2.selectAll(".data-header").data(
64129         _datum ? [_datum] : [],
64130         function(d2) {
64131           return d2.__featurehash__;
64132         }
64133       );
64134       header.exit().remove();
64135       var headerEnter = header.enter().append("div").attr("class", "data-header");
64136       var iconEnter = headerEnter.append("div").attr("class", "data-header-icon");
64137       iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-data", "note-fill"));
64138       headerEnter.append("div").attr("class", "data-header-label").call(_t.append("map_data.layers.custom.title"));
64139     }
64140     dataHeader.datum = function(val) {
64141       if (!arguments.length) return _datum;
64142       _datum = val;
64143       return this;
64144     };
64145     return dataHeader;
64146   }
64147
64148   // modules/ui/disclosure.js
64149   function uiDisclosure(context, key, expandedDefault) {
64150     var dispatch14 = dispatch_default("toggled");
64151     var _expanded;
64152     var _label = utilFunctor("");
64153     var _updatePreference = true;
64154     var _content = function() {
64155     };
64156     var disclosure = function(selection2) {
64157       if (_expanded === void 0 || _expanded === null) {
64158         var preference = corePreferences("disclosure." + key + ".expanded");
64159         _expanded = preference === null ? !!expandedDefault : preference === "true";
64160       }
64161       var hideToggle = selection2.selectAll(".hide-toggle-" + key).data([0]);
64162       var hideToggleEnter = hideToggle.enter().append("h3").append("a").attr("role", "button").attr("href", "#").attr("class", "hide-toggle hide-toggle-" + key).call(svgIcon("", "pre-text", "hide-toggle-icon"));
64163       hideToggleEnter.append("span").attr("class", "hide-toggle-text");
64164       hideToggle = hideToggleEnter.merge(hideToggle);
64165       hideToggle.on("click", toggle).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand"))).attr("aria-expanded", _expanded).classed("expanded", _expanded);
64166       const label = _label();
64167       const labelSelection = hideToggle.selectAll(".hide-toggle-text");
64168       if (typeof label !== "function") {
64169         labelSelection.text(_label());
64170       } else {
64171         labelSelection.text("").call(label);
64172       }
64173       hideToggle.selectAll(".hide-toggle-icon").attr(
64174         "xlink:href",
64175         _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward"
64176       );
64177       var wrap2 = selection2.selectAll(".disclosure-wrap").data([0]);
64178       wrap2 = wrap2.enter().append("div").attr("class", "disclosure-wrap disclosure-wrap-" + key).merge(wrap2).classed("hide", !_expanded);
64179       if (_expanded) {
64180         wrap2.call(_content);
64181       }
64182       function toggle(d3_event) {
64183         d3_event.preventDefault();
64184         _expanded = !_expanded;
64185         if (_updatePreference) {
64186           corePreferences("disclosure." + key + ".expanded", _expanded);
64187         }
64188         hideToggle.classed("expanded", _expanded).attr("aria-expanded", _expanded).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand")));
64189         hideToggle.selectAll(".hide-toggle-icon").attr(
64190           "xlink:href",
64191           _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward"
64192         );
64193         wrap2.call(uiToggle(_expanded));
64194         if (_expanded) {
64195           wrap2.call(_content);
64196         }
64197         dispatch14.call("toggled", this, _expanded);
64198       }
64199     };
64200     disclosure.label = function(val) {
64201       if (!arguments.length) return _label;
64202       _label = utilFunctor(val);
64203       return disclosure;
64204     };
64205     disclosure.expanded = function(val) {
64206       if (!arguments.length) return _expanded;
64207       _expanded = val;
64208       return disclosure;
64209     };
64210     disclosure.updatePreference = function(val) {
64211       if (!arguments.length) return _updatePreference;
64212       _updatePreference = val;
64213       return disclosure;
64214     };
64215     disclosure.content = function(val) {
64216       if (!arguments.length) return _content;
64217       _content = val;
64218       return disclosure;
64219     };
64220     return utilRebind(disclosure, dispatch14, "on");
64221   }
64222
64223   // modules/ui/section.js
64224   function uiSection(id2, context) {
64225     var _classes = utilFunctor("");
64226     var _shouldDisplay;
64227     var _content;
64228     var _disclosure;
64229     var _label;
64230     var _expandedByDefault = utilFunctor(true);
64231     var _disclosureContent;
64232     var _disclosureExpanded;
64233     var _containerSelection = select_default2(null);
64234     var section = {
64235       id: id2
64236     };
64237     section.classes = function(val) {
64238       if (!arguments.length) return _classes;
64239       _classes = utilFunctor(val);
64240       return section;
64241     };
64242     section.label = function(val) {
64243       if (!arguments.length) return _label;
64244       _label = utilFunctor(val);
64245       return section;
64246     };
64247     section.expandedByDefault = function(val) {
64248       if (!arguments.length) return _expandedByDefault;
64249       _expandedByDefault = utilFunctor(val);
64250       return section;
64251     };
64252     section.shouldDisplay = function(val) {
64253       if (!arguments.length) return _shouldDisplay;
64254       _shouldDisplay = utilFunctor(val);
64255       return section;
64256     };
64257     section.content = function(val) {
64258       if (!arguments.length) return _content;
64259       _content = val;
64260       return section;
64261     };
64262     section.disclosureContent = function(val) {
64263       if (!arguments.length) return _disclosureContent;
64264       _disclosureContent = val;
64265       return section;
64266     };
64267     section.disclosureExpanded = function(val) {
64268       if (!arguments.length) return _disclosureExpanded;
64269       _disclosureExpanded = val;
64270       return section;
64271     };
64272     section.render = function(selection2) {
64273       _containerSelection = selection2.selectAll(".section-" + id2).data([0]);
64274       var sectionEnter = _containerSelection.enter().append("div").attr("class", "section section-" + id2 + " " + (_classes && _classes() || ""));
64275       _containerSelection = sectionEnter.merge(_containerSelection);
64276       _containerSelection.call(renderContent);
64277     };
64278     section.reRender = function() {
64279       _containerSelection.call(renderContent);
64280     };
64281     section.selection = function() {
64282       return _containerSelection;
64283     };
64284     section.disclosure = function() {
64285       return _disclosure;
64286     };
64287     function renderContent(selection2) {
64288       if (_shouldDisplay) {
64289         var shouldDisplay = _shouldDisplay();
64290         selection2.classed("hide", !shouldDisplay);
64291         if (!shouldDisplay) {
64292           selection2.html("");
64293           return;
64294         }
64295       }
64296       if (_disclosureContent) {
64297         if (!_disclosure) {
64298           _disclosure = uiDisclosure(context, id2.replace(/-/g, "_"), _expandedByDefault()).label(_label || "").content(_disclosureContent);
64299         }
64300         if (_disclosureExpanded !== void 0) {
64301           _disclosure.expanded(_disclosureExpanded);
64302           _disclosureExpanded = void 0;
64303         }
64304         selection2.call(_disclosure);
64305         return;
64306       }
64307       if (_content) {
64308         selection2.call(_content);
64309       }
64310     }
64311     return section;
64312   }
64313
64314   // modules/ui/tag_reference.js
64315   function uiTagReference(what) {
64316     var wikibase = what.qid ? services.wikidata : services.osmWikibase;
64317     var tagReference = {};
64318     var _button = select_default2(null);
64319     var _body = select_default2(null);
64320     var _loaded;
64321     var _showing;
64322     function load() {
64323       if (!wikibase) return;
64324       _button.classed("tag-reference-loading", true);
64325       wikibase.getDocs(what, gotDocs);
64326     }
64327     function gotDocs(err, docs) {
64328       _body.html("");
64329       if (!docs || !docs.title) {
64330         _body.append("p").attr("class", "tag-reference-description").call(_t.append("inspector.no_documentation_key"));
64331         done();
64332         return;
64333       }
64334       if (docs.imageURL) {
64335         _body.append("img").attr("class", "tag-reference-wiki-image").attr("alt", docs.description).attr("src", docs.imageURL).on("load", function() {
64336           done();
64337         }).on("error", function() {
64338           select_default2(this).remove();
64339           done();
64340         });
64341       } else {
64342         done();
64343       }
64344       var tagReferenceDescription = _body.append("p").attr("class", "tag-reference-description").append("span");
64345       if (docs.description) {
64346         tagReferenceDescription = tagReferenceDescription.attr("class", "localized-text").attr("lang", docs.descriptionLocaleCode || "und").text(docs.description);
64347       } else {
64348         tagReferenceDescription = tagReferenceDescription.call(_t.append("inspector.no_documentation_key"));
64349       }
64350       tagReferenceDescription.append("a").attr("class", "tag-reference-edit").attr("target", "_blank").attr("title", _t("inspector.edit_reference")).attr("href", docs.editURL).call(svgIcon("#iD-icon-edit", "inline"));
64351       if (docs.wiki) {
64352         _body.append("a").attr("class", "tag-reference-link").attr("target", "_blank").attr("href", docs.wiki.url).call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append(docs.wiki.text));
64353       }
64354       if (what.key === "comment") {
64355         _body.append("a").attr("class", "tag-reference-comment-link").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", _t("commit.about_changeset_comments_link")).append("span").call(_t.append("commit.about_changeset_comments"));
64356       }
64357     }
64358     function done() {
64359       _loaded = true;
64360       _button.classed("tag-reference-loading", false);
64361       _body.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1");
64362       _showing = true;
64363       _button.selectAll("svg.icon use").each(function() {
64364         var iconUse = select_default2(this);
64365         if (iconUse.attr("href") === "#iD-icon-info") {
64366           iconUse.attr("href", "#iD-icon-info-filled");
64367         }
64368       });
64369     }
64370     function hide() {
64371       _body.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() {
64372         _body.classed("expanded", false);
64373       });
64374       _showing = false;
64375       _button.selectAll("svg.icon use").each(function() {
64376         var iconUse = select_default2(this);
64377         if (iconUse.attr("href") === "#iD-icon-info-filled") {
64378           iconUse.attr("href", "#iD-icon-info");
64379         }
64380       });
64381     }
64382     tagReference.button = function(selection2, klass, iconName) {
64383       _button = selection2.selectAll(".tag-reference-button").data([0]);
64384       _button = _button.enter().append("button").attr("class", "tag-reference-button " + (klass || "")).attr("title", _t("icons.information")).call(svgIcon("#iD-icon-" + (iconName || "inspect"))).merge(_button);
64385       _button.on("click", function(d3_event) {
64386         d3_event.stopPropagation();
64387         d3_event.preventDefault();
64388         this.blur();
64389         if (_showing) {
64390           hide();
64391         } else if (_loaded) {
64392           done();
64393         } else {
64394           load();
64395         }
64396       });
64397     };
64398     tagReference.body = function(selection2) {
64399       var itemID = what.qid || what.key + "-" + (what.value || "");
64400       _body = selection2.selectAll(".tag-reference-body").data([itemID], function(d2) {
64401         return d2;
64402       });
64403       _body.exit().remove();
64404       _body = _body.enter().append("div").attr("class", "tag-reference-body").style("max-height", "0").style("opacity", "0").merge(_body);
64405       if (_showing === false) {
64406         hide();
64407       }
64408     };
64409     tagReference.showing = function(val) {
64410       if (!arguments.length) return _showing;
64411       _showing = val;
64412       return tagReference;
64413     };
64414     return tagReference;
64415   }
64416
64417   // modules/ui/sections/raw_tag_editor.js
64418   function uiSectionRawTagEditor(id2, context) {
64419     var section = uiSection(id2, context).classes("raw-tag-editor").label(function() {
64420       var count = Object.keys(_tags).filter(function(d2) {
64421         return d2;
64422       }).length;
64423       return _t.append("inspector.title_count", { title: _t("inspector.tags"), count });
64424     }).expandedByDefault(false).disclosureContent(renderDisclosureContent);
64425     var taginfo = services.taginfo;
64426     var dispatch14 = dispatch_default("change");
64427     var availableViews = [
64428       { id: "list", icon: "#fas-th-list" },
64429       { id: "text", icon: "#fas-i-cursor" }
64430     ];
64431     let _discardTags = {};
64432     _mainFileFetcher.get("discarded").then((d2) => {
64433       _discardTags = d2;
64434     }).catch(() => {
64435     });
64436     var _tagView = corePreferences("raw-tag-editor-view") || "list";
64437     var _readOnlyTags = [];
64438     var _orderedKeys = [];
64439     var _showBlank = false;
64440     var _pendingChange = null;
64441     var _state;
64442     var _presets;
64443     var _tags;
64444     var _entityIDs;
64445     var _didInteract = false;
64446     function interacted() {
64447       _didInteract = true;
64448     }
64449     function renderDisclosureContent(wrap2) {
64450       _orderedKeys = _orderedKeys.filter(function(key) {
64451         return _tags[key] !== void 0;
64452       });
64453       var all = Object.keys(_tags).sort();
64454       var missingKeys = utilArrayDifference(all, _orderedKeys);
64455       for (var i3 in missingKeys) {
64456         _orderedKeys.push(missingKeys[i3]);
64457       }
64458       var rowData = _orderedKeys.map(function(key, i4) {
64459         return { index: i4, key, value: _tags[key] };
64460       });
64461       if (!rowData.length || _showBlank) {
64462         _showBlank = false;
64463         rowData.push({ index: rowData.length, key: "", value: "" });
64464       }
64465       var options2 = wrap2.selectAll(".raw-tag-options").data([0]);
64466       options2.exit().remove();
64467       var optionsEnter = options2.enter().insert("div", ":first-child").attr("class", "raw-tag-options").attr("role", "tablist");
64468       var optionEnter = optionsEnter.selectAll(".raw-tag-option").data(availableViews, function(d2) {
64469         return d2.id;
64470       }).enter();
64471       optionEnter.append("button").attr("class", function(d2) {
64472         return "raw-tag-option raw-tag-option-" + d2.id + (_tagView === d2.id ? " selected" : "");
64473       }).attr("aria-selected", function(d2) {
64474         return _tagView === d2.id;
64475       }).attr("role", "tab").attr("title", function(d2) {
64476         return _t("icons." + d2.id);
64477       }).on("click", function(d3_event, d2) {
64478         _tagView = d2.id;
64479         corePreferences("raw-tag-editor-view", d2.id);
64480         wrap2.selectAll(".raw-tag-option").classed("selected", function(datum2) {
64481           return datum2 === d2;
64482         }).attr("aria-selected", function(datum2) {
64483           return datum2 === d2;
64484         });
64485         wrap2.selectAll(".tag-text").classed("hide", d2.id !== "text").each(setTextareaHeight);
64486         wrap2.selectAll(".tag-list, .add-row").classed("hide", d2.id !== "list");
64487       }).each(function(d2) {
64488         select_default2(this).call(svgIcon(d2.icon));
64489       });
64490       var textData = rowsToText(rowData);
64491       var textarea = wrap2.selectAll(".tag-text").data([0]);
64492       textarea = textarea.enter().append("textarea").attr("class", "tag-text" + (_tagView !== "text" ? " hide" : "")).call(utilNoAuto).attr("placeholder", _t("inspector.key_value")).attr("spellcheck", "false").merge(textarea);
64493       textarea.call(utilGetSetValue, textData).each(setTextareaHeight).on("input", setTextareaHeight).on("focus", interacted).on("blur", textChanged).on("change", textChanged);
64494       var list2 = wrap2.selectAll(".tag-list").data([0]);
64495       list2 = list2.enter().append("ul").attr("class", "tag-list" + (_tagView !== "list" ? " hide" : "")).merge(list2);
64496       var addRowEnter = wrap2.selectAll(".add-row").data([0]).enter().append("div").attr("class", "add-row" + (_tagView !== "list" ? " hide" : ""));
64497       addRowEnter.append("button").attr("class", "add-tag").attr("aria-label", _t("inspector.add_to_tag")).call(svgIcon("#iD-icon-plus", "light")).call(uiTooltip().title(() => _t.append("inspector.add_to_tag")).placement(_mainLocalizer.textDirection() === "ltr" ? "right" : "left")).on("click", addTag);
64498       addRowEnter.append("div").attr("class", "space-value");
64499       addRowEnter.append("div").attr("class", "space-buttons");
64500       var items = list2.selectAll(".tag-row").data(rowData, function(d2) {
64501         return d2.key;
64502       });
64503       items.exit().each(unbind).remove();
64504       var itemsEnter = items.enter().append("li").attr("class", "tag-row").classed("readonly", isReadOnly);
64505       var innerWrap = itemsEnter.append("div").attr("class", "inner-wrap");
64506       innerWrap.append("div").attr("class", "key-wrap").append("input").property("type", "text").attr("class", "key").call(utilNoAuto).on("focus", interacted).on("blur", keyChange).on("change", keyChange);
64507       innerWrap.append("div").attr("class", "value-wrap").append("input").property("type", "text").attr("class", "value").call(utilNoAuto).on("focus", interacted).on("blur", valueChange).on("change", valueChange).on("keydown.push-more", pushMore);
64508       innerWrap.append("button").attr("class", "form-field-button remove").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
64509       items = items.merge(itemsEnter).sort(function(a2, b2) {
64510         return a2.index - b2.index;
64511       });
64512       items.each(function(d2) {
64513         var row = select_default2(this);
64514         var key = row.select("input.key");
64515         var value = row.select("input.value");
64516         if (_entityIDs && taginfo && _state !== "hover") {
64517           bindTypeahead(key, value);
64518         }
64519         var referenceOptions = { key: d2.key };
64520         if (typeof d2.value === "string") {
64521           referenceOptions.value = d2.value;
64522         }
64523         var reference = uiTagReference(referenceOptions, context);
64524         if (_state === "hover") {
64525           reference.showing(false);
64526         }
64527         row.select(".inner-wrap").call(reference.button);
64528         row.call(reference.body);
64529         row.select("button.remove");
64530       });
64531       items.selectAll("input.key").attr("title", function(d2) {
64532         return d2.key;
64533       }).call(utilGetSetValue, function(d2) {
64534         return d2.key;
64535       }).attr("readonly", function(d2) {
64536         return isReadOnly(d2) || null;
64537       });
64538       items.selectAll("input.value").attr("title", function(d2) {
64539         return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : d2.value;
64540       }).classed("mixed", function(d2) {
64541         return Array.isArray(d2.value);
64542       }).attr("placeholder", function(d2) {
64543         return typeof d2.value === "string" ? null : _t("inspector.multiple_values");
64544       }).call(utilGetSetValue, function(d2) {
64545         return typeof d2.value === "string" ? d2.value : "";
64546       }).attr("readonly", function(d2) {
64547         return isReadOnly(d2) || null;
64548       });
64549       items.selectAll("button.remove").on(
64550         ("PointerEvent" in window ? "pointer" : "mouse") + "down",
64551         // 'click' fires too late - #5878
64552         (d3_event, d2) => {
64553           if (d3_event.button !== 0) return;
64554           removeTag(d3_event, d2);
64555         }
64556       );
64557     }
64558     function isReadOnly(d2) {
64559       for (var i3 = 0; i3 < _readOnlyTags.length; i3++) {
64560         if (d2.key.match(_readOnlyTags[i3]) !== null) {
64561           return true;
64562         }
64563       }
64564       return false;
64565     }
64566     function setTextareaHeight() {
64567       if (_tagView !== "text") return;
64568       var selection2 = select_default2(this);
64569       var matches = selection2.node().value.match(/\n/g);
64570       var lineCount = 2 + Number(matches && matches.length);
64571       var lineHeight = 20;
64572       selection2.style("height", lineCount * lineHeight + "px");
64573     }
64574     function stringify3(s2) {
64575       const stringified = JSON.stringify(s2).slice(1, -1);
64576       if (stringified !== s2) {
64577         return '"'.concat(stringified, '"');
64578       } else {
64579         return s2;
64580       }
64581     }
64582     function unstringify(s2) {
64583       const isQuoted = s2.length > 1 && s2.charAt(0) === '"' && s2.charAt(s2.length - 1) === '"';
64584       if (isQuoted) {
64585         try {
64586           return JSON.parse(s2);
64587         } catch (e3) {
64588           return s2;
64589         }
64590       } else {
64591         return s2;
64592       }
64593     }
64594     function rowsToText(rows) {
64595       var str = rows.filter(function(row) {
64596         return row.key && row.key.trim() !== "";
64597       }).map(function(row) {
64598         var rawVal = row.value;
64599         if (typeof rawVal !== "string") rawVal = "*";
64600         var val = rawVal ? stringify3(rawVal) : "";
64601         return stringify3(row.key) + "=" + val;
64602       }).join("\n");
64603       if (_state !== "hover" && str.length) {
64604         return str + "\n";
64605       }
64606       return str;
64607     }
64608     function textChanged() {
64609       var newText = this.value.trim();
64610       var newTags = {};
64611       newText.split("\n").forEach(function(row) {
64612         var m2 = row.match(/^\s*([^=]+)=(.*)$/);
64613         if (m2 !== null) {
64614           var k2 = context.cleanTagKey(unstringify(m2[1].trim()));
64615           var v2 = context.cleanTagValue(unstringify(m2[2].trim()));
64616           newTags[k2] = v2;
64617         }
64618       });
64619       var tagDiff = utilTagDiff(_tags, newTags);
64620       _pendingChange = _pendingChange || {};
64621       tagDiff.forEach(function(change) {
64622         if (isReadOnly({ key: change.key })) return;
64623         if (change.newVal === "*" && typeof change.oldVal !== "string") return;
64624         if (change.type === "-") {
64625           _pendingChange[change.key] = void 0;
64626         } else if (change.type === "+") {
64627           _pendingChange[change.key] = change.newVal || "";
64628         }
64629       });
64630       if (Object.keys(_pendingChange).length === 0) {
64631         _pendingChange = null;
64632         section.reRender();
64633         return;
64634       }
64635       scheduleChange();
64636     }
64637     function pushMore(d3_event) {
64638       if (d3_event.keyCode === 9 && !d3_event.shiftKey && section.selection().selectAll(".tag-list li:last-child input.value").node() === this && utilGetSetValue(select_default2(this))) {
64639         addTag();
64640       }
64641     }
64642     function bindTypeahead(key, value) {
64643       if (isReadOnly(key.datum())) return;
64644       if (Array.isArray(value.datum().value)) {
64645         value.call(uiCombobox(context, "tag-value").minItems(1).fetcher(function(value2, callback) {
64646           var keyString = utilGetSetValue(key);
64647           if (!_tags[keyString]) return;
64648           var data = _tags[keyString].map(function(tagValue) {
64649             if (!tagValue) {
64650               return {
64651                 value: " ",
64652                 title: _t("inspector.empty"),
64653                 display: (selection2) => selection2.text("").classed("virtual-option", true).call(_t.append("inspector.empty"))
64654               };
64655             }
64656             return {
64657               value: tagValue,
64658               title: tagValue
64659             };
64660           });
64661           callback(data);
64662         }));
64663         return;
64664       }
64665       var geometry = context.graph().geometry(_entityIDs[0]);
64666       key.call(uiCombobox(context, "tag-key").fetcher(function(value2, callback) {
64667         taginfo.keys({
64668           debounce: true,
64669           geometry,
64670           query: value2
64671         }, function(err, data) {
64672           if (!err) {
64673             const filtered = data.filter((d2) => _tags[d2.value] === void 0).filter((d2) => !(d2.value in _discardTags)).filter((d2) => !/_\d$/.test(d2)).filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase()));
64674             callback(sort(value2, filtered));
64675           }
64676         });
64677       }));
64678       value.call(uiCombobox(context, "tag-value").fetcher(function(value2, callback) {
64679         taginfo.values({
64680           debounce: true,
64681           key: utilGetSetValue(key),
64682           geometry,
64683           query: value2
64684         }, function(err, data) {
64685           if (!err) {
64686             const filtered = data.filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase()));
64687             callback(sort(value2, filtered));
64688           }
64689         });
64690       }).caseSensitive(allowUpperCaseTagValues.test(utilGetSetValue(key))));
64691       function sort(value2, data) {
64692         var sameletter = [];
64693         var other2 = [];
64694         for (var i3 = 0; i3 < data.length; i3++) {
64695           if (data[i3].value.substring(0, value2.length) === value2) {
64696             sameletter.push(data[i3]);
64697           } else {
64698             other2.push(data[i3]);
64699           }
64700         }
64701         return sameletter.concat(other2);
64702       }
64703     }
64704     function unbind() {
64705       var row = select_default2(this);
64706       row.selectAll("input.key").call(uiCombobox.off, context);
64707       row.selectAll("input.value").call(uiCombobox.off, context);
64708     }
64709     function keyChange(d3_event, d2) {
64710       if (select_default2(this).attr("readonly")) return;
64711       var kOld = d2.key;
64712       if (_pendingChange && _pendingChange.hasOwnProperty(kOld) && _pendingChange[kOld] === void 0) return;
64713       var kNew = context.cleanTagKey(this.value.trim());
64714       if (isReadOnly({ key: kNew })) {
64715         this.value = kOld;
64716         return;
64717       }
64718       if (kNew && kNew !== kOld && _tags[kNew] !== void 0) {
64719         this.value = kOld;
64720         section.selection().selectAll(".tag-list input.value").each(function(d4) {
64721           if (d4.key === kNew) {
64722             var input = select_default2(this).node();
64723             input.focus();
64724             input.select();
64725           }
64726         });
64727         return;
64728       }
64729       _pendingChange = _pendingChange || {};
64730       if (kOld) {
64731         if (kOld === kNew) return;
64732         _pendingChange[kNew] = _pendingChange[kOld] || { oldKey: kOld };
64733         _pendingChange[kOld] = void 0;
64734       } else {
64735         let row = this.parentNode.parentNode;
64736         let inputVal = select_default2(row).selectAll("input.value");
64737         let vNew = context.cleanTagValue(utilGetSetValue(inputVal));
64738         _pendingChange[kNew] = vNew;
64739         utilGetSetValue(inputVal, vNew);
64740       }
64741       var existingKeyIndex = _orderedKeys.indexOf(kOld);
64742       if (existingKeyIndex !== -1) _orderedKeys[existingKeyIndex] = kNew;
64743       d2.key = kNew;
64744       this.value = kNew;
64745       scheduleChange();
64746     }
64747     function valueChange(d3_event, d2) {
64748       if (isReadOnly(d2)) return;
64749       if (typeof d2.value !== "string" && !this.value) return;
64750       if (_pendingChange && _pendingChange.hasOwnProperty(d2.key) && _pendingChange[d2.key] === void 0) return;
64751       _pendingChange = _pendingChange || {};
64752       _pendingChange[d2.key] = context.cleanTagValue(this.value);
64753       scheduleChange();
64754     }
64755     function removeTag(d3_event, d2) {
64756       if (isReadOnly(d2)) return;
64757       if (d2.key === "") {
64758         _showBlank = false;
64759         section.reRender();
64760       } else {
64761         _orderedKeys = _orderedKeys.filter(function(key) {
64762           return key !== d2.key;
64763         });
64764         _pendingChange = _pendingChange || {};
64765         _pendingChange[d2.key] = void 0;
64766         scheduleChange();
64767       }
64768     }
64769     function addTag() {
64770       window.setTimeout(function() {
64771         _showBlank = true;
64772         section.reRender();
64773         section.selection().selectAll(".tag-list li:last-child input.key").node().focus();
64774       }, 20);
64775     }
64776     function scheduleChange() {
64777       var entityIDs = _entityIDs;
64778       window.setTimeout(function() {
64779         if (!_pendingChange) return;
64780         dispatch14.call("change", this, entityIDs, _pendingChange);
64781         _pendingChange = null;
64782       }, 10);
64783     }
64784     section.state = function(val) {
64785       if (!arguments.length) return _state;
64786       if (_state !== val) {
64787         _orderedKeys = [];
64788         _state = val;
64789       }
64790       return section;
64791     };
64792     section.presets = function(val) {
64793       if (!arguments.length) return _presets;
64794       _presets = val;
64795       if (_presets && _presets.length && _presets[0].isFallback()) {
64796         section.disclosureExpanded(true);
64797       } else if (!_didInteract) {
64798         section.disclosureExpanded(null);
64799       }
64800       return section;
64801     };
64802     section.tags = function(val) {
64803       if (!arguments.length) return _tags;
64804       _tags = val;
64805       return section;
64806     };
64807     section.entityIDs = function(val) {
64808       if (!arguments.length) return _entityIDs;
64809       if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) {
64810         _entityIDs = val;
64811         _orderedKeys = [];
64812       }
64813       return section;
64814     };
64815     section.readOnlyTags = function(val) {
64816       if (!arguments.length) return _readOnlyTags;
64817       _readOnlyTags = val;
64818       return section;
64819     };
64820     return utilRebind(section, dispatch14, "on");
64821   }
64822
64823   // modules/ui/data_editor.js
64824   function uiDataEditor(context) {
64825     var dataHeader = uiDataHeader();
64826     var rawTagEditor = uiSectionRawTagEditor("custom-data-tag-editor", context).expandedByDefault(true).readOnlyTags([/./]);
64827     var _datum;
64828     function dataEditor(selection2) {
64829       var header = selection2.selectAll(".header").data([0]);
64830       var headerEnter = header.enter().append("div").attr("class", "header fillL");
64831       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
64832         context.enter(modeBrowse(context));
64833       }).call(svgIcon("#iD-icon-close"));
64834       headerEnter.append("h2").call(_t.append("map_data.title"));
64835       var body = selection2.selectAll(".body").data([0]);
64836       body = body.enter().append("div").attr("class", "body").merge(body);
64837       var editor = body.selectAll(".data-editor").data([0]);
64838       editor.enter().append("div").attr("class", "modal-section data-editor").merge(editor).call(dataHeader.datum(_datum));
64839       var rte = body.selectAll(".raw-tag-editor").data([0]);
64840       rte.enter().append("div").attr("class", "raw-tag-editor data-editor").merge(rte).call(
64841         rawTagEditor.tags(_datum && _datum.properties || {}).state("hover").render
64842       ).selectAll("textarea.tag-text").attr("readonly", true).classed("readonly", true);
64843     }
64844     dataEditor.datum = function(val) {
64845       if (!arguments.length) return _datum;
64846       _datum = val;
64847       return this;
64848     };
64849     return dataEditor;
64850   }
64851
64852   // modules/ui/feature_list.js
64853   var sexagesimal = __toESM(require_sexagesimal());
64854   function uiFeatureList(context) {
64855     var _geocodeResults;
64856     function featureList(selection2) {
64857       var header = selection2.append("div").attr("class", "header fillL");
64858       header.append("h2").call(_t.append("inspector.feature_list"));
64859       var searchWrap = selection2.append("div").attr("class", "search-header");
64860       searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
64861       var search = searchWrap.append("input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keypress", keypress).on("keydown", keydown).on("input", inputevent);
64862       var listWrap = selection2.append("div").attr("class", "inspector-body");
64863       var list2 = listWrap.append("div").attr("class", "feature-list");
64864       context.on("exit.feature-list", clearSearch);
64865       context.map().on("drawn.feature-list", mapDrawn);
64866       context.keybinding().on(uiCmd("\u2318F"), focusSearch);
64867       function focusSearch(d3_event) {
64868         var mode = context.mode() && context.mode().id;
64869         if (mode !== "browse") return;
64870         d3_event.preventDefault();
64871         search.node().focus();
64872       }
64873       function keydown(d3_event) {
64874         if (d3_event.keyCode === 27) {
64875           search.node().blur();
64876         }
64877       }
64878       function keypress(d3_event) {
64879         var q2 = search.property("value"), items = list2.selectAll(".feature-list-item");
64880         if (d3_event.keyCode === 13 && // ↩ Return
64881         q2.length && items.size()) {
64882           click(d3_event, items.datum());
64883         }
64884       }
64885       function inputevent() {
64886         _geocodeResults = void 0;
64887         drawList();
64888       }
64889       function clearSearch() {
64890         search.property("value", "");
64891         drawList();
64892       }
64893       function mapDrawn(e3) {
64894         if (e3.full) {
64895           drawList();
64896         }
64897       }
64898       function features() {
64899         var result = [];
64900         var graph = context.graph();
64901         var visibleCenter = context.map().extent().center();
64902         var q2 = search.property("value").toLowerCase();
64903         if (!q2) return result;
64904         var locationMatch = sexagesimal.pair(q2.toUpperCase()) || dmsMatcher(q2);
64905         if (locationMatch) {
64906           var loc = [Number(locationMatch[0]), Number(locationMatch[1])];
64907           result.push({
64908             id: loc[0] + "/" + loc[1],
64909             geometry: "point",
64910             type: _t("inspector.location"),
64911             name: dmsCoordinatePair([loc[1], loc[0]]),
64912             location: loc
64913           });
64914         }
64915         var idMatch = !locationMatch && q2.match(/(?:^|\W)(node|way|relation|note|[nwr])\W{0,2}0*([1-9]\d*)(?:\W|$)/i);
64916         if (idMatch) {
64917           var elemType = idMatch[1] === "note" ? idMatch[1] : idMatch[1].charAt(0);
64918           var elemId = idMatch[2];
64919           result.push({
64920             id: elemType + elemId,
64921             geometry: elemType === "n" ? "point" : elemType === "w" ? "line" : elemType === "note" ? "note" : "relation",
64922             type: elemType === "n" ? _t("inspector.node") : elemType === "w" ? _t("inspector.way") : elemType === "note" ? _t("note.note") : _t("inspector.relation"),
64923             name: elemId
64924           });
64925         }
64926         var allEntities = graph.entities;
64927         var localResults = [];
64928         for (var id2 in allEntities) {
64929           var entity = allEntities[id2];
64930           if (!entity) continue;
64931           var name = utilDisplayName(entity) || "";
64932           if (name.toLowerCase().indexOf(q2) < 0) continue;
64933           var matched = _mainPresetIndex.match(entity, graph);
64934           var type2 = matched && matched.name() || utilDisplayType(entity.id);
64935           var extent = entity.extent(graph);
64936           var distance = extent ? geoSphericalDistance(visibleCenter, extent.center()) : 0;
64937           localResults.push({
64938             id: entity.id,
64939             entity,
64940             geometry: entity.geometry(graph),
64941             type: type2,
64942             name,
64943             distance
64944           });
64945           if (localResults.length > 100) break;
64946         }
64947         localResults = localResults.sort(function byDistance(a2, b2) {
64948           return a2.distance - b2.distance;
64949         });
64950         result = result.concat(localResults);
64951         (_geocodeResults || []).forEach(function(d2) {
64952           if (d2.osm_type && d2.osm_id) {
64953             var id3 = osmEntity.id.fromOSM(d2.osm_type, d2.osm_id);
64954             var tags = {};
64955             tags[d2.class] = d2.type;
64956             var attrs = { id: id3, type: d2.osm_type, tags };
64957             if (d2.osm_type === "way") {
64958               attrs.nodes = ["a", "a"];
64959             }
64960             var tempEntity = osmEntity(attrs);
64961             var tempGraph = coreGraph([tempEntity]);
64962             var matched2 = _mainPresetIndex.match(tempEntity, tempGraph);
64963             var type3 = matched2 && matched2.name() || utilDisplayType(id3);
64964             result.push({
64965               id: tempEntity.id,
64966               geometry: tempEntity.geometry(tempGraph),
64967               type: type3,
64968               name: d2.display_name,
64969               extent: new geoExtent(
64970                 [Number(d2.boundingbox[3]), Number(d2.boundingbox[0])],
64971                 [Number(d2.boundingbox[2]), Number(d2.boundingbox[1])]
64972               )
64973             });
64974           }
64975         });
64976         if (q2.match(/^[0-9]+$/)) {
64977           result.push({
64978             id: "n" + q2,
64979             geometry: "point",
64980             type: _t("inspector.node"),
64981             name: q2
64982           });
64983           result.push({
64984             id: "w" + q2,
64985             geometry: "line",
64986             type: _t("inspector.way"),
64987             name: q2
64988           });
64989           result.push({
64990             id: "r" + q2,
64991             geometry: "relation",
64992             type: _t("inspector.relation"),
64993             name: q2
64994           });
64995           result.push({
64996             id: "note" + q2,
64997             geometry: "note",
64998             type: _t("note.note"),
64999             name: q2
65000           });
65001         }
65002         return result;
65003       }
65004       function drawList() {
65005         var value = search.property("value");
65006         var results = features();
65007         list2.classed("filtered", value.length);
65008         var resultsIndicator = list2.selectAll(".no-results-item").data([0]).enter().append("button").property("disabled", true).attr("class", "no-results-item").call(svgIcon("#iD-icon-alert", "pre-text"));
65009         resultsIndicator.append("span").attr("class", "entity-name");
65010         list2.selectAll(".no-results-item .entity-name").html("").call(_t.append("geocoder.no_results_worldwide"));
65011         if (services.geocoder) {
65012           list2.selectAll(".geocode-item").data([0]).enter().append("button").attr("class", "geocode-item secondary-action").on("click", geocoderSearch).append("div").attr("class", "label").append("span").attr("class", "entity-name").call(_t.append("geocoder.search"));
65013         }
65014         list2.selectAll(".no-results-item").style("display", value.length && !results.length ? "block" : "none");
65015         list2.selectAll(".geocode-item").style("display", value && _geocodeResults === void 0 ? "block" : "none");
65016         var items = list2.selectAll(".feature-list-item").data(results, function(d2) {
65017           return d2.id;
65018         });
65019         var enter = items.enter().insert("button", ".geocode-item").attr("class", "feature-list-item").on("pointerenter", mouseover).on("pointerleave", mouseout).on("focus", mouseover).on("blur", mouseout).on("click", click);
65020         var label = enter.append("div").attr("class", "label");
65021         label.each(function(d2) {
65022           select_default2(this).call(svgIcon("#iD-icon-" + d2.geometry, "pre-text"));
65023         });
65024         label.append("span").attr("class", "entity-type").text(function(d2) {
65025           return d2.type;
65026         });
65027         label.append("span").attr("class", "entity-name").classed("has-colour", (d2) => d2.entity && d2.entity.type === "relation" && d2.entity.tags.colour && isColourValid(d2.entity.tags.colour)).style("border-color", (d2) => d2.entity && d2.entity.type === "relation" && d2.entity.tags.colour).text(function(d2) {
65028           return d2.name;
65029         });
65030         enter.style("opacity", 0).transition().style("opacity", 1);
65031         items.exit().each((d2) => mouseout(void 0, d2)).remove();
65032         items.merge(enter).order();
65033       }
65034       function mouseover(d3_event, d2) {
65035         if (d2.location !== void 0) return;
65036         utilHighlightEntities([d2.id], true, context);
65037       }
65038       function mouseout(d3_event, d2) {
65039         if (d2.location !== void 0) return;
65040         utilHighlightEntities([d2.id], false, context);
65041       }
65042       function click(d3_event, d2) {
65043         d3_event.preventDefault();
65044         if (d2.location) {
65045           context.map().centerZoomEase([d2.location[1], d2.location[0]], 19);
65046         } else if (d2.entity) {
65047           utilHighlightEntities([d2.id], false, context);
65048           context.enter(modeSelect(context, [d2.entity.id]));
65049           context.map().zoomToEase(d2.entity);
65050         } else if (d2.geometry === "note") {
65051           const noteId = d2.id.replace(/\D/g, "");
65052           context.zoomToNote(noteId);
65053         } else {
65054           context.zoomToEntity(d2.id);
65055         }
65056       }
65057       function geocoderSearch() {
65058         services.geocoder.search(search.property("value"), function(err, resp) {
65059           _geocodeResults = resp || [];
65060           drawList();
65061         });
65062       }
65063     }
65064     return featureList;
65065   }
65066
65067   // modules/ui/entity_editor.js
65068   var import_fast_deep_equal9 = __toESM(require_fast_deep_equal());
65069
65070   // modules/ui/sections/entity_issues.js
65071   function uiSectionEntityIssues(context) {
65072     var preference = corePreferences("entity-issues.reference.expanded");
65073     var _expanded = preference === null ? true : preference === "true";
65074     var _entityIDs = [];
65075     var _issues = [];
65076     var _activeIssueID;
65077     var section = uiSection("entity-issues", context).shouldDisplay(function() {
65078       return _issues.length > 0;
65079     }).label(function() {
65080       return _t.append("inspector.title_count", { title: _t("issues.list_title"), count: _issues.length });
65081     }).disclosureContent(renderDisclosureContent);
65082     context.validator().on("validated.entity_issues", function() {
65083       reloadIssues();
65084       section.reRender();
65085     }).on("focusedIssue.entity_issues", function(issue) {
65086       makeActiveIssue(issue.id);
65087     });
65088     function reloadIssues() {
65089       _issues = context.validator().getSharedEntityIssues(_entityIDs, { includeDisabledRules: true });
65090     }
65091     function makeActiveIssue(issueID) {
65092       _activeIssueID = issueID;
65093       section.selection().selectAll(".issue-container").classed("active", function(d2) {
65094         return d2.id === _activeIssueID;
65095       });
65096     }
65097     function renderDisclosureContent(selection2) {
65098       selection2.classed("grouped-items-area", true);
65099       _activeIssueID = _issues.length > 0 ? _issues[0].id : null;
65100       var containers = selection2.selectAll(".issue-container").data(_issues, function(d2) {
65101         return d2.key;
65102       });
65103       containers.exit().remove();
65104       var containersEnter = containers.enter().append("div").attr("class", "issue-container");
65105       var itemsEnter = containersEnter.append("div").attr("class", function(d2) {
65106         return "issue severity-" + d2.severity;
65107       }).on("mouseover.highlight", function(d3_event, d2) {
65108         var ids = d2.entityIds.filter(function(e3) {
65109           return _entityIDs.indexOf(e3) === -1;
65110         });
65111         utilHighlightEntities(ids, true, context);
65112       }).on("mouseout.highlight", function(d3_event, d2) {
65113         var ids = d2.entityIds.filter(function(e3) {
65114           return _entityIDs.indexOf(e3) === -1;
65115         });
65116         utilHighlightEntities(ids, false, context);
65117       });
65118       var labelsEnter = itemsEnter.append("div").attr("class", "issue-label");
65119       var textEnter = labelsEnter.append("button").attr("class", "issue-text").on("click", function(d3_event, d2) {
65120         makeActiveIssue(d2.id);
65121         var extent = d2.extent(context.graph());
65122         if (extent) {
65123           var setZoom = Math.max(context.map().zoom(), 19);
65124           context.map().unobscuredCenterZoomEase(extent.center(), setZoom);
65125         }
65126       });
65127       textEnter.each(function(d2) {
65128         var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error");
65129         select_default2(this).call(svgIcon(iconName, "issue-icon"));
65130       });
65131       textEnter.append("span").attr("class", "issue-message");
65132       var infoButton = labelsEnter.append("button").attr("class", "issue-info-button").attr("title", _t("icons.information")).call(svgIcon("#iD-icon-inspect"));
65133       infoButton.on("click", function(d3_event) {
65134         d3_event.stopPropagation();
65135         d3_event.preventDefault();
65136         this.blur();
65137         var container = select_default2(this.parentNode.parentNode.parentNode);
65138         var info = container.selectAll(".issue-info");
65139         var isExpanded = info.classed("expanded");
65140         _expanded = !isExpanded;
65141         corePreferences("entity-issues.reference.expanded", _expanded);
65142         if (isExpanded) {
65143           info.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() {
65144             info.classed("expanded", false);
65145           });
65146         } else {
65147           info.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1").on("end", function() {
65148             info.style("max-height", null);
65149           });
65150         }
65151       });
65152       itemsEnter.append("ul").attr("class", "issue-fix-list");
65153       containersEnter.append("div").attr("class", "issue-info" + (_expanded ? " expanded" : "")).style("max-height", _expanded ? null : "0").style("opacity", _expanded ? "1" : "0").each(function(d2) {
65154         if (typeof d2.reference === "function") {
65155           select_default2(this).call(d2.reference);
65156         } else {
65157           select_default2(this).call(_t.append("inspector.no_documentation_key"));
65158         }
65159       });
65160       containers = containers.merge(containersEnter).classed("active", function(d2) {
65161         return d2.id === _activeIssueID;
65162       });
65163       containers.selectAll(".issue-message").text("").each(function(d2) {
65164         return d2.message(context)(select_default2(this));
65165       });
65166       var fixLists = containers.selectAll(".issue-fix-list");
65167       var fixes = fixLists.selectAll(".issue-fix-item").data(function(d2) {
65168         return d2.fixes ? d2.fixes(context) : [];
65169       }, function(fix) {
65170         return fix.id;
65171       });
65172       fixes.exit().remove();
65173       var fixesEnter = fixes.enter().append("li").attr("class", "issue-fix-item");
65174       var buttons = fixesEnter.append("button").on("click", function(d3_event, d2) {
65175         if (select_default2(this).attr("disabled") || !d2.onClick) return;
65176         if (d2.issue.dateLastRanFix && /* @__PURE__ */ new Date() - d2.issue.dateLastRanFix < 1e3) return;
65177         d2.issue.dateLastRanFix = /* @__PURE__ */ new Date();
65178         utilHighlightEntities(d2.issue.entityIds.concat(d2.entityIds), false, context);
65179         new Promise(function(resolve, reject) {
65180           d2.onClick(context, resolve, reject);
65181           if (d2.onClick.length <= 1) {
65182             resolve();
65183           }
65184         }).then(function() {
65185           context.validator().validate();
65186         });
65187       }).on("mouseover.highlight", function(d3_event, d2) {
65188         utilHighlightEntities(d2.entityIds, true, context);
65189       }).on("mouseout.highlight", function(d3_event, d2) {
65190         utilHighlightEntities(d2.entityIds, false, context);
65191       });
65192       buttons.each(function(d2) {
65193         var iconName = d2.icon || "iD-icon-wrench";
65194         if (iconName.startsWith("maki")) {
65195           iconName += "-15";
65196         }
65197         select_default2(this).call(svgIcon("#" + iconName, "fix-icon"));
65198       });
65199       buttons.append("span").attr("class", "fix-message").each(function(d2) {
65200         return d2.title(select_default2(this));
65201       });
65202       fixesEnter.merge(fixes).selectAll("button").classed("actionable", function(d2) {
65203         return d2.onClick;
65204       }).attr("disabled", function(d2) {
65205         return d2.onClick ? null : "true";
65206       }).attr("title", function(d2) {
65207         if (d2.disabledReason) {
65208           return d2.disabledReason;
65209         }
65210         return null;
65211       });
65212     }
65213     section.entityIDs = function(val) {
65214       if (!arguments.length) return _entityIDs;
65215       if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) {
65216         _entityIDs = val;
65217         _activeIssueID = null;
65218         reloadIssues();
65219       }
65220       return section;
65221     };
65222     return section;
65223   }
65224
65225   // modules/ui/preset_icon.js
65226   function uiPresetIcon() {
65227     let _preset;
65228     let _geometry;
65229     function presetIcon(selection2) {
65230       selection2.each(render);
65231     }
65232     function getIcon(p2, geom) {
65233       if (p2.isFallback && p2.isFallback()) return geom === "vertex" ? "" : "iD-icon-" + p2.id;
65234       if (p2.icon) return p2.icon;
65235       if (geom === "line") return "iD-other-line";
65236       if (geom === "vertex") return "temaki-vertex";
65237       return "maki-marker-stroked";
65238     }
65239     function renderPointBorder(container, drawPoint) {
65240       let pointBorder = container.selectAll(".preset-icon-point-border").data(drawPoint ? [0] : []);
65241       pointBorder.exit().remove();
65242       let pointBorderEnter = pointBorder.enter();
65243       const w2 = 40;
65244       const h2 = 40;
65245       pointBorderEnter.append("svg").attr("class", "preset-icon-fill preset-icon-point-border").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2)).append("path").attr("transform", "translate(11.5, 8)").attr("d", "M 17,8 C 17,13 11,21 8.5,23.5 C 6,21 0,13 0,8 C 0,4 4,-0.5 8.5,-0.5 C 13,-0.5 17,4 17,8 z");
65246       pointBorder = pointBorderEnter.merge(pointBorder);
65247     }
65248     function renderCategoryBorder(container, category) {
65249       let categoryBorder = container.selectAll(".preset-icon-category-border").data(category ? [0] : []);
65250       categoryBorder.exit().remove();
65251       let categoryBorderEnter = categoryBorder.enter();
65252       const d2 = 60;
65253       let svgEnter = categoryBorderEnter.append("svg").attr("class", "preset-icon-fill preset-icon-category-border").attr("width", d2).attr("height", d2).attr("viewBox", "0 0 ".concat(d2, " ").concat(d2));
65254       svgEnter.append("path").attr("class", "area").attr("d", "M9.5,7.5 L25.5,7.5 L28.5,12.5 L49.5,12.5 C51.709139,12.5 53.5,14.290861 53.5,16.5 L53.5,43.5 C53.5,45.709139 51.709139,47.5 49.5,47.5 L10.5,47.5 C8.290861,47.5 6.5,45.709139 6.5,43.5 L6.5,12.5 L9.5,7.5 Z");
65255       categoryBorder = categoryBorderEnter.merge(categoryBorder);
65256       if (category) {
65257         categoryBorder.selectAll("path").attr("class", "area ".concat(category.id));
65258       }
65259     }
65260     function renderCircleFill(container, drawVertex) {
65261       let vertexFill = container.selectAll(".preset-icon-fill-vertex").data(drawVertex ? [0] : []);
65262       vertexFill.exit().remove();
65263       let vertexFillEnter = vertexFill.enter();
65264       const w2 = 60;
65265       const h2 = 60;
65266       const d2 = 40;
65267       vertexFillEnter.append("svg").attr("class", "preset-icon-fill preset-icon-fill-vertex").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2)).append("circle").attr("cx", w2 / 2).attr("cy", h2 / 2).attr("r", d2 / 2);
65268       vertexFill = vertexFillEnter.merge(vertexFill);
65269     }
65270     function renderSquareFill(container, drawArea, tagClasses) {
65271       let fill = container.selectAll(".preset-icon-fill-area").data(drawArea ? [0] : []);
65272       fill.exit().remove();
65273       let fillEnter = fill.enter();
65274       const d2 = 60;
65275       const w2 = d2;
65276       const h2 = d2;
65277       const l2 = d2 * 2 / 3;
65278       const c1 = (w2 - l2) / 2;
65279       const c2 = c1 + l2;
65280       fillEnter = fillEnter.append("svg").attr("class", "preset-icon-fill preset-icon-fill-area").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
65281       ["fill", "stroke"].forEach((klass) => {
65282         fillEnter.append("path").attr("d", "M".concat(c1, " ").concat(c1, " L").concat(c1, " ").concat(c2, " L").concat(c2, " ").concat(c2, " L").concat(c2, " ").concat(c1, " Z")).attr("class", "area ".concat(klass));
65283       });
65284       const rVertex = 2.5;
65285       [[c1, c1], [c1, c2], [c2, c2], [c2, c1]].forEach((point) => {
65286         fillEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", rVertex);
65287       });
65288       const rMidpoint = 1.25;
65289       [[c1, w2 / 2], [c2, w2 / 2], [h2 / 2, c1], [h2 / 2, c2]].forEach((point) => {
65290         fillEnter.append("circle").attr("class", "midpoint").attr("cx", point[0]).attr("cy", point[1]).attr("r", rMidpoint);
65291       });
65292       fill = fillEnter.merge(fill);
65293       fill.selectAll("path.stroke").attr("class", "area stroke ".concat(tagClasses));
65294       fill.selectAll("path.fill").attr("class", "area fill ".concat(tagClasses));
65295     }
65296     function renderLine(container, drawLine, tagClasses) {
65297       let line = container.selectAll(".preset-icon-line").data(drawLine ? [0] : []);
65298       line.exit().remove();
65299       let lineEnter = line.enter();
65300       const d2 = 60;
65301       const w2 = d2;
65302       const h2 = d2;
65303       const y2 = Math.round(d2 * 0.72);
65304       const l2 = Math.round(d2 * 0.6);
65305       const r2 = 2.5;
65306       const x12 = (w2 - l2) / 2;
65307       const x2 = x12 + l2;
65308       lineEnter = lineEnter.append("svg").attr("class", "preset-icon-line").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
65309       ["casing", "stroke"].forEach((klass) => {
65310         lineEnter.append("path").attr("d", "M".concat(x12, " ").concat(y2, " L").concat(x2, " ").concat(y2)).attr("class", "line ".concat(klass));
65311       });
65312       [[x12 - 1, y2], [x2 + 1, y2]].forEach((point) => {
65313         lineEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", r2);
65314       });
65315       line = lineEnter.merge(line);
65316       line.selectAll("path.stroke").attr("class", "line stroke ".concat(tagClasses));
65317       line.selectAll("path.casing").attr("class", "line casing ".concat(tagClasses));
65318     }
65319     function renderRoute(container, drawRoute, p2) {
65320       let route = container.selectAll(".preset-icon-route").data(drawRoute ? [0] : []);
65321       route.exit().remove();
65322       let routeEnter = route.enter();
65323       const d2 = 60;
65324       const w2 = d2;
65325       const h2 = d2;
65326       const y12 = Math.round(d2 * 0.8);
65327       const y2 = Math.round(d2 * 0.68);
65328       const l2 = Math.round(d2 * 0.6);
65329       const r2 = 2;
65330       const x12 = (w2 - l2) / 2;
65331       const x2 = x12 + l2 / 3;
65332       const x3 = x2 + l2 / 3;
65333       const x4 = x3 + l2 / 3;
65334       routeEnter = routeEnter.append("svg").attr("class", "preset-icon-route").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
65335       ["casing", "stroke"].forEach((klass) => {
65336         routeEnter.append("path").attr("d", "M".concat(x12, " ").concat(y12, " L").concat(x2, " ").concat(y2)).attr("class", "segment0 line ".concat(klass));
65337         routeEnter.append("path").attr("d", "M".concat(x2, " ").concat(y2, " L").concat(x3, " ").concat(y12)).attr("class", "segment1 line ".concat(klass));
65338         routeEnter.append("path").attr("d", "M".concat(x3, " ").concat(y12, " L").concat(x4, " ").concat(y2)).attr("class", "segment2 line ".concat(klass));
65339       });
65340       [[x12, y12], [x2, y2], [x3, y12], [x4, y2]].forEach((point) => {
65341         routeEnter.append("circle").attr("class", "vertex").attr("cx", point[0]).attr("cy", point[1]).attr("r", r2);
65342       });
65343       route = routeEnter.merge(route);
65344       if (drawRoute) {
65345         let routeType = p2.tags.type === "waterway" ? "waterway" : p2.tags.route;
65346         const segmentPresetIDs = routeSegments[routeType];
65347         for (let i3 in segmentPresetIDs) {
65348           const segmentPreset = _mainPresetIndex.item(segmentPresetIDs[i3]);
65349           const segmentTagClasses = svgTagClasses().getClassesString(segmentPreset.tags, "");
65350           route.selectAll("path.stroke.segment".concat(i3)).attr("class", "segment".concat(i3, " line stroke ").concat(segmentTagClasses));
65351           route.selectAll("path.casing.segment".concat(i3)).attr("class", "segment".concat(i3, " line casing ").concat(segmentTagClasses));
65352         }
65353       }
65354     }
65355     function renderSvgIcon(container, picon, geom, isFramed, category, tagClasses) {
65356       const isMaki = picon && /^maki-/.test(picon);
65357       const isTemaki = picon && /^temaki-/.test(picon);
65358       const isFa = picon && /^fa[srb]-/.test(picon);
65359       const isR\u00F6ntgen = picon && /^roentgen-/.test(picon);
65360       const isiDIcon = picon && !(isMaki || isTemaki || isFa || isR\u00F6ntgen);
65361       let icon2 = container.selectAll(".preset-icon").data(picon ? [0] : []);
65362       icon2.exit().remove();
65363       icon2 = icon2.enter().append("div").attr("class", "preset-icon").call(svgIcon("")).merge(icon2);
65364       icon2.attr("class", "preset-icon " + (geom ? geom + "-geom" : "")).classed("category", category).classed("framed", isFramed).classed("preset-icon-iD", isiDIcon);
65365       icon2.selectAll("svg").attr("class", "icon " + picon + " " + (!isiDIcon && geom !== "line" ? "" : tagClasses));
65366       icon2.selectAll("use").attr("href", "#" + picon);
65367     }
65368     function renderImageIcon(container, imageURL) {
65369       let imageIcon = container.selectAll("img.image-icon").data(imageURL ? [0] : []);
65370       imageIcon.exit().remove();
65371       imageIcon = imageIcon.enter().append("img").attr("class", "image-icon").on("load", () => container.classed("showing-img", true)).on("error", () => container.classed("showing-img", false)).merge(imageIcon);
65372       imageIcon.attr("src", imageURL);
65373     }
65374     const routeSegments = {
65375       bicycle: ["highway/cycleway", "highway/cycleway", "highway/cycleway"],
65376       bus: ["highway/unclassified", "highway/secondary", "highway/primary"],
65377       trolleybus: ["highway/unclassified", "highway/secondary", "highway/primary"],
65378       detour: ["highway/tertiary", "highway/residential", "highway/unclassified"],
65379       ferry: ["route/ferry", "route/ferry", "route/ferry"],
65380       foot: ["highway/footway", "highway/footway", "highway/footway"],
65381       hiking: ["highway/path", "highway/path", "highway/path"],
65382       horse: ["highway/bridleway", "highway/bridleway", "highway/bridleway"],
65383       light_rail: ["railway/light_rail", "railway/light_rail", "railway/light_rail"],
65384       monorail: ["railway/monorail", "railway/monorail", "railway/monorail"],
65385       mtb: ["highway/path", "highway/track", "highway/bridleway"],
65386       pipeline: ["man_made/pipeline", "man_made/pipeline", "man_made/pipeline"],
65387       piste: ["piste/downhill", "piste/hike", "piste/nordic"],
65388       power: ["power/line", "power/line", "power/line"],
65389       road: ["highway/secondary", "highway/primary", "highway/trunk"],
65390       subway: ["railway/subway", "railway/subway", "railway/subway"],
65391       train: ["railway/rail", "railway/rail", "railway/rail"],
65392       tram: ["railway/tram", "railway/tram", "railway/tram"],
65393       railway: ["railway/rail", "railway/rail", "railway/rail"],
65394       waterway: ["waterway/stream", "waterway/stream", "waterway/stream"]
65395     };
65396     function render() {
65397       let p2 = _preset.apply(this, arguments);
65398       let geom = _geometry ? _geometry.apply(this, arguments) : null;
65399       if (geom === "relation" && p2.tags && (p2.tags.type === "route" && p2.tags.route && routeSegments[p2.tags.route] || p2.tags.type === "waterway")) {
65400         geom = "route";
65401       }
65402       const showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true";
65403       const isFallback = p2.isFallback && p2.isFallback();
65404       const imageURL = showThirdPartyIcons === "true" && p2.imageURL;
65405       const picon = getIcon(p2, geom);
65406       const isCategory = !p2.setTags;
65407       const drawPoint = false;
65408       const drawVertex = picon !== null && geom === "vertex";
65409       const drawLine = picon && geom === "line" && !isFallback && !isCategory;
65410       const drawArea = picon && geom === "area" && !isFallback && !isCategory;
65411       const drawRoute = picon && geom === "route";
65412       const isFramed = drawVertex || drawArea || drawLine || drawRoute || isCategory;
65413       let tags = !isCategory ? p2.setTags({}, geom) : {};
65414       for (let k2 in tags) {
65415         if (tags[k2] === "*") {
65416           tags[k2] = "yes";
65417         }
65418       }
65419       let tagClasses = svgTagClasses().getClassesString(tags, "");
65420       let selection2 = select_default2(this);
65421       let container = selection2.selectAll(".preset-icon-container").data([0]);
65422       container = container.enter().append("div").attr("class", "preset-icon-container").merge(container);
65423       container.classed("showing-img", !!imageURL).classed("fallback", isFallback);
65424       renderCategoryBorder(container, isCategory && p2);
65425       renderPointBorder(container, drawPoint);
65426       renderCircleFill(container, drawVertex);
65427       renderSquareFill(container, drawArea, tagClasses);
65428       renderLine(container, drawLine, tagClasses);
65429       renderRoute(container, drawRoute, p2);
65430       renderSvgIcon(container, picon, geom, isFramed, isCategory, tagClasses);
65431       renderImageIcon(container, imageURL);
65432     }
65433     presetIcon.preset = function(val) {
65434       if (!arguments.length) return _preset;
65435       _preset = utilFunctor(val);
65436       return presetIcon;
65437     };
65438     presetIcon.geometry = function(val) {
65439       if (!arguments.length) return _geometry;
65440       _geometry = utilFunctor(val);
65441       return presetIcon;
65442     };
65443     return presetIcon;
65444   }
65445
65446   // modules/ui/sections/feature_type.js
65447   function uiSectionFeatureType(context) {
65448     var dispatch14 = dispatch_default("choose");
65449     var _entityIDs = [];
65450     var _presets = [];
65451     var _tagReference;
65452     var section = uiSection("feature-type", context).label(() => _t.append("inspector.feature_type")).disclosureContent(renderDisclosureContent);
65453     function renderDisclosureContent(selection2) {
65454       selection2.classed("preset-list-item", true);
65455       selection2.classed("mixed-types", _presets.length > 1);
65456       var presetButtonWrap = selection2.selectAll(".preset-list-button-wrap").data([0]).enter().append("div").attr("class", "preset-list-button-wrap");
65457       var presetButton = presetButtonWrap.append("button").attr("class", "preset-list-button preset-reset").call(
65458         uiTooltip().title(() => _t.append("inspector.back_tooltip")).placement("bottom")
65459       );
65460       presetButton.append("div").attr("class", "preset-icon-container");
65461       presetButton.append("div").attr("class", "label").append("div").attr("class", "label-inner");
65462       presetButtonWrap.append("div").attr("class", "accessory-buttons");
65463       var tagReferenceBodyWrap = selection2.selectAll(".tag-reference-body-wrap").data([0]);
65464       tagReferenceBodyWrap = tagReferenceBodyWrap.enter().append("div").attr("class", "tag-reference-body-wrap").merge(tagReferenceBodyWrap);
65465       if (_tagReference) {
65466         selection2.selectAll(".preset-list-button-wrap .accessory-buttons").style("display", _presets.length === 1 ? null : "none").call(_tagReference.button);
65467         tagReferenceBodyWrap.style("display", _presets.length === 1 ? null : "none").call(_tagReference.body);
65468       }
65469       selection2.selectAll(".preset-reset").on("click", function() {
65470         dispatch14.call("choose", this, _presets);
65471       }).on("pointerdown pointerup mousedown mouseup", function(d3_event) {
65472         d3_event.preventDefault();
65473         d3_event.stopPropagation();
65474       });
65475       var geometries = entityGeometries();
65476       selection2.select(".preset-list-item button").call(
65477         uiPresetIcon().geometry(_presets.length === 1 ? geometries.length === 1 && geometries[0] : null).preset(_presets.length === 1 ? _presets[0] : _mainPresetIndex.item("point"))
65478       );
65479       var names = _presets.length === 1 ? [
65480         _presets[0].nameLabel(),
65481         _presets[0].subtitleLabel()
65482       ].filter(Boolean) : [_t.append("inspector.multiple_types")];
65483       var label = selection2.select(".label-inner");
65484       var nameparts = label.selectAll(".namepart").data(names, (d2) => d2.stringId);
65485       nameparts.exit().remove();
65486       nameparts.enter().append("div").attr("class", "namepart").text("").each(function(d2) {
65487         d2(select_default2(this));
65488       });
65489     }
65490     section.entityIDs = function(val) {
65491       if (!arguments.length) return _entityIDs;
65492       _entityIDs = val;
65493       return section;
65494     };
65495     section.presets = function(val) {
65496       if (!arguments.length) return _presets;
65497       if (!utilArrayIdentical(val, _presets)) {
65498         _presets = val;
65499         if (_presets.length === 1) {
65500           _tagReference = uiTagReference(_presets[0].reference(), context).showing(false);
65501         }
65502       }
65503       return section;
65504     };
65505     function entityGeometries() {
65506       var counts = {};
65507       for (var i3 in _entityIDs) {
65508         var geometry = context.graph().geometry(_entityIDs[i3]);
65509         if (!counts[geometry]) counts[geometry] = 0;
65510         counts[geometry] += 1;
65511       }
65512       return Object.keys(counts).sort(function(geom1, geom2) {
65513         return counts[geom2] - counts[geom1];
65514       });
65515     }
65516     return utilRebind(section, dispatch14, "on");
65517   }
65518
65519   // modules/ui/form_fields.js
65520   function uiFormFields(context) {
65521     var moreCombo = uiCombobox(context, "more-fields").minItems(1);
65522     var _fieldsArr = [];
65523     var _lastPlaceholder = "";
65524     var _state = "";
65525     var _klass = "";
65526     function formFields(selection2) {
65527       var allowedFields = _fieldsArr.filter(function(field) {
65528         return field.isAllowed();
65529       });
65530       var shown = allowedFields.filter(function(field) {
65531         return field.isShown();
65532       });
65533       var notShown = allowedFields.filter(function(field) {
65534         return !field.isShown();
65535       }).sort(function(a2, b2) {
65536         return a2.universal === b2.universal ? 0 : a2.universal ? 1 : -1;
65537       });
65538       var container = selection2.selectAll(".form-fields-container").data([0]);
65539       container = container.enter().append("div").attr("class", "form-fields-container " + (_klass || "")).merge(container);
65540       var fields = container.selectAll(".wrap-form-field").data(shown, function(d2) {
65541         return d2.id + (d2.entityIDs ? d2.entityIDs.join() : "");
65542       });
65543       fields.exit().remove();
65544       var enter = fields.enter().append("div").attr("class", function(d2) {
65545         return "wrap-form-field wrap-form-field-" + d2.safeid;
65546       });
65547       fields = fields.merge(enter);
65548       fields.order().each(function(d2) {
65549         select_default2(this).call(d2.render);
65550       });
65551       var titles = [];
65552       var moreFields = notShown.map(function(field) {
65553         var title = field.title();
65554         titles.push(title);
65555         var terms = field.terms();
65556         if (field.key) terms.push(field.key);
65557         if (field.keys) terms = terms.concat(field.keys);
65558         return {
65559           display: field.label(),
65560           value: title,
65561           title,
65562           field,
65563           terms
65564         };
65565       });
65566       var placeholder = titles.slice(0, 3).join(", ") + (titles.length > 3 ? "\u2026" : "");
65567       var more = selection2.selectAll(".more-fields").data(_state === "hover" || moreFields.length === 0 ? [] : [0]);
65568       more.exit().remove();
65569       var moreEnter = more.enter().append("div").attr("class", "more-fields").append("label");
65570       moreEnter.append("span").call(_t.append("inspector.add_fields"));
65571       more = moreEnter.merge(more);
65572       var input = more.selectAll(".value").data([0]);
65573       input.exit().remove();
65574       input = input.enter().append("input").attr("class", "value").attr("type", "text").attr("placeholder", placeholder).call(utilNoAuto).merge(input);
65575       input.call(utilGetSetValue, "").call(
65576         moreCombo.data(moreFields).on("accept", function(d2) {
65577           if (!d2) return;
65578           var field = d2.field;
65579           field.show();
65580           selection2.call(formFields);
65581           field.focus();
65582         })
65583       );
65584       if (_lastPlaceholder !== placeholder) {
65585         input.attr("placeholder", placeholder);
65586         _lastPlaceholder = placeholder;
65587       }
65588     }
65589     formFields.fieldsArr = function(val) {
65590       if (!arguments.length) return _fieldsArr;
65591       _fieldsArr = val || [];
65592       return formFields;
65593     };
65594     formFields.state = function(val) {
65595       if (!arguments.length) return _state;
65596       _state = val;
65597       return formFields;
65598     };
65599     formFields.klass = function(val) {
65600       if (!arguments.length) return _klass;
65601       _klass = val;
65602       return formFields;
65603     };
65604     return formFields;
65605   }
65606
65607   // modules/ui/sections/preset_fields.js
65608   function uiSectionPresetFields(context) {
65609     var section = uiSection("preset-fields", context).label(() => _t.append("inspector.fields")).disclosureContent(renderDisclosureContent);
65610     var dispatch14 = dispatch_default("change", "revert");
65611     var formFields = uiFormFields(context);
65612     var _state;
65613     var _fieldsArr;
65614     var _presets = [];
65615     var _tags;
65616     var _entityIDs;
65617     function renderDisclosureContent(selection2) {
65618       if (!_fieldsArr) {
65619         var graph = context.graph();
65620         var geometries = Object.keys(_entityIDs.reduce(function(geoms, entityID) {
65621           geoms[graph.entity(entityID).geometry(graph)] = true;
65622           return geoms;
65623         }, {}));
65624         const loc = _entityIDs.reduce(function(extent, entityID) {
65625           var entity = context.graph().entity(entityID);
65626           return extent.extend(entity.extent(context.graph()));
65627         }, geoExtent()).center();
65628         var presetsManager = _mainPresetIndex;
65629         var allFields = [];
65630         var allMoreFields = [];
65631         var sharedTotalFields;
65632         _presets.forEach(function(preset) {
65633           var fields = preset.fields(loc);
65634           var moreFields = preset.moreFields(loc);
65635           allFields = utilArrayUnion(allFields, fields);
65636           allMoreFields = utilArrayUnion(allMoreFields, moreFields);
65637           if (!sharedTotalFields) {
65638             sharedTotalFields = utilArrayUnion(fields, moreFields);
65639           } else {
65640             sharedTotalFields = sharedTotalFields.filter(function(field) {
65641               return fields.indexOf(field) !== -1 || moreFields.indexOf(field) !== -1;
65642             });
65643           }
65644         });
65645         var sharedFields = allFields.filter(function(field) {
65646           return sharedTotalFields.indexOf(field) !== -1;
65647         });
65648         var sharedMoreFields = allMoreFields.filter(function(field) {
65649           return sharedTotalFields.indexOf(field) !== -1;
65650         });
65651         _fieldsArr = [];
65652         sharedFields.forEach(function(field) {
65653           if (field.matchAllGeometry(geometries)) {
65654             _fieldsArr.push(
65655               uiField(context, field, _entityIDs)
65656             );
65657           }
65658         });
65659         var singularEntity = _entityIDs.length === 1 && graph.hasEntity(_entityIDs[0]);
65660         if (singularEntity && singularEntity.isHighwayIntersection(graph) && presetsManager.field("restrictions")) {
65661           _fieldsArr.push(
65662             uiField(context, presetsManager.field("restrictions"), _entityIDs)
65663           );
65664         }
65665         var additionalFields = utilArrayUnion(sharedMoreFields, presetsManager.universal());
65666         additionalFields.sort(function(field1, field2) {
65667           return field1.title().localeCompare(field2.title(), _mainLocalizer.localeCode());
65668         });
65669         additionalFields.forEach(function(field) {
65670           if (sharedFields.indexOf(field) === -1 && field.matchAllGeometry(geometries)) {
65671             _fieldsArr.push(
65672               uiField(context, field, _entityIDs, { show: false })
65673             );
65674           }
65675         });
65676         _fieldsArr.forEach(function(field) {
65677           field.on("change", function(t2, onInput) {
65678             dispatch14.call("change", field, _entityIDs, t2, onInput);
65679           }).on("revert", function(keys2) {
65680             dispatch14.call("revert", field, keys2);
65681           });
65682         });
65683       }
65684       _fieldsArr.forEach(function(field) {
65685         field.state(_state).tags(_tags);
65686       });
65687       selection2.call(
65688         formFields.fieldsArr(_fieldsArr).state(_state).klass("grouped-items-area")
65689       );
65690     }
65691     section.presets = function(val) {
65692       if (!arguments.length) return _presets;
65693       if (!_presets || !val || !utilArrayIdentical(_presets, val)) {
65694         _presets = val;
65695         _fieldsArr = null;
65696       }
65697       return section;
65698     };
65699     section.state = function(val) {
65700       if (!arguments.length) return _state;
65701       _state = val;
65702       return section;
65703     };
65704     section.tags = function(val) {
65705       if (!arguments.length) return _tags;
65706       _tags = val;
65707       return section;
65708     };
65709     section.entityIDs = function(val) {
65710       if (!arguments.length) return _entityIDs;
65711       if (!val || !_entityIDs || !utilArrayIdentical(_entityIDs, val)) {
65712         _entityIDs = val;
65713         _fieldsArr = null;
65714       }
65715       return section;
65716     };
65717     return utilRebind(section, dispatch14, "on");
65718   }
65719
65720   // modules/ui/sections/raw_member_editor.js
65721   function uiSectionRawMemberEditor(context) {
65722     var section = uiSection("raw-member-editor", context).shouldDisplay(function() {
65723       if (!_entityIDs || _entityIDs.length !== 1) return false;
65724       var entity = context.hasEntity(_entityIDs[0]);
65725       return entity && entity.type === "relation";
65726     }).label(function() {
65727       var entity = context.hasEntity(_entityIDs[0]);
65728       if (!entity) return "";
65729       var gt2 = entity.members.length > _maxMembers ? ">" : "";
65730       var count = gt2 + entity.members.slice(0, _maxMembers).length;
65731       return _t.append("inspector.title_count", { title: _t("inspector.members"), count });
65732     }).disclosureContent(renderDisclosureContent);
65733     var taginfo = services.taginfo;
65734     var _entityIDs;
65735     var _maxMembers = 1e3;
65736     function downloadMember(d3_event, d2) {
65737       d3_event.preventDefault();
65738       select_default2(this).classed("loading", true);
65739       context.loadEntity(d2.id, function() {
65740         section.reRender();
65741       });
65742     }
65743     function zoomToMember(d3_event, d2) {
65744       d3_event.preventDefault();
65745       var entity = context.entity(d2.id);
65746       context.map().zoomToEase(entity);
65747       utilHighlightEntities([d2.id], true, context);
65748     }
65749     function selectMember(d3_event, d2) {
65750       d3_event.preventDefault();
65751       utilHighlightEntities([d2.id], false, context);
65752       var entity = context.entity(d2.id);
65753       var mapExtent = context.map().extent();
65754       if (!entity.intersects(mapExtent, context.graph())) {
65755         context.map().zoomToEase(entity);
65756       }
65757       context.enter(modeSelect(context, [d2.id]));
65758     }
65759     function changeRole(d3_event, d2) {
65760       var oldRole = d2.role;
65761       var newRole = context.cleanRelationRole(select_default2(this).property("value"));
65762       if (oldRole !== newRole) {
65763         var member = { id: d2.id, type: d2.type, role: newRole };
65764         context.perform(
65765           actionChangeMember(d2.relation.id, member, d2.index),
65766           _t("operations.change_role.annotation", {
65767             n: 1
65768           })
65769         );
65770         context.validator().validate();
65771       }
65772     }
65773     function deleteMember(d3_event, d2) {
65774       utilHighlightEntities([d2.id], false, context);
65775       context.perform(
65776         actionDeleteMember(d2.relation.id, d2.index),
65777         _t("operations.delete_member.annotation", {
65778           n: 1
65779         })
65780       );
65781       if (!context.hasEntity(d2.relation.id)) {
65782         context.enter(modeBrowse(context));
65783       } else {
65784         context.validator().validate();
65785       }
65786     }
65787     function renderDisclosureContent(selection2) {
65788       var entityID = _entityIDs[0];
65789       var memberships = [];
65790       var entity = context.entity(entityID);
65791       entity.members.slice(0, _maxMembers).forEach(function(member, index) {
65792         memberships.push({
65793           index,
65794           id: member.id,
65795           type: member.type,
65796           role: member.role,
65797           relation: entity,
65798           member: context.hasEntity(member.id),
65799           domId: utilUniqueDomId(entityID + "-member-" + index)
65800         });
65801       });
65802       var list2 = selection2.selectAll(".member-list").data([0]);
65803       list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
65804       var items = list2.selectAll("li").data(memberships, function(d2) {
65805         return osmEntity.key(d2.relation) + "," + d2.index + "," + (d2.member ? osmEntity.key(d2.member) : "incomplete");
65806       });
65807       items.exit().each(unbind).remove();
65808       var itemsEnter = items.enter().append("li").attr("class", "member-row form-field").classed("member-incomplete", function(d2) {
65809         return !d2.member;
65810       });
65811       itemsEnter.each(function(d2) {
65812         var item = select_default2(this);
65813         var label = item.append("label").attr("class", "field-label").attr("for", d2.domId);
65814         if (d2.member) {
65815           item.on("mouseover", function() {
65816             utilHighlightEntities([d2.id], true, context);
65817           }).on("mouseout", function() {
65818             utilHighlightEntities([d2.id], false, context);
65819           });
65820           var labelLink = label.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectMember);
65821           labelLink.append("span").attr("class", "member-entity-type").text(function(d4) {
65822             var matched = _mainPresetIndex.match(d4.member, context.graph());
65823             return matched && matched.name() || utilDisplayType(d4.member.id);
65824           });
65825           labelLink.append("span").attr("class", "member-entity-name").classed("has-colour", (d4) => d4.member.type === "relation" && d4.member.tags.colour && isColourValid(d4.member.tags.colour)).style("border-color", (d4) => d4.member.type === "relation" && d4.member.tags.colour).text(function(d4) {
65826             return utilDisplayName(d4.member);
65827           });
65828           label.append("button").attr("title", _t("icons.remove")).attr("class", "remove member-delete").call(svgIcon("#iD-operation-delete"));
65829           label.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToMember);
65830         } else {
65831           var labelText = label.append("span").attr("class", "label-text");
65832           labelText.append("span").attr("class", "member-entity-type").call(_t.append("inspector." + d2.type, { id: d2.id }));
65833           labelText.append("span").attr("class", "member-entity-name").call(_t.append("inspector.incomplete", { id: d2.id }));
65834           label.append("button").attr("class", "member-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMember);
65835         }
65836       });
65837       var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
65838       wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
65839         return d2.domId;
65840       }).property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
65841       if (taginfo) {
65842         wrapEnter.each(bindTypeahead);
65843       }
65844       items = items.merge(itemsEnter).order();
65845       items.select("input.member-role").property("value", function(d2) {
65846         return d2.role;
65847       }).on("blur", changeRole).on("change", changeRole);
65848       items.select("button.member-delete").on("click", deleteMember);
65849       var dragOrigin, targetIndex;
65850       items.call(
65851         drag_default().on("start", function(d3_event) {
65852           dragOrigin = {
65853             x: d3_event.x,
65854             y: d3_event.y
65855           };
65856           targetIndex = null;
65857         }).on("drag", function(d3_event) {
65858           var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y;
65859           if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold
65860           Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5) return;
65861           var index = items.nodes().indexOf(this);
65862           select_default2(this).classed("dragging", true);
65863           targetIndex = null;
65864           selection2.selectAll("li.member-row").style("transform", function(d2, index2) {
65865             var node = select_default2(this).node();
65866             if (index === index2) {
65867               return "translate(" + x2 + "px, " + y2 + "px)";
65868             } else if (index2 > index && d3_event.y > node.offsetTop) {
65869               if (targetIndex === null || index2 > targetIndex) {
65870                 targetIndex = index2;
65871               }
65872               return "translateY(-100%)";
65873             } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) {
65874               if (targetIndex === null || index2 < targetIndex) {
65875                 targetIndex = index2;
65876               }
65877               return "translateY(100%)";
65878             }
65879             return null;
65880           });
65881         }).on("end", function(d3_event, d2) {
65882           if (!select_default2(this).classed("dragging")) return;
65883           var index = items.nodes().indexOf(this);
65884           select_default2(this).classed("dragging", false);
65885           selection2.selectAll("li.member-row").style("transform", null);
65886           if (targetIndex !== null) {
65887             context.perform(
65888               actionMoveMember(d2.relation.id, index, targetIndex),
65889               _t("operations.reorder_members.annotation")
65890             );
65891             context.validator().validate();
65892           }
65893         })
65894       );
65895       function bindTypeahead(d2) {
65896         var row = select_default2(this);
65897         var role = row.selectAll("input.member-role");
65898         var origValue = role.property("value");
65899         function sort(value, data) {
65900           var sameletter = [];
65901           var other2 = [];
65902           for (var i3 = 0; i3 < data.length; i3++) {
65903             if (data[i3].value.substring(0, value.length) === value) {
65904               sameletter.push(data[i3]);
65905             } else {
65906               other2.push(data[i3]);
65907             }
65908           }
65909           return sameletter.concat(other2);
65910         }
65911         role.call(
65912           uiCombobox(context, "member-role").fetcher(function(role2, callback) {
65913             var geometry;
65914             if (d2.member) {
65915               geometry = context.graph().geometry(d2.member.id);
65916             } else if (d2.type === "relation") {
65917               geometry = "relation";
65918             } else if (d2.type === "way") {
65919               geometry = "line";
65920             } else {
65921               geometry = "point";
65922             }
65923             var rtype = entity.tags.type;
65924             taginfo.roles({
65925               debounce: true,
65926               rtype: rtype || "",
65927               geometry,
65928               query: role2
65929             }, function(err, data) {
65930               if (!err) callback(sort(role2, data));
65931             });
65932           }).on("cancel", function() {
65933             role.property("value", origValue);
65934           })
65935         );
65936       }
65937       function unbind() {
65938         var row = select_default2(this);
65939         row.selectAll("input.member-role").call(uiCombobox.off, context);
65940       }
65941     }
65942     section.entityIDs = function(val) {
65943       if (!arguments.length) return _entityIDs;
65944       _entityIDs = val;
65945       return section;
65946     };
65947     return section;
65948   }
65949
65950   // modules/actions/delete_members.js
65951   function actionDeleteMembers(relationId, memberIndexes) {
65952     return function(graph) {
65953       memberIndexes.sort((a2, b2) => b2 - a2);
65954       for (var i3 in memberIndexes) {
65955         graph = actionDeleteMember(relationId, memberIndexes[i3])(graph);
65956       }
65957       return graph;
65958     };
65959   }
65960
65961   // modules/ui/sections/raw_membership_editor.js
65962   function uiSectionRawMembershipEditor(context) {
65963     var section = uiSection("raw-membership-editor", context).shouldDisplay(function() {
65964       return _entityIDs && _entityIDs.length;
65965     }).label(function() {
65966       var parents = getSharedParentRelations();
65967       var gt2 = parents.length > _maxMemberships ? ">" : "";
65968       var count = gt2 + parents.slice(0, _maxMemberships).length;
65969       return _t.append("inspector.title_count", { title: _t("inspector.relations"), count });
65970     }).disclosureContent(renderDisclosureContent);
65971     var taginfo = services.taginfo;
65972     var nearbyCombo = uiCombobox(context, "parent-relation").minItems(1).fetcher(fetchNearbyRelations).itemsMouseEnter(function(d3_event, d2) {
65973       if (d2.relation) utilHighlightEntities([d2.relation.id], true, context);
65974     }).itemsMouseLeave(function(d3_event, d2) {
65975       if (d2.relation) utilHighlightEntities([d2.relation.id], false, context);
65976     });
65977     var _inChange = false;
65978     var _entityIDs = [];
65979     var _showBlank;
65980     var _maxMemberships = 1e3;
65981     function getSharedParentRelations() {
65982       var parents = [];
65983       for (var i3 = 0; i3 < _entityIDs.length; i3++) {
65984         var entity = context.graph().hasEntity(_entityIDs[i3]);
65985         if (!entity) continue;
65986         if (i3 === 0) {
65987           parents = context.graph().parentRelations(entity);
65988         } else {
65989           parents = utilArrayIntersection(parents, context.graph().parentRelations(entity));
65990         }
65991         if (!parents.length) break;
65992       }
65993       return parents;
65994     }
65995     function getMemberships() {
65996       var memberships = [];
65997       var relations = getSharedParentRelations().slice(0, _maxMemberships);
65998       var isMultiselect = _entityIDs.length > 1;
65999       var i3, relation, membership, index, member, indexedMember;
66000       for (i3 = 0; i3 < relations.length; i3++) {
66001         relation = relations[i3];
66002         membership = {
66003           relation,
66004           members: [],
66005           hash: osmEntity.key(relation)
66006         };
66007         for (index = 0; index < relation.members.length; index++) {
66008           member = relation.members[index];
66009           if (_entityIDs.indexOf(member.id) !== -1) {
66010             indexedMember = Object.assign({}, member, { index });
66011             membership.members.push(indexedMember);
66012             membership.hash += "," + index.toString();
66013             if (!isMultiselect) {
66014               memberships.push(membership);
66015               membership = {
66016                 relation,
66017                 members: [],
66018                 hash: osmEntity.key(relation)
66019               };
66020             }
66021           }
66022         }
66023         if (membership.members.length) memberships.push(membership);
66024       }
66025       memberships.forEach(function(membership2) {
66026         membership2.domId = utilUniqueDomId("membership-" + membership2.relation.id);
66027         var roles = [];
66028         membership2.members.forEach(function(member2) {
66029           if (roles.indexOf(member2.role) === -1) roles.push(member2.role);
66030         });
66031         membership2.role = roles.length === 1 ? roles[0] : roles;
66032       });
66033       return memberships;
66034     }
66035     function selectRelation(d3_event, d2) {
66036       d3_event.preventDefault();
66037       utilHighlightEntities([d2.relation.id], false, context);
66038       context.enter(modeSelect(context, [d2.relation.id]));
66039     }
66040     function zoomToRelation(d3_event, d2) {
66041       d3_event.preventDefault();
66042       var entity = context.entity(d2.relation.id);
66043       context.map().zoomToEase(entity);
66044       utilHighlightEntities([d2.relation.id], true, context);
66045     }
66046     function changeRole(d3_event, d2) {
66047       if (d2 === 0) return;
66048       if (_inChange) return;
66049       var newRole = context.cleanRelationRole(select_default2(this).property("value"));
66050       if (!newRole.trim() && typeof d2.role !== "string") return;
66051       var membersToUpdate = d2.members.filter(function(member) {
66052         return member.role !== newRole;
66053       });
66054       if (membersToUpdate.length) {
66055         _inChange = true;
66056         context.perform(
66057           function actionChangeMemberRoles(graph) {
66058             membersToUpdate.forEach(function(member) {
66059               var newMember = Object.assign({}, member, { role: newRole });
66060               delete newMember.index;
66061               graph = actionChangeMember(d2.relation.id, newMember, member.index)(graph);
66062             });
66063             return graph;
66064           },
66065           _t("operations.change_role.annotation", {
66066             n: membersToUpdate.length
66067           })
66068         );
66069         context.validator().validate();
66070       }
66071       _inChange = false;
66072     }
66073     function addMembership(d2, role) {
66074       _showBlank = false;
66075       function actionAddMembers(relationId, ids, role2) {
66076         return function(graph) {
66077           for (var i3 in ids) {
66078             var member = { id: ids[i3], type: graph.entity(ids[i3]).type, role: role2 };
66079             graph = actionAddMember(relationId, member)(graph);
66080           }
66081           return graph;
66082         };
66083       }
66084       if (d2.relation) {
66085         context.perform(
66086           actionAddMembers(d2.relation.id, _entityIDs, role),
66087           _t("operations.add_member.annotation", {
66088             n: _entityIDs.length
66089           })
66090         );
66091         context.validator().validate();
66092       } else {
66093         var relation = osmRelation();
66094         context.perform(
66095           actionAddEntity(relation),
66096           actionAddMembers(relation.id, _entityIDs, role),
66097           _t("operations.add.annotation.relation")
66098         );
66099         context.enter(modeSelect(context, [relation.id]).newFeature(true));
66100       }
66101     }
66102     function downloadMembers(d3_event, d2) {
66103       d3_event.preventDefault();
66104       const button = select_default2(this);
66105       button.classed("loading", true);
66106       context.loadEntity(d2.relation.id, function() {
66107         section.reRender();
66108       });
66109     }
66110     function deleteMembership(d3_event, d2) {
66111       this.blur();
66112       if (d2 === 0) return;
66113       utilHighlightEntities([d2.relation.id], false, context);
66114       var indexes = d2.members.map(function(member) {
66115         return member.index;
66116       });
66117       context.perform(
66118         actionDeleteMembers(d2.relation.id, indexes),
66119         _t("operations.delete_member.annotation", {
66120           n: _entityIDs.length
66121         })
66122       );
66123       context.validator().validate();
66124     }
66125     function fetchNearbyRelations(q2, callback) {
66126       var newRelation = {
66127         relation: null,
66128         value: _t("inspector.new_relation"),
66129         display: _t.append("inspector.new_relation")
66130       };
66131       var entityID = _entityIDs[0];
66132       var result = [];
66133       var graph = context.graph();
66134       function baseDisplayValue(entity) {
66135         var matched = _mainPresetIndex.match(entity, graph);
66136         var presetName = matched && matched.name() || _t("inspector.relation");
66137         var entityName = utilDisplayName(entity) || "";
66138         return presetName + " " + entityName;
66139       }
66140       function baseDisplayLabel(entity) {
66141         var matched = _mainPresetIndex.match(entity, graph);
66142         var presetName = matched && matched.name() || _t("inspector.relation");
66143         var entityName = utilDisplayName(entity) || "";
66144         return (selection2) => {
66145           selection2.append("b").text(presetName + " ");
66146           selection2.append("span").classed("has-colour", entity.tags.colour && isColourValid(entity.tags.colour)).style("border-color", entity.tags.colour).text(entityName);
66147         };
66148       }
66149       var explicitRelation = q2 && context.hasEntity(q2.toLowerCase());
66150       if (explicitRelation && explicitRelation.type === "relation" && explicitRelation.id !== entityID) {
66151         result.push({
66152           relation: explicitRelation,
66153           value: baseDisplayValue(explicitRelation) + " " + explicitRelation.id,
66154           display: baseDisplayLabel(explicitRelation)
66155         });
66156       } else {
66157         context.history().intersects(context.map().extent()).forEach(function(entity) {
66158           if (entity.type !== "relation" || entity.id === entityID) return;
66159           var value = baseDisplayValue(entity);
66160           if (q2 && (value + " " + entity.id).toLowerCase().indexOf(q2.toLowerCase()) === -1) return;
66161           result.push({
66162             relation: entity,
66163             value,
66164             display: baseDisplayLabel(entity)
66165           });
66166         });
66167         result.sort(function(a2, b2) {
66168           return osmRelation.creationOrder(a2.relation, b2.relation);
66169         });
66170         var dupeGroups = Object.values(utilArrayGroupBy(result, "value")).filter(function(v2) {
66171           return v2.length > 1;
66172         });
66173         dupeGroups.forEach(function(group) {
66174           group.forEach(function(obj) {
66175             obj.value += " " + obj.relation.id;
66176           });
66177         });
66178       }
66179       result.forEach(function(obj) {
66180         obj.title = obj.value;
66181       });
66182       result.unshift(newRelation);
66183       callback(result);
66184     }
66185     function renderDisclosureContent(selection2) {
66186       var memberships = getMemberships();
66187       var list2 = selection2.selectAll(".member-list").data([0]);
66188       list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
66189       var items = list2.selectAll("li.member-row-normal").data(memberships, function(d2) {
66190         return d2.hash;
66191       });
66192       items.exit().each(unbind).remove();
66193       var itemsEnter = items.enter().append("li").attr("class", "member-row member-row-normal form-field");
66194       itemsEnter.on("mouseover", function(d3_event, d2) {
66195         utilHighlightEntities([d2.relation.id], true, context);
66196       }).on("mouseout", function(d3_event, d2) {
66197         utilHighlightEntities([d2.relation.id], false, context);
66198       });
66199       var labelEnter = itemsEnter.append("label").attr("class", "field-label").attr("for", function(d2) {
66200         return d2.domId;
66201       });
66202       var labelLink = labelEnter.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectRelation);
66203       labelLink.append("span").attr("class", "member-entity-type").text(function(d2) {
66204         var matched = _mainPresetIndex.match(d2.relation, context.graph());
66205         return matched && matched.name() || _t.html("inspector.relation");
66206       });
66207       labelLink.append("span").attr("class", "member-entity-name").classed("has-colour", (d2) => d2.relation.tags.colour && isColourValid(d2.relation.tags.colour)).style("border-color", (d2) => d2.relation.tags.colour).html(function(d2) {
66208         const matched = _mainPresetIndex.match(d2.relation, context.graph());
66209         return utilDisplayName(d2.relation, matched.suggestion);
66210       });
66211       labelEnter.append("button").attr("class", "members-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMembers);
66212       labelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", deleteMembership);
66213       labelEnter.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToRelation);
66214       items = items.merge(itemsEnter);
66215       items.selectAll("button.members-download").classed("hide", (d2) => {
66216         const graph = context.graph();
66217         return d2.relation.members.every((m2) => graph.hasEntity(m2.id));
66218       });
66219       var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
66220       wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
66221         return d2.domId;
66222       }).property("type", "text").property("value", function(d2) {
66223         return typeof d2.role === "string" ? d2.role : "";
66224       }).attr("title", function(d2) {
66225         return Array.isArray(d2.role) ? d2.role.filter(Boolean).join("\n") : d2.role;
66226       }).attr("placeholder", function(d2) {
66227         return Array.isArray(d2.role) ? _t("inspector.multiple_roles") : _t("inspector.role");
66228       }).classed("mixed", function(d2) {
66229         return Array.isArray(d2.role);
66230       }).call(utilNoAuto).on("blur", changeRole).on("change", changeRole);
66231       if (taginfo) {
66232         wrapEnter.each(bindTypeahead);
66233       }
66234       var newMembership = list2.selectAll(".member-row-new").data(_showBlank ? [0] : []);
66235       newMembership.exit().remove();
66236       var newMembershipEnter = newMembership.enter().append("li").attr("class", "member-row member-row-new form-field");
66237       var newLabelEnter = newMembershipEnter.append("label").attr("class", "field-label");
66238       newLabelEnter.append("input").attr("placeholder", _t("inspector.choose_relation")).attr("type", "text").attr("class", "member-entity-input").call(utilNoAuto);
66239       newLabelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", function() {
66240         list2.selectAll(".member-row-new").remove();
66241       });
66242       var newWrapEnter = newMembershipEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
66243       newWrapEnter.append("input").attr("class", "member-role").property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
66244       newMembership = newMembership.merge(newMembershipEnter);
66245       newMembership.selectAll(".member-entity-input").on("blur", cancelEntity).call(
66246         nearbyCombo.on("accept", function(d2) {
66247           this.blur();
66248           acceptEntity.call(this, d2);
66249         }).on("cancel", cancelEntity)
66250       );
66251       var addRow = selection2.selectAll(".add-row").data([0]);
66252       var addRowEnter = addRow.enter().append("div").attr("class", "add-row");
66253       var addRelationButton = addRowEnter.append("button").attr("class", "add-relation").attr("aria-label", _t("inspector.add_to_relation"));
66254       addRelationButton.call(svgIcon("#iD-icon-plus", "light"));
66255       addRelationButton.call(uiTooltip().title(() => _t.append("inspector.add_to_relation")).placement(_mainLocalizer.textDirection() === "ltr" ? "right" : "left"));
66256       addRowEnter.append("div").attr("class", "space-value");
66257       addRowEnter.append("div").attr("class", "space-buttons");
66258       addRow = addRow.merge(addRowEnter);
66259       addRow.select(".add-relation").on("click", function() {
66260         _showBlank = true;
66261         section.reRender();
66262         list2.selectAll(".member-entity-input").node().focus();
66263       });
66264       function acceptEntity(d2) {
66265         if (!d2) {
66266           cancelEntity();
66267           return;
66268         }
66269         if (d2.relation) utilHighlightEntities([d2.relation.id], false, context);
66270         var role = context.cleanRelationRole(list2.selectAll(".member-row-new .member-role").property("value"));
66271         addMembership(d2, role);
66272       }
66273       function cancelEntity() {
66274         var input = newMembership.selectAll(".member-entity-input");
66275         input.property("value", "");
66276         context.surface().selectAll(".highlighted").classed("highlighted", false);
66277       }
66278       function bindTypeahead(d2) {
66279         var row = select_default2(this);
66280         var role = row.selectAll("input.member-role");
66281         var origValue = role.property("value");
66282         function sort(value, data) {
66283           var sameletter = [];
66284           var other2 = [];
66285           for (var i3 = 0; i3 < data.length; i3++) {
66286             if (data[i3].value.substring(0, value.length) === value) {
66287               sameletter.push(data[i3]);
66288             } else {
66289               other2.push(data[i3]);
66290             }
66291           }
66292           return sameletter.concat(other2);
66293         }
66294         role.call(
66295           uiCombobox(context, "member-role").fetcher(function(role2, callback) {
66296             var rtype = d2.relation.tags.type;
66297             taginfo.roles({
66298               debounce: true,
66299               rtype: rtype || "",
66300               geometry: context.graph().geometry(_entityIDs[0]),
66301               query: role2
66302             }, function(err, data) {
66303               if (!err) callback(sort(role2, data));
66304             });
66305           }).on("cancel", function() {
66306             role.property("value", origValue);
66307           })
66308         );
66309       }
66310       function unbind() {
66311         var row = select_default2(this);
66312         row.selectAll("input.member-role").call(uiCombobox.off, context);
66313       }
66314     }
66315     section.entityIDs = function(val) {
66316       if (!arguments.length) return _entityIDs;
66317       _entityIDs = val;
66318       _showBlank = false;
66319       return section;
66320     };
66321     return section;
66322   }
66323
66324   // modules/ui/sections/selection_list.js
66325   function uiSectionSelectionList(context) {
66326     var _selectedIDs = [];
66327     var section = uiSection("selected-features", context).shouldDisplay(function() {
66328       return _selectedIDs.length > 1;
66329     }).label(function() {
66330       return _t.append("inspector.title_count", { title: _t("inspector.features"), count: _selectedIDs.length });
66331     }).disclosureContent(renderDisclosureContent);
66332     context.history().on("change.selectionList", function(difference2) {
66333       if (difference2) {
66334         section.reRender();
66335       }
66336     });
66337     section.entityIDs = function(val) {
66338       if (!arguments.length) return _selectedIDs;
66339       _selectedIDs = val;
66340       return section;
66341     };
66342     function selectEntity(d3_event, entity) {
66343       context.enter(modeSelect(context, [entity.id]));
66344     }
66345     function deselectEntity(d3_event, entity) {
66346       var selectedIDs = _selectedIDs.slice();
66347       var index = selectedIDs.indexOf(entity.id);
66348       if (index > -1) {
66349         selectedIDs.splice(index, 1);
66350         context.enter(modeSelect(context, selectedIDs));
66351       }
66352     }
66353     function renderDisclosureContent(selection2) {
66354       var list2 = selection2.selectAll(".feature-list").data([0]);
66355       list2 = list2.enter().append("ul").attr("class", "feature-list").merge(list2);
66356       var entities = _selectedIDs.map(function(id2) {
66357         return context.hasEntity(id2);
66358       }).filter(Boolean);
66359       var items = list2.selectAll(".feature-list-item").data(entities, osmEntity.key);
66360       items.exit().remove();
66361       var enter = items.enter().append("li").attr("class", "feature-list-item").each(function(d2) {
66362         select_default2(this).on("mouseover", function() {
66363           utilHighlightEntities([d2.id], true, context);
66364         }).on("mouseout", function() {
66365           utilHighlightEntities([d2.id], false, context);
66366         });
66367       });
66368       var label = enter.append("button").attr("class", "label").on("click", selectEntity);
66369       label.append("span").attr("class", "entity-geom-icon").call(svgIcon("", "pre-text"));
66370       label.append("span").attr("class", "entity-type");
66371       label.append("span").attr("class", "entity-name");
66372       enter.append("button").attr("class", "close").attr("title", _t("icons.deselect")).on("click", deselectEntity).call(svgIcon("#iD-icon-close"));
66373       items = items.merge(enter);
66374       items.selectAll(".entity-geom-icon use").attr("href", function() {
66375         var entity = this.parentNode.parentNode.__data__;
66376         return "#iD-icon-" + entity.geometry(context.graph());
66377       });
66378       items.selectAll(".entity-type").text(function(entity) {
66379         return _mainPresetIndex.match(entity, context.graph()).name();
66380       });
66381       items.selectAll(".entity-name").text(function(d2) {
66382         var entity = context.entity(d2.id);
66383         return utilDisplayName(entity);
66384       });
66385     }
66386     return section;
66387   }
66388
66389   // modules/ui/entity_editor.js
66390   function uiEntityEditor(context) {
66391     var dispatch14 = dispatch_default("choose");
66392     var _state = "select";
66393     var _coalesceChanges = false;
66394     var _modified = false;
66395     var _base;
66396     var _entityIDs;
66397     var _activePresets = [];
66398     var _newFeature;
66399     var _sections;
66400     function entityEditor(selection2) {
66401       var combinedTags = utilCombinedTags(_entityIDs, context.graph());
66402       var header = selection2.selectAll(".header").data([0]);
66403       var headerEnter = header.enter().append("div").attr("class", "header fillL");
66404       var direction = _mainLocalizer.textDirection() === "rtl" ? "forward" : "backward";
66405       headerEnter.append("button").attr("class", "preset-reset preset-choose").attr("title", _t("inspector.back_tooltip")).call(svgIcon("#iD-icon-".concat(direction)));
66406       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
66407         context.enter(modeBrowse(context));
66408       }).call(svgIcon(_modified ? "#iD-icon-apply" : "#iD-icon-close"));
66409       headerEnter.append("h2");
66410       header = header.merge(headerEnter);
66411       header.selectAll("h2").text("").call(_entityIDs.length === 1 ? _t.append("inspector.edit") : _t.append("inspector.edit_features"));
66412       header.selectAll(".preset-reset").on("click", function() {
66413         dispatch14.call("choose", this, _activePresets);
66414       });
66415       var body = selection2.selectAll(".inspector-body").data([0]);
66416       var bodyEnter = body.enter().append("div").attr("class", "entity-editor inspector-body sep-top");
66417       body = body.merge(bodyEnter);
66418       if (!_sections) {
66419         _sections = [
66420           uiSectionSelectionList(context),
66421           uiSectionFeatureType(context).on("choose", function(presets) {
66422             dispatch14.call("choose", this, presets);
66423           }),
66424           uiSectionEntityIssues(context),
66425           uiSectionPresetFields(context).on("change", changeTags).on("revert", revertTags),
66426           uiSectionRawTagEditor("raw-tag-editor", context).on("change", changeTags),
66427           uiSectionRawMemberEditor(context),
66428           uiSectionRawMembershipEditor(context)
66429         ];
66430       }
66431       _sections.forEach(function(section) {
66432         if (section.entityIDs) {
66433           section.entityIDs(_entityIDs);
66434         }
66435         if (section.presets) {
66436           section.presets(_activePresets);
66437         }
66438         if (section.tags) {
66439           section.tags(combinedTags);
66440         }
66441         if (section.state) {
66442           section.state(_state);
66443         }
66444         body.call(section.render);
66445       });
66446       context.history().on("change.entity-editor", historyChanged);
66447       function historyChanged(difference2) {
66448         if (selection2.selectAll(".entity-editor").empty()) return;
66449         if (_state === "hide") return;
66450         var significant = !difference2 || difference2.didChange.properties || difference2.didChange.addition || difference2.didChange.deletion;
66451         if (!significant) return;
66452         _entityIDs = _entityIDs.filter(context.hasEntity);
66453         if (!_entityIDs.length) return;
66454         var priorActivePreset = _activePresets.length === 1 && _activePresets[0];
66455         loadActivePresets();
66456         var graph = context.graph();
66457         entityEditor.modified(_base !== graph);
66458         entityEditor(selection2);
66459         if (priorActivePreset && _activePresets.length === 1 && priorActivePreset !== _activePresets[0]) {
66460           context.container().selectAll(".entity-editor button.preset-reset .label").style("background-color", "#fff").transition().duration(750).style("background-color", null);
66461         }
66462       }
66463     }
66464     function changeTags(entityIDs, changed, onInput) {
66465       var actions = [];
66466       for (var i3 in entityIDs) {
66467         var entityID = entityIDs[i3];
66468         var entity = context.entity(entityID);
66469         var tags = Object.assign({}, entity.tags);
66470         if (typeof changed === "function") {
66471           tags = changed(tags);
66472         } else {
66473           for (var k2 in changed) {
66474             if (!k2) continue;
66475             var v2 = changed[k2];
66476             if (typeof v2 === "object") {
66477               tags[k2] = tags[v2.oldKey];
66478             } else if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
66479               tags[k2] = v2;
66480             }
66481           }
66482         }
66483         if (!onInput) {
66484           tags = utilCleanTags(tags);
66485         }
66486         if (!(0, import_fast_deep_equal9.default)(entity.tags, tags)) {
66487           actions.push(actionChangeTags(entityID, tags));
66488         }
66489       }
66490       if (actions.length) {
66491         var combinedAction = function(graph) {
66492           actions.forEach(function(action) {
66493             graph = action(graph);
66494           });
66495           return graph;
66496         };
66497         var annotation = _t("operations.change_tags.annotation");
66498         if (_coalesceChanges) {
66499           context.overwrite(combinedAction, annotation);
66500         } else {
66501           context.perform(combinedAction, annotation);
66502           _coalesceChanges = !!onInput;
66503         }
66504       }
66505       if (!onInput) {
66506         context.validator().validate();
66507       }
66508     }
66509     function revertTags(keys2) {
66510       var actions = [];
66511       for (var i3 in _entityIDs) {
66512         var entityID = _entityIDs[i3];
66513         var original = context.graph().base().entities[entityID];
66514         var changed = {};
66515         for (var j2 in keys2) {
66516           var key = keys2[j2];
66517           changed[key] = original ? original.tags[key] : void 0;
66518         }
66519         var entity = context.entity(entityID);
66520         var tags = Object.assign({}, entity.tags);
66521         for (var k2 in changed) {
66522           if (!k2) continue;
66523           var v2 = changed[k2];
66524           if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
66525             tags[k2] = v2;
66526           }
66527         }
66528         tags = utilCleanTags(tags);
66529         if (!(0, import_fast_deep_equal9.default)(entity.tags, tags)) {
66530           actions.push(actionChangeTags(entityID, tags));
66531         }
66532       }
66533       if (actions.length) {
66534         var combinedAction = function(graph) {
66535           actions.forEach(function(action) {
66536             graph = action(graph);
66537           });
66538           return graph;
66539         };
66540         var annotation = _t("operations.change_tags.annotation");
66541         if (_coalesceChanges) {
66542           context.overwrite(combinedAction, annotation);
66543         } else {
66544           context.perform(combinedAction, annotation);
66545           _coalesceChanges = false;
66546         }
66547       }
66548       context.validator().validate();
66549     }
66550     entityEditor.modified = function(val) {
66551       if (!arguments.length) return _modified;
66552       _modified = val;
66553       return entityEditor;
66554     };
66555     entityEditor.state = function(val) {
66556       if (!arguments.length) return _state;
66557       _state = val;
66558       return entityEditor;
66559     };
66560     entityEditor.entityIDs = function(val) {
66561       if (!arguments.length) return _entityIDs;
66562       _base = context.graph();
66563       _coalesceChanges = false;
66564       if (val && _entityIDs && utilArrayIdentical(_entityIDs, val)) return entityEditor;
66565       _entityIDs = val;
66566       loadActivePresets(true);
66567       return entityEditor.modified(false);
66568     };
66569     entityEditor.newFeature = function(val) {
66570       if (!arguments.length) return _newFeature;
66571       _newFeature = val;
66572       return entityEditor;
66573     };
66574     function loadActivePresets(isForNewSelection) {
66575       var graph = context.graph();
66576       var counts = {};
66577       for (var i3 in _entityIDs) {
66578         var entity = graph.hasEntity(_entityIDs[i3]);
66579         if (!entity) return;
66580         var match = _mainPresetIndex.match(entity, graph);
66581         if (!counts[match.id]) counts[match.id] = 0;
66582         counts[match.id] += 1;
66583       }
66584       var matches = Object.keys(counts).sort(function(p1, p2) {
66585         return counts[p2] - counts[p1];
66586       }).map(function(pID) {
66587         return _mainPresetIndex.item(pID);
66588       });
66589       if (!isForNewSelection) {
66590         var weakPreset = _activePresets.length === 1 && !_activePresets[0].isFallback() && Object.keys(_activePresets[0].addTags || {}).length === 0;
66591         if (weakPreset && matches.length === 1 && matches[0].isFallback()) return;
66592       }
66593       entityEditor.presets(matches);
66594     }
66595     entityEditor.presets = function(val) {
66596       if (!arguments.length) return _activePresets;
66597       if (!utilArrayIdentical(val, _activePresets)) {
66598         _activePresets = val;
66599       }
66600       return entityEditor;
66601     };
66602     return utilRebind(entityEditor, dispatch14, "on");
66603   }
66604
66605   // modules/ui/preset_list.js
66606   function uiPresetList(context) {
66607     var dispatch14 = dispatch_default("cancel", "choose");
66608     var _entityIDs;
66609     var _currLoc;
66610     var _currentPresets;
66611     var _autofocus = false;
66612     function presetList(selection2) {
66613       if (!_entityIDs) return;
66614       var presets = _mainPresetIndex.matchAllGeometry(entityGeometries());
66615       selection2.html("");
66616       var messagewrap = selection2.append("div").attr("class", "header fillL");
66617       var message = messagewrap.append("h2").call(_t.append("inspector.choose"));
66618       var direction = _mainLocalizer.textDirection() === "rtl" ? "backward" : "forward";
66619       messagewrap.append("button").attr("class", "preset-choose").attr("title", _entityIDs.length === 1 ? _t("inspector.edit") : _t("inspector.edit_features")).on("click", function() {
66620         dispatch14.call("cancel", this);
66621       }).call(svgIcon("#iD-icon-".concat(direction)));
66622       function initialKeydown(d3_event) {
66623         if (search.property("value").length === 0 && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) {
66624           d3_event.preventDefault();
66625           d3_event.stopPropagation();
66626           operationDelete(context, _entityIDs)();
66627         } else if (search.property("value").length === 0 && (d3_event.ctrlKey || d3_event.metaKey) && d3_event.keyCode === utilKeybinding.keyCodes.z) {
66628           d3_event.preventDefault();
66629           d3_event.stopPropagation();
66630           context.undo();
66631         } else if (!d3_event.ctrlKey && !d3_event.metaKey) {
66632           select_default2(this).on("keydown", keydown);
66633           keydown.call(this, d3_event);
66634         }
66635       }
66636       function keydown(d3_event) {
66637         if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"] && // if insertion point is at the end of the string
66638         search.node().selectionStart === search.property("value").length) {
66639           d3_event.preventDefault();
66640           d3_event.stopPropagation();
66641           var buttons = list2.selectAll(".preset-list-button");
66642           if (!buttons.empty()) buttons.nodes()[0].focus();
66643         }
66644       }
66645       function keypress(d3_event) {
66646         var value = search.property("value");
66647         if (d3_event.keyCode === 13 && // ↩ Return
66648         value.length) {
66649           list2.selectAll(".preset-list-item:first-child").each(function(d2) {
66650             d2.choose.call(this);
66651           });
66652         }
66653       }
66654       function inputevent() {
66655         var value = search.property("value");
66656         list2.classed("filtered", value.length);
66657         var results, messageText;
66658         if (value.length) {
66659           results = presets.search(value, entityGeometries()[0], _currLoc);
66660           messageText = _t.html("inspector.results", {
66661             n: results.collection.length,
66662             search: value
66663           });
66664         } else {
66665           var entityPresets2 = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
66666           results = _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets2);
66667           messageText = _t.html("inspector.choose");
66668         }
66669         list2.call(drawList, results);
66670         message.html(messageText);
66671       }
66672       var searchWrap = selection2.append("div").attr("class", "search-header");
66673       searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
66674       var search = searchWrap.append("input").attr("class", "preset-search-input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keydown", initialKeydown).on("keypress", keypress).on("input", debounce_default(inputevent));
66675       if (_autofocus) {
66676         search.node().focus();
66677         setTimeout(function() {
66678           search.node().focus();
66679         }, 0);
66680       }
66681       var listWrap = selection2.append("div").attr("class", "inspector-body");
66682       var entityPresets = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
66683       var list2 = listWrap.append("div").attr("class", "preset-list").call(drawList, _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets));
66684       context.features().on("change.preset-list", updateForFeatureHiddenState);
66685     }
66686     function drawList(list2, presets) {
66687       presets = presets.matchAllGeometry(entityGeometries());
66688       var collection = presets.collection.reduce(function(collection2, preset) {
66689         if (!preset) return collection2;
66690         if (preset.members) {
66691           if (preset.members.collection.filter(function(preset2) {
66692             return preset2.addable();
66693           }).length > 1) {
66694             collection2.push(CategoryItem(preset));
66695           }
66696         } else if (preset.addable()) {
66697           collection2.push(PresetItem(preset));
66698         }
66699         return collection2;
66700       }, []);
66701       var items = list2.selectAll(".preset-list-item").data(collection, function(d2) {
66702         return d2.preset.id;
66703       });
66704       items.order();
66705       items.exit().remove();
66706       items.enter().append("div").attr("class", function(item) {
66707         return "preset-list-item preset-" + item.preset.id.replace("/", "-");
66708       }).classed("current", function(item) {
66709         return _currentPresets.indexOf(item.preset) !== -1;
66710       }).each(function(item) {
66711         select_default2(this).call(item);
66712       }).style("opacity", 0).transition().style("opacity", 1);
66713       updateForFeatureHiddenState();
66714     }
66715     function itemKeydown(d3_event) {
66716       var item = select_default2(this.closest(".preset-list-item"));
66717       var parentItem = select_default2(item.node().parentNode.closest(".preset-list-item"));
66718       if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"]) {
66719         d3_event.preventDefault();
66720         d3_event.stopPropagation();
66721         var nextItem = select_default2(item.node().nextElementSibling);
66722         if (nextItem.empty()) {
66723           if (!parentItem.empty()) {
66724             nextItem = select_default2(parentItem.node().nextElementSibling);
66725           }
66726         } else if (select_default2(this).classed("expanded")) {
66727           nextItem = item.select(".subgrid .preset-list-item:first-child");
66728         }
66729         if (!nextItem.empty()) {
66730           nextItem.select(".preset-list-button").node().focus();
66731         }
66732       } else if (d3_event.keyCode === utilKeybinding.keyCodes["\u2191"]) {
66733         d3_event.preventDefault();
66734         d3_event.stopPropagation();
66735         var previousItem = select_default2(item.node().previousElementSibling);
66736         if (previousItem.empty()) {
66737           if (!parentItem.empty()) {
66738             previousItem = parentItem;
66739           }
66740         } else if (previousItem.select(".preset-list-button").classed("expanded")) {
66741           previousItem = previousItem.select(".subgrid .preset-list-item:last-child");
66742         }
66743         if (!previousItem.empty()) {
66744           previousItem.select(".preset-list-button").node().focus();
66745         } else {
66746           var search = select_default2(this.closest(".preset-list-pane")).select(".preset-search-input");
66747           search.node().focus();
66748         }
66749       } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
66750         d3_event.preventDefault();
66751         d3_event.stopPropagation();
66752         if (!parentItem.empty()) {
66753           parentItem.select(".preset-list-button").node().focus();
66754         }
66755       } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
66756         d3_event.preventDefault();
66757         d3_event.stopPropagation();
66758         item.datum().choose.call(select_default2(this).node());
66759       }
66760     }
66761     function CategoryItem(preset) {
66762       var box, sublist, shown = false;
66763       function item(selection2) {
66764         var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap category");
66765         function click() {
66766           var isExpanded = select_default2(this).classed("expanded");
66767           var iconName = isExpanded ? _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" : "#iD-icon-down";
66768           select_default2(this).classed("expanded", !isExpanded).attr("title", !isExpanded ? _t("icons.collapse") : _t("icons.expand"));
66769           select_default2(this).selectAll("div.label-inner svg.icon use").attr("href", iconName);
66770           item.choose();
66771         }
66772         var geometries = entityGeometries();
66773         var button = wrap2.append("button").attr("class", "preset-list-button").attr("title", _t("icons.expand")).classed("expanded", false).call(uiPresetIcon().geometry(geometries.length === 1 && geometries[0]).preset(preset)).on("click", click).on("keydown", function(d3_event) {
66774           if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
66775             d3_event.preventDefault();
66776             d3_event.stopPropagation();
66777             if (!select_default2(this).classed("expanded")) {
66778               click.call(this, d3_event);
66779             }
66780           } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
66781             d3_event.preventDefault();
66782             d3_event.stopPropagation();
66783             if (select_default2(this).classed("expanded")) {
66784               click.call(this, d3_event);
66785             }
66786           } else {
66787             itemKeydown.call(this, d3_event);
66788           }
66789         });
66790         var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
66791         label.append("div").attr("class", "namepart").call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward", "inline")).append("span").call(preset.nameLabel()).append("span").text("\u2026");
66792         box = selection2.append("div").attr("class", "subgrid").style("max-height", "0px").style("opacity", 0);
66793         box.append("div").attr("class", "arrow");
66794         sublist = box.append("div").attr("class", "preset-list fillL3");
66795       }
66796       item.choose = function() {
66797         if (!box || !sublist) return;
66798         if (shown) {
66799           shown = false;
66800           box.transition().duration(200).style("opacity", "0").style("max-height", "0px").style("padding-bottom", "0px");
66801         } else {
66802           shown = true;
66803           var members = preset.members.matchAllGeometry(entityGeometries());
66804           sublist.call(drawList, members);
66805           box.transition().duration(200).style("opacity", "1").style("max-height", 200 + members.collection.length * 190 + "px").style("padding-bottom", "10px");
66806         }
66807       };
66808       item.preset = preset;
66809       return item;
66810     }
66811     function PresetItem(preset) {
66812       function item(selection2) {
66813         var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap");
66814         var geometries = entityGeometries();
66815         var button = wrap2.append("button").attr("class", "preset-list-button").call(uiPresetIcon().geometry(geometries.length === 1 && geometries[0]).preset(preset)).on("click", item.choose).on("keydown", itemKeydown);
66816         var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
66817         var nameparts = [
66818           preset.nameLabel(),
66819           preset.subtitleLabel()
66820         ].filter(Boolean);
66821         label.selectAll(".namepart").data(nameparts, (d2) => d2.stringId).enter().append("div").attr("class", "namepart").text("").each(function(d2) {
66822           d2(select_default2(this));
66823         });
66824         wrap2.call(item.reference.button);
66825         selection2.call(item.reference.body);
66826       }
66827       item.choose = function() {
66828         if (select_default2(this).classed("disabled")) return;
66829         if (!context.inIntro()) {
66830           _mainPresetIndex.setMostRecent(preset, entityGeometries()[0]);
66831         }
66832         context.perform(
66833           function(graph) {
66834             for (var i3 in _entityIDs) {
66835               var entityID = _entityIDs[i3];
66836               var oldPreset = _mainPresetIndex.match(graph.entity(entityID), graph);
66837               graph = actionChangePreset(entityID, oldPreset, preset)(graph);
66838             }
66839             return graph;
66840           },
66841           _t("operations.change_tags.annotation")
66842         );
66843         context.validator().validate();
66844         dispatch14.call("choose", this, preset);
66845       };
66846       item.help = function(d3_event) {
66847         d3_event.stopPropagation();
66848         item.reference.toggle();
66849       };
66850       item.preset = preset;
66851       item.reference = uiTagReference(preset.reference(), context);
66852       return item;
66853     }
66854     function updateForFeatureHiddenState() {
66855       if (!_entityIDs.every(context.hasEntity)) return;
66856       var geometries = entityGeometries();
66857       var button = context.container().selectAll(".preset-list .preset-list-button");
66858       button.call(uiTooltip().destroyAny);
66859       button.each(function(item, index) {
66860         var hiddenPresetFeaturesId;
66861         for (var i3 in geometries) {
66862           hiddenPresetFeaturesId = context.features().isHiddenPreset(item.preset, geometries[i3]);
66863           if (hiddenPresetFeaturesId) break;
66864         }
66865         var isHiddenPreset = !context.inIntro() && !!hiddenPresetFeaturesId && (_currentPresets.length !== 1 || item.preset !== _currentPresets[0]);
66866         select_default2(this).classed("disabled", isHiddenPreset);
66867         if (isHiddenPreset) {
66868           var isAutoHidden = context.features().autoHidden(hiddenPresetFeaturesId);
66869           select_default2(this).call(
66870             uiTooltip().title(() => _t.append("inspector.hidden_preset." + (isAutoHidden ? "zoom" : "manual"), {
66871               features: _t("feature." + hiddenPresetFeaturesId + ".description")
66872             })).placement(index < 2 ? "bottom" : "top")
66873           );
66874         }
66875       });
66876     }
66877     presetList.autofocus = function(val) {
66878       if (!arguments.length) return _autofocus;
66879       _autofocus = val;
66880       return presetList;
66881     };
66882     presetList.entityIDs = function(val) {
66883       if (!arguments.length) return _entityIDs;
66884       _entityIDs = val;
66885       _currLoc = null;
66886       if (_entityIDs && _entityIDs.length) {
66887         const extent = _entityIDs.reduce(function(extent2, entityID) {
66888           var entity = context.graph().entity(entityID);
66889           return extent2.extend(entity.extent(context.graph()));
66890         }, geoExtent());
66891         _currLoc = extent.center();
66892         var presets = _entityIDs.map(function(entityID) {
66893           return _mainPresetIndex.match(context.entity(entityID), context.graph());
66894         });
66895         presetList.presets(presets);
66896       }
66897       return presetList;
66898     };
66899     presetList.presets = function(val) {
66900       if (!arguments.length) return _currentPresets;
66901       _currentPresets = val;
66902       return presetList;
66903     };
66904     function entityGeometries() {
66905       var counts = {};
66906       for (var i3 in _entityIDs) {
66907         var entityID = _entityIDs[i3];
66908         var entity = context.entity(entityID);
66909         var geometry = entity.geometry(context.graph());
66910         if (geometry === "vertex" && entity.isOnAddressLine(context.graph())) {
66911           geometry = "point";
66912         }
66913         if (!counts[geometry]) counts[geometry] = 0;
66914         counts[geometry] += 1;
66915       }
66916       return Object.keys(counts).sort(function(geom1, geom2) {
66917         return counts[geom2] - counts[geom1];
66918       });
66919     }
66920     return utilRebind(presetList, dispatch14, "on");
66921   }
66922
66923   // modules/ui/inspector.js
66924   function uiInspector(context) {
66925     var presetList = uiPresetList(context);
66926     var entityEditor = uiEntityEditor(context);
66927     var wrap2 = select_default2(null), presetPane = select_default2(null), editorPane = select_default2(null);
66928     var _state = "select";
66929     var _entityIDs;
66930     var _newFeature = false;
66931     function inspector(selection2) {
66932       presetList.entityIDs(_entityIDs).autofocus(_newFeature).on("choose", inspector.setPreset).on("cancel", function() {
66933         inspector.setPreset();
66934       });
66935       entityEditor.state(_state).entityIDs(_entityIDs).on("choose", inspector.showList);
66936       wrap2 = selection2.selectAll(".panewrap").data([0]);
66937       var enter = wrap2.enter().append("div").attr("class", "panewrap");
66938       enter.append("div").attr("class", "preset-list-pane pane");
66939       enter.append("div").attr("class", "entity-editor-pane pane");
66940       wrap2 = wrap2.merge(enter);
66941       presetPane = wrap2.selectAll(".preset-list-pane");
66942       editorPane = wrap2.selectAll(".entity-editor-pane");
66943       function shouldDefaultToPresetList() {
66944         if (_state !== "select") return false;
66945         if (_entityIDs.length !== 1) return false;
66946         var entityID = _entityIDs[0];
66947         var entity = context.hasEntity(entityID);
66948         if (!entity) return false;
66949         if (entity.hasNonGeometryTags()) return false;
66950         if (_newFeature) return true;
66951         if (entity.geometry(context.graph()) !== "vertex") return false;
66952         if (context.graph().parentRelations(entity).length) return false;
66953         if (context.validator().getEntityIssues(entityID).length) return false;
66954         if (entity.isHighwayIntersection(context.graph())) return false;
66955         return true;
66956       }
66957       if (shouldDefaultToPresetList()) {
66958         wrap2.style("right", "-100%");
66959         editorPane.classed("hide", true);
66960         presetPane.classed("hide", false).call(presetList);
66961       } else {
66962         wrap2.style("right", "0%");
66963         presetPane.classed("hide", true);
66964         editorPane.classed("hide", false).call(entityEditor);
66965       }
66966       var footer = selection2.selectAll(".footer").data([0]);
66967       footer = footer.enter().append("div").attr("class", "footer").merge(footer);
66968       footer.call(
66969         uiViewOnOSM(context).what(context.hasEntity(_entityIDs.length === 1 && _entityIDs[0]))
66970       );
66971     }
66972     inspector.showList = function(presets) {
66973       presetPane.classed("hide", false);
66974       wrap2.transition().styleTween("right", function() {
66975         return value_default("0%", "-100%");
66976       }).on("end", function() {
66977         editorPane.classed("hide", true);
66978       });
66979       if (presets) {
66980         presetList.presets(presets);
66981       }
66982       presetPane.call(presetList.autofocus(true));
66983     };
66984     inspector.setPreset = function(preset) {
66985       if (preset && preset.id === "type/multipolygon") {
66986         presetPane.call(presetList.autofocus(true));
66987       } else {
66988         editorPane.classed("hide", false);
66989         wrap2.transition().styleTween("right", function() {
66990           return value_default("-100%", "0%");
66991         }).on("end", function() {
66992           presetPane.classed("hide", true);
66993         });
66994         if (preset) {
66995           entityEditor.presets([preset]);
66996         }
66997         editorPane.call(entityEditor);
66998       }
66999     };
67000     inspector.state = function(val) {
67001       if (!arguments.length) return _state;
67002       _state = val;
67003       entityEditor.state(_state);
67004       context.container().selectAll(".field-help-body").remove();
67005       return inspector;
67006     };
67007     inspector.entityIDs = function(val) {
67008       if (!arguments.length) return _entityIDs;
67009       _entityIDs = val;
67010       return inspector;
67011     };
67012     inspector.newFeature = function(val) {
67013       if (!arguments.length) return _newFeature;
67014       _newFeature = val;
67015       return inspector;
67016     };
67017     return inspector;
67018   }
67019
67020   // modules/ui/keepRight_details.js
67021   function uiKeepRightDetails(context) {
67022     let _qaItem;
67023     function issueDetail(d2) {
67024       const { itemType, parentIssueType } = d2;
67025       const unknown = { html: _t.html("inspector.unknown") };
67026       let replacements = d2.replacements || {};
67027       replacements.default = unknown;
67028       if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
67029         return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".description"), replacements);
67030       } else {
67031         return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".description"), replacements);
67032       }
67033     }
67034     function keepRightDetails(selection2) {
67035       const details = selection2.selectAll(".error-details").data(
67036         _qaItem ? [_qaItem] : [],
67037         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
67038       );
67039       details.exit().remove();
67040       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
67041       const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection");
67042       descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description"));
67043       descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail);
67044       let relatedEntities = [];
67045       descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() {
67046         const link3 = select_default2(this);
67047         const isObjectLink = link3.classed("error_object_link");
67048         const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent;
67049         const entity = context.hasEntity(entityID);
67050         relatedEntities.push(entityID);
67051         link3.on("mouseenter", () => {
67052           utilHighlightEntities([entityID], true, context);
67053         }).on("mouseleave", () => {
67054           utilHighlightEntities([entityID], false, context);
67055         }).on("click", (d3_event) => {
67056           d3_event.preventDefault();
67057           utilHighlightEntities([entityID], false, context);
67058           const osmlayer = context.layers().layer("osm");
67059           if (!osmlayer.enabled()) {
67060             osmlayer.enabled(true);
67061           }
67062           context.map().centerZoomEase(_qaItem.loc, 20);
67063           if (entity) {
67064             context.enter(modeSelect(context, [entityID]));
67065           } else {
67066             context.loadEntity(entityID, (err, result) => {
67067               if (err) return;
67068               const entity2 = result.data.find((e3) => e3.id === entityID);
67069               if (entity2) context.enter(modeSelect(context, [entityID]));
67070             });
67071           }
67072         });
67073         if (entity) {
67074           let name = utilDisplayName(entity);
67075           if (!name && !isObjectLink) {
67076             const preset = _mainPresetIndex.match(entity, context.graph());
67077             name = preset && !preset.isFallback() && preset.name();
67078           }
67079           if (name) {
67080             this.innerText = name;
67081           }
67082         }
67083       });
67084       context.features().forceVisible(relatedEntities);
67085       context.map().pan([0, 0]);
67086     }
67087     keepRightDetails.issue = function(val) {
67088       if (!arguments.length) return _qaItem;
67089       _qaItem = val;
67090       return keepRightDetails;
67091     };
67092     return keepRightDetails;
67093   }
67094
67095   // modules/ui/keepRight_header.js
67096   function uiKeepRightHeader() {
67097     let _qaItem;
67098     function issueTitle(d2) {
67099       const { itemType, parentIssueType } = d2;
67100       const unknown = _t.html("inspector.unknown");
67101       let replacements = d2.replacements || {};
67102       replacements.default = { html: unknown };
67103       if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
67104         return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".title"), replacements);
67105       } else {
67106         return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".title"), replacements);
67107       }
67108     }
67109     function keepRightHeader(selection2) {
67110       const header = selection2.selectAll(".qa-header").data(
67111         _qaItem ? [_qaItem] : [],
67112         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
67113       );
67114       header.exit().remove();
67115       const headerEnter = header.enter().append("div").attr("class", "qa-header");
67116       const iconEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0);
67117       iconEnter.append("div").attr("class", (d2) => "preset-icon-28 qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.parentIssueType)).call(svgIcon("#iD-icon-bolt", "qaItem-fill"));
67118       headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle);
67119     }
67120     keepRightHeader.issue = function(val) {
67121       if (!arguments.length) return _qaItem;
67122       _qaItem = val;
67123       return keepRightHeader;
67124     };
67125     return keepRightHeader;
67126   }
67127
67128   // modules/ui/view_on_keepRight.js
67129   function uiViewOnKeepRight() {
67130     let _qaItem;
67131     function viewOnKeepRight(selection2) {
67132       let url;
67133       if (services.keepRight && _qaItem instanceof QAItem) {
67134         url = services.keepRight.issueURL(_qaItem);
67135       }
67136       const link3 = selection2.selectAll(".view-on-keepRight").data(url ? [url] : []);
67137       link3.exit().remove();
67138       const linkEnter = link3.enter().append("a").attr("class", "view-on-keepRight").attr("target", "_blank").attr("rel", "noopener").attr("href", (d2) => d2).call(svgIcon("#iD-icon-out-link", "inline"));
67139       linkEnter.append("span").call(_t.append("inspector.view_on_keepRight"));
67140     }
67141     viewOnKeepRight.what = function(val) {
67142       if (!arguments.length) return _qaItem;
67143       _qaItem = val;
67144       return viewOnKeepRight;
67145     };
67146     return viewOnKeepRight;
67147   }
67148
67149   // modules/ui/keepRight_editor.js
67150   function uiKeepRightEditor(context) {
67151     const dispatch14 = dispatch_default("change");
67152     const qaDetails = uiKeepRightDetails(context);
67153     const qaHeader = uiKeepRightHeader(context);
67154     let _qaItem;
67155     function keepRightEditor(selection2) {
67156       const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
67157       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
67158       headerEnter.append("h2").call(_t.append("QA.keepRight.title"));
67159       let body = selection2.selectAll(".body").data([0]);
67160       body = body.enter().append("div").attr("class", "body").merge(body);
67161       const editor = body.selectAll(".qa-editor").data([0]);
67162       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(keepRightSaveSection);
67163       const footer = selection2.selectAll(".footer").data([0]);
67164       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnKeepRight(context).what(_qaItem));
67165     }
67166     function keepRightSaveSection(selection2) {
67167       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
67168       const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment);
67169       let saveSection = selection2.selectAll(".qa-save").data(
67170         isShown ? [_qaItem] : [],
67171         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
67172       );
67173       saveSection.exit().remove();
67174       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
67175       saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("QA.keepRight.comment"));
67176       saveSectionEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("QA.keepRight.comment_placeholder")).attr("maxlength", 1e3).property("value", (d2) => d2.newComment || d2.comment).call(utilNoAuto).on("input", changeInput).on("blur", changeInput);
67177       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
67178       function changeInput() {
67179         const input = select_default2(this);
67180         let val = input.property("value").trim();
67181         if (val === _qaItem.comment) {
67182           val = void 0;
67183         }
67184         _qaItem = _qaItem.update({ newComment: val });
67185         const qaService = services.keepRight;
67186         if (qaService) {
67187           qaService.replaceItem(_qaItem);
67188         }
67189         saveSection.call(qaSaveButtons);
67190       }
67191     }
67192     function qaSaveButtons(selection2) {
67193       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
67194       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
67195       buttonSection.exit().remove();
67196       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
67197       buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment"));
67198       buttonEnter.append("button").attr("class", "button close-button action");
67199       buttonEnter.append("button").attr("class", "button ignore-button action");
67200       buttonSection = buttonSection.merge(buttonEnter);
67201       buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) {
67202         this.blur();
67203         const qaService = services.keepRight;
67204         if (qaService) {
67205           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
67206         }
67207       });
67208       buttonSection.select(".close-button").html((d2) => {
67209         const andComment = d2.newComment ? "_comment" : "";
67210         return _t.html("QA.keepRight.close".concat(andComment));
67211       }).on("click.close", function(d3_event, d2) {
67212         this.blur();
67213         const qaService = services.keepRight;
67214         if (qaService) {
67215           d2.newStatus = "ignore_t";
67216           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
67217         }
67218       });
67219       buttonSection.select(".ignore-button").html((d2) => {
67220         const andComment = d2.newComment ? "_comment" : "";
67221         return _t.html("QA.keepRight.ignore".concat(andComment));
67222       }).on("click.ignore", function(d3_event, d2) {
67223         this.blur();
67224         const qaService = services.keepRight;
67225         if (qaService) {
67226           d2.newStatus = "ignore";
67227           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
67228         }
67229       });
67230     }
67231     keepRightEditor.error = function(val) {
67232       if (!arguments.length) return _qaItem;
67233       _qaItem = val;
67234       return keepRightEditor;
67235     };
67236     return utilRebind(keepRightEditor, dispatch14, "on");
67237   }
67238
67239   // modules/ui/osmose_details.js
67240   function uiOsmoseDetails(context) {
67241     let _qaItem;
67242     function issueString(d2, type2) {
67243       if (!d2) return "";
67244       const s2 = services.osmose.getStrings(d2.itemType);
67245       return type2 in s2 ? s2[type2] : "";
67246     }
67247     function osmoseDetails(selection2) {
67248       const details = selection2.selectAll(".error-details").data(
67249         _qaItem ? [_qaItem] : [],
67250         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
67251       );
67252       details.exit().remove();
67253       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
67254       if (issueString(_qaItem, "detail")) {
67255         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
67256         div.append("h4").call(_t.append("QA.keepRight.detail_description"));
67257         div.append("p").attr("class", "qa-details-description-text").html((d2) => issueString(d2, "detail")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
67258       }
67259       const detailsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
67260       const elemsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
67261       if (issueString(_qaItem, "fix")) {
67262         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
67263         div.append("h4").call(_t.append("QA.osmose.fix_title"));
67264         div.append("p").html((d2) => issueString(d2, "fix")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
67265       }
67266       if (issueString(_qaItem, "trap")) {
67267         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
67268         div.append("h4").call(_t.append("QA.osmose.trap_title"));
67269         div.append("p").html((d2) => issueString(d2, "trap")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
67270       }
67271       const thisItem = _qaItem;
67272       services.osmose.loadIssueDetail(_qaItem).then((d2) => {
67273         if (!d2.elems || d2.elems.length === 0) return;
67274         if (context.selectedErrorID() !== thisItem.id && context.container().selectAll(".qaItem.osmose.hover.itemId-".concat(thisItem.id)).empty()) return;
67275         if (d2.detail) {
67276           detailsDiv.append("h4").call(_t.append("QA.osmose.detail_title"));
67277           detailsDiv.append("p").html((d4) => d4.detail).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
67278         }
67279         elemsDiv.append("h4").call(_t.append("QA.osmose.elems_title"));
67280         elemsDiv.append("ul").selectAll("li").data(d2.elems).enter().append("li").append("a").attr("href", "#").attr("class", "error_entity_link").text((d4) => d4).each(function() {
67281           const link3 = select_default2(this);
67282           const entityID = this.textContent;
67283           const entity = context.hasEntity(entityID);
67284           link3.on("mouseenter", () => {
67285             utilHighlightEntities([entityID], true, context);
67286           }).on("mouseleave", () => {
67287             utilHighlightEntities([entityID], false, context);
67288           }).on("click", (d3_event) => {
67289             d3_event.preventDefault();
67290             utilHighlightEntities([entityID], false, context);
67291             const osmlayer = context.layers().layer("osm");
67292             if (!osmlayer.enabled()) {
67293               osmlayer.enabled(true);
67294             }
67295             context.map().centerZoom(d2.loc, 20);
67296             if (entity) {
67297               context.enter(modeSelect(context, [entityID]));
67298             } else {
67299               context.loadEntity(entityID, (err, result) => {
67300                 if (err) return;
67301                 const entity2 = result.data.find((e3) => e3.id === entityID);
67302                 if (entity2) context.enter(modeSelect(context, [entityID]));
67303               });
67304             }
67305           });
67306           if (entity) {
67307             let name = utilDisplayName(entity);
67308             if (!name) {
67309               const preset = _mainPresetIndex.match(entity, context.graph());
67310               name = preset && !preset.isFallback() && preset.name();
67311             }
67312             if (name) {
67313               this.innerText = name;
67314             }
67315           }
67316         });
67317         context.features().forceVisible(d2.elems);
67318         context.map().pan([0, 0]);
67319       }).catch((err) => {
67320         console.log(err);
67321       });
67322     }
67323     osmoseDetails.issue = function(val) {
67324       if (!arguments.length) return _qaItem;
67325       _qaItem = val;
67326       return osmoseDetails;
67327     };
67328     return osmoseDetails;
67329   }
67330
67331   // modules/ui/osmose_header.js
67332   function uiOsmoseHeader() {
67333     let _qaItem;
67334     function issueTitle(d2) {
67335       const unknown = _t("inspector.unknown");
67336       if (!d2) return unknown;
67337       const s2 = services.osmose.getStrings(d2.itemType);
67338       return "title" in s2 ? s2.title : unknown;
67339     }
67340     function osmoseHeader(selection2) {
67341       const header = selection2.selectAll(".qa-header").data(
67342         _qaItem ? [_qaItem] : [],
67343         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
67344       );
67345       header.exit().remove();
67346       const headerEnter = header.enter().append("div").attr("class", "qa-header");
67347       const svgEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0).append("svg").attr("width", "20px").attr("height", "30px").attr("viewbox", "0 0 20 30").attr("class", (d2) => "preset-icon-28 qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
67348       svgEnter.append("polygon").attr("fill", (d2) => services.osmose.getColor(d2.item)).attr("class", "qaItem-fill").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6");
67349       svgEnter.append("use").attr("class", "icon-annotation").attr("width", "12px").attr("height", "12px").attr("transform", "translate(4, 5.5)").attr("xlink:href", (d2) => d2.icon ? "#" + d2.icon : "");
67350       headerEnter.append("div").attr("class", "qa-header-label").text(issueTitle);
67351     }
67352     osmoseHeader.issue = function(val) {
67353       if (!arguments.length) return _qaItem;
67354       _qaItem = val;
67355       return osmoseHeader;
67356     };
67357     return osmoseHeader;
67358   }
67359
67360   // modules/ui/view_on_osmose.js
67361   function uiViewOnOsmose() {
67362     let _qaItem;
67363     function viewOnOsmose(selection2) {
67364       let url;
67365       if (services.osmose && _qaItem instanceof QAItem) {
67366         url = services.osmose.itemURL(_qaItem);
67367       }
67368       const link3 = selection2.selectAll(".view-on-osmose").data(url ? [url] : []);
67369       link3.exit().remove();
67370       const linkEnter = link3.enter().append("a").attr("class", "view-on-osmose").attr("target", "_blank").attr("rel", "noopener").attr("href", (d2) => d2).call(svgIcon("#iD-icon-out-link", "inline"));
67371       linkEnter.append("span").call(_t.append("inspector.view_on_osmose"));
67372     }
67373     viewOnOsmose.what = function(val) {
67374       if (!arguments.length) return _qaItem;
67375       _qaItem = val;
67376       return viewOnOsmose;
67377     };
67378     return viewOnOsmose;
67379   }
67380
67381   // modules/ui/osmose_editor.js
67382   function uiOsmoseEditor(context) {
67383     const dispatch14 = dispatch_default("change");
67384     const qaDetails = uiOsmoseDetails(context);
67385     const qaHeader = uiOsmoseHeader(context);
67386     let _qaItem;
67387     function osmoseEditor(selection2) {
67388       const header = selection2.selectAll(".header").data([0]);
67389       const headerEnter = header.enter().append("div").attr("class", "header fillL");
67390       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
67391       headerEnter.append("h2").call(_t.append("QA.osmose.title"));
67392       let body = selection2.selectAll(".body").data([0]);
67393       body = body.enter().append("div").attr("class", "body").merge(body);
67394       let editor = body.selectAll(".qa-editor").data([0]);
67395       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(osmoseSaveSection);
67396       const footer = selection2.selectAll(".footer").data([0]);
67397       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOsmose(context).what(_qaItem));
67398     }
67399     function osmoseSaveSection(selection2) {
67400       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
67401       const isShown = _qaItem && isSelected;
67402       let saveSection = selection2.selectAll(".qa-save").data(
67403         isShown ? [_qaItem] : [],
67404         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
67405       );
67406       saveSection.exit().remove();
67407       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
67408       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
67409     }
67410     function qaSaveButtons(selection2) {
67411       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
67412       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
67413       buttonSection.exit().remove();
67414       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
67415       buttonEnter.append("button").attr("class", "button close-button action");
67416       buttonEnter.append("button").attr("class", "button ignore-button action");
67417       buttonSection = buttonSection.merge(buttonEnter);
67418       buttonSection.select(".close-button").call(_t.append("QA.keepRight.close")).on("click.close", function(d3_event, d2) {
67419         this.blur();
67420         const qaService = services.osmose;
67421         if (qaService) {
67422           d2.newStatus = "done";
67423           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
67424         }
67425       });
67426       buttonSection.select(".ignore-button").call(_t.append("QA.keepRight.ignore")).on("click.ignore", function(d3_event, d2) {
67427         this.blur();
67428         const qaService = services.osmose;
67429         if (qaService) {
67430           d2.newStatus = "false";
67431           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
67432         }
67433       });
67434     }
67435     osmoseEditor.error = function(val) {
67436       if (!arguments.length) return _qaItem;
67437       _qaItem = val;
67438       return osmoseEditor;
67439     };
67440     return utilRebind(osmoseEditor, dispatch14, "on");
67441   }
67442
67443   // modules/ui/sidebar.js
67444   function uiSidebar(context) {
67445     var inspector = uiInspector(context);
67446     var dataEditor = uiDataEditor(context);
67447     var noteEditor = uiNoteEditor(context);
67448     var keepRightEditor = uiKeepRightEditor(context);
67449     var osmoseEditor = uiOsmoseEditor(context);
67450     var _current;
67451     var _wasData = false;
67452     var _wasNote = false;
67453     var _wasQaItem = false;
67454     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
67455     function sidebar(selection2) {
67456       var container = context.container();
67457       var minWidth = 240;
67458       var sidebarWidth;
67459       var containerWidth;
67460       var dragOffset;
67461       selection2.style("min-width", minWidth + "px").style("max-width", "400px").style("width", "33.3333%");
67462       var resizer = selection2.append("div").attr("class", "sidebar-resizer").on(_pointerPrefix + "down.sidebar-resizer", pointerdown);
67463       var downPointerId, lastClientX, containerLocGetter;
67464       function pointerdown(d3_event) {
67465         if (downPointerId) return;
67466         if ("button" in d3_event && d3_event.button !== 0) return;
67467         downPointerId = d3_event.pointerId || "mouse";
67468         lastClientX = d3_event.clientX;
67469         containerLocGetter = utilFastMouse(container.node());
67470         dragOffset = utilFastMouse(resizer.node())(d3_event)[0] - 1;
67471         sidebarWidth = selection2.node().getBoundingClientRect().width;
67472         containerWidth = container.node().getBoundingClientRect().width;
67473         var widthPct = sidebarWidth / containerWidth * 100;
67474         selection2.style("width", widthPct + "%").style("max-width", "85%");
67475         resizer.classed("dragging", true);
67476         select_default2(window).on("touchmove.sidebar-resizer", function(d3_event2) {
67477           d3_event2.preventDefault();
67478         }, { passive: false }).on(_pointerPrefix + "move.sidebar-resizer", pointermove).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", pointerup);
67479       }
67480       function pointermove(d3_event) {
67481         if (downPointerId !== (d3_event.pointerId || "mouse")) return;
67482         d3_event.preventDefault();
67483         var dx = d3_event.clientX - lastClientX;
67484         lastClientX = d3_event.clientX;
67485         var isRTL = _mainLocalizer.textDirection() === "rtl";
67486         var scaleX = isRTL ? 0 : 1;
67487         var xMarginProperty = isRTL ? "margin-right" : "margin-left";
67488         var x2 = containerLocGetter(d3_event)[0] - dragOffset;
67489         sidebarWidth = isRTL ? containerWidth - x2 : x2;
67490         var isCollapsed = selection2.classed("collapsed");
67491         var shouldCollapse = sidebarWidth < minWidth;
67492         selection2.classed("collapsed", shouldCollapse);
67493         if (shouldCollapse) {
67494           if (!isCollapsed) {
67495             selection2.style(xMarginProperty, "-400px").style("width", "400px");
67496             context.ui().onResize([(sidebarWidth - dx) * scaleX, 0]);
67497           }
67498         } else {
67499           var widthPct = sidebarWidth / containerWidth * 100;
67500           selection2.style(xMarginProperty, null).style("width", widthPct + "%");
67501           if (isCollapsed) {
67502             context.ui().onResize([-sidebarWidth * scaleX, 0]);
67503           } else {
67504             context.ui().onResize([-dx * scaleX, 0]);
67505           }
67506         }
67507       }
67508       function pointerup(d3_event) {
67509         if (downPointerId !== (d3_event.pointerId || "mouse")) return;
67510         downPointerId = null;
67511         resizer.classed("dragging", false);
67512         select_default2(window).on("touchmove.sidebar-resizer", null).on(_pointerPrefix + "move.sidebar-resizer", null).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", null);
67513       }
67514       var featureListWrap = selection2.append("div").attr("class", "feature-list-pane").call(uiFeatureList(context));
67515       var inspectorWrap = selection2.append("div").attr("class", "inspector-hidden inspector-wrap");
67516       var hoverModeSelect = function(targets) {
67517         context.container().selectAll(".feature-list-item button").classed("hover", false);
67518         if (context.selectedIDs().length > 1 && targets && targets.length) {
67519           var elements = context.container().selectAll(".feature-list-item button").filter(function(node) {
67520             return targets.indexOf(node) !== -1;
67521           });
67522           if (!elements.empty()) {
67523             elements.classed("hover", true);
67524           }
67525         }
67526       };
67527       sidebar.hoverModeSelect = throttle_default(hoverModeSelect, 200);
67528       function hover(targets) {
67529         var datum2 = targets && targets.length && targets[0];
67530         if (datum2 && datum2.__featurehash__) {
67531           _wasData = true;
67532           sidebar.show(dataEditor.datum(datum2));
67533           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
67534         } else if (datum2 instanceof osmNote) {
67535           if (context.mode().id === "drag-note") return;
67536           _wasNote = true;
67537           var osm = services.osm;
67538           if (osm) {
67539             datum2 = osm.getNote(datum2.id);
67540           }
67541           sidebar.show(noteEditor.note(datum2));
67542           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
67543         } else if (datum2 instanceof QAItem) {
67544           _wasQaItem = true;
67545           var errService = services[datum2.service];
67546           if (errService) {
67547             datum2 = errService.getError(datum2.id);
67548           }
67549           var errEditor;
67550           if (datum2.service === "keepRight") {
67551             errEditor = keepRightEditor;
67552           } else {
67553             errEditor = osmoseEditor;
67554           }
67555           context.container().selectAll(".qaItem." + datum2.service).classed("hover", function(d2) {
67556             return d2.id === datum2.id;
67557           });
67558           sidebar.show(errEditor.error(datum2));
67559           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
67560         } else if (!_current && datum2 instanceof osmEntity) {
67561           featureListWrap.classed("inspector-hidden", true);
67562           inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", true);
67563           if (!inspector.entityIDs() || !utilArrayIdentical(inspector.entityIDs(), [datum2.id]) || inspector.state() !== "hover") {
67564             inspector.state("hover").entityIDs([datum2.id]).newFeature(false);
67565             inspectorWrap.call(inspector);
67566           }
67567         } else if (!_current) {
67568           featureListWrap.classed("inspector-hidden", false);
67569           inspectorWrap.classed("inspector-hidden", true);
67570           inspector.state("hide");
67571         } else if (_wasData || _wasNote || _wasQaItem) {
67572           _wasNote = false;
67573           _wasData = false;
67574           _wasQaItem = false;
67575           context.container().selectAll(".note").classed("hover", false);
67576           context.container().selectAll(".qaItem").classed("hover", false);
67577           sidebar.hide();
67578         }
67579       }
67580       sidebar.hover = throttle_default(hover, 200);
67581       sidebar.intersects = function(extent) {
67582         var rect = selection2.node().getBoundingClientRect();
67583         return extent.intersects([
67584           context.projection.invert([0, rect.height]),
67585           context.projection.invert([rect.width, 0])
67586         ]);
67587       };
67588       sidebar.select = function(ids, newFeature) {
67589         sidebar.hide();
67590         if (ids && ids.length) {
67591           var entity = ids.length === 1 && context.entity(ids[0]);
67592           if (entity && newFeature && selection2.classed("collapsed")) {
67593             var extent = entity.extent(context.graph());
67594             sidebar.expand(sidebar.intersects(extent));
67595           }
67596           featureListWrap.classed("inspector-hidden", true);
67597           inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", false);
67598           inspector.state("select").entityIDs(ids).newFeature(newFeature);
67599           inspectorWrap.call(inspector);
67600         } else {
67601           inspector.state("hide");
67602         }
67603       };
67604       sidebar.showPresetList = function() {
67605         inspector.showList();
67606       };
67607       sidebar.show = function(component, element) {
67608         featureListWrap.classed("inspector-hidden", true);
67609         inspectorWrap.classed("inspector-hidden", true);
67610         if (_current) _current.remove();
67611         _current = selection2.append("div").attr("class", "sidebar-component").call(component, element);
67612       };
67613       sidebar.hide = function() {
67614         featureListWrap.classed("inspector-hidden", false);
67615         inspectorWrap.classed("inspector-hidden", true);
67616         if (_current) _current.remove();
67617         _current = null;
67618       };
67619       sidebar.expand = function(moveMap) {
67620         if (selection2.classed("collapsed")) {
67621           sidebar.toggle(moveMap);
67622         }
67623       };
67624       sidebar.collapse = function(moveMap) {
67625         if (!selection2.classed("collapsed")) {
67626           sidebar.toggle(moveMap);
67627         }
67628       };
67629       sidebar.toggle = function(moveMap) {
67630         if (context.inIntro()) return;
67631         var isCollapsed = selection2.classed("collapsed");
67632         var isCollapsing = !isCollapsed;
67633         var isRTL = _mainLocalizer.textDirection() === "rtl";
67634         var scaleX = isRTL ? 0 : 1;
67635         var xMarginProperty = isRTL ? "margin-right" : "margin-left";
67636         sidebarWidth = selection2.node().getBoundingClientRect().width;
67637         selection2.style("width", sidebarWidth + "px");
67638         var startMargin, endMargin, lastMargin;
67639         if (isCollapsing) {
67640           startMargin = lastMargin = 0;
67641           endMargin = -sidebarWidth;
67642         } else {
67643           startMargin = lastMargin = -sidebarWidth;
67644           endMargin = 0;
67645         }
67646         if (!isCollapsing) {
67647           selection2.classed("collapsed", isCollapsing);
67648         }
67649         selection2.transition().style(xMarginProperty, endMargin + "px").tween("panner", function() {
67650           var i3 = number_default(startMargin, endMargin);
67651           return function(t2) {
67652             var dx = lastMargin - Math.round(i3(t2));
67653             lastMargin = lastMargin - dx;
67654             context.ui().onResize(moveMap ? void 0 : [dx * scaleX, 0]);
67655           };
67656         }).on("end", function() {
67657           if (isCollapsing) {
67658             selection2.classed("collapsed", isCollapsing);
67659           }
67660           if (!isCollapsing) {
67661             var containerWidth2 = container.node().getBoundingClientRect().width;
67662             var widthPct = sidebarWidth / containerWidth2 * 100;
67663             selection2.style(xMarginProperty, null).style("width", widthPct + "%");
67664           }
67665         });
67666       };
67667       resizer.on("dblclick", function(d3_event) {
67668         d3_event.preventDefault();
67669         if (d3_event.sourceEvent) {
67670           d3_event.sourceEvent.preventDefault();
67671         }
67672         sidebar.toggle();
67673       });
67674       context.map().on("crossEditableZoom.sidebar", function(within) {
67675         if (!within && !selection2.select(".inspector-hover").empty()) {
67676           hover([]);
67677         }
67678       });
67679     }
67680     sidebar.showPresetList = function() {
67681     };
67682     sidebar.hover = function() {
67683     };
67684     sidebar.hover.cancel = function() {
67685     };
67686     sidebar.intersects = function() {
67687     };
67688     sidebar.select = function() {
67689     };
67690     sidebar.show = function() {
67691     };
67692     sidebar.hide = function() {
67693     };
67694     sidebar.expand = function() {
67695     };
67696     sidebar.collapse = function() {
67697     };
67698     sidebar.toggle = function() {
67699     };
67700     return sidebar;
67701   }
67702
67703   // modules/ui/source_switch.js
67704   function uiSourceSwitch(context) {
67705     var keys2;
67706     function click(d3_event) {
67707       d3_event.preventDefault();
67708       var osm = context.connection();
67709       if (!osm) return;
67710       if (context.inIntro()) return;
67711       if (context.history().hasChanges() && !window.confirm(_t("source_switch.lose_changes"))) return;
67712       var isLive = select_default2(this).classed("live");
67713       isLive = !isLive;
67714       context.enter(modeBrowse(context));
67715       context.history().clearSaved();
67716       context.flush();
67717       select_default2(this).html(isLive ? _t.html("source_switch.live") : _t.html("source_switch.dev")).classed("live", isLive).classed("chip", isLive);
67718       osm.switch(isLive ? keys2[0] : keys2[1]);
67719     }
67720     var sourceSwitch = function(selection2) {
67721       selection2.append("a").attr("href", "#").call(_t.append("source_switch.live")).attr("class", "live chip").on("click", click);
67722     };
67723     sourceSwitch.keys = function(_2) {
67724       if (!arguments.length) return keys2;
67725       keys2 = _2;
67726       return sourceSwitch;
67727     };
67728     return sourceSwitch;
67729   }
67730
67731   // modules/ui/spinner.js
67732   function uiSpinner(context) {
67733     var osm = context.connection();
67734     return function(selection2) {
67735       var img = selection2.append("img").attr("src", context.imagePath("loader-black.gif")).style("opacity", 0);
67736       if (osm) {
67737         osm.on("loading.spinner", function() {
67738           img.transition().style("opacity", 1);
67739         }).on("loaded.spinner", function() {
67740           img.transition().style("opacity", 0);
67741         });
67742       }
67743     };
67744   }
67745
67746   // modules/ui/sections/privacy.js
67747   function uiSectionPrivacy(context) {
67748     let section = uiSection("preferences-third-party", context).label(() => _t.append("preferences.privacy.title")).disclosureContent(renderDisclosureContent);
67749     function renderDisclosureContent(selection2) {
67750       selection2.selectAll(".privacy-options-list").data([0]).enter().append("ul").attr("class", "layer-list privacy-options-list");
67751       let thirdPartyIconsEnter = selection2.select(".privacy-options-list").selectAll(".privacy-third-party-icons-item").data([corePreferences("preferences.privacy.thirdpartyicons") || "true"]).enter().append("li").attr("class", "privacy-third-party-icons-item").append("label").call(
67752         uiTooltip().title(() => _t.append("preferences.privacy.third_party_icons.tooltip")).placement("bottom")
67753       );
67754       thirdPartyIconsEnter.append("input").attr("type", "checkbox").on("change", (d3_event, d2) => {
67755         d3_event.preventDefault();
67756         corePreferences("preferences.privacy.thirdpartyicons", d2 === "true" ? "false" : "true");
67757       });
67758       thirdPartyIconsEnter.append("span").call(_t.append("preferences.privacy.third_party_icons.description"));
67759       selection2.selectAll(".privacy-third-party-icons-item").classed("active", (d2) => d2 === "true").select("input").property("checked", (d2) => d2 === "true");
67760       selection2.selectAll(".privacy-link").data([0]).enter().append("div").attr("class", "privacy-link").append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/openstreetmap/iD/blob/release/PRIVACY.md").append("span").call(_t.append("preferences.privacy.privacy_link"));
67761     }
67762     corePreferences.onChange("preferences.privacy.thirdpartyicons", section.reRender);
67763     return section;
67764   }
67765
67766   // modules/ui/splash.js
67767   function uiSplash(context) {
67768     return (selection2) => {
67769       if (context.history().hasRestorableChanges()) return;
67770       let updateMessage = "";
67771       const sawPrivacyVersion = corePreferences("sawPrivacyVersion");
67772       let showSplash = !corePreferences("sawSplash");
67773       if (sawPrivacyVersion !== context.privacyVersion) {
67774         updateMessage = _t("splash.privacy_update");
67775         showSplash = true;
67776       }
67777       if (!showSplash) return;
67778       corePreferences("sawSplash", true);
67779       corePreferences("sawPrivacyVersion", context.privacyVersion);
67780       _mainFileFetcher.get("intro_graph");
67781       let modalSelection = uiModal(selection2);
67782       modalSelection.select(".modal").attr("class", "modal-splash modal");
67783       let introModal = modalSelection.select(".content").append("div").attr("class", "fillL");
67784       introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("splash.welcome"));
67785       let modalSection = introModal.append("div").attr("class", "modal-section");
67786       modalSection.append("p").html(_t.html("splash.text", {
67787         version: context.version,
67788         website: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/develop/CHANGELOG.md#whats-new">' + _t.html("splash.changelog") + "</a>" },
67789         github: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/issues">github.com</a>' }
67790       }));
67791       modalSection.append("p").html(_t.html("splash.privacy", {
67792         updateMessage,
67793         privacyLink: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/release/PRIVACY.md">' + _t("splash.privacy_policy") + "</a>" }
67794       }));
67795       uiSectionPrivacy(context).label(() => _t.append("splash.privacy_settings")).render(modalSection);
67796       let buttonWrap = introModal.append("div").attr("class", "modal-actions");
67797       let walkthrough = buttonWrap.append("button").attr("class", "walkthrough").on("click", () => {
67798         context.container().call(uiIntro(context));
67799         modalSelection.close();
67800       });
67801       walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough");
67802       walkthrough.append("div").call(_t.append("splash.walkthrough"));
67803       let startEditing = buttonWrap.append("button").attr("class", "start-editing").on("click", modalSelection.close);
67804       startEditing.append("svg").attr("class", "logo logo-features").append("use").attr("xlink:href", "#iD-logo-features");
67805       startEditing.append("div").call(_t.append("splash.start"));
67806       modalSelection.select("button.close").attr("class", "hide");
67807     };
67808   }
67809
67810   // modules/ui/status.js
67811   function uiStatus(context) {
67812     var osm = context.connection();
67813     return function(selection2) {
67814       if (!osm) return;
67815       function update(err, apiStatus) {
67816         selection2.html("");
67817         if (err) {
67818           if (apiStatus === "connectionSwitched") {
67819             return;
67820           } else if (apiStatus === "rateLimited") {
67821             selection2.call(_t.append("osm_api_status.message.rateLimit")).append("a").attr("href", "#").attr("class", "api-status-login").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append("login")).on("click.login", function(d3_event) {
67822               d3_event.preventDefault();
67823               osm.authenticate();
67824             });
67825           } else {
67826             var throttledRetry = throttle_default(function() {
67827               context.loadTiles(context.projection);
67828               osm.reloadApiStatus();
67829             }, 2e3);
67830             selection2.call(_t.append("osm_api_status.message.error", { suffix: " " })).append("a").attr("href", "#").call(_t.append("osm_api_status.retry")).on("click.retry", function(d3_event) {
67831               d3_event.preventDefault();
67832               throttledRetry();
67833             });
67834           }
67835         } else if (apiStatus === "readonly") {
67836           selection2.call(_t.append("osm_api_status.message.readonly"));
67837         } else if (apiStatus === "offline") {
67838           selection2.call(_t.append("osm_api_status.message.offline"));
67839         }
67840         selection2.attr("class", "api-status " + (err ? "error" : apiStatus));
67841       }
67842       osm.on("apiStatusChange.uiStatus", update);
67843       context.history().on("storage_error", () => {
67844         selection2.selectAll("span.local-storage-full").remove();
67845         selection2.append("span").attr("class", "local-storage-full").call(_t.append("osm_api_status.message.local_storage_full"));
67846         selection2.classed("error", true);
67847       });
67848       window.setInterval(function() {
67849         osm.reloadApiStatus();
67850       }, 9e4);
67851       osm.reloadApiStatus();
67852     };
67853   }
67854
67855   // modules/ui/tools/modes.js
67856   function uiToolDrawModes(context) {
67857     var tool = {
67858       id: "old_modes",
67859       label: _t.append("toolbar.add_feature")
67860     };
67861     var modes = [
67862       modeAddPoint(context, {
67863         title: _t.append("modes.add_point.title"),
67864         button: "point",
67865         description: _t.append("modes.add_point.description"),
67866         preset: _mainPresetIndex.item("point"),
67867         key: "1"
67868       }),
67869       modeAddLine(context, {
67870         title: _t.append("modes.add_line.title"),
67871         button: "line",
67872         description: _t.append("modes.add_line.description"),
67873         preset: _mainPresetIndex.item("line"),
67874         key: "2"
67875       }),
67876       modeAddArea(context, {
67877         title: _t.append("modes.add_area.title"),
67878         button: "area",
67879         description: _t.append("modes.add_area.description"),
67880         preset: _mainPresetIndex.item("area"),
67881         key: "3"
67882       })
67883     ];
67884     function enabled(_mode) {
67885       return osmEditable();
67886     }
67887     function osmEditable() {
67888       return context.editable();
67889     }
67890     modes.forEach(function(mode) {
67891       context.keybinding().on(mode.key, function() {
67892         if (!enabled(mode)) return;
67893         if (mode.id === context.mode().id) {
67894           context.enter(modeBrowse(context));
67895         } else {
67896           context.enter(mode);
67897         }
67898       });
67899     });
67900     tool.render = function(selection2) {
67901       var wrap2 = selection2.append("div").attr("class", "joined").style("display", "flex");
67902       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
67903       context.map().on("move.modes", debouncedUpdate).on("drawn.modes", debouncedUpdate);
67904       context.on("enter.modes", update);
67905       update();
67906       function update() {
67907         var buttons = wrap2.selectAll("button.add-button").data(modes, function(d2) {
67908           return d2.id;
67909         });
67910         buttons.exit().remove();
67911         var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
67912           return d2.id + " add-button bar-button";
67913         }).on("click.mode-buttons", function(d3_event, d2) {
67914           if (!enabled(d2)) return;
67915           var currMode = context.mode().id;
67916           if (/^draw/.test(currMode)) return;
67917           if (d2.id === currMode) {
67918             context.enter(modeBrowse(context));
67919           } else {
67920             context.enter(d2);
67921           }
67922         }).call(
67923           uiTooltip().placement("bottom").title(function(d2) {
67924             return d2.description;
67925           }).keys(function(d2) {
67926             return [d2.key];
67927           }).scrollContainer(context.container().select(".top-toolbar"))
67928         );
67929         buttonsEnter.each(function(d2) {
67930           select_default2(this).call(svgIcon("#iD-icon-" + d2.button));
67931         });
67932         buttonsEnter.append("span").attr("class", "label").text("").each(function(mode) {
67933           mode.title(select_default2(this));
67934         });
67935         if (buttons.enter().size() || buttons.exit().size()) {
67936           context.ui().checkOverflow(".top-toolbar", true);
67937         }
67938         buttons = buttons.merge(buttonsEnter).attr("aria-disabled", function(d2) {
67939           return !enabled(d2);
67940         }).classed("disabled", function(d2) {
67941           return !enabled(d2);
67942         }).attr("aria-pressed", function(d2) {
67943           return context.mode() && context.mode().button === d2.button;
67944         }).classed("active", function(d2) {
67945           return context.mode() && context.mode().button === d2.button;
67946         });
67947       }
67948     };
67949     return tool;
67950   }
67951
67952   // modules/ui/tools/notes.js
67953   function uiToolNotes(context) {
67954     var tool = {
67955       id: "notes",
67956       label: _t.append("modes.add_note.label")
67957     };
67958     var mode = modeAddNote(context);
67959     function enabled() {
67960       return notesEnabled() && notesEditable();
67961     }
67962     function notesEnabled() {
67963       var noteLayer = context.layers().layer("notes");
67964       return noteLayer && noteLayer.enabled();
67965     }
67966     function notesEditable() {
67967       var mode2 = context.mode();
67968       return context.map().notesEditable() && mode2 && mode2.id !== "save";
67969     }
67970     context.keybinding().on(mode.key, function() {
67971       if (!enabled()) return;
67972       if (mode.id === context.mode().id) {
67973         context.enter(modeBrowse(context));
67974       } else {
67975         context.enter(mode);
67976       }
67977     });
67978     tool.render = function(selection2) {
67979       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
67980       context.map().on("move.notes", debouncedUpdate).on("drawn.notes", debouncedUpdate);
67981       context.on("enter.notes", update);
67982       update();
67983       function update() {
67984         var showNotes = notesEnabled();
67985         var data = showNotes ? [mode] : [];
67986         var buttons = selection2.selectAll("button.add-button").data(data, function(d2) {
67987           return d2.id;
67988         });
67989         buttons.exit().remove();
67990         var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
67991           return d2.id + " add-button bar-button";
67992         }).on("click.notes", function(d3_event, d2) {
67993           if (!enabled()) return;
67994           var currMode = context.mode().id;
67995           if (/^draw/.test(currMode)) return;
67996           if (d2.id === currMode) {
67997             context.enter(modeBrowse(context));
67998           } else {
67999             context.enter(d2);
68000           }
68001         }).call(
68002           uiTooltip().placement("bottom").title(function(d2) {
68003             return d2.description;
68004           }).keys(function(d2) {
68005             return [d2.key];
68006           }).scrollContainer(context.container().select(".top-toolbar"))
68007         );
68008         buttonsEnter.each(function(d2) {
68009           select_default2(this).call(svgIcon(d2.icon || "#iD-icon-" + d2.button));
68010         });
68011         if (buttons.enter().size() || buttons.exit().size()) {
68012           context.ui().checkOverflow(".top-toolbar", true);
68013         }
68014         buttons = buttons.merge(buttonsEnter).classed("disabled", function() {
68015           return !enabled();
68016         }).attr("aria-disabled", function() {
68017           return !enabled();
68018         }).classed("active", function(d2) {
68019           return context.mode() && context.mode().button === d2.button;
68020         }).attr("aria-pressed", function(d2) {
68021           return context.mode() && context.mode().button === d2.button;
68022         });
68023       }
68024     };
68025     tool.uninstall = function() {
68026       context.on("enter.editor.notes", null).on("exit.editor.notes", null).on("enter.notes", null);
68027       context.map().on("move.notes", null).on("drawn.notes", null);
68028     };
68029     return tool;
68030   }
68031
68032   // modules/ui/tools/save.js
68033   function uiToolSave(context) {
68034     var tool = {
68035       id: "save",
68036       label: _t.append("save.title")
68037     };
68038     var button = null;
68039     var tooltipBehavior = null;
68040     var history = context.history();
68041     var key = uiCmd("\u2318S");
68042     var _numChanges = 0;
68043     function isSaving() {
68044       var mode = context.mode();
68045       return mode && mode.id === "save";
68046     }
68047     function isDisabled() {
68048       return _numChanges === 0 || isSaving();
68049     }
68050     function save(d3_event) {
68051       d3_event.preventDefault();
68052       if (!context.inIntro() && !isSaving() && history.hasChanges()) {
68053         context.enter(modeSave(context));
68054       }
68055     }
68056     function bgColor(numChanges) {
68057       var step;
68058       if (numChanges === 0) {
68059         return null;
68060       } else if (numChanges <= 50) {
68061         step = numChanges / 50;
68062         return rgb_default("#fff", "#ff8")(step);
68063       } else {
68064         step = Math.min((numChanges - 50) / 50, 1);
68065         return rgb_default("#ff8", "#f88")(step);
68066       }
68067     }
68068     function updateCount() {
68069       var val = history.difference().summary().length;
68070       if (val === _numChanges) return;
68071       _numChanges = val;
68072       if (tooltipBehavior) {
68073         tooltipBehavior.title(() => _t.append(_numChanges > 0 ? "save.help" : "save.no_changes")).keys([key]);
68074       }
68075       if (button) {
68076         button.classed("disabled", isDisabled()).style("background", bgColor(_numChanges));
68077         button.select("span.count").text(_numChanges);
68078       }
68079     }
68080     tool.render = function(selection2) {
68081       tooltipBehavior = uiTooltip().placement("bottom").title(() => _t.append("save.no_changes")).keys([key]).scrollContainer(context.container().select(".top-toolbar"));
68082       var lastPointerUpType;
68083       button = selection2.append("button").attr("class", "save disabled bar-button").on("pointerup", function(d3_event) {
68084         lastPointerUpType = d3_event.pointerType;
68085       }).on("click", function(d3_event) {
68086         save(d3_event);
68087         if (_numChanges === 0 && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
68088           context.ui().flash.duration(2e3).iconName("#iD-icon-save").iconClass("disabled").label(_t.append("save.no_changes"))();
68089         }
68090         lastPointerUpType = null;
68091       }).call(tooltipBehavior);
68092       button.call(svgIcon("#iD-icon-save"));
68093       button.append("span").attr("class", "count").attr("aria-hidden", "true").text("0");
68094       updateCount();
68095       context.keybinding().on(key, save, true);
68096       context.history().on("change.save", updateCount);
68097       context.on("enter.save", function() {
68098         if (button) {
68099           button.classed("disabled", isDisabled());
68100           if (isSaving()) {
68101             button.call(tooltipBehavior.hide);
68102           }
68103         }
68104       });
68105     };
68106     tool.uninstall = function() {
68107       context.keybinding().off(key, true);
68108       context.history().on("change.save", null);
68109       context.on("enter.save", null);
68110       button = null;
68111       tooltipBehavior = null;
68112     };
68113     return tool;
68114   }
68115
68116   // modules/ui/tools/sidebar_toggle.js
68117   function uiToolSidebarToggle(context) {
68118     var tool = {
68119       id: "sidebar_toggle",
68120       label: _t.append("toolbar.inspect")
68121     };
68122     tool.render = function(selection2) {
68123       selection2.append("button").attr("class", "bar-button").attr("aria-label", _t("sidebar.tooltip")).on("click", function() {
68124         context.ui().sidebar.toggle();
68125       }).call(
68126         uiTooltip().placement("bottom").title(() => _t.append("sidebar.tooltip")).keys([_t("sidebar.key")]).scrollContainer(context.container().select(".top-toolbar"))
68127       ).call(svgIcon("#iD-icon-sidebar-" + (_mainLocalizer.textDirection() === "rtl" ? "right" : "left")));
68128     };
68129     return tool;
68130   }
68131
68132   // modules/ui/tools/undo_redo.js
68133   function uiToolUndoRedo(context) {
68134     var tool = {
68135       id: "undo_redo",
68136       label: _t.append("toolbar.undo_redo")
68137     };
68138     var commands = [{
68139       id: "undo",
68140       cmd: uiCmd("\u2318Z"),
68141       action: function() {
68142         context.undo();
68143       },
68144       annotation: function() {
68145         return context.history().undoAnnotation();
68146       },
68147       icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")
68148     }, {
68149       id: "redo",
68150       cmd: uiCmd("\u2318\u21E7Z"),
68151       action: function() {
68152         context.redo();
68153       },
68154       annotation: function() {
68155         return context.history().redoAnnotation();
68156       },
68157       icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "undo" : "redo")
68158     }];
68159     function editable() {
68160       return context.mode() && context.mode().id !== "save" && context.map().editableDataEnabled(
68161         true
68162         /* ignore min zoom */
68163       );
68164     }
68165     tool.render = function(selection2) {
68166       var tooltipBehavior = uiTooltip().placement("bottom").title(function(d2) {
68167         return d2.annotation() ? _t.append(d2.id + ".tooltip", { action: d2.annotation() }) : _t.append(d2.id + ".nothing");
68168       }).keys(function(d2) {
68169         return [d2.cmd];
68170       }).scrollContainer(context.container().select(".top-toolbar"));
68171       var lastPointerUpType;
68172       var buttons = selection2.selectAll("button").data(commands).enter().append("button").attr("class", function(d2) {
68173         return "disabled " + d2.id + "-button bar-button";
68174       }).on("pointerup", function(d3_event) {
68175         lastPointerUpType = d3_event.pointerType;
68176       }).on("click", function(d3_event, d2) {
68177         d3_event.preventDefault();
68178         var annotation = d2.annotation();
68179         if (editable() && annotation) {
68180           d2.action();
68181         }
68182         if (editable() && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
68183           var label = annotation ? _t.append(d2.id + ".tooltip", { action: annotation }) : _t.append(d2.id + ".nothing");
68184           context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass(annotation ? "" : "disabled").label(label)();
68185         }
68186         lastPointerUpType = null;
68187       }).call(tooltipBehavior);
68188       buttons.each(function(d2) {
68189         select_default2(this).call(svgIcon("#" + d2.icon));
68190       });
68191       context.keybinding().on(commands[0].cmd, function(d3_event) {
68192         d3_event.preventDefault();
68193         if (editable()) commands[0].action();
68194       }).on(commands[1].cmd, function(d3_event) {
68195         d3_event.preventDefault();
68196         if (editable()) commands[1].action();
68197       });
68198       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
68199       context.map().on("move.undo_redo", debouncedUpdate).on("drawn.undo_redo", debouncedUpdate);
68200       context.history().on("change.undo_redo", function(difference2) {
68201         if (difference2) update();
68202       });
68203       context.on("enter.undo_redo", update);
68204       function update() {
68205         buttons.classed("disabled", function(d2) {
68206           return !editable() || !d2.annotation();
68207         }).each(function() {
68208           var selection3 = select_default2(this);
68209           if (!selection3.select(".tooltip.in").empty()) {
68210             selection3.call(tooltipBehavior.updateContent);
68211           }
68212         });
68213       }
68214     };
68215     tool.uninstall = function() {
68216       context.keybinding().off(commands[0].cmd).off(commands[1].cmd);
68217       context.map().on("move.undo_redo", null).on("drawn.undo_redo", null);
68218       context.history().on("change.undo_redo", null);
68219       context.on("enter.undo_redo", null);
68220     };
68221     return tool;
68222   }
68223
68224   // modules/ui/top_toolbar.js
68225   function uiTopToolbar(context) {
68226     var sidebarToggle = uiToolSidebarToggle(context), modes = uiToolDrawModes(context), notes = uiToolNotes(context), undoRedo = uiToolUndoRedo(context), save = uiToolSave(context);
68227     function notesEnabled() {
68228       var noteLayer = context.layers().layer("notes");
68229       return noteLayer && noteLayer.enabled();
68230     }
68231     function topToolbar(bar) {
68232       bar.on("wheel.topToolbar", function(d3_event) {
68233         if (!d3_event.deltaX) {
68234           bar.node().scrollLeft += d3_event.deltaY;
68235         }
68236       });
68237       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
68238       context.layers().on("change.topToolbar", debouncedUpdate);
68239       update();
68240       function update() {
68241         var tools = [
68242           sidebarToggle,
68243           "spacer",
68244           modes
68245         ];
68246         tools.push("spacer");
68247         if (notesEnabled()) {
68248           tools = tools.concat([notes, "spacer"]);
68249         }
68250         tools = tools.concat([undoRedo, save]);
68251         var toolbarItems = bar.selectAll(".toolbar-item").data(tools, function(d2) {
68252           return d2.id || d2;
68253         });
68254         toolbarItems.exit().each(function(d2) {
68255           if (d2.uninstall) {
68256             d2.uninstall();
68257           }
68258         }).remove();
68259         var itemsEnter = toolbarItems.enter().append("div").attr("class", function(d2) {
68260           var classes = "toolbar-item " + (d2.id || d2).replace("_", "-");
68261           if (d2.klass) classes += " " + d2.klass;
68262           return classes;
68263         });
68264         var actionableItems = itemsEnter.filter(function(d2) {
68265           return d2 !== "spacer";
68266         });
68267         actionableItems.append("div").attr("class", "item-content").each(function(d2) {
68268           select_default2(this).call(d2.render, bar);
68269         });
68270         actionableItems.append("div").attr("class", "item-label").each(function(d2) {
68271           d2.label(select_default2(this));
68272         });
68273       }
68274     }
68275     return topToolbar;
68276   }
68277
68278   // modules/ui/version.js
68279   var sawVersion = null;
68280   var isNewVersion = false;
68281   var isNewUser = false;
68282   function uiVersion(context) {
68283     var currVersion = context.version;
68284     var matchedVersion = currVersion.match(/\d+\.\d+\.\d+.*/);
68285     if (sawVersion === null && matchedVersion !== null) {
68286       if (corePreferences("sawVersion")) {
68287         isNewUser = false;
68288         isNewVersion = corePreferences("sawVersion") !== currVersion && currVersion.indexOf("-") === -1;
68289       } else {
68290         isNewUser = true;
68291         isNewVersion = true;
68292       }
68293       corePreferences("sawVersion", currVersion);
68294       sawVersion = currVersion;
68295     }
68296     return function(selection2) {
68297       selection2.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD").text(currVersion);
68298       if (isNewVersion && !isNewUser) {
68299         selection2.append("a").attr("class", "badge").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD/blob/release/CHANGELOG.md#whats-new").call(svgIcon("#maki-gift")).call(
68300           uiTooltip().title(() => _t.append("version.whats_new", { version: currVersion })).placement("top").scrollContainer(context.container().select(".main-footer-wrap"))
68301         );
68302       }
68303     };
68304   }
68305
68306   // modules/ui/zoom.js
68307   function uiZoom(context) {
68308     var zooms = [{
68309       id: "zoom-in",
68310       icon: "iD-icon-plus",
68311       title: _t.append("zoom.in"),
68312       action: zoomIn,
68313       disabled: function() {
68314         return !context.map().canZoomIn();
68315       },
68316       disabledTitle: _t.append("zoom.disabled.in"),
68317       key: "+"
68318     }, {
68319       id: "zoom-out",
68320       icon: "iD-icon-minus",
68321       title: _t.append("zoom.out"),
68322       action: zoomOut,
68323       disabled: function() {
68324         return !context.map().canZoomOut();
68325       },
68326       disabledTitle: _t.append("zoom.disabled.out"),
68327       key: "-"
68328     }];
68329     function zoomIn(d3_event) {
68330       if (d3_event.shiftKey) return;
68331       d3_event.preventDefault();
68332       context.map().zoomIn();
68333     }
68334     function zoomOut(d3_event) {
68335       if (d3_event.shiftKey) return;
68336       d3_event.preventDefault();
68337       context.map().zoomOut();
68338     }
68339     function zoomInFurther(d3_event) {
68340       if (d3_event.shiftKey) return;
68341       d3_event.preventDefault();
68342       context.map().zoomInFurther();
68343     }
68344     function zoomOutFurther(d3_event) {
68345       if (d3_event.shiftKey) return;
68346       d3_event.preventDefault();
68347       context.map().zoomOutFurther();
68348     }
68349     return function(selection2) {
68350       var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function(d2) {
68351         if (d2.disabled()) {
68352           return d2.disabledTitle;
68353         }
68354         return d2.title;
68355       }).keys(function(d2) {
68356         return [d2.key];
68357       });
68358       var lastPointerUpType;
68359       var buttons = selection2.selectAll("button").data(zooms).enter().append("button").attr("class", function(d2) {
68360         return d2.id;
68361       }).on("pointerup.editor", function(d3_event) {
68362         lastPointerUpType = d3_event.pointerType;
68363       }).on("click.editor", function(d3_event, d2) {
68364         if (!d2.disabled()) {
68365           d2.action(d3_event);
68366         } else if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
68367           context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass("disabled").label(d2.disabledTitle)();
68368         }
68369         lastPointerUpType = null;
68370       }).call(tooltipBehavior);
68371       buttons.each(function(d2) {
68372         select_default2(this).call(svgIcon("#" + d2.icon, "light"));
68373       });
68374       utilKeybinding.plusKeys.forEach(function(key) {
68375         context.keybinding().on([key], zoomIn);
68376         context.keybinding().on([uiCmd("\u2325" + key)], zoomInFurther);
68377       });
68378       utilKeybinding.minusKeys.forEach(function(key) {
68379         context.keybinding().on([key], zoomOut);
68380         context.keybinding().on([uiCmd("\u2325" + key)], zoomOutFurther);
68381       });
68382       function updateButtonStates() {
68383         buttons.classed("disabled", function(d2) {
68384           return d2.disabled();
68385         }).each(function() {
68386           var selection3 = select_default2(this);
68387           if (!selection3.select(".tooltip.in").empty()) {
68388             selection3.call(tooltipBehavior.updateContent);
68389           }
68390         });
68391       }
68392       updateButtonStates();
68393       context.map().on("move.uiZoom", updateButtonStates);
68394     };
68395   }
68396
68397   // modules/ui/zoom_to_selection.js
68398   function uiZoomToSelection(context) {
68399     function isDisabled() {
68400       var mode = context.mode();
68401       return !mode || !mode.zoomToSelected;
68402     }
68403     var _lastPointerUpType;
68404     function pointerup(d3_event) {
68405       _lastPointerUpType = d3_event.pointerType;
68406     }
68407     function click(d3_event) {
68408       d3_event.preventDefault();
68409       if (isDisabled()) {
68410         if (_lastPointerUpType === "touch" || _lastPointerUpType === "pen") {
68411           context.ui().flash.duration(2e3).iconName("#iD-icon-framed-dot").iconClass("disabled").label(_t.append("inspector.zoom_to.no_selection"))();
68412         }
68413       } else {
68414         var mode = context.mode();
68415         if (mode && mode.zoomToSelected) {
68416           mode.zoomToSelected();
68417         }
68418       }
68419       _lastPointerUpType = null;
68420     }
68421     return function(selection2) {
68422       var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function() {
68423         if (isDisabled()) {
68424           return _t.append("inspector.zoom_to.no_selection");
68425         }
68426         return _t.append("inspector.zoom_to.title");
68427       }).keys([_t("inspector.zoom_to.key")]);
68428       var button = selection2.append("button").on("pointerup", pointerup).on("click", click).call(svgIcon("#iD-icon-framed-dot", "light")).call(tooltipBehavior);
68429       function setEnabledState() {
68430         button.classed("disabled", isDisabled());
68431         if (!button.select(".tooltip.in").empty()) {
68432           button.call(tooltipBehavior.updateContent);
68433         }
68434       }
68435       context.on("enter.uiZoomToSelection", setEnabledState);
68436       setEnabledState();
68437     };
68438   }
68439
68440   // modules/ui/pane.js
68441   function uiPane(id2, context) {
68442     var _key;
68443     var _label = "";
68444     var _description = "";
68445     var _iconName = "";
68446     var _sections;
68447     var _paneSelection = select_default2(null);
68448     var _paneTooltip;
68449     var pane = {
68450       id: id2
68451     };
68452     pane.label = function(val) {
68453       if (!arguments.length) return _label;
68454       _label = val;
68455       return pane;
68456     };
68457     pane.key = function(val) {
68458       if (!arguments.length) return _key;
68459       _key = val;
68460       return pane;
68461     };
68462     pane.description = function(val) {
68463       if (!arguments.length) return _description;
68464       _description = val;
68465       return pane;
68466     };
68467     pane.iconName = function(val) {
68468       if (!arguments.length) return _iconName;
68469       _iconName = val;
68470       return pane;
68471     };
68472     pane.sections = function(val) {
68473       if (!arguments.length) return _sections;
68474       _sections = val;
68475       return pane;
68476     };
68477     pane.selection = function() {
68478       return _paneSelection;
68479     };
68480     function hidePane() {
68481       context.ui().togglePanes();
68482     }
68483     pane.togglePane = function(d3_event) {
68484       if (d3_event) d3_event.preventDefault();
68485       _paneTooltip.hide();
68486       context.ui().togglePanes(!_paneSelection.classed("shown") ? _paneSelection : void 0);
68487     };
68488     pane.renderToggleButton = function(selection2) {
68489       if (!_paneTooltip) {
68490         _paneTooltip = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _description).keys([_key]);
68491       }
68492       selection2.append("button").on("click", pane.togglePane).call(svgIcon("#" + _iconName, "light")).call(_paneTooltip);
68493     };
68494     pane.renderContent = function(selection2) {
68495       if (_sections) {
68496         _sections.forEach(function(section) {
68497           selection2.call(section.render);
68498         });
68499       }
68500     };
68501     pane.renderPane = function(selection2) {
68502       _paneSelection = selection2.append("div").attr("class", "fillL map-pane hide " + id2 + "-pane").attr("pane", id2);
68503       var heading2 = _paneSelection.append("div").attr("class", "pane-heading");
68504       heading2.append("h2").text("").call(_label);
68505       heading2.append("button").attr("title", _t("icons.close")).on("click", hidePane).call(svgIcon("#iD-icon-close"));
68506       _paneSelection.append("div").attr("class", "pane-content").call(pane.renderContent);
68507       if (_key) {
68508         context.keybinding().on(_key, pane.togglePane);
68509       }
68510     };
68511     return pane;
68512   }
68513
68514   // modules/ui/sections/background_display_options.js
68515   function uiSectionBackgroundDisplayOptions(context) {
68516     var section = uiSection("background-display-options", context).label(() => _t.append("background.display_options")).disclosureContent(renderDisclosureContent);
68517     var _storedOpacity = corePreferences("background-opacity");
68518     var _minVal = 0;
68519     var _maxVal = 3;
68520     var _sliders = ["brightness", "contrast", "saturation", "sharpness"];
68521     var _options = {
68522       brightness: _storedOpacity !== null ? +_storedOpacity : 1,
68523       contrast: 1,
68524       saturation: 1,
68525       sharpness: 1
68526     };
68527     function clamp3(x2, min3, max3) {
68528       return Math.max(min3, Math.min(x2, max3));
68529     }
68530     function updateValue(d2, val) {
68531       val = clamp3(val, _minVal, _maxVal);
68532       _options[d2] = val;
68533       context.background()[d2](val);
68534       if (d2 === "brightness") {
68535         corePreferences("background-opacity", val);
68536       }
68537       section.reRender();
68538     }
68539     function renderDisclosureContent(selection2) {
68540       var container = selection2.selectAll(".display-options-container").data([0]);
68541       var containerEnter = container.enter().append("div").attr("class", "display-options-container controls-list");
68542       var slidersEnter = containerEnter.selectAll(".display-control").data(_sliders).enter().append("label").attr("class", function(d2) {
68543         return "display-control display-control-" + d2;
68544       });
68545       slidersEnter.html(function(d2) {
68546         return _t.html("background." + d2);
68547       }).append("span").attr("class", function(d2) {
68548         return "display-option-value display-option-value-" + d2;
68549       });
68550       var sildersControlEnter = slidersEnter.append("div").attr("class", "control-wrap");
68551       sildersControlEnter.append("input").attr("class", function(d2) {
68552         return "display-option-input display-option-input-" + d2;
68553       }).attr("type", "range").attr("min", _minVal).attr("max", _maxVal).attr("step", "0.05").on("input", function(d3_event, d2) {
68554         var val = select_default2(this).property("value");
68555         if (!val && d3_event && d3_event.target) {
68556           val = d3_event.target.value;
68557         }
68558         updateValue(d2, val);
68559       });
68560       sildersControlEnter.append("button").attr("title", function(d2) {
68561         return "".concat(_t("background.reset"), " ").concat(_t("background." + d2));
68562       }).attr("class", function(d2) {
68563         return "display-option-reset display-option-reset-" + d2;
68564       }).on("click", function(d3_event, d2) {
68565         if (d3_event.button !== 0) return;
68566         updateValue(d2, 1);
68567       }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
68568       containerEnter.append("a").attr("class", "display-option-resetlink").attr("role", "button").attr("href", "#").call(_t.append("background.reset_all")).on("click", function(d3_event) {
68569         d3_event.preventDefault();
68570         for (var i3 = 0; i3 < _sliders.length; i3++) {
68571           updateValue(_sliders[i3], 1);
68572         }
68573       });
68574       container = containerEnter.merge(container);
68575       container.selectAll(".display-option-input").property("value", function(d2) {
68576         return _options[d2];
68577       });
68578       container.selectAll(".display-option-value").text(function(d2) {
68579         return Math.floor(_options[d2] * 100) + "%";
68580       });
68581       container.selectAll(".display-option-reset").classed("disabled", function(d2) {
68582         return _options[d2] === 1;
68583       });
68584       if (containerEnter.size() && _options.brightness !== 1) {
68585         context.background().brightness(_options.brightness);
68586       }
68587     }
68588     return section;
68589   }
68590
68591   // modules/ui/settings/custom_background.js
68592   function uiSettingsCustomBackground() {
68593     var dispatch14 = dispatch_default("change");
68594     function render(selection2) {
68595       var _origSettings = {
68596         template: corePreferences("background-custom-template")
68597       };
68598       var _currSettings = {
68599         template: corePreferences("background-custom-template")
68600       };
68601       var example = "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png";
68602       var modal = uiConfirm(selection2).okButton();
68603       modal.classed("settings-modal settings-custom-background", true);
68604       modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_background.header"));
68605       var textSection = modal.select(".modal-section.message-text");
68606       var instructions = "".concat(_t.html("settings.custom_background.instructions.info"), "\n") + "\n" + "#### ".concat(_t.html("settings.custom_background.instructions.wms.tokens_label"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.proj"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.wkid"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.dimensions"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.bbox"), "\n") + "\n" + "#### ".concat(_t.html("settings.custom_background.instructions.tms.tokens_label"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.xyz"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.flipped_y"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.switch"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.quadtile"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.scale_factor"), "\n") + "\n" + "#### ".concat(_t.html("settings.custom_background.instructions.example"), "\n") + "`".concat(example, "`");
68607       textSection.append("div").attr("class", "instructions-template").html(marked(instructions));
68608       textSection.append("textarea").attr("class", "field-template").attr("placeholder", _t("settings.custom_background.template.placeholder")).call(utilNoAuto).property("value", _currSettings.template);
68609       var buttonSection = modal.select(".modal-section.buttons");
68610       buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
68611       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
68612       buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
68613       function isSaveDisabled() {
68614         return null;
68615       }
68616       function clickCancel() {
68617         textSection.select(".field-template").property("value", _origSettings.template);
68618         corePreferences("background-custom-template", _origSettings.template);
68619         this.blur();
68620         modal.close();
68621       }
68622       function clickSave() {
68623         _currSettings.template = textSection.select(".field-template").property("value");
68624         corePreferences("background-custom-template", _currSettings.template);
68625         this.blur();
68626         modal.close();
68627         dispatch14.call("change", this, _currSettings);
68628       }
68629     }
68630     return utilRebind(render, dispatch14, "on");
68631   }
68632
68633   // modules/ui/sections/background_list.js
68634   function uiSectionBackgroundList(context) {
68635     var _backgroundList = select_default2(null);
68636     var _customSource = context.background().findSource("custom");
68637     var _settingsCustomBackground = uiSettingsCustomBackground(context).on("change", customChanged);
68638     var section = uiSection("background-list", context).label(() => _t.append("background.backgrounds")).disclosureContent(renderDisclosureContent);
68639     function previousBackgroundID() {
68640       return corePreferences("background-last-used-toggle");
68641     }
68642     function renderDisclosureContent(selection2) {
68643       var container = selection2.selectAll(".layer-background-list").data([0]);
68644       _backgroundList = container.enter().append("ul").attr("class", "layer-list layer-background-list").attr("dir", "auto").merge(container);
68645       var bgExtrasListEnter = selection2.selectAll(".bg-extras-list").data([0]).enter().append("ul").attr("class", "layer-list bg-extras-list");
68646       var minimapLabelEnter = bgExtrasListEnter.append("li").attr("class", "minimap-toggle-item").append("label").call(
68647         uiTooltip().title(() => _t.append("background.minimap.tooltip")).keys([_t("background.minimap.key")]).placement("top")
68648       );
68649       minimapLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
68650         d3_event.preventDefault();
68651         uiMapInMap.toggle();
68652       });
68653       minimapLabelEnter.append("span").call(_t.append("background.minimap.description"));
68654       var panelLabelEnter = bgExtrasListEnter.append("li").attr("class", "background-panel-toggle-item").append("label").call(
68655         uiTooltip().title(() => _t.append("background.panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.background.key"))]).placement("top")
68656       );
68657       panelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
68658         d3_event.preventDefault();
68659         context.ui().info.toggle("background");
68660       });
68661       panelLabelEnter.append("span").call(_t.append("background.panel.description"));
68662       var locPanelLabelEnter = bgExtrasListEnter.append("li").attr("class", "location-panel-toggle-item").append("label").call(
68663         uiTooltip().title(() => _t.append("background.location_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.location.key"))]).placement("top")
68664       );
68665       locPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
68666         d3_event.preventDefault();
68667         context.ui().info.toggle("location");
68668       });
68669       locPanelLabelEnter.append("span").call(_t.append("background.location_panel.description"));
68670       selection2.selectAll(".imagery-faq").data([0]).enter().append("div").attr("class", "imagery-faq").append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/openstreetmap/iD/blob/develop/FAQ.md#how-can-i-report-an-issue-with-background-imagery").append("span").call(_t.append("background.imagery_problem_faq"));
68671       _backgroundList.call(drawListItems, "radio", function(d3_event, d2) {
68672         chooseBackground(d2);
68673       }, function(d2) {
68674         return !d2.isHidden() && !d2.overlay;
68675       });
68676     }
68677     function setTooltips(selection2) {
68678       selection2.each(function(d2, i3, nodes) {
68679         var item = select_default2(this).select("label");
68680         var span = item.select("span");
68681         var placement = i3 < nodes.length / 2 ? "bottom" : "top";
68682         var hasDescription = d2.hasDescription();
68683         var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
68684         item.call(uiTooltip().destroyAny);
68685         if (d2.id === previousBackgroundID()) {
68686           item.call(
68687             uiTooltip().placement(placement).title(() => _t.append("background.switch")).keys([uiCmd("\u2318" + _t("background.key"))])
68688           );
68689         } else if (hasDescription || isOverflowing) {
68690           item.call(
68691             uiTooltip().placement(placement).title(() => hasDescription ? d2.description() : d2.label())
68692           );
68693         }
68694       });
68695     }
68696     function drawListItems(layerList, type2, change, filter2) {
68697       var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2).sort(function(a2, b2) {
68698         return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
68699       });
68700       var layerLinks = layerList.selectAll("li").data(sources, function(d2, i3) {
68701         return d2.id + "---" + i3;
68702       });
68703       layerLinks.exit().remove();
68704       var enter = layerLinks.enter().append("li").classed("layer-custom", function(d2) {
68705         return d2.id === "custom";
68706       }).classed("best", function(d2) {
68707         return d2.best();
68708       });
68709       var label = enter.append("label");
68710       label.append("input").attr("type", type2).attr("name", "background-layer").attr("value", function(d2) {
68711         return d2.id;
68712       }).on("change", change);
68713       label.append("span").each(function(d2) {
68714         d2.label()(select_default2(this));
68715       });
68716       enter.filter(function(d2) {
68717         return d2.id === "custom";
68718       }).append("button").attr("class", "layer-browse").call(
68719         uiTooltip().title(() => _t.append("settings.custom_background.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
68720       ).on("click", function(d3_event) {
68721         d3_event.preventDefault();
68722         editCustom();
68723       }).call(svgIcon("#iD-icon-more"));
68724       enter.filter(function(d2) {
68725         return d2.best();
68726       }).append("div").attr("class", "best").call(
68727         uiTooltip().title(() => _t.append("background.best_imagery")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
68728       ).append("span").text("\u2605");
68729       layerList.call(updateLayerSelections);
68730     }
68731     function updateLayerSelections(selection2) {
68732       function active(d2) {
68733         return context.background().showsLayer(d2);
68734       }
68735       selection2.selectAll("li").classed("active", active).classed("switch", function(d2) {
68736         return d2.id === previousBackgroundID();
68737       }).call(setTooltips).selectAll("input").property("checked", active);
68738     }
68739     function chooseBackground(d2) {
68740       if (d2.id === "custom" && !d2.template()) {
68741         return editCustom();
68742       }
68743       var previousBackground = context.background().baseLayerSource();
68744       corePreferences("background-last-used-toggle", previousBackground.id);
68745       corePreferences("background-last-used", d2.id);
68746       context.background().baseLayerSource(d2);
68747     }
68748     function customChanged(d2) {
68749       if (d2 && d2.template) {
68750         _customSource.template(d2.template);
68751         chooseBackground(_customSource);
68752       } else {
68753         _customSource.template("");
68754         chooseBackground(context.background().findSource("none"));
68755       }
68756     }
68757     function editCustom() {
68758       context.container().call(_settingsCustomBackground);
68759     }
68760     context.background().on("change.background_list", function() {
68761       _backgroundList.call(updateLayerSelections);
68762     });
68763     context.map().on(
68764       "move.background_list",
68765       debounce_default(function() {
68766         window.requestIdleCallback(section.reRender);
68767       }, 1e3)
68768     );
68769     return section;
68770   }
68771
68772   // modules/ui/sections/background_offset.js
68773   function uiSectionBackgroundOffset(context) {
68774     var section = uiSection("background-offset", context).label(() => _t.append("background.fix_misalignment")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
68775     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
68776     var _directions = [
68777       ["top", [0, -0.5]],
68778       ["left", [-0.5, 0]],
68779       ["right", [0.5, 0]],
68780       ["bottom", [0, 0.5]]
68781     ];
68782     function updateValue() {
68783       var meters = geoOffsetToMeters(context.background().offset());
68784       var x2 = +meters[0].toFixed(2);
68785       var y2 = +meters[1].toFixed(2);
68786       context.container().selectAll(".nudge-inner-rect").select("input").classed("error", false).property("value", x2 + ", " + y2);
68787       context.container().selectAll(".nudge-reset").classed("disabled", function() {
68788         return x2 === 0 && y2 === 0;
68789       });
68790     }
68791     function resetOffset() {
68792       context.background().offset([0, 0]);
68793       updateValue();
68794     }
68795     function nudge(d2) {
68796       context.background().nudge(d2, context.map().zoom());
68797       updateValue();
68798     }
68799     function inputOffset() {
68800       var input = select_default2(this);
68801       var d2 = input.node().value;
68802       if (d2 === "") return resetOffset();
68803       d2 = d2.replace(/;/g, ",").split(",").map(function(n3) {
68804         return !isNaN(n3) && n3;
68805       });
68806       if (d2.length !== 2 || !d2[0] || !d2[1]) {
68807         input.classed("error", true);
68808         return;
68809       }
68810       context.background().offset(geoMetersToOffset(d2));
68811       updateValue();
68812     }
68813     function dragOffset(d3_event) {
68814       if (d3_event.button !== 0) return;
68815       var origin = [d3_event.clientX, d3_event.clientY];
68816       var pointerId = d3_event.pointerId || "mouse";
68817       context.container().append("div").attr("class", "nudge-surface");
68818       select_default2(window).on(_pointerPrefix + "move.drag-bg-offset", pointermove).on(_pointerPrefix + "up.drag-bg-offset", pointerup);
68819       if (_pointerPrefix === "pointer") {
68820         select_default2(window).on("pointercancel.drag-bg-offset", pointerup);
68821       }
68822       function pointermove(d3_event2) {
68823         if (pointerId !== (d3_event2.pointerId || "mouse")) return;
68824         var latest = [d3_event2.clientX, d3_event2.clientY];
68825         var d2 = [
68826           -(origin[0] - latest[0]) / 4,
68827           -(origin[1] - latest[1]) / 4
68828         ];
68829         origin = latest;
68830         nudge(d2);
68831       }
68832       function pointerup(d3_event2) {
68833         if (pointerId !== (d3_event2.pointerId || "mouse")) return;
68834         if (d3_event2.button !== 0) return;
68835         context.container().selectAll(".nudge-surface").remove();
68836         select_default2(window).on(".drag-bg-offset", null);
68837       }
68838     }
68839     function renderDisclosureContent(selection2) {
68840       var container = selection2.selectAll(".nudge-container").data([0]);
68841       var containerEnter = container.enter().append("div").attr("class", "nudge-container");
68842       containerEnter.append("div").attr("class", "nudge-instructions").call(_t.append("background.offset"));
68843       var nudgeWrapEnter = containerEnter.append("div").attr("class", "nudge-controls-wrap");
68844       var nudgeEnter = nudgeWrapEnter.append("div").attr("class", "nudge-outer-rect").on(_pointerPrefix + "down", dragOffset);
68845       nudgeEnter.append("div").attr("class", "nudge-inner-rect").append("input").attr("type", "text").attr("aria-label", _t("background.offset_label")).on("change", inputOffset);
68846       nudgeWrapEnter.append("div").selectAll("button").data(_directions).enter().append("button").attr("title", function(d2) {
68847         return _t("background.nudge.".concat(d2[0]));
68848       }).attr("class", function(d2) {
68849         return d2[0] + " nudge";
68850       }).on("click", function(d3_event, d2) {
68851         nudge(d2[1]);
68852       });
68853       nudgeWrapEnter.append("button").attr("title", _t("background.reset")).attr("class", "nudge-reset disabled").on("click", function(d3_event) {
68854         d3_event.preventDefault();
68855         resetOffset();
68856       }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
68857       updateValue();
68858     }
68859     context.background().on("change.backgroundOffset-update", updateValue);
68860     return section;
68861   }
68862
68863   // modules/ui/sections/overlay_list.js
68864   function uiSectionOverlayList(context) {
68865     var section = uiSection("overlay-list", context).label(() => _t.append("background.overlays")).disclosureContent(renderDisclosureContent);
68866     var _overlayList = select_default2(null);
68867     function setTooltips(selection2) {
68868       selection2.each(function(d2, i3, nodes) {
68869         var item = select_default2(this).select("label");
68870         var span = item.select("span");
68871         var placement = i3 < nodes.length / 2 ? "bottom" : "top";
68872         var description = d2.description();
68873         var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
68874         item.call(uiTooltip().destroyAny);
68875         if (description || isOverflowing) {
68876           item.call(
68877             uiTooltip().placement(placement).title(() => description || d2.name())
68878           );
68879         }
68880       });
68881     }
68882     function updateLayerSelections(selection2) {
68883       function active(d2) {
68884         return context.background().showsLayer(d2);
68885       }
68886       selection2.selectAll("li").classed("active", active).call(setTooltips).selectAll("input").property("checked", active);
68887     }
68888     function chooseOverlay(d3_event, d2) {
68889       d3_event.preventDefault();
68890       context.background().toggleOverlayLayer(d2);
68891       _overlayList.call(updateLayerSelections);
68892       document.activeElement.blur();
68893     }
68894     function drawListItems(layerList, type2, change, filter2) {
68895       var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2);
68896       var layerLinks = layerList.selectAll("li").data(sources, function(d2) {
68897         return d2.name();
68898       });
68899       layerLinks.exit().remove();
68900       var enter = layerLinks.enter().append("li");
68901       var label = enter.append("label");
68902       label.append("input").attr("type", type2).attr("name", "layers").on("change", change);
68903       label.append("span").each(function(d2) {
68904         d2.label()(select_default2(this));
68905       });
68906       layerList.selectAll("li").sort(sortSources);
68907       layerList.call(updateLayerSelections);
68908       function sortSources(a2, b2) {
68909         return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
68910       }
68911     }
68912     function renderDisclosureContent(selection2) {
68913       var container = selection2.selectAll(".layer-overlay-list").data([0]);
68914       _overlayList = container.enter().append("ul").attr("class", "layer-list layer-overlay-list").attr("dir", "auto").merge(container);
68915       _overlayList.call(drawListItems, "checkbox", chooseOverlay, function(d2) {
68916         return !d2.isHidden() && d2.overlay;
68917       });
68918     }
68919     context.map().on(
68920       "move.overlay_list",
68921       debounce_default(function() {
68922         window.requestIdleCallback(section.reRender);
68923       }, 1e3)
68924     );
68925     return section;
68926   }
68927
68928   // modules/ui/panes/background.js
68929   function uiPaneBackground(context) {
68930     var backgroundPane = uiPane("background", context).key(_t("background.key")).label(_t.append("background.title")).description(_t.append("background.description")).iconName("iD-icon-layers").sections([
68931       uiSectionBackgroundList(context),
68932       uiSectionOverlayList(context),
68933       uiSectionBackgroundDisplayOptions(context),
68934       uiSectionBackgroundOffset(context)
68935     ]);
68936     return backgroundPane;
68937   }
68938
68939   // modules/ui/panes/help.js
68940   function uiPaneHelp(context) {
68941     var docKeys = [
68942       ["help", [
68943         "welcome",
68944         "open_data_h",
68945         "open_data",
68946         "before_start_h",
68947         "before_start",
68948         "open_source_h",
68949         "open_source",
68950         "open_source_attribution",
68951         "open_source_help"
68952       ]],
68953       ["overview", [
68954         "navigation_h",
68955         "navigation_drag",
68956         "navigation_zoom",
68957         "features_h",
68958         "features",
68959         "nodes_ways"
68960       ]],
68961       ["editing", [
68962         "select_h",
68963         "select_left_click",
68964         "select_right_click",
68965         "select_space",
68966         "multiselect_h",
68967         "multiselect",
68968         "multiselect_shift_click",
68969         "multiselect_lasso",
68970         "undo_redo_h",
68971         "undo_redo",
68972         "save_h",
68973         "save",
68974         "save_validation",
68975         "upload_h",
68976         "upload",
68977         "backups_h",
68978         "backups",
68979         "keyboard_h",
68980         "keyboard"
68981       ]],
68982       ["feature_editor", [
68983         "intro",
68984         "definitions",
68985         "type_h",
68986         "type",
68987         "type_picker",
68988         "fields_h",
68989         "fields_all_fields",
68990         "fields_example",
68991         "fields_add_field",
68992         "tags_h",
68993         "tags_all_tags",
68994         "tags_resources"
68995       ]],
68996       ["points", [
68997         "intro",
68998         "add_point_h",
68999         "add_point",
69000         "add_point_finish",
69001         "move_point_h",
69002         "move_point",
69003         "delete_point_h",
69004         "delete_point",
69005         "delete_point_command"
69006       ]],
69007       ["lines", [
69008         "intro",
69009         "add_line_h",
69010         "add_line",
69011         "add_line_draw",
69012         "add_line_continue",
69013         "add_line_finish",
69014         "modify_line_h",
69015         "modify_line_dragnode",
69016         "modify_line_addnode",
69017         "connect_line_h",
69018         "connect_line",
69019         "connect_line_display",
69020         "connect_line_drag",
69021         "connect_line_tag",
69022         "disconnect_line_h",
69023         "disconnect_line_command",
69024         "move_line_h",
69025         "move_line_command",
69026         "move_line_connected",
69027         "delete_line_h",
69028         "delete_line",
69029         "delete_line_command"
69030       ]],
69031       ["areas", [
69032         "intro",
69033         "point_or_area_h",
69034         "point_or_area",
69035         "add_area_h",
69036         "add_area_command",
69037         "add_area_draw",
69038         "add_area_continue",
69039         "add_area_finish",
69040         "square_area_h",
69041         "square_area_command",
69042         "modify_area_h",
69043         "modify_area_dragnode",
69044         "modify_area_addnode",
69045         "delete_area_h",
69046         "delete_area",
69047         "delete_area_command"
69048       ]],
69049       ["relations", [
69050         "intro",
69051         "edit_relation_h",
69052         "edit_relation",
69053         "edit_relation_add",
69054         "edit_relation_delete",
69055         "maintain_relation_h",
69056         "maintain_relation",
69057         "relation_types_h",
69058         "multipolygon_h",
69059         "multipolygon",
69060         "multipolygon_create",
69061         "multipolygon_merge",
69062         "turn_restriction_h",
69063         "turn_restriction",
69064         "turn_restriction_field",
69065         "turn_restriction_editing",
69066         "route_h",
69067         "route",
69068         "route_add",
69069         "boundary_h",
69070         "boundary",
69071         "boundary_add"
69072       ]],
69073       ["operations", [
69074         "intro",
69075         "intro_2",
69076         "straighten",
69077         "orthogonalize",
69078         "circularize",
69079         "move",
69080         "rotate",
69081         "reflect",
69082         "continue",
69083         "reverse",
69084         "disconnect",
69085         "split",
69086         "extract",
69087         "merge",
69088         "delete",
69089         "downgrade",
69090         "copy_paste"
69091       ]],
69092       ["notes", [
69093         "intro",
69094         "add_note_h",
69095         "add_note",
69096         "place_note",
69097         "move_note",
69098         "update_note_h",
69099         "update_note",
69100         "save_note_h",
69101         "save_note"
69102       ]],
69103       ["imagery", [
69104         "intro",
69105         "sources_h",
69106         "choosing",
69107         "sources",
69108         "offsets_h",
69109         "offset",
69110         "offset_change"
69111       ]],
69112       ["streetlevel", [
69113         "intro",
69114         "using_h",
69115         "using",
69116         "photos",
69117         "viewer"
69118       ]],
69119       ["gps", [
69120         "intro",
69121         "survey",
69122         "using_h",
69123         "using",
69124         "tracing",
69125         "upload"
69126       ]],
69127       ["qa", [
69128         "intro",
69129         "tools_h",
69130         "tools",
69131         "issues_h",
69132         "issues"
69133       ]]
69134     ];
69135     var headings = {
69136       "help.help.open_data_h": 3,
69137       "help.help.before_start_h": 3,
69138       "help.help.open_source_h": 3,
69139       "help.overview.navigation_h": 3,
69140       "help.overview.features_h": 3,
69141       "help.editing.select_h": 3,
69142       "help.editing.multiselect_h": 3,
69143       "help.editing.undo_redo_h": 3,
69144       "help.editing.save_h": 3,
69145       "help.editing.upload_h": 3,
69146       "help.editing.backups_h": 3,
69147       "help.editing.keyboard_h": 3,
69148       "help.feature_editor.type_h": 3,
69149       "help.feature_editor.fields_h": 3,
69150       "help.feature_editor.tags_h": 3,
69151       "help.points.add_point_h": 3,
69152       "help.points.move_point_h": 3,
69153       "help.points.delete_point_h": 3,
69154       "help.lines.add_line_h": 3,
69155       "help.lines.modify_line_h": 3,
69156       "help.lines.connect_line_h": 3,
69157       "help.lines.disconnect_line_h": 3,
69158       "help.lines.move_line_h": 3,
69159       "help.lines.delete_line_h": 3,
69160       "help.areas.point_or_area_h": 3,
69161       "help.areas.add_area_h": 3,
69162       "help.areas.square_area_h": 3,
69163       "help.areas.modify_area_h": 3,
69164       "help.areas.delete_area_h": 3,
69165       "help.relations.edit_relation_h": 3,
69166       "help.relations.maintain_relation_h": 3,
69167       "help.relations.relation_types_h": 2,
69168       "help.relations.multipolygon_h": 3,
69169       "help.relations.turn_restriction_h": 3,
69170       "help.relations.route_h": 3,
69171       "help.relations.boundary_h": 3,
69172       "help.notes.add_note_h": 3,
69173       "help.notes.update_note_h": 3,
69174       "help.notes.save_note_h": 3,
69175       "help.imagery.sources_h": 3,
69176       "help.imagery.offsets_h": 3,
69177       "help.streetlevel.using_h": 3,
69178       "help.gps.using_h": 3,
69179       "help.qa.tools_h": 3,
69180       "help.qa.issues_h": 3
69181     };
69182     var docs = docKeys.map(function(key) {
69183       var helpkey = "help." + key[0];
69184       var helpPaneReplacements = { version: context.version };
69185       var text = key[1].reduce(function(all, part) {
69186         var subkey = helpkey + "." + part;
69187         var depth = headings[subkey];
69188         var hhh = depth ? Array(depth + 1).join("#") + " " : "";
69189         return all + hhh + helpHtml(subkey, helpPaneReplacements) + "\n\n";
69190       }, "");
69191       return {
69192         title: _t.html(helpkey + ".title"),
69193         content: marked(text.trim()).replace(/<code>/g, "<kbd>").replace(/<\/code>/g, "</kbd>")
69194       };
69195     });
69196     var helpPane = uiPane("help", context).key(_t("help.key")).label(_t.append("help.title")).description(_t.append("help.title")).iconName("iD-icon-help");
69197     helpPane.renderContent = function(content) {
69198       function clickHelp(d2, i3) {
69199         var rtl = _mainLocalizer.textDirection() === "rtl";
69200         content.property("scrollTop", 0);
69201         helpPane.selection().select(".pane-heading h2").html(d2.title);
69202         body.html(d2.content);
69203         body.selectAll("a").attr("target", "_blank");
69204         menuItems.classed("selected", function(m2) {
69205           return m2.title === d2.title;
69206         });
69207         nav.html("");
69208         if (rtl) {
69209           nav.call(drawNext).call(drawPrevious);
69210         } else {
69211           nav.call(drawPrevious).call(drawNext);
69212         }
69213         function drawNext(selection2) {
69214           if (i3 < docs.length - 1) {
69215             var nextLink = selection2.append("a").attr("href", "#").attr("class", "next").on("click", function(d3_event) {
69216               d3_event.preventDefault();
69217               clickHelp(docs[i3 + 1], i3 + 1);
69218             });
69219             nextLink.append("span").html(docs[i3 + 1].title).call(svgIcon(rtl ? "#iD-icon-backward" : "#iD-icon-forward", "inline"));
69220           }
69221         }
69222         function drawPrevious(selection2) {
69223           if (i3 > 0) {
69224             var prevLink = selection2.append("a").attr("href", "#").attr("class", "previous").on("click", function(d3_event) {
69225               d3_event.preventDefault();
69226               clickHelp(docs[i3 - 1], i3 - 1);
69227             });
69228             prevLink.call(svgIcon(rtl ? "#iD-icon-forward" : "#iD-icon-backward", "inline")).append("span").html(docs[i3 - 1].title);
69229           }
69230         }
69231       }
69232       function clickWalkthrough(d3_event) {
69233         d3_event.preventDefault();
69234         if (context.inIntro()) return;
69235         context.container().call(uiIntro(context));
69236         context.ui().togglePanes();
69237       }
69238       function clickShortcuts(d3_event) {
69239         d3_event.preventDefault();
69240         context.container().call(context.ui().shortcuts, true);
69241       }
69242       var toc = content.append("ul").attr("class", "toc");
69243       var menuItems = toc.selectAll("li").data(docs).enter().append("li").append("a").attr("role", "button").attr("href", "#").html(function(d2) {
69244         return d2.title;
69245       }).on("click", function(d3_event, d2) {
69246         d3_event.preventDefault();
69247         clickHelp(d2, docs.indexOf(d2));
69248       });
69249       var shortcuts = toc.append("li").attr("class", "shortcuts").call(
69250         uiTooltip().title(() => _t.append("shortcuts.tooltip")).keys(["?"]).placement("top")
69251       ).append("a").attr("href", "#").on("click", clickShortcuts);
69252       shortcuts.append("div").call(_t.append("shortcuts.title"));
69253       var walkthrough = toc.append("li").attr("class", "walkthrough").append("a").attr("href", "#").on("click", clickWalkthrough);
69254       walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough");
69255       walkthrough.append("div").call(_t.append("splash.walkthrough"));
69256       var helpContent = content.append("div").attr("class", "left-content");
69257       var body = helpContent.append("div").attr("class", "body");
69258       var nav = helpContent.append("div").attr("class", "nav");
69259       clickHelp(docs[0], 0);
69260     };
69261     return helpPane;
69262   }
69263
69264   // modules/ui/sections/validation_issues.js
69265   function uiSectionValidationIssues(id2, severity, context) {
69266     var _issues = [];
69267     var section = uiSection(id2, context).label(function() {
69268       if (!_issues) return "";
69269       var issueCountText = _issues.length > 1e3 ? "1000+" : String(_issues.length);
69270       return _t.append("inspector.title_count", { title: _t("issues." + severity + "s.list_title"), count: issueCountText });
69271     }).disclosureContent(renderDisclosureContent).shouldDisplay(function() {
69272       return _issues && _issues.length;
69273     });
69274     function getOptions() {
69275       return {
69276         what: corePreferences("validate-what") || "edited",
69277         where: corePreferences("validate-where") || "all"
69278       };
69279     }
69280     function reloadIssues() {
69281       _issues = context.validator().getIssuesBySeverity(getOptions())[severity];
69282     }
69283     function renderDisclosureContent(selection2) {
69284       var center = context.map().center();
69285       var graph = context.graph();
69286       var issues = _issues.map(function withDistance(issue) {
69287         var extent = issue.extent(graph);
69288         var dist = extent ? geoSphericalDistance(center, extent.center()) : 0;
69289         return Object.assign(issue, { dist });
69290       }).sort(function byDistance(a2, b2) {
69291         return a2.dist - b2.dist;
69292       });
69293       issues = issues.slice(0, 1e3);
69294       selection2.call(drawIssuesList, issues);
69295     }
69296     function drawIssuesList(selection2, issues) {
69297       var list2 = selection2.selectAll(".issues-list").data([0]);
69298       list2 = list2.enter().append("ul").attr("class", "layer-list issues-list " + severity + "s-list").merge(list2);
69299       var items = list2.selectAll("li").data(issues, function(d2) {
69300         return d2.key;
69301       });
69302       items.exit().remove();
69303       var itemsEnter = items.enter().append("li").attr("class", function(d2) {
69304         return "issue severity-" + d2.severity;
69305       });
69306       var labelsEnter = itemsEnter.append("button").attr("class", "issue-label").on("click", function(d3_event, d2) {
69307         context.validator().focusIssue(d2);
69308       }).on("mouseover", function(d3_event, d2) {
69309         utilHighlightEntities(d2.entityIds, true, context);
69310       }).on("mouseout", function(d3_event, d2) {
69311         utilHighlightEntities(d2.entityIds, false, context);
69312       });
69313       var textEnter = labelsEnter.append("span").attr("class", "issue-text");
69314       textEnter.append("span").attr("class", "issue-icon").each(function(d2) {
69315         var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error");
69316         select_default2(this).call(svgIcon(iconName));
69317       });
69318       textEnter.append("span").attr("class", "issue-message");
69319       items = items.merge(itemsEnter).order();
69320       items.selectAll(".issue-message").text("").each(function(d2) {
69321         return d2.message(context)(select_default2(this));
69322       });
69323     }
69324     context.validator().on("validated.uiSectionValidationIssues" + id2, function() {
69325       window.requestIdleCallback(function() {
69326         reloadIssues();
69327         section.reRender();
69328       });
69329     });
69330     context.map().on(
69331       "move.uiSectionValidationIssues" + id2,
69332       debounce_default(function() {
69333         window.requestIdleCallback(function() {
69334           if (getOptions().where === "visible") {
69335             reloadIssues();
69336           }
69337           section.reRender();
69338         });
69339       }, 1e3)
69340     );
69341     return section;
69342   }
69343
69344   // modules/ui/sections/validation_options.js
69345   function uiSectionValidationOptions(context) {
69346     var section = uiSection("issues-options", context).content(renderContent);
69347     function renderContent(selection2) {
69348       var container = selection2.selectAll(".issues-options-container").data([0]);
69349       container = container.enter().append("div").attr("class", "issues-options-container").merge(container);
69350       var data = [
69351         { key: "what", values: ["edited", "all"] },
69352         { key: "where", values: ["visible", "all"] }
69353       ];
69354       var options2 = container.selectAll(".issues-option").data(data, function(d2) {
69355         return d2.key;
69356       });
69357       var optionsEnter = options2.enter().append("div").attr("class", function(d2) {
69358         return "issues-option issues-option-" + d2.key;
69359       });
69360       optionsEnter.append("div").attr("class", "issues-option-title").html(function(d2) {
69361         return _t.html("issues.options." + d2.key + ".title");
69362       });
69363       var valuesEnter = optionsEnter.selectAll("label").data(function(d2) {
69364         return d2.values.map(function(val) {
69365           return { value: val, key: d2.key };
69366         });
69367       }).enter().append("label");
69368       valuesEnter.append("input").attr("type", "radio").attr("name", function(d2) {
69369         return "issues-option-" + d2.key;
69370       }).attr("value", function(d2) {
69371         return d2.value;
69372       }).property("checked", function(d2) {
69373         return getOptions()[d2.key] === d2.value;
69374       }).on("change", function(d3_event, d2) {
69375         updateOptionValue(d3_event, d2.key, d2.value);
69376       });
69377       valuesEnter.append("span").html(function(d2) {
69378         return _t.html("issues.options." + d2.key + "." + d2.value);
69379       });
69380     }
69381     function getOptions() {
69382       return {
69383         what: corePreferences("validate-what") || "edited",
69384         // 'all', 'edited'
69385         where: corePreferences("validate-where") || "all"
69386         // 'all', 'visible'
69387       };
69388     }
69389     function updateOptionValue(d3_event, d2, val) {
69390       if (!val && d3_event && d3_event.target) {
69391         val = d3_event.target.value;
69392       }
69393       corePreferences("validate-" + d2, val);
69394       context.validator().validate();
69395     }
69396     return section;
69397   }
69398
69399   // modules/ui/sections/validation_rules.js
69400   function uiSectionValidationRules(context) {
69401     var MINSQUARE = 0;
69402     var MAXSQUARE = 20;
69403     var DEFAULTSQUARE = 5;
69404     var section = uiSection("issues-rules", context).disclosureContent(renderDisclosureContent).label(() => _t.append("issues.rules.title"));
69405     var _ruleKeys = context.validator().getRuleKeys().filter(function(key) {
69406       return key !== "maprules";
69407     }).sort(function(key1, key2) {
69408       return _t("issues." + key1 + ".title") < _t("issues." + key2 + ".title") ? -1 : 1;
69409     });
69410     function renderDisclosureContent(selection2) {
69411       var container = selection2.selectAll(".issues-rulelist-container").data([0]);
69412       var containerEnter = container.enter().append("div").attr("class", "issues-rulelist-container");
69413       containerEnter.append("ul").attr("class", "layer-list issue-rules-list");
69414       var ruleLinks = containerEnter.append("div").attr("class", "issue-rules-links section-footer");
69415       ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) {
69416         d3_event.preventDefault();
69417         context.validator().disableRules(_ruleKeys);
69418       });
69419       ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) {
69420         d3_event.preventDefault();
69421         context.validator().disableRules([]);
69422       });
69423       container = container.merge(containerEnter);
69424       container.selectAll(".issue-rules-list").call(drawListItems, _ruleKeys, "checkbox", "rule", toggleRule, isRuleEnabled);
69425     }
69426     function drawListItems(selection2, data, type2, name, change, active) {
69427       var items = selection2.selectAll("li").data(data);
69428       items.exit().remove();
69429       var enter = items.enter().append("li");
69430       if (name === "rule") {
69431         enter.call(
69432           uiTooltip().title(function(d2) {
69433             return _t.append("issues." + d2 + ".tip");
69434           }).placement("top")
69435         );
69436       }
69437       var label = enter.append("label");
69438       label.append("input").attr("type", type2).attr("name", name).on("change", change);
69439       label.append("span").html(function(d2) {
69440         var params = {};
69441         if (d2 === "unsquare_way") {
69442           params.val = { html: '<span class="square-degrees"></span>' };
69443         }
69444         return _t.html("issues." + d2 + ".title", params);
69445       });
69446       items = items.merge(enter);
69447       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false);
69448       var degStr = corePreferences("validate-square-degrees");
69449       if (degStr === null) {
69450         degStr = DEFAULTSQUARE.toString();
69451       }
69452       var span = items.selectAll(".square-degrees");
69453       var input = span.selectAll(".square-degrees-input").data([0]);
69454       input.enter().append("input").attr("type", "number").attr("min", MINSQUARE.toString()).attr("max", MAXSQUARE.toString()).attr("step", "0.5").attr("class", "square-degrees-input").call(utilNoAuto).on("click", function(d3_event) {
69455         d3_event.preventDefault();
69456         d3_event.stopPropagation();
69457         this.select();
69458       }).on("keyup", function(d3_event) {
69459         if (d3_event.keyCode === 13) {
69460           this.blur();
69461           this.select();
69462         }
69463       }).on("blur", changeSquare).merge(input).property("value", degStr);
69464     }
69465     function changeSquare() {
69466       var input = select_default2(this);
69467       var degStr = utilGetSetValue(input).trim();
69468       var degNum = Number(degStr);
69469       if (!isFinite(degNum)) {
69470         degNum = DEFAULTSQUARE;
69471       } else if (degNum > MAXSQUARE) {
69472         degNum = MAXSQUARE;
69473       } else if (degNum < MINSQUARE) {
69474         degNum = MINSQUARE;
69475       }
69476       degNum = Math.round(degNum * 10) / 10;
69477       degStr = degNum.toString();
69478       input.property("value", degStr);
69479       corePreferences("validate-square-degrees", degStr);
69480       context.validator().revalidateUnsquare();
69481     }
69482     function isRuleEnabled(d2) {
69483       return context.validator().isRuleEnabled(d2);
69484     }
69485     function toggleRule(d3_event, d2) {
69486       context.validator().toggleRule(d2);
69487     }
69488     context.validator().on("validated.uiSectionValidationRules", function() {
69489       window.requestIdleCallback(section.reRender);
69490     });
69491     return section;
69492   }
69493
69494   // modules/ui/sections/validation_status.js
69495   function uiSectionValidationStatus(context) {
69496     var section = uiSection("issues-status", context).content(renderContent).shouldDisplay(function() {
69497       var issues = context.validator().getIssues(getOptions());
69498       return issues.length === 0;
69499     });
69500     function getOptions() {
69501       return {
69502         what: corePreferences("validate-what") || "edited",
69503         where: corePreferences("validate-where") || "all"
69504       };
69505     }
69506     function renderContent(selection2) {
69507       var box = selection2.selectAll(".box").data([0]);
69508       var boxEnter = box.enter().append("div").attr("class", "box");
69509       boxEnter.append("div").call(svgIcon("#iD-icon-apply", "pre-text"));
69510       var noIssuesMessage = boxEnter.append("span");
69511       noIssuesMessage.append("strong").attr("class", "message");
69512       noIssuesMessage.append("br");
69513       noIssuesMessage.append("span").attr("class", "details");
69514       renderIgnoredIssuesReset(selection2);
69515       setNoIssuesText(selection2);
69516     }
69517     function renderIgnoredIssuesReset(selection2) {
69518       var ignoredIssues = context.validator().getIssues({ what: "all", where: "all", includeDisabledRules: true, includeIgnored: "only" });
69519       var resetIgnored = selection2.selectAll(".reset-ignored").data(ignoredIssues.length ? [0] : []);
69520       resetIgnored.exit().remove();
69521       var resetIgnoredEnter = resetIgnored.enter().append("div").attr("class", "reset-ignored section-footer");
69522       resetIgnoredEnter.append("a").attr("href", "#");
69523       resetIgnored = resetIgnored.merge(resetIgnoredEnter);
69524       resetIgnored.select("a").html(_t.html("inspector.title_count", { title: { html: _t.html("issues.reset_ignored") }, count: ignoredIssues.length }));
69525       resetIgnored.on("click", function(d3_event) {
69526         d3_event.preventDefault();
69527         context.validator().resetIgnoredIssues();
69528       });
69529     }
69530     function setNoIssuesText(selection2) {
69531       var opts = getOptions();
69532       function checkForHiddenIssues(cases) {
69533         for (var type2 in cases) {
69534           var hiddenOpts = cases[type2];
69535           var hiddenIssues = context.validator().getIssues(hiddenOpts);
69536           if (hiddenIssues.length) {
69537             selection2.select(".box .details").html("").call(_t.append(
69538               "issues.no_issues.hidden_issues." + type2,
69539               { count: hiddenIssues.length.toString() }
69540             ));
69541             return;
69542           }
69543         }
69544         selection2.select(".box .details").html("").call(_t.append("issues.no_issues.hidden_issues.none"));
69545       }
69546       var messageType;
69547       if (opts.what === "edited" && opts.where === "visible") {
69548         messageType = "edits_in_view";
69549         checkForHiddenIssues({
69550           elsewhere: { what: "edited", where: "all" },
69551           everything_else: { what: "all", where: "visible" },
69552           disabled_rules: { what: "edited", where: "visible", includeDisabledRules: "only" },
69553           everything_else_elsewhere: { what: "all", where: "all" },
69554           disabled_rules_elsewhere: { what: "edited", where: "all", includeDisabledRules: "only" },
69555           ignored_issues: { what: "edited", where: "visible", includeIgnored: "only" },
69556           ignored_issues_elsewhere: { what: "edited", where: "all", includeIgnored: "only" }
69557         });
69558       } else if (opts.what === "edited" && opts.where === "all") {
69559         messageType = "edits";
69560         checkForHiddenIssues({
69561           everything_else: { what: "all", where: "all" },
69562           disabled_rules: { what: "edited", where: "all", includeDisabledRules: "only" },
69563           ignored_issues: { what: "edited", where: "all", includeIgnored: "only" }
69564         });
69565       } else if (opts.what === "all" && opts.where === "visible") {
69566         messageType = "everything_in_view";
69567         checkForHiddenIssues({
69568           elsewhere: { what: "all", where: "all" },
69569           disabled_rules: { what: "all", where: "visible", includeDisabledRules: "only" },
69570           disabled_rules_elsewhere: { what: "all", where: "all", includeDisabledRules: "only" },
69571           ignored_issues: { what: "all", where: "visible", includeIgnored: "only" },
69572           ignored_issues_elsewhere: { what: "all", where: "all", includeIgnored: "only" }
69573         });
69574       } else if (opts.what === "all" && opts.where === "all") {
69575         messageType = "everything";
69576         checkForHiddenIssues({
69577           disabled_rules: { what: "all", where: "all", includeDisabledRules: "only" },
69578           ignored_issues: { what: "all", where: "all", includeIgnored: "only" }
69579         });
69580       }
69581       if (opts.what === "edited" && context.history().difference().summary().length === 0) {
69582         messageType = "no_edits";
69583       }
69584       selection2.select(".box .message").html("").call(_t.append("issues.no_issues.message." + messageType));
69585     }
69586     context.validator().on("validated.uiSectionValidationStatus", function() {
69587       window.requestIdleCallback(section.reRender);
69588     });
69589     context.map().on(
69590       "move.uiSectionValidationStatus",
69591       debounce_default(function() {
69592         window.requestIdleCallback(section.reRender);
69593       }, 1e3)
69594     );
69595     return section;
69596   }
69597
69598   // modules/ui/panes/issues.js
69599   function uiPaneIssues(context) {
69600     var issuesPane = uiPane("issues", context).key(_t("issues.key")).label(_t.append("issues.title")).description(_t.append("issues.title")).iconName("iD-icon-alert").sections([
69601       uiSectionValidationOptions(context),
69602       uiSectionValidationStatus(context),
69603       uiSectionValidationIssues("issues-errors", "error", context),
69604       uiSectionValidationIssues("issues-warnings", "warning", context),
69605       uiSectionValidationRules(context)
69606     ]);
69607     return issuesPane;
69608   }
69609
69610   // modules/ui/settings/custom_data.js
69611   function uiSettingsCustomData(context) {
69612     var dispatch14 = dispatch_default("change");
69613     function render(selection2) {
69614       var dataLayer = context.layers().layer("data");
69615       var _origSettings = {
69616         fileList: dataLayer && dataLayer.fileList() || null,
69617         url: corePreferences("settings-custom-data-url")
69618       };
69619       var _currSettings = {
69620         fileList: dataLayer && dataLayer.fileList() || null
69621         // url: prefs('settings-custom-data-url')
69622       };
69623       var modal = uiConfirm(selection2).okButton();
69624       modal.classed("settings-modal settings-custom-data", true);
69625       modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_data.header"));
69626       var textSection = modal.select(".modal-section.message-text");
69627       textSection.append("pre").attr("class", "instructions-file").call(_t.append("settings.custom_data.file.instructions"));
69628       textSection.append("input").attr("class", "field-file").attr("type", "file").attr("accept", ".gpx,.kml,.geojson,.json,application/gpx+xml,application/vnd.google-earth.kml+xml,application/geo+json,application/json").property("files", _currSettings.fileList).on("change", function(d3_event) {
69629         var files = d3_event.target.files;
69630         if (files && files.length) {
69631           _currSettings.url = "";
69632           textSection.select(".field-url").property("value", "");
69633           _currSettings.fileList = files;
69634         } else {
69635           _currSettings.fileList = null;
69636         }
69637       });
69638       textSection.append("h4").call(_t.append("settings.custom_data.or"));
69639       textSection.append("pre").attr("class", "instructions-url").call(_t.append("settings.custom_data.url.instructions"));
69640       textSection.append("textarea").attr("class", "field-url").attr("placeholder", _t("settings.custom_data.url.placeholder")).call(utilNoAuto).property("value", _currSettings.url);
69641       var buttonSection = modal.select(".modal-section.buttons");
69642       buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
69643       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
69644       buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
69645       function isSaveDisabled() {
69646         return null;
69647       }
69648       function clickCancel() {
69649         textSection.select(".field-url").property("value", _origSettings.url);
69650         corePreferences("settings-custom-data-url", _origSettings.url);
69651         this.blur();
69652         modal.close();
69653       }
69654       function clickSave() {
69655         _currSettings.url = textSection.select(".field-url").property("value").trim();
69656         if (_currSettings.url) {
69657           _currSettings.fileList = null;
69658         }
69659         if (_currSettings.fileList) {
69660           _currSettings.url = "";
69661         }
69662         corePreferences("settings-custom-data-url", _currSettings.url);
69663         this.blur();
69664         modal.close();
69665         dispatch14.call("change", this, _currSettings);
69666       }
69667     }
69668     return utilRebind(render, dispatch14, "on");
69669   }
69670
69671   // modules/ui/sections/data_layers.js
69672   function uiSectionDataLayers(context) {
69673     var settingsCustomData = uiSettingsCustomData(context).on("change", customChanged);
69674     var layers = context.layers();
69675     var section = uiSection("data-layers", context).label(() => _t.append("map_data.data_layers")).disclosureContent(renderDisclosureContent);
69676     function renderDisclosureContent(selection2) {
69677       var container = selection2.selectAll(".data-layer-container").data([0]);
69678       container.enter().append("div").attr("class", "data-layer-container").merge(container).call(drawOsmItems).call(drawQAItems).call(drawCustomDataItems).call(drawVectorItems).call(drawPanelItems);
69679     }
69680     function showsLayer(which) {
69681       var layer = layers.layer(which);
69682       if (layer) {
69683         return layer.enabled();
69684       }
69685       return false;
69686     }
69687     function setLayer(which, enabled) {
69688       var mode = context.mode();
69689       if (mode && /^draw/.test(mode.id)) return;
69690       var layer = layers.layer(which);
69691       if (layer) {
69692         layer.enabled(enabled);
69693         if (!enabled && (which === "osm" || which === "notes")) {
69694           context.enter(modeBrowse(context));
69695         }
69696       }
69697     }
69698     function toggleLayer(which) {
69699       setLayer(which, !showsLayer(which));
69700     }
69701     function drawOsmItems(selection2) {
69702       var osmKeys = ["osm", "notes"];
69703       var osmLayers = layers.all().filter(function(obj) {
69704         return osmKeys.indexOf(obj.id) !== -1;
69705       });
69706       var ul = selection2.selectAll(".layer-list-osm").data([0]);
69707       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-osm").merge(ul);
69708       var li = ul.selectAll(".list-item").data(osmLayers);
69709       li.exit().remove();
69710       var liEnter = li.enter().append("li").attr("class", function(d2) {
69711         return "list-item list-item-" + d2.id;
69712       });
69713       var labelEnter = liEnter.append("label").each(function(d2) {
69714         if (d2.id === "osm") {
69715           select_default2(this).call(
69716             uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).keys([uiCmd("\u2325" + _t("area_fill.wireframe.key"))]).placement("bottom")
69717           );
69718         } else {
69719           select_default2(this).call(
69720             uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom")
69721           );
69722         }
69723       });
69724       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
69725         toggleLayer(d2.id);
69726       });
69727       labelEnter.append("span").html(function(d2) {
69728         return _t.html("map_data.layers." + d2.id + ".title");
69729       });
69730       li.merge(liEnter).classed("active", function(d2) {
69731         return d2.layer.enabled();
69732       }).selectAll("input").property("checked", function(d2) {
69733         return d2.layer.enabled();
69734       });
69735     }
69736     function drawQAItems(selection2) {
69737       var qaKeys = ["keepRight", "osmose"];
69738       var qaLayers = layers.all().filter(function(obj) {
69739         return qaKeys.indexOf(obj.id) !== -1;
69740       });
69741       var ul = selection2.selectAll(".layer-list-qa").data([0]);
69742       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-qa").merge(ul);
69743       var li = ul.selectAll(".list-item").data(qaLayers);
69744       li.exit().remove();
69745       var liEnter = li.enter().append("li").attr("class", function(d2) {
69746         return "list-item list-item-" + d2.id;
69747       });
69748       var labelEnter = liEnter.append("label").each(function(d2) {
69749         select_default2(this).call(
69750           uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom")
69751         );
69752       });
69753       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
69754         toggleLayer(d2.id);
69755       });
69756       labelEnter.append("span").each(function(d2) {
69757         _t.append("map_data.layers." + d2.id + ".title")(select_default2(this));
69758       });
69759       li.merge(liEnter).classed("active", function(d2) {
69760         return d2.layer.enabled();
69761       }).selectAll("input").property("checked", function(d2) {
69762         return d2.layer.enabled();
69763       });
69764     }
69765     function drawVectorItems(selection2) {
69766       var dataLayer = layers.layer("data");
69767       var vtData = [
69768         {
69769           name: "Detroit Neighborhoods/Parks",
69770           src: "neighborhoods-parks",
69771           tooltip: "Neighborhood boundaries and parks as compiled by City of Detroit in concert with community groups.",
69772           template: "https://{switch:a,b,c,d}.tiles.mapbox.com/v4/jonahadkins.cjksmur6x34562qp9iv1u3ksf-54hev,jonahadkins.cjksmqxdx33jj2wp90xd9x2md-4e5y2/{z}/{x}/{y}.vector.pbf?access_token=pk.eyJ1Ijoiam9uYWhhZGtpbnMiLCJhIjoiRlVVVkx3VSJ9.9sdVEK_B_VkEXPjssU5MqA"
69773         },
69774         {
69775           name: "Detroit Composite POIs",
69776           src: "composite-poi",
69777           tooltip: "Fire Inspections, Business Licenses, and other public location data collated from the City of Detroit.",
69778           template: "https://{switch:a,b,c,d}.tiles.mapbox.com/v4/jonahadkins.cjksmm6a02sli31myxhsr7zf3-2sw8h/{z}/{x}/{y}.vector.pbf?access_token=pk.eyJ1Ijoiam9uYWhhZGtpbnMiLCJhIjoiRlVVVkx3VSJ9.9sdVEK_B_VkEXPjssU5MqA"
69779         },
69780         {
69781           name: "Detroit All-The-Places POIs",
69782           src: "alltheplaces-poi",
69783           tooltip: "Public domain business location data created by web scrapers.",
69784           template: "https://{switch:a,b,c,d}.tiles.mapbox.com/v4/jonahadkins.cjksmswgk340g2vo06p1w9w0j-8fjjc/{z}/{x}/{y}.vector.pbf?access_token=pk.eyJ1Ijoiam9uYWhhZGtpbnMiLCJhIjoiRlVVVkx3VSJ9.9sdVEK_B_VkEXPjssU5MqA"
69785         }
69786       ];
69787       var detroit = geoExtent([-83.5, 42.1], [-82.8, 42.5]);
69788       var showVectorItems = context.map().zoom() > 9 && detroit.contains(context.map().center());
69789       var container = selection2.selectAll(".vectortile-container").data(showVectorItems ? [0] : []);
69790       container.exit().remove();
69791       var containerEnter = container.enter().append("div").attr("class", "vectortile-container");
69792       containerEnter.append("h4").attr("class", "vectortile-header").text("Detroit Vector Tiles (Beta)");
69793       containerEnter.append("ul").attr("class", "layer-list layer-list-vectortile");
69794       containerEnter.append("div").attr("class", "vectortile-footer").append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/osmus/detroit-mapping-challenge").append("span").text("About these layers");
69795       container = container.merge(containerEnter);
69796       var ul = container.selectAll(".layer-list-vectortile");
69797       var li = ul.selectAll(".list-item").data(vtData);
69798       li.exit().remove();
69799       var liEnter = li.enter().append("li").attr("class", function(d2) {
69800         return "list-item list-item-" + d2.src;
69801       });
69802       var labelEnter = liEnter.append("label").each(function(d2) {
69803         select_default2(this).call(
69804           uiTooltip().title(d2.tooltip).placement("top")
69805         );
69806       });
69807       labelEnter.append("input").attr("type", "radio").attr("name", "vectortile").on("change", selectVTLayer);
69808       labelEnter.append("span").text(function(d2) {
69809         return d2.name;
69810       });
69811       li.merge(liEnter).classed("active", isVTLayerSelected).selectAll("input").property("checked", isVTLayerSelected);
69812       function isVTLayerSelected(d2) {
69813         return dataLayer && dataLayer.template() === d2.template;
69814       }
69815       function selectVTLayer(d3_event, d2) {
69816         corePreferences("settings-custom-data-url", d2.template);
69817         if (dataLayer) {
69818           dataLayer.template(d2.template, d2.src);
69819           dataLayer.enabled(true);
69820         }
69821       }
69822     }
69823     function drawCustomDataItems(selection2) {
69824       var dataLayer = layers.layer("data");
69825       var hasData = dataLayer && dataLayer.hasData();
69826       var showsData = hasData && dataLayer.enabled();
69827       var ul = selection2.selectAll(".layer-list-data").data(dataLayer ? [0] : []);
69828       ul.exit().remove();
69829       var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-data");
69830       var liEnter = ulEnter.append("li").attr("class", "list-item-data");
69831       var labelEnter = liEnter.append("label").call(
69832         uiTooltip().title(() => _t.append("map_data.layers.custom.tooltip")).placement("top")
69833       );
69834       labelEnter.append("input").attr("type", "checkbox").on("change", function() {
69835         toggleLayer("data");
69836       });
69837       labelEnter.append("span").call(_t.append("map_data.layers.custom.title"));
69838       liEnter.append("button").attr("class", "open-data-options").call(
69839         uiTooltip().title(() => _t.append("settings.custom_data.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
69840       ).on("click", function(d3_event) {
69841         d3_event.preventDefault();
69842         editCustom();
69843       }).call(svgIcon("#iD-icon-more"));
69844       liEnter.append("button").attr("class", "zoom-to-data").call(
69845         uiTooltip().title(() => _t.append("map_data.layers.custom.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
69846       ).on("click", function(d3_event) {
69847         if (select_default2(this).classed("disabled")) return;
69848         d3_event.preventDefault();
69849         d3_event.stopPropagation();
69850         dataLayer.fitZoom();
69851       }).call(svgIcon("#iD-icon-framed-dot", "monochrome"));
69852       ul = ul.merge(ulEnter);
69853       ul.selectAll(".list-item-data").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData);
69854       ul.selectAll("button.zoom-to-data").classed("disabled", !hasData);
69855     }
69856     function editCustom() {
69857       context.container().call(settingsCustomData);
69858     }
69859     function customChanged(d2) {
69860       var dataLayer = layers.layer("data");
69861       if (d2 && d2.url) {
69862         dataLayer.url(d2.url);
69863       } else if (d2 && d2.fileList) {
69864         dataLayer.fileList(d2.fileList);
69865       }
69866     }
69867     function drawPanelItems(selection2) {
69868       var panelsListEnter = selection2.selectAll(".md-extras-list").data([0]).enter().append("ul").attr("class", "layer-list md-extras-list");
69869       var historyPanelLabelEnter = panelsListEnter.append("li").attr("class", "history-panel-toggle-item").append("label").call(
69870         uiTooltip().title(() => _t.append("map_data.history_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.history.key"))]).placement("top")
69871       );
69872       historyPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
69873         d3_event.preventDefault();
69874         context.ui().info.toggle("history");
69875       });
69876       historyPanelLabelEnter.append("span").call(_t.append("map_data.history_panel.title"));
69877       var measurementPanelLabelEnter = panelsListEnter.append("li").attr("class", "measurement-panel-toggle-item").append("label").call(
69878         uiTooltip().title(() => _t.append("map_data.measurement_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.measurement.key"))]).placement("top")
69879       );
69880       measurementPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
69881         d3_event.preventDefault();
69882         context.ui().info.toggle("measurement");
69883       });
69884       measurementPanelLabelEnter.append("span").call(_t.append("map_data.measurement_panel.title"));
69885     }
69886     context.layers().on("change.uiSectionDataLayers", section.reRender);
69887     context.map().on(
69888       "move.uiSectionDataLayers",
69889       debounce_default(function() {
69890         window.requestIdleCallback(section.reRender);
69891       }, 1e3)
69892     );
69893     return section;
69894   }
69895
69896   // modules/ui/sections/map_features.js
69897   function uiSectionMapFeatures(context) {
69898     var _features = context.features().keys();
69899     var section = uiSection("map-features", context).label(() => _t.append("map_data.map_features")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
69900     function renderDisclosureContent(selection2) {
69901       var container = selection2.selectAll(".layer-feature-list-container").data([0]);
69902       var containerEnter = container.enter().append("div").attr("class", "layer-feature-list-container");
69903       containerEnter.append("ul").attr("class", "layer-list layer-feature-list");
69904       var footer = containerEnter.append("div").attr("class", "feature-list-links section-footer");
69905       footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) {
69906         d3_event.preventDefault();
69907         context.features().disableAll();
69908       });
69909       footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) {
69910         d3_event.preventDefault();
69911         context.features().enableAll();
69912       });
69913       container = container.merge(containerEnter);
69914       container.selectAll(".layer-feature-list").call(drawListItems, _features, "checkbox", "feature", clickFeature, showsFeature);
69915     }
69916     function drawListItems(selection2, data, type2, name, change, active) {
69917       var items = selection2.selectAll("li").data(data);
69918       items.exit().remove();
69919       var enter = items.enter().append("li").call(
69920         uiTooltip().title(function(d2) {
69921           var tip = _t.append(name + "." + d2 + ".tooltip");
69922           if (autoHiddenFeature(d2)) {
69923             var msg = showsLayer("osm") ? _t.append("map_data.autohidden") : _t.append("map_data.osmhidden");
69924             return (selection3) => {
69925               selection3.call(tip);
69926               selection3.append("div").call(msg);
69927             };
69928           }
69929           return tip;
69930         }).placement("top")
69931       );
69932       var label = enter.append("label");
69933       label.append("input").attr("type", type2).attr("name", name).on("change", change);
69934       label.append("span").html(function(d2) {
69935         return _t.html(name + "." + d2 + ".description");
69936       });
69937       items = items.merge(enter);
69938       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", autoHiddenFeature);
69939     }
69940     function autoHiddenFeature(d2) {
69941       return context.features().autoHidden(d2);
69942     }
69943     function showsFeature(d2) {
69944       return context.features().enabled(d2);
69945     }
69946     function clickFeature(d3_event, d2) {
69947       context.features().toggle(d2);
69948     }
69949     function showsLayer(id2) {
69950       var layer = context.layers().layer(id2);
69951       return layer && layer.enabled();
69952     }
69953     context.features().on("change.map_features", section.reRender);
69954     return section;
69955   }
69956
69957   // modules/ui/sections/map_style_options.js
69958   function uiSectionMapStyleOptions(context) {
69959     var section = uiSection("fill-area", context).label(() => _t.append("map_data.style_options")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
69960     function renderDisclosureContent(selection2) {
69961       var container = selection2.selectAll(".layer-fill-list").data([0]);
69962       container.enter().append("ul").attr("class", "layer-list layer-fill-list").merge(container).call(drawListItems, context.map().areaFillOptions, "radio", "area_fill", setFill, isActiveFill);
69963       var container2 = selection2.selectAll(".layer-visual-diff-list").data([0]);
69964       container2.enter().append("ul").attr("class", "layer-list layer-visual-diff-list").merge(container2).call(drawListItems, ["highlight_edits"], "checkbox", "visual_diff", toggleHighlightEdited, function() {
69965         return context.surface().classed("highlight-edited");
69966       });
69967     }
69968     function drawListItems(selection2, data, type2, name, change, active) {
69969       var items = selection2.selectAll("li").data(data);
69970       items.exit().remove();
69971       var enter = items.enter().append("li").call(
69972         uiTooltip().title(function(d2) {
69973           return _t.append(name + "." + d2 + ".tooltip");
69974         }).keys(function(d2) {
69975           var key = d2 === "wireframe" ? _t("area_fill.wireframe.key") : null;
69976           if (d2 === "highlight_edits") key = _t("map_data.highlight_edits.key");
69977           return key ? [key] : null;
69978         }).placement("top")
69979       );
69980       var label = enter.append("label");
69981       label.append("input").attr("type", type2).attr("name", name).on("change", change);
69982       label.append("span").html(function(d2) {
69983         return _t.html(name + "." + d2 + ".description");
69984       });
69985       items = items.merge(enter);
69986       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false);
69987     }
69988     function isActiveFill(d2) {
69989       return context.map().activeAreaFill() === d2;
69990     }
69991     function toggleHighlightEdited(d3_event) {
69992       d3_event.preventDefault();
69993       context.map().toggleHighlightEdited();
69994     }
69995     function setFill(d3_event, d2) {
69996       context.map().activeAreaFill(d2);
69997     }
69998     context.map().on("changeHighlighting.ui_style, changeAreaFill.ui_style", section.reRender);
69999     return section;
70000   }
70001
70002   // modules/ui/settings/local_photos.js
70003   function uiSettingsLocalPhotos(context) {
70004     var dispatch14 = dispatch_default("change");
70005     var photoLayer = context.layers().layer("local-photos");
70006     var modal;
70007     function render(selection2) {
70008       modal = uiConfirm(selection2).okButton();
70009       modal.classed("settings-modal settings-local-photos", true);
70010       modal.select(".modal-section.header").append("h3").call(_t.append("local_photos.header"));
70011       modal.select(".modal-section.message-text").append("div").classed("local-photos", true);
70012       var instructionsSection = modal.select(".modal-section.message-text .local-photos").append("div").classed("instructions", true);
70013       instructionsSection.append("p").classed("instructions-local-photos", true).call(_t.append("local_photos.file.instructions"));
70014       instructionsSection.append("input").classed("field-file", true).attr("type", "file").attr("multiple", "multiple").attr("accept", ".jpg,.jpeg,.png,image/png,image/jpeg").style("visibility", "hidden").attr("id", "local-photo-files").on("change", function(d3_event) {
70015         var files = d3_event.target.files;
70016         if (files && files.length) {
70017           photoList.select("ul").append("li").classed("placeholder", true).append("div");
70018           dispatch14.call("change", this, files);
70019         }
70020         d3_event.target.value = null;
70021       });
70022       instructionsSection.append("label").attr("for", "local-photo-files").classed("button", true).call(_t.append("local_photos.file.label"));
70023       const photoList = modal.select(".modal-section.message-text .local-photos").append("div").append("div").classed("list-local-photos", true);
70024       photoList.append("ul");
70025       updatePhotoList(photoList.select("ul"));
70026       context.layers().on("change", () => updatePhotoList(photoList.select("ul")));
70027     }
70028     function updatePhotoList(container) {
70029       var _a4;
70030       function locationUnavailable(d2) {
70031         return !(isArray_default(d2.loc) && isNumber_default(d2.loc[0]) && isNumber_default(d2.loc[1]));
70032       }
70033       container.selectAll("li.placeholder").remove();
70034       let selection2 = container.selectAll("li").data((_a4 = photoLayer.getPhotos()) != null ? _a4 : [], (d2) => d2.id);
70035       selection2.exit().remove();
70036       const selectionEnter = selection2.enter().append("li");
70037       selectionEnter.append("span").classed("filename", true);
70038       selectionEnter.append("button").classed("form-field-button zoom-to-data", true).attr("title", _t("local_photos.zoom_single")).call(svgIcon("#iD-icon-framed-dot"));
70039       selectionEnter.append("button").classed("form-field-button no-geolocation", true).call(svgIcon("#iD-icon-alert")).call(
70040         uiTooltip().title(() => _t.append("local_photos.no_geolocation.tooltip")).placement("left")
70041       );
70042       selectionEnter.append("button").classed("form-field-button remove", true).attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
70043       selection2 = selection2.merge(selectionEnter);
70044       selection2.classed("invalid", locationUnavailable);
70045       selection2.select("span.filename").text((d2) => d2.name).attr("title", (d2) => d2.name);
70046       selection2.select("span.filename").on("click", (d3_event, d2) => {
70047         photoLayer.openPhoto(d3_event, d2, false);
70048       });
70049       selection2.select("button.zoom-to-data").on("click", (d3_event, d2) => {
70050         photoLayer.openPhoto(d3_event, d2, true);
70051       });
70052       selection2.select("button.remove").on("click", (d3_event, d2) => {
70053         photoLayer.removePhoto(d2.id);
70054         updatePhotoList(container);
70055       });
70056     }
70057     return utilRebind(render, dispatch14, "on");
70058   }
70059
70060   // modules/ui/sections/photo_overlays.js
70061   function uiSectionPhotoOverlays(context) {
70062     var settingsLocalPhotos = uiSettingsLocalPhotos(context).on("change", localPhotosChanged);
70063     var layers = context.layers();
70064     var section = uiSection("photo-overlays", context).label(() => _t.append("photo_overlays.title")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
70065     function renderDisclosureContent(selection2) {
70066       var container = selection2.selectAll(".photo-overlay-container").data([0]);
70067       container.enter().append("div").attr("class", "photo-overlay-container").merge(container).call(drawPhotoItems).call(drawPhotoTypeItems).call(drawDateFilter).call(drawUsernameFilter).call(drawLocalPhotos);
70068     }
70069     function drawPhotoItems(selection2) {
70070       var photoKeys = context.photos().overlayLayerIDs();
70071       var photoLayers = layers.all().filter(function(obj) {
70072         return photoKeys.indexOf(obj.id) !== -1;
70073       });
70074       var data = photoLayers.filter(function(obj) {
70075         if (!obj.layer.supported()) return false;
70076         if (layerEnabled(obj)) return true;
70077         if (typeof obj.layer.validHere === "function") {
70078           return obj.layer.validHere(context.map().extent(), context.map().zoom());
70079         }
70080         return true;
70081       });
70082       function layerSupported(d2) {
70083         return d2.layer && d2.layer.supported();
70084       }
70085       function layerEnabled(d2) {
70086         return layerSupported(d2) && d2.layer.enabled();
70087       }
70088       function layerRendered(d2) {
70089         var _a4, _b3, _c2;
70090         return (_c2 = (_b3 = (_a4 = d2.layer).rendered) == null ? void 0 : _b3.call(_a4, context.map().zoom())) != null ? _c2 : true;
70091       }
70092       var ul = selection2.selectAll(".layer-list-photos").data([0]);
70093       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photos").merge(ul);
70094       var li = ul.selectAll(".list-item-photos").data(data, (d2) => d2.id);
70095       li.exit().remove();
70096       var liEnter = li.enter().append("li").attr("class", function(d2) {
70097         var classes = "list-item-photos list-item-" + d2.id;
70098         if (d2.id === "mapillary-signs" || d2.id === "mapillary-map-features") {
70099           classes += " indented";
70100         }
70101         return classes;
70102       });
70103       var labelEnter = liEnter.append("label").each(function(d2) {
70104         var titleID;
70105         if (d2.id === "mapillary-signs") titleID = "mapillary.signs.tooltip";
70106         else if (d2.id === "mapillary") titleID = "mapillary_images.tooltip";
70107         else if (d2.id === "kartaview") titleID = "kartaview_images.tooltip";
70108         else titleID = d2.id.replace(/-/g, "_") + ".tooltip";
70109         select_default2(this).call(
70110           uiTooltip().title(() => {
70111             if (!layerRendered(d2)) {
70112               return _t.append("street_side.minzoom_tooltip");
70113             } else {
70114               return _t.append(titleID);
70115             }
70116           }).placement("top")
70117         );
70118       });
70119       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
70120         toggleLayer(d2.id);
70121       });
70122       labelEnter.append("span").html(function(d2) {
70123         var id2 = d2.id;
70124         if (id2 === "mapillary-signs") id2 = "photo_overlays.traffic_signs";
70125         return _t.html(id2.replace(/-/g, "_") + ".title");
70126       });
70127       li.merge(liEnter).classed("active", layerEnabled).selectAll("input").property("disabled", (d2) => !layerRendered(d2)).property("checked", layerEnabled);
70128     }
70129     function drawPhotoTypeItems(selection2) {
70130       var data = context.photos().allPhotoTypes();
70131       function typeEnabled(d2) {
70132         return context.photos().showsPhotoType(d2);
70133       }
70134       var ul = selection2.selectAll(".layer-list-photo-types").data([0]);
70135       ul.exit().remove();
70136       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photo-types").merge(ul);
70137       var li = ul.selectAll(".list-item-photo-types").data(context.photos().shouldFilterByPhotoType() ? data : []);
70138       li.exit().remove();
70139       var liEnter = li.enter().append("li").attr("class", function(d2) {
70140         return "list-item-photo-types list-item-" + d2;
70141       });
70142       var labelEnter = liEnter.append("label").each(function(d2) {
70143         select_default2(this).call(
70144           uiTooltip().title(() => _t.append("photo_overlays.photo_type." + d2 + ".tooltip")).placement("top")
70145         );
70146       });
70147       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
70148         context.photos().togglePhotoType(d2);
70149       });
70150       labelEnter.append("span").html(function(d2) {
70151         return _t.html("photo_overlays.photo_type." + d2 + ".title");
70152       });
70153       li.merge(liEnter).classed("active", typeEnabled).selectAll("input").property("checked", typeEnabled);
70154     }
70155     function drawDateFilter(selection2) {
70156       var data = context.photos().dateFilters();
70157       function filterEnabled(d2) {
70158         return context.photos().dateFilterValue(d2);
70159       }
70160       var ul = selection2.selectAll(".layer-list-date-filter").data([0]);
70161       ul.exit().remove();
70162       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-date-filter").merge(ul);
70163       var li = ul.selectAll(".list-item-date-filter").data(context.photos().shouldFilterByDate() ? data : []);
70164       li.exit().remove();
70165       var liEnter = li.enter().append("li").attr("class", "list-item-date-filter");
70166       var labelEnter = liEnter.append("label").each(function(d2) {
70167         select_default2(this).call(
70168           uiTooltip().title(() => _t.append("photo_overlays.date_filter." + d2 + ".tooltip")).placement("top")
70169         );
70170       });
70171       labelEnter.append("span").each(function(d2) {
70172         _t.append("photo_overlays.date_filter." + d2 + ".title")(select_default2(this));
70173       });
70174       labelEnter.append("input").attr("type", "date").attr("class", "list-item-input").attr("placeholder", _t("units.year_month_day")).call(utilNoAuto).each(function(d2) {
70175         utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d2) || "");
70176       }).on("change", function(d3_event, d2) {
70177         var value = utilGetSetValue(select_default2(this)).trim();
70178         context.photos().setDateFilter(d2, value, true);
70179         li.selectAll("input").each(function(d4) {
70180           utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d4) || "");
70181         });
70182       });
70183       li = li.merge(liEnter).classed("active", filterEnabled);
70184     }
70185     function drawUsernameFilter(selection2) {
70186       function filterEnabled() {
70187         return context.photos().usernames();
70188       }
70189       var ul = selection2.selectAll(".layer-list-username-filter").data([0]);
70190       ul.exit().remove();
70191       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-username-filter").merge(ul);
70192       var li = ul.selectAll(".list-item-username-filter").data(context.photos().shouldFilterByUsername() ? ["username-filter"] : []);
70193       li.exit().remove();
70194       var liEnter = li.enter().append("li").attr("class", "list-item-username-filter");
70195       var labelEnter = liEnter.append("label").each(function() {
70196         select_default2(this).call(
70197           uiTooltip().title(() => _t.append("photo_overlays.username_filter.tooltip")).placement("top")
70198         );
70199       });
70200       labelEnter.append("span").call(_t.append("photo_overlays.username_filter.title"));
70201       labelEnter.append("input").attr("type", "text").attr("class", "list-item-input").call(utilNoAuto).property("value", usernameValue).on("change", function() {
70202         var value = select_default2(this).property("value");
70203         context.photos().setUsernameFilter(value, true);
70204         select_default2(this).property("value", usernameValue);
70205       });
70206       li.merge(liEnter).classed("active", filterEnabled);
70207       function usernameValue() {
70208         var usernames = context.photos().usernames();
70209         if (usernames) return usernames.join("; ");
70210         return usernames;
70211       }
70212     }
70213     function toggleLayer(which) {
70214       setLayer(which, !showsLayer(which));
70215     }
70216     function showsLayer(which) {
70217       var layer = layers.layer(which);
70218       if (layer) {
70219         return layer.enabled();
70220       }
70221       return false;
70222     }
70223     function setLayer(which, enabled) {
70224       var layer = layers.layer(which);
70225       if (layer) {
70226         layer.enabled(enabled);
70227       }
70228     }
70229     function drawLocalPhotos(selection2) {
70230       var photoLayer = layers.layer("local-photos");
70231       var hasData = photoLayer && photoLayer.hasData();
70232       var showsData = hasData && photoLayer.enabled();
70233       var ul = selection2.selectAll(".layer-list-local-photos").data(photoLayer ? [0] : []);
70234       ul.exit().remove();
70235       var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-local-photos");
70236       var localPhotosEnter = ulEnter.append("li").attr("class", "list-item-local-photos");
70237       var localPhotosLabelEnter = localPhotosEnter.append("label").call(uiTooltip().title(() => _t.append("local_photos.tooltip")));
70238       localPhotosLabelEnter.append("input").attr("type", "checkbox").on("change", function() {
70239         toggleLayer("local-photos");
70240       });
70241       localPhotosLabelEnter.call(_t.append("local_photos.header"));
70242       localPhotosEnter.append("button").attr("class", "open-data-options").call(
70243         uiTooltip().title(() => _t.append("local_photos.tooltip_edit")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
70244       ).on("click", function(d3_event) {
70245         d3_event.preventDefault();
70246         editLocalPhotos();
70247       }).call(svgIcon("#iD-icon-more"));
70248       localPhotosEnter.append("button").attr("class", "zoom-to-data").call(
70249         uiTooltip().title(() => _t.append("local_photos.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
70250       ).on("click", function(d3_event) {
70251         if (select_default2(this).classed("disabled")) return;
70252         d3_event.preventDefault();
70253         d3_event.stopPropagation();
70254         photoLayer.fitZoom();
70255       }).call(svgIcon("#iD-icon-framed-dot", "monochrome"));
70256       ul = ul.merge(ulEnter);
70257       ul.selectAll(".list-item-local-photos").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData);
70258       ul.selectAll("button.zoom-to-data").classed("disabled", !hasData);
70259     }
70260     function editLocalPhotos() {
70261       context.container().call(settingsLocalPhotos);
70262     }
70263     function localPhotosChanged(d2) {
70264       var localPhotosLayer = layers.layer("local-photos");
70265       localPhotosLayer.fileList(d2);
70266     }
70267     context.layers().on("change.uiSectionPhotoOverlays", section.reRender);
70268     context.photos().on("change.uiSectionPhotoOverlays", section.reRender);
70269     context.map().on(
70270       "move.photo_overlays",
70271       debounce_default(function() {
70272         window.requestIdleCallback(section.reRender);
70273       }, 1e3)
70274     );
70275     return section;
70276   }
70277
70278   // modules/ui/panes/map_data.js
70279   function uiPaneMapData(context) {
70280     var mapDataPane = uiPane("map-data", context).key(_t("map_data.key")).label(_t.append("map_data.title")).description(_t.append("map_data.description")).iconName("iD-icon-data").sections([
70281       uiSectionDataLayers(context),
70282       uiSectionPhotoOverlays(context),
70283       uiSectionMapStyleOptions(context),
70284       uiSectionMapFeatures(context)
70285     ]);
70286     return mapDataPane;
70287   }
70288
70289   // modules/ui/panes/preferences.js
70290   function uiPanePreferences(context) {
70291     let preferencesPane = uiPane("preferences", context).key(_t("preferences.key")).label(_t.append("preferences.title")).description(_t.append("preferences.description")).iconName("fas-user-cog").sections([
70292       uiSectionPrivacy(context)
70293     ]);
70294     return preferencesPane;
70295   }
70296
70297   // modules/ui/init.js
70298   function uiInit(context) {
70299     var _initCounter = 0;
70300     var _needWidth = {};
70301     var _lastPointerType;
70302     var overMap;
70303     function render(container) {
70304       container.on("click.ui", function(d3_event) {
70305         if (d3_event.button !== 0) return;
70306         if (!d3_event.composedPath) return;
70307         var isOkayTarget = d3_event.composedPath().some(function(node) {
70308           return node.nodeType === 1 && // clicking <input> focuses it and/or changes a value
70309           (node.nodeName === "INPUT" || // clicking <label> affects its <input> by default
70310           node.nodeName === "LABEL" || // clicking <a> opens a hyperlink by default
70311           node.nodeName === "A");
70312         });
70313         if (isOkayTarget) return;
70314         d3_event.preventDefault();
70315       });
70316       var detected = utilDetect();
70317       if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping,
70318       // but we only need to do this on desktop Safari anyway. – #7694
70319       !detected.isMobileWebKit) {
70320         container.on("gesturestart.ui gesturechange.ui gestureend.ui", function(d3_event) {
70321           d3_event.preventDefault();
70322         });
70323       }
70324       if ("PointerEvent" in window) {
70325         select_default2(window).on("pointerdown.ui pointerup.ui", function(d3_event) {
70326           var pointerType = d3_event.pointerType || "mouse";
70327           if (_lastPointerType !== pointerType) {
70328             _lastPointerType = pointerType;
70329             container.attr("pointer", pointerType);
70330           }
70331         }, true);
70332       } else {
70333         _lastPointerType = "mouse";
70334         container.attr("pointer", "mouse");
70335       }
70336       container.attr("lang", _mainLocalizer.localeCode()).attr("dir", _mainLocalizer.textDirection());
70337       container.call(uiFullScreen(context));
70338       var map2 = context.map();
70339       map2.redrawEnable(false);
70340       map2.on("hitMinZoom.ui", function() {
70341         ui.flash.iconName("#iD-icon-no").label(_t.append("cannot_zoom"))();
70342       });
70343       container.append("svg").attr("id", "ideditor-defs").call(ui.svgDefs);
70344       container.append("div").attr("class", "sidebar").call(ui.sidebar);
70345       var content = container.append("div").attr("class", "main-content active");
70346       content.append("div").attr("class", "top-toolbar-wrap").append("div").attr("class", "top-toolbar fillD").call(uiTopToolbar(context));
70347       content.append("div").attr("class", "main-map").attr("dir", "ltr").call(map2);
70348       overMap = content.append("div").attr("class", "over-map");
70349       overMap.append("div").attr("class", "select-trap").text("t");
70350       overMap.call(uiMapInMap(context)).call(uiNotice(context));
70351       overMap.append("div").attr("class", "spinner").call(uiSpinner(context));
70352       var controlsWrap = overMap.append("div").attr("class", "map-controls-wrap");
70353       var controls = controlsWrap.append("div").attr("class", "map-controls");
70354       controls.append("div").attr("class", "map-control zoombuttons").call(uiZoom(context));
70355       controls.append("div").attr("class", "map-control zoom-to-selection-control").call(uiZoomToSelection(context));
70356       controls.append("div").attr("class", "map-control geolocate-control").call(uiGeolocate(context));
70357       controlsWrap.on("wheel.mapControls", function(d3_event) {
70358         if (!d3_event.deltaX) {
70359           controlsWrap.node().scrollTop += d3_event.deltaY;
70360         }
70361       });
70362       var panes = overMap.append("div").attr("class", "map-panes");
70363       var uiPanes = [
70364         uiPaneBackground(context),
70365         uiPaneMapData(context),
70366         uiPaneIssues(context),
70367         uiPanePreferences(context),
70368         uiPaneHelp(context)
70369       ];
70370       uiPanes.forEach(function(pane) {
70371         controls.append("div").attr("class", "map-control map-pane-control " + pane.id + "-control").call(pane.renderToggleButton);
70372         panes.call(pane.renderPane);
70373       });
70374       ui.info = uiInfo(context);
70375       overMap.call(ui.info);
70376       overMap.append("div").attr("class", "photoviewer").classed("al", true).classed("hide", true).call(ui.photoviewer);
70377       overMap.append("div").attr("class", "attribution-wrap").attr("dir", "ltr").call(uiAttribution(context));
70378       var about = content.append("div").attr("class", "map-footer");
70379       about.append("div").attr("class", "api-status").call(uiStatus(context));
70380       var footer = about.append("div").attr("class", "map-footer-bar fillD");
70381       footer.append("div").attr("class", "flash-wrap footer-hide");
70382       var footerWrap = footer.append("div").attr("class", "main-footer-wrap footer-show");
70383       footerWrap.append("div").attr("class", "scale-block").call(uiScale(context));
70384       var aboutList = footerWrap.append("div").attr("class", "info-block").append("ul").attr("class", "map-footer-list");
70385       aboutList.append("li").attr("class", "user-list").call(uiContributors(context));
70386       var apiConnections = context.connection().apiConnections();
70387       if (apiConnections && apiConnections.length > 1) {
70388         aboutList.append("li").attr("class", "source-switch").call(
70389           uiSourceSwitch(context).keys(apiConnections)
70390         );
70391       }
70392       aboutList.append("li").attr("class", "issues-info").call(uiIssuesInfo(context));
70393       aboutList.append("li").attr("class", "feature-warning").call(uiFeatureInfo(context));
70394       var issueLinks = aboutList.append("li");
70395       issueLinks.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD/issues").attr("aria-label", _t("report_a_bug")).call(svgIcon("#iD-icon-bug", "light")).call(uiTooltip().title(() => _t.append("report_a_bug")).placement("top"));
70396       issueLinks.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD/blob/develop/CONTRIBUTING.md#translating").attr("aria-label", _t("help_translate")).call(svgIcon("#iD-icon-translate", "light")).call(uiTooltip().title(() => _t.append("help_translate")).placement("top"));
70397       aboutList.append("li").attr("class", "version").call(uiVersion(context));
70398       if (!context.embed()) {
70399         aboutList.call(uiAccount(context));
70400       }
70401       ui.onResize();
70402       map2.redrawEnable(true);
70403       ui.hash = behaviorHash(context);
70404       ui.hash();
70405       if (!ui.hash.hadLocation) {
70406         map2.centerZoom([0, 0], 2);
70407       }
70408       window.onbeforeunload = function() {
70409         return context.save();
70410       };
70411       window.onunload = function() {
70412         context.history().unlock();
70413       };
70414       select_default2(window).on("resize.editor", function() {
70415         ui.onResize();
70416       });
70417       var panPixels = 80;
70418       context.keybinding().on([_t("sidebar.key"), "`", "\xB2", "@"], ui.sidebar.toggle).on("\u2190", pan([panPixels, 0])).on("\u2191", pan([0, panPixels])).on("\u2192", pan([-panPixels, 0])).on("\u2193", pan([0, -panPixels])).on(uiCmd("\u2325\u2190"), pan([map2.dimensions()[0], 0])).on(uiCmd("\u2325\u2191"), pan([0, map2.dimensions()[1]])).on(uiCmd("\u2325\u2192"), pan([-map2.dimensions()[0], 0])).on(uiCmd("\u2325\u2193"), pan([0, -map2.dimensions()[1]])).on(uiCmd("\u2318" + _t("background.key")), function quickSwitch(d3_event) {
70419         if (d3_event) {
70420           d3_event.stopImmediatePropagation();
70421           d3_event.preventDefault();
70422         }
70423         var previousBackground = context.background().findSource(corePreferences("background-last-used-toggle"));
70424         if (previousBackground) {
70425           var currentBackground = context.background().baseLayerSource();
70426           corePreferences("background-last-used-toggle", currentBackground.id);
70427           corePreferences("background-last-used", previousBackground.id);
70428           context.background().baseLayerSource(previousBackground);
70429         }
70430       }).on(_t("area_fill.wireframe.key"), function toggleWireframe(d3_event) {
70431         d3_event.preventDefault();
70432         d3_event.stopPropagation();
70433         context.map().toggleWireframe();
70434       }).on(uiCmd("\u2325" + _t("area_fill.wireframe.key")), function toggleOsmData(d3_event) {
70435         d3_event.preventDefault();
70436         d3_event.stopPropagation();
70437         var mode = context.mode();
70438         if (mode && /^draw/.test(mode.id)) return;
70439         var layer = context.layers().layer("osm");
70440         if (layer) {
70441           layer.enabled(!layer.enabled());
70442           if (!layer.enabled()) {
70443             context.enter(modeBrowse(context));
70444           }
70445         }
70446       }).on(_t("map_data.highlight_edits.key"), function toggleHighlightEdited(d3_event) {
70447         d3_event.preventDefault();
70448         context.map().toggleHighlightEdited();
70449       });
70450       context.on("enter.editor", function(entered) {
70451         container.classed("mode-" + entered.id, true);
70452       }).on("exit.editor", function(exited) {
70453         container.classed("mode-" + exited.id, false);
70454       });
70455       context.enter(modeBrowse(context));
70456       if (!_initCounter++) {
70457         if (!ui.hash.startWalkthrough) {
70458           context.container().call(uiSplash(context)).call(uiRestore(context));
70459         }
70460         context.container().call(ui.shortcuts);
70461       }
70462       var osm = context.connection();
70463       var auth = uiLoading(context).message(_t.html("loading_auth")).blocking(true);
70464       if (osm && auth) {
70465         osm.on("authLoading.ui", function() {
70466           context.container().call(auth);
70467         }).on("authDone.ui", function() {
70468           auth.close();
70469         });
70470       }
70471       _initCounter++;
70472       if (ui.hash.startWalkthrough) {
70473         ui.hash.startWalkthrough = false;
70474         context.container().call(uiIntro(context));
70475       }
70476       function pan(d2) {
70477         return function(d3_event) {
70478           if (d3_event.shiftKey) return;
70479           if (context.container().select(".combobox").size()) return;
70480           d3_event.preventDefault();
70481           context.map().pan(d2, 100);
70482         };
70483       }
70484     }
70485     let ui = {};
70486     let _loadPromise;
70487     ui.ensureLoaded = () => {
70488       if (_loadPromise) return _loadPromise;
70489       return _loadPromise = Promise.all([
70490         // must have strings and presets before loading the UI
70491         _mainLocalizer.ensureLoaded(),
70492         _mainPresetIndex.ensureLoaded()
70493       ]).then(() => {
70494         if (!context.container().empty()) render(context.container());
70495       }).catch((err) => console.error(err));
70496     };
70497     ui.restart = function() {
70498       context.keybinding().clear();
70499       _loadPromise = null;
70500       context.container().selectAll("*").remove();
70501       ui.ensureLoaded();
70502     };
70503     ui.lastPointerType = function() {
70504       return _lastPointerType;
70505     };
70506     ui.svgDefs = svgDefs(context);
70507     ui.flash = uiFlash(context);
70508     ui.sidebar = uiSidebar(context);
70509     ui.photoviewer = uiPhotoviewer(context);
70510     ui.shortcuts = uiShortcuts(context);
70511     ui.onResize = function(withPan) {
70512       var map2 = context.map();
70513       var mapDimensions = utilGetDimensions(context.container().select(".main-content"), true);
70514       utilGetDimensions(context.container().select(".sidebar"), true);
70515       if (withPan !== void 0) {
70516         map2.redrawEnable(false);
70517         map2.pan(withPan);
70518         map2.redrawEnable(true);
70519       }
70520       map2.dimensions(mapDimensions);
70521       ui.photoviewer.onMapResize();
70522       ui.checkOverflow(".top-toolbar");
70523       ui.checkOverflow(".map-footer-bar");
70524       var resizeWindowEvent = document.createEvent("Event");
70525       resizeWindowEvent.initEvent("resizeWindow", true, true);
70526       document.dispatchEvent(resizeWindowEvent);
70527     };
70528     ui.checkOverflow = function(selector, reset) {
70529       if (reset) {
70530         delete _needWidth[selector];
70531       }
70532       var selection2 = context.container().select(selector);
70533       if (selection2.empty()) return;
70534       var scrollWidth = selection2.property("scrollWidth");
70535       var clientWidth = selection2.property("clientWidth");
70536       var needed = _needWidth[selector] || scrollWidth;
70537       if (scrollWidth > clientWidth) {
70538         selection2.classed("narrow", true);
70539         if (!_needWidth[selector]) {
70540           _needWidth[selector] = scrollWidth;
70541         }
70542       } else if (scrollWidth >= needed) {
70543         selection2.classed("narrow", false);
70544       }
70545     };
70546     ui.togglePanes = function(showPane) {
70547       var hidePanes = context.container().selectAll(".map-pane.shown");
70548       var side = _mainLocalizer.textDirection() === "ltr" ? "right" : "left";
70549       hidePanes.classed("shown", false).classed("hide", true);
70550       context.container().selectAll(".map-pane-control button").classed("active", false);
70551       if (showPane) {
70552         hidePanes.classed("shown", false).classed("hide", true).style(side, "-500px");
70553         context.container().selectAll("." + showPane.attr("pane") + "-control button").classed("active", true);
70554         showPane.classed("shown", true).classed("hide", false);
70555         if (hidePanes.empty()) {
70556           showPane.style(side, "-500px").transition().duration(200).style(side, "0px");
70557         } else {
70558           showPane.style(side, "0px");
70559         }
70560       } else {
70561         hidePanes.classed("shown", true).classed("hide", false).style(side, "0px").transition().duration(200).style(side, "-500px").on("end", function() {
70562           select_default2(this).classed("shown", false).classed("hide", true);
70563         });
70564       }
70565     };
70566     var _editMenu = uiEditMenu(context);
70567     ui.editMenu = function() {
70568       return _editMenu;
70569     };
70570     ui.showEditMenu = function(anchorPoint, triggerType, operations) {
70571       ui.closeEditMenu();
70572       if (!operations && context.mode().operations) operations = context.mode().operations();
70573       if (!operations || !operations.length) return;
70574       if (!context.map().editableDataEnabled()) return;
70575       var surfaceNode = context.surface().node();
70576       if (surfaceNode.focus) {
70577         surfaceNode.focus();
70578       }
70579       operations.forEach(function(operation2) {
70580         if (operation2.point) operation2.point(anchorPoint);
70581       });
70582       _editMenu.anchorLoc(anchorPoint).triggerType(triggerType).operations(operations);
70583       overMap.call(_editMenu);
70584     };
70585     ui.closeEditMenu = function() {
70586       if (overMap !== void 0) {
70587         overMap.select(".edit-menu").remove();
70588       }
70589     };
70590     var _saveLoading = select_default2(null);
70591     context.uploader().on("saveStarted.ui", function() {
70592       _saveLoading = uiLoading(context).message(_t.html("save.uploading")).blocking(true);
70593       context.container().call(_saveLoading);
70594     }).on("saveEnded.ui", function() {
70595       _saveLoading.close();
70596       _saveLoading = select_default2(null);
70597     });
70598     marked.use({
70599       mangle: false,
70600       headerIds: false
70601     });
70602     return ui;
70603   }
70604
70605   // modules/ui/commit_warnings.js
70606   function uiCommitWarnings(context) {
70607     function commitWarnings(selection2) {
70608       var issuesBySeverity = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeDisabledRules: true });
70609       for (var severity in issuesBySeverity) {
70610         var issues = issuesBySeverity[severity];
70611         if (severity !== "error") {
70612           issues = issues.filter(function(issue) {
70613             return issue.type !== "help_request";
70614           });
70615         }
70616         var section = severity + "-section";
70617         var issueItem = severity + "-item";
70618         var container = selection2.selectAll("." + section).data(issues.length ? [0] : []);
70619         container.exit().remove();
70620         var containerEnter = container.enter().append("div").attr("class", "modal-section " + section + " fillL2");
70621         containerEnter.append("h3").call(severity === "warning" ? _t.append("commit.warnings") : _t.append("commit.errors"));
70622         containerEnter.append("ul").attr("class", "changeset-list");
70623         container = containerEnter.merge(container);
70624         var items = container.select("ul").selectAll("li").data(issues, function(d2) {
70625           return d2.key;
70626         });
70627         items.exit().remove();
70628         var itemsEnter = items.enter().append("li").attr("class", issueItem);
70629         var buttons = itemsEnter.append("button").on("mouseover", function(d3_event, d2) {
70630           if (d2.entityIds) {
70631             context.surface().selectAll(
70632               utilEntityOrMemberSelector(
70633                 d2.entityIds,
70634                 context.graph()
70635               )
70636             ).classed("hover", true);
70637           }
70638         }).on("mouseout", function() {
70639           context.surface().selectAll(".hover").classed("hover", false);
70640         }).on("click", function(d3_event, d2) {
70641           context.validator().focusIssue(d2);
70642         });
70643         buttons.call(svgIcon("#iD-icon-alert", "pre-text"));
70644         buttons.append("strong").attr("class", "issue-message");
70645         buttons.filter(function(d2) {
70646           return d2.tooltip;
70647         }).call(
70648           uiTooltip().title(function(d2) {
70649             return d2.tooltip;
70650           }).placement("top")
70651         );
70652         items = itemsEnter.merge(items);
70653         items.selectAll(".issue-message").text("").each(function(d2) {
70654           return d2.message(context)(select_default2(this));
70655         });
70656       }
70657     }
70658     return commitWarnings;
70659   }
70660
70661   // modules/ui/lasso.js
70662   function uiLasso(context) {
70663     var group, polygon2;
70664     lasso.coordinates = [];
70665     function lasso(selection2) {
70666       context.container().classed("lasso", true);
70667       group = selection2.append("g").attr("class", "lasso hide");
70668       polygon2 = group.append("path").attr("class", "lasso-path");
70669       group.call(uiToggle(true));
70670     }
70671     function draw() {
70672       if (polygon2) {
70673         polygon2.data([lasso.coordinates]).attr("d", function(d2) {
70674           return "M" + d2.join(" L") + " Z";
70675         });
70676       }
70677     }
70678     lasso.extent = function() {
70679       return lasso.coordinates.reduce(function(extent, point) {
70680         return extent.extend(geoExtent(point));
70681       }, geoExtent());
70682     };
70683     lasso.p = function(_2) {
70684       if (!arguments.length) return lasso;
70685       lasso.coordinates.push(_2);
70686       draw();
70687       return lasso;
70688     };
70689     lasso.close = function() {
70690       if (group) {
70691         group.call(uiToggle(false, function() {
70692           select_default2(this).remove();
70693         }));
70694       }
70695       context.container().classed("lasso", false);
70696     };
70697     return lasso;
70698   }
70699
70700   // node_modules/osm-community-index/lib/simplify.js
70701   var import_diacritics2 = __toESM(require_diacritics(), 1);
70702   function simplify(str) {
70703     if (typeof str !== "string") return "";
70704     return import_diacritics2.default.remove(
70705       str.replace(/&/g, "and").replace(/(İ|i̇)/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()
70706     );
70707   }
70708
70709   // node_modules/osm-community-index/lib/resolve_strings.js
70710   function resolveStrings(item, defaults, localizerFn) {
70711     let itemStrings = Object.assign({}, item.strings);
70712     let defaultStrings = Object.assign({}, defaults[item.type]);
70713     const anyToken = new RegExp(/(\{\w+\})/, "gi");
70714     if (localizerFn) {
70715       if (itemStrings.community) {
70716         const communityID = simplify(itemStrings.community);
70717         itemStrings.community = localizerFn("_communities.".concat(communityID));
70718       }
70719       ["name", "description", "extendedDescription"].forEach((prop) => {
70720         if (defaultStrings[prop]) defaultStrings[prop] = localizerFn("_defaults.".concat(item.type, ".").concat(prop));
70721         if (itemStrings[prop]) itemStrings[prop] = localizerFn("".concat(item.id, ".").concat(prop));
70722       });
70723     }
70724     let replacements = {
70725       account: item.account,
70726       community: itemStrings.community,
70727       signupUrl: itemStrings.signupUrl,
70728       url: itemStrings.url
70729     };
70730     if (!replacements.signupUrl) {
70731       replacements.signupUrl = resolve(itemStrings.signupUrl || defaultStrings.signupUrl);
70732     }
70733     if (!replacements.url) {
70734       replacements.url = resolve(itemStrings.url || defaultStrings.url);
70735     }
70736     let resolved = {
70737       name: resolve(itemStrings.name || defaultStrings.name),
70738       url: resolve(itemStrings.url || defaultStrings.url),
70739       signupUrl: resolve(itemStrings.signupUrl || defaultStrings.signupUrl),
70740       description: resolve(itemStrings.description || defaultStrings.description),
70741       extendedDescription: resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription)
70742     };
70743     resolved.nameHTML = linkify(resolved.url, resolved.name);
70744     resolved.urlHTML = linkify(resolved.url);
70745     resolved.signupUrlHTML = linkify(resolved.signupUrl);
70746     resolved.descriptionHTML = resolve(itemStrings.description || defaultStrings.description, true);
70747     resolved.extendedDescriptionHTML = resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription, true);
70748     return resolved;
70749     function resolve(s2, addLinks) {
70750       if (!s2) return void 0;
70751       let result = s2;
70752       for (let key in replacements) {
70753         const token = "{".concat(key, "}");
70754         const regex = new RegExp(token, "g");
70755         if (regex.test(result)) {
70756           let replacement = replacements[key];
70757           if (!replacement) {
70758             throw new Error("Cannot resolve token: ".concat(token));
70759           } else {
70760             if (addLinks && (key === "signupUrl" || key === "url")) {
70761               replacement = linkify(replacement);
70762             }
70763             result = result.replace(regex, replacement);
70764           }
70765         }
70766       }
70767       const leftovers = result.match(anyToken);
70768       if (leftovers) {
70769         throw new Error("Cannot resolve tokens: ".concat(leftovers));
70770       }
70771       if (addLinks && item.type === "reddit") {
70772         result = result.replace(/(\/r\/\w+\/*)/i, (match) => linkify(resolved.url, match));
70773       }
70774       return result;
70775     }
70776     function linkify(url, text) {
70777       if (!url) return void 0;
70778       text = text || url;
70779       return '<a target="_blank" href="'.concat(url, '">').concat(text, "</a>");
70780     }
70781   }
70782
70783   // modules/ui/success.js
70784   var _oci = null;
70785   function uiSuccess(context) {
70786     const MAXEVENTS = 2;
70787     const dispatch14 = dispatch_default("cancel");
70788     let _changeset2;
70789     let _location;
70790     ensureOSMCommunityIndex();
70791     function ensureOSMCommunityIndex() {
70792       const data = _mainFileFetcher;
70793       return Promise.all([
70794         data.get("oci_features"),
70795         data.get("oci_resources"),
70796         data.get("oci_defaults")
70797       ]).then((vals) => {
70798         if (_oci) return _oci;
70799         if (vals[0] && Array.isArray(vals[0].features)) {
70800           _sharedLocationManager.mergeCustomGeoJSON(vals[0]);
70801         }
70802         let ociResources = Object.values(vals[1].resources);
70803         if (ociResources.length) {
70804           return _sharedLocationManager.mergeLocationSets(ociResources).then(() => {
70805             _oci = {
70806               resources: ociResources,
70807               defaults: vals[2].defaults
70808             };
70809             return _oci;
70810           });
70811         } else {
70812           _oci = {
70813             resources: [],
70814             // no resources?
70815             defaults: vals[2].defaults
70816           };
70817           return _oci;
70818         }
70819       });
70820     }
70821     function parseEventDate(when) {
70822       if (!when) return;
70823       let raw = when.trim();
70824       if (!raw) return;
70825       if (!/Z$/.test(raw)) {
70826         raw += "Z";
70827       }
70828       const parsed = new Date(raw);
70829       return new Date(parsed.toUTCString().slice(0, 25));
70830     }
70831     function success(selection2) {
70832       let header = selection2.append("div").attr("class", "header fillL");
70833       header.append("h2").call(_t.append("success.just_edited"));
70834       header.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => dispatch14.call("cancel")).call(svgIcon("#iD-icon-close"));
70835       let body = selection2.append("div").attr("class", "body save-success fillL");
70836       let summary = body.append("div").attr("class", "save-summary");
70837       summary.append("h3").call(_t.append("success.thank_you" + (_location ? "_location" : ""), { where: _location }));
70838       summary.append("p").call(_t.append("success.help_html")).append("a").attr("class", "link-out").attr("target", "_blank").attr("href", _t("success.help_link_url")).call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append("success.help_link_text"));
70839       let osm = context.connection();
70840       if (!osm) return;
70841       let changesetURL = osm.changesetURL(_changeset2.id);
70842       let table = summary.append("table").attr("class", "summary-table");
70843       let row = table.append("tr").attr("class", "summary-row");
70844       row.append("td").attr("class", "cell-icon summary-icon").append("a").attr("target", "_blank").attr("href", changesetURL).append("svg").attr("class", "logo-small").append("use").attr("xlink:href", "#iD-logo-osm");
70845       let summaryDetail = row.append("td").attr("class", "cell-detail summary-detail");
70846       summaryDetail.append("a").attr("class", "cell-detail summary-view-on-osm").attr("target", "_blank").attr("href", changesetURL).call(_t.append("success.view_on_osm"));
70847       summaryDetail.append("div").html(_t.html("success.changeset_id", {
70848         changeset_id: { html: '<a href="'.concat(changesetURL, '" target="_blank">').concat(_changeset2.id, "</a>") }
70849       }));
70850       if (showDonationMessage !== false) {
70851         const donationUrl = "https://supporting.openstreetmap.org/";
70852         let supporting = body.append("div").attr("class", "save-supporting");
70853         supporting.append("h3").call(_t.append("success.supporting.title"));
70854         supporting.append("p").call(_t.append("success.supporting.details"));
70855         table = supporting.append("table").attr("class", "supporting-table");
70856         row = table.append("tr").attr("class", "supporting-row");
70857         row.append("td").attr("class", "cell-icon supporting-icon").append("a").attr("target", "_blank").attr("href", donationUrl).append("svg").attr("class", "logo-small").append("use").attr("xlink:href", "#iD-donation");
70858         let supportingDetail = row.append("td").attr("class", "cell-detail supporting-detail");
70859         supportingDetail.append("a").attr("class", "cell-detail support-the-map").attr("target", "_blank").attr("href", donationUrl).call(_t.append("success.supporting.donation.title"));
70860         supportingDetail.append("div").call(_t.append("success.supporting.donation.details"));
70861       }
70862       ensureOSMCommunityIndex().then((oci) => {
70863         const loc = context.map().center();
70864         const validHere = _sharedLocationManager.locationSetsAt(loc);
70865         let communities = [];
70866         oci.resources.forEach((resource) => {
70867           let area = validHere[resource.locationSetID];
70868           if (!area) return;
70869           const localizer = (stringID) => _t.html("community.".concat(stringID));
70870           resource.resolved = resolveStrings(resource, oci.defaults, localizer);
70871           communities.push({
70872             area,
70873             order: resource.order || 0,
70874             resource
70875           });
70876         });
70877         communities.sort((a2, b2) => a2.area - b2.area || b2.order - a2.order);
70878         body.call(showCommunityLinks, communities.map((c2) => c2.resource));
70879       });
70880     }
70881     function showCommunityLinks(selection2, resources) {
70882       let communityLinks = selection2.append("div").attr("class", "save-communityLinks");
70883       communityLinks.append("h3").call(_t.append("success.like_osm"));
70884       let table = communityLinks.append("table").attr("class", "community-table");
70885       let row = table.selectAll(".community-row").data(resources);
70886       let rowEnter = row.enter().append("tr").attr("class", "community-row");
70887       rowEnter.append("td").attr("class", "cell-icon community-icon").append("a").attr("target", "_blank").attr("href", (d2) => d2.resolved.url).append("svg").attr("class", "logo-small").append("use").attr("xlink:href", (d2) => "#community-".concat(d2.type));
70888       let communityDetail = rowEnter.append("td").attr("class", "cell-detail community-detail");
70889       communityDetail.each(showCommunityDetails);
70890       communityLinks.append("div").attr("class", "community-missing").call(_t.append("success.missing")).append("a").attr("class", "link-out").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/osmlab/osm-community-index/issues").append("span").call(_t.append("success.tell_us"));
70891     }
70892     function showCommunityDetails(d2) {
70893       let selection2 = select_default2(this);
70894       let communityID = d2.id;
70895       selection2.append("div").attr("class", "community-name").html(d2.resolved.nameHTML);
70896       selection2.append("div").attr("class", "community-description").html(d2.resolved.descriptionHTML);
70897       if (d2.resolved.extendedDescriptionHTML || d2.languageCodes && d2.languageCodes.length) {
70898         selection2.append("div").call(
70899           uiDisclosure(context, "community-more-".concat(d2.id), false).expanded(false).updatePreference(false).label(() => _t.append("success.more")).content(showMore)
70900         );
70901       }
70902       let nextEvents = (d2.events || []).map((event) => {
70903         event.date = parseEventDate(event.when);
70904         return event;
70905       }).filter((event) => {
70906         const t2 = event.date.getTime();
70907         const now3 = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0);
70908         return !isNaN(t2) && t2 >= now3;
70909       }).sort((a2, b2) => {
70910         return a2.date < b2.date ? -1 : a2.date > b2.date ? 1 : 0;
70911       }).slice(0, MAXEVENTS);
70912       if (nextEvents.length) {
70913         selection2.append("div").call(
70914           uiDisclosure(context, "community-events-".concat(d2.id), false).expanded(false).updatePreference(false).label(_t.html("success.events")).content(showNextEvents)
70915         ).select(".hide-toggle").append("span").attr("class", "badge-text").text(nextEvents.length);
70916       }
70917       function showMore(selection3) {
70918         let more = selection3.selectAll(".community-more").data([0]);
70919         let moreEnter = more.enter().append("div").attr("class", "community-more");
70920         if (d2.resolved.extendedDescriptionHTML) {
70921           moreEnter.append("div").attr("class", "community-extended-description").html(d2.resolved.extendedDescriptionHTML);
70922         }
70923         if (d2.languageCodes && d2.languageCodes.length) {
70924           const languageList = d2.languageCodes.map((code) => _mainLocalizer.languageName(code)).join(", ");
70925           moreEnter.append("div").attr("class", "community-languages").call(_t.append("success.languages", { languages: languageList }));
70926         }
70927       }
70928       function showNextEvents(selection3) {
70929         let events = selection3.append("div").attr("class", "community-events");
70930         let item = events.selectAll(".community-event").data(nextEvents);
70931         let itemEnter = item.enter().append("div").attr("class", "community-event");
70932         itemEnter.append("div").attr("class", "community-event-name").append("a").attr("target", "_blank").attr("href", (d4) => d4.url).text((d4) => {
70933           let name = d4.name;
70934           if (d4.i18n && d4.id) {
70935             name = _t("community.".concat(communityID, ".events.").concat(d4.id, ".name"), { default: name });
70936           }
70937           return name;
70938         });
70939         itemEnter.append("div").attr("class", "community-event-when").text((d4) => {
70940           let options2 = { weekday: "short", day: "numeric", month: "short", year: "numeric" };
70941           if (d4.date.getHours() || d4.date.getMinutes()) {
70942             options2.hour = "numeric";
70943             options2.minute = "numeric";
70944           }
70945           return d4.date.toLocaleString(_mainLocalizer.localeCode(), options2);
70946         });
70947         itemEnter.append("div").attr("class", "community-event-where").text((d4) => {
70948           let where = d4.where;
70949           if (d4.i18n && d4.id) {
70950             where = _t("community.".concat(communityID, ".events.").concat(d4.id, ".where"), { default: where });
70951           }
70952           return where;
70953         });
70954         itemEnter.append("div").attr("class", "community-event-description").text((d4) => {
70955           let description = d4.description;
70956           if (d4.i18n && d4.id) {
70957             description = _t("community.".concat(communityID, ".events.").concat(d4.id, ".description"), { default: description });
70958           }
70959           return description;
70960         });
70961       }
70962     }
70963     success.changeset = function(val) {
70964       if (!arguments.length) return _changeset2;
70965       _changeset2 = val;
70966       return success;
70967     };
70968     success.location = function(val) {
70969       if (!arguments.length) return _location;
70970       _location = val;
70971       return success;
70972     };
70973     return utilRebind(success, dispatch14, "on");
70974   }
70975
70976   // modules/ui/fields/input.js
70977   var likelyRawNumberFormat = /^-?(0\.\d*|\d*\.\d{0,2}(\d{4,})?|\d{4,}\.\d{3})$/;
70978   function uiFieldText(field, context) {
70979     var dispatch14 = dispatch_default("change");
70980     var input = select_default2(null);
70981     var outlinkButton = select_default2(null);
70982     var wrap2 = select_default2(null);
70983     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
70984     var _entityIDs = [];
70985     var _tags;
70986     var _phoneFormats = {};
70987     const isDirectionField = field.key.split(":").some((keyPart) => keyPart === "direction");
70988     const formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
70989     const parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
70990     const countDecimalPlaces = _mainLocalizer.decimalPlaceCounter(_mainLocalizer.languageCode());
70991     if (field.type === "tel") {
70992       _mainFileFetcher.get("phone_formats").then(function(d2) {
70993         _phoneFormats = d2;
70994         updatePhonePlaceholder();
70995       }).catch(function() {
70996       });
70997     }
70998     function calcLocked() {
70999       var isLocked = (field.id === "brand" || field.id === "network" || field.id === "operator" || field.id === "flag") && _entityIDs.length && _entityIDs.some(function(entityID) {
71000         var entity = context.graph().hasEntity(entityID);
71001         if (!entity) return false;
71002         if (entity.tags.wikidata) return true;
71003         var preset = _mainPresetIndex.match(entity, context.graph());
71004         var isSuggestion = preset && preset.suggestion;
71005         var which = field.id;
71006         return isSuggestion && !!entity.tags[which] && !!entity.tags[which + ":wikidata"];
71007       });
71008       field.locked(isLocked);
71009     }
71010     function i3(selection2) {
71011       calcLocked();
71012       var isLocked = field.locked();
71013       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
71014       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
71015       input = wrap2.selectAll("input").data([0]);
71016       input = input.enter().append("input").attr("type", field.type === "identifier" ? "text" : field.type).attr("id", field.domId).classed(field.type, true).call(utilNoAuto).merge(input);
71017       input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
71018       wrap2.call(_lengthIndicator);
71019       if (field.type === "tel") {
71020         updatePhonePlaceholder();
71021       } else if (field.type === "number") {
71022         var rtl = _mainLocalizer.textDirection() === "rtl";
71023         input.attr("type", "text");
71024         var inc = field.increment;
71025         var buttons = wrap2.selectAll(".increment, .decrement").data(rtl ? [inc, -inc] : [-inc, inc]);
71026         buttons.enter().append("button").attr("class", function(d2) {
71027           var which = d2 > 0 ? "increment" : "decrement";
71028           return "form-field-button " + which;
71029         }).attr("title", function(d2) {
71030           var which = d2 > 0 ? "increment" : "decrement";
71031           return _t("inspector.".concat(which));
71032         }).merge(buttons).on("click", function(d3_event, d2) {
71033           d3_event.preventDefault();
71034           var isMixed = Array.isArray(_tags[field.key]);
71035           if (isMixed) return;
71036           var raw_vals = input.node().value || "0";
71037           var vals = raw_vals.split(";");
71038           vals = vals.map(function(v2) {
71039             v2 = v2.trim();
71040             const isRawNumber = likelyRawNumberFormat.test(v2);
71041             var num = isRawNumber ? parseFloat(v2) : parseLocaleFloat(v2);
71042             if (isDirectionField) {
71043               const compassDir = cardinal[v2.toLowerCase()];
71044               if (compassDir !== void 0) {
71045                 num = compassDir;
71046               }
71047             }
71048             if (!isFinite(num)) return v2;
71049             num = parseFloat(num);
71050             if (!isFinite(num)) return v2;
71051             num += d2;
71052             if (isDirectionField) {
71053               num = (num % 360 + 360) % 360;
71054             }
71055             return formatFloat(clamped(num), isRawNumber ? v2.includes(".") ? v2.split(".")[1].length : 0 : countDecimalPlaces(v2));
71056           });
71057           input.node().value = vals.join(";");
71058           change()();
71059         });
71060       } else if (field.type === "identifier" && field.urlFormat && field.pattern) {
71061         input.attr("type", "text");
71062         outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
71063         outlinkButton = outlinkButton.enter().append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", function() {
71064           var domainResults = /^https?:\/\/(.{1,}?)\//.exec(field.urlFormat);
71065           if (domainResults.length >= 2 && domainResults[1]) {
71066             var domain = domainResults[1];
71067             return _t("icons.view_on", { domain });
71068           }
71069           return "";
71070         }).merge(outlinkButton);
71071         outlinkButton.on("click", function(d3_event) {
71072           d3_event.preventDefault();
71073           var value = validIdentifierValueForLink();
71074           if (value) {
71075             var url = field.urlFormat.replace(/{value}/, encodeURIComponent(value));
71076             window.open(url, "_blank");
71077           }
71078         }).classed("disabled", () => !validIdentifierValueForLink()).merge(outlinkButton);
71079       } else if (field.type === "url") {
71080         input.attr("type", "text");
71081         outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
71082         outlinkButton.enter().append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", () => _t("icons.visit_website")).on("click", function(d3_event) {
71083           d3_event.preventDefault();
71084           const value = validIdentifierValueForLink();
71085           if (value) window.open(value, "_blank");
71086         }).merge(outlinkButton);
71087       } else if (field.type === "colour") {
71088         input.attr("type", "text");
71089         updateColourPreview();
71090       } else if (field.type === "date") {
71091         input.attr("type", "text");
71092         updateDateField();
71093       }
71094     }
71095     function updateColourPreview() {
71096       wrap2.selectAll(".colour-preview").remove();
71097       const colour = utilGetSetValue(input);
71098       if (!isColourValid(colour) && colour !== "") {
71099         wrap2.selectAll("input.colour-selector").remove();
71100         wrap2.selectAll(".form-field-button").remove();
71101         return;
71102       }
71103       var colourSelector = wrap2.selectAll(".colour-selector").data([0]);
71104       colourSelector.enter().append("input").attr("type", "color").attr("class", "colour-selector").on("input", debounce_default(function(d3_event) {
71105         d3_event.preventDefault();
71106         var colour2 = this.value;
71107         if (!isColourValid(colour2)) return;
71108         utilGetSetValue(input, this.value);
71109         change()();
71110         updateColourPreview();
71111       }, 100));
71112       wrap2.selectAll("input.colour-selector").attr("value", colour);
71113       var chooserButton = wrap2.selectAll(".colour-preview").data([colour]);
71114       chooserButton = chooserButton.enter().append("div").attr("class", "form-field-button colour-preview").append("div").style("background-color", (d2) => d2).attr("class", "colour-box");
71115       if (colour === "") {
71116         chooserButton = chooserButton.call(svgIcon("#iD-icon-edit"));
71117       }
71118       chooserButton.on("click", () => wrap2.select(".colour-selector").node().showPicker());
71119     }
71120     function updateDateField() {
71121       function isDateValid(date2) {
71122         return date2.match(/^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$/);
71123       }
71124       const date = utilGetSetValue(input);
71125       const now3 = /* @__PURE__ */ new Date();
71126       const today = new Date(now3.getTime() - now3.getTimezoneOffset() * 6e4).toISOString().split("T")[0];
71127       if ((field.key === "check_date" || field.key === "survey:date") && date !== today) {
71128         wrap2.selectAll(".date-set-today").data([0]).enter().append("button").attr("class", "form-field-button date-set-today").call(svgIcon("#fas-rotate")).call(uiTooltip().title(() => _t.append("inspector.set_today"))).on("click", () => {
71129           utilGetSetValue(input, today);
71130           change()();
71131           updateDateField();
71132         });
71133       } else {
71134         wrap2.selectAll(".date-set-today").remove();
71135       }
71136       if (!isDateValid(date) && date !== "") {
71137         wrap2.selectAll("input.date-selector").remove();
71138         wrap2.selectAll(".date-calendar").remove();
71139         return;
71140       }
71141       if (utilDetect().browser !== "Safari") {
71142         var dateSelector = wrap2.selectAll(".date-selector").data([0]);
71143         dateSelector.enter().append("input").attr("type", "date").attr("class", "date-selector").on("input", debounce_default(function(d3_event) {
71144           d3_event.preventDefault();
71145           var date2 = this.value;
71146           if (!isDateValid(date2)) return;
71147           utilGetSetValue(input, this.value);
71148           change()();
71149           updateDateField();
71150         }, 100));
71151         wrap2.selectAll("input.date-selector").attr("value", date);
71152         var calendarButton = wrap2.selectAll(".date-calendar").data([date]);
71153         calendarButton = calendarButton.enter().append("button").attr("class", "form-field-button date-calendar").call(svgIcon("#fas-calendar-days"));
71154         calendarButton.on("click", () => wrap2.select(".date-selector").node().showPicker());
71155       }
71156     }
71157     function updatePhonePlaceholder() {
71158       if (input.empty() || !Object.keys(_phoneFormats).length) return;
71159       var extent = combinedEntityExtent();
71160       var countryCode = extent && iso1A2Code(extent.center());
71161       var format2 = countryCode && _phoneFormats[countryCode.toLowerCase()];
71162       if (format2) input.attr("placeholder", format2);
71163     }
71164     function validIdentifierValueForLink() {
71165       var _a4;
71166       const value = utilGetSetValue(input).trim();
71167       if (field.type === "url" && value) {
71168         try {
71169           return new URL(value).href;
71170         } catch (e3) {
71171           return null;
71172         }
71173       }
71174       if (field.type === "identifier" && field.pattern) {
71175         return value && ((_a4 = value.match(new RegExp(field.pattern))) == null ? void 0 : _a4[0]);
71176       }
71177       return null;
71178     }
71179     function clamped(num) {
71180       if (field.minValue !== void 0) {
71181         num = Math.max(num, field.minValue);
71182       }
71183       if (field.maxValue !== void 0) {
71184         num = Math.min(num, field.maxValue);
71185       }
71186       return num;
71187     }
71188     function getVals(tags) {
71189       if (field.keys) {
71190         const multiSelection = context.selectedIDs();
71191         tags = multiSelection.length > 1 ? context.selectedIDs().map((id2) => context.graph().entity(id2)).map((entity) => entity.tags) : [tags];
71192         return tags.map((tags2) => new Set(field.keys.reduce((acc, key) => acc.concat(tags2[key]), []).filter(Boolean))).map((vals) => vals.size === 0 ? /* @__PURE__ */ new Set([void 0]) : vals).reduce((a2, b2) => /* @__PURE__ */ new Set([...a2, ...b2]));
71193       } else {
71194         return new Set([].concat(tags[field.key]));
71195       }
71196     }
71197     function change(onInput) {
71198       return function() {
71199         var t2 = {};
71200         var val = utilGetSetValue(input);
71201         if (!onInput) val = context.cleanTagValue(val);
71202         if (!val && getVals(_tags).size > 1) return;
71203         var displayVal = val;
71204         if (field.type === "number" && val) {
71205           var numbers2 = val.split(";");
71206           numbers2 = numbers2.map(function(v2) {
71207             if (likelyRawNumberFormat.test(v2)) {
71208               return v2;
71209             }
71210             var num = parseLocaleFloat(v2);
71211             const fractionDigits = countDecimalPlaces(v2);
71212             return isFinite(num) ? clamped(num).toFixed(fractionDigits) : v2;
71213           });
71214           val = numbers2.join(";");
71215         }
71216         if (!onInput) utilGetSetValue(input, displayVal);
71217         t2[field.key] = val || void 0;
71218         if (field.keys) {
71219           dispatch14.call("change", this, (tags) => {
71220             if (field.keys.some((key) => tags[key])) {
71221               field.keys.filter((key) => tags[key]).forEach((key) => {
71222                 tags[key] = val || void 0;
71223               });
71224             } else {
71225               tags[field.key] = val || void 0;
71226             }
71227             return tags;
71228           }, onInput);
71229         } else {
71230           dispatch14.call("change", this, t2, onInput);
71231         }
71232       };
71233     }
71234     i3.entityIDs = function(val) {
71235       if (!arguments.length) return _entityIDs;
71236       _entityIDs = val;
71237       return i3;
71238     };
71239     i3.tags = function(tags) {
71240       var _a4;
71241       _tags = tags;
71242       const vals = getVals(tags);
71243       const isMixed = vals.size > 1;
71244       var val = vals.size === 1 ? (_a4 = [...vals][0]) != null ? _a4 : "" : "";
71245       var shouldUpdate;
71246       if (field.type === "number" && val) {
71247         var numbers2 = val.split(";");
71248         var oriNumbers = utilGetSetValue(input).split(";");
71249         if (numbers2.length !== oriNumbers.length) shouldUpdate = true;
71250         numbers2 = numbers2.map(function(v2) {
71251           v2 = v2.trim();
71252           var num = Number(v2);
71253           if (!isFinite(num) || v2 === "") return v2;
71254           const fractionDigits = v2.includes(".") ? v2.split(".")[1].length : 0;
71255           return formatFloat(num, fractionDigits);
71256         });
71257         val = numbers2.join(";");
71258         shouldUpdate = (inputValue, setValue) => {
71259           const inputNums = inputValue.split(";").map(
71260             (setVal) => likelyRawNumberFormat.test(setVal) ? parseFloat(setVal) : parseLocaleFloat(setVal)
71261           );
71262           const setNums = setValue.split(";").map(parseLocaleFloat);
71263           return !isEqual_default(inputNums, setNums);
71264         };
71265       }
71266       utilGetSetValue(input, val, shouldUpdate).attr("title", isMixed ? [...vals].join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder() || _t("inspector.unknown")).classed("mixed", isMixed);
71267       if (field.type === "number") {
71268         const buttons = wrap2.selectAll(".increment, .decrement");
71269         if (isMixed) {
71270           buttons.attr("disabled", "disabled").classed("disabled", true);
71271         } else {
71272           var raw_vals = tags[field.key] || "0";
71273           const canIncDec = raw_vals.split(";").some(
71274             (val2) => isFinite(Number(val2)) || isDirectionField && val2.trim().toLowerCase() in cardinal
71275           );
71276           buttons.attr("disabled", canIncDec ? null : "disabled").classed("disabled", !canIncDec);
71277         }
71278       }
71279       if (field.type === "tel") updatePhonePlaceholder();
71280       if (field.type === "colour") updateColourPreview();
71281       if (field.type === "date") updateDateField();
71282       if (outlinkButton && !outlinkButton.empty()) {
71283         var disabled = !validIdentifierValueForLink();
71284         outlinkButton.classed("disabled", disabled);
71285       }
71286       if (!isMixed) {
71287         _lengthIndicator.update(tags[field.key]);
71288       }
71289     };
71290     i3.focus = function() {
71291       var node = input.node();
71292       if (node) node.focus();
71293     };
71294     function combinedEntityExtent() {
71295       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
71296     }
71297     return utilRebind(i3, dispatch14, "on");
71298   }
71299
71300   // modules/ui/fields/access.js
71301   function uiFieldAccess(field, context) {
71302     var dispatch14 = dispatch_default("change");
71303     var items = select_default2(null);
71304     var _tags;
71305     function access(selection2) {
71306       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
71307       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
71308       var list2 = wrap2.selectAll("ul").data([0]);
71309       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
71310       items = list2.selectAll("li").data(field.keys);
71311       var enter = items.enter().append("li").attr("class", function(d2) {
71312         return "labeled-input preset-access-" + d2;
71313       });
71314       enter.append("div").attr("class", "label preset-label-access").attr("for", function(d2) {
71315         return "preset-input-access-" + d2;
71316       }).html(function(d2) {
71317         return field.t.html("types." + d2);
71318       });
71319       enter.append("div").attr("class", "preset-input-access-wrap").append("input").attr("type", "text").attr("class", function(d2) {
71320         return "preset-input-access preset-input-access-" + d2;
71321       }).call(utilNoAuto).each(function(d2) {
71322         select_default2(this).call(
71323           uiCombobox(context, "access-" + d2).data(access.options(d2))
71324         );
71325       });
71326       items = items.merge(enter);
71327       wrap2.selectAll(".preset-input-access").on("change", change).on("blur", change);
71328     }
71329     function change(d3_event, d2) {
71330       var tag2 = {};
71331       var value = context.cleanTagValue(utilGetSetValue(select_default2(this)));
71332       if (!value && typeof _tags[d2] !== "string") return;
71333       tag2[d2] = value || void 0;
71334       dispatch14.call("change", this, tag2);
71335     }
71336     access.options = function(type2) {
71337       var options2 = [
71338         "yes",
71339         "no",
71340         "designated",
71341         "permissive",
71342         "destination",
71343         "customers",
71344         "private",
71345         "permit",
71346         "unknown"
71347       ];
71348       if (type2 === "access") {
71349         options2 = options2.filter((v2) => v2 !== "yes" && v2 !== "designated");
71350       }
71351       if (type2 === "bicycle") {
71352         options2.splice(options2.length - 4, 0, "dismount");
71353       }
71354       var stringsField = field.resolveReference("stringsCrossReference");
71355       return options2.map(function(option) {
71356         return {
71357           title: stringsField.t("options." + option + ".description"),
71358           value: option
71359         };
71360       });
71361     };
71362     const placeholdersByTag = {
71363       highway: {
71364         footway: {
71365           foot: "designated",
71366           motor_vehicle: "no"
71367         },
71368         steps: {
71369           foot: "yes",
71370           motor_vehicle: "no",
71371           bicycle: "no",
71372           horse: "no"
71373         },
71374         ladder: {
71375           foot: "yes",
71376           motor_vehicle: "no",
71377           bicycle: "no",
71378           horse: "no"
71379         },
71380         pedestrian: {
71381           foot: "yes",
71382           motor_vehicle: "no"
71383         },
71384         cycleway: {
71385           motor_vehicle: "no",
71386           bicycle: "designated"
71387         },
71388         bridleway: {
71389           motor_vehicle: "no",
71390           horse: "designated"
71391         },
71392         path: {
71393           foot: "yes",
71394           motor_vehicle: "no",
71395           bicycle: "yes",
71396           horse: "yes"
71397         },
71398         motorway: {
71399           foot: "no",
71400           motor_vehicle: "yes",
71401           bicycle: "no",
71402           horse: "no"
71403         },
71404         trunk: {
71405           motor_vehicle: "yes"
71406         },
71407         primary: {
71408           foot: "yes",
71409           motor_vehicle: "yes",
71410           bicycle: "yes",
71411           horse: "yes"
71412         },
71413         secondary: {
71414           foot: "yes",
71415           motor_vehicle: "yes",
71416           bicycle: "yes",
71417           horse: "yes"
71418         },
71419         tertiary: {
71420           foot: "yes",
71421           motor_vehicle: "yes",
71422           bicycle: "yes",
71423           horse: "yes"
71424         },
71425         residential: {
71426           foot: "yes",
71427           motor_vehicle: "yes",
71428           bicycle: "yes",
71429           horse: "yes"
71430         },
71431         unclassified: {
71432           foot: "yes",
71433           motor_vehicle: "yes",
71434           bicycle: "yes",
71435           horse: "yes"
71436         },
71437         service: {
71438           foot: "yes",
71439           motor_vehicle: "yes",
71440           bicycle: "yes",
71441           horse: "yes"
71442         },
71443         motorway_link: {
71444           foot: "no",
71445           motor_vehicle: "yes",
71446           bicycle: "no",
71447           horse: "no"
71448         },
71449         trunk_link: {
71450           motor_vehicle: "yes"
71451         },
71452         primary_link: {
71453           foot: "yes",
71454           motor_vehicle: "yes",
71455           bicycle: "yes",
71456           horse: "yes"
71457         },
71458         secondary_link: {
71459           foot: "yes",
71460           motor_vehicle: "yes",
71461           bicycle: "yes",
71462           horse: "yes"
71463         },
71464         tertiary_link: {
71465           foot: "yes",
71466           motor_vehicle: "yes",
71467           bicycle: "yes",
71468           horse: "yes"
71469         },
71470         construction: {
71471           access: "no"
71472         },
71473         busway: {
71474           access: "no",
71475           bus: "designated",
71476           emergency: "yes"
71477         }
71478       },
71479       barrier: {
71480         bollard: {
71481           access: "no",
71482           bicycle: "yes",
71483           foot: "yes"
71484         },
71485         bus_trap: {
71486           motor_vehicle: "no",
71487           psv: "yes",
71488           foot: "yes",
71489           bicycle: "yes"
71490         },
71491         city_wall: {
71492           access: "no"
71493         },
71494         coupure: {
71495           access: "yes"
71496         },
71497         cycle_barrier: {
71498           motor_vehicle: "no"
71499         },
71500         ditch: {
71501           access: "no"
71502         },
71503         entrance: {
71504           access: "yes"
71505         },
71506         fence: {
71507           access: "no"
71508         },
71509         hedge: {
71510           access: "no"
71511         },
71512         jersey_barrier: {
71513           access: "no"
71514         },
71515         motorcycle_barrier: {
71516           motor_vehicle: "no"
71517         },
71518         rail_guard: {
71519           access: "no"
71520         }
71521       }
71522     };
71523     access.tags = function(tags) {
71524       _tags = tags;
71525       utilGetSetValue(items.selectAll(".preset-input-access"), function(d2) {
71526         return typeof tags[d2] === "string" ? tags[d2] : "";
71527       }).classed("mixed", function(d2) {
71528         return tags[d2] && Array.isArray(tags[d2]);
71529       }).attr("title", function(d2) {
71530         return tags[d2] && Array.isArray(tags[d2]) && tags[d2].filter(Boolean).join("\n");
71531       }).attr("placeholder", function(d2) {
71532         if (tags[d2] && Array.isArray(tags[d2])) {
71533           return _t("inspector.multiple_values");
71534         }
71535         if (d2 === "bicycle" || d2 === "motor_vehicle") {
71536           if (tags.vehicle && typeof tags.vehicle === "string") {
71537             return tags.vehicle;
71538           }
71539         }
71540         if (tags.access && typeof tags.access === "string") {
71541           return tags.access;
71542         }
71543         function getPlaceholdersByTag(key, placeholdersByKey) {
71544           if (typeof tags[key] === "string") {
71545             if (placeholdersByKey[tags[key]] && placeholdersByKey[tags[key]][d2]) {
71546               return placeholdersByKey[tags[key]][d2];
71547             }
71548           } else {
71549             var impliedAccesses = tags[key].filter(Boolean).map(function(val) {
71550               return placeholdersByKey[val] && placeholdersByKey[val][d2];
71551             }).filter(Boolean);
71552             if (impliedAccesses.length === tags[key].length && new Set(impliedAccesses).size === 1) {
71553               return impliedAccesses[0];
71554             }
71555           }
71556         }
71557         for (const key in placeholdersByTag) {
71558           if (tags[key]) {
71559             const impliedAccess = getPlaceholdersByTag(key, placeholdersByTag[key]);
71560             if (impliedAccess) {
71561               return impliedAccess;
71562             }
71563           }
71564         }
71565         if (d2 === "access" && !tags.barrier) {
71566           return "yes";
71567         }
71568         return field.placeholder();
71569       });
71570     };
71571     access.focus = function() {
71572       items.selectAll(".preset-input-access").node().focus();
71573     };
71574     return utilRebind(access, dispatch14, "on");
71575   }
71576
71577   // modules/ui/fields/address.js
71578   function uiFieldAddress(field, context) {
71579     var dispatch14 = dispatch_default("change");
71580     var _selection = select_default2(null);
71581     var _wrap = select_default2(null);
71582     var addrField = _mainPresetIndex.field("address");
71583     var _entityIDs = [];
71584     var _tags;
71585     var _countryCode;
71586     var _addressFormats = [{
71587       format: [
71588         ["housenumber", "street"],
71589         ["city", "postcode"]
71590       ]
71591     }];
71592     _mainFileFetcher.get("address_formats").then(function(d2) {
71593       _addressFormats = d2;
71594       if (!_selection.empty()) {
71595         _selection.call(address);
71596       }
71597     }).catch(function() {
71598     });
71599     function getNear(isAddressable, type2, searchRadius, resultProp) {
71600       var extent = combinedEntityExtent();
71601       var l2 = extent.center();
71602       var box = geoExtent(l2).padByMeters(searchRadius);
71603       var features = context.history().intersects(box).filter(isAddressable).map((d2) => {
71604         let dist = geoSphericalDistance(d2.extent(context.graph()).center(), l2);
71605         if (d2.geometry(context.graph()) === "line") {
71606           var loc = context.projection([
71607             (extent[0][0] + extent[1][0]) / 2,
71608             (extent[0][1] + extent[1][1]) / 2
71609           ]);
71610           var choice = geoChooseEdge(context.graph().childNodes(d2), loc, context.projection);
71611           dist = geoSphericalDistance(choice.loc, l2);
71612         }
71613         const value = resultProp && d2.tags[resultProp] ? d2.tags[resultProp] : d2.tags.name;
71614         let title = value;
71615         if (type2 === "street") {
71616           title = "".concat(addrField.t("placeholders.street"), ": ").concat(title);
71617         } else if (type2 === "place") {
71618           title = "".concat(addrField.t("placeholders.place"), ": ").concat(title);
71619         }
71620         return {
71621           title,
71622           value,
71623           dist,
71624           type: type2,
71625           klass: "address-".concat(type2)
71626         };
71627       }).sort(function(a2, b2) {
71628         return a2.dist - b2.dist;
71629       });
71630       return utilArrayUniqBy(features, "value");
71631     }
71632     function getNearStreets() {
71633       function isAddressable(d2) {
71634         return d2.tags.highway && d2.tags.name && d2.type === "way";
71635       }
71636       return getNear(isAddressable, "street", 200);
71637     }
71638     function getNearPlaces() {
71639       function isAddressable(d2) {
71640         if (d2.tags.name) {
71641           if (d2.tags.place) return true;
71642           if (d2.tags.boundary === "administrative" && d2.tags.admin_level > 8) return true;
71643         }
71644         return false;
71645       }
71646       return getNear(isAddressable, "place", 200);
71647     }
71648     function getNearCities() {
71649       function isAddressable(d2) {
71650         if (d2.tags.name) {
71651           if (d2.tags.boundary === "administrative" && d2.tags.admin_level === "8") return true;
71652           if (d2.tags.border_type === "city") return true;
71653           if (d2.tags.place === "city" || d2.tags.place === "town" || d2.tags.place === "village") return true;
71654         }
71655         if (d2.tags["".concat(field.key, ":city")]) return true;
71656         return false;
71657       }
71658       return getNear(isAddressable, "city", 200, "".concat(field.key, ":city"));
71659     }
71660     function getNearPostcodes() {
71661       return [...new Set([].concat(getNearValues("postcode")).concat(getNear((d2) => d2.tags.postal_code, "postcode", 200, "postal_code")))];
71662     }
71663     function getNearValues(key) {
71664       const tagKey = "".concat(field.key, ":").concat(key);
71665       function hasTag(d2) {
71666         return _entityIDs.indexOf(d2.id) === -1 && d2.tags[tagKey];
71667       }
71668       return getNear(hasTag, key, 200, tagKey);
71669     }
71670     function updateForCountryCode() {
71671       if (!_countryCode) return;
71672       var addressFormat;
71673       for (var i3 = 0; i3 < _addressFormats.length; i3++) {
71674         var format2 = _addressFormats[i3];
71675         if (!format2.countryCodes) {
71676           addressFormat = format2;
71677         } else if (format2.countryCodes.indexOf(_countryCode) !== -1) {
71678           addressFormat = format2;
71679           break;
71680         }
71681       }
71682       var dropdowns = addressFormat.dropdowns || [
71683         "city",
71684         "county",
71685         "country",
71686         "district",
71687         "hamlet",
71688         "neighbourhood",
71689         "place",
71690         "postcode",
71691         "province",
71692         "quarter",
71693         "state",
71694         "street",
71695         "street+place",
71696         "subdistrict",
71697         "suburb"
71698       ];
71699       var widths = addressFormat.widths || {
71700         housenumber: 1 / 5,
71701         unit: 1 / 5,
71702         street: 1 / 2,
71703         place: 1 / 2,
71704         city: 2 / 3,
71705         state: 1 / 4,
71706         postcode: 1 / 3
71707       };
71708       function row(r2) {
71709         var total = r2.reduce(function(sum, key) {
71710           return sum + (widths[key] || 0.5);
71711         }, 0);
71712         return r2.map(function(key) {
71713           return {
71714             id: key,
71715             width: (widths[key] || 0.5) / total
71716           };
71717         });
71718       }
71719       var rows = _wrap.selectAll(".addr-row").data(addressFormat.format, function(d2) {
71720         return d2.toString();
71721       });
71722       rows.exit().remove();
71723       rows.enter().append("div").attr("class", "addr-row").selectAll("input").data(row).enter().append("input").property("type", "text").call(updatePlaceholder).attr("class", function(d2) {
71724         return "addr-" + d2.id;
71725       }).call(utilNoAuto).each(addDropdown).style("width", function(d2) {
71726         return d2.width * 100 + "%";
71727       });
71728       function addDropdown(d2) {
71729         if (dropdowns.indexOf(d2.id) === -1) return;
71730         var nearValues;
71731         switch (d2.id) {
71732           case "street":
71733             nearValues = getNearStreets;
71734             break;
71735           case "place":
71736             nearValues = getNearPlaces;
71737             break;
71738           case "street+place":
71739             nearValues = () => [].concat(getNearStreets()).concat(getNearPlaces());
71740             d2.isAutoStreetPlace = true;
71741             d2.id = _tags["".concat(field.key, ":place")] ? "place" : "street";
71742             break;
71743           case "city":
71744             nearValues = getNearCities;
71745             break;
71746           case "postcode":
71747             nearValues = getNearPostcodes;
71748             break;
71749           default:
71750             nearValues = getNearValues;
71751         }
71752         select_default2(this).call(
71753           uiCombobox(context, "address-".concat(d2.isAutoStreetPlace ? "street-place" : d2.id)).minItems(1).caseSensitive(true).fetcher(function(typedValue, callback) {
71754             typedValue = typedValue.toLowerCase();
71755             callback(nearValues(d2.id).filter((v2) => v2.value.toLowerCase().indexOf(typedValue) !== -1));
71756           }).on("accept", function(selected) {
71757             if (d2.isAutoStreetPlace) {
71758               d2.id = selected ? selected.type : "street";
71759               utilTriggerEvent(select_default2(this), "change");
71760             }
71761           })
71762         );
71763       }
71764       _wrap.selectAll("input").on("blur", change()).on("change", change());
71765       _wrap.selectAll("input:not(.combobox-input)").on("input", change(true));
71766       if (_tags) updateTags(_tags);
71767     }
71768     function address(selection2) {
71769       _selection = selection2;
71770       _wrap = selection2.selectAll(".form-field-input-wrap").data([0]);
71771       _wrap = _wrap.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(_wrap);
71772       var extent = combinedEntityExtent();
71773       if (extent) {
71774         var countryCode;
71775         if (context.inIntro()) {
71776           countryCode = _t("intro.graph.countrycode");
71777         } else {
71778           var center = extent.center();
71779           countryCode = iso1A2Code(center);
71780         }
71781         if (countryCode) {
71782           _countryCode = countryCode.toLowerCase();
71783           updateForCountryCode();
71784         }
71785       }
71786     }
71787     function change(onInput) {
71788       return function() {
71789         var tags = {};
71790         _wrap.selectAll("input").each(function(subfield) {
71791           var key = field.key + ":" + subfield.id;
71792           var value = this.value;
71793           if (!onInput) value = context.cleanTagValue(value);
71794           if (Array.isArray(_tags[key]) && !value) return;
71795           if (subfield.isAutoStreetPlace) {
71796             if (subfield.id === "street") {
71797               tags["".concat(field.key, ":place")] = void 0;
71798             } else if (subfield.id === "place") {
71799               tags["".concat(field.key, ":street")] = void 0;
71800             }
71801           }
71802           tags[key] = value || void 0;
71803         });
71804         Object.keys(tags).filter((k2) => tags[k2]).forEach((k2) => _tags[k2] = tags[k2]);
71805         dispatch14.call("change", this, tags, onInput);
71806       };
71807     }
71808     function updatePlaceholder(inputSelection) {
71809       return inputSelection.attr("placeholder", function(subfield) {
71810         if (_tags && Array.isArray(_tags[field.key + ":" + subfield.id])) {
71811           return _t("inspector.multiple_values");
71812         }
71813         if (subfield.isAutoStreetPlace) {
71814           return "".concat(getLocalPlaceholder("street"), " / ").concat(getLocalPlaceholder("place"));
71815         }
71816         return getLocalPlaceholder(subfield.id);
71817       });
71818     }
71819     function getLocalPlaceholder(key) {
71820       if (_countryCode) {
71821         var localkey = key + "!" + _countryCode;
71822         var tkey = addrField.hasTextForStringId("placeholders." + localkey) ? localkey : key;
71823         return addrField.t("placeholders." + tkey);
71824       }
71825     }
71826     function updateTags(tags) {
71827       utilGetSetValue(_wrap.selectAll("input"), (subfield) => {
71828         var val;
71829         if (subfield.isAutoStreetPlace) {
71830           const streetKey = "".concat(field.key, ":street");
71831           const placeKey = "".concat(field.key, ":place");
71832           if (tags[streetKey] !== void 0 || tags[placeKey] === void 0) {
71833             val = tags[streetKey];
71834             subfield.id = "street";
71835           } else {
71836             val = tags[placeKey];
71837             subfield.id = "place";
71838           }
71839         } else {
71840           val = tags["".concat(field.key, ":").concat(subfield.id)];
71841         }
71842         return typeof val === "string" ? val : "";
71843       }).attr("title", function(subfield) {
71844         var val = tags[field.key + ":" + subfield.id];
71845         return val && Array.isArray(val) ? val.filter(Boolean).join("\n") : void 0;
71846       }).classed("mixed", function(subfield) {
71847         return Array.isArray(tags[field.key + ":" + subfield.id]);
71848       }).call(updatePlaceholder);
71849     }
71850     function combinedEntityExtent() {
71851       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
71852     }
71853     address.entityIDs = function(val) {
71854       if (!arguments.length) return _entityIDs;
71855       _entityIDs = val;
71856       return address;
71857     };
71858     address.tags = function(tags) {
71859       _tags = tags;
71860       updateTags(tags);
71861     };
71862     address.focus = function() {
71863       var node = _wrap.selectAll("input").node();
71864       if (node) node.focus();
71865     };
71866     return utilRebind(address, dispatch14, "on");
71867   }
71868
71869   // modules/ui/fields/directional_combo.js
71870   function uiFieldDirectionalCombo(field, context) {
71871     var dispatch14 = dispatch_default("change");
71872     var items = select_default2(null);
71873     var wrap2 = select_default2(null);
71874     var _tags;
71875     var _combos = {};
71876     if (field.type === "cycleway") {
71877       field = __spreadProps(__spreadValues({}, field), {
71878         key: field.keys[0],
71879         keys: field.keys.slice(1)
71880       });
71881     }
71882     function directionalCombo(selection2) {
71883       function stripcolon(s2) {
71884         return s2.replace(":", "");
71885       }
71886       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
71887       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
71888       var div = wrap2.selectAll("ul").data([0]);
71889       div = div.enter().append("ul").attr("class", "rows rows-table").merge(div);
71890       items = div.selectAll("li").data(field.keys);
71891       var enter = items.enter().append("li").attr("class", function(d2) {
71892         return "labeled-input preset-directionalcombo-" + stripcolon(d2);
71893       });
71894       enter.append("div").attr("class", "label preset-label-directionalcombo").attr("for", function(d2) {
71895         return "preset-input-directionalcombo-" + stripcolon(d2);
71896       }).html(function(d2) {
71897         return field.t.html("types." + d2);
71898       });
71899       enter.append("div").attr("class", "preset-input-directionalcombo-wrap form-field-input-wrap").each(function(key) {
71900         const subField = __spreadProps(__spreadValues({}, field), {
71901           type: "combo",
71902           key
71903         });
71904         const combo = uiFieldCombo(subField, context);
71905         combo.on("change", (t2) => change(key, t2[key]));
71906         _combos[key] = combo;
71907         select_default2(this).call(combo);
71908       });
71909       items = items.merge(enter);
71910       wrap2.selectAll(".preset-input-directionalcombo").on("change", change).on("blur", change);
71911     }
71912     function change(key, newValue) {
71913       const commonKey = field.key;
71914       const otherCommonKey = field.key.endsWith(":both") ? field.key.replace(/:both$/, "") : "".concat(field.key, ":both");
71915       const otherKey = key === field.keys[0] ? field.keys[1] : field.keys[0];
71916       dispatch14.call("change", this, (tags) => {
71917         const otherValue = tags[otherKey] || tags[commonKey] || tags[otherCommonKey];
71918         if (newValue === otherValue) {
71919           tags[commonKey] = newValue;
71920           delete tags[key];
71921           delete tags[otherKey];
71922           delete tags[otherCommonKey];
71923         } else {
71924           tags[key] = newValue;
71925           delete tags[commonKey];
71926           delete tags[otherCommonKey];
71927           tags[otherKey] = otherValue;
71928         }
71929         return tags;
71930       });
71931     }
71932     directionalCombo.tags = function(tags) {
71933       _tags = tags;
71934       const commonKey = field.key.replace(/:both$/, "");
71935       for (let key in _combos) {
71936         const uniqueValues = [...new Set([].concat(_tags[commonKey]).concat(_tags["".concat(commonKey, ":both")]).concat(_tags[key]).filter(Boolean))];
71937         _combos[key].tags({ [key]: uniqueValues.length > 1 ? uniqueValues : uniqueValues[0] });
71938       }
71939     };
71940     directionalCombo.focus = function() {
71941       var node = wrap2.selectAll("input").node();
71942       if (node) node.focus();
71943     };
71944     return utilRebind(directionalCombo, dispatch14, "on");
71945   }
71946
71947   // modules/ui/fields/lanes.js
71948   function uiFieldLanes(field, context) {
71949     var dispatch14 = dispatch_default("change");
71950     var LANE_WIDTH = 40;
71951     var LANE_HEIGHT = 200;
71952     var _entityIDs = [];
71953     function lanes(selection2) {
71954       var lanesData = context.entity(_entityIDs[0]).lanes();
71955       if (!context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode) {
71956         selection2.call(lanes.off);
71957         return;
71958       }
71959       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
71960       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
71961       var surface = wrap2.selectAll(".surface").data([0]);
71962       var d2 = utilGetDimensions(wrap2);
71963       var freeSpace = d2[0] - lanesData.lanes.length * LANE_WIDTH * 1.5 + LANE_WIDTH * 0.5;
71964       surface = surface.enter().append("svg").attr("width", d2[0]).attr("height", 300).attr("class", "surface").merge(surface);
71965       var lanesSelection = surface.selectAll(".lanes").data([0]);
71966       lanesSelection = lanesSelection.enter().append("g").attr("class", "lanes").merge(lanesSelection);
71967       lanesSelection.attr("transform", function() {
71968         return "translate(" + freeSpace / 2 + ", 0)";
71969       });
71970       var lane = lanesSelection.selectAll(".lane").data(lanesData.lanes);
71971       lane.exit().remove();
71972       var enter = lane.enter().append("g").attr("class", "lane");
71973       enter.append("g").append("rect").attr("y", 50).attr("width", LANE_WIDTH).attr("height", LANE_HEIGHT);
71974       enter.append("g").attr("class", "forward").append("text").attr("y", 40).attr("x", 14).text("\u25B2");
71975       enter.append("g").attr("class", "bothways").append("text").attr("y", 40).attr("x", 14).text("\u25B2\u25BC");
71976       enter.append("g").attr("class", "backward").append("text").attr("y", 40).attr("x", 14).text("\u25BC");
71977       lane = lane.merge(enter);
71978       lane.attr("transform", function(d4) {
71979         return "translate(" + LANE_WIDTH * d4.index * 1.5 + ", 0)";
71980       });
71981       lane.select(".forward").style("visibility", function(d4) {
71982         return d4.direction === "forward" ? "visible" : "hidden";
71983       });
71984       lane.select(".bothways").style("visibility", function(d4) {
71985         return d4.direction === "bothways" ? "visible" : "hidden";
71986       });
71987       lane.select(".backward").style("visibility", function(d4) {
71988         return d4.direction === "backward" ? "visible" : "hidden";
71989       });
71990     }
71991     lanes.entityIDs = function(val) {
71992       _entityIDs = val;
71993     };
71994     lanes.tags = function() {
71995     };
71996     lanes.focus = function() {
71997     };
71998     lanes.off = function() {
71999     };
72000     return utilRebind(lanes, dispatch14, "on");
72001   }
72002   uiFieldLanes.supportsMultiselection = false;
72003
72004   // modules/ui/fields/localized.js
72005   var _languagesArray = [];
72006   var LANGUAGE_SUFFIX_REGEX = /^(.*):([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?)$/;
72007   function uiFieldLocalized(field, context) {
72008     var dispatch14 = dispatch_default("change", "input");
72009     var wikipedia = services.wikipedia;
72010     var input = select_default2(null);
72011     var localizedInputs = select_default2(null);
72012     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
72013     var _countryCode;
72014     var _tags;
72015     _mainFileFetcher.get("languages").then(loadLanguagesArray).catch(function() {
72016     });
72017     var _territoryLanguages = {};
72018     _mainFileFetcher.get("territory_languages").then(function(d2) {
72019       _territoryLanguages = d2;
72020     }).catch(function() {
72021     });
72022     var langCombo = uiCombobox(context, "localized-lang").fetcher(fetchLanguages).minItems(0);
72023     var _selection = select_default2(null);
72024     var _multilingual = [];
72025     var _buttonTip = uiTooltip().title(() => _t.append("translate.translate")).placement("left");
72026     var _wikiTitles;
72027     var _entityIDs = [];
72028     function loadLanguagesArray(dataLanguages) {
72029       if (_languagesArray.length !== 0) return;
72030       var replacements = {
72031         sr: "sr-Cyrl",
72032         // in OSM, `sr` implies Cyrillic
72033         "sr-Cyrl": false
72034         // `sr-Cyrl` isn't used in OSM
72035       };
72036       for (var code in dataLanguages) {
72037         if (replacements[code] === false) continue;
72038         var metaCode = code;
72039         if (replacements[code]) metaCode = replacements[code];
72040         _languagesArray.push({
72041           localName: _mainLocalizer.languageName(metaCode, { localOnly: true }),
72042           nativeName: dataLanguages[metaCode].nativeName,
72043           code,
72044           label: _mainLocalizer.languageName(metaCode)
72045         });
72046       }
72047     }
72048     function calcLocked() {
72049       var isLocked = field.id === "name" && _entityIDs.length && _entityIDs.some(function(entityID) {
72050         var entity = context.graph().hasEntity(entityID);
72051         if (!entity) return false;
72052         if (entity.tags.wikidata) return true;
72053         if (entity.tags["name:etymology:wikidata"]) return true;
72054         var preset = _mainPresetIndex.match(entity, context.graph());
72055         if (preset) {
72056           var isSuggestion = preset.suggestion;
72057           var fields = preset.fields(entity.extent(context.graph()).center());
72058           var showsBrandField = fields.some(function(d2) {
72059             return d2.id === "brand";
72060           });
72061           var showsOperatorField = fields.some(function(d2) {
72062             return d2.id === "operator";
72063           });
72064           var setsName = preset.addTags.name;
72065           var setsBrandWikidata = preset.addTags["brand:wikidata"];
72066           var setsOperatorWikidata = preset.addTags["operator:wikidata"];
72067           return isSuggestion && setsName && (setsBrandWikidata && !showsBrandField || setsOperatorWikidata && !showsOperatorField);
72068         }
72069         return false;
72070       });
72071       field.locked(isLocked);
72072     }
72073     function calcMultilingual(tags) {
72074       var existingLangsOrdered = _multilingual.map(function(item2) {
72075         return item2.lang;
72076       });
72077       var existingLangs = new Set(existingLangsOrdered.filter(Boolean));
72078       for (var k2 in tags) {
72079         var m2 = k2.match(LANGUAGE_SUFFIX_REGEX);
72080         if (m2 && m2[1] === field.key && m2[2]) {
72081           var item = { lang: m2[2], value: tags[k2] };
72082           if (existingLangs.has(item.lang)) {
72083             _multilingual[existingLangsOrdered.indexOf(item.lang)].value = item.value;
72084             existingLangs.delete(item.lang);
72085           } else {
72086             _multilingual.push(item);
72087           }
72088         }
72089       }
72090       _multilingual.forEach(function(item2) {
72091         if (item2.lang && existingLangs.has(item2.lang)) {
72092           item2.value = "";
72093         }
72094       });
72095     }
72096     function localized(selection2) {
72097       _selection = selection2;
72098       calcLocked();
72099       var isLocked = field.locked();
72100       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
72101       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
72102       input = wrap2.selectAll(".localized-main").data([0]);
72103       input = input.enter().append("input").attr("type", "text").attr("id", field.domId).attr("class", "localized-main").call(utilNoAuto).merge(input);
72104       input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
72105       wrap2.call(_lengthIndicator);
72106       var translateButton = wrap2.selectAll(".localized-add").data([0]);
72107       translateButton = translateButton.enter().append("button").attr("class", "localized-add form-field-button").attr("aria-label", _t("icons.plus")).call(svgIcon("#iD-icon-plus")).merge(translateButton);
72108       translateButton.classed("disabled", !!isLocked).call(isLocked ? _buttonTip.destroy : _buttonTip).on("click", addNew);
72109       if (_tags && !_multilingual.length) {
72110         calcMultilingual(_tags);
72111       }
72112       localizedInputs = selection2.selectAll(".localized-multilingual").data([0]);
72113       localizedInputs = localizedInputs.enter().append("div").attr("class", "localized-multilingual").merge(localizedInputs);
72114       localizedInputs.call(renderMultilingual);
72115       localizedInputs.selectAll("button, input").classed("disabled", !!isLocked).attr("readonly", isLocked || null);
72116       selection2.selectAll(".combobox-caret").classed("nope", true);
72117       function addNew(d3_event) {
72118         d3_event.preventDefault();
72119         if (field.locked()) return;
72120         var defaultLang = _mainLocalizer.languageCode().toLowerCase();
72121         var langExists = _multilingual.find(function(datum2) {
72122           return datum2.lang === defaultLang;
72123         });
72124         var isLangEn = defaultLang.indexOf("en") > -1;
72125         if (isLangEn || langExists) {
72126           defaultLang = "";
72127           langExists = _multilingual.find(function(datum2) {
72128             return datum2.lang === defaultLang;
72129           });
72130         }
72131         if (!langExists) {
72132           _multilingual.unshift({ lang: defaultLang, value: "" });
72133           localizedInputs.call(renderMultilingual);
72134         }
72135       }
72136       function change(onInput) {
72137         return function(d3_event) {
72138           if (field.locked()) {
72139             d3_event.preventDefault();
72140             return;
72141           }
72142           var val = utilGetSetValue(select_default2(this));
72143           if (!onInput) val = context.cleanTagValue(val);
72144           if (!val && Array.isArray(_tags[field.key])) return;
72145           var t2 = {};
72146           t2[field.key] = val || void 0;
72147           dispatch14.call("change", this, t2, onInput);
72148         };
72149       }
72150     }
72151     function key(lang) {
72152       return field.key + ":" + lang;
72153     }
72154     function changeLang(d3_event, d2) {
72155       var tags = {};
72156       var lang = utilGetSetValue(select_default2(this)).toLowerCase();
72157       var language = _languagesArray.find(function(d4) {
72158         return d4.label.toLowerCase() === lang || d4.localName && d4.localName.toLowerCase() === lang || d4.nativeName && d4.nativeName.toLowerCase() === lang;
72159       });
72160       if (language) lang = language.code;
72161       if (d2.lang && d2.lang !== lang) {
72162         tags[key(d2.lang)] = void 0;
72163       }
72164       var newKey = lang && context.cleanTagKey(key(lang));
72165       var value = utilGetSetValue(select_default2(this.parentNode).selectAll(".localized-value"));
72166       if (newKey && value) {
72167         tags[newKey] = value;
72168       } else if (newKey && _wikiTitles && _wikiTitles[d2.lang]) {
72169         tags[newKey] = _wikiTitles[d2.lang];
72170       }
72171       d2.lang = lang;
72172       dispatch14.call("change", this, tags);
72173     }
72174     function changeValue(d3_event, d2) {
72175       if (!d2.lang) return;
72176       var value = context.cleanTagValue(utilGetSetValue(select_default2(this))) || void 0;
72177       if (!value && Array.isArray(d2.value)) return;
72178       var t2 = {};
72179       t2[key(d2.lang)] = value;
72180       d2.value = value;
72181       dispatch14.call("change", this, t2);
72182     }
72183     function fetchLanguages(value, cb) {
72184       var v2 = value.toLowerCase();
72185       var langCodes = [_mainLocalizer.localeCode(), _mainLocalizer.languageCode()];
72186       if (_countryCode && _territoryLanguages[_countryCode]) {
72187         langCodes = langCodes.concat(_territoryLanguages[_countryCode]);
72188       }
72189       var langItems = [];
72190       langCodes.forEach(function(code) {
72191         var langItem = _languagesArray.find(function(item) {
72192           return item.code === code;
72193         });
72194         if (langItem) langItems.push(langItem);
72195       });
72196       langItems = utilArrayUniq(langItems.concat(_languagesArray));
72197       cb(langItems.filter(function(d2) {
72198         return d2.label.toLowerCase().indexOf(v2) >= 0 || d2.localName && d2.localName.toLowerCase().indexOf(v2) >= 0 || d2.nativeName && d2.nativeName.toLowerCase().indexOf(v2) >= 0 || d2.code.toLowerCase().indexOf(v2) >= 0;
72199       }).map(function(d2) {
72200         return { value: d2.label };
72201       }));
72202     }
72203     function renderMultilingual(selection2) {
72204       var entries = selection2.selectAll("div.entry").data(_multilingual, function(d2) {
72205         return d2.lang;
72206       });
72207       entries.exit().style("top", "0").style("max-height", "240px").transition().duration(200).style("opacity", "0").style("max-height", "0px").remove();
72208       var entriesEnter = entries.enter().append("div").attr("class", "entry").each(function(_2, index) {
72209         var wrap2 = select_default2(this);
72210         var domId = utilUniqueDomId(index);
72211         var label = wrap2.append("label").attr("class", "field-label").attr("for", domId);
72212         var text = label.append("span").attr("class", "label-text");
72213         text.append("span").attr("class", "label-textvalue").call(_t.append("translate.localized_translation_label"));
72214         text.append("span").attr("class", "label-textannotation");
72215         label.append("button").attr("class", "remove-icon-multilingual").attr("title", _t("icons.remove")).on("click", function(d3_event, d2) {
72216           if (field.locked()) return;
72217           d3_event.preventDefault();
72218           _multilingual.splice(_multilingual.indexOf(d2), 1);
72219           var langKey = d2.lang && key(d2.lang);
72220           if (langKey && langKey in _tags) {
72221             delete _tags[langKey];
72222             var t2 = {};
72223             t2[langKey] = void 0;
72224             dispatch14.call("change", this, t2);
72225             return;
72226           }
72227           renderMultilingual(selection2);
72228         }).call(svgIcon("#iD-operation-delete"));
72229         wrap2.append("input").attr("class", "localized-lang").attr("id", domId).attr("type", "text").attr("placeholder", _t("translate.localized_translation_language")).on("blur", changeLang).on("change", changeLang).call(langCombo);
72230         wrap2.append("input").attr("type", "text").attr("class", "localized-value").on("blur", changeValue).on("change", changeValue);
72231       });
72232       entriesEnter.style("margin-top", "0px").style("max-height", "0px").style("opacity", "0").transition().duration(200).style("margin-top", "10px").style("max-height", "240px").style("opacity", "1").on("end", function() {
72233         select_default2(this).style("max-height", "").style("overflow", "visible");
72234       });
72235       entries = entries.merge(entriesEnter);
72236       entries.order();
72237       entries.classed("present", true);
72238       utilGetSetValue(entries.select(".localized-lang"), function(d2) {
72239         var langItem = _languagesArray.find(function(item) {
72240           return item.code === d2.lang;
72241         });
72242         if (langItem) return langItem.label;
72243         return d2.lang;
72244       });
72245       utilGetSetValue(entries.select(".localized-value"), function(d2) {
72246         return typeof d2.value === "string" ? d2.value : "";
72247       }).attr("title", function(d2) {
72248         return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : null;
72249       }).attr("placeholder", function(d2) {
72250         return Array.isArray(d2.value) ? _t("inspector.multiple_values") : _t("translate.localized_translation_name");
72251       }).attr("lang", function(d2) {
72252         return d2.lang;
72253       }).classed("mixed", function(d2) {
72254         return Array.isArray(d2.value);
72255       });
72256     }
72257     localized.tags = function(tags) {
72258       _tags = tags;
72259       if (typeof tags.wikipedia === "string" && !_wikiTitles) {
72260         _wikiTitles = {};
72261         var wm = tags.wikipedia.match(/([^:]+):(.+)/);
72262         if (wm && wm[0] && wm[1]) {
72263           wikipedia.translations(wm[1], wm[2], function(err, d2) {
72264             if (err || !d2) return;
72265             _wikiTitles = d2;
72266           });
72267         }
72268       }
72269       var isMixed = Array.isArray(tags[field.key]);
72270       utilGetSetValue(input, typeof tags[field.key] === "string" ? tags[field.key] : "").attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder()).classed("mixed", isMixed);
72271       calcMultilingual(tags);
72272       _selection.call(localized);
72273       if (!isMixed) {
72274         _lengthIndicator.update(tags[field.key]);
72275       }
72276     };
72277     localized.focus = function() {
72278       input.node().focus();
72279     };
72280     localized.entityIDs = function(val) {
72281       if (!arguments.length) return _entityIDs;
72282       _entityIDs = val;
72283       _multilingual = [];
72284       loadCountryCode();
72285       return localized;
72286     };
72287     function loadCountryCode() {
72288       var extent = combinedEntityExtent();
72289       var countryCode = extent && iso1A2Code(extent.center());
72290       _countryCode = countryCode && countryCode.toLowerCase();
72291     }
72292     function combinedEntityExtent() {
72293       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
72294     }
72295     return utilRebind(localized, dispatch14, "on");
72296   }
72297
72298   // modules/ui/fields/roadheight.js
72299   function uiFieldRoadheight(field, context) {
72300     var dispatch14 = dispatch_default("change");
72301     var primaryUnitInput = select_default2(null);
72302     var primaryInput = select_default2(null);
72303     var secondaryInput = select_default2(null);
72304     var secondaryUnitInput = select_default2(null);
72305     var _entityIDs = [];
72306     var _tags;
72307     var _isImperial;
72308     var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
72309     var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
72310     var primaryUnits = [
72311       {
72312         value: "m",
72313         title: _t("inspector.roadheight.meter")
72314       },
72315       {
72316         value: "ft",
72317         title: _t("inspector.roadheight.foot")
72318       }
72319     ];
72320     var unitCombo = uiCombobox(context, "roadheight-unit").data(primaryUnits);
72321     function roadheight(selection2) {
72322       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
72323       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
72324       primaryInput = wrap2.selectAll("input.roadheight-number").data([0]);
72325       primaryInput = primaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-number").attr("id", field.domId).call(utilNoAuto).merge(primaryInput);
72326       primaryInput.on("change", change).on("blur", change);
72327       var loc = combinedEntityExtent().center();
72328       _isImperial = roadHeightUnit(loc) === "ft";
72329       primaryUnitInput = wrap2.selectAll("input.roadheight-unit").data([0]);
72330       primaryUnitInput = primaryUnitInput.enter().append("input").attr("type", "text").attr("class", "roadheight-unit").call(unitCombo).merge(primaryUnitInput);
72331       primaryUnitInput.on("blur", changeUnits).on("change", changeUnits);
72332       secondaryInput = wrap2.selectAll("input.roadheight-secondary-number").data([0]);
72333       secondaryInput = secondaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-secondary-number").call(utilNoAuto).merge(secondaryInput);
72334       secondaryInput.on("change", change).on("blur", change);
72335       secondaryUnitInput = wrap2.selectAll("input.roadheight-secondary-unit").data([0]);
72336       secondaryUnitInput = secondaryUnitInput.enter().append("input").attr("type", "text").call(utilNoAuto).classed("disabled", true).classed("roadheight-secondary-unit", true).attr("readonly", "readonly").merge(secondaryUnitInput);
72337       function changeUnits() {
72338         var primaryUnit = utilGetSetValue(primaryUnitInput);
72339         if (primaryUnit === "m") {
72340           _isImperial = false;
72341         } else if (primaryUnit === "ft") {
72342           _isImperial = true;
72343         }
72344         utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
72345         setUnitSuggestions();
72346         change();
72347       }
72348     }
72349     function setUnitSuggestions() {
72350       utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
72351     }
72352     function change() {
72353       var tag2 = {};
72354       var primaryValue = utilGetSetValue(primaryInput).trim();
72355       var secondaryValue = utilGetSetValue(secondaryInput).trim();
72356       if (!primaryValue && !secondaryValue && Array.isArray(_tags[field.key])) return;
72357       if (!primaryValue && !secondaryValue) {
72358         tag2[field.key] = void 0;
72359       } else {
72360         var rawPrimaryValue = likelyRawNumberFormat.test(primaryValue) ? parseFloat(primaryValue) : parseLocaleFloat(primaryValue);
72361         if (isNaN(rawPrimaryValue)) rawPrimaryValue = primaryValue;
72362         var rawSecondaryValue = likelyRawNumberFormat.test(secondaryValue) ? parseFloat(secondaryValue) : parseLocaleFloat(secondaryValue);
72363         if (isNaN(rawSecondaryValue)) rawSecondaryValue = secondaryValue;
72364         if (isNaN(rawPrimaryValue) || isNaN(rawSecondaryValue) || !_isImperial) {
72365           tag2[field.key] = context.cleanTagValue(rawPrimaryValue);
72366         } else {
72367           if (rawPrimaryValue !== "") {
72368             rawPrimaryValue = rawPrimaryValue + "'";
72369           }
72370           if (rawSecondaryValue !== "") {
72371             rawSecondaryValue = rawSecondaryValue + '"';
72372           }
72373           tag2[field.key] = context.cleanTagValue(rawPrimaryValue + rawSecondaryValue);
72374         }
72375       }
72376       dispatch14.call("change", this, tag2);
72377     }
72378     roadheight.tags = function(tags) {
72379       _tags = tags;
72380       var primaryValue = tags[field.key];
72381       var secondaryValue;
72382       var isMixed = Array.isArray(primaryValue);
72383       if (!isMixed) {
72384         if (primaryValue && (primaryValue.indexOf("'") >= 0 || primaryValue.indexOf('"') >= 0)) {
72385           secondaryValue = primaryValue.match(/(-?[\d.]+)"/);
72386           if (secondaryValue !== null) {
72387             secondaryValue = formatFloat(parseFloat(secondaryValue[1]));
72388           }
72389           primaryValue = primaryValue.match(/(-?[\d.]+)'/);
72390           if (primaryValue !== null) {
72391             primaryValue = formatFloat(parseFloat(primaryValue[1]));
72392           }
72393           _isImperial = true;
72394         } else if (primaryValue) {
72395           var rawValue = primaryValue;
72396           primaryValue = parseFloat(rawValue);
72397           if (isNaN(primaryValue)) {
72398             primaryValue = rawValue;
72399           } else {
72400             primaryValue = formatFloat(primaryValue);
72401           }
72402           _isImperial = false;
72403         }
72404       }
72405       setUnitSuggestions();
72406       var inchesPlaceholder = formatFloat(0);
72407       utilGetSetValue(primaryInput, typeof primaryValue === "string" ? primaryValue : "").attr("title", isMixed ? primaryValue.filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : _t("inspector.unknown")).classed("mixed", isMixed);
72408       utilGetSetValue(secondaryInput, typeof secondaryValue === "string" ? secondaryValue : "").attr("placeholder", isMixed ? _t("inspector.multiple_values") : _isImperial ? inchesPlaceholder : null).classed("mixed", isMixed).classed("disabled", !_isImperial).attr("readonly", _isImperial ? null : "readonly");
72409       secondaryUnitInput.attr("value", _isImperial ? _t("inspector.roadheight.inch") : null);
72410     };
72411     roadheight.focus = function() {
72412       primaryInput.node().focus();
72413     };
72414     roadheight.entityIDs = function(val) {
72415       _entityIDs = val;
72416     };
72417     function combinedEntityExtent() {
72418       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
72419     }
72420     return utilRebind(roadheight, dispatch14, "on");
72421   }
72422
72423   // modules/ui/fields/roadspeed.js
72424   function uiFieldRoadspeed(field, context) {
72425     var dispatch14 = dispatch_default("change");
72426     var unitInput = select_default2(null);
72427     var input = select_default2(null);
72428     var _entityIDs = [];
72429     var _tags;
72430     var _isImperial;
72431     var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
72432     var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
72433     var speedCombo = uiCombobox(context, "roadspeed");
72434     var unitCombo = uiCombobox(context, "roadspeed-unit").data(["km/h", "mph"].map(comboValues));
72435     var metricValues = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120];
72436     var imperialValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80];
72437     function roadspeed(selection2) {
72438       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
72439       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
72440       input = wrap2.selectAll("input.roadspeed-number").data([0]);
72441       input = input.enter().append("input").attr("type", "text").attr("class", "roadspeed-number").attr("id", field.domId).call(utilNoAuto).call(speedCombo).merge(input);
72442       input.on("change", change).on("blur", change);
72443       var loc = combinedEntityExtent().center();
72444       _isImperial = roadSpeedUnit(loc) === "mph";
72445       unitInput = wrap2.selectAll("input.roadspeed-unit").data([0]);
72446       unitInput = unitInput.enter().append("input").attr("type", "text").attr("class", "roadspeed-unit").attr("aria-label", _t("inspector.speed_unit")).call(unitCombo).merge(unitInput);
72447       unitInput.on("blur", changeUnits).on("change", changeUnits);
72448       function changeUnits() {
72449         var unit2 = utilGetSetValue(unitInput);
72450         if (unit2 === "km/h") {
72451           _isImperial = false;
72452         } else if (unit2 === "mph") {
72453           _isImperial = true;
72454         }
72455         utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
72456         setUnitSuggestions();
72457         change();
72458       }
72459     }
72460     function setUnitSuggestions() {
72461       speedCombo.data((_isImperial ? imperialValues : metricValues).map(comboValues));
72462       utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
72463     }
72464     function comboValues(d2) {
72465       return {
72466         value: formatFloat(d2),
72467         title: formatFloat(d2)
72468       };
72469     }
72470     function change() {
72471       var tag2 = {};
72472       var value = utilGetSetValue(input).trim();
72473       if (!value && Array.isArray(_tags[field.key])) return;
72474       if (!value) {
72475         tag2[field.key] = void 0;
72476       } else {
72477         var rawValue = likelyRawNumberFormat.test(value) ? parseFloat(value) : parseLocaleFloat(value);
72478         if (isNaN(rawValue)) rawValue = value;
72479         if (isNaN(rawValue) || !_isImperial) {
72480           tag2[field.key] = context.cleanTagValue(rawValue);
72481         } else {
72482           tag2[field.key] = context.cleanTagValue(rawValue + " mph");
72483         }
72484       }
72485       dispatch14.call("change", this, tag2);
72486     }
72487     roadspeed.tags = function(tags) {
72488       _tags = tags;
72489       var rawValue = tags[field.key];
72490       var value = rawValue;
72491       var isMixed = Array.isArray(value);
72492       if (!isMixed) {
72493         if (rawValue && rawValue.indexOf("mph") >= 0) {
72494           _isImperial = true;
72495         } else if (rawValue) {
72496           _isImperial = false;
72497         }
72498         value = parseInt(value, 10);
72499         if (isNaN(value)) {
72500           value = rawValue;
72501         } else {
72502           value = formatFloat(value);
72503         }
72504       }
72505       setUnitSuggestions();
72506       utilGetSetValue(input, typeof value === "string" ? value : "").attr("title", isMixed ? value.filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder()).classed("mixed", isMixed);
72507     };
72508     roadspeed.focus = function() {
72509       input.node().focus();
72510     };
72511     roadspeed.entityIDs = function(val) {
72512       _entityIDs = val;
72513     };
72514     function combinedEntityExtent() {
72515       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
72516     }
72517     return utilRebind(roadspeed, dispatch14, "on");
72518   }
72519
72520   // modules/ui/fields/radio.js
72521   function uiFieldRadio(field, context) {
72522     var dispatch14 = dispatch_default("change");
72523     var placeholder = select_default2(null);
72524     var wrap2 = select_default2(null);
72525     var labels = select_default2(null);
72526     var radios = select_default2(null);
72527     var radioData = (field.options || field.keys).slice();
72528     var typeField;
72529     var layerField;
72530     var _oldType = {};
72531     var _entityIDs = [];
72532     function selectedKey() {
72533       var node = wrap2.selectAll(".form-field-input-radio label.active input");
72534       return !node.empty() && node.datum();
72535     }
72536     function radio(selection2) {
72537       selection2.classed("preset-radio", true);
72538       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
72539       var enter = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-radio");
72540       enter.append("span").attr("class", "placeholder");
72541       wrap2 = wrap2.merge(enter);
72542       placeholder = wrap2.selectAll(".placeholder");
72543       labels = wrap2.selectAll("label").data(radioData);
72544       enter = labels.enter().append("label");
72545       var stringsField = field.resolveReference("stringsCrossReference");
72546       enter.append("input").attr("type", "radio").attr("name", field.id).attr("value", function(d2) {
72547         return stringsField.t("options." + d2, { "default": d2 });
72548       }).attr("checked", false);
72549       enter.append("span").each(function(d2) {
72550         stringsField.t.append("options." + d2, { "default": d2 })(select_default2(this));
72551       });
72552       labels = labels.merge(enter);
72553       radios = labels.selectAll("input").on("change", changeRadio);
72554     }
72555     function structureExtras(selection2, tags) {
72556       var selected = selectedKey() || tags.layer !== void 0;
72557       var type2 = _mainPresetIndex.field(selected);
72558       var layer = _mainPresetIndex.field("layer");
72559       var showLayer = selected === "bridge" || selected === "tunnel" || tags.layer !== void 0;
72560       var extrasWrap = selection2.selectAll(".structure-extras-wrap").data(selected ? [0] : []);
72561       extrasWrap.exit().remove();
72562       extrasWrap = extrasWrap.enter().append("div").attr("class", "structure-extras-wrap").merge(extrasWrap);
72563       var list2 = extrasWrap.selectAll("ul").data([0]);
72564       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
72565       if (type2) {
72566         if (!typeField || typeField.id !== selected) {
72567           typeField = uiField(context, type2, _entityIDs, { wrap: false }).on("change", changeType);
72568         }
72569         typeField.tags(tags);
72570       } else {
72571         typeField = null;
72572       }
72573       var typeItem = list2.selectAll(".structure-type-item").data(typeField ? [typeField] : [], function(d2) {
72574         return d2.id;
72575       });
72576       typeItem.exit().remove();
72577       var typeEnter = typeItem.enter().insert("li", ":first-child").attr("class", "labeled-input structure-type-item");
72578       typeEnter.append("div").attr("class", "label structure-label-type").attr("for", "preset-input-" + selected).call(_t.append("inspector.radio.structure.type"));
72579       typeEnter.append("div").attr("class", "structure-input-type-wrap");
72580       typeItem = typeItem.merge(typeEnter);
72581       if (typeField) {
72582         typeItem.selectAll(".structure-input-type-wrap").call(typeField.render);
72583       }
72584       if (layer && showLayer) {
72585         if (!layerField) {
72586           layerField = uiField(context, layer, _entityIDs, { wrap: false }).on("change", changeLayer);
72587         }
72588         layerField.tags(tags);
72589         field.keys = utilArrayUnion(field.keys, ["layer"]);
72590       } else {
72591         layerField = null;
72592         field.keys = field.keys.filter(function(k2) {
72593           return k2 !== "layer";
72594         });
72595       }
72596       var layerItem = list2.selectAll(".structure-layer-item").data(layerField ? [layerField] : []);
72597       layerItem.exit().remove();
72598       var layerEnter = layerItem.enter().append("li").attr("class", "labeled-input structure-layer-item");
72599       layerEnter.append("div").attr("class", "label structure-label-layer").attr("for", "preset-input-layer").call(_t.append("inspector.radio.structure.layer"));
72600       layerEnter.append("div").attr("class", "structure-input-layer-wrap");
72601       layerItem = layerItem.merge(layerEnter);
72602       if (layerField) {
72603         layerItem.selectAll(".structure-input-layer-wrap").call(layerField.render);
72604       }
72605     }
72606     function changeType(t2, onInput) {
72607       var key = selectedKey();
72608       if (!key) return;
72609       var val = t2[key];
72610       if (val !== "no") {
72611         _oldType[key] = val;
72612       }
72613       if (field.type === "structureRadio") {
72614         if (val === "no" || key !== "bridge" && key !== "tunnel" || key === "tunnel" && val === "building_passage") {
72615           t2.layer = void 0;
72616         }
72617         if (t2.layer === void 0) {
72618           if (key === "bridge" && val !== "no") {
72619             t2.layer = "1";
72620           }
72621           if (key === "tunnel" && val !== "no" && val !== "building_passage") {
72622             t2.layer = "-1";
72623           }
72624         }
72625       }
72626       dispatch14.call("change", this, t2, onInput);
72627     }
72628     function changeLayer(t2, onInput) {
72629       if (t2.layer === "0") {
72630         t2.layer = void 0;
72631       }
72632       dispatch14.call("change", this, t2, onInput);
72633     }
72634     function changeRadio() {
72635       var t2 = {};
72636       var activeKey;
72637       if (field.key) {
72638         t2[field.key] = void 0;
72639       }
72640       radios.each(function(d2) {
72641         var active = select_default2(this).property("checked");
72642         if (active) activeKey = d2;
72643         if (field.key) {
72644           if (active) t2[field.key] = d2;
72645         } else {
72646           var val = _oldType[activeKey] || "yes";
72647           t2[d2] = active ? val : void 0;
72648         }
72649       });
72650       if (field.type === "structureRadio") {
72651         if (activeKey === "bridge") {
72652           t2.layer = "1";
72653         } else if (activeKey === "tunnel" && t2.tunnel !== "building_passage") {
72654           t2.layer = "-1";
72655         } else {
72656           t2.layer = void 0;
72657         }
72658       }
72659       dispatch14.call("change", this, t2);
72660     }
72661     radio.tags = function(tags) {
72662       function isOptionChecked(d2) {
72663         if (field.key) {
72664           return tags[field.key] === d2;
72665         }
72666         return !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
72667       }
72668       function isMixed(d2) {
72669         if (field.key) {
72670           return Array.isArray(tags[field.key]) && tags[field.key].includes(d2);
72671         }
72672         return Array.isArray(tags[d2]);
72673       }
72674       radios.property("checked", function(d2) {
72675         return isOptionChecked(d2) && (field.key || field.options.filter(isOptionChecked).length === 1);
72676       });
72677       labels.classed("active", function(d2) {
72678         if (field.key) {
72679           return Array.isArray(tags[field.key]) && tags[field.key].includes(d2) || tags[field.key] === d2;
72680         }
72681         return Array.isArray(tags[d2]) && tags[d2].some((v2) => typeof v2 === "string" && v2.toLowerCase() !== "no") || !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
72682       }).classed("mixed", isMixed).attr("title", function(d2) {
72683         return isMixed(d2) ? _t("inspector.unshared_value_tooltip") : null;
72684       });
72685       var selection2 = radios.filter(function() {
72686         return this.checked;
72687       });
72688       if (selection2.empty()) {
72689         placeholder.text("");
72690         placeholder.call(_t.append("inspector.none"));
72691       } else {
72692         placeholder.text(selection2.attr("value"));
72693         _oldType[selection2.datum()] = tags[selection2.datum()];
72694       }
72695       if (field.type === "structureRadio") {
72696         if (!!tags.waterway && !_oldType.tunnel) {
72697           _oldType.tunnel = "culvert";
72698         }
72699         wrap2.call(structureExtras, tags);
72700       }
72701     };
72702     radio.focus = function() {
72703       radios.node().focus();
72704     };
72705     radio.entityIDs = function(val) {
72706       if (!arguments.length) return _entityIDs;
72707       _entityIDs = val;
72708       _oldType = {};
72709       return radio;
72710     };
72711     radio.isAllowed = function() {
72712       return _entityIDs.length === 1;
72713     };
72714     return utilRebind(radio, dispatch14, "on");
72715   }
72716
72717   // modules/ui/fields/restrictions.js
72718   function uiFieldRestrictions(field, context) {
72719     var dispatch14 = dispatch_default("change");
72720     var breathe = behaviorBreathe(context);
72721     corePreferences("turn-restriction-via-way", null);
72722     var storedViaWay = corePreferences("turn-restriction-via-way0");
72723     var storedDistance = corePreferences("turn-restriction-distance");
72724     var _maxViaWay = storedViaWay !== null ? +storedViaWay : 0;
72725     var _maxDistance = storedDistance ? +storedDistance : 30;
72726     var _initialized3 = false;
72727     var _parent = select_default2(null);
72728     var _container = select_default2(null);
72729     var _oldTurns;
72730     var _graph;
72731     var _vertexID;
72732     var _intersection;
72733     var _fromWayID;
72734     var _lastXPos;
72735     function restrictions(selection2) {
72736       _parent = selection2;
72737       if (_vertexID && (context.graph() !== _graph || !_intersection)) {
72738         _graph = context.graph();
72739         _intersection = osmIntersection(_graph, _vertexID, _maxDistance);
72740       }
72741       var isOK = _intersection && _intersection.vertices.length && // has vertices
72742       _intersection.vertices.filter(function(vertex) {
72743         return vertex.id === _vertexID;
72744       }).length && _intersection.ways.length > 2;
72745       select_default2(selection2.node().parentNode).classed("hide", !isOK);
72746       if (!isOK || !context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode || !selection2.node().parentNode.parentNode) {
72747         selection2.call(restrictions.off);
72748         return;
72749       }
72750       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
72751       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
72752       var container = wrap2.selectAll(".restriction-container").data([0]);
72753       var containerEnter = container.enter().append("div").attr("class", "restriction-container");
72754       containerEnter.append("div").attr("class", "restriction-help");
72755       _container = containerEnter.merge(container).call(renderViewer);
72756       var controls = wrap2.selectAll(".restriction-controls").data([0]);
72757       controls.enter().append("div").attr("class", "restriction-controls-container").append("div").attr("class", "restriction-controls").merge(controls).call(renderControls);
72758     }
72759     function renderControls(selection2) {
72760       var distControl = selection2.selectAll(".restriction-distance").data([0]);
72761       distControl.exit().remove();
72762       var distControlEnter = distControl.enter().append("div").attr("class", "restriction-control restriction-distance");
72763       distControlEnter.append("span").attr("class", "restriction-control-label restriction-distance-label").call(_t.append("restriction.controls.distance", { suffix: ":" }));
72764       distControlEnter.append("input").attr("class", "restriction-distance-input").attr("type", "range").attr("min", "20").attr("max", "50").attr("step", "5");
72765       distControlEnter.append("span").attr("class", "restriction-distance-text");
72766       selection2.selectAll(".restriction-distance-input").property("value", _maxDistance).on("input", function() {
72767         var val = select_default2(this).property("value");
72768         _maxDistance = +val;
72769         _intersection = null;
72770         _container.selectAll(".layer-osm .layer-turns *").remove();
72771         corePreferences("turn-restriction-distance", _maxDistance);
72772         _parent.call(restrictions);
72773       });
72774       selection2.selectAll(".restriction-distance-text").call(displayMaxDistance(_maxDistance));
72775       var viaControl = selection2.selectAll(".restriction-via-way").data([0]);
72776       viaControl.exit().remove();
72777       var viaControlEnter = viaControl.enter().append("div").attr("class", "restriction-control restriction-via-way");
72778       viaControlEnter.append("span").attr("class", "restriction-control-label restriction-via-way-label").call(_t.append("restriction.controls.via", { suffix: ":" }));
72779       viaControlEnter.append("input").attr("class", "restriction-via-way-input").attr("type", "range").attr("min", "0").attr("max", "2").attr("step", "1");
72780       viaControlEnter.append("span").attr("class", "restriction-via-way-text");
72781       selection2.selectAll(".restriction-via-way-input").property("value", _maxViaWay).on("input", function() {
72782         var val = select_default2(this).property("value");
72783         _maxViaWay = +val;
72784         _container.selectAll(".layer-osm .layer-turns *").remove();
72785         corePreferences("turn-restriction-via-way0", _maxViaWay);
72786         _parent.call(restrictions);
72787       });
72788       selection2.selectAll(".restriction-via-way-text").call(displayMaxVia(_maxViaWay));
72789     }
72790     function renderViewer(selection2) {
72791       if (!_intersection) return;
72792       var vgraph = _intersection.graph;
72793       var filter2 = utilFunctor(true);
72794       var projection2 = geoRawMercator();
72795       var sdims = utilGetDimensions(context.container().select(".sidebar"));
72796       var d2 = [sdims[0] - 50, 370];
72797       var c2 = geoVecScale(d2, 0.5);
72798       var z2 = 22;
72799       projection2.scale(geoZoomToScale(z2));
72800       var extent = geoExtent();
72801       for (var i3 = 0; i3 < _intersection.vertices.length; i3++) {
72802         extent._extend(_intersection.vertices[i3].extent());
72803       }
72804       var padTop = 35;
72805       if (_intersection.vertices.length > 1) {
72806         var hPadding = Math.min(160, Math.max(110, d2[0] * 0.4));
72807         var vPadding = 160;
72808         var tl = projection2([extent[0][0], extent[1][1]]);
72809         var br2 = projection2([extent[1][0], extent[0][1]]);
72810         var hFactor = (br2[0] - tl[0]) / (d2[0] - hPadding);
72811         var vFactor = (br2[1] - tl[1]) / (d2[1] - vPadding - padTop);
72812         var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
72813         var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
72814         z2 = z2 - Math.max(hZoomDiff, vZoomDiff);
72815         projection2.scale(geoZoomToScale(z2));
72816       }
72817       var extentCenter = projection2(extent.center());
72818       extentCenter[1] = extentCenter[1] - padTop / 2;
72819       projection2.translate(geoVecSubtract(c2, extentCenter)).clipExtent([[0, 0], d2]);
72820       var drawLayers = svgLayers(projection2, context).only(["osm", "touch"]).dimensions(d2);
72821       var drawVertices = svgVertices(projection2, context);
72822       var drawLines = svgLines(projection2, context);
72823       var drawTurns = svgTurns(projection2, context);
72824       var firstTime = selection2.selectAll(".surface").empty();
72825       selection2.call(drawLayers);
72826       var surface = selection2.selectAll(".surface").classed("tr", true);
72827       if (firstTime) {
72828         _initialized3 = true;
72829         surface.call(breathe);
72830       }
72831       if (_fromWayID && !vgraph.hasEntity(_fromWayID)) {
72832         _fromWayID = null;
72833         _oldTurns = null;
72834       }
72835       surface.call(utilSetDimensions, d2).call(drawVertices, vgraph, _intersection.vertices, filter2, extent, z2).call(drawLines, vgraph, _intersection.ways, filter2).call(drawTurns, vgraph, _intersection.turns(_fromWayID, _maxViaWay));
72836       surface.on("click.restrictions", click).on("mouseover.restrictions", mouseover);
72837       surface.selectAll(".selected").classed("selected", false);
72838       surface.selectAll(".related").classed("related", false);
72839       var way;
72840       if (_fromWayID) {
72841         way = vgraph.entity(_fromWayID);
72842         surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
72843       }
72844       document.addEventListener("resizeWindow", function() {
72845         utilSetDimensions(_container, null);
72846         redraw(1);
72847       }, false);
72848       updateHints(null);
72849       function click(d3_event) {
72850         surface.call(breathe.off).call(breathe);
72851         var datum2 = d3_event.target.__data__;
72852         var entity = datum2 && datum2.properties && datum2.properties.entity;
72853         if (entity) {
72854           datum2 = entity;
72855         }
72856         if (datum2 instanceof osmWay && (datum2.__from || datum2.__via)) {
72857           _fromWayID = datum2.id;
72858           _oldTurns = null;
72859           redraw();
72860         } else if (datum2 instanceof osmTurn) {
72861           var actions, extraActions, turns, i4;
72862           var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
72863           if (datum2.restrictionID && !datum2.direct) {
72864             return;
72865           } else if (datum2.restrictionID && !datum2.only) {
72866             var seen = {};
72867             var datumOnly = JSON.parse(JSON.stringify(datum2));
72868             datumOnly.only = true;
72869             restrictionType = restrictionType.replace(/^no/, "only");
72870             turns = _intersection.turns(_fromWayID, 2);
72871             extraActions = [];
72872             _oldTurns = [];
72873             for (i4 = 0; i4 < turns.length; i4++) {
72874               var turn = turns[i4];
72875               if (seen[turn.restrictionID]) continue;
72876               if (turn.direct && turn.path[1] === datum2.path[1]) {
72877                 seen[turns[i4].restrictionID] = true;
72878                 turn.restrictionType = osmInferRestriction(vgraph, turn, projection2);
72879                 _oldTurns.push(turn);
72880                 extraActions.push(actionUnrestrictTurn(turn));
72881               }
72882             }
72883             actions = _intersection.actions.concat(extraActions, [
72884               actionRestrictTurn(datumOnly, restrictionType),
72885               _t("operations.restriction.annotation.create")
72886             ]);
72887           } else if (datum2.restrictionID) {
72888             turns = _oldTurns || [];
72889             extraActions = [];
72890             for (i4 = 0; i4 < turns.length; i4++) {
72891               if (turns[i4].key !== datum2.key) {
72892                 extraActions.push(actionRestrictTurn(turns[i4], turns[i4].restrictionType));
72893               }
72894             }
72895             _oldTurns = null;
72896             actions = _intersection.actions.concat(extraActions, [
72897               actionUnrestrictTurn(datum2),
72898               _t("operations.restriction.annotation.delete")
72899             ]);
72900           } else {
72901             actions = _intersection.actions.concat([
72902               actionRestrictTurn(datum2, restrictionType),
72903               _t("operations.restriction.annotation.create")
72904             ]);
72905           }
72906           context.perform.apply(context, actions);
72907           var s2 = surface.selectAll("." + datum2.key);
72908           datum2 = s2.empty() ? null : s2.datum();
72909           updateHints(datum2);
72910         } else {
72911           _fromWayID = null;
72912           _oldTurns = null;
72913           redraw();
72914         }
72915       }
72916       function mouseover(d3_event) {
72917         var datum2 = d3_event.target.__data__;
72918         updateHints(datum2);
72919       }
72920       _lastXPos = _lastXPos || sdims[0];
72921       function redraw(minChange) {
72922         var xPos = -1;
72923         if (minChange) {
72924           xPos = utilGetDimensions(context.container().select(".sidebar"))[0];
72925         }
72926         if (!minChange || minChange && Math.abs(xPos - _lastXPos) >= minChange) {
72927           if (context.hasEntity(_vertexID)) {
72928             _lastXPos = xPos;
72929             _container.call(renderViewer);
72930           }
72931         }
72932       }
72933       function highlightPathsFrom(wayID) {
72934         surface.selectAll(".related").classed("related", false).classed("allow", false).classed("restrict", false).classed("only", false);
72935         surface.selectAll("." + wayID).classed("related", true);
72936         if (wayID) {
72937           var turns = _intersection.turns(wayID, _maxViaWay);
72938           for (var i4 = 0; i4 < turns.length; i4++) {
72939             var turn = turns[i4];
72940             var ids = [turn.to.way];
72941             var klass = turn.no ? "restrict" : turn.only ? "only" : "allow";
72942             if (turn.only || turns.length === 1) {
72943               if (turn.via.ways) {
72944                 ids = ids.concat(turn.via.ways);
72945               }
72946             } else if (turn.to.way === wayID) {
72947               continue;
72948             }
72949             surface.selectAll(utilEntitySelector(ids)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
72950           }
72951         }
72952       }
72953       function updateHints(datum2) {
72954         var help = _container.selectAll(".restriction-help").html("");
72955         var placeholders = {};
72956         ["from", "via", "to"].forEach(function(k2) {
72957           placeholders[k2] = { html: '<span class="qualifier">' + _t("restriction.help." + k2) + "</span>" };
72958         });
72959         var entity = datum2 && datum2.properties && datum2.properties.entity;
72960         if (entity) {
72961           datum2 = entity;
72962         }
72963         if (_fromWayID) {
72964           way = vgraph.entity(_fromWayID);
72965           surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
72966         }
72967         if (datum2 instanceof osmWay && datum2.__from) {
72968           way = datum2;
72969           highlightPathsFrom(_fromWayID ? null : way.id);
72970           surface.selectAll("." + way.id).classed("related", true);
72971           var clickSelect = !_fromWayID || _fromWayID !== way.id;
72972           help.append("div").html(_t.html("restriction.help." + (clickSelect ? "select_from_name" : "from_name"), {
72973             from: placeholders.from,
72974             fromName: displayName(way.id, vgraph)
72975           }));
72976         } else if (datum2 instanceof osmTurn) {
72977           var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
72978           var turnType = restrictionType.replace(/^(only|no)\_/, "");
72979           var indirect = datum2.direct === false ? _t.html("restriction.help.indirect") : "";
72980           var klass, turnText, nextText;
72981           if (datum2.no) {
72982             klass = "restrict";
72983             turnText = _t.html("restriction.help.turn.no_" + turnType, { indirect: { html: indirect } });
72984             nextText = _t.html("restriction.help.turn.only_" + turnType, { indirect: "" });
72985           } else if (datum2.only) {
72986             klass = "only";
72987             turnText = _t.html("restriction.help.turn.only_" + turnType, { indirect: { html: indirect } });
72988             nextText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: "" });
72989           } else {
72990             klass = "allow";
72991             turnText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: { html: indirect } });
72992             nextText = _t.html("restriction.help.turn.no_" + turnType, { indirect: "" });
72993           }
72994           help.append("div").attr("class", "qualifier " + klass).html(turnText);
72995           help.append("div").html(_t.html("restriction.help.from_name_to_name", {
72996             from: placeholders.from,
72997             fromName: displayName(datum2.from.way, vgraph),
72998             to: placeholders.to,
72999             toName: displayName(datum2.to.way, vgraph)
73000           }));
73001           if (datum2.via.ways && datum2.via.ways.length) {
73002             var names = [];
73003             for (var i4 = 0; i4 < datum2.via.ways.length; i4++) {
73004               var prev = names[names.length - 1];
73005               var curr = displayName(datum2.via.ways[i4], vgraph);
73006               if (!prev || curr !== prev) {
73007                 names.push(curr);
73008               }
73009             }
73010             help.append("div").html(_t.html("restriction.help.via_names", {
73011               via: placeholders.via,
73012               viaNames: names.join(", ")
73013             }));
73014           }
73015           if (!indirect) {
73016             help.append("div").html(_t.html("restriction.help.toggle", { turn: { html: nextText.trim() } }));
73017           }
73018           highlightPathsFrom(null);
73019           var alongIDs = datum2.path.slice();
73020           surface.selectAll(utilEntitySelector(alongIDs)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
73021         } else {
73022           highlightPathsFrom(null);
73023           if (_fromWayID) {
73024             help.append("div").html(_t.html("restriction.help.from_name", {
73025               from: placeholders.from,
73026               fromName: displayName(_fromWayID, vgraph)
73027             }));
73028           } else {
73029             help.append("div").html(_t.html("restriction.help.select_from", {
73030               from: placeholders.from
73031             }));
73032           }
73033         }
73034       }
73035     }
73036     function displayMaxDistance(maxDist) {
73037       return (selection2) => {
73038         var isImperial = !_mainLocalizer.usesMetric();
73039         var opts;
73040         if (isImperial) {
73041           var distToFeet = {
73042             // imprecise conversion for prettier display
73043             20: 70,
73044             25: 85,
73045             30: 100,
73046             35: 115,
73047             40: 130,
73048             45: 145,
73049             50: 160
73050           }[maxDist];
73051           opts = { distance: _t("units.feet", { quantity: distToFeet }) };
73052         } else {
73053           opts = { distance: _t("units.meters", { quantity: maxDist }) };
73054         }
73055         return selection2.html("").call(_t.append("restriction.controls.distance_up_to", opts));
73056       };
73057     }
73058     function displayMaxVia(maxVia) {
73059       return (selection2) => {
73060         selection2 = selection2.html("");
73061         return maxVia === 0 ? selection2.call(_t.append("restriction.controls.via_node_only")) : maxVia === 1 ? selection2.call(_t.append("restriction.controls.via_up_to_one")) : selection2.call(_t.append("restriction.controls.via_up_to_two"));
73062       };
73063     }
73064     function displayName(entityID, graph) {
73065       var entity = graph.entity(entityID);
73066       var name = utilDisplayName(entity) || "";
73067       var matched = _mainPresetIndex.match(entity, graph);
73068       var type2 = matched && matched.name() || utilDisplayType(entity.id);
73069       return name || type2;
73070     }
73071     restrictions.entityIDs = function(val) {
73072       _intersection = null;
73073       _fromWayID = null;
73074       _oldTurns = null;
73075       _vertexID = val[0];
73076     };
73077     restrictions.tags = function() {
73078     };
73079     restrictions.focus = function() {
73080     };
73081     restrictions.off = function(selection2) {
73082       if (!_initialized3) return;
73083       selection2.selectAll(".surface").call(breathe.off).on("click.restrictions", null).on("mouseover.restrictions", null);
73084       select_default2(window).on("resize.restrictions", null);
73085     };
73086     return utilRebind(restrictions, dispatch14, "on");
73087   }
73088   uiFieldRestrictions.supportsMultiselection = false;
73089
73090   // modules/ui/fields/textarea.js
73091   function uiFieldTextarea(field, context) {
73092     var dispatch14 = dispatch_default("change");
73093     var input = select_default2(null);
73094     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue()).silent(field.usage === "changeset" && field.key === "comment");
73095     var _tags;
73096     function textarea(selection2) {
73097       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
73098       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).style("position", "relative").merge(wrap2);
73099       input = wrap2.selectAll("textarea").data([0]);
73100       input = input.enter().append("textarea").attr("id", field.domId).call(utilNoAuto).on("input", change(true)).on("blur", change()).on("change", change()).merge(input);
73101       wrap2.call(_lengthIndicator);
73102       function change(onInput) {
73103         return function() {
73104           var val = utilGetSetValue(input);
73105           if (!onInput) val = context.cleanTagValue(val);
73106           if (!val && Array.isArray(_tags[field.key])) return;
73107           var t2 = {};
73108           t2[field.key] = val || void 0;
73109           dispatch14.call("change", this, t2, onInput);
73110         };
73111       }
73112     }
73113     textarea.tags = function(tags) {
73114       _tags = tags;
73115       var isMixed = Array.isArray(tags[field.key]);
73116       utilGetSetValue(input, !isMixed && tags[field.key] ? tags[field.key] : "").attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder() || _t("inspector.unknown")).classed("mixed", isMixed);
73117       if (!isMixed) {
73118         _lengthIndicator.update(tags[field.key]);
73119       }
73120     };
73121     textarea.focus = function() {
73122       input.node().focus();
73123     };
73124     return utilRebind(textarea, dispatch14, "on");
73125   }
73126
73127   // modules/ui/fields/wikidata.js
73128   function uiFieldWikidata(field, context) {
73129     var wikidata = services.wikidata;
73130     var dispatch14 = dispatch_default("change");
73131     var _selection = select_default2(null);
73132     var _searchInput = select_default2(null);
73133     var _qid = null;
73134     var _wikidataEntity = null;
73135     var _wikiURL = "";
73136     var _entityIDs = [];
73137     var _wikipediaKey = field.keys && field.keys.find(function(key) {
73138       return key.includes("wikipedia");
73139     });
73140     var _hintKey = field.key === "wikidata" ? "name" : field.key.split(":")[0];
73141     var combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(true).minItems(1);
73142     function wiki(selection2) {
73143       _selection = selection2;
73144       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
73145       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
73146       var list2 = wrap2.selectAll("ul").data([0]);
73147       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
73148       var searchRow = list2.selectAll("li.wikidata-search").data([0]);
73149       var searchRowEnter = searchRow.enter().append("li").attr("class", "wikidata-search");
73150       searchRowEnter.append("input").attr("type", "text").attr("id", field.domId).style("flex", "1").call(utilNoAuto).on("focus", function() {
73151         var node = select_default2(this).node();
73152         node.setSelectionRange(0, node.value.length);
73153       }).on("blur", function() {
73154         setLabelForEntity();
73155       }).call(combobox.fetcher(fetchWikidataItems));
73156       combobox.on("accept", function(d2) {
73157         if (d2) {
73158           _qid = d2.id;
73159           change();
73160         }
73161       }).on("cancel", function() {
73162         setLabelForEntity();
73163       });
73164       searchRowEnter.append("button").attr("class", "form-field-button wiki-link").attr("title", _t("icons.view_on", { domain: "wikidata.org" })).call(svgIcon("#iD-icon-out-link")).on("click", function(d3_event) {
73165         d3_event.preventDefault();
73166         if (_wikiURL) window.open(_wikiURL, "_blank");
73167       });
73168       searchRow = searchRow.merge(searchRowEnter);
73169       _searchInput = searchRow.select("input");
73170       var wikidataProperties = ["description", "identifier"];
73171       var items = list2.selectAll("li.labeled-input").data(wikidataProperties);
73172       var enter = items.enter().append("li").attr("class", function(d2) {
73173         return "labeled-input preset-wikidata-" + d2;
73174       });
73175       enter.append("div").attr("class", "label").html(function(d2) {
73176         return _t.html("wikidata." + d2);
73177       });
73178       enter.append("input").attr("type", "text").call(utilNoAuto).classed("disabled", "true").attr("readonly", "true");
73179       enter.append("button").attr("class", "form-field-button").attr("title", _t("icons.copy")).call(svgIcon("#iD-operation-copy")).on("click", function(d3_event) {
73180         d3_event.preventDefault();
73181         select_default2(this.parentNode).select("input").node().select();
73182         document.execCommand("copy");
73183       });
73184     }
73185     function fetchWikidataItems(q2, callback) {
73186       if (!q2 && _hintKey) {
73187         for (var i3 in _entityIDs) {
73188           var entity = context.hasEntity(_entityIDs[i3]);
73189           if (entity.tags[_hintKey]) {
73190             q2 = entity.tags[_hintKey];
73191             break;
73192           }
73193         }
73194       }
73195       wikidata.itemsForSearchQuery(q2, function(err, data) {
73196         if (err) {
73197           if (err !== "No query") console.error(err);
73198           return;
73199         }
73200         var result = data.map(function(item) {
73201           return {
73202             id: item.id,
73203             value: item.display.label.value + " (" + item.id + ")",
73204             display: (selection2) => selection2.append("span").attr("class", "localized-text").attr("lang", item.display.label.language).text(item.display.label.value),
73205             title: item.display.description && item.display.description.value,
73206             terms: item.aliases
73207           };
73208         });
73209         if (callback) callback(result);
73210       });
73211     }
73212     function change() {
73213       var syncTags = {};
73214       syncTags[field.key] = _qid;
73215       dispatch14.call("change", this, syncTags);
73216       var initGraph = context.graph();
73217       var initEntityIDs = _entityIDs;
73218       wikidata.entityByQID(_qid, function(err, entity) {
73219         if (err) return;
73220         if (context.graph() !== initGraph) return;
73221         if (!entity.sitelinks) return;
73222         var langs = wikidata.languagesToQuery();
73223         ["labels", "descriptions"].forEach(function(key) {
73224           if (!entity[key]) return;
73225           var valueLangs = Object.keys(entity[key]);
73226           if (valueLangs.length === 0) return;
73227           var valueLang = valueLangs[0];
73228           if (langs.indexOf(valueLang) === -1) {
73229             langs.push(valueLang);
73230           }
73231         });
73232         var newWikipediaValue;
73233         if (_wikipediaKey) {
73234           var foundPreferred;
73235           for (var i3 in langs) {
73236             var lang = langs[i3];
73237             var siteID = lang.replace("-", "_") + "wiki";
73238             if (entity.sitelinks[siteID]) {
73239               foundPreferred = true;
73240               newWikipediaValue = lang + ":" + entity.sitelinks[siteID].title;
73241               break;
73242             }
73243           }
73244           if (!foundPreferred) {
73245             var wikiSiteKeys = Object.keys(entity.sitelinks).filter(function(site) {
73246               return site.endsWith("wiki");
73247             });
73248             if (wikiSiteKeys.length === 0) {
73249               newWikipediaValue = null;
73250             } else {
73251               var wikiLang = wikiSiteKeys[0].slice(0, -4).replace("_", "-");
73252               var wikiTitle = entity.sitelinks[wikiSiteKeys[0]].title;
73253               newWikipediaValue = wikiLang + ":" + wikiTitle;
73254             }
73255           }
73256         }
73257         if (newWikipediaValue) {
73258           newWikipediaValue = context.cleanTagValue(newWikipediaValue);
73259         }
73260         if (typeof newWikipediaValue === "undefined") return;
73261         var actions = initEntityIDs.map(function(entityID) {
73262           var entity2 = context.hasEntity(entityID);
73263           if (!entity2) return null;
73264           var currTags = Object.assign({}, entity2.tags);
73265           if (newWikipediaValue === null) {
73266             if (!currTags[_wikipediaKey]) return null;
73267             delete currTags[_wikipediaKey];
73268           } else {
73269             currTags[_wikipediaKey] = newWikipediaValue;
73270           }
73271           return actionChangeTags(entityID, currTags);
73272         }).filter(Boolean);
73273         if (!actions.length) return;
73274         context.overwrite(
73275           function actionUpdateWikipediaTags(graph) {
73276             actions.forEach(function(action) {
73277               graph = action(graph);
73278             });
73279             return graph;
73280           },
73281           context.history().undoAnnotation()
73282         );
73283       });
73284     }
73285     function setLabelForEntity() {
73286       var label = {
73287         value: ""
73288       };
73289       if (_wikidataEntity) {
73290         label = entityPropertyForDisplay(_wikidataEntity, "labels");
73291         if (label.value.length === 0) {
73292           label.value = _wikidataEntity.id.toString();
73293         }
73294       }
73295       utilGetSetValue(_searchInput, label.value).attr("lang", label.language);
73296     }
73297     wiki.tags = function(tags) {
73298       var isMixed = Array.isArray(tags[field.key]);
73299       _searchInput.attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : "").classed("mixed", isMixed);
73300       _qid = typeof tags[field.key] === "string" && tags[field.key] || "";
73301       if (!/^Q[0-9]*$/.test(_qid)) {
73302         unrecognized();
73303         return;
73304       }
73305       _wikiURL = "https://wikidata.org/wiki/" + _qid;
73306       wikidata.entityByQID(_qid, function(err, entity) {
73307         if (err) {
73308           unrecognized();
73309           return;
73310         }
73311         _wikidataEntity = entity;
73312         setLabelForEntity();
73313         var description = entityPropertyForDisplay(entity, "descriptions");
73314         _selection.select("button.wiki-link").classed("disabled", false);
73315         _selection.select(".preset-wikidata-description").style("display", function() {
73316           return description.value.length > 0 ? "flex" : "none";
73317         }).select("input").attr("value", description.value).attr("lang", description.language);
73318         _selection.select(".preset-wikidata-identifier").style("display", function() {
73319           return entity.id ? "flex" : "none";
73320         }).select("input").attr("value", entity.id);
73321       });
73322       function unrecognized() {
73323         _wikidataEntity = null;
73324         setLabelForEntity();
73325         _selection.select(".preset-wikidata-description").style("display", "none");
73326         _selection.select(".preset-wikidata-identifier").style("display", "none");
73327         _selection.select("button.wiki-link").classed("disabled", true);
73328         if (_qid && _qid !== "") {
73329           _wikiURL = "https://wikidata.org/wiki/Special:Search?search=" + _qid;
73330         } else {
73331           _wikiURL = "";
73332         }
73333       }
73334     };
73335     function entityPropertyForDisplay(wikidataEntity, propKey) {
73336       var blankResponse = { value: "" };
73337       if (!wikidataEntity[propKey]) return blankResponse;
73338       var propObj = wikidataEntity[propKey];
73339       var langKeys = Object.keys(propObj);
73340       if (langKeys.length === 0) return blankResponse;
73341       var langs = wikidata.languagesToQuery();
73342       for (var i3 in langs) {
73343         var lang = langs[i3];
73344         var valueObj = propObj[lang];
73345         if (valueObj && valueObj.value && valueObj.value.length > 0) return valueObj;
73346       }
73347       return propObj[langKeys[0]];
73348     }
73349     wiki.entityIDs = function(val) {
73350       if (!arguments.length) return _entityIDs;
73351       _entityIDs = val;
73352       return wiki;
73353     };
73354     wiki.focus = function() {
73355       _searchInput.node().focus();
73356     };
73357     return utilRebind(wiki, dispatch14, "on");
73358   }
73359
73360   // modules/ui/fields/wikipedia.js
73361   function uiFieldWikipedia(field, context) {
73362     const scheme = "https://";
73363     const domain = "wikipedia.org";
73364     const dispatch14 = dispatch_default("change");
73365     const wikipedia = services.wikipedia;
73366     const wikidata = services.wikidata;
73367     let _langInput = select_default2(null);
73368     let _titleInput = select_default2(null);
73369     let _wikiURL = "";
73370     let _entityIDs;
73371     let _tags;
73372     let _dataWikipedia = [];
73373     _mainFileFetcher.get("wmf_sitematrix").then((d2) => {
73374       _dataWikipedia = d2;
73375       if (_tags) updateForTags(_tags);
73376     }).catch(() => {
73377     });
73378     const langCombo = uiCombobox(context, "wikipedia-lang").fetcher((value, callback) => {
73379       const v2 = value.toLowerCase();
73380       callback(
73381         _dataWikipedia.filter((d2) => {
73382           return d2[0].toLowerCase().indexOf(v2) >= 0 || d2[1].toLowerCase().indexOf(v2) >= 0 || d2[2].toLowerCase().indexOf(v2) >= 0;
73383         }).map((d2) => ({ value: d2[1] }))
73384       );
73385     });
73386     const titleCombo = uiCombobox(context, "wikipedia-title").fetcher((value, callback) => {
73387       if (!value) {
73388         value = "";
73389         for (let i3 in _entityIDs) {
73390           let entity = context.hasEntity(_entityIDs[i3]);
73391           if (entity.tags.name) {
73392             value = entity.tags.name;
73393             break;
73394           }
73395         }
73396       }
73397       const searchfn = value.length > 7 ? wikipedia.search : wikipedia.suggestions;
73398       searchfn(language()[2], value, (query, data) => {
73399         callback(data.map((d2) => ({ value: d2 })));
73400       });
73401     });
73402     function wiki(selection2) {
73403       let wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
73404       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-".concat(field.type)).merge(wrap2);
73405       let langContainer = wrap2.selectAll(".wiki-lang-container").data([0]);
73406       langContainer = langContainer.enter().append("div").attr("class", "wiki-lang-container").merge(langContainer);
73407       _langInput = langContainer.selectAll("input.wiki-lang").data([0]);
73408       _langInput = _langInput.enter().append("input").attr("type", "text").attr("class", "wiki-lang").attr("placeholder", _t("translate.localized_translation_language")).call(utilNoAuto).call(langCombo).merge(_langInput);
73409       _langInput.on("blur", changeLang).on("change", changeLang);
73410       let titleContainer = wrap2.selectAll(".wiki-title-container").data([0]);
73411       titleContainer = titleContainer.enter().append("div").attr("class", "wiki-title-container").merge(titleContainer);
73412       _titleInput = titleContainer.selectAll("input.wiki-title").data([0]);
73413       _titleInput = _titleInput.enter().append("input").attr("type", "text").attr("class", "wiki-title").attr("id", field.domId).call(utilNoAuto).call(titleCombo).merge(_titleInput);
73414       _titleInput.on("blur", function() {
73415         change(true);
73416       }).on("change", function() {
73417         change(false);
73418       });
73419       let link3 = titleContainer.selectAll(".wiki-link").data([0]);
73420       link3 = link3.enter().append("button").attr("class", "form-field-button wiki-link").attr("title", _t("icons.view_on", { domain })).call(svgIcon("#iD-icon-out-link")).merge(link3);
73421       link3.on("click", (d3_event) => {
73422         d3_event.preventDefault();
73423         if (_wikiURL) window.open(_wikiURL, "_blank");
73424       });
73425     }
73426     function defaultLanguageInfo(skipEnglishFallback) {
73427       const langCode = _mainLocalizer.languageCode().toLowerCase();
73428       for (let i3 in _dataWikipedia) {
73429         let d2 = _dataWikipedia[i3];
73430         if (d2[2] === langCode) return d2;
73431       }
73432       return skipEnglishFallback ? ["", "", ""] : ["English", "English", "en"];
73433     }
73434     function language(skipEnglishFallback) {
73435       const value = utilGetSetValue(_langInput).toLowerCase();
73436       for (let i3 in _dataWikipedia) {
73437         let d2 = _dataWikipedia[i3];
73438         if (d2[0].toLowerCase() === value || d2[1].toLowerCase() === value || d2[2] === value) return d2;
73439       }
73440       return defaultLanguageInfo(skipEnglishFallback);
73441     }
73442     function changeLang() {
73443       utilGetSetValue(_langInput, language()[1]);
73444       change(true);
73445     }
73446     function change(skipWikidata) {
73447       let value = utilGetSetValue(_titleInput);
73448       const m2 = value.match(/https?:\/\/([-a-z]+)\.wikipedia\.org\/(?:wiki|\1-[-a-z]+)\/([^#]+)(?:#(.+))?/);
73449       const langInfo = m2 && _dataWikipedia.find((d2) => m2[1] === d2[2]);
73450       let syncTags = {};
73451       if (langInfo) {
73452         const nativeLangName = langInfo[1];
73453         value = decodeURIComponent(m2[2]).replace(/_/g, " ");
73454         if (m2[3]) {
73455           let anchor;
73456           anchor = decodeURIComponent(m2[3]);
73457           value += "#" + anchor.replace(/_/g, " ");
73458         }
73459         value = value.slice(0, 1).toUpperCase() + value.slice(1);
73460         utilGetSetValue(_langInput, nativeLangName).attr("lang", langInfo[2]);
73461         utilGetSetValue(_titleInput, value);
73462       }
73463       if (value) {
73464         syncTags.wikipedia = context.cleanTagValue(language()[2] + ":" + value);
73465       } else {
73466         syncTags.wikipedia = void 0;
73467       }
73468       dispatch14.call("change", this, syncTags);
73469       if (skipWikidata || !value || !language()[2]) return;
73470       const initGraph = context.graph();
73471       const initEntityIDs = _entityIDs;
73472       wikidata.itemsByTitle(language()[2], value, (err, data) => {
73473         if (err || !data || !Object.keys(data).length) return;
73474         if (context.graph() !== initGraph) return;
73475         const qids = Object.keys(data);
73476         const value2 = qids && qids.find((id2) => id2.match(/^Q\d+$/));
73477         let actions = initEntityIDs.map((entityID) => {
73478           let entity = context.entity(entityID).tags;
73479           let currTags = Object.assign({}, entity);
73480           if (currTags.wikidata !== value2) {
73481             currTags.wikidata = value2;
73482             return actionChangeTags(entityID, currTags);
73483           }
73484           return null;
73485         }).filter(Boolean);
73486         if (!actions.length) return;
73487         context.overwrite(
73488           function actionUpdateWikidataTags(graph) {
73489             actions.forEach(function(action) {
73490               graph = action(graph);
73491             });
73492             return graph;
73493           },
73494           context.history().undoAnnotation()
73495         );
73496       });
73497     }
73498     wiki.tags = (tags) => {
73499       _tags = tags;
73500       updateForTags(tags);
73501     };
73502     function updateForTags(tags) {
73503       const value = typeof tags[field.key] === "string" ? tags[field.key] : "";
73504       const m2 = value.match(/([^:]+):([^#]+)(?:#(.+))?/);
73505       const tagLang = m2 && m2[1];
73506       const tagArticleTitle = m2 && m2[2];
73507       let anchor = m2 && m2[3];
73508       const tagLangInfo = tagLang && _dataWikipedia.find((d2) => tagLang === d2[2]);
73509       if (tagLangInfo) {
73510         const nativeLangName = tagLangInfo[1];
73511         utilGetSetValue(_langInput, nativeLangName);
73512         _titleInput.attr("lang", tagLangInfo[2]);
73513         utilGetSetValue(_titleInput, tagArticleTitle + (anchor ? "#" + anchor : ""));
73514         _wikiURL = "".concat(scheme).concat(tagLang, ".").concat(domain, "/wiki/").concat(wiki.encodePath(tagArticleTitle, anchor));
73515       } else {
73516         utilGetSetValue(_titleInput, value);
73517         if (value && value !== "") {
73518           utilGetSetValue(_langInput, "");
73519           const defaultLangInfo = defaultLanguageInfo();
73520           _wikiURL = "".concat(scheme).concat(defaultLangInfo[2], ".").concat(domain, "/w/index.php?fulltext=1&search=").concat(value);
73521         } else {
73522           const shownOrDefaultLangInfo = language(
73523             true
73524             /* skipEnglishFallback */
73525           );
73526           utilGetSetValue(_langInput, shownOrDefaultLangInfo[1]);
73527           _wikiURL = "";
73528         }
73529       }
73530     }
73531     wiki.encodePath = (tagArticleTitle, anchor) => {
73532       const underscoredTitle = tagArticleTitle.replace(/ /g, "_");
73533       const uriEncodedUnderscoredTitle = encodeURIComponent(underscoredTitle);
73534       const uriEncodedAnchorFragment = wiki.encodeURIAnchorFragment(anchor);
73535       return "".concat(uriEncodedUnderscoredTitle).concat(uriEncodedAnchorFragment);
73536     };
73537     wiki.encodeURIAnchorFragment = (anchor) => {
73538       if (!anchor) return "";
73539       const underscoredAnchor = anchor.replace(/ /g, "_");
73540       return "#" + encodeURIComponent(underscoredAnchor);
73541     };
73542     wiki.entityIDs = (val) => {
73543       if (!arguments.length) return _entityIDs;
73544       _entityIDs = val;
73545       return wiki;
73546     };
73547     wiki.focus = () => {
73548       _titleInput.node().focus();
73549     };
73550     return utilRebind(wiki, dispatch14, "on");
73551   }
73552   uiFieldWikipedia.supportsMultiselection = false;
73553
73554   // modules/ui/fields/index.js
73555   var uiFields = {
73556     access: uiFieldAccess,
73557     address: uiFieldAddress,
73558     check: uiFieldCheck,
73559     colour: uiFieldText,
73560     combo: uiFieldCombo,
73561     cycleway: uiFieldDirectionalCombo,
73562     date: uiFieldText,
73563     defaultCheck: uiFieldCheck,
73564     directionalCombo: uiFieldDirectionalCombo,
73565     email: uiFieldText,
73566     identifier: uiFieldText,
73567     lanes: uiFieldLanes,
73568     localized: uiFieldLocalized,
73569     roadheight: uiFieldRoadheight,
73570     roadspeed: uiFieldRoadspeed,
73571     manyCombo: uiFieldCombo,
73572     multiCombo: uiFieldCombo,
73573     networkCombo: uiFieldCombo,
73574     number: uiFieldText,
73575     onewayCheck: uiFieldCheck,
73576     radio: uiFieldRadio,
73577     restrictions: uiFieldRestrictions,
73578     semiCombo: uiFieldCombo,
73579     structureRadio: uiFieldRadio,
73580     tel: uiFieldText,
73581     text: uiFieldText,
73582     textarea: uiFieldTextarea,
73583     typeCombo: uiFieldCombo,
73584     url: uiFieldText,
73585     wikidata: uiFieldWikidata,
73586     wikipedia: uiFieldWikipedia
73587   };
73588
73589   // modules/ui/field.js
73590   function uiField(context, presetField2, entityIDs, options2) {
73591     options2 = Object.assign({
73592       show: true,
73593       wrap: true,
73594       remove: true,
73595       revert: true,
73596       info: true
73597     }, options2);
73598     var dispatch14 = dispatch_default("change", "revert");
73599     var field = Object.assign({}, presetField2);
73600     field.domId = utilUniqueDomId("form-field-" + field.safeid);
73601     var _show = options2.show;
73602     var _state = "";
73603     var _tags = {};
73604     var _entityExtent;
73605     if (entityIDs && entityIDs.length) {
73606       _entityExtent = entityIDs.reduce(function(extent, entityID) {
73607         var entity = context.graph().entity(entityID);
73608         return extent.extend(entity.extent(context.graph()));
73609       }, geoExtent());
73610     }
73611     var _locked = false;
73612     var _lockedTip = uiTooltip().title(() => _t.append("inspector.lock.suggestion", { label: field.title })).placement("bottom");
73613     if (_show && !field.impl) {
73614       createField();
73615     }
73616     function createField() {
73617       field.impl = uiFields[field.type](field, context).on("change", function(t2, onInput) {
73618         dispatch14.call("change", field, t2, onInput);
73619       });
73620       if (entityIDs) {
73621         field.entityIDs = entityIDs;
73622         if (field.impl.entityIDs) {
73623           field.impl.entityIDs(entityIDs);
73624         }
73625       }
73626     }
73627     function allKeys() {
73628       let keys2 = field.keys || [field.key];
73629       if (field.type === "directionalCombo" && field.key) {
73630         const baseKey = field.key.replace(/:both$/, "");
73631         keys2 = keys2.concat(baseKey, "".concat(baseKey, ":both"));
73632       }
73633       return keys2;
73634     }
73635     function isModified() {
73636       if (!entityIDs || !entityIDs.length) return false;
73637       return entityIDs.some(function(entityID) {
73638         var original = context.graph().base().entities[entityID];
73639         var latest = context.graph().entity(entityID);
73640         return allKeys().some(function(key) {
73641           return original ? latest.tags[key] !== original.tags[key] : latest.tags[key];
73642         });
73643       });
73644     }
73645     function tagsContainFieldKey() {
73646       return allKeys().some(function(key) {
73647         if (field.type === "multiCombo") {
73648           for (var tagKey in _tags) {
73649             if (tagKey.indexOf(key) === 0) {
73650               return true;
73651             }
73652           }
73653           return false;
73654         }
73655         if (field.type === "localized") {
73656           for (let tagKey2 in _tags) {
73657             let match = tagKey2.match(LANGUAGE_SUFFIX_REGEX);
73658             if (match && match[1] === field.key && match[2]) {
73659               return true;
73660             }
73661           }
73662         }
73663         return _tags[key] !== void 0;
73664       });
73665     }
73666     function revert(d3_event, d2) {
73667       d3_event.stopPropagation();
73668       d3_event.preventDefault();
73669       if (!entityIDs || _locked) return;
73670       dispatch14.call("revert", d2, allKeys());
73671     }
73672     function remove2(d3_event, d2) {
73673       d3_event.stopPropagation();
73674       d3_event.preventDefault();
73675       if (_locked) return;
73676       var t2 = {};
73677       allKeys().forEach(function(key) {
73678         t2[key] = void 0;
73679       });
73680       dispatch14.call("change", d2, t2);
73681     }
73682     field.render = function(selection2) {
73683       var container = selection2.selectAll(".form-field").data([field]);
73684       var enter = container.enter().append("div").attr("class", function(d2) {
73685         return "form-field form-field-" + d2.safeid;
73686       }).classed("nowrap", !options2.wrap);
73687       if (options2.wrap) {
73688         var labelEnter = enter.append("label").attr("class", "field-label").attr("for", function(d2) {
73689           return d2.domId;
73690         });
73691         var textEnter = labelEnter.append("span").attr("class", "label-text");
73692         textEnter.append("span").attr("class", "label-textvalue").each(function(d2) {
73693           d2.label()(select_default2(this));
73694         });
73695         textEnter.append("span").attr("class", "label-textannotation");
73696         if (options2.remove) {
73697           labelEnter.append("button").attr("class", "remove-icon").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
73698         }
73699         if (options2.revert) {
73700           labelEnter.append("button").attr("class", "modified-icon").attr("title", _t("icons.undo")).call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-redo" : "#iD-icon-undo"));
73701         }
73702       }
73703       container = container.merge(enter);
73704       container.select(".field-label > .remove-icon").on("click", remove2);
73705       container.select(".field-label > .modified-icon").on("click", revert);
73706       container.each(function(d2) {
73707         var selection3 = select_default2(this);
73708         if (!d2.impl) {
73709           createField();
73710         }
73711         var reference, help;
73712         if (options2.wrap && field.type === "restrictions") {
73713           help = uiFieldHelp(context, "restrictions");
73714         }
73715         if (options2.wrap && options2.info) {
73716           var referenceKey = d2.key || "";
73717           if (d2.type === "multiCombo") {
73718             referenceKey = referenceKey.replace(/:$/, "");
73719           }
73720           var referenceOptions = d2.reference || {
73721             key: referenceKey,
73722             value: _tags[referenceKey]
73723           };
73724           reference = uiTagReference(referenceOptions, context);
73725           if (_state === "hover") {
73726             reference.showing(false);
73727           }
73728         }
73729         selection3.call(d2.impl);
73730         if (help) {
73731           selection3.call(help.body).select(".field-label").call(help.button);
73732         }
73733         if (reference) {
73734           selection3.call(reference.body).select(".field-label").call(reference.button);
73735         }
73736         d2.impl.tags(_tags);
73737       });
73738       container.classed("locked", _locked).classed("modified", isModified()).classed("present", tagsContainFieldKey());
73739       var annotation = container.selectAll(".field-label .label-textannotation");
73740       var icon2 = annotation.selectAll(".icon").data(_locked ? [0] : []);
73741       icon2.exit().remove();
73742       icon2.enter().append("svg").attr("class", "icon").append("use").attr("xlink:href", "#fas-lock");
73743       container.call(_locked ? _lockedTip : _lockedTip.destroy);
73744     };
73745     field.state = function(val) {
73746       if (!arguments.length) return _state;
73747       _state = val;
73748       return field;
73749     };
73750     field.tags = function(val) {
73751       if (!arguments.length) return _tags;
73752       _tags = val;
73753       if (tagsContainFieldKey() && !_show) {
73754         _show = true;
73755         if (!field.impl) {
73756           createField();
73757         }
73758       }
73759       return field;
73760     };
73761     field.locked = function(val) {
73762       if (!arguments.length) return _locked;
73763       _locked = val;
73764       return field;
73765     };
73766     field.show = function() {
73767       _show = true;
73768       if (!field.impl) {
73769         createField();
73770       }
73771       if (field.default && field.key && _tags[field.key] !== field.default) {
73772         var t2 = {};
73773         t2[field.key] = field.default;
73774         dispatch14.call("change", this, t2);
73775       }
73776     };
73777     field.isShown = function() {
73778       return _show;
73779     };
73780     field.isAllowed = function() {
73781       if (entityIDs && entityIDs.length > 1 && uiFields[field.type].supportsMultiselection === false) return false;
73782       if (field.geometry && !entityIDs.every(function(entityID) {
73783         return field.matchGeometry(context.graph().geometry(entityID));
73784       })) return false;
73785       if (entityIDs && _entityExtent && field.locationSetID) {
73786         var validHere = _sharedLocationManager.locationSetsAt(_entityExtent.center());
73787         if (!validHere[field.locationSetID]) return false;
73788       }
73789       var prerequisiteTag = field.prerequisiteTag;
73790       if (entityIDs && !tagsContainFieldKey() && // ignore tagging prerequisites if a value is already present
73791       prerequisiteTag) {
73792         if (!entityIDs.every(function(entityID) {
73793           var entity = context.graph().entity(entityID);
73794           if (prerequisiteTag.key) {
73795             var value = entity.tags[prerequisiteTag.key];
73796             if (!value) return false;
73797             if (prerequisiteTag.valueNot) {
73798               return prerequisiteTag.valueNot !== value;
73799             }
73800             if (prerequisiteTag.value) {
73801               return prerequisiteTag.value === value;
73802             }
73803           } else if (prerequisiteTag.keyNot) {
73804             if (entity.tags[prerequisiteTag.keyNot]) return false;
73805           }
73806           return true;
73807         })) return false;
73808       }
73809       return true;
73810     };
73811     field.focus = function() {
73812       if (field.impl) {
73813         field.impl.focus();
73814       }
73815     };
73816     return utilRebind(field, dispatch14, "on");
73817   }
73818
73819   // modules/ui/changeset_editor.js
73820   function uiChangesetEditor(context) {
73821     var dispatch14 = dispatch_default("change");
73822     var formFields = uiFormFields(context);
73823     var commentCombo = uiCombobox(context, "comment").caseSensitive(true);
73824     var _fieldsArr;
73825     var _tags;
73826     var _changesetID;
73827     function changesetEditor(selection2) {
73828       render(selection2);
73829     }
73830     function render(selection2) {
73831       var initial = false;
73832       if (!_fieldsArr) {
73833         initial = true;
73834         var presets = _mainPresetIndex;
73835         _fieldsArr = [
73836           uiField(context, presets.field("comment"), null, { show: true, revert: false }),
73837           uiField(context, presets.field("source"), null, { show: true, revert: false }),
73838           uiField(context, presets.field("hashtags"), null, { show: false, revert: false })
73839         ];
73840         _fieldsArr.forEach(function(field) {
73841           field.on("change", function(t2, onInput) {
73842             dispatch14.call("change", field, void 0, t2, onInput);
73843           });
73844         });
73845       }
73846       _fieldsArr.forEach(function(field) {
73847         field.tags(_tags);
73848       });
73849       selection2.call(formFields.fieldsArr(_fieldsArr));
73850       if (initial) {
73851         var commentField = selection2.select(".form-field-comment textarea");
73852         var commentNode = commentField.node();
73853         if (commentNode) {
73854           commentNode.focus();
73855           commentNode.select();
73856         }
73857         utilTriggerEvent(commentField, "blur");
73858         var osm = context.connection();
73859         if (osm) {
73860           osm.userChangesets(function(err, changesets) {
73861             if (err) return;
73862             var comments = changesets.map(function(changeset) {
73863               var comment = changeset.tags.comment;
73864               return comment ? { title: comment, value: comment } : null;
73865             }).filter(Boolean);
73866             commentField.call(
73867               commentCombo.data(utilArrayUniqBy(comments, "title"))
73868             );
73869           });
73870         }
73871       }
73872       const warnings = [];
73873       if (_tags.comment.match(/google/i)) {
73874         warnings.push({
73875           id: 'contains "google"',
73876           msg: _t.append("commit.google_warning"),
73877           link: _t("commit.google_warning_link")
73878         });
73879       }
73880       const maxChars = context.maxCharsForTagValue();
73881       const strLen = utilUnicodeCharsCount(utilCleanOsmString(_tags.comment, Number.POSITIVE_INFINITY));
73882       if (strLen > maxChars || false) {
73883         warnings.push({
73884           id: "message too long",
73885           msg: _t.append("commit.changeset_comment_length_warning", { maxChars })
73886         });
73887       }
73888       var commentWarning = selection2.select(".form-field-comment").selectAll(".comment-warning").data(warnings, (d2) => d2.id);
73889       commentWarning.exit().transition().duration(200).style("opacity", 0).remove();
73890       var commentEnter = commentWarning.enter().insert("div", ".comment-warning").attr("class", "comment-warning field-warning").style("opacity", 0);
73891       commentEnter.call(svgIcon("#iD-icon-alert", "inline")).append("span");
73892       commentEnter.transition().duration(200).style("opacity", 1);
73893       commentWarning.merge(commentEnter).selectAll("div > span").text("").each(function(d2) {
73894         let selection3 = select_default2(this);
73895         if (d2.link) {
73896           selection3 = selection3.append("a").attr("target", "_blank").attr("href", d2.link);
73897         }
73898         selection3.call(d2.msg);
73899       });
73900     }
73901     changesetEditor.tags = function(_2) {
73902       if (!arguments.length) return _tags;
73903       _tags = _2;
73904       return changesetEditor;
73905     };
73906     changesetEditor.changesetID = function(_2) {
73907       if (!arguments.length) return _changesetID;
73908       if (_changesetID === _2) return changesetEditor;
73909       _changesetID = _2;
73910       _fieldsArr = null;
73911       return changesetEditor;
73912     };
73913     return utilRebind(changesetEditor, dispatch14, "on");
73914   }
73915
73916   // modules/ui/sections/changes.js
73917   function uiSectionChanges(context) {
73918     var _discardTags = {};
73919     _mainFileFetcher.get("discarded").then(function(d2) {
73920       _discardTags = d2;
73921     }).catch(function() {
73922     });
73923     var section = uiSection("changes-list", context).label(function() {
73924       var history = context.history();
73925       var summary = history.difference().summary();
73926       return _t.append("inspector.title_count", { title: _t("commit.changes"), count: summary.length });
73927     }).disclosureContent(renderDisclosureContent);
73928     function renderDisclosureContent(selection2) {
73929       var history = context.history();
73930       var summary = history.difference().summary();
73931       var container = selection2.selectAll(".commit-section").data([0]);
73932       var containerEnter = container.enter().append("div").attr("class", "commit-section");
73933       containerEnter.append("ul").attr("class", "changeset-list");
73934       container = containerEnter.merge(container);
73935       var items = container.select("ul").selectAll("li").data(summary);
73936       var itemsEnter = items.enter().append("li").attr("class", "change-item");
73937       var buttons = itemsEnter.append("button").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click);
73938       buttons.each(function(d2) {
73939         select_default2(this).call(svgIcon("#iD-icon-" + d2.entity.geometry(d2.graph), "pre-text " + d2.changeType));
73940       });
73941       buttons.append("span").attr("class", "change-type").html(function(d2) {
73942         return _t.html("commit." + d2.changeType) + " ";
73943       });
73944       buttons.append("strong").attr("class", "entity-type").text(function(d2) {
73945         var matched = _mainPresetIndex.match(d2.entity, d2.graph);
73946         return matched && matched.name() || utilDisplayType(d2.entity.id);
73947       });
73948       buttons.append("span").attr("class", "entity-name").text(function(d2) {
73949         var name = utilDisplayName(d2.entity) || "", string = "";
73950         if (name !== "") {
73951           string += ":";
73952         }
73953         return string += " " + name;
73954       });
73955       items = itemsEnter.merge(items);
73956       var changeset = new osmChangeset().update({ id: void 0 });
73957       var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
73958       delete changeset.id;
73959       var data = JXON.stringify(changeset.osmChangeJXON(changes));
73960       var blob = new Blob([data], { type: "text/xml;charset=utf-8;" });
73961       var fileName = "changes.osc";
73962       var linkEnter = container.selectAll(".download-changes").data([0]).enter().append("a").attr("class", "download-changes");
73963       linkEnter.attr("href", window.URL.createObjectURL(blob)).attr("download", fileName);
73964       linkEnter.call(svgIcon("#iD-icon-load", "inline")).append("span").call(_t.append("commit.download_changes"));
73965       function mouseover(d2) {
73966         if (d2.entity) {
73967           context.surface().selectAll(
73968             utilEntityOrMemberSelector([d2.entity.id], context.graph())
73969           ).classed("hover", true);
73970         }
73971       }
73972       function mouseout() {
73973         context.surface().selectAll(".hover").classed("hover", false);
73974       }
73975       function click(d3_event, change) {
73976         if (change.changeType !== "deleted") {
73977           var entity = change.entity;
73978           context.map().zoomToEase(entity);
73979           context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())).classed("hover", true);
73980         }
73981       }
73982     }
73983     return section;
73984   }
73985
73986   // modules/ui/commit.js
73987   var readOnlyTags = [
73988     /^changesets_count$/,
73989     /^created_by$/,
73990     /^ideditor:/,
73991     /^imagery_used$/,
73992     /^host$/,
73993     /^locale$/,
73994     /^warnings:/,
73995     /^resolved:/,
73996     /^closed:note$/,
73997     /^closed:keepright$/,
73998     /^closed:osmose:/
73999   ];
74000   var hashtagRegex = /(#[^\u2000-\u206F\u2E00-\u2E7F\s\\'!"#$%()*,.\/:;<=>?@\[\]^`{|}~]+)/g;
74001   function uiCommit(context) {
74002     var dispatch14 = dispatch_default("cancel");
74003     var _userDetails2;
74004     var _selection;
74005     var changesetEditor = uiChangesetEditor(context).on("change", changeTags);
74006     var rawTagEditor = uiSectionRawTagEditor("changeset-tag-editor", context).on("change", changeTags).readOnlyTags(readOnlyTags);
74007     var commitChanges = uiSectionChanges(context);
74008     var commitWarnings = uiCommitWarnings(context);
74009     function commit(selection2) {
74010       _selection = selection2;
74011       if (!context.changeset) initChangeset();
74012       loadDerivedChangesetTags();
74013       selection2.call(render);
74014     }
74015     function initChangeset() {
74016       var commentDate = +corePreferences("commentDate") || 0;
74017       var currDate = Date.now();
74018       var cutoff = 2 * 86400 * 1e3;
74019       if (commentDate > currDate || currDate - commentDate > cutoff) {
74020         corePreferences("comment", null);
74021         corePreferences("hashtags", null);
74022         corePreferences("source", null);
74023       }
74024       if (context.defaultChangesetComment()) {
74025         corePreferences("comment", context.defaultChangesetComment());
74026         corePreferences("commentDate", Date.now());
74027       }
74028       if (context.defaultChangesetSource()) {
74029         corePreferences("source", context.defaultChangesetSource());
74030         corePreferences("commentDate", Date.now());
74031       }
74032       if (context.defaultChangesetHashtags()) {
74033         corePreferences("hashtags", context.defaultChangesetHashtags());
74034         corePreferences("commentDate", Date.now());
74035       }
74036       var detected = utilDetect();
74037       var tags = {
74038         comment: corePreferences("comment") || "",
74039         created_by: context.cleanTagValue("iD " + context.version),
74040         host: context.cleanTagValue(detected.host),
74041         locale: context.cleanTagValue(_mainLocalizer.localeCode())
74042       };
74043       findHashtags(tags, true);
74044       var hashtags = corePreferences("hashtags");
74045       if (hashtags) {
74046         tags.hashtags = hashtags;
74047       }
74048       var source = corePreferences("source");
74049       if (source) {
74050         tags.source = source;
74051       }
74052       var photoOverlaysUsed = context.history().photoOverlaysUsed();
74053       if (photoOverlaysUsed.length) {
74054         var sources = (tags.source || "").split(";");
74055         if (sources.indexOf("streetlevel imagery") === -1) {
74056           sources.push("streetlevel imagery");
74057         }
74058         photoOverlaysUsed.forEach(function(photoOverlay) {
74059           if (sources.indexOf(photoOverlay) === -1) {
74060             sources.push(photoOverlay);
74061           }
74062         });
74063         tags.source = context.cleanTagValue(sources.join(";"));
74064       }
74065       context.changeset = new osmChangeset({ tags });
74066     }
74067     function loadDerivedChangesetTags() {
74068       var osm = context.connection();
74069       if (!osm) return;
74070       var tags = Object.assign({}, context.changeset.tags);
74071       var imageryUsed = context.cleanTagValue(context.history().imageryUsed().join(";"));
74072       tags.imagery_used = imageryUsed || "None";
74073       var osmClosed = osm.getClosedIDs();
74074       var itemType;
74075       if (osmClosed.length) {
74076         tags["closed:note"] = context.cleanTagValue(osmClosed.join(";"));
74077       }
74078       if (services.keepRight) {
74079         var krClosed = services.keepRight.getClosedIDs();
74080         if (krClosed.length) {
74081           tags["closed:keepright"] = context.cleanTagValue(krClosed.join(";"));
74082         }
74083       }
74084       if (services.osmose) {
74085         var osmoseClosed = services.osmose.getClosedCounts();
74086         for (itemType in osmoseClosed) {
74087           tags["closed:osmose:" + itemType] = context.cleanTagValue(osmoseClosed[itemType].toString());
74088         }
74089       }
74090       for (var key in tags) {
74091         if (key.match(/(^warnings:)|(^resolved:)/)) {
74092           delete tags[key];
74093         }
74094       }
74095       function addIssueCounts(issues, prefix) {
74096         var issuesByType = utilArrayGroupBy(issues, "type");
74097         for (var issueType in issuesByType) {
74098           var issuesOfType = issuesByType[issueType];
74099           if (issuesOfType[0].subtype) {
74100             var issuesBySubtype = utilArrayGroupBy(issuesOfType, "subtype");
74101             for (var issueSubtype in issuesBySubtype) {
74102               var issuesOfSubtype = issuesBySubtype[issueSubtype];
74103               tags[prefix + ":" + issueType + ":" + issueSubtype] = context.cleanTagValue(issuesOfSubtype.length.toString());
74104             }
74105           } else {
74106             tags[prefix + ":" + issueType] = context.cleanTagValue(issuesOfType.length.toString());
74107           }
74108         }
74109       }
74110       var warnings = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeIgnored: true, includeDisabledRules: true }).warning.filter(function(issue) {
74111         return issue.type !== "help_request";
74112       });
74113       addIssueCounts(warnings, "warnings");
74114       var resolvedIssues = context.validator().getResolvedIssues();
74115       addIssueCounts(resolvedIssues, "resolved");
74116       context.changeset = context.changeset.update({ tags });
74117     }
74118     function render(selection2) {
74119       var osm = context.connection();
74120       if (!osm) return;
74121       var header = selection2.selectAll(".header").data([0]);
74122       var headerTitle = header.enter().append("div").attr("class", "header fillL");
74123       headerTitle.append("div").append("h2").call(_t.append("commit.title"));
74124       headerTitle.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
74125         dispatch14.call("cancel", this);
74126       }).call(svgIcon("#iD-icon-close"));
74127       var body = selection2.selectAll(".body").data([0]);
74128       body = body.enter().append("div").attr("class", "body").merge(body);
74129       var changesetSection = body.selectAll(".changeset-editor").data([0]);
74130       changesetSection = changesetSection.enter().append("div").attr("class", "modal-section changeset-editor").merge(changesetSection);
74131       changesetSection.call(
74132         changesetEditor.changesetID(context.changeset.id).tags(context.changeset.tags)
74133       );
74134       body.call(commitWarnings);
74135       var saveSection = body.selectAll(".save-section").data([0]);
74136       saveSection = saveSection.enter().append("div").attr("class", "modal-section save-section fillL").merge(saveSection);
74137       var prose = saveSection.selectAll(".commit-info").data([0]);
74138       if (prose.enter().size()) {
74139         _userDetails2 = null;
74140       }
74141       prose = prose.enter().append("p").attr("class", "commit-info").call(_t.append("commit.upload_explanation")).merge(prose);
74142       osm.userDetails(function(err, user) {
74143         if (err) return;
74144         if (_userDetails2 === user) return;
74145         _userDetails2 = user;
74146         var userLink = select_default2(document.createElement("div"));
74147         if (user.image_url) {
74148           userLink.append("img").attr("src", user.image_url).attr("class", "icon pre-text user-icon");
74149         }
74150         userLink.append("a").attr("class", "user-info").text(user.display_name).attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
74151         prose.html(_t.html("commit.upload_explanation_with_user", { user: { html: userLink.html() } }));
74152       });
74153       var requestReview = saveSection.selectAll(".request-review").data([0]);
74154       var requestReviewEnter = requestReview.enter().append("div").attr("class", "request-review");
74155       var requestReviewDomId = utilUniqueDomId("commit-input-request-review");
74156       var labelEnter = requestReviewEnter.append("label").attr("for", requestReviewDomId);
74157       if (!labelEnter.empty()) {
74158         labelEnter.call(uiTooltip().title(() => _t.append("commit.request_review_info")).placement("top"));
74159       }
74160       labelEnter.append("input").attr("type", "checkbox").attr("id", requestReviewDomId);
74161       labelEnter.append("span").call(_t.append("commit.request_review"));
74162       requestReview = requestReview.merge(requestReviewEnter);
74163       var requestReviewInput = requestReview.selectAll("input").property("checked", isReviewRequested(context.changeset.tags)).on("change", toggleRequestReview);
74164       var buttonSection = saveSection.selectAll(".buttons").data([0]);
74165       var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons fillL");
74166       buttonEnter.append("button").attr("class", "secondary-action button cancel-button").append("span").attr("class", "label").call(_t.append("commit.cancel"));
74167       var uploadButton = buttonEnter.append("button").attr("class", "action button save-button");
74168       uploadButton.append("span").attr("class", "label").call(_t.append("commit.save"));
74169       var uploadBlockerTooltipText = getUploadBlockerMessage();
74170       buttonSection = buttonSection.merge(buttonEnter);
74171       buttonSection.selectAll(".cancel-button").on("click.cancel", function() {
74172         dispatch14.call("cancel", this);
74173       });
74174       buttonSection.selectAll(".save-button").classed("disabled", uploadBlockerTooltipText !== null).on("click.save", function() {
74175         if (!select_default2(this).classed("disabled")) {
74176           this.blur();
74177           for (var key in context.changeset.tags) {
74178             if (!key) delete context.changeset.tags[key];
74179           }
74180           context.uploader().save(context.changeset);
74181         }
74182       });
74183       uiTooltip().destroyAny(buttonSection.selectAll(".save-button"));
74184       if (uploadBlockerTooltipText) {
74185         buttonSection.selectAll(".save-button").call(uiTooltip().title(() => uploadBlockerTooltipText).placement("top"));
74186       }
74187       var tagSection = body.selectAll(".tag-section.raw-tag-editor").data([0]);
74188       tagSection = tagSection.enter().append("div").attr("class", "modal-section tag-section raw-tag-editor").merge(tagSection);
74189       tagSection.call(
74190         rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
74191       );
74192       var changesSection = body.selectAll(".commit-changes-section").data([0]);
74193       changesSection = changesSection.enter().append("div").attr("class", "modal-section commit-changes-section").merge(changesSection);
74194       changesSection.call(commitChanges.render);
74195       function toggleRequestReview() {
74196         var rr = requestReviewInput.property("checked");
74197         updateChangeset({ review_requested: rr ? "yes" : void 0 });
74198         tagSection.call(
74199           rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
74200         );
74201       }
74202     }
74203     function getUploadBlockerMessage() {
74204       var errors = context.validator().getIssuesBySeverity({ what: "edited", where: "all" }).error;
74205       if (errors.length) {
74206         return _t.append("commit.outstanding_errors_message", { count: errors.length });
74207       } else {
74208         var hasChangesetComment = context.changeset && context.changeset.tags.comment && context.changeset.tags.comment.trim().length;
74209         if (!hasChangesetComment) {
74210           return _t.append("commit.comment_needed_message");
74211         }
74212       }
74213       return null;
74214     }
74215     function changeTags(_2, changed, onInput) {
74216       if (changed.hasOwnProperty("comment")) {
74217         if (changed.comment === void 0) {
74218           changed.comment = "";
74219         }
74220         if (!onInput) {
74221           corePreferences("comment", changed.comment);
74222           corePreferences("commentDate", Date.now());
74223         }
74224       }
74225       if (changed.hasOwnProperty("source")) {
74226         if (changed.source === void 0) {
74227           corePreferences("source", null);
74228         } else if (!onInput) {
74229           corePreferences("source", changed.source);
74230           corePreferences("commentDate", Date.now());
74231         }
74232       }
74233       updateChangeset(changed, onInput);
74234       if (_selection) {
74235         _selection.call(render);
74236       }
74237     }
74238     function findHashtags(tags, commentOnly) {
74239       var detectedHashtags = commentHashtags();
74240       if (detectedHashtags.length) {
74241         corePreferences("hashtags", null);
74242       }
74243       if (!detectedHashtags.length || !commentOnly) {
74244         detectedHashtags = detectedHashtags.concat(hashtagHashtags());
74245       }
74246       var allLowerCase = /* @__PURE__ */ new Set();
74247       return detectedHashtags.filter(function(hashtag) {
74248         var lowerCase = hashtag.toLowerCase();
74249         if (!allLowerCase.has(lowerCase)) {
74250           allLowerCase.add(lowerCase);
74251           return true;
74252         }
74253         return false;
74254       });
74255       function commentHashtags() {
74256         var matches = (tags.comment || "").replace(/http\S*/g, "").match(hashtagRegex);
74257         return matches || [];
74258       }
74259       function hashtagHashtags() {
74260         var matches = (tags.hashtags || "").split(/[,;\s]+/).map(function(s2) {
74261           if (s2[0] !== "#") {
74262             s2 = "#" + s2;
74263           }
74264           var matched = s2.match(hashtagRegex);
74265           return matched && matched[0];
74266         }).filter(Boolean);
74267         return matches || [];
74268       }
74269     }
74270     function isReviewRequested(tags) {
74271       var rr = tags.review_requested;
74272       if (rr === void 0) return false;
74273       rr = rr.trim().toLowerCase();
74274       return !(rr === "" || rr === "no");
74275     }
74276     function updateChangeset(changed, onInput) {
74277       var tags = Object.assign({}, context.changeset.tags);
74278       Object.keys(changed).forEach(function(k2) {
74279         var v2 = changed[k2];
74280         k2 = context.cleanTagKey(k2);
74281         if (readOnlyTags.indexOf(k2) !== -1) return;
74282         if (v2 === void 0) {
74283           delete tags[k2];
74284         } else if (onInput) {
74285           tags[k2] = v2;
74286         } else {
74287           tags[k2] = context.cleanTagValue(v2);
74288         }
74289       });
74290       if (!onInput) {
74291         var commentOnly = changed.hasOwnProperty("comment") && changed.comment !== "";
74292         var arr = findHashtags(tags, commentOnly);
74293         if (arr.length) {
74294           tags.hashtags = context.cleanTagValue(arr.join(";"));
74295           corePreferences("hashtags", tags.hashtags);
74296         } else {
74297           delete tags.hashtags;
74298           corePreferences("hashtags", null);
74299         }
74300       }
74301       if (_userDetails2 && _userDetails2.changesets_count !== void 0) {
74302         var changesetsCount = parseInt(_userDetails2.changesets_count, 10) + 1;
74303         tags.changesets_count = String(changesetsCount);
74304         if (changesetsCount <= 100) {
74305           var s2;
74306           s2 = corePreferences("walkthrough_completed");
74307           if (s2) {
74308             tags["ideditor:walkthrough_completed"] = s2;
74309           }
74310           s2 = corePreferences("walkthrough_progress");
74311           if (s2) {
74312             tags["ideditor:walkthrough_progress"] = s2;
74313           }
74314           s2 = corePreferences("walkthrough_started");
74315           if (s2) {
74316             tags["ideditor:walkthrough_started"] = s2;
74317           }
74318         }
74319       } else {
74320         delete tags.changesets_count;
74321       }
74322       if (!(0, import_fast_deep_equal10.default)(context.changeset.tags, tags)) {
74323         context.changeset = context.changeset.update({ tags });
74324       }
74325     }
74326     commit.reset = function() {
74327       context.changeset = null;
74328     };
74329     return utilRebind(commit, dispatch14, "on");
74330   }
74331
74332   // modules/modes/save.js
74333   function modeSave(context) {
74334     var mode = { id: "save" };
74335     var keybinding = utilKeybinding("modeSave");
74336     var commit = uiCommit(context).on("cancel", cancel);
74337     var _conflictsUi;
74338     var _location;
74339     var _success;
74340     var uploader = context.uploader().on("saveStarted.modeSave", function() {
74341       keybindingOff();
74342     }).on("willAttemptUpload.modeSave", prepareForSuccess).on("progressChanged.modeSave", showProgress).on("resultNoChanges.modeSave", function() {
74343       cancel();
74344     }).on("resultErrors.modeSave", showErrors).on("resultConflicts.modeSave", showConflicts).on("resultSuccess.modeSave", showSuccess);
74345     function cancel() {
74346       context.enter(modeBrowse(context));
74347     }
74348     function showProgress(num, total) {
74349       var modal = context.container().select(".loading-modal .modal-section");
74350       var progress = modal.selectAll(".progress").data([0]);
74351       progress.enter().append("div").attr("class", "progress").merge(progress).text(_t("save.conflict_progress", { num, total }));
74352     }
74353     function showConflicts(changeset, conflicts, origChanges) {
74354       var selection2 = context.container().select(".sidebar").append("div").attr("class", "sidebar-component");
74355       context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
74356       _conflictsUi = uiConflicts(context).conflictList(conflicts).origChanges(origChanges).on("cancel", function() {
74357         context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
74358         selection2.remove();
74359         keybindingOn();
74360         uploader.cancelConflictResolution();
74361       }).on("save", function() {
74362         context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
74363         selection2.remove();
74364         uploader.processResolvedConflicts(changeset);
74365       });
74366       selection2.call(_conflictsUi);
74367     }
74368     function showErrors(errors) {
74369       keybindingOn();
74370       var selection2 = uiConfirm(context.container());
74371       selection2.select(".modal-section.header").append("h3").text(_t("save.error"));
74372       addErrors(selection2, errors);
74373       selection2.okButton();
74374     }
74375     function addErrors(selection2, data) {
74376       var message = selection2.select(".modal-section.message-text");
74377       var items = message.selectAll(".error-container").data(data);
74378       var enter = items.enter().append("div").attr("class", "error-container");
74379       enter.append("a").attr("class", "error-description").attr("href", "#").classed("hide-toggle", true).text(function(d2) {
74380         return d2.msg || _t("save.unknown_error_details");
74381       }).on("click", function(d3_event) {
74382         d3_event.preventDefault();
74383         var error = select_default2(this);
74384         var detail = select_default2(this.nextElementSibling);
74385         var exp2 = error.classed("expanded");
74386         detail.style("display", exp2 ? "none" : "block");
74387         error.classed("expanded", !exp2);
74388       });
74389       var details = enter.append("div").attr("class", "error-detail-container").style("display", "none");
74390       details.append("ul").attr("class", "error-detail-list").selectAll("li").data(function(d2) {
74391         return d2.details || [];
74392       }).enter().append("li").attr("class", "error-detail-item").text(function(d2) {
74393         return d2;
74394       });
74395       items.exit().remove();
74396     }
74397     function showSuccess(changeset) {
74398       commit.reset();
74399       var ui = _success.changeset(changeset).location(_location).on("cancel", function() {
74400         context.ui().sidebar.hide();
74401       });
74402       context.enter(modeBrowse(context).sidebar(ui));
74403     }
74404     function keybindingOn() {
74405       select_default2(document).call(keybinding.on("\u238B", cancel, true));
74406     }
74407     function keybindingOff() {
74408       select_default2(document).call(keybinding.unbind);
74409     }
74410     function prepareForSuccess() {
74411       _success = uiSuccess(context);
74412       _location = null;
74413       if (!services.geocoder) return;
74414       services.geocoder.reverse(context.map().center(), function(err, result) {
74415         if (err || !result || !result.address) return;
74416         var addr = result.address;
74417         var place = addr && (addr.town || addr.city || addr.county) || "";
74418         var region = addr && (addr.state || addr.country) || "";
74419         var separator = place && region ? _t("success.thank_you_where.separator") : "";
74420         _location = _t(
74421           "success.thank_you_where.format",
74422           { place, separator, region }
74423         );
74424       });
74425     }
74426     mode.selectedIDs = function() {
74427       return _conflictsUi ? _conflictsUi.shownEntityIds() : [];
74428     };
74429     mode.enter = function() {
74430       context.ui().sidebar.expand();
74431       function done() {
74432         context.ui().sidebar.show(commit);
74433       }
74434       keybindingOn();
74435       context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
74436       var osm = context.connection();
74437       if (!osm) {
74438         cancel();
74439         return;
74440       }
74441       if (osm.authenticated()) {
74442         done();
74443       } else {
74444         osm.authenticate(function(err) {
74445           if (err) {
74446             cancel();
74447           } else {
74448             done();
74449           }
74450         });
74451       }
74452     };
74453     mode.exit = function() {
74454       keybindingOff();
74455       context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
74456       context.ui().sidebar.hide();
74457     };
74458     return mode;
74459   }
74460
74461   // modules/modes/select_error.js
74462   function modeSelectError(context, selectedErrorID, selectedErrorService) {
74463     var mode = {
74464       id: "select-error",
74465       button: "browse"
74466     };
74467     var keybinding = utilKeybinding("select-error");
74468     var errorService = services[selectedErrorService];
74469     var errorEditor;
74470     switch (selectedErrorService) {
74471       case "keepRight":
74472         errorEditor = uiKeepRightEditor(context).on("change", function() {
74473           context.map().pan([0, 0]);
74474           var error = checkSelectedID();
74475           if (!error) return;
74476           context.ui().sidebar.show(errorEditor.error(error));
74477         });
74478         break;
74479       case "osmose":
74480         errorEditor = uiOsmoseEditor(context).on("change", function() {
74481           context.map().pan([0, 0]);
74482           var error = checkSelectedID();
74483           if (!error) return;
74484           context.ui().sidebar.show(errorEditor.error(error));
74485         });
74486         break;
74487     }
74488     var behaviors = [
74489       behaviorBreathe(context),
74490       behaviorHover(context),
74491       behaviorSelect(context),
74492       behaviorLasso(context),
74493       modeDragNode(context).behavior,
74494       modeDragNote(context).behavior
74495     ];
74496     function checkSelectedID() {
74497       if (!errorService) return;
74498       var error = errorService.getError(selectedErrorID);
74499       if (!error) {
74500         context.enter(modeBrowse(context));
74501       }
74502       return error;
74503     }
74504     mode.zoomToSelected = function() {
74505       if (!errorService) return;
74506       var error = errorService.getError(selectedErrorID);
74507       if (error) {
74508         context.map().centerZoomEase(error.loc, 20);
74509       }
74510     };
74511     mode.enter = function() {
74512       var error = checkSelectedID();
74513       if (!error) return;
74514       behaviors.forEach(context.install);
74515       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
74516       select_default2(document).call(keybinding);
74517       selectError();
74518       var sidebar = context.ui().sidebar;
74519       sidebar.show(errorEditor.error(error));
74520       context.map().on("drawn.select-error", selectError);
74521       function selectError(d3_event, drawn) {
74522         if (!checkSelectedID()) return;
74523         var selection2 = context.surface().selectAll(".itemId-" + selectedErrorID + "." + selectedErrorService);
74524         if (selection2.empty()) {
74525           var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
74526           if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
74527             context.enter(modeBrowse(context));
74528           }
74529         } else {
74530           selection2.classed("selected", true);
74531           context.selectedErrorID(selectedErrorID);
74532         }
74533       }
74534       function esc() {
74535         if (context.container().select(".combobox").size()) return;
74536         context.enter(modeBrowse(context));
74537       }
74538     };
74539     mode.exit = function() {
74540       behaviors.forEach(context.uninstall);
74541       select_default2(document).call(keybinding.unbind);
74542       context.surface().selectAll(".qaItem.selected").classed("selected hover", false);
74543       context.map().on("drawn.select-error", null);
74544       context.ui().sidebar.hide();
74545       context.selectedErrorID(null);
74546       context.features().forceVisible([]);
74547     };
74548     return mode;
74549   }
74550
74551   // modules/core/context.js
74552   function coreContext() {
74553     const dispatch14 = dispatch_default("enter", "exit", "change");
74554     let context = utilRebind({}, dispatch14, "on");
74555     let _deferred2 = /* @__PURE__ */ new Set();
74556     context.version = package_default.version;
74557     context.privacyVersion = "20201202";
74558     context.initialHashParams = window.location.hash ? utilStringQs(window.location.hash) : {};
74559     context.changeset = null;
74560     let _defaultChangesetComment = context.initialHashParams.comment;
74561     let _defaultChangesetSource = context.initialHashParams.source;
74562     let _defaultChangesetHashtags = context.initialHashParams.hashtags;
74563     context.defaultChangesetComment = function(val) {
74564       if (!arguments.length) return _defaultChangesetComment;
74565       _defaultChangesetComment = val;
74566       return context;
74567     };
74568     context.defaultChangesetSource = function(val) {
74569       if (!arguments.length) return _defaultChangesetSource;
74570       _defaultChangesetSource = val;
74571       return context;
74572     };
74573     context.defaultChangesetHashtags = function(val) {
74574       if (!arguments.length) return _defaultChangesetHashtags;
74575       _defaultChangesetHashtags = val;
74576       return context;
74577     };
74578     let _setsDocumentTitle = true;
74579     context.setsDocumentTitle = function(val) {
74580       if (!arguments.length) return _setsDocumentTitle;
74581       _setsDocumentTitle = val;
74582       return context;
74583     };
74584     let _documentTitleBase = document.title;
74585     context.documentTitleBase = function(val) {
74586       if (!arguments.length) return _documentTitleBase;
74587       _documentTitleBase = val;
74588       return context;
74589     };
74590     let _ui;
74591     context.ui = () => _ui;
74592     context.lastPointerType = () => _ui.lastPointerType();
74593     let _keybinding = utilKeybinding("context");
74594     context.keybinding = () => _keybinding;
74595     select_default2(document).call(_keybinding);
74596     let _connection = services.osm;
74597     let _history;
74598     let _validator;
74599     let _uploader;
74600     context.connection = () => _connection;
74601     context.history = () => _history;
74602     context.validator = () => _validator;
74603     context.uploader = () => _uploader;
74604     context.preauth = (options2) => {
74605       if (_connection) {
74606         _connection.switch(options2);
74607       }
74608       return context;
74609     };
74610     context.locale = function(locale2) {
74611       if (!arguments.length) return _mainLocalizer.localeCode();
74612       _mainLocalizer.preferredLocaleCodes(locale2);
74613       return context;
74614     };
74615     function afterLoad(cid, callback) {
74616       return (err, result) => {
74617         if (err) {
74618           if (err.status === 400 || err.status === 401 || err.status === 403) {
74619             if (_connection) {
74620               _connection.logout();
74621             }
74622           }
74623           if (typeof callback === "function") {
74624             callback(err);
74625           }
74626           return;
74627         } else if (_connection && _connection.getConnectionId() !== cid) {
74628           if (typeof callback === "function") {
74629             callback({ message: "Connection Switched", status: -1 });
74630           }
74631           return;
74632         } else {
74633           _history.merge(result.data, result.extent);
74634           if (typeof callback === "function") {
74635             callback(err, result);
74636           }
74637           return;
74638         }
74639       };
74640     }
74641     context.loadTiles = (projection2, callback) => {
74642       const handle = window.requestIdleCallback(() => {
74643         _deferred2.delete(handle);
74644         if (_connection && context.editableDataEnabled()) {
74645           const cid = _connection.getConnectionId();
74646           _connection.loadTiles(projection2, afterLoad(cid, callback));
74647         }
74648       });
74649       _deferred2.add(handle);
74650     };
74651     context.loadTileAtLoc = (loc, callback) => {
74652       const handle = window.requestIdleCallback(() => {
74653         _deferred2.delete(handle);
74654         if (_connection && context.editableDataEnabled()) {
74655           const cid = _connection.getConnectionId();
74656           _connection.loadTileAtLoc(loc, afterLoad(cid, callback));
74657         }
74658       });
74659       _deferred2.add(handle);
74660     };
74661     context.loadEntity = (entityID, callback) => {
74662       if (_connection) {
74663         const cid = _connection.getConnectionId();
74664         _connection.loadEntity(entityID, afterLoad(cid, callback));
74665         _connection.loadEntityRelations(entityID, afterLoad(cid, callback));
74666       }
74667     };
74668     context.loadNote = (entityID, callback) => {
74669       if (_connection) {
74670         const cid = _connection.getConnectionId();
74671         _connection.loadEntityNote(entityID, afterLoad(cid, callback));
74672       }
74673     };
74674     context.zoomToEntity = (entityID, zoomTo) => {
74675       context.zoomToEntities([entityID], zoomTo);
74676     };
74677     context.zoomToEntities = (entityIDs, zoomTo) => {
74678       let loadedEntities = [];
74679       const throttledZoomTo = throttle_default(() => _map.zoomTo(loadedEntities), 500);
74680       entityIDs.forEach((entityID) => context.loadEntity(entityID, (err, result) => {
74681         if (err) return;
74682         const entity = result.data.find((e3) => e3.id === entityID);
74683         if (!entity) return;
74684         loadedEntities.push(entity);
74685         if (zoomTo !== false) {
74686           throttledZoomTo();
74687         }
74688       }));
74689       _map.on("drawn.zoomToEntity", () => {
74690         if (!entityIDs.every((entityID) => context.hasEntity(entityID))) return;
74691         _map.on("drawn.zoomToEntity", null);
74692         context.on("enter.zoomToEntity", null);
74693         context.enter(modeSelect(context, entityIDs));
74694       });
74695       context.on("enter.zoomToEntity", () => {
74696         if (_mode.id !== "browse") {
74697           _map.on("drawn.zoomToEntity", null);
74698           context.on("enter.zoomToEntity", null);
74699         }
74700       });
74701     };
74702     context.zoomToNote = (noteId, zoomTo) => {
74703       context.loadNote(noteId, (err, result) => {
74704         if (err) return;
74705         const entity = result.data.find((e3) => e3.id === noteId);
74706         if (entity) {
74707           const note = services.osm.getNote(noteId);
74708           if (zoomTo !== false) {
74709             context.map().centerZoom(note.loc, 15);
74710           }
74711           const noteLayer = context.layers().layer("notes");
74712           noteLayer.enabled(true);
74713           context.enter(modeSelectNote(context, noteId));
74714         }
74715       });
74716     };
74717     let _minEditableZoom = 16;
74718     context.minEditableZoom = function(val) {
74719       if (!arguments.length) return _minEditableZoom;
74720       _minEditableZoom = val;
74721       if (_connection) {
74722         _connection.tileZoom(val);
74723       }
74724       return context;
74725     };
74726     context.maxCharsForTagKey = () => 255;
74727     context.maxCharsForTagValue = () => 255;
74728     context.maxCharsForRelationRole = () => 255;
74729     context.cleanTagKey = (val) => utilCleanOsmString(val, context.maxCharsForTagKey());
74730     context.cleanTagValue = (val) => utilCleanOsmString(val, context.maxCharsForTagValue());
74731     context.cleanRelationRole = (val) => utilCleanOsmString(val, context.maxCharsForRelationRole());
74732     let _inIntro = false;
74733     context.inIntro = function(val) {
74734       if (!arguments.length) return _inIntro;
74735       _inIntro = val;
74736       return context;
74737     };
74738     context.save = () => {
74739       if (_inIntro || context.container().select(".modal").size()) return;
74740       let canSave;
74741       if (_mode && _mode.id === "save") {
74742         canSave = false;
74743         if (services.osm && services.osm.isChangesetInflight()) {
74744           _history.clearSaved();
74745           return;
74746         }
74747       } else {
74748         canSave = context.selectedIDs().every((id2) => {
74749           const entity = context.hasEntity(id2);
74750           return entity && !entity.isDegenerate();
74751         });
74752       }
74753       if (canSave) {
74754         _history.save();
74755       }
74756       if (_history.hasChanges()) {
74757         return _t("save.unsaved_changes");
74758       }
74759     };
74760     context.debouncedSave = debounce_default(context.save, 350);
74761     function withDebouncedSave(fn) {
74762       return function() {
74763         const result = fn.apply(_history, arguments);
74764         context.debouncedSave();
74765         return result;
74766       };
74767     }
74768     context.hasEntity = (id2) => _history.graph().hasEntity(id2);
74769     context.entity = (id2) => _history.graph().entity(id2);
74770     let _mode;
74771     context.mode = () => _mode;
74772     context.enter = (newMode) => {
74773       if (_mode) {
74774         _mode.exit();
74775         dispatch14.call("exit", this, _mode);
74776       }
74777       _mode = newMode;
74778       _mode.enter();
74779       dispatch14.call("enter", this, _mode);
74780     };
74781     context.selectedIDs = () => _mode && _mode.selectedIDs && _mode.selectedIDs() || [];
74782     context.activeID = () => _mode && _mode.activeID && _mode.activeID();
74783     let _selectedNoteID;
74784     context.selectedNoteID = function(noteID) {
74785       if (!arguments.length) return _selectedNoteID;
74786       _selectedNoteID = noteID;
74787       return context;
74788     };
74789     let _selectedErrorID;
74790     context.selectedErrorID = function(errorID) {
74791       if (!arguments.length) return _selectedErrorID;
74792       _selectedErrorID = errorID;
74793       return context;
74794     };
74795     context.install = (behavior) => context.surface().call(behavior);
74796     context.uninstall = (behavior) => context.surface().call(behavior.off);
74797     let _copyGraph;
74798     context.copyGraph = () => _copyGraph;
74799     let _copyIDs = [];
74800     context.copyIDs = function(val) {
74801       if (!arguments.length) return _copyIDs;
74802       _copyIDs = val;
74803       _copyGraph = _history.graph();
74804       return context;
74805     };
74806     let _copyLonLat;
74807     context.copyLonLat = function(val) {
74808       if (!arguments.length) return _copyLonLat;
74809       _copyLonLat = val;
74810       return context;
74811     };
74812     let _background;
74813     context.background = () => _background;
74814     let _features;
74815     context.features = () => _features;
74816     context.hasHiddenConnections = (id2) => {
74817       const graph = _history.graph();
74818       const entity = graph.entity(id2);
74819       return _features.hasHiddenConnections(entity, graph);
74820     };
74821     let _photos;
74822     context.photos = () => _photos;
74823     let _map;
74824     context.map = () => _map;
74825     context.layers = () => _map.layers();
74826     context.surface = () => _map.surface;
74827     context.editableDataEnabled = () => _map.editableDataEnabled();
74828     context.surfaceRect = () => _map.surface.node().getBoundingClientRect();
74829     context.editable = () => {
74830       const mode = context.mode();
74831       if (!mode || mode.id === "save") return false;
74832       return _map.editableDataEnabled();
74833     };
74834     let _debugFlags = {
74835       tile: false,
74836       // tile boundaries
74837       collision: false,
74838       // label collision bounding boxes
74839       imagery: false,
74840       // imagery bounding polygons
74841       target: false,
74842       // touch targets
74843       downloaded: false
74844       // downloaded data from osm
74845     };
74846     context.debugFlags = () => _debugFlags;
74847     context.getDebug = (flag) => flag && _debugFlags[flag];
74848     context.setDebug = function(flag, val) {
74849       if (arguments.length === 1) val = true;
74850       _debugFlags[flag] = val;
74851       dispatch14.call("change");
74852       return context;
74853     };
74854     let _container = select_default2(null);
74855     context.container = function(val) {
74856       if (!arguments.length) return _container;
74857       _container = val;
74858       _container.classed("ideditor", true);
74859       return context;
74860     };
74861     context.containerNode = function(val) {
74862       if (!arguments.length) return context.container().node();
74863       context.container(select_default2(val));
74864       return context;
74865     };
74866     let _embed;
74867     context.embed = function(val) {
74868       if (!arguments.length) return _embed;
74869       _embed = val;
74870       return context;
74871     };
74872     let _assetPath = "";
74873     context.assetPath = function(val) {
74874       if (!arguments.length) return _assetPath;
74875       _assetPath = val;
74876       _mainFileFetcher.assetPath(val);
74877       return context;
74878     };
74879     let _assetMap = {};
74880     context.assetMap = function(val) {
74881       if (!arguments.length) return _assetMap;
74882       _assetMap = val;
74883       _mainFileFetcher.assetMap(val);
74884       return context;
74885     };
74886     context.asset = (val) => {
74887       if (/^http(s)?:\/\//i.test(val)) return val;
74888       const filename = _assetPath + val;
74889       return _assetMap[filename] || filename;
74890     };
74891     context.imagePath = (val) => context.asset("img/".concat(val));
74892     context.reset = context.flush = () => {
74893       context.debouncedSave.cancel();
74894       Array.from(_deferred2).forEach((handle) => {
74895         window.cancelIdleCallback(handle);
74896         _deferred2.delete(handle);
74897       });
74898       Object.values(services).forEach((service) => {
74899         if (service && typeof service.reset === "function") {
74900           service.reset(context);
74901         }
74902       });
74903       context.changeset = null;
74904       _validator.reset();
74905       _features.reset();
74906       _history.reset();
74907       _uploader.reset();
74908       context.container().select(".inspector-wrap *").remove();
74909       return context;
74910     };
74911     context.projection = geoRawMercator();
74912     context.curtainProjection = geoRawMercator();
74913     context.init = () => {
74914       instantiateInternal();
74915       initializeDependents();
74916       return context;
74917       function instantiateInternal() {
74918         _history = coreHistory(context);
74919         context.graph = _history.graph;
74920         context.pauseChangeDispatch = _history.pauseChangeDispatch;
74921         context.resumeChangeDispatch = _history.resumeChangeDispatch;
74922         context.perform = withDebouncedSave(_history.perform);
74923         context.replace = withDebouncedSave(_history.replace);
74924         context.pop = withDebouncedSave(_history.pop);
74925         context.overwrite = withDebouncedSave(_history.overwrite);
74926         context.undo = withDebouncedSave(_history.undo);
74927         context.redo = withDebouncedSave(_history.redo);
74928         _validator = coreValidator(context);
74929         _uploader = coreUploader(context);
74930         _background = rendererBackground(context);
74931         _features = rendererFeatures(context);
74932         _map = rendererMap(context);
74933         _photos = rendererPhotos(context);
74934         _ui = uiInit(context);
74935       }
74936       function initializeDependents() {
74937         if (context.initialHashParams.presets) {
74938           _mainPresetIndex.addablePresetIDs(new Set(context.initialHashParams.presets.split(",")));
74939         }
74940         if (context.initialHashParams.locale) {
74941           _mainLocalizer.preferredLocaleCodes(context.initialHashParams.locale);
74942         }
74943         _mainLocalizer.ensureLoaded();
74944         _mainPresetIndex.ensureLoaded();
74945         _background.ensureLoaded();
74946         Object.values(services).forEach((service) => {
74947           if (service && typeof service.init === "function") {
74948             service.init();
74949           }
74950         });
74951         _map.init();
74952         _validator.init();
74953         _features.init();
74954         if (services.maprules && context.initialHashParams.maprules) {
74955           json_default(context.initialHashParams.maprules).then((mapcss) => {
74956             services.maprules.init();
74957             mapcss.forEach((mapcssSelector) => services.maprules.addRule(mapcssSelector));
74958           }).catch(() => {
74959           });
74960         }
74961         if (!context.container().empty()) {
74962           _ui.ensureLoaded().then(() => {
74963             _background.init();
74964             _photos.init();
74965           });
74966         }
74967       }
74968     };
74969     return context;
74970   }
74971
74972   // modules/services/nominatim.js
74973   var apibase = nominatimApiUrl;
74974   var _inflight = {};
74975   var _nominatimCache;
74976   var nominatim_default = {
74977     init: function() {
74978       _inflight = {};
74979       _nominatimCache = new RBush();
74980     },
74981     reset: function() {
74982       Object.values(_inflight).forEach(function(controller) {
74983         controller.abort();
74984       });
74985       _inflight = {};
74986       _nominatimCache = new RBush();
74987     },
74988     countryCode: function(location, callback) {
74989       this.reverse(location, function(err, result) {
74990         if (err) {
74991           return callback(err);
74992         } else if (result.address) {
74993           return callback(null, result.address.country_code);
74994         } else {
74995           return callback("Unable to geocode", null);
74996         }
74997       });
74998     },
74999     reverse: function(loc, callback) {
75000       var cached = _nominatimCache.search(
75001         { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] }
75002       );
75003       if (cached.length > 0) {
75004         if (callback) callback(null, cached[0].data);
75005         return;
75006       }
75007       var params = { zoom: 13, format: "json", addressdetails: 1, lat: loc[1], lon: loc[0] };
75008       var url = apibase + "reverse?" + utilQsString(params);
75009       if (_inflight[url]) return;
75010       var controller = new AbortController();
75011       _inflight[url] = controller;
75012       json_default(url, {
75013         signal: controller.signal,
75014         headers: {
75015           "Accept-Language": _mainLocalizer.localeCodes().join(",")
75016         }
75017       }).then(function(result) {
75018         delete _inflight[url];
75019         if (result && result.error) {
75020           throw new Error(result.error);
75021         }
75022         var extent = geoExtent(loc).padByMeters(200);
75023         _nominatimCache.insert(Object.assign(extent.bbox(), { data: result }));
75024         if (callback) callback(null, result);
75025       }).catch(function(err) {
75026         delete _inflight[url];
75027         if (err.name === "AbortError") return;
75028         if (callback) callback(err.message);
75029       });
75030     },
75031     search: function(val, callback) {
75032       const params = {
75033         q: val,
75034         limit: 10,
75035         format: "json"
75036       };
75037       var url = apibase + "search?" + utilQsString(params);
75038       if (_inflight[url]) return;
75039       var controller = new AbortController();
75040       _inflight[url] = controller;
75041       json_default(url, {
75042         signal: controller.signal,
75043         headers: {
75044           "Accept-Language": _mainLocalizer.localeCodes().join(",")
75045         }
75046       }).then(function(result) {
75047         delete _inflight[url];
75048         if (result && result.error) {
75049           throw new Error(result.error);
75050         }
75051         if (callback) callback(null, result);
75052       }).catch(function(err) {
75053         delete _inflight[url];
75054         if (err.name === "AbortError") return;
75055         if (callback) callback(err.message);
75056       });
75057     }
75058   };
75059
75060   // node_modules/name-suggestion-index/lib/matcher.js
75061   var import_which_polygon4 = __toESM(require_which_polygon(), 1);
75062
75063   // node_modules/name-suggestion-index/lib/simplify.js
75064   var import_diacritics3 = __toESM(require_diacritics(), 1);
75065   function simplify2(str) {
75066     if (typeof str !== "string") return "";
75067     return import_diacritics3.default.remove(
75068       str.replace(/&/g, "and").replace(/(İ|i̇)/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()
75069     );
75070   }
75071
75072   // node_modules/name-suggestion-index/config/matchGroups.json
75073   var matchGroups_default = {
75074     matchGroups: {
75075       adult_gaming_centre: [
75076         "amenity/casino",
75077         "amenity/gambling",
75078         "leisure/adult_gaming_centre"
75079       ],
75080       bar: [
75081         "amenity/bar",
75082         "amenity/pub",
75083         "amenity/restaurant"
75084       ],
75085       beauty: [
75086         "shop/beauty",
75087         "shop/hairdresser_supply"
75088       ],
75089       bed: [
75090         "shop/bed",
75091         "shop/furniture"
75092       ],
75093       beverages: [
75094         "shop/alcohol",
75095         "shop/beer",
75096         "shop/beverages",
75097         "shop/kiosk",
75098         "shop/wine"
75099       ],
75100       camping: [
75101         "tourism/camp_site",
75102         "tourism/caravan_site"
75103       ],
75104       car_parts: [
75105         "shop/car_parts",
75106         "shop/car_repair",
75107         "shop/tires",
75108         "shop/tyres"
75109       ],
75110       clinic: [
75111         "amenity/clinic",
75112         "amenity/doctors",
75113         "healthcare/clinic",
75114         "healthcare/laboratory",
75115         "healthcare/physiotherapist",
75116         "healthcare/sample_collection",
75117         "healthcare/dialysis"
75118       ],
75119       convenience: [
75120         "shop/beauty",
75121         "shop/chemist",
75122         "shop/convenience",
75123         "shop/cosmetics",
75124         "shop/grocery",
75125         "shop/kiosk",
75126         "shop/newsagent",
75127         "shop/perfumery"
75128       ],
75129       coworking: [
75130         "amenity/coworking_space",
75131         "office/coworking",
75132         "office/coworking_space"
75133       ],
75134       dentist: [
75135         "amenity/dentist",
75136         "amenity/doctors",
75137         "healthcare/dentist"
75138       ],
75139       electronics: [
75140         "office/telecommunication",
75141         "shop/appliance",
75142         "shop/computer",
75143         "shop/electronics",
75144         "shop/hifi",
75145         "shop/kiosk",
75146         "shop/mobile",
75147         "shop/mobile_phone",
75148         "shop/telecommunication",
75149         "shop/video_games"
75150       ],
75151       estate_agents: [
75152         "office/estate_agent",
75153         "shop/estate_agent",
75154         "office/mortgage",
75155         "office/financial"
75156       ],
75157       fabric: [
75158         "shop/fabric",
75159         "shop/haberdashery",
75160         "shop/sewing"
75161       ],
75162       fashion: [
75163         "shop/accessories",
75164         "shop/bag",
75165         "shop/boutique",
75166         "shop/clothes",
75167         "shop/department_store",
75168         "shop/fashion",
75169         "shop/fashion_accessories",
75170         "shop/sports",
75171         "shop/shoes"
75172       ],
75173       financial: [
75174         "amenity/bank",
75175         "office/accountant",
75176         "office/financial",
75177         "office/financial_advisor",
75178         "office/tax_advisor",
75179         "shop/tax"
75180       ],
75181       fitness: [
75182         "leisure/fitness_centre",
75183         "leisure/fitness_center",
75184         "leisure/sports_centre",
75185         "leisure/sports_center"
75186       ],
75187       food: [
75188         "amenity/cafe",
75189         "amenity/fast_food",
75190         "amenity/ice_cream",
75191         "amenity/restaurant",
75192         "shop/bakery",
75193         "shop/candy",
75194         "shop/chocolate",
75195         "shop/coffee",
75196         "shop/confectionary",
75197         "shop/confectionery",
75198         "shop/deli",
75199         "shop/food",
75200         "shop/kiosk",
75201         "shop/ice_cream",
75202         "shop/pastry",
75203         "shop/tea"
75204       ],
75205       fuel: [
75206         "amenity/fuel",
75207         "shop/gas",
75208         "shop/convenience;gas",
75209         "shop/gas;convenience"
75210       ],
75211       gift: [
75212         "shop/gift",
75213         "shop/card",
75214         "shop/cards",
75215         "shop/kiosk",
75216         "shop/stationery"
75217       ],
75218       glass: [
75219         "craft/window_construction",
75220         "craft/glaziery",
75221         "shop/car_repair"
75222       ],
75223       hardware: [
75224         "shop/bathroom_furnishing",
75225         "shop/carpet",
75226         "shop/diy",
75227         "shop/doityourself",
75228         "shop/doors",
75229         "shop/electrical",
75230         "shop/flooring",
75231         "shop/hardware",
75232         "shop/hardware_store",
75233         "shop/power_tools",
75234         "shop/tool_hire",
75235         "shop/tools",
75236         "shop/trade"
75237       ],
75238       health_food: [
75239         "shop/health",
75240         "shop/health_food",
75241         "shop/herbalist",
75242         "shop/nutrition_supplements"
75243       ],
75244       hobby: [
75245         "shop/electronics",
75246         "shop/hobby",
75247         "shop/books",
75248         "shop/games",
75249         "shop/collector",
75250         "shop/toys",
75251         "shop/model",
75252         "shop/video_games",
75253         "shop/anime"
75254       ],
75255       hospital: [
75256         "amenity/doctors",
75257         "amenity/hospital",
75258         "healthcare/hospital"
75259       ],
75260       houseware: [
75261         "shop/houseware",
75262         "shop/interior_decoration"
75263       ],
75264       water_rescue: [
75265         "amenity/lifeboat_station",
75266         "emergency/lifeboat_station",
75267         "emergency/marine_rescue",
75268         "emergency/water_rescue"
75269       ],
75270       locksmith: [
75271         "craft/key_cutter",
75272         "craft/locksmith",
75273         "shop/locksmith"
75274       ],
75275       lodging: [
75276         "tourism/guest_house",
75277         "tourism/hotel",
75278         "tourism/motel"
75279       ],
75280       money_transfer: [
75281         "amenity/money_transfer",
75282         "shop/money_transfer"
75283       ],
75284       music: ["shop/music", "shop/musical_instrument"],
75285       office_supplies: [
75286         "shop/office_supplies",
75287         "shop/stationary",
75288         "shop/stationery"
75289       ],
75290       outdoor: [
75291         "shop/clothes",
75292         "shop/outdoor",
75293         "shop/sports"
75294       ],
75295       parcel_locker: [
75296         "amenity/parcel_locker",
75297         "amenity/vending_machine"
75298       ],
75299       pharmacy: [
75300         "amenity/doctors",
75301         "amenity/pharmacy",
75302         "healthcare/pharmacy",
75303         "shop/chemist"
75304       ],
75305       playground: [
75306         "amenity/theme_park",
75307         "leisure/amusement_arcade",
75308         "leisure/playground"
75309       ],
75310       rental: [
75311         "amenity/bicycle_rental",
75312         "amenity/boat_rental",
75313         "amenity/car_rental",
75314         "amenity/truck_rental",
75315         "amenity/vehicle_rental",
75316         "shop/kiosk",
75317         "shop/plant_hire",
75318         "shop/rental",
75319         "shop/tool_hire"
75320       ],
75321       school: [
75322         "amenity/childcare",
75323         "amenity/college",
75324         "amenity/kindergarten",
75325         "amenity/language_school",
75326         "amenity/prep_school",
75327         "amenity/school",
75328         "amenity/university"
75329       ],
75330       storage: [
75331         "shop/storage_units",
75332         "shop/storage_rental"
75333       ],
75334       substation: [
75335         "power/station",
75336         "power/substation",
75337         "power/sub_station"
75338       ],
75339       supermarket: [
75340         "shop/food",
75341         "shop/frozen_food",
75342         "shop/greengrocer",
75343         "shop/grocery",
75344         "shop/supermarket",
75345         "shop/wholesale"
75346       ],
75347       thrift: [
75348         "shop/charity",
75349         "shop/clothes",
75350         "shop/second_hand"
75351       ],
75352       tobacco: [
75353         "shop/e-cigarette",
75354         "shop/tobacco"
75355       ],
75356       variety_store: [
75357         "shop/variety_store",
75358         "shop/discount",
75359         "shop/convenience"
75360       ],
75361       vending: [
75362         "amenity/vending_machine",
75363         "shop/kiosk",
75364         "shop/vending_machine"
75365       ],
75366       weight_loss: [
75367         "amenity/clinic",
75368         "amenity/doctors",
75369         "amenity/weight_clinic",
75370         "healthcare/counselling",
75371         "leisure/fitness_centre",
75372         "office/therapist",
75373         "shop/beauty",
75374         "shop/diet",
75375         "shop/food",
75376         "shop/health_food",
75377         "shop/herbalist",
75378         "shop/nutrition",
75379         "shop/nutrition_supplements",
75380         "shop/weight_loss"
75381       ],
75382       wholesale: [
75383         "shop/wholesale",
75384         "shop/supermarket",
75385         "shop/department_store"
75386       ]
75387     }
75388   };
75389
75390   // node_modules/name-suggestion-index/config/genericWords.json
75391   var genericWords_default = {
75392     genericWords: [
75393       "^(barn|bazaa?r|bench|bou?tique|building|casa|church)$",
75394       "^(baseball|basketball|football|soccer|softball|tennis(halle)?)\\s?(field|court)?$",
75395       "^(club|green|out|ware)\\s?house$",
75396       "^(driveway|el \xE1rbol|fountain|generic|golf|government|graveyard)$",
75397       "^(fixme|n\\s?\\/?\\s?a|name|no\\s?name|none|null|temporary|test|unknown)$",
75398       "^(hofladen|librairie|magazine?|maison|toko)$",
75399       "^(mobile home|skate)?\\s?park$",
75400       "^(obuwie|pond|pool|sale|shops?|sklep|stores?)$",
75401       "^\\?+$",
75402       "^private$",
75403       "^tattoo( studio)?$",
75404       "^windmill$",
75405       "^\u0446\u0435\u0440\u043A\u043E\u0432\u043D\u0430\u044F( \u043B\u0430\u0432\u043A\u0430)?$"
75406     ]
75407   };
75408
75409   // node_modules/name-suggestion-index/config/trees.json
75410   var trees_default = {
75411     trees: {
75412       brands: {
75413         emoji: "\u{1F354}",
75414         mainTag: "brand:wikidata",
75415         sourceTags: ["brand", "name"],
75416         nameTags: {
75417           primary: "^(name|name:\\w+)$",
75418           alternate: "^(brand|brand:\\w+|operator|operator:\\w+|\\w+_name|\\w+_name:\\w+)$"
75419         }
75420       },
75421       flags: {
75422         emoji: "\u{1F6A9}",
75423         mainTag: "flag:wikidata",
75424         nameTags: {
75425           primary: "^(flag:name|flag:name:\\w+)$",
75426           alternate: "^(country|country:\\w+|flag|flag:\\w+|subject|subject:\\w+)$"
75427         }
75428       },
75429       operators: {
75430         emoji: "\u{1F4BC}",
75431         mainTag: "operator:wikidata",
75432         sourceTags: ["operator"],
75433         nameTags: {
75434           primary: "^(name|name:\\w+|operator|operator:\\w+)$",
75435           alternate: "^(brand|brand:\\w+|\\w+_name|\\w+_name:\\w+)$"
75436         }
75437       },
75438       transit: {
75439         emoji: "\u{1F687}",
75440         mainTag: "network:wikidata",
75441         sourceTags: ["network"],
75442         nameTags: {
75443           primary: "^network$",
75444           alternate: "^(operator|operator:\\w+|network:\\w+|\\w+_name|\\w+_name:\\w+)$"
75445         }
75446       }
75447     }
75448   };
75449
75450   // node_modules/name-suggestion-index/lib/matcher.js
75451   var matchGroups = matchGroups_default.matchGroups;
75452   var trees = trees_default.trees;
75453   var Matcher = class {
75454     //
75455     // `constructor`
75456     // initialize the genericWords regexes
75457     constructor() {
75458       this.matchIndex = void 0;
75459       this.genericWords = /* @__PURE__ */ new Map();
75460       (genericWords_default.genericWords || []).forEach((s2) => this.genericWords.set(s2, new RegExp(s2, "i")));
75461       this.itemLocation = void 0;
75462       this.locationSets = void 0;
75463       this.locationIndex = void 0;
75464       this.warnings = [];
75465     }
75466     //
75467     // `buildMatchIndex()`
75468     // Call this to prepare the matcher for use
75469     //
75470     // `data` needs to be an Object indexed on a 'tree/key/value' path.
75471     // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
75472     // {
75473     //    'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
75474     //    'brands/amenity/bar':  { properties: {}, items: [ {}, {}, … ] },
75475     //    …
75476     // }
75477     //
75478     buildMatchIndex(data) {
75479       const that = this;
75480       if (that.matchIndex) return;
75481       that.matchIndex = /* @__PURE__ */ new Map();
75482       const seenTree = /* @__PURE__ */ new Map();
75483       Object.keys(data).forEach((tkv) => {
75484         const category = data[tkv];
75485         const parts = tkv.split("/", 3);
75486         const t2 = parts[0];
75487         const k2 = parts[1];
75488         const v2 = parts[2];
75489         const thiskv = "".concat(k2, "/").concat(v2);
75490         const tree = trees[t2];
75491         let branch = that.matchIndex.get(thiskv);
75492         if (!branch) {
75493           branch = {
75494             primary: /* @__PURE__ */ new Map(),
75495             alternate: /* @__PURE__ */ new Map(),
75496             excludeGeneric: /* @__PURE__ */ new Map(),
75497             excludeNamed: /* @__PURE__ */ new Map()
75498           };
75499           that.matchIndex.set(thiskv, branch);
75500         }
75501         const properties = category.properties || {};
75502         const exclude = properties.exclude || {};
75503         (exclude.generic || []).forEach((s2) => branch.excludeGeneric.set(s2, new RegExp(s2, "i")));
75504         (exclude.named || []).forEach((s2) => branch.excludeNamed.set(s2, new RegExp(s2, "i")));
75505         const excludeRegexes = [...branch.excludeGeneric.values(), ...branch.excludeNamed.values()];
75506         let items = category.items;
75507         if (!Array.isArray(items) || !items.length) return;
75508         const primaryName = new RegExp(tree.nameTags.primary, "i");
75509         const alternateName = new RegExp(tree.nameTags.alternate, "i");
75510         const notName = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
75511         const skipGenericKV = skipGenericKVMatches(t2, k2, v2);
75512         const genericKV = /* @__PURE__ */ new Set(["".concat(k2, "/yes"), "building/yes"]);
75513         const matchGroupKV = /* @__PURE__ */ new Set();
75514         Object.values(matchGroups).forEach((matchGroup) => {
75515           const inGroup = matchGroup.some((otherkv) => otherkv === thiskv);
75516           if (!inGroup) return;
75517           matchGroup.forEach((otherkv) => {
75518             if (otherkv === thiskv) return;
75519             matchGroupKV.add(otherkv);
75520             const otherk = otherkv.split("/", 2)[0];
75521             genericKV.add("".concat(otherk, "/yes"));
75522           });
75523         });
75524         items.forEach((item) => {
75525           if (!item.id) return;
75526           if (Array.isArray(item.matchTags) && item.matchTags.length) {
75527             item.matchTags = item.matchTags.filter((matchTag) => !matchGroupKV.has(matchTag) && matchTag !== thiskv && !genericKV.has(matchTag));
75528             if (!item.matchTags.length) delete item.matchTags;
75529           }
75530           let kvTags = ["".concat(thiskv)].concat(item.matchTags || []);
75531           if (!skipGenericKV) {
75532             kvTags = kvTags.concat(Array.from(genericKV));
75533           }
75534           Object.keys(item.tags).forEach((osmkey) => {
75535             if (notName.test(osmkey)) return;
75536             const osmvalue = item.tags[osmkey];
75537             if (!osmvalue || excludeRegexes.some((regex) => regex.test(osmvalue))) return;
75538             if (primaryName.test(osmkey)) {
75539               kvTags.forEach((kv) => insertName("primary", t2, kv, simplify2(osmvalue), item.id));
75540             } else if (alternateName.test(osmkey)) {
75541               kvTags.forEach((kv) => insertName("alternate", t2, kv, simplify2(osmvalue), item.id));
75542             }
75543           });
75544           let keepMatchNames = /* @__PURE__ */ new Set();
75545           (item.matchNames || []).forEach((matchName) => {
75546             const nsimple = simplify2(matchName);
75547             kvTags.forEach((kv) => {
75548               const branch2 = that.matchIndex.get(kv);
75549               const primaryLeaf = branch2 && branch2.primary.get(nsimple);
75550               const alternateLeaf = branch2 && branch2.alternate.get(nsimple);
75551               const inPrimary = primaryLeaf && primaryLeaf.has(item.id);
75552               const inAlternate = alternateLeaf && alternateLeaf.has(item.id);
75553               if (!inPrimary && !inAlternate) {
75554                 insertName("alternate", t2, kv, nsimple, item.id);
75555                 keepMatchNames.add(matchName);
75556               }
75557             });
75558           });
75559           if (keepMatchNames.size) {
75560             item.matchNames = Array.from(keepMatchNames);
75561           } else {
75562             delete item.matchNames;
75563           }
75564         });
75565       });
75566       function insertName(which, t2, kv, nsimple, itemID) {
75567         if (!nsimple) {
75568           that.warnings.push("Warning: skipping empty ".concat(which, " name for item ").concat(t2, "/").concat(kv, ": ").concat(itemID));
75569           return;
75570         }
75571         let branch = that.matchIndex.get(kv);
75572         if (!branch) {
75573           branch = {
75574             primary: /* @__PURE__ */ new Map(),
75575             alternate: /* @__PURE__ */ new Map(),
75576             excludeGeneric: /* @__PURE__ */ new Map(),
75577             excludeNamed: /* @__PURE__ */ new Map()
75578           };
75579           that.matchIndex.set(kv, branch);
75580         }
75581         let leaf = branch[which].get(nsimple);
75582         if (!leaf) {
75583           leaf = /* @__PURE__ */ new Set();
75584           branch[which].set(nsimple, leaf);
75585         }
75586         leaf.add(itemID);
75587         if (!/yes$/.test(kv)) {
75588           const kvnsimple = "".concat(kv, "/").concat(nsimple);
75589           const existing = seenTree.get(kvnsimple);
75590           if (existing && existing !== t2) {
75591             const items = Array.from(leaf);
75592             that.warnings.push('Duplicate cache key "'.concat(kvnsimple, '" in trees "').concat(t2, '" and "').concat(existing, '", check items: ').concat(items));
75593             return;
75594           }
75595           seenTree.set(kvnsimple, t2);
75596         }
75597       }
75598       function skipGenericKVMatches(t2, k2, v2) {
75599         return t2 === "flags" || t2 === "transit" || k2 === "landuse" || v2 === "atm" || v2 === "bicycle_parking" || v2 === "car_sharing" || v2 === "caravan_site" || v2 === "charging_station" || v2 === "dog_park" || v2 === "parking" || v2 === "phone" || v2 === "playground" || v2 === "post_box" || v2 === "public_bookcase" || v2 === "recycling" || v2 === "vending_machine";
75600       }
75601     }
75602     //
75603     // `buildLocationIndex()`
75604     // Call this to prepare a which-polygon location index.
75605     // This *resolves* all the locationSets into GeoJSON, which takes some time.
75606     // You can skip this step if you don't care about matching within a location.
75607     //
75608     // `data` needs to be an Object indexed on a 'tree/key/value' path.
75609     // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
75610     // {
75611     //    'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
75612     //    'brands/amenity/bar':  { properties: {}, items: [ {}, {}, … ] },
75613     //    …
75614     // }
75615     //
75616     buildLocationIndex(data, loco) {
75617       const that = this;
75618       if (that.locationIndex) return;
75619       that.itemLocation = /* @__PURE__ */ new Map();
75620       that.locationSets = /* @__PURE__ */ new Map();
75621       Object.keys(data).forEach((tkv) => {
75622         const items = data[tkv].items;
75623         if (!Array.isArray(items) || !items.length) return;
75624         items.forEach((item) => {
75625           if (that.itemLocation.has(item.id)) return;
75626           let resolved;
75627           try {
75628             resolved = loco.resolveLocationSet(item.locationSet);
75629           } catch (err) {
75630             console.warn("buildLocationIndex: ".concat(err.message));
75631           }
75632           if (!resolved || !resolved.id) return;
75633           that.itemLocation.set(item.id, resolved.id);
75634           if (that.locationSets.has(resolved.id)) return;
75635           let feature3 = _cloneDeep2(resolved.feature);
75636           feature3.id = resolved.id;
75637           feature3.properties.id = resolved.id;
75638           if (!feature3.geometry.coordinates.length || !feature3.properties.area) {
75639             console.warn("buildLocationIndex: locationSet ".concat(resolved.id, " for ").concat(item.id, " resolves to an empty feature:"));
75640             console.warn(JSON.stringify(feature3));
75641             return;
75642           }
75643           that.locationSets.set(resolved.id, feature3);
75644         });
75645       });
75646       that.locationIndex = (0, import_which_polygon4.default)({ type: "FeatureCollection", features: [...that.locationSets.values()] });
75647       function _cloneDeep2(obj) {
75648         return JSON.parse(JSON.stringify(obj));
75649       }
75650     }
75651     //
75652     // `match()`
75653     // Pass parts and return an Array of matches.
75654     // `k` - key
75655     // `v` - value
75656     // `n` - namelike
75657     // `loc` - optional - [lon,lat] location to search
75658     //
75659     // 1. If the [k,v,n] tuple matches a canonical item…
75660     // Return an Array of match results.
75661     // Each result will include the area in km² that the item is valid.
75662     //
75663     // Order of results:
75664     // Primary ordering will be on the "match" column:
75665     //   "primary" - where the query matches the `name` tag, followed by
75666     //   "alternate" - where the query matches an alternate name tag (e.g. short_name, brand, operator, etc)
75667     // Secondary ordering will be on the "area" column:
75668     //   "area descending" if no location was provided, (worldwide before local)
75669     //   "area ascending" if location was provided (local before worldwide)
75670     //
75671     // [
75672     //   { match: 'primary',   itemID: String,  area: Number,  kv: String,  nsimple: String },
75673     //   { match: 'primary',   itemID: String,  area: Number,  kv: String,  nsimple: String },
75674     //   { match: 'alternate', itemID: String,  area: Number,  kv: String,  nsimple: String },
75675     //   { match: 'alternate', itemID: String,  area: Number,  kv: String,  nsimple: String },
75676     //   …
75677     // ]
75678     //
75679     // -or-
75680     //
75681     // 2. If the [k,v,n] tuple matches an exclude pattern…
75682     // Return an Array with a single exclude result, either
75683     //
75684     // [ { match: 'excludeGeneric', pattern: String,  kv: String } ]  // "generic" e.g. "Food Court"
75685     //   or
75686     // [ { match: 'excludeNamed', pattern: String,  kv: String } ]    // "named", e.g. "Kebabai"
75687     //
75688     // About results
75689     //   "generic" - a generic word that is probably not really a name.
75690     //     For these, iD should warn the user "Hey don't put 'food court' in the name tag".
75691     //   "named" - a real name like "Kebabai" that is just common, but not a brand.
75692     //     For these, iD should just let it be. We don't include these in NSI, but we don't want to nag users about it either.
75693     //
75694     // -or-
75695     //
75696     // 3. If the [k,v,n] tuple matches nothing of any kind, return `null`
75697     //
75698     //
75699     match(k2, v2, n3, loc) {
75700       const that = this;
75701       if (!that.matchIndex) {
75702         throw new Error("match:  matchIndex not built.");
75703       }
75704       let matchLocations;
75705       if (Array.isArray(loc) && that.locationIndex) {
75706         matchLocations = that.locationIndex([loc[0], loc[1], loc[0], loc[1]], true);
75707       }
75708       const nsimple = simplify2(n3);
75709       let seen = /* @__PURE__ */ new Set();
75710       let results = [];
75711       gatherResults("primary");
75712       gatherResults("alternate");
75713       if (results.length) return results;
75714       gatherResults("exclude");
75715       return results.length ? results : null;
75716       function gatherResults(which) {
75717         const kv = "".concat(k2, "/").concat(v2);
75718         let didMatch = tryMatch(which, kv);
75719         if (didMatch) return;
75720         for (let mg in matchGroups) {
75721           const matchGroup = matchGroups[mg];
75722           const inGroup = matchGroup.some((otherkv) => otherkv === kv);
75723           if (!inGroup) continue;
75724           for (let i3 = 0; i3 < matchGroup.length; i3++) {
75725             const otherkv = matchGroup[i3];
75726             if (otherkv === kv) continue;
75727             didMatch = tryMatch(which, otherkv);
75728             if (didMatch) return;
75729           }
75730         }
75731         if (which === "exclude") {
75732           const regex = [...that.genericWords.values()].find((regex2) => regex2.test(n3));
75733           if (regex) {
75734             results.push({ match: "excludeGeneric", pattern: String(regex) });
75735             return;
75736           }
75737         }
75738       }
75739       function tryMatch(which, kv) {
75740         const branch = that.matchIndex.get(kv);
75741         if (!branch) return;
75742         if (which === "exclude") {
75743           let regex = [...branch.excludeNamed.values()].find((regex2) => regex2.test(n3));
75744           if (regex) {
75745             results.push({ match: "excludeNamed", pattern: String(regex), kv });
75746             return;
75747           }
75748           regex = [...branch.excludeGeneric.values()].find((regex2) => regex2.test(n3));
75749           if (regex) {
75750             results.push({ match: "excludeGeneric", pattern: String(regex), kv });
75751             return;
75752           }
75753           return;
75754         }
75755         const leaf = branch[which].get(nsimple);
75756         if (!leaf || !leaf.size) return;
75757         let hits = Array.from(leaf).map((itemID) => {
75758           let area = Infinity;
75759           if (that.itemLocation && that.locationSets) {
75760             const location = that.locationSets.get(that.itemLocation.get(itemID));
75761             area = location && location.properties.area || Infinity;
75762           }
75763           return { match: which, itemID, area, kv, nsimple };
75764         });
75765         let sortFn = byAreaDescending;
75766         if (matchLocations) {
75767           hits = hits.filter(isValidLocation);
75768           sortFn = byAreaAscending;
75769         }
75770         if (!hits.length) return;
75771         hits.sort(sortFn).forEach((hit) => {
75772           if (seen.has(hit.itemID)) return;
75773           seen.add(hit.itemID);
75774           results.push(hit);
75775         });
75776         return true;
75777         function isValidLocation(hit) {
75778           if (!that.itemLocation) return true;
75779           return matchLocations.find((props) => props.id === that.itemLocation.get(hit.itemID));
75780         }
75781         function byAreaAscending(hitA, hitB) {
75782           return hitA.area - hitB.area;
75783         }
75784         function byAreaDescending(hitA, hitB) {
75785           return hitB.area - hitA.area;
75786         }
75787       }
75788     }
75789     //
75790     // `getWarnings()`
75791     // Return any warnings discovered when buiding the index.
75792     // (currently this does nothing)
75793     //
75794     getWarnings() {
75795       return this.warnings;
75796     }
75797   };
75798
75799   // modules/services/nsi.js
75800   var import_vparse2 = __toESM(require_vparse());
75801   var _nsiStatus = "loading";
75802   var _nsi = {};
75803   var buildingPreset = {
75804     "building/commercial": true,
75805     "building/government": true,
75806     "building/hotel": true,
75807     "building/retail": true,
75808     "building/office": true,
75809     "building/supermarket": true,
75810     "building/yes": true
75811   };
75812   var notNames = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
75813   var notBranches = /(coop|express|wireless|factory|outlet)/i;
75814   function setNsiSources() {
75815     const nsiVersion = package_default.dependencies["name-suggestion-index"] || package_default.devDependencies["name-suggestion-index"];
75816     const v2 = (0, import_vparse2.default)(nsiVersion);
75817     const vMinor = "".concat(v2.major, ".").concat(v2.minor);
75818     const cdn = nsiCdnUrl.replace("{version}", vMinor);
75819     const sources = {
75820       "nsi_data": cdn + "dist/nsi.min.json",
75821       "nsi_dissolved": cdn + "dist/dissolved.min.json",
75822       "nsi_features": cdn + "dist/featureCollection.min.json",
75823       "nsi_generics": cdn + "dist/genericWords.min.json",
75824       "nsi_presets": cdn + "dist/presets/nsi-id-presets.min.json",
75825       "nsi_replacements": cdn + "dist/replacements.min.json",
75826       "nsi_trees": cdn + "dist/trees.min.json"
75827     };
75828     let fileMap = _mainFileFetcher.fileMap();
75829     for (const k2 in sources) {
75830       if (!fileMap[k2]) fileMap[k2] = sources[k2];
75831     }
75832   }
75833   function loadNsiPresets() {
75834     return Promise.all([
75835       _mainFileFetcher.get("nsi_presets"),
75836       _mainFileFetcher.get("nsi_features")
75837     ]).then((vals) => {
75838       Object.values(vals[0].presets).forEach((preset) => preset.suggestion = true);
75839       Object.values(vals[0].presets).forEach((preset) => {
75840         if (preset.tags["brand:wikidata"]) {
75841           preset.removeTags = __spreadValues({ "brand:wikipedia": "*" }, preset.removeTags || preset.addTags || preset.tags);
75842         }
75843         if (preset.tags["operator:wikidata"]) {
75844           preset.removeTags = __spreadValues({ "operator:wikipedia": "*" }, preset.removeTags || preset.addTags || preset.tags);
75845         }
75846         if (preset.tags["network:wikidata"]) {
75847           preset.removeTags = __spreadValues({ "network:wikipedia": "*" }, preset.removeTags || preset.addTags || preset.tags);
75848         }
75849       });
75850       _mainPresetIndex.merge({
75851         presets: vals[0].presets,
75852         featureCollection: vals[1]
75853       });
75854     });
75855   }
75856   function loadNsiData() {
75857     return Promise.all([
75858       _mainFileFetcher.get("nsi_data"),
75859       _mainFileFetcher.get("nsi_dissolved"),
75860       _mainFileFetcher.get("nsi_replacements"),
75861       _mainFileFetcher.get("nsi_trees")
75862     ]).then((vals) => {
75863       _nsi = {
75864         data: vals[0].nsi,
75865         // the raw name-suggestion-index data
75866         dissolved: vals[1].dissolved,
75867         // list of dissolved items
75868         replacements: vals[2].replacements,
75869         // trivial old->new qid replacements
75870         trees: vals[3].trees,
75871         // metadata about trees, main tags
75872         kvt: /* @__PURE__ */ new Map(),
75873         // Map (k -> Map (v -> t) )
75874         qids: /* @__PURE__ */ new Map(),
75875         // Map (wd/wp tag values -> qids)
75876         ids: /* @__PURE__ */ new Map()
75877         // Map (id -> NSI item)
75878       };
75879       const matcher = _nsi.matcher = new Matcher();
75880       matcher.buildMatchIndex(_nsi.data);
75881       matcher.itemLocation = /* @__PURE__ */ new Map();
75882       matcher.locationSets = /* @__PURE__ */ new Map();
75883       Object.keys(_nsi.data).forEach((tkv) => {
75884         const items = _nsi.data[tkv].items;
75885         if (!Array.isArray(items) || !items.length) return;
75886         items.forEach((item) => {
75887           if (matcher.itemLocation.has(item.id)) return;
75888           const locationSetID = _sharedLocationManager.locationSetID(item.locationSet);
75889           matcher.itemLocation.set(item.id, locationSetID);
75890           if (matcher.locationSets.has(locationSetID)) return;
75891           const fakeFeature = { id: locationSetID, properties: { id: locationSetID, area: 1 } };
75892           matcher.locationSets.set(locationSetID, fakeFeature);
75893         });
75894       });
75895       matcher.locationIndex = (bbox2) => {
75896         const validHere = _sharedLocationManager.locationSetsAt([bbox2[0], bbox2[1]]);
75897         const results = [];
75898         for (const [locationSetID, area] of Object.entries(validHere)) {
75899           const fakeFeature = matcher.locationSets.get(locationSetID);
75900           if (fakeFeature) {
75901             fakeFeature.properties.area = area;
75902             results.push(fakeFeature);
75903           }
75904         }
75905         return results;
75906       };
75907       Object.keys(_nsi.data).forEach((tkv) => {
75908         const category = _nsi.data[tkv];
75909         const parts = tkv.split("/", 3);
75910         const t2 = parts[0];
75911         const k2 = parts[1];
75912         const v2 = parts[2];
75913         let vmap = _nsi.kvt.get(k2);
75914         if (!vmap) {
75915           vmap = /* @__PURE__ */ new Map();
75916           _nsi.kvt.set(k2, vmap);
75917         }
75918         vmap.set(v2, t2);
75919         const tree = _nsi.trees[t2];
75920         const mainTag = tree.mainTag;
75921         const items = category.items || [];
75922         items.forEach((item) => {
75923           item.tkv = tkv;
75924           item.mainTag = mainTag;
75925           _nsi.ids.set(item.id, item);
75926           const wd = item.tags[mainTag];
75927           const wp = item.tags[mainTag.replace("wikidata", "wikipedia")];
75928           if (wd) _nsi.qids.set(wd, wd);
75929           if (wp && wd) _nsi.qids.set(wp, wd);
75930         });
75931       });
75932     });
75933   }
75934   function gatherKVs(tags) {
75935     let primary = /* @__PURE__ */ new Set();
75936     let alternate = /* @__PURE__ */ new Set();
75937     Object.keys(tags).forEach((osmkey) => {
75938       const osmvalue = tags[osmkey];
75939       if (!osmvalue) return;
75940       if (osmkey === "route_master") osmkey = "route";
75941       const vmap = _nsi.kvt.get(osmkey);
75942       if (!vmap) return;
75943       if (vmap.get(osmvalue)) {
75944         primary.add("".concat(osmkey, "/").concat(osmvalue));
75945       } else if (osmvalue === "yes") {
75946         alternate.add("".concat(osmkey, "/").concat(osmvalue));
75947       }
75948     });
75949     const preset = _mainPresetIndex.matchTags(tags, "area");
75950     if (buildingPreset[preset.id]) {
75951       alternate.add("building/yes");
75952     }
75953     return { primary, alternate };
75954   }
75955   function identifyTree(tags) {
75956     let unknown;
75957     let t2;
75958     Object.keys(tags).forEach((osmkey) => {
75959       if (t2) return;
75960       const osmvalue = tags[osmkey];
75961       if (!osmvalue) return;
75962       if (osmkey === "route_master") osmkey = "route";
75963       const vmap = _nsi.kvt.get(osmkey);
75964       if (!vmap) return;
75965       if (osmvalue === "yes") {
75966         unknown = "unknown";
75967       } else {
75968         t2 = vmap.get(osmvalue);
75969       }
75970     });
75971     return t2 || unknown || null;
75972   }
75973   function gatherNames(tags) {
75974     const empty2 = { primary: /* @__PURE__ */ new Set(), alternate: /* @__PURE__ */ new Set() };
75975     let primary = /* @__PURE__ */ new Set();
75976     let alternate = /* @__PURE__ */ new Set();
75977     let foundSemi = false;
75978     let testNameFragments = false;
75979     let patterns2;
75980     let t2 = identifyTree(tags);
75981     if (!t2) return empty2;
75982     if (t2 === "transit") {
75983       patterns2 = {
75984         primary: /^network$/i,
75985         alternate: /^(operator|operator:\w+|network:\w+|\w+_name|\w+_name:\w+)$/i
75986       };
75987     } else if (t2 === "flags") {
75988       patterns2 = {
75989         primary: /^(flag:name|flag:name:\w+)$/i,
75990         alternate: /^(flag|flag:\w+|subject|subject:\w+)$/i
75991         // note: no `country`, we special-case it below
75992       };
75993     } else if (t2 === "brands") {
75994       testNameFragments = true;
75995       patterns2 = {
75996         primary: /^(name|name:\w+)$/i,
75997         alternate: /^(brand|brand:\w+|operator|operator:\w+|\w+_name|\w+_name:\w+)/i
75998       };
75999     } else if (t2 === "operators") {
76000       testNameFragments = true;
76001       patterns2 = {
76002         primary: /^(name|name:\w+|operator|operator:\w+)$/i,
76003         alternate: /^(brand|brand:\w+|\w+_name|\w+_name:\w+)/i
76004       };
76005     } else {
76006       testNameFragments = true;
76007       patterns2 = {
76008         primary: /^(name|name:\w+)$/i,
76009         alternate: /^(brand|brand:\w+|network|network:\w+|operator|operator:\w+|\w+_name|\w+_name:\w+)/i
76010       };
76011     }
76012     if (tags.name && testNameFragments) {
76013       const nameParts = tags.name.split(/[\s\-\/,.]/);
76014       for (let split = nameParts.length; split > 0; split--) {
76015         const name = nameParts.slice(0, split).join(" ");
76016         primary.add(name);
76017       }
76018     }
76019     Object.keys(tags).forEach((osmkey) => {
76020       const osmvalue = tags[osmkey];
76021       if (!osmvalue) return;
76022       if (isNamelike(osmkey, "primary")) {
76023         if (/;/.test(osmvalue)) {
76024           foundSemi = true;
76025         } else {
76026           primary.add(osmvalue);
76027           alternate.delete(osmvalue);
76028         }
76029       } else if (!primary.has(osmvalue) && isNamelike(osmkey, "alternate")) {
76030         if (/;/.test(osmvalue)) {
76031           foundSemi = true;
76032         } else {
76033           alternate.add(osmvalue);
76034         }
76035       }
76036     });
76037     if (tags.man_made === "flagpole" && !primary.size && !alternate.size && !!tags.country) {
76038       const osmvalue = tags.country;
76039       if (/;/.test(osmvalue)) {
76040         foundSemi = true;
76041       } else {
76042         alternate.add(osmvalue);
76043       }
76044     }
76045     if (foundSemi) {
76046       return empty2;
76047     } else {
76048       return { primary, alternate };
76049     }
76050     function isNamelike(osmkey, which) {
76051       if (osmkey === "old_name") return false;
76052       return patterns2[which].test(osmkey) && !notNames.test(osmkey);
76053     }
76054   }
76055   function gatherTuples(tryKVs, tryNames) {
76056     let tuples = [];
76057     ["primary", "alternate"].forEach((whichName) => {
76058       const arr = Array.from(tryNames[whichName]).sort((a2, b2) => b2.length - a2.length);
76059       arr.forEach((n3) => {
76060         ["primary", "alternate"].forEach((whichKV) => {
76061           tryKVs[whichKV].forEach((kv) => {
76062             const parts = kv.split("/", 2);
76063             const k2 = parts[0];
76064             const v2 = parts[1];
76065             tuples.push({ k: k2, v: v2, n: n3 });
76066           });
76067         });
76068       });
76069     });
76070     return tuples;
76071   }
76072   function _upgradeTags(tags, loc) {
76073     let newTags = Object.assign({}, tags);
76074     let changed = false;
76075     Object.keys(newTags).forEach((osmkey) => {
76076       const matchTag = osmkey.match(/^(\w+:)?wikidata$/);
76077       if (matchTag) {
76078         const prefix = matchTag[1] || "";
76079         const wd = newTags[osmkey];
76080         const replace = _nsi.replacements[wd];
76081         if (replace && replace.wikidata !== void 0) {
76082           changed = true;
76083           if (replace.wikidata) {
76084             newTags[osmkey] = replace.wikidata;
76085           } else {
76086             delete newTags[osmkey];
76087           }
76088         }
76089         if (replace && replace.wikipedia !== void 0) {
76090           changed = true;
76091           const wpkey = "".concat(prefix, "wikipedia");
76092           if (replace.wikipedia) {
76093             newTags[wpkey] = replace.wikipedia;
76094           } else {
76095             delete newTags[wpkey];
76096           }
76097         }
76098       }
76099     });
76100     const isRouteMaster = tags.type === "route_master";
76101     const tryKVs = gatherKVs(tags);
76102     if (!tryKVs.primary.size && !tryKVs.alternate.size) {
76103       return changed ? { newTags, matched: null } : null;
76104     }
76105     const tryNames = gatherNames(tags);
76106     const foundQID = _nsi.qids.get(tags.wikidata) || _nsi.qids.get(tags.wikipedia);
76107     if (foundQID) tryNames.primary.add(foundQID);
76108     if (!tryNames.primary.size && !tryNames.alternate.size) {
76109       return changed ? { newTags, matched: null } : null;
76110     }
76111     const tuples = gatherTuples(tryKVs, tryNames);
76112     for (let i3 = 0; i3 < tuples.length; i3++) {
76113       const tuple = tuples[i3];
76114       const hits = _nsi.matcher.match(tuple.k, tuple.v, tuple.n, loc);
76115       if (!hits || !hits.length) continue;
76116       if (hits[0].match !== "primary" && hits[0].match !== "alternate") break;
76117       let itemID, item;
76118       for (let j2 = 0; j2 < hits.length; j2++) {
76119         const hit = hits[j2];
76120         itemID = hit.itemID;
76121         if (_nsi.dissolved[itemID]) continue;
76122         item = _nsi.ids.get(itemID);
76123         if (!item) continue;
76124         const mainTag = item.mainTag;
76125         const itemQID = item.tags[mainTag];
76126         const notQID = newTags["not:".concat(mainTag)];
76127         if (
76128           // Exceptions, skip this hit
76129           !itemQID || itemQID === notQID || // No `*:wikidata` or matched a `not:*:wikidata`
76130           newTags.office && !item.tags.office
76131         ) {
76132           item = null;
76133           continue;
76134         } else {
76135           break;
76136         }
76137       }
76138       if (!item) continue;
76139       item = JSON.parse(JSON.stringify(item));
76140       const tkv = item.tkv;
76141       const parts = tkv.split("/", 3);
76142       const k2 = parts[1];
76143       const v2 = parts[2];
76144       const category = _nsi.data[tkv];
76145       const properties = category.properties || {};
76146       let preserveTags = item.preserveTags || properties.preserveTags || [];
76147       ["building", "emergency", "internet_access", "opening_hours", "takeaway"].forEach((osmkey) => {
76148         if (k2 !== osmkey) preserveTags.push("^".concat(osmkey, "$"));
76149       });
76150       const regexes = preserveTags.map((s2) => new RegExp(s2, "i"));
76151       let keepTags = {};
76152       Object.keys(newTags).forEach((osmkey) => {
76153         if (regexes.some((regex) => regex.test(osmkey))) {
76154           keepTags[osmkey] = newTags[osmkey];
76155         }
76156       });
76157       _nsi.kvt.forEach((vmap, k3) => {
76158         if (newTags[k3] === "yes") delete newTags[k3];
76159       });
76160       if (foundQID) {
76161         delete newTags.wikipedia;
76162         delete newTags.wikidata;
76163       }
76164       Object.assign(newTags, item.tags, keepTags);
76165       if (isRouteMaster) {
76166         newTags.route_master = newTags.route;
76167         delete newTags.route;
76168       }
76169       const origName = tags.name;
76170       const newName = newTags.name;
76171       if (newName && origName && newName !== origName && !newTags.branch) {
76172         const newNames = gatherNames(newTags);
76173         const newSet = /* @__PURE__ */ new Set([...newNames.primary, ...newNames.alternate]);
76174         const isMoved = newSet.has(origName);
76175         if (!isMoved) {
76176           const nameParts = origName.split(/[\s\-\/,.]/);
76177           for (let split = nameParts.length; split > 0; split--) {
76178             const name = nameParts.slice(0, split).join(" ");
76179             const branch = nameParts.slice(split).join(" ");
76180             const nameHits = _nsi.matcher.match(k2, v2, name, loc);
76181             if (!nameHits || !nameHits.length) continue;
76182             if (nameHits.some((hit) => hit.itemID === itemID)) {
76183               if (branch) {
76184                 if (notBranches.test(branch)) {
76185                   newTags.name = origName;
76186                 } else {
76187                   const branchHits = _nsi.matcher.match(k2, v2, branch, loc);
76188                   if (branchHits && branchHits.length) {
76189                     if (branchHits[0].match === "primary" || branchHits[0].match === "alternate") {
76190                       return null;
76191                     }
76192                   } else {
76193                     newTags.branch = branch;
76194                   }
76195                 }
76196               }
76197               break;
76198             }
76199           }
76200         }
76201       }
76202       return { newTags, matched: item };
76203     }
76204     return changed ? { newTags, matched: null } : null;
76205   }
76206   function _isGenericName(tags) {
76207     const n3 = tags.name;
76208     if (!n3) return false;
76209     const tryNames = { primary: /* @__PURE__ */ new Set([n3]), alternate: /* @__PURE__ */ new Set() };
76210     const tryKVs = gatherKVs(tags);
76211     if (!tryKVs.primary.size && !tryKVs.alternate.size) return false;
76212     const tuples = gatherTuples(tryKVs, tryNames);
76213     for (let i3 = 0; i3 < tuples.length; i3++) {
76214       const tuple = tuples[i3];
76215       const hits = _nsi.matcher.match(tuple.k, tuple.v, tuple.n);
76216       if (hits && hits.length && hits[0].match === "excludeGeneric") return true;
76217     }
76218     return false;
76219   }
76220   var nsi_default = {
76221     // `init()`
76222     // On init, start preparing the name-suggestion-index
76223     //
76224     init: () => {
76225       setNsiSources();
76226       _mainPresetIndex.ensureLoaded().then(() => loadNsiPresets()).then(() => loadNsiData()).then(() => _nsiStatus = "ok").catch(() => _nsiStatus = "failed");
76227     },
76228     // `reset()`
76229     // Reset is called when user saves data to OSM (does nothing here)
76230     //
76231     reset: () => {
76232     },
76233     // `status()`
76234     // To let other code know how it's going...
76235     //
76236     // Returns
76237     //   `String`: 'loading', 'ok', 'failed'
76238     //
76239     status: () => _nsiStatus,
76240     // `isGenericName()`
76241     // Is the `name` tag generic?
76242     //
76243     // Arguments
76244     //   `tags`: `Object` containing the feature's OSM tags
76245     // Returns
76246     //   `true` if it is generic, `false` if not
76247     //
76248     isGenericName: (tags) => _isGenericName(tags),
76249     // `upgradeTags()`
76250     // Suggest tag upgrades.
76251     // This function will not modify the input tags, it makes a copy.
76252     //
76253     // Arguments
76254     //   `tags`: `Object` containing the feature's OSM tags
76255     //   `loc`: Location where this feature exists, as a [lon, lat]
76256     // Returns
76257     //   `Object` containing the result, or `null` if no changes needed:
76258     //   {
76259     //     'newTags': `Object` - The tags the the feature should have
76260     //     'matched': `Object` - The matched item
76261     //   }
76262     //
76263     upgradeTags: (tags, loc) => _upgradeTags(tags, loc),
76264     // `cache()`
76265     // Direct access to the NSI cache, useful for testing or breaking things
76266     //
76267     // Returns
76268     //   `Object`: the internal NSI cache
76269     //
76270     cache: () => _nsi
76271   };
76272
76273   // modules/services/kartaview.js
76274   var apibase2 = "https://kartaview.org";
76275   var maxResults = 1e3;
76276   var tileZoom = 14;
76277   var tiler3 = utilTiler().zoomExtent([tileZoom, tileZoom]).skipNullIsland(true);
76278   var dispatch6 = dispatch_default("loadedImages");
76279   var imgZoom2 = zoom_default2().extent([[0, 0], [320, 240]]).translateExtent([[0, 0], [320, 240]]).scaleExtent([1, 15]);
76280   var _oscCache;
76281   var _oscSelectedImage;
76282   var _loadViewerPromise2;
76283   function abortRequest3(controller) {
76284     controller.abort();
76285   }
76286   function maxPageAtZoom(z2) {
76287     if (z2 < 15) return 2;
76288     if (z2 === 15) return 5;
76289     if (z2 === 16) return 10;
76290     if (z2 === 17) return 20;
76291     if (z2 === 18) return 40;
76292     if (z2 > 18) return 80;
76293   }
76294   function loadTiles2(which, url, projection2) {
76295     var currZoom = Math.floor(geoScaleToZoom(projection2.scale()));
76296     var tiles = tiler3.getTiles(projection2);
76297     var cache = _oscCache[which];
76298     Object.keys(cache.inflight).forEach(function(k2) {
76299       var wanted = tiles.find(function(tile) {
76300         return k2.indexOf(tile.id + ",") === 0;
76301       });
76302       if (!wanted) {
76303         abortRequest3(cache.inflight[k2]);
76304         delete cache.inflight[k2];
76305       }
76306     });
76307     tiles.forEach(function(tile) {
76308       loadNextTilePage(which, currZoom, url, tile);
76309     });
76310   }
76311   function loadNextTilePage(which, currZoom, url, tile) {
76312     var cache = _oscCache[which];
76313     var bbox2 = tile.extent.bbox();
76314     var maxPages = maxPageAtZoom(currZoom);
76315     var nextPage = cache.nextPage[tile.id] || 1;
76316     var params = utilQsString({
76317       ipp: maxResults,
76318       page: nextPage,
76319       // client_id: clientId,
76320       bbTopLeft: [bbox2.maxY, bbox2.minX].join(","),
76321       bbBottomRight: [bbox2.minY, bbox2.maxX].join(",")
76322     }, true);
76323     if (nextPage > maxPages) return;
76324     var id2 = tile.id + "," + String(nextPage);
76325     if (cache.loaded[id2] || cache.inflight[id2]) return;
76326     var controller = new AbortController();
76327     cache.inflight[id2] = controller;
76328     var options2 = {
76329       method: "POST",
76330       signal: controller.signal,
76331       body: params,
76332       headers: { "Content-Type": "application/x-www-form-urlencoded" }
76333     };
76334     json_default(url, options2).then(function(data) {
76335       cache.loaded[id2] = true;
76336       delete cache.inflight[id2];
76337       if (!data || !data.currentPageItems || !data.currentPageItems.length) {
76338         throw new Error("No Data");
76339       }
76340       var features = data.currentPageItems.map(function(item) {
76341         var loc = [+item.lng, +item.lat];
76342         var d2;
76343         if (which === "images") {
76344           d2 = {
76345             loc,
76346             key: item.id,
76347             ca: +item.heading,
76348             captured_at: item.shot_date || item.date_added,
76349             captured_by: item.username,
76350             imagePath: item.lth_name,
76351             sequence_id: item.sequence_id,
76352             sequence_index: +item.sequence_index
76353           };
76354           var seq = _oscCache.sequences[d2.sequence_id];
76355           if (!seq) {
76356             seq = { rotation: 0, images: [] };
76357             _oscCache.sequences[d2.sequence_id] = seq;
76358           }
76359           seq.images[d2.sequence_index] = d2;
76360           _oscCache.images.forImageKey[d2.key] = d2;
76361         }
76362         return {
76363           minX: loc[0],
76364           minY: loc[1],
76365           maxX: loc[0],
76366           maxY: loc[1],
76367           data: d2
76368         };
76369       });
76370       cache.rtree.load(features);
76371       if (data.currentPageItems.length === maxResults) {
76372         cache.nextPage[tile.id] = nextPage + 1;
76373         loadNextTilePage(which, currZoom, url, tile);
76374       } else {
76375         cache.nextPage[tile.id] = Infinity;
76376       }
76377       if (which === "images") {
76378         dispatch6.call("loadedImages");
76379       }
76380     }).catch(function() {
76381       cache.loaded[id2] = true;
76382       delete cache.inflight[id2];
76383     });
76384   }
76385   function partitionViewport2(projection2) {
76386     var z2 = geoScaleToZoom(projection2.scale());
76387     var z22 = Math.ceil(z2 * 2) / 2 + 2.5;
76388     var tiler8 = utilTiler().zoomExtent([z22, z22]);
76389     return tiler8.getTiles(projection2).map(function(tile) {
76390       return tile.extent;
76391     });
76392   }
76393   function searchLimited2(limit, projection2, rtree) {
76394     limit = limit || 5;
76395     return partitionViewport2(projection2).reduce(function(result, extent) {
76396       var found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
76397         return d2.data;
76398       });
76399       return found.length ? result.concat(found) : result;
76400     }, []);
76401   }
76402   var kartaview_default = {
76403     init: function() {
76404       if (!_oscCache) {
76405         this.reset();
76406       }
76407       this.event = utilRebind(this, dispatch6, "on");
76408     },
76409     reset: function() {
76410       if (_oscCache) {
76411         Object.values(_oscCache.images.inflight).forEach(abortRequest3);
76412       }
76413       _oscCache = {
76414         images: { inflight: {}, loaded: {}, nextPage: {}, rtree: new RBush(), forImageKey: {} },
76415         sequences: {}
76416       };
76417       _oscSelectedImage = null;
76418     },
76419     images: function(projection2) {
76420       var limit = 5;
76421       return searchLimited2(limit, projection2, _oscCache.images.rtree);
76422     },
76423     sequences: function(projection2) {
76424       var viewport = projection2.clipExtent();
76425       var min3 = [viewport[0][0], viewport[1][1]];
76426       var max3 = [viewport[1][0], viewport[0][1]];
76427       var bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
76428       var sequenceKeys = {};
76429       _oscCache.images.rtree.search(bbox2).forEach(function(d2) {
76430         sequenceKeys[d2.data.sequence_id] = true;
76431       });
76432       var lineStrings = [];
76433       Object.keys(sequenceKeys).forEach(function(sequenceKey) {
76434         var seq = _oscCache.sequences[sequenceKey];
76435         var images = seq && seq.images;
76436         if (images) {
76437           lineStrings.push({
76438             type: "LineString",
76439             coordinates: images.map(function(d2) {
76440               return d2.loc;
76441             }).filter(Boolean),
76442             properties: {
76443               captured_at: images[0] ? images[0].captured_at : null,
76444               captured_by: images[0] ? images[0].captured_by : null,
76445               key: sequenceKey
76446             }
76447           });
76448         }
76449       });
76450       return lineStrings;
76451     },
76452     cachedImage: function(imageKey) {
76453       return _oscCache.images.forImageKey[imageKey];
76454     },
76455     loadImages: function(projection2) {
76456       var url = apibase2 + "/1.0/list/nearby-photos/";
76457       loadTiles2("images", url, projection2);
76458     },
76459     ensureViewerLoaded: function(context) {
76460       if (_loadViewerPromise2) return _loadViewerPromise2;
76461       var wrap2 = context.container().select(".photoviewer").selectAll(".kartaview-wrapper").data([0]);
76462       var that = this;
76463       var wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper kartaview-wrapper").classed("hide", true).call(imgZoom2.on("zoom", zoomPan2)).on("dblclick.zoom", null);
76464       wrapEnter.append("div").attr("class", "photo-attribution fillD");
76465       var controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
76466       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
76467       controlsEnter.append("button").on("click.rotate-ccw", rotate(-90)).text("\u293F");
76468       controlsEnter.append("button").on("click.rotate-cw", rotate(90)).text("\u293E");
76469       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
76470       wrapEnter.append("div").attr("class", "kartaview-image-wrap");
76471       context.ui().photoviewer.on("resize.kartaview", function(dimensions) {
76472         imgZoom2.extent([[0, 0], dimensions]).translateExtent([[0, 0], dimensions]);
76473       });
76474       function zoomPan2(d3_event) {
76475         var t2 = d3_event.transform;
76476         context.container().select(".photoviewer .kartaview-image-wrap").call(utilSetTransform, t2.x, t2.y, t2.k);
76477       }
76478       function rotate(deg) {
76479         return function() {
76480           if (!_oscSelectedImage) return;
76481           var sequenceKey = _oscSelectedImage.sequence_id;
76482           var sequence = _oscCache.sequences[sequenceKey];
76483           if (!sequence) return;
76484           var r2 = sequence.rotation || 0;
76485           r2 += deg;
76486           if (r2 > 180) r2 -= 360;
76487           if (r2 < -180) r2 += 360;
76488           sequence.rotation = r2;
76489           var wrap3 = context.container().select(".photoviewer .kartaview-wrapper");
76490           wrap3.transition().duration(100).call(imgZoom2.transform, identity2);
76491           wrap3.selectAll(".kartaview-image").transition().duration(100).style("transform", "rotate(" + r2 + "deg)");
76492         };
76493       }
76494       function step(stepBy) {
76495         return function() {
76496           if (!_oscSelectedImage) return;
76497           var sequenceKey = _oscSelectedImage.sequence_id;
76498           var sequence = _oscCache.sequences[sequenceKey];
76499           if (!sequence) return;
76500           var nextIndex = _oscSelectedImage.sequence_index + stepBy;
76501           var nextImage = sequence.images[nextIndex];
76502           if (!nextImage) return;
76503           context.map().centerEase(nextImage.loc);
76504           that.selectImage(context, nextImage.key);
76505         };
76506       }
76507       _loadViewerPromise2 = Promise.resolve();
76508       return _loadViewerPromise2;
76509     },
76510     showViewer: function(context) {
76511       var viewer = context.container().select(".photoviewer").classed("hide", false);
76512       var isHidden = viewer.selectAll(".photo-wrapper.kartaview-wrapper.hide").size();
76513       if (isHidden) {
76514         viewer.selectAll(".photo-wrapper:not(.kartaview-wrapper)").classed("hide", true);
76515         viewer.selectAll(".photo-wrapper.kartaview-wrapper").classed("hide", false);
76516       }
76517       return this;
76518     },
76519     hideViewer: function(context) {
76520       _oscSelectedImage = null;
76521       this.updateUrlImage(null);
76522       var viewer = context.container().select(".photoviewer");
76523       if (!viewer.empty()) viewer.datum(null);
76524       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
76525       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
76526       return this.setStyles(context, null, true);
76527     },
76528     selectImage: function(context, imageKey) {
76529       var d2 = this.cachedImage(imageKey);
76530       _oscSelectedImage = d2;
76531       this.updateUrlImage(imageKey);
76532       var viewer = context.container().select(".photoviewer");
76533       if (!viewer.empty()) viewer.datum(d2);
76534       this.setStyles(context, null, true);
76535       context.container().selectAll(".icon-sign").classed("currentView", false);
76536       if (!d2) return this;
76537       var wrap2 = context.container().select(".photoviewer .kartaview-wrapper");
76538       var imageWrap = wrap2.selectAll(".kartaview-image-wrap");
76539       var attribution = wrap2.selectAll(".photo-attribution").text("");
76540       wrap2.transition().duration(100).call(imgZoom2.transform, identity2);
76541       imageWrap.selectAll(".kartaview-image").remove();
76542       if (d2) {
76543         var sequence = _oscCache.sequences[d2.sequence_id];
76544         var r2 = sequence && sequence.rotation || 0;
76545         imageWrap.append("img").attr("class", "kartaview-image").attr("src", apibase2 + "/" + d2.imagePath).style("transform", "rotate(" + r2 + "deg)");
76546         if (d2.captured_by) {
76547           attribution.append("a").attr("class", "captured_by").attr("target", "_blank").attr("href", "https://kartaview.org/user/" + encodeURIComponent(d2.captured_by)).text("@" + d2.captured_by);
76548           attribution.append("span").text("|");
76549         }
76550         if (d2.captured_at) {
76551           attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.captured_at));
76552           attribution.append("span").text("|");
76553         }
76554         attribution.append("a").attr("class", "image-link").attr("target", "_blank").attr("href", "https://kartaview.org/details/" + d2.sequence_id + "/" + d2.sequence_index).text("kartaview.org");
76555       }
76556       return this;
76557       function localeDateString2(s2) {
76558         if (!s2) return null;
76559         var options2 = { day: "numeric", month: "short", year: "numeric" };
76560         var d4 = new Date(s2);
76561         if (isNaN(d4.getTime())) return null;
76562         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
76563       }
76564     },
76565     getSelectedImage: function() {
76566       return _oscSelectedImage;
76567     },
76568     getSequenceKeyForImage: function(d2) {
76569       return d2 && d2.sequence_id;
76570     },
76571     // Updates the currently highlighted sequence and selected bubble.
76572     // Reset is only necessary when interacting with the viewport because
76573     // this implicitly changes the currently selected bubble/sequence
76574     setStyles: function(context, hovered, reset) {
76575       if (reset) {
76576         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
76577         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
76578       }
76579       var hoveredImageId = hovered && hovered.key;
76580       var hoveredSequenceId = this.getSequenceKeyForImage(hovered);
76581       var viewer = context.container().select(".photoviewer");
76582       var selected = viewer.empty() ? void 0 : viewer.datum();
76583       var selectedImageId = selected && selected.key;
76584       var selectedSequenceId = this.getSequenceKeyForImage(selected);
76585       context.container().selectAll(".layer-kartaview .viewfield-group").classed("highlighted", function(d2) {
76586         return d2.sequence_id === selectedSequenceId || d2.id === hoveredImageId;
76587       }).classed("hovered", function(d2) {
76588         return d2.key === hoveredImageId;
76589       }).classed("currentView", function(d2) {
76590         return d2.key === selectedImageId;
76591       });
76592       context.container().selectAll(".layer-kartaview .sequence").classed("highlighted", function(d2) {
76593         return d2.properties.key === hoveredSequenceId;
76594       }).classed("currentView", function(d2) {
76595         return d2.properties.key === selectedSequenceId;
76596       });
76597       context.container().selectAll(".layer-kartaview .viewfield-group .viewfield").attr("d", viewfieldPath);
76598       function viewfieldPath() {
76599         var d2 = this.parentNode.__data__;
76600         if (d2.pano && d2.key !== selectedImageId) {
76601           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
76602         } else {
76603           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
76604         }
76605       }
76606       return this;
76607     },
76608     updateUrlImage: function(imageKey) {
76609       if (!window.mocha) {
76610         var hash2 = utilStringQs(window.location.hash);
76611         if (imageKey) {
76612           hash2.photo = "kartaview/" + imageKey;
76613         } else {
76614           delete hash2.photo;
76615         }
76616         window.location.replace("#" + utilQsString(hash2, true));
76617       }
76618     },
76619     cache: function() {
76620       return _oscCache;
76621     }
76622   };
76623
76624   // modules/services/pannellum_photo.js
76625   var pannellumViewerCSS = "pannellum/pannellum.css";
76626   var pannellumViewerJS = "pannellum/pannellum.js";
76627   var dispatch7 = dispatch_default("viewerChanged");
76628   var _currScenes = [];
76629   var _pannellumViewer;
76630   var pannellum_photo_default = {
76631     init: async function(context, selection2) {
76632       selection2.append("div").attr("class", "photo-frame pannellum-frame").attr("id", "ideditor-pannellum-viewer").classed("hide", true).on("keydown", function(e3) {
76633         e3.stopPropagation();
76634       });
76635       if (!window.pannellum) {
76636         await this.loadPannellum(context);
76637       }
76638       const options2 = {
76639         "default": { firstScene: "" },
76640         scenes: {},
76641         minHfov: 20
76642       };
76643       _pannellumViewer = window.pannellum.viewer("ideditor-pannellum-viewer", options2);
76644       _pannellumViewer.on("mousedown", () => {
76645         select_default2(window).on("pointermove.pannellum mousemove.pannellum", () => {
76646           dispatch7.call("viewerChanged");
76647         });
76648       }).on("mouseup", () => {
76649         select_default2(window).on("pointermove.pannellum mousemove.pannellum", null);
76650       }).on("animatefinished", () => {
76651         dispatch7.call("viewerChanged");
76652       });
76653       context.ui().photoviewer.on("resize.pannellum", () => {
76654         _pannellumViewer.resize();
76655       });
76656       this.event = utilRebind(this, dispatch7, "on");
76657       return this;
76658     },
76659     loadPannellum: function(context) {
76660       const head = select_default2("head");
76661       return Promise.all([
76662         new Promise((resolve, reject) => {
76663           head.selectAll("#ideditor-pannellum-viewercss").data([0]).enter().append("link").attr("id", "ideditor-pannellum-viewercss").attr("rel", "stylesheet").attr("crossorigin", "anonymous").attr("href", context.asset(pannellumViewerCSS)).on("load.pannellum", resolve).on("error.pannellum", reject);
76664         }),
76665         new Promise((resolve, reject) => {
76666           head.selectAll("#ideditor-pannellum-viewerjs").data([0]).enter().append("script").attr("id", "ideditor-pannellum-viewerjs").attr("crossorigin", "anonymous").attr("src", context.asset(pannellumViewerJS)).on("load.pannellum", resolve).on("error.pannellum", reject);
76667         })
76668       ]);
76669     },
76670     showPhotoFrame: function(context) {
76671       const isHidden = context.selectAll(".photo-frame.pannellum-frame.hide").size();
76672       if (isHidden) {
76673         context.selectAll(".photo-frame:not(.pannellum-frame)").classed("hide", true);
76674         context.selectAll(".photo-frame.pannellum-frame").classed("hide", false);
76675       }
76676       return this;
76677     },
76678     hidePhotoFrame: function(viewerContext) {
76679       viewerContext.select("photo-frame.pannellum-frame").classed("hide", false);
76680       return this;
76681     },
76682     selectPhoto: function(data, keepOrientation) {
76683       const { key } = data;
76684       if (!(key in _currScenes)) {
76685         let newSceneOptions = {
76686           showFullscreenCtrl: false,
76687           autoLoad: false,
76688           compass: false,
76689           yaw: 0,
76690           type: "equirectangular",
76691           preview: data.preview_path,
76692           panorama: data.image_path,
76693           northOffset: data.ca
76694         };
76695         _currScenes.push(key);
76696         _pannellumViewer.addScene(key, newSceneOptions);
76697       }
76698       let yaw = 0;
76699       let pitch = 0;
76700       if (keepOrientation) {
76701         yaw = this.getYaw();
76702         pitch = _pannellumViewer.getPitch();
76703       }
76704       _pannellumViewer.loadScene(key, pitch, yaw);
76705       dispatch7.call("viewerChanged");
76706       if (_currScenes.length > 3) {
76707         const old_key = _currScenes.shift();
76708         _pannellumViewer.removeScene(old_key);
76709       }
76710       _pannellumViewer.resize();
76711       return this;
76712     },
76713     getYaw: function() {
76714       return _pannellumViewer.getYaw();
76715     }
76716   };
76717
76718   // modules/services/vegbilder.js
76719   var owsEndpoint = "https://www.vegvesen.no/kart/ogc/vegbilder_1_0/ows?";
76720   var tileZoom2 = 14;
76721   var tiler4 = utilTiler().zoomExtent([tileZoom2, tileZoom2]).skipNullIsland(true);
76722   var dispatch8 = dispatch_default("loadedImages", "viewerChanged");
76723   var directionEnum = Object.freeze({
76724     forward: Symbol(0),
76725     backward: Symbol(1)
76726   });
76727   var _planeFrame;
76728   var _pannellumFrame;
76729   var _currentFrame;
76730   var _loadViewerPromise3;
76731   var _vegbilderCache;
76732   async function fetchAvailableLayers() {
76733     var _a4, _b3, _c2;
76734     const params = {
76735       service: "WFS",
76736       request: "GetCapabilities",
76737       version: "2.0.0"
76738     };
76739     const urlForRequest = owsEndpoint + utilQsString(params);
76740     const response = await xml_default(urlForRequest);
76741     const regexMatcher = new RegExp("^vegbilder_1_0:Vegbilder(?<image_type>_360)?_(?<year>\\d{4})$");
76742     const availableLayers = [];
76743     for (const node of response.querySelectorAll("FeatureType > Name")) {
76744       const match = (_a4 = node.textContent) == null ? void 0 : _a4.match(regexMatcher);
76745       if (match) {
76746         availableLayers.push({
76747           name: match[0],
76748           is_sphere: !!((_b3 = match.groups) == null ? void 0 : _b3.image_type),
76749           year: parseInt((_c2 = match.groups) == null ? void 0 : _c2.year, 10)
76750         });
76751       }
76752     }
76753     return availableLayers;
76754   }
76755   function filterAvailableLayers(photoContex) {
76756     const fromDateString = photoContex.fromDate();
76757     const toDateString = photoContex.toDate();
76758     const fromYear = fromDateString ? new Date(fromDateString).getFullYear() : 2016;
76759     const toYear = toDateString ? new Date(toDateString).getFullYear() : null;
76760     const showsFlat = photoContex.showsFlat();
76761     const showsPano = photoContex.showsPanoramic();
76762     return Array.from(_vegbilderCache.wfslayers.values()).filter(({ layerInfo }) => layerInfo.year >= fromYear && (!toYear || layerInfo.year <= toYear) && (!layerInfo.is_sphere && showsFlat || layerInfo.is_sphere && showsPano));
76763   }
76764   function loadWFSLayers(projection2, margin, wfslayers) {
76765     const tiles = tiler4.margin(margin).getTiles(projection2);
76766     for (const cache of wfslayers) {
76767       loadWFSLayer(projection2, cache, tiles);
76768     }
76769   }
76770   function loadWFSLayer(projection2, cache, tiles) {
76771     for (const [key, controller] of cache.inflight.entries()) {
76772       const wanted = tiles.some((tile) => key === tile.id);
76773       if (!wanted) {
76774         controller.abort();
76775         cache.inflight.delete(key);
76776       }
76777     }
76778     Promise.all(tiles.map(
76779       (tile) => loadTile2(cache, cache.layerInfo.name, tile)
76780     )).then(() => orderSequences(projection2, cache));
76781   }
76782   async function loadTile2(cache, typename, tile) {
76783     const bbox2 = tile.extent.bbox();
76784     const tileid = tile.id;
76785     if (cache.loaded.get(tileid) === true || cache.inflight.has(tileid)) return;
76786     const params = {
76787       service: "WFS",
76788       request: "GetFeature",
76789       version: "2.0.0",
76790       typenames: typename,
76791       bbox: [bbox2.minY, bbox2.minX, bbox2.maxY, bbox2.maxX].join(","),
76792       outputFormat: "json"
76793     };
76794     const controller = new AbortController();
76795     cache.inflight.set(tileid, controller);
76796     const options2 = {
76797       method: "GET",
76798       signal: controller.signal
76799     };
76800     const urlForRequest = owsEndpoint + utilQsString(params);
76801     let featureCollection;
76802     try {
76803       featureCollection = await json_default(urlForRequest, options2);
76804     } catch (e3) {
76805       cache.loaded.set(tileid, false);
76806       return;
76807     } finally {
76808       cache.inflight.delete(tileid);
76809     }
76810     cache.loaded.set(tileid, true);
76811     if (featureCollection.features.length === 0) {
76812       return;
76813     }
76814     const features = featureCollection.features.map((feature3) => {
76815       const loc = feature3.geometry.coordinates;
76816       const key = feature3.id;
76817       const properties = feature3.properties;
76818       const {
76819         RETNING: ca,
76820         TIDSPUNKT: captured_at,
76821         URL: image_path,
76822         URLPREVIEW: preview_path,
76823         BILDETYPE: image_type,
76824         METER: metering,
76825         FELTKODE: lane_code
76826       } = properties;
76827       const lane_number = parseInt(lane_code.match(/^[0-9]+/)[0], 10);
76828       const direction = lane_number % 2 === 0 ? directionEnum.backward : directionEnum.forward;
76829       const data = {
76830         loc,
76831         key,
76832         ca,
76833         image_path,
76834         preview_path,
76835         road_reference: roadReference(properties),
76836         metering,
76837         lane_code,
76838         direction,
76839         captured_at: new Date(captured_at),
76840         is_sphere: image_type === "360"
76841       };
76842       cache.points.set(key, data);
76843       return {
76844         minX: loc[0],
76845         minY: loc[1],
76846         maxX: loc[0],
76847         maxY: loc[1],
76848         data
76849       };
76850     });
76851     _vegbilderCache.rtree.load(features);
76852     dispatch8.call("loadedImages");
76853   }
76854   function orderSequences(projection2, cache) {
76855     const { points } = cache;
76856     const grouped = Array.from(points.values()).reduce((grouped2, image) => {
76857       const key = image.road_reference;
76858       if (grouped2.has(key)) {
76859         grouped2.get(key).push(image);
76860       } else {
76861         grouped2.set(key, [image]);
76862       }
76863       return grouped2;
76864     }, /* @__PURE__ */ new Map());
76865     const imageSequences = Array.from(grouped.values()).reduce((imageSequences2, imageGroup) => {
76866       imageGroup.sort((a2, b2) => {
76867         if (a2.captured_at.valueOf() > b2.captured_at.valueOf()) {
76868           return 1;
76869         } else if (a2.captured_at.valueOf() < b2.captured_at.valueOf()) {
76870           return -1;
76871         } else {
76872           const { direction } = a2;
76873           if (direction === directionEnum.forward) {
76874             return a2.metering - b2.metering;
76875           } else {
76876             return b2.metering - a2.metering;
76877           }
76878         }
76879       });
76880       let imageSequence = [imageGroup[0]];
76881       let angle2 = null;
76882       for (const [lastImage, image] of pairs(imageGroup)) {
76883         if (lastImage.ca === null) {
76884           const b2 = projection2(lastImage.loc);
76885           const a2 = projection2(image.loc);
76886           if (!geoVecEqual(a2, b2)) {
76887             angle2 = geoVecAngle(a2, b2);
76888             angle2 *= 180 / Math.PI;
76889             angle2 -= 90;
76890             angle2 = angle2 >= 0 ? angle2 : angle2 + 360;
76891           }
76892           lastImage.ca = angle2;
76893         }
76894         if (image.direction === lastImage.direction && image.captured_at.valueOf() - lastImage.captured_at.valueOf() <= 2e4) {
76895           imageSequence.push(image);
76896         } else {
76897           imageSequences2.push(imageSequence);
76898           imageSequence = [image];
76899         }
76900       }
76901       imageSequences2.push(imageSequence);
76902       return imageSequences2;
76903     }, []);
76904     cache.sequences = imageSequences.map((images) => {
76905       const sequence = {
76906         images,
76907         key: images[0].key,
76908         geometry: {
76909           type: "LineString",
76910           coordinates: images.map((image) => image.loc)
76911         }
76912       };
76913       for (const image of images) {
76914         _vegbilderCache.image2sequence_map.set(image.key, sequence);
76915       }
76916       return sequence;
76917     });
76918   }
76919   function roadReference(properties) {
76920     const {
76921       FYLKENUMMER: county_number,
76922       VEGKATEGORI: road_class,
76923       VEGSTATUS: road_status,
76924       VEGNUMMER: road_number,
76925       STREKNING: section,
76926       DELSTREKNING: subsection,
76927       HP: parcel,
76928       KRYSSDEL: junction_part,
76929       SIDEANLEGGSDEL: services_part,
76930       ANKERPUNKT: anker_point,
76931       AAR: year
76932     } = properties;
76933     let reference;
76934     if (year >= 2020) {
76935       reference = "".concat(road_class).concat(road_status).concat(road_number, " S").concat(section, "D").concat(subsection);
76936       if (junction_part) {
76937         reference = "".concat(reference, " M").concat(anker_point, " KD").concat(junction_part);
76938       } else if (services_part) {
76939         reference = "".concat(reference, " M").concat(anker_point, " SD").concat(services_part);
76940       }
76941     } else {
76942       reference = "".concat(county_number).concat(road_class).concat(road_status).concat(road_number, " HP").concat(parcel);
76943     }
76944     return reference;
76945   }
76946   function localeTimestamp(date) {
76947     const options2 = {
76948       day: "2-digit",
76949       month: "2-digit",
76950       year: "numeric",
76951       hour: "numeric",
76952       minute: "numeric",
76953       second: "numeric"
76954     };
76955     return date.toLocaleString(_mainLocalizer.localeCode(), options2);
76956   }
76957   function partitionViewport3(projection2) {
76958     const zoom = geoScaleToZoom(projection2.scale());
76959     const roundZoom = Math.ceil(zoom * 2) / 2 + 2.5;
76960     const tiler8 = utilTiler().zoomExtent([roundZoom, roundZoom]);
76961     return tiler8.getTiles(projection2).map((tile) => tile.extent);
76962   }
76963   function searchLimited3(limit, projection2, rtree) {
76964     limit != null ? limit : limit = 5;
76965     return partitionViewport3(projection2).reduce((result, extent) => {
76966       const found = rtree.search(extent.bbox()).slice(0, limit).map((d2) => d2.data);
76967       return result.concat(found);
76968     }, []);
76969   }
76970   var vegbilder_default = {
76971     init: function() {
76972       this.event = utilRebind(this, dispatch8, "on");
76973     },
76974     reset: async function() {
76975       if (_vegbilderCache) {
76976         for (const layer of _vegbilderCache.wfslayers.values()) {
76977           for (const controller of layer.inflight.values()) {
76978             controller.abort();
76979           }
76980         }
76981       }
76982       _vegbilderCache = {
76983         wfslayers: /* @__PURE__ */ new Map(),
76984         rtree: new RBush(),
76985         image2sequence_map: /* @__PURE__ */ new Map()
76986       };
76987       const availableLayers = await fetchAvailableLayers();
76988       const { wfslayers } = _vegbilderCache;
76989       for (const layerInfo of availableLayers) {
76990         const cache = {
76991           layerInfo,
76992           loaded: /* @__PURE__ */ new Map(),
76993           inflight: /* @__PURE__ */ new Map(),
76994           points: /* @__PURE__ */ new Map(),
76995           sequences: []
76996         };
76997         wfslayers.set(layerInfo.name, cache);
76998       }
76999     },
77000     images: function(projection2) {
77001       const limit = 5;
77002       return searchLimited3(limit, projection2, _vegbilderCache.rtree);
77003     },
77004     sequences: function(projection2) {
77005       const viewport = projection2.clipExtent();
77006       const min3 = [viewport[0][0], viewport[1][1]];
77007       const max3 = [viewport[1][0], viewport[0][1]];
77008       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
77009       const seen = /* @__PURE__ */ new Set();
77010       const line_strings = [];
77011       for (const { data } of _vegbilderCache.rtree.search(bbox2)) {
77012         const sequence = _vegbilderCache.image2sequence_map.get(data.key);
77013         if (!sequence) continue;
77014         const { key, geometry, images } = sequence;
77015         if (seen.has(key)) continue;
77016         seen.add(key);
77017         const line = {
77018           type: "LineString",
77019           coordinates: geometry.coordinates,
77020           key,
77021           images
77022         };
77023         line_strings.push(line);
77024       }
77025       return line_strings;
77026     },
77027     cachedImage: function(key) {
77028       for (const { points } of _vegbilderCache.wfslayers.values()) {
77029         if (points.has(key)) return points.get(key);
77030       }
77031     },
77032     getSequenceForImage: function(image) {
77033       return _vegbilderCache == null ? void 0 : _vegbilderCache.image2sequence_map.get(image == null ? void 0 : image.key);
77034     },
77035     loadImages: async function(context, margin) {
77036       if (!_vegbilderCache) {
77037         await this.reset();
77038       }
77039       margin != null ? margin : margin = 1;
77040       const wfslayers = filterAvailableLayers(context.photos());
77041       loadWFSLayers(context.projection, margin, wfslayers);
77042     },
77043     photoFrame: function() {
77044       return _currentFrame;
77045     },
77046     ensureViewerLoaded: function(context) {
77047       if (_loadViewerPromise3) return _loadViewerPromise3;
77048       const step = (stepBy) => () => {
77049         const viewer = context.container().select(".photoviewer");
77050         const selected = viewer.empty() ? void 0 : viewer.datum();
77051         if (!selected) return;
77052         const sequence = this.getSequenceForImage(selected);
77053         const nextIndex = sequence.images.indexOf(selected) + stepBy;
77054         const nextImage = sequence.images[nextIndex];
77055         if (!nextImage) return;
77056         context.map().centerEase(nextImage.loc);
77057         this.selectImage(context, nextImage.key, true);
77058       };
77059       const wrap2 = context.container().select(".photoviewer").selectAll(".vegbilder-wrapper").data([0]);
77060       const wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper vegbilder-wrapper").classed("hide", true);
77061       wrapEnter.append("div").attr("class", "photo-attribution fillD");
77062       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
77063       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
77064       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
77065       _loadViewerPromise3 = Promise.all([
77066         pannellum_photo_default.init(context, wrapEnter),
77067         plane_photo_default.init(context, wrapEnter)
77068       ]).then(([pannellumPhotoFrame, planePhotoFrame]) => {
77069         _pannellumFrame = pannellumPhotoFrame;
77070         _pannellumFrame.event.on("viewerChanged", () => dispatch8.call("viewerChanged"));
77071         _planeFrame = planePhotoFrame;
77072         _planeFrame.event.on("viewerChanged", () => dispatch8.call("viewerChanged"));
77073       });
77074       return _loadViewerPromise3;
77075     },
77076     selectImage: function(context, key, keepOrientation) {
77077       const d2 = this.cachedImage(key);
77078       this.updateUrlImage(key);
77079       const viewer = context.container().select(".photoviewer");
77080       if (!viewer.empty()) {
77081         viewer.datum(d2);
77082       }
77083       this.setStyles(context, null, true);
77084       if (!d2) return this;
77085       const wrap2 = context.container().select(".photoviewer .vegbilder-wrapper");
77086       const attribution = wrap2.selectAll(".photo-attribution").text("");
77087       if (d2.captured_at) {
77088         attribution.append("span").attr("class", "captured_at").text(localeTimestamp(d2.captured_at));
77089       }
77090       attribution.append("a").attr("target", "_blank").attr("href", "https://vegvesen.no").call(_t.append("vegbilder.publisher"));
77091       attribution.append("a").attr("target", "_blank").attr("href", "https://vegbilder.atlas.vegvesen.no/?year=".concat(d2.captured_at.getFullYear(), "&lat=").concat(d2.loc[1], "&lng=").concat(d2.loc[0], "&view=image&imageId=").concat(d2.key)).call(_t.append("vegbilder.view_on"));
77092       _currentFrame = d2.is_sphere ? _pannellumFrame : _planeFrame;
77093       _currentFrame.selectPhoto(d2, keepOrientation).showPhotoFrame(wrap2);
77094       return this;
77095     },
77096     showViewer: function(context) {
77097       const viewer = context.container().select(".photoviewer").classed("hide", false);
77098       const isHidden = viewer.selectAll(".photo-wrapper.vegbilder-wrapper.hide").size();
77099       if (isHidden) {
77100         viewer.selectAll(".photo-wrapper:not(.vegbilder-wrapper)").classed("hide", true);
77101         viewer.selectAll(".photo-wrapper.vegbilder-wrapper").classed("hide", false);
77102       }
77103       return this;
77104     },
77105     hideViewer: function(context) {
77106       this.updateUrlImage(null);
77107       const viewer = context.container().select(".photoviewer");
77108       if (!viewer.empty()) viewer.datum(null);
77109       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
77110       context.container().selectAll(".viewfield-group, .sequence").classed("currentView", false);
77111       return this.setStyles(context, null, true);
77112     },
77113     // Updates the currently highlighted sequence and selected bubble.
77114     // Reset is only necessary when interacting with the viewport because
77115     // this implicitly changes the currently selected bubble/sequence
77116     setStyles: function(context, hovered, reset) {
77117       var _a4, _b3;
77118       if (reset) {
77119         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
77120         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
77121       }
77122       const hoveredImageKey = hovered == null ? void 0 : hovered.key;
77123       const hoveredSequence = this.getSequenceForImage(hovered);
77124       const hoveredSequenceKey = hoveredSequence == null ? void 0 : hoveredSequence.key;
77125       const hoveredImageKeys = (_a4 = hoveredSequence == null ? void 0 : hoveredSequence.images.map((d2) => d2.key)) != null ? _a4 : [];
77126       const viewer = context.container().select(".photoviewer");
77127       const selected = viewer.empty() ? void 0 : viewer.datum();
77128       const selectedImageKey = selected == null ? void 0 : selected.key;
77129       const selectedSequence = this.getSequenceForImage(selected);
77130       const selectedSequenceKey = selectedSequence == null ? void 0 : selectedSequence.key;
77131       const selectedImageKeys = (_b3 = selectedSequence == null ? void 0 : selectedSequence.images.map((d2) => d2.key)) != null ? _b3 : [];
77132       const highlightedImageKeys = utilArrayUnion(hoveredImageKeys, selectedImageKeys);
77133       context.container().selectAll(".layer-vegbilder .viewfield-group").classed("highlighted", (d2) => highlightedImageKeys.indexOf(d2.key) !== -1).classed("hovered", (d2) => d2.key === hoveredImageKey).classed("currentView", (d2) => d2.key === selectedImageKey);
77134       context.container().selectAll(".layer-vegbilder .sequence").classed("highlighted", (d2) => d2.key === hoveredSequenceKey).classed("currentView", (d2) => d2.key === selectedSequenceKey);
77135       context.container().selectAll(".layer-vegbilder .viewfield-group .viewfield").attr("d", viewfieldPath);
77136       function viewfieldPath() {
77137         const d2 = this.parentNode.__data__;
77138         if (d2.is_sphere && d2.key !== selectedImageKey) {
77139           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
77140         } else {
77141           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
77142         }
77143       }
77144       return this;
77145     },
77146     updateUrlImage: function(key) {
77147       if (!window.mocha) {
77148         const hash2 = utilStringQs(window.location.hash);
77149         if (key) {
77150           hash2.photo = "vegbilder/" + key;
77151         } else {
77152           delete hash2.photo;
77153         }
77154         window.location.replace("#" + utilQsString(hash2, true));
77155       }
77156     },
77157     validHere: function(extent) {
77158       const bbox2 = Object.values(extent.bbox());
77159       return iso1A2Codes(bbox2).includes("NO");
77160     },
77161     cache: function() {
77162       return _vegbilderCache;
77163     }
77164   };
77165
77166   // node_modules/osm-auth/src/osm-auth.mjs
77167   function osmAuth(o2) {
77168     var oauth2 = {};
77169     var _store = null;
77170     try {
77171       _store = window.localStorage;
77172     } catch (e3) {
77173       var _mock = /* @__PURE__ */ new Map();
77174       _store = {
77175         isMocked: true,
77176         hasItem: (k2) => _mock.has(k2),
77177         getItem: (k2) => _mock.get(k2),
77178         setItem: (k2, v2) => _mock.set(k2, v2),
77179         removeItem: (k2) => _mock.delete(k2),
77180         clear: () => _mock.clear()
77181       };
77182     }
77183     function token(k2, v2) {
77184       var key = o2.url + k2;
77185       if (arguments.length === 1) {
77186         var val = _store.getItem(key) || "";
77187         return val.replace(/"/g, "");
77188       } else if (arguments.length === 2) {
77189         if (v2) {
77190           return _store.setItem(key, v2);
77191         } else {
77192           return _store.removeItem(key);
77193         }
77194       }
77195     }
77196     oauth2.authenticated = function() {
77197       return !!token("oauth2_access_token");
77198     };
77199     oauth2.logout = function() {
77200       token("oauth2_access_token", "");
77201       token("oauth_token", "");
77202       token("oauth_token_secret", "");
77203       token("oauth_request_token_secret", "");
77204       return oauth2;
77205     };
77206     oauth2.authenticate = function(callback, options2) {
77207       if (oauth2.authenticated()) {
77208         callback(null, oauth2);
77209         return;
77210       }
77211       oauth2.logout();
77212       _preopenPopup(function(error, popup) {
77213         if (error) {
77214           callback(error);
77215         } else {
77216           _generatePkceChallenge(function(pkce) {
77217             _authenticate(pkce, options2, popup, callback);
77218           });
77219         }
77220       });
77221     };
77222     oauth2.authenticateAsync = function(options2) {
77223       if (oauth2.authenticated()) {
77224         return Promise.resolve(oauth2);
77225       }
77226       oauth2.logout();
77227       return new Promise((resolve, reject) => {
77228         var errback = (err, result) => {
77229           if (err) {
77230             reject(err);
77231           } else {
77232             resolve(result);
77233           }
77234         };
77235         _preopenPopup((error, popup) => {
77236           if (error) {
77237             errback(error);
77238           } else {
77239             _generatePkceChallenge((pkce) => _authenticate(pkce, options2, popup, errback));
77240           }
77241         });
77242       });
77243     };
77244     function _preopenPopup(callback) {
77245       if (o2.singlepage) {
77246         callback(null, void 0);
77247         return;
77248       }
77249       var w2 = 550;
77250       var h2 = 610;
77251       var settings = [
77252         ["width", w2],
77253         ["height", h2],
77254         ["left", window.screen.width / 2 - w2 / 2],
77255         ["top", window.screen.height / 2 - h2 / 2]
77256       ].map(function(x2) {
77257         return x2.join("=");
77258       }).join(",");
77259       var popup = window.open("about:blank", "oauth_window", settings);
77260       if (popup) {
77261         callback(null, popup);
77262       } else {
77263         var error = new Error("Popup was blocked");
77264         error.status = "popup-blocked";
77265         callback(error);
77266       }
77267     }
77268     function _authenticate(pkce, options2, popup, callback) {
77269       var state = generateState();
77270       var path = "/oauth2/authorize?" + utilQsString2({
77271         client_id: o2.client_id,
77272         redirect_uri: o2.redirect_uri,
77273         response_type: "code",
77274         scope: o2.scope,
77275         state,
77276         code_challenge: pkce.code_challenge,
77277         code_challenge_method: pkce.code_challenge_method,
77278         locale: o2.locale || ""
77279       });
77280       var url = (options2 == null ? void 0 : options2.switchUser) ? "".concat(o2.url, "/logout?referer=").concat(encodeURIComponent("/login?referer=".concat(encodeURIComponent(path)))) : o2.url + path;
77281       if (o2.singlepage) {
77282         if (_store.isMocked) {
77283           var error = new Error("localStorage unavailable, but required in singlepage mode");
77284           error.status = "pkce-localstorage-unavailable";
77285           callback(error);
77286           return;
77287         }
77288         var params = utilStringQs2(window.location.search.slice(1));
77289         if (params.code) {
77290           oauth2.bootstrapToken(params.code, callback);
77291         } else {
77292           token("oauth2_state", state);
77293           token("oauth2_pkce_code_verifier", pkce.code_verifier);
77294           window.location = url;
77295         }
77296       } else {
77297         var popupClosedWatcher = setInterval(function() {
77298           if (popup.closed) {
77299             var error2 = new Error("Popup was closed prematurely");
77300             error2.status = "popup-closed";
77301             callback(error2);
77302             window.clearInterval(popupClosedWatcher);
77303             delete window.authComplete;
77304           }
77305         }, 1e3);
77306         oauth2.popupWindow = popup;
77307         popup.location = url;
77308       }
77309       window.authComplete = function(url2) {
77310         clearTimeout(popupClosedWatcher);
77311         var params2 = utilStringQs2(url2.split("?")[1]);
77312         if (params2.state !== state) {
77313           var error2 = new Error("Invalid state");
77314           error2.status = "invalid-state";
77315           callback(error2);
77316           return;
77317         }
77318         _getAccessToken(params2.code, pkce.code_verifier, accessTokenDone);
77319         delete window.authComplete;
77320       };
77321       function accessTokenDone(err, xhr) {
77322         o2.done();
77323         if (err) {
77324           callback(err);
77325           return;
77326         }
77327         var access_token = JSON.parse(xhr.response);
77328         token("oauth2_access_token", access_token.access_token);
77329         callback(null, oauth2);
77330       }
77331     }
77332     function _getAccessToken(auth_code, code_verifier, accessTokenDone) {
77333       var url = o2.url + "/oauth2/token?" + utilQsString2({
77334         client_id: o2.client_id,
77335         redirect_uri: o2.redirect_uri,
77336         grant_type: "authorization_code",
77337         code: auth_code,
77338         code_verifier
77339       });
77340       oauth2.rawxhr("POST", url, null, null, null, accessTokenDone);
77341       o2.loading();
77342     }
77343     oauth2.bringPopupWindowToFront = function() {
77344       var broughtPopupToFront = false;
77345       try {
77346         if (oauth2.popupWindow && !oauth2.popupWindow.closed) {
77347           oauth2.popupWindow.focus();
77348           broughtPopupToFront = true;
77349         }
77350       } catch (err) {
77351       }
77352       return broughtPopupToFront;
77353     };
77354     oauth2.bootstrapToken = function(auth_code, callback) {
77355       var state = token("oauth2_state");
77356       token("oauth2_state", "");
77357       var params = utilStringQs2(window.location.search.slice(1));
77358       if (params.state !== state) {
77359         var error = new Error("Invalid state");
77360         error.status = "invalid-state";
77361         callback(error);
77362         return;
77363       }
77364       var code_verifier = token("oauth2_pkce_code_verifier");
77365       token("oauth2_pkce_code_verifier", "");
77366       _getAccessToken(auth_code, code_verifier, accessTokenDone);
77367       function accessTokenDone(err, xhr) {
77368         o2.done();
77369         if (err) {
77370           callback(err);
77371           return;
77372         }
77373         var access_token = JSON.parse(xhr.response);
77374         token("oauth2_access_token", access_token.access_token);
77375         callback(null, oauth2);
77376       }
77377     };
77378     oauth2.fetch = function(resource, options2) {
77379       if (oauth2.authenticated()) {
77380         return _doFetch();
77381       } else {
77382         if (o2.auto) {
77383           return oauth2.authenticateAsync().then(_doFetch);
77384         } else {
77385           return Promise.reject(new Error("not authenticated"));
77386         }
77387       }
77388       function _doFetch() {
77389         options2 = options2 || {};
77390         if (!options2.headers) {
77391           options2.headers = { "Content-Type": "application/x-www-form-urlencoded" };
77392         }
77393         options2.headers.Authorization = "Bearer " + token("oauth2_access_token");
77394         return fetch(resource, options2);
77395       }
77396     };
77397     oauth2.xhr = function(options2, callback) {
77398       if (oauth2.authenticated()) {
77399         return _doXHR();
77400       } else {
77401         if (o2.auto) {
77402           oauth2.authenticate(_doXHR);
77403           return;
77404         } else {
77405           callback("not authenticated", null);
77406           return;
77407         }
77408       }
77409       function _doXHR() {
77410         var url = options2.prefix !== false ? o2.apiUrl + options2.path : options2.path;
77411         return oauth2.rawxhr(
77412           options2.method,
77413           url,
77414           token("oauth2_access_token"),
77415           options2.content,
77416           options2.headers,
77417           done
77418         );
77419       }
77420       function done(err, xhr) {
77421         if (err) {
77422           callback(err);
77423         } else if (xhr.responseXML) {
77424           callback(err, xhr.responseXML);
77425         } else {
77426           callback(err, xhr.response);
77427         }
77428       }
77429     };
77430     oauth2.rawxhr = function(method, url, access_token, data, headers, callback) {
77431       headers = headers || { "Content-Type": "application/x-www-form-urlencoded" };
77432       if (access_token) {
77433         headers.Authorization = "Bearer " + access_token;
77434       }
77435       var xhr = new XMLHttpRequest();
77436       xhr.onreadystatechange = function() {
77437         if (4 === xhr.readyState && 0 !== xhr.status) {
77438           if (/^20\d$/.test(xhr.status)) {
77439             callback(null, xhr);
77440           } else {
77441             callback(xhr, null);
77442           }
77443         }
77444       };
77445       xhr.onerror = function(e3) {
77446         callback(e3, null);
77447       };
77448       xhr.open(method, url, true);
77449       for (var h2 in headers) xhr.setRequestHeader(h2, headers[h2]);
77450       xhr.send(data);
77451       return xhr;
77452     };
77453     oauth2.preauth = function(val) {
77454       if (val && val.access_token) {
77455         token("oauth2_access_token", val.access_token);
77456       }
77457       return oauth2;
77458     };
77459     oauth2.options = function(val) {
77460       if (!arguments.length) return o2;
77461       o2 = val;
77462       o2.apiUrl = o2.apiUrl || "https://api.openstreetmap.org";
77463       o2.url = o2.url || "https://www.openstreetmap.org";
77464       o2.auto = o2.auto || false;
77465       o2.singlepage = o2.singlepage || false;
77466       o2.loading = o2.loading || function() {
77467       };
77468       o2.done = o2.done || function() {
77469       };
77470       return oauth2.preauth(o2);
77471     };
77472     oauth2.options(o2);
77473     return oauth2;
77474   }
77475   function utilQsString2(obj) {
77476     return Object.keys(obj).filter(function(key) {
77477       return obj[key] !== void 0;
77478     }).sort().map(function(key) {
77479       return encodeURIComponent(key) + "=" + encodeURIComponent(obj[key]);
77480     }).join("&");
77481   }
77482   function utilStringQs2(str) {
77483     var i3 = 0;
77484     while (i3 < str.length && (str[i3] === "?" || str[i3] === "#")) i3++;
77485     str = str.slice(i3);
77486     return str.split("&").reduce(function(obj, pair3) {
77487       var parts = pair3.split("=");
77488       if (parts.length === 2) {
77489         obj[parts[0]] = decodeURIComponent(parts[1]);
77490       }
77491       return obj;
77492     }, {});
77493   }
77494   function supportsWebCryptoAPI() {
77495     return window && window.crypto && window.crypto.getRandomValues && window.crypto.subtle && window.crypto.subtle.digest;
77496   }
77497   function _generatePkceChallenge(callback) {
77498     var code_verifier;
77499     if (supportsWebCryptoAPI()) {
77500       var random = window.crypto.getRandomValues(new Uint8Array(32));
77501       code_verifier = base64(random.buffer);
77502       var verifier = Uint8Array.from(Array.from(code_verifier).map(function(char) {
77503         return char.charCodeAt(0);
77504       }));
77505       window.crypto.subtle.digest("SHA-256", verifier).then(function(hash2) {
77506         var code_challenge = base64(hash2);
77507         callback({
77508           code_challenge,
77509           code_verifier,
77510           code_challenge_method: "S256"
77511         });
77512       });
77513     } else {
77514       var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
77515       code_verifier = "";
77516       for (var i3 = 0; i3 < 64; i3++) {
77517         code_verifier += chars[Math.floor(Math.random() * chars.length)];
77518       }
77519       callback({
77520         code_verifier,
77521         code_challenge: code_verifier,
77522         code_challenge_method: "plain"
77523       });
77524     }
77525   }
77526   function generateState() {
77527     var state;
77528     if (supportsWebCryptoAPI()) {
77529       var random = window.crypto.getRandomValues(new Uint8Array(32));
77530       state = base64(random.buffer);
77531     } else {
77532       var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
77533       state = "";
77534       for (var i3 = 0; i3 < 64; i3++) {
77535         state += chars[Math.floor(Math.random() * chars.length)];
77536       }
77537     }
77538     return state;
77539   }
77540   function base64(buffer) {
77541     return btoa(String.fromCharCode.apply(null, new Uint8Array(buffer))).replace(/\//g, "_").replace(/\+/g, "-").replace(/[=]/g, "");
77542   }
77543
77544   // modules/services/osm.js
77545   var tiler5 = utilTiler();
77546   var dispatch9 = dispatch_default("apiStatusChange", "authLoading", "authDone", "change", "loading", "loaded", "loadedNotes");
77547   var urlroot = osmApiConnections[0].url;
77548   var apiUrlroot = osmApiConnections[0].apiUrl || urlroot;
77549   var redirectPath = window.location.origin + window.location.pathname;
77550   var oauth = osmAuth({
77551     url: urlroot,
77552     apiUrl: apiUrlroot,
77553     client_id: osmApiConnections[0].client_id,
77554     scope: "read_prefs write_prefs write_api read_gpx write_notes",
77555     redirect_uri: redirectPath + "land.html",
77556     loading: authLoading,
77557     done: authDone
77558   });
77559   var _apiConnections = osmApiConnections;
77560   var _imageryBlocklists = [/.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/];
77561   var _tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new RBush() };
77562   var _noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new RBush() };
77563   var _userCache = { toLoad: {}, user: {} };
77564   var _cachedApiStatus;
77565   var _changeset = {};
77566   var _deferred = /* @__PURE__ */ new Set();
77567   var _connectionID = 1;
77568   var _tileZoom3 = 16;
77569   var _noteZoom = 12;
77570   var _rateLimitError;
77571   var _userChangesets;
77572   var _userDetails;
77573   var _off;
77574   var _maxWayNodes = 2e3;
77575   function authLoading() {
77576     dispatch9.call("authLoading");
77577   }
77578   function authDone() {
77579     dispatch9.call("authDone");
77580   }
77581   function abortRequest4(controllerOrXHR) {
77582     if (controllerOrXHR) {
77583       controllerOrXHR.abort();
77584     }
77585   }
77586   function hasInflightRequests(cache) {
77587     return Object.keys(cache.inflight).length;
77588   }
77589   function abortUnwantedRequests3(cache, visibleTiles) {
77590     Object.keys(cache.inflight).forEach(function(k2) {
77591       if (cache.toLoad[k2]) return;
77592       if (visibleTiles.find(function(tile) {
77593         return k2 === tile.id;
77594       })) return;
77595       abortRequest4(cache.inflight[k2]);
77596       delete cache.inflight[k2];
77597     });
77598   }
77599   function getLoc(attrs) {
77600     var lon = attrs.lon && attrs.lon.value;
77601     var lat = attrs.lat && attrs.lat.value;
77602     return [Number(lon), Number(lat)];
77603   }
77604   function getNodes(obj) {
77605     var elems = obj.getElementsByTagName("nd");
77606     var nodes = new Array(elems.length);
77607     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
77608       nodes[i3] = "n" + elems[i3].attributes.ref.value;
77609     }
77610     return nodes;
77611   }
77612   function getNodesJSON(obj) {
77613     var elems = obj.nodes;
77614     var nodes = new Array(elems.length);
77615     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
77616       nodes[i3] = "n" + elems[i3];
77617     }
77618     return nodes;
77619   }
77620   function getTags(obj) {
77621     var elems = obj.getElementsByTagName("tag");
77622     var tags = {};
77623     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
77624       var attrs = elems[i3].attributes;
77625       tags[attrs.k.value] = attrs.v.value;
77626     }
77627     return tags;
77628   }
77629   function getMembers(obj) {
77630     var elems = obj.getElementsByTagName("member");
77631     var members = new Array(elems.length);
77632     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
77633       var attrs = elems[i3].attributes;
77634       members[i3] = {
77635         id: attrs.type.value[0] + attrs.ref.value,
77636         type: attrs.type.value,
77637         role: attrs.role.value
77638       };
77639     }
77640     return members;
77641   }
77642   function getMembersJSON(obj) {
77643     var elems = obj.members;
77644     var members = new Array(elems.length);
77645     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
77646       var attrs = elems[i3];
77647       members[i3] = {
77648         id: attrs.type[0] + attrs.ref,
77649         type: attrs.type,
77650         role: attrs.role
77651       };
77652     }
77653     return members;
77654   }
77655   function getVisible(attrs) {
77656     return !attrs.visible || attrs.visible.value !== "false";
77657   }
77658   function parseComments(comments) {
77659     var parsedComments = [];
77660     for (var i3 = 0; i3 < comments.length; i3++) {
77661       var comment = comments[i3];
77662       if (comment.nodeName === "comment") {
77663         var childNodes = comment.childNodes;
77664         var parsedComment = {};
77665         for (var j2 = 0; j2 < childNodes.length; j2++) {
77666           var node = childNodes[j2];
77667           var nodeName = node.nodeName;
77668           if (nodeName === "#text") continue;
77669           parsedComment[nodeName] = node.textContent;
77670           if (nodeName === "uid") {
77671             var uid = node.textContent;
77672             if (uid && !_userCache.user[uid]) {
77673               _userCache.toLoad[uid] = true;
77674             }
77675           }
77676         }
77677         if (parsedComment) {
77678           parsedComments.push(parsedComment);
77679         }
77680       }
77681     }
77682     return parsedComments;
77683   }
77684   function encodeNoteRtree(note) {
77685     return {
77686       minX: note.loc[0],
77687       minY: note.loc[1],
77688       maxX: note.loc[0],
77689       maxY: note.loc[1],
77690       data: note
77691     };
77692   }
77693   var jsonparsers = {
77694     node: function nodeData(obj, uid) {
77695       return new osmNode({
77696         id: uid,
77697         visible: typeof obj.visible === "boolean" ? obj.visible : true,
77698         version: obj.version && obj.version.toString(),
77699         changeset: obj.changeset && obj.changeset.toString(),
77700         timestamp: obj.timestamp,
77701         user: obj.user,
77702         uid: obj.uid && obj.uid.toString(),
77703         loc: [Number(obj.lon), Number(obj.lat)],
77704         tags: obj.tags
77705       });
77706     },
77707     way: function wayData(obj, uid) {
77708       return new osmWay({
77709         id: uid,
77710         visible: typeof obj.visible === "boolean" ? obj.visible : true,
77711         version: obj.version && obj.version.toString(),
77712         changeset: obj.changeset && obj.changeset.toString(),
77713         timestamp: obj.timestamp,
77714         user: obj.user,
77715         uid: obj.uid && obj.uid.toString(),
77716         tags: obj.tags,
77717         nodes: getNodesJSON(obj)
77718       });
77719     },
77720     relation: function relationData(obj, uid) {
77721       return new osmRelation({
77722         id: uid,
77723         visible: typeof obj.visible === "boolean" ? obj.visible : true,
77724         version: obj.version && obj.version.toString(),
77725         changeset: obj.changeset && obj.changeset.toString(),
77726         timestamp: obj.timestamp,
77727         user: obj.user,
77728         uid: obj.uid && obj.uid.toString(),
77729         tags: obj.tags,
77730         members: getMembersJSON(obj)
77731       });
77732     },
77733     user: function parseUser(obj, uid) {
77734       return {
77735         id: uid,
77736         display_name: obj.display_name,
77737         account_created: obj.account_created,
77738         image_url: obj.img && obj.img.href,
77739         changesets_count: obj.changesets && obj.changesets.count && obj.changesets.count.toString() || "0",
77740         active_blocks: obj.blocks && obj.blocks.received && obj.blocks.received.active && obj.blocks.received.active.toString() || "0"
77741       };
77742     }
77743   };
77744   function parseJSON(payload, callback, options2) {
77745     options2 = Object.assign({ skipSeen: true }, options2);
77746     if (!payload) {
77747       return callback({ message: "No JSON", status: -1 });
77748     }
77749     var json = payload;
77750     if (typeof json !== "object") json = JSON.parse(payload);
77751     if (!json.elements) return callback({ message: "No JSON", status: -1 });
77752     var children2 = json.elements;
77753     var handle = window.requestIdleCallback(function() {
77754       _deferred.delete(handle);
77755       var results = [];
77756       var result;
77757       for (var i3 = 0; i3 < children2.length; i3++) {
77758         result = parseChild(children2[i3]);
77759         if (result) results.push(result);
77760       }
77761       callback(null, results);
77762     });
77763     _deferred.add(handle);
77764     function parseChild(child) {
77765       var parser3 = jsonparsers[child.type];
77766       if (!parser3) return null;
77767       var uid;
77768       uid = osmEntity.id.fromOSM(child.type, child.id);
77769       if (options2.skipSeen) {
77770         if (_tileCache.seen[uid]) return null;
77771         _tileCache.seen[uid] = true;
77772       }
77773       return parser3(child, uid);
77774     }
77775   }
77776   function parseUserJSON(payload, callback, options2) {
77777     options2 = Object.assign({ skipSeen: true }, options2);
77778     if (!payload) {
77779       return callback({ message: "No JSON", status: -1 });
77780     }
77781     var json = payload;
77782     if (typeof json !== "object") json = JSON.parse(payload);
77783     if (!json.users && !json.user) return callback({ message: "No JSON", status: -1 });
77784     var objs = json.users || [json];
77785     var handle = window.requestIdleCallback(function() {
77786       _deferred.delete(handle);
77787       var results = [];
77788       var result;
77789       for (var i3 = 0; i3 < objs.length; i3++) {
77790         result = parseObj(objs[i3]);
77791         if (result) results.push(result);
77792       }
77793       callback(null, results);
77794     });
77795     _deferred.add(handle);
77796     function parseObj(obj) {
77797       var uid = obj.user.id && obj.user.id.toString();
77798       if (options2.skipSeen && _userCache.user[uid]) {
77799         delete _userCache.toLoad[uid];
77800         return null;
77801       }
77802       var user = jsonparsers.user(obj.user, uid);
77803       _userCache.user[uid] = user;
77804       delete _userCache.toLoad[uid];
77805       return user;
77806     }
77807   }
77808   var parsers = {
77809     node: function nodeData2(obj, uid) {
77810       var attrs = obj.attributes;
77811       return new osmNode({
77812         id: uid,
77813         visible: getVisible(attrs),
77814         version: attrs.version.value,
77815         changeset: attrs.changeset && attrs.changeset.value,
77816         timestamp: attrs.timestamp && attrs.timestamp.value,
77817         user: attrs.user && attrs.user.value,
77818         uid: attrs.uid && attrs.uid.value,
77819         loc: getLoc(attrs),
77820         tags: getTags(obj)
77821       });
77822     },
77823     way: function wayData2(obj, uid) {
77824       var attrs = obj.attributes;
77825       return new osmWay({
77826         id: uid,
77827         visible: getVisible(attrs),
77828         version: attrs.version.value,
77829         changeset: attrs.changeset && attrs.changeset.value,
77830         timestamp: attrs.timestamp && attrs.timestamp.value,
77831         user: attrs.user && attrs.user.value,
77832         uid: attrs.uid && attrs.uid.value,
77833         tags: getTags(obj),
77834         nodes: getNodes(obj)
77835       });
77836     },
77837     relation: function relationData2(obj, uid) {
77838       var attrs = obj.attributes;
77839       return new osmRelation({
77840         id: uid,
77841         visible: getVisible(attrs),
77842         version: attrs.version.value,
77843         changeset: attrs.changeset && attrs.changeset.value,
77844         timestamp: attrs.timestamp && attrs.timestamp.value,
77845         user: attrs.user && attrs.user.value,
77846         uid: attrs.uid && attrs.uid.value,
77847         tags: getTags(obj),
77848         members: getMembers(obj)
77849       });
77850     },
77851     note: function parseNote(obj, uid) {
77852       var attrs = obj.attributes;
77853       var childNodes = obj.childNodes;
77854       var props = {};
77855       props.id = uid;
77856       props.loc = getLoc(attrs);
77857       if (!_noteCache.note[uid]) {
77858         let coincident = false;
77859         const epsilon3 = 1e-5;
77860         do {
77861           if (coincident) {
77862             props.loc = geoVecAdd(props.loc, [epsilon3, epsilon3]);
77863           }
77864           const bbox2 = geoExtent(props.loc).bbox();
77865           coincident = _noteCache.rtree.search(bbox2).length;
77866         } while (coincident);
77867       } else {
77868         props.loc = _noteCache.note[uid].loc;
77869       }
77870       for (var i3 = 0; i3 < childNodes.length; i3++) {
77871         var node = childNodes[i3];
77872         var nodeName = node.nodeName;
77873         if (nodeName === "#text") continue;
77874         if (nodeName === "comments") {
77875           props[nodeName] = parseComments(node.childNodes);
77876         } else {
77877           props[nodeName] = node.textContent;
77878         }
77879       }
77880       var note = new osmNote(props);
77881       var item = encodeNoteRtree(note);
77882       _noteCache.note[note.id] = note;
77883       updateRtree3(item, true);
77884       return note;
77885     },
77886     user: function parseUser2(obj, uid) {
77887       var attrs = obj.attributes;
77888       var user = {
77889         id: uid,
77890         display_name: attrs.display_name && attrs.display_name.value,
77891         account_created: attrs.account_created && attrs.account_created.value,
77892         changesets_count: "0",
77893         active_blocks: "0"
77894       };
77895       var img = obj.getElementsByTagName("img");
77896       if (img && img[0] && img[0].getAttribute("href")) {
77897         user.image_url = img[0].getAttribute("href");
77898       }
77899       var changesets = obj.getElementsByTagName("changesets");
77900       if (changesets && changesets[0] && changesets[0].getAttribute("count")) {
77901         user.changesets_count = changesets[0].getAttribute("count");
77902       }
77903       var blocks = obj.getElementsByTagName("blocks");
77904       if (blocks && blocks[0]) {
77905         var received = blocks[0].getElementsByTagName("received");
77906         if (received && received[0] && received[0].getAttribute("active")) {
77907           user.active_blocks = received[0].getAttribute("active");
77908         }
77909       }
77910       _userCache.user[uid] = user;
77911       delete _userCache.toLoad[uid];
77912       return user;
77913     }
77914   };
77915   function parseXML(xml, callback, options2) {
77916     options2 = Object.assign({ skipSeen: true }, options2);
77917     if (!xml || !xml.childNodes) {
77918       return callback({ message: "No XML", status: -1 });
77919     }
77920     var root3 = xml.childNodes[0];
77921     var children2 = root3.childNodes;
77922     var handle = window.requestIdleCallback(function() {
77923       _deferred.delete(handle);
77924       var results = [];
77925       var result;
77926       for (var i3 = 0; i3 < children2.length; i3++) {
77927         result = parseChild(children2[i3]);
77928         if (result) results.push(result);
77929       }
77930       callback(null, results);
77931     });
77932     _deferred.add(handle);
77933     function parseChild(child) {
77934       var parser3 = parsers[child.nodeName];
77935       if (!parser3) return null;
77936       var uid;
77937       if (child.nodeName === "user") {
77938         uid = child.attributes.id.value;
77939         if (options2.skipSeen && _userCache.user[uid]) {
77940           delete _userCache.toLoad[uid];
77941           return null;
77942         }
77943       } else if (child.nodeName === "note") {
77944         uid = child.getElementsByTagName("id")[0].textContent;
77945       } else {
77946         uid = osmEntity.id.fromOSM(child.nodeName, child.attributes.id.value);
77947         if (options2.skipSeen) {
77948           if (_tileCache.seen[uid]) return null;
77949           _tileCache.seen[uid] = true;
77950         }
77951       }
77952       return parser3(child, uid);
77953     }
77954   }
77955   function updateRtree3(item, replace) {
77956     _noteCache.rtree.remove(item, function isEql(a2, b2) {
77957       return a2.data.id === b2.data.id;
77958     });
77959     if (replace) {
77960       _noteCache.rtree.insert(item);
77961     }
77962   }
77963   function wrapcb(thisArg, callback, cid) {
77964     return function(err, result) {
77965       if (err) {
77966         if (err.status === 400 || err.status === 401 || err.status === 403) {
77967           thisArg.logout();
77968         }
77969         return callback.call(thisArg, err);
77970       } else if (thisArg.getConnectionId() !== cid) {
77971         return callback.call(thisArg, { message: "Connection Switched", status: -1 });
77972       } else {
77973         return callback.call(thisArg, err, result);
77974       }
77975     };
77976   }
77977   var osm_default = {
77978     init: function() {
77979       utilRebind(this, dispatch9, "on");
77980     },
77981     reset: function() {
77982       Array.from(_deferred).forEach(function(handle) {
77983         window.cancelIdleCallback(handle);
77984         _deferred.delete(handle);
77985       });
77986       _connectionID++;
77987       _userChangesets = void 0;
77988       _userDetails = void 0;
77989       _rateLimitError = void 0;
77990       Object.values(_tileCache.inflight).forEach(abortRequest4);
77991       Object.values(_noteCache.inflight).forEach(abortRequest4);
77992       Object.values(_noteCache.inflightPost).forEach(abortRequest4);
77993       if (_changeset.inflight) abortRequest4(_changeset.inflight);
77994       _tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new RBush() };
77995       _noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new RBush() };
77996       _userCache = { toLoad: {}, user: {} };
77997       _cachedApiStatus = void 0;
77998       _changeset = {};
77999       return this;
78000     },
78001     getConnectionId: function() {
78002       return _connectionID;
78003     },
78004     getUrlRoot: function() {
78005       return urlroot;
78006     },
78007     getApiUrlRoot: function() {
78008       return apiUrlroot;
78009     },
78010     changesetURL: function(changesetID) {
78011       return urlroot + "/changeset/" + changesetID;
78012     },
78013     changesetsURL: function(center, zoom) {
78014       var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
78015       return urlroot + "/history#map=" + Math.floor(zoom) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3);
78016     },
78017     entityURL: function(entity) {
78018       return urlroot + "/" + entity.type + "/" + entity.osmId();
78019     },
78020     historyURL: function(entity) {
78021       return urlroot + "/" + entity.type + "/" + entity.osmId() + "/history";
78022     },
78023     userURL: function(username) {
78024       return urlroot + "/user/" + encodeURIComponent(username);
78025     },
78026     noteURL: function(note) {
78027       return urlroot + "/note/" + note.id;
78028     },
78029     noteReportURL: function(note) {
78030       return urlroot + "/reports/new?reportable_type=Note&reportable_id=" + note.id;
78031     },
78032     // Generic method to load data from the OSM API
78033     // Can handle either auth or unauth calls.
78034     loadFromAPI: function(path, callback, options2) {
78035       options2 = Object.assign({ skipSeen: true }, options2);
78036       var that = this;
78037       var cid = _connectionID;
78038       function done(err, payload) {
78039         if (that.getConnectionId() !== cid) {
78040           if (callback) callback({ message: "Connection Switched", status: -1 });
78041           return;
78042         }
78043         var isAuthenticated = that.authenticated();
78044         if (isAuthenticated && err && err.status && (err.status === 400 || err.status === 401 || err.status === 403)) {
78045           that.logout();
78046           that.loadFromAPI(path, callback, options2);
78047         } else {
78048           if (!isAuthenticated && !_rateLimitError && err && err.status && (err.status === 509 || err.status === 429)) {
78049             _rateLimitError = err;
78050             dispatch9.call("change");
78051             that.reloadApiStatus();
78052           } else if (err && _cachedApiStatus === "online" || !err && _cachedApiStatus !== "online") {
78053             that.reloadApiStatus();
78054           }
78055           if (callback) {
78056             if (err) {
78057               return callback(err);
78058             } else {
78059               if (path.indexOf(".json") !== -1) {
78060                 return parseJSON(payload, callback, options2);
78061               } else {
78062                 return parseXML(payload, callback, options2);
78063               }
78064             }
78065           }
78066         }
78067       }
78068       if (this.authenticated()) {
78069         return oauth.xhr({
78070           method: "GET",
78071           path
78072         }, done);
78073       } else {
78074         var url = apiUrlroot + path;
78075         var controller = new AbortController();
78076         var fn;
78077         if (path.indexOf(".json") !== -1) {
78078           fn = json_default;
78079         } else {
78080           fn = xml_default;
78081         }
78082         fn(url, { signal: controller.signal }).then(function(data) {
78083           done(null, data);
78084         }).catch(function(err) {
78085           if (err.name === "AbortError") return;
78086           var match = err.message.match(/^\d{3}/);
78087           if (match) {
78088             done({ status: +match[0], statusText: err.message });
78089           } else {
78090             done(err.message);
78091           }
78092         });
78093         return controller;
78094       }
78095     },
78096     // Load a single entity by id (ways and relations use the `/full` call to include
78097     // nodes and members). Parent relations are not included, see `loadEntityRelations`.
78098     // GET /api/0.6/node/#id
78099     // GET /api/0.6/[way|relation]/#id/full
78100     loadEntity: function(id2, callback) {
78101       var type2 = osmEntity.id.type(id2);
78102       var osmID = osmEntity.id.toOSM(id2);
78103       var options2 = { skipSeen: false };
78104       this.loadFromAPI(
78105         "/api/0.6/" + type2 + "/" + osmID + (type2 !== "node" ? "/full" : "") + ".json",
78106         function(err, entities) {
78107           if (callback) callback(err, { data: entities });
78108         },
78109         options2
78110       );
78111     },
78112     // Load a single note by id , XML format
78113     // GET /api/0.6/notes/#id
78114     loadEntityNote: function(id2, callback) {
78115       var options2 = { skipSeen: false };
78116       this.loadFromAPI(
78117         "/api/0.6/notes/" + id2,
78118         function(err, entities) {
78119           if (callback) callback(err, { data: entities });
78120         },
78121         options2
78122       );
78123     },
78124     // Load a single entity with a specific version
78125     // GET /api/0.6/[node|way|relation]/#id/#version
78126     loadEntityVersion: function(id2, version, callback) {
78127       var type2 = osmEntity.id.type(id2);
78128       var osmID = osmEntity.id.toOSM(id2);
78129       var options2 = { skipSeen: false };
78130       this.loadFromAPI(
78131         "/api/0.6/" + type2 + "/" + osmID + "/" + version + ".json",
78132         function(err, entities) {
78133           if (callback) callback(err, { data: entities });
78134         },
78135         options2
78136       );
78137     },
78138     // Load the relations of a single entity with the given.
78139     // GET /api/0.6/[node|way|relation]/#id/relations
78140     loadEntityRelations: function(id2, callback) {
78141       var type2 = osmEntity.id.type(id2);
78142       var osmID = osmEntity.id.toOSM(id2);
78143       var options2 = { skipSeen: false };
78144       this.loadFromAPI(
78145         "/api/0.6/" + type2 + "/" + osmID + "/relations.json",
78146         function(err, entities) {
78147           if (callback) callback(err, { data: entities });
78148         },
78149         options2
78150       );
78151     },
78152     // Load multiple entities in chunks
78153     // (note: callback may be called multiple times)
78154     // Unlike `loadEntity`, child nodes and members are not fetched
78155     // GET /api/0.6/[nodes|ways|relations]?#parameters
78156     loadMultiple: function(ids, callback) {
78157       var that = this;
78158       var groups = utilArrayGroupBy(utilArrayUniq(ids), osmEntity.id.type);
78159       Object.keys(groups).forEach(function(k2) {
78160         var type2 = k2 + "s";
78161         var osmIDs = groups[k2].map(function(id2) {
78162           return osmEntity.id.toOSM(id2);
78163         });
78164         var options2 = { skipSeen: false };
78165         utilArrayChunk(osmIDs, 150).forEach(function(arr) {
78166           that.loadFromAPI(
78167             "/api/0.6/" + type2 + ".json?" + type2 + "=" + arr.join(),
78168             function(err, entities) {
78169               if (callback) callback(err, { data: entities });
78170             },
78171             options2
78172           );
78173         });
78174       });
78175     },
78176     // Create, upload, and close a changeset
78177     // PUT /api/0.6/changeset/create
78178     // POST /api/0.6/changeset/#id/upload
78179     // PUT /api/0.6/changeset/#id/close
78180     putChangeset: function(changeset, changes, callback) {
78181       var cid = _connectionID;
78182       if (_changeset.inflight) {
78183         return callback({ message: "Changeset already inflight", status: -2 }, changeset);
78184       } else if (_changeset.open) {
78185         return createdChangeset.call(this, null, _changeset.open);
78186       } else {
78187         var options2 = {
78188           method: "PUT",
78189           path: "/api/0.6/changeset/create",
78190           headers: { "Content-Type": "text/xml" },
78191           content: JXON.stringify(changeset.asJXON())
78192         };
78193         _changeset.inflight = oauth.xhr(
78194           options2,
78195           wrapcb(this, createdChangeset, cid)
78196         );
78197       }
78198       function createdChangeset(err, changesetID) {
78199         _changeset.inflight = null;
78200         if (err) {
78201           return callback(err, changeset);
78202         }
78203         _changeset.open = changesetID;
78204         changeset = changeset.update({ id: changesetID });
78205         var options3 = {
78206           method: "POST",
78207           path: "/api/0.6/changeset/" + changesetID + "/upload",
78208           headers: { "Content-Type": "text/xml" },
78209           content: JXON.stringify(changeset.osmChangeJXON(changes))
78210         };
78211         _changeset.inflight = oauth.xhr(
78212           options3,
78213           wrapcb(this, uploadedChangeset, cid)
78214         );
78215       }
78216       function uploadedChangeset(err) {
78217         _changeset.inflight = null;
78218         if (err) return callback(err, changeset);
78219         window.setTimeout(function() {
78220           callback(null, changeset);
78221         }, 2500);
78222         _changeset.open = null;
78223         if (this.getConnectionId() === cid) {
78224           oauth.xhr({
78225             method: "PUT",
78226             path: "/api/0.6/changeset/" + changeset.id + "/close",
78227             headers: { "Content-Type": "text/xml" }
78228           }, function() {
78229             return true;
78230           });
78231         }
78232       }
78233     },
78234     // Load multiple users in chunks
78235     // (note: callback may be called multiple times)
78236     // GET /api/0.6/users?users=#id1,#id2,...,#idn
78237     loadUsers: function(uids, callback) {
78238       var toLoad = [];
78239       var cached = [];
78240       utilArrayUniq(uids).forEach(function(uid) {
78241         if (_userCache.user[uid]) {
78242           delete _userCache.toLoad[uid];
78243           cached.push(_userCache.user[uid]);
78244         } else {
78245           toLoad.push(uid);
78246         }
78247       });
78248       if (cached.length || !this.authenticated()) {
78249         callback(void 0, cached);
78250         if (!this.authenticated()) return;
78251       }
78252       utilArrayChunk(toLoad, 150).forEach((function(arr) {
78253         oauth.xhr({
78254           method: "GET",
78255           path: "/api/0.6/users.json?users=" + arr.join()
78256         }, wrapcb(this, done, _connectionID));
78257       }).bind(this));
78258       function done(err, payload) {
78259         if (err) return callback(err);
78260         var options2 = { skipSeen: true };
78261         return parseUserJSON(payload, function(err2, results) {
78262           if (err2) return callback(err2);
78263           return callback(void 0, results);
78264         }, options2);
78265       }
78266     },
78267     // Load a given user by id
78268     // GET /api/0.6/user/#id
78269     loadUser: function(uid, callback) {
78270       if (_userCache.user[uid] || !this.authenticated()) {
78271         delete _userCache.toLoad[uid];
78272         return callback(void 0, _userCache.user[uid]);
78273       }
78274       oauth.xhr({
78275         method: "GET",
78276         path: "/api/0.6/user/" + uid + ".json"
78277       }, wrapcb(this, done, _connectionID));
78278       function done(err, payload) {
78279         if (err) return callback(err);
78280         var options2 = { skipSeen: true };
78281         return parseUserJSON(payload, function(err2, results) {
78282           if (err2) return callback(err2);
78283           return callback(void 0, results[0]);
78284         }, options2);
78285       }
78286     },
78287     // Load the details of the logged-in user
78288     // GET /api/0.6/user/details
78289     userDetails: function(callback) {
78290       if (_userDetails) {
78291         return callback(void 0, _userDetails);
78292       }
78293       oauth.xhr({
78294         method: "GET",
78295         path: "/api/0.6/user/details.json"
78296       }, wrapcb(this, done, _connectionID));
78297       function done(err, payload) {
78298         if (err) return callback(err);
78299         var options2 = { skipSeen: false };
78300         return parseUserJSON(payload, function(err2, results) {
78301           if (err2) return callback(err2);
78302           _userDetails = results[0];
78303           return callback(void 0, _userDetails);
78304         }, options2);
78305       }
78306     },
78307     // Load previous changesets for the logged in user
78308     // GET /api/0.6/changesets?user=#id
78309     userChangesets: function(callback) {
78310       if (_userChangesets) {
78311         return callback(void 0, _userChangesets);
78312       }
78313       this.userDetails(
78314         wrapcb(this, gotDetails, _connectionID)
78315       );
78316       function gotDetails(err, user) {
78317         if (err) {
78318           return callback(err);
78319         }
78320         oauth.xhr({
78321           method: "GET",
78322           path: "/api/0.6/changesets?user=" + user.id
78323         }, wrapcb(this, done, _connectionID));
78324       }
78325       function done(err, xml) {
78326         if (err) {
78327           return callback(err);
78328         }
78329         _userChangesets = Array.prototype.map.call(
78330           xml.getElementsByTagName("changeset"),
78331           function(changeset) {
78332             return { tags: getTags(changeset) };
78333           }
78334         ).filter(function(changeset) {
78335           var comment = changeset.tags.comment;
78336           return comment && comment !== "";
78337         });
78338         return callback(void 0, _userChangesets);
78339       }
78340     },
78341     // Fetch the status of the OSM API
78342     // GET /api/capabilities
78343     status: function(callback) {
78344       var url = apiUrlroot + "/api/capabilities";
78345       var errback = wrapcb(this, done, _connectionID);
78346       xml_default(url).then(function(data) {
78347         errback(null, data);
78348       }).catch(function(err) {
78349         errback(err.message);
78350       });
78351       function done(err, xml) {
78352         if (err) {
78353           return callback(err, null);
78354         }
78355         var elements = xml.getElementsByTagName("blacklist");
78356         var regexes = [];
78357         for (var i3 = 0; i3 < elements.length; i3++) {
78358           var regexString = elements[i3].getAttribute("regex");
78359           if (regexString) {
78360             try {
78361               var regex = new RegExp(regexString);
78362               regexes.push(regex);
78363             } catch (e3) {
78364             }
78365           }
78366         }
78367         if (regexes.length) {
78368           _imageryBlocklists = regexes;
78369         }
78370         if (_rateLimitError) {
78371           return callback(_rateLimitError, "rateLimited");
78372         } else {
78373           var waynodes = xml.getElementsByTagName("waynodes");
78374           var maxWayNodes = waynodes.length && parseInt(waynodes[0].getAttribute("maximum"), 10);
78375           if (maxWayNodes && isFinite(maxWayNodes)) _maxWayNodes = maxWayNodes;
78376           var apiStatus = xml.getElementsByTagName("status");
78377           var val = apiStatus[0].getAttribute("api");
78378           return callback(void 0, val);
78379         }
78380       }
78381     },
78382     // Calls `status` and dispatches an `apiStatusChange` event if the returned
78383     // status differs from the cached status.
78384     reloadApiStatus: function() {
78385       if (!this.throttledReloadApiStatus) {
78386         var that = this;
78387         this.throttledReloadApiStatus = throttle_default(function() {
78388           that.status(function(err, status) {
78389             if (status !== _cachedApiStatus) {
78390               _cachedApiStatus = status;
78391               dispatch9.call("apiStatusChange", that, err, status);
78392             }
78393           });
78394         }, 500);
78395       }
78396       this.throttledReloadApiStatus();
78397     },
78398     // Returns the maximum number of nodes a single way can have
78399     maxWayNodes: function() {
78400       return _maxWayNodes;
78401     },
78402     // Load data (entities) from the API in tiles
78403     // GET /api/0.6/map?bbox=
78404     loadTiles: function(projection2, callback) {
78405       if (_off) return;
78406       var tiles = tiler5.zoomExtent([_tileZoom3, _tileZoom3]).getTiles(projection2);
78407       var hadRequests = hasInflightRequests(_tileCache);
78408       abortUnwantedRequests3(_tileCache, tiles);
78409       if (hadRequests && !hasInflightRequests(_tileCache)) {
78410         dispatch9.call("loaded");
78411       }
78412       tiles.forEach(function(tile) {
78413         this.loadTile(tile, callback);
78414       }, this);
78415     },
78416     // Load a single data tile
78417     // GET /api/0.6/map?bbox=
78418     loadTile: function(tile, callback) {
78419       if (_off) return;
78420       if (_tileCache.loaded[tile.id] || _tileCache.inflight[tile.id]) return;
78421       if (!hasInflightRequests(_tileCache)) {
78422         dispatch9.call("loading");
78423       }
78424       var path = "/api/0.6/map.json?bbox=";
78425       var options2 = { skipSeen: true };
78426       _tileCache.inflight[tile.id] = this.loadFromAPI(
78427         path + tile.extent.toParam(),
78428         tileCallback,
78429         options2
78430       );
78431       function tileCallback(err, parsed) {
78432         delete _tileCache.inflight[tile.id];
78433         if (!err) {
78434           delete _tileCache.toLoad[tile.id];
78435           _tileCache.loaded[tile.id] = true;
78436           var bbox2 = tile.extent.bbox();
78437           bbox2.id = tile.id;
78438           _tileCache.rtree.insert(bbox2);
78439         }
78440         if (callback) {
78441           callback(err, Object.assign({ data: parsed }, tile));
78442         }
78443         if (!hasInflightRequests(_tileCache)) {
78444           dispatch9.call("loaded");
78445         }
78446       }
78447     },
78448     isDataLoaded: function(loc) {
78449       var bbox2 = { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] };
78450       return _tileCache.rtree.collides(bbox2);
78451     },
78452     // load the tile that covers the given `loc`
78453     loadTileAtLoc: function(loc, callback) {
78454       if (Object.keys(_tileCache.toLoad).length > 50) return;
78455       var k2 = geoZoomToScale(_tileZoom3 + 1);
78456       var offset = geoRawMercator().scale(k2)(loc);
78457       var projection2 = geoRawMercator().transform({ k: k2, x: -offset[0], y: -offset[1] });
78458       var tiles = tiler5.zoomExtent([_tileZoom3, _tileZoom3]).getTiles(projection2);
78459       tiles.forEach(function(tile) {
78460         if (_tileCache.toLoad[tile.id] || _tileCache.loaded[tile.id] || _tileCache.inflight[tile.id]) return;
78461         _tileCache.toLoad[tile.id] = true;
78462         this.loadTile(tile, callback);
78463       }, this);
78464     },
78465     // Load notes from the API in tiles
78466     // GET /api/0.6/notes?bbox=
78467     loadNotes: function(projection2, noteOptions) {
78468       noteOptions = Object.assign({ limit: 1e4, closed: 7 }, noteOptions);
78469       if (_off) return;
78470       var that = this;
78471       var path = "/api/0.6/notes?limit=" + noteOptions.limit + "&closed=" + noteOptions.closed + "&bbox=";
78472       var throttleLoadUsers = throttle_default(function() {
78473         var uids = Object.keys(_userCache.toLoad);
78474         if (!uids.length) return;
78475         that.loadUsers(uids, function() {
78476         });
78477       }, 750);
78478       var tiles = tiler5.zoomExtent([_noteZoom, _noteZoom]).getTiles(projection2);
78479       abortUnwantedRequests3(_noteCache, tiles);
78480       tiles.forEach(function(tile) {
78481         if (_noteCache.loaded[tile.id] || _noteCache.inflight[tile.id]) return;
78482         var options2 = { skipSeen: false };
78483         _noteCache.inflight[tile.id] = that.loadFromAPI(
78484           path + tile.extent.toParam(),
78485           function(err) {
78486             delete _noteCache.inflight[tile.id];
78487             if (!err) {
78488               _noteCache.loaded[tile.id] = true;
78489             }
78490             throttleLoadUsers();
78491             dispatch9.call("loadedNotes");
78492           },
78493           options2
78494         );
78495       });
78496     },
78497     // Create a note
78498     // POST /api/0.6/notes?params
78499     postNoteCreate: function(note, callback) {
78500       if (!this.authenticated()) {
78501         return callback({ message: "Not Authenticated", status: -3 }, note);
78502       }
78503       if (_noteCache.inflightPost[note.id]) {
78504         return callback({ message: "Note update already inflight", status: -2 }, note);
78505       }
78506       if (!note.loc[0] || !note.loc[1] || !note.newComment) return;
78507       var comment = note.newComment;
78508       if (note.newCategory && note.newCategory !== "None") {
78509         comment += " #" + note.newCategory;
78510       }
78511       var path = "/api/0.6/notes?" + utilQsString({ lon: note.loc[0], lat: note.loc[1], text: comment });
78512       _noteCache.inflightPost[note.id] = oauth.xhr({
78513         method: "POST",
78514         path
78515       }, wrapcb(this, done, _connectionID));
78516       function done(err, xml) {
78517         delete _noteCache.inflightPost[note.id];
78518         if (err) {
78519           return callback(err);
78520         }
78521         this.removeNote(note);
78522         var options2 = { skipSeen: false };
78523         return parseXML(xml, function(err2, results) {
78524           if (err2) {
78525             return callback(err2);
78526           } else {
78527             return callback(void 0, results[0]);
78528           }
78529         }, options2);
78530       }
78531     },
78532     // Update a note
78533     // POST /api/0.6/notes/#id/comment?text=comment
78534     // POST /api/0.6/notes/#id/close?text=comment
78535     // POST /api/0.6/notes/#id/reopen?text=comment
78536     postNoteUpdate: function(note, newStatus, callback) {
78537       if (!this.authenticated()) {
78538         return callback({ message: "Not Authenticated", status: -3 }, note);
78539       }
78540       if (_noteCache.inflightPost[note.id]) {
78541         return callback({ message: "Note update already inflight", status: -2 }, note);
78542       }
78543       var action;
78544       if (note.status !== "closed" && newStatus === "closed") {
78545         action = "close";
78546       } else if (note.status !== "open" && newStatus === "open") {
78547         action = "reopen";
78548       } else {
78549         action = "comment";
78550         if (!note.newComment) return;
78551       }
78552       var path = "/api/0.6/notes/" + note.id + "/" + action;
78553       if (note.newComment) {
78554         path += "?" + utilQsString({ text: note.newComment });
78555       }
78556       _noteCache.inflightPost[note.id] = oauth.xhr({
78557         method: "POST",
78558         path
78559       }, wrapcb(this, done, _connectionID));
78560       function done(err, xml) {
78561         delete _noteCache.inflightPost[note.id];
78562         if (err) {
78563           return callback(err);
78564         }
78565         this.removeNote(note);
78566         if (action === "close") {
78567           _noteCache.closed[note.id] = true;
78568         } else if (action === "reopen") {
78569           delete _noteCache.closed[note.id];
78570         }
78571         var options2 = { skipSeen: false };
78572         return parseXML(xml, function(err2, results) {
78573           if (err2) {
78574             return callback(err2);
78575           } else {
78576             return callback(void 0, results[0]);
78577           }
78578         }, options2);
78579       }
78580     },
78581     /* connection options for source switcher (optional) */
78582     apiConnections: function(val) {
78583       if (!arguments.length) return _apiConnections;
78584       _apiConnections = val;
78585       return this;
78586     },
78587     switch: function(newOptions) {
78588       urlroot = newOptions.url;
78589       apiUrlroot = newOptions.apiUrl || urlroot;
78590       if (newOptions.url && !newOptions.apiUrl) {
78591         newOptions = __spreadProps(__spreadValues({}, newOptions), {
78592           apiUrl: newOptions.url
78593         });
78594       }
78595       const oldOptions = utilObjectOmit(oauth.options(), "access_token");
78596       oauth.options(__spreadValues(__spreadValues({}, oldOptions), newOptions));
78597       this.reset();
78598       this.userChangesets(function() {
78599       });
78600       dispatch9.call("change");
78601       return this;
78602     },
78603     toggle: function(val) {
78604       _off = !val;
78605       return this;
78606     },
78607     isChangesetInflight: function() {
78608       return !!_changeset.inflight;
78609     },
78610     // get/set cached data
78611     // This is used to save/restore the state when entering/exiting the walkthrough
78612     // Also used for testing purposes.
78613     caches: function(obj) {
78614       function cloneCache(source) {
78615         var target = {};
78616         Object.keys(source).forEach(function(k2) {
78617           if (k2 === "rtree") {
78618             target.rtree = new RBush().fromJSON(source.rtree.toJSON());
78619           } else if (k2 === "note") {
78620             target.note = {};
78621             Object.keys(source.note).forEach(function(id2) {
78622               target.note[id2] = osmNote(source.note[id2]);
78623             });
78624           } else {
78625             target[k2] = JSON.parse(JSON.stringify(source[k2]));
78626           }
78627         });
78628         return target;
78629       }
78630       if (!arguments.length) {
78631         return {
78632           tile: cloneCache(_tileCache),
78633           note: cloneCache(_noteCache),
78634           user: cloneCache(_userCache)
78635         };
78636       }
78637       if (obj === "get") {
78638         return {
78639           tile: _tileCache,
78640           note: _noteCache,
78641           user: _userCache
78642         };
78643       }
78644       if (obj.tile) {
78645         _tileCache = obj.tile;
78646         _tileCache.inflight = {};
78647       }
78648       if (obj.note) {
78649         _noteCache = obj.note;
78650         _noteCache.inflight = {};
78651         _noteCache.inflightPost = {};
78652       }
78653       if (obj.user) {
78654         _userCache = obj.user;
78655       }
78656       return this;
78657     },
78658     logout: function() {
78659       _userChangesets = void 0;
78660       _userDetails = void 0;
78661       oauth.logout();
78662       dispatch9.call("change");
78663       return this;
78664     },
78665     authenticated: function() {
78666       return oauth.authenticated();
78667     },
78668     /** @param {import('osm-auth').LoginOptions} options */
78669     authenticate: function(callback, options2) {
78670       var that = this;
78671       var cid = _connectionID;
78672       _userChangesets = void 0;
78673       _userDetails = void 0;
78674       function done(err, res) {
78675         if (err) {
78676           if (callback) callback(err);
78677           return;
78678         }
78679         if (that.getConnectionId() !== cid) {
78680           if (callback) callback({ message: "Connection Switched", status: -1 });
78681           return;
78682         }
78683         _rateLimitError = void 0;
78684         dispatch9.call("change");
78685         if (callback) callback(err, res);
78686         that.userChangesets(function() {
78687         });
78688       }
78689       oauth.options(__spreadProps(__spreadValues({}, oauth.options()), {
78690         locale: _mainLocalizer.localeCode()
78691       }));
78692       oauth.authenticate(done, options2);
78693     },
78694     imageryBlocklists: function() {
78695       return _imageryBlocklists;
78696     },
78697     tileZoom: function(val) {
78698       if (!arguments.length) return _tileZoom3;
78699       _tileZoom3 = val;
78700       return this;
78701     },
78702     // get all cached notes covering the viewport
78703     notes: function(projection2) {
78704       var viewport = projection2.clipExtent();
78705       var min3 = [viewport[0][0], viewport[1][1]];
78706       var max3 = [viewport[1][0], viewport[0][1]];
78707       var bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
78708       return _noteCache.rtree.search(bbox2).map(function(d2) {
78709         return d2.data;
78710       });
78711     },
78712     // get a single note from the cache
78713     getNote: function(id2) {
78714       return _noteCache.note[id2];
78715     },
78716     // remove a single note from the cache
78717     removeNote: function(note) {
78718       if (!(note instanceof osmNote) || !note.id) return;
78719       delete _noteCache.note[note.id];
78720       updateRtree3(encodeNoteRtree(note), false);
78721     },
78722     // replace a single note in the cache
78723     replaceNote: function(note) {
78724       if (!(note instanceof osmNote) || !note.id) return;
78725       _noteCache.note[note.id] = note;
78726       updateRtree3(encodeNoteRtree(note), true);
78727       return note;
78728     },
78729     // Get an array of note IDs closed during this session.
78730     // Used to populate `closed:note` changeset tag
78731     getClosedIDs: function() {
78732       return Object.keys(_noteCache.closed).sort();
78733     }
78734   };
78735
78736   // modules/services/osm_wikibase.js
78737   var apibase3 = "https://wiki.openstreetmap.org/w/api.php";
78738   var _inflight2 = {};
78739   var _wikibaseCache = {};
78740   var _localeIDs = { en: false };
78741   var debouncedRequest = debounce_default(request, 500, { leading: false });
78742   function request(url, callback) {
78743     if (_inflight2[url]) return;
78744     var controller = new AbortController();
78745     _inflight2[url] = controller;
78746     json_default(url, { signal: controller.signal }).then(function(result) {
78747       delete _inflight2[url];
78748       if (callback) callback(null, result);
78749     }).catch(function(err) {
78750       delete _inflight2[url];
78751       if (err.name === "AbortError") return;
78752       if (callback) callback(err.message);
78753     });
78754   }
78755   var osm_wikibase_default = {
78756     init: function() {
78757       _inflight2 = {};
78758       _wikibaseCache = {};
78759       _localeIDs = {};
78760     },
78761     reset: function() {
78762       Object.values(_inflight2).forEach(function(controller) {
78763         controller.abort();
78764       });
78765       _inflight2 = {};
78766     },
78767     /**
78768      * Get the best value for the property, or undefined if not found
78769      * @param entity object from wikibase
78770      * @param property string e.g. 'P4' for image
78771      * @param langCode string e.g. 'fr' for French
78772      */
78773     claimToValue: function(entity, property, langCode) {
78774       if (!entity.claims[property]) return void 0;
78775       var locale2 = _localeIDs[langCode];
78776       var preferredPick, localePick;
78777       entity.claims[property].forEach(function(stmt) {
78778         if (!preferredPick && stmt.rank === "preferred") {
78779           preferredPick = stmt;
78780         }
78781         if (locale2 && stmt.qualifiers && stmt.qualifiers.P26 && stmt.qualifiers.P26[0].datavalue.value.id === locale2) {
78782           localePick = stmt;
78783         }
78784       });
78785       var result = localePick || preferredPick;
78786       if (result) {
78787         var datavalue = result.mainsnak.datavalue;
78788         return datavalue.type === "wikibase-entityid" ? datavalue.value.id : datavalue.value;
78789       } else {
78790         return void 0;
78791       }
78792     },
78793     /**
78794      * Convert monolingual property into a key-value object (language -> value)
78795      * @param entity object from wikibase
78796      * @param property string e.g. 'P31' for monolingual wiki page title
78797      */
78798     monolingualClaimToValueObj: function(entity, property) {
78799       if (!entity || !entity.claims[property]) return void 0;
78800       return entity.claims[property].reduce(function(acc, obj) {
78801         var value = obj.mainsnak.datavalue.value;
78802         acc[value.language] = value.text;
78803         return acc;
78804       }, {});
78805     },
78806     toSitelink: function(key, value) {
78807       var result = value ? "Tag:" + key + "=" + value : "Key:" + key;
78808       return result.replace(/_/g, " ").trim();
78809     },
78810     //
78811     // Pass params object of the form:
78812     // {
78813     //   key: 'string',
78814     //   value: 'string',
78815     //   langCode: 'string'
78816     // }
78817     //
78818     getEntity: function(params, callback) {
78819       var doRequest = params.debounce ? debouncedRequest : request;
78820       var that = this;
78821       var titles = [];
78822       var result = {};
78823       var rtypeSitelink = params.key === "type" && params.value ? ("Relation:" + params.value).replace(/_/g, " ").trim() : false;
78824       var keySitelink = params.key ? this.toSitelink(params.key) : false;
78825       var tagSitelink = params.key && params.value ? this.toSitelink(params.key, params.value) : false;
78826       var localeSitelink;
78827       if (params.langCodes) {
78828         params.langCodes.forEach(function(langCode) {
78829           if (_localeIDs[langCode] === void 0) {
78830             localeSitelink = ("Locale:" + langCode).replace(/_/g, " ").trim();
78831             titles.push(localeSitelink);
78832           }
78833         });
78834       }
78835       if (rtypeSitelink) {
78836         if (_wikibaseCache[rtypeSitelink]) {
78837           result.rtype = _wikibaseCache[rtypeSitelink];
78838         } else {
78839           titles.push(rtypeSitelink);
78840         }
78841       }
78842       if (keySitelink) {
78843         if (_wikibaseCache[keySitelink]) {
78844           result.key = _wikibaseCache[keySitelink];
78845         } else {
78846           titles.push(keySitelink);
78847         }
78848       }
78849       if (tagSitelink) {
78850         if (_wikibaseCache[tagSitelink]) {
78851           result.tag = _wikibaseCache[tagSitelink];
78852         } else {
78853           titles.push(tagSitelink);
78854         }
78855       }
78856       if (!titles.length) {
78857         return callback(null, result);
78858       }
78859       var obj = {
78860         action: "wbgetentities",
78861         sites: "wiki",
78862         titles: titles.join("|"),
78863         languages: params.langCodes.join("|"),
78864         languagefallback: 1,
78865         origin: "*",
78866         format: "json"
78867         // There is an MW Wikibase API bug https://phabricator.wikimedia.org/T212069
78868         // We shouldn't use v1 until it gets fixed, but should switch to it afterwards
78869         // formatversion: 2,
78870       };
78871       var url = apibase3 + "?" + utilQsString(obj);
78872       doRequest(url, function(err, d2) {
78873         if (err) {
78874           callback(err);
78875         } else if (!d2.success || d2.error) {
78876           callback(d2.error.messages.map(function(v2) {
78877             return v2.html["*"];
78878           }).join("<br>"));
78879         } else {
78880           var localeID = false;
78881           Object.values(d2.entities).forEach(function(res) {
78882             if (res.missing !== "") {
78883               var title = res.sitelinks.wiki.title;
78884               if (title === rtypeSitelink) {
78885                 _wikibaseCache[rtypeSitelink] = res;
78886                 result.rtype = res;
78887               } else if (title === keySitelink) {
78888                 _wikibaseCache[keySitelink] = res;
78889                 result.key = res;
78890               } else if (title === tagSitelink) {
78891                 _wikibaseCache[tagSitelink] = res;
78892                 result.tag = res;
78893               } else if (title === localeSitelink) {
78894                 localeID = res.id;
78895               } else {
78896                 console.log("Unexpected title " + title);
78897               }
78898             }
78899           });
78900           if (localeSitelink) {
78901             that.addLocale(params.langCodes[0], localeID);
78902           }
78903           callback(null, result);
78904         }
78905       });
78906     },
78907     //
78908     // Pass params object of the form:
78909     // {
78910     //   key: 'string',     // required
78911     //   value: 'string'    // optional
78912     // }
78913     //
78914     // Get an result object used to display tag documentation
78915     // {
78916     //   title:        'string',
78917     //   description:  'string',
78918     //   editURL:      'string',
78919     //   imageURL:     'string',
78920     //   wiki:         { title: 'string', text: 'string', url: 'string' }
78921     // }
78922     //
78923     getDocs: function(params, callback) {
78924       var that = this;
78925       var langCodes = _mainLocalizer.localeCodes().map(function(code) {
78926         return code.toLowerCase();
78927       });
78928       params.langCodes = langCodes;
78929       this.getEntity(params, function(err, data) {
78930         if (err) {
78931           callback(err);
78932           return;
78933         }
78934         var entity = data.rtype || data.tag || data.key;
78935         if (!entity) {
78936           callback("No entity");
78937           return;
78938         }
78939         var i3;
78940         var description;
78941         for (i3 in langCodes) {
78942           let code2 = langCodes[i3];
78943           if (entity.descriptions[code2] && entity.descriptions[code2].language === code2) {
78944             description = entity.descriptions[code2];
78945             break;
78946           }
78947         }
78948         if (!description && Object.values(entity.descriptions).length) description = Object.values(entity.descriptions)[0];
78949         var result = {
78950           title: entity.title,
78951           description: description ? description.value : "",
78952           descriptionLocaleCode: description ? description.language : "",
78953           editURL: "https://wiki.openstreetmap.org/wiki/" + entity.title
78954         };
78955         if (entity.claims) {
78956           var imageroot;
78957           var image = that.claimToValue(entity, "P4", langCodes[0]);
78958           if (image) {
78959             imageroot = "https://commons.wikimedia.org/w/index.php";
78960           } else {
78961             image = that.claimToValue(entity, "P28", langCodes[0]);
78962             if (image) {
78963               imageroot = "https://wiki.openstreetmap.org/w/index.php";
78964             }
78965           }
78966           if (imageroot && image) {
78967             result.imageURL = imageroot + "?" + utilQsString({
78968               title: "Special:Redirect/file/" + image,
78969               width: 400
78970             });
78971           }
78972         }
78973         var rtypeWiki = that.monolingualClaimToValueObj(data.rtype, "P31");
78974         var tagWiki = that.monolingualClaimToValueObj(data.tag, "P31");
78975         var keyWiki = that.monolingualClaimToValueObj(data.key, "P31");
78976         var wikis = [rtypeWiki, tagWiki, keyWiki];
78977         for (i3 in wikis) {
78978           var wiki = wikis[i3];
78979           for (var j2 in langCodes) {
78980             var code = langCodes[j2];
78981             var referenceId = langCodes[0].split("-")[0] !== "en" && code.split("-")[0] === "en" ? "inspector.wiki_en_reference" : "inspector.wiki_reference";
78982             var info = getWikiInfo(wiki, code, referenceId);
78983             if (info) {
78984               result.wiki = info;
78985               break;
78986             }
78987           }
78988           if (result.wiki) break;
78989         }
78990         callback(null, result);
78991         function getWikiInfo(wiki2, langCode, tKey) {
78992           if (wiki2 && wiki2[langCode]) {
78993             return {
78994               title: wiki2[langCode],
78995               text: tKey,
78996               url: "https://wiki.openstreetmap.org/wiki/" + wiki2[langCode]
78997             };
78998           }
78999         }
79000       });
79001     },
79002     addLocale: function(langCode, qid) {
79003       _localeIDs[langCode] = qid;
79004     },
79005     apibase: function(val) {
79006       if (!arguments.length) return apibase3;
79007       apibase3 = val;
79008       return this;
79009     }
79010   };
79011
79012   // modules/services/streetside.js
79013   var streetsideApi = "https://dev.virtualearth.net/REST/v1/Imagery/MetaData/Streetside?mapArea={bbox}&key={key}&count={count}";
79014   var maxResults2 = 500;
79015   var bubbleAppKey = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0");
79016   var pannellumViewerCSS2 = "pannellum/pannellum.css";
79017   var pannellumViewerJS2 = "pannellum/pannellum.js";
79018   var tileZoom3 = 16.5;
79019   var tiler6 = utilTiler().zoomExtent([tileZoom3, tileZoom3]).skipNullIsland(true);
79020   var dispatch10 = dispatch_default("loadedImages", "viewerChanged");
79021   var minHfov = 10;
79022   var maxHfov = 90;
79023   var defaultHfov = 45;
79024   var _hires = false;
79025   var _resolution = 512;
79026   var _currScene = 0;
79027   var _ssCache;
79028   var _pannellumViewer2;
79029   var _sceneOptions = {
79030     showFullscreenCtrl: false,
79031     autoLoad: true,
79032     compass: true,
79033     yaw: 0,
79034     minHfov,
79035     maxHfov,
79036     hfov: defaultHfov,
79037     type: "cubemap",
79038     cubeMap: []
79039   };
79040   var _loadViewerPromise4;
79041   function abortRequest5(i3) {
79042     i3.abort();
79043   }
79044   function localeTimestamp2(s2) {
79045     if (!s2) return null;
79046     const options2 = { day: "numeric", month: "short", year: "numeric" };
79047     const d2 = new Date(s2);
79048     if (isNaN(d2.getTime())) return null;
79049     return d2.toLocaleString(_mainLocalizer.localeCode(), options2);
79050   }
79051   function loadTiles3(which, url, projection2, margin) {
79052     const tiles = tiler6.margin(margin).getTiles(projection2);
79053     const cache = _ssCache[which];
79054     Object.keys(cache.inflight).forEach((k2) => {
79055       const wanted = tiles.find((tile) => k2.indexOf(tile.id + ",") === 0);
79056       if (!wanted) {
79057         abortRequest5(cache.inflight[k2]);
79058         delete cache.inflight[k2];
79059       }
79060     });
79061     tiles.forEach((tile) => loadNextTilePage2(which, url, tile));
79062   }
79063   function loadNextTilePage2(which, url, tile) {
79064     const cache = _ssCache[which];
79065     const nextPage = cache.nextPage[tile.id] || 0;
79066     const id2 = tile.id + "," + String(nextPage);
79067     if (cache.loaded[id2] || cache.inflight[id2]) return;
79068     cache.inflight[id2] = getBubbles(url, tile, (response) => {
79069       cache.loaded[id2] = true;
79070       delete cache.inflight[id2];
79071       if (!response) return;
79072       if (response.resourceSets[0].resources.length === maxResults2) {
79073         const split = tile.extent.split();
79074         loadNextTilePage2(which, url, { id: tile.id + ",a", extent: split[0] });
79075         loadNextTilePage2(which, url, { id: tile.id + ",b", extent: split[1] });
79076         loadNextTilePage2(which, url, { id: tile.id + ",c", extent: split[2] });
79077         loadNextTilePage2(which, url, { id: tile.id + ",d", extent: split[3] });
79078       }
79079       const features = response.resourceSets[0].resources.map((bubble) => {
79080         const bubbleId = bubble.imageUrl;
79081         if (cache.points[bubbleId]) return null;
79082         const loc = [
79083           bubble.lon || bubble.longitude,
79084           bubble.lat || bubble.latitude
79085         ];
79086         const d2 = {
79087           loc,
79088           key: bubbleId,
79089           imageUrl: bubble.imageUrl.replace(
79090             "{subdomain}",
79091             bubble.imageUrlSubdomains[0]
79092           ),
79093           ca: bubble.he || bubble.heading,
79094           captured_at: bubble.vintageEnd,
79095           captured_by: "microsoft",
79096           pano: true,
79097           sequenceKey: null
79098         };
79099         cache.points[bubbleId] = d2;
79100         return {
79101           minX: loc[0],
79102           minY: loc[1],
79103           maxX: loc[0],
79104           maxY: loc[1],
79105           data: d2
79106         };
79107       }).filter(Boolean);
79108       cache.rtree.load(features);
79109       if (which === "bubbles") {
79110         dispatch10.call("loadedImages");
79111       }
79112     });
79113   }
79114   function getBubbles(url, tile, callback) {
79115     let rect = tile.extent.rectangle();
79116     let urlForRequest = url.replace("{key}", bubbleAppKey).replace("{bbox}", [rect[1], rect[0], rect[3], rect[2]].join(",")).replace("{count}", maxResults2);
79117     const controller = new AbortController();
79118     fetch(urlForRequest, { signal: controller.signal }).then(function(response) {
79119       if (!response.ok) {
79120         throw new Error(response.status + " " + response.statusText);
79121       }
79122       return response.json();
79123     }).then(function(result) {
79124       if (!result) {
79125         callback(null);
79126       }
79127       return callback(result || []);
79128     }).catch(function(err) {
79129       if (err.name === "AbortError") {
79130       } else {
79131         throw new Error(err);
79132       }
79133     });
79134     return controller;
79135   }
79136   function partitionViewport4(projection2) {
79137     let z2 = geoScaleToZoom(projection2.scale());
79138     let z22 = Math.ceil(z2 * 2) / 2 + 2.5;
79139     let tiler8 = utilTiler().zoomExtent([z22, z22]);
79140     return tiler8.getTiles(projection2).map((tile) => tile.extent);
79141   }
79142   function searchLimited4(limit, projection2, rtree) {
79143     limit = limit || 5;
79144     return partitionViewport4(projection2).reduce((result, extent) => {
79145       let found = rtree.search(extent.bbox()).slice(0, limit).map((d2) => d2.data);
79146       return found.length ? result.concat(found) : result;
79147     }, []);
79148   }
79149   function loadImage2(imgInfo) {
79150     return new Promise((resolve) => {
79151       let img = new Image();
79152       img.onload = () => {
79153         let canvas = document.getElementById("ideditor-canvas" + imgInfo.face);
79154         let ctx = canvas.getContext("2d");
79155         ctx.drawImage(img, imgInfo.x, imgInfo.y);
79156         resolve({ imgInfo, status: "ok" });
79157       };
79158       img.onerror = () => {
79159         resolve({ data: imgInfo, status: "error" });
79160       };
79161       img.setAttribute("crossorigin", "");
79162       img.src = imgInfo.url;
79163     });
79164   }
79165   function loadCanvas(imageGroup) {
79166     return Promise.all(imageGroup.map(loadImage2)).then((data) => {
79167       let canvas = document.getElementById("ideditor-canvas" + data[0].imgInfo.face);
79168       const which = { "01": 0, "02": 1, "03": 2, "10": 3, "11": 4, "12": 5 };
79169       let face = data[0].imgInfo.face;
79170       _sceneOptions.cubeMap[which[face]] = canvas.toDataURL("image/jpeg", 1);
79171       return { status: "loadCanvas for face " + data[0].imgInfo.face + "ok" };
79172     });
79173   }
79174   function loadFaces(faceGroup) {
79175     return Promise.all(faceGroup.map(loadCanvas)).then(() => {
79176       return { status: "loadFaces done" };
79177     });
79178   }
79179   function setupCanvas(selection2, reset) {
79180     if (reset) {
79181       selection2.selectAll("#ideditor-stitcher-canvases").remove();
79182     }
79183     selection2.selectAll("#ideditor-stitcher-canvases").data([0]).enter().append("div").attr("id", "ideditor-stitcher-canvases").attr("display", "none").selectAll("canvas").data(["canvas01", "canvas02", "canvas03", "canvas10", "canvas11", "canvas12"]).enter().append("canvas").attr("id", (d2) => "ideditor-" + d2).attr("width", _resolution).attr("height", _resolution);
79184   }
79185   function qkToXY(qk) {
79186     let x2 = 0;
79187     let y2 = 0;
79188     let scale = 256;
79189     for (let i3 = qk.length; i3 > 0; i3--) {
79190       const key = qk[i3 - 1];
79191       x2 += +(key === "1" || key === "3") * scale;
79192       y2 += +(key === "2" || key === "3") * scale;
79193       scale *= 2;
79194     }
79195     return [x2, y2];
79196   }
79197   function getQuadKeys() {
79198     let dim = _resolution / 256;
79199     let quadKeys;
79200     if (dim === 16) {
79201       quadKeys = [
79202         "0000",
79203         "0001",
79204         "0010",
79205         "0011",
79206         "0100",
79207         "0101",
79208         "0110",
79209         "0111",
79210         "1000",
79211         "1001",
79212         "1010",
79213         "1011",
79214         "1100",
79215         "1101",
79216         "1110",
79217         "1111",
79218         "0002",
79219         "0003",
79220         "0012",
79221         "0013",
79222         "0102",
79223         "0103",
79224         "0112",
79225         "0113",
79226         "1002",
79227         "1003",
79228         "1012",
79229         "1013",
79230         "1102",
79231         "1103",
79232         "1112",
79233         "1113",
79234         "0020",
79235         "0021",
79236         "0030",
79237         "0031",
79238         "0120",
79239         "0121",
79240         "0130",
79241         "0131",
79242         "1020",
79243         "1021",
79244         "1030",
79245         "1031",
79246         "1120",
79247         "1121",
79248         "1130",
79249         "1131",
79250         "0022",
79251         "0023",
79252         "0032",
79253         "0033",
79254         "0122",
79255         "0123",
79256         "0132",
79257         "0133",
79258         "1022",
79259         "1023",
79260         "1032",
79261         "1033",
79262         "1122",
79263         "1123",
79264         "1132",
79265         "1133",
79266         "0200",
79267         "0201",
79268         "0210",
79269         "0211",
79270         "0300",
79271         "0301",
79272         "0310",
79273         "0311",
79274         "1200",
79275         "1201",
79276         "1210",
79277         "1211",
79278         "1300",
79279         "1301",
79280         "1310",
79281         "1311",
79282         "0202",
79283         "0203",
79284         "0212",
79285         "0213",
79286         "0302",
79287         "0303",
79288         "0312",
79289         "0313",
79290         "1202",
79291         "1203",
79292         "1212",
79293         "1213",
79294         "1302",
79295         "1303",
79296         "1312",
79297         "1313",
79298         "0220",
79299         "0221",
79300         "0230",
79301         "0231",
79302         "0320",
79303         "0321",
79304         "0330",
79305         "0331",
79306         "1220",
79307         "1221",
79308         "1230",
79309         "1231",
79310         "1320",
79311         "1321",
79312         "1330",
79313         "1331",
79314         "0222",
79315         "0223",
79316         "0232",
79317         "0233",
79318         "0322",
79319         "0323",
79320         "0332",
79321         "0333",
79322         "1222",
79323         "1223",
79324         "1232",
79325         "1233",
79326         "1322",
79327         "1323",
79328         "1332",
79329         "1333",
79330         "2000",
79331         "2001",
79332         "2010",
79333         "2011",
79334         "2100",
79335         "2101",
79336         "2110",
79337         "2111",
79338         "3000",
79339         "3001",
79340         "3010",
79341         "3011",
79342         "3100",
79343         "3101",
79344         "3110",
79345         "3111",
79346         "2002",
79347         "2003",
79348         "2012",
79349         "2013",
79350         "2102",
79351         "2103",
79352         "2112",
79353         "2113",
79354         "3002",
79355         "3003",
79356         "3012",
79357         "3013",
79358         "3102",
79359         "3103",
79360         "3112",
79361         "3113",
79362         "2020",
79363         "2021",
79364         "2030",
79365         "2031",
79366         "2120",
79367         "2121",
79368         "2130",
79369         "2131",
79370         "3020",
79371         "3021",
79372         "3030",
79373         "3031",
79374         "3120",
79375         "3121",
79376         "3130",
79377         "3131",
79378         "2022",
79379         "2023",
79380         "2032",
79381         "2033",
79382         "2122",
79383         "2123",
79384         "2132",
79385         "2133",
79386         "3022",
79387         "3023",
79388         "3032",
79389         "3033",
79390         "3122",
79391         "3123",
79392         "3132",
79393         "3133",
79394         "2200",
79395         "2201",
79396         "2210",
79397         "2211",
79398         "2300",
79399         "2301",
79400         "2310",
79401         "2311",
79402         "3200",
79403         "3201",
79404         "3210",
79405         "3211",
79406         "3300",
79407         "3301",
79408         "3310",
79409         "3311",
79410         "2202",
79411         "2203",
79412         "2212",
79413         "2213",
79414         "2302",
79415         "2303",
79416         "2312",
79417         "2313",
79418         "3202",
79419         "3203",
79420         "3212",
79421         "3213",
79422         "3302",
79423         "3303",
79424         "3312",
79425         "3313",
79426         "2220",
79427         "2221",
79428         "2230",
79429         "2231",
79430         "2320",
79431         "2321",
79432         "2330",
79433         "2331",
79434         "3220",
79435         "3221",
79436         "3230",
79437         "3231",
79438         "3320",
79439         "3321",
79440         "3330",
79441         "3331",
79442         "2222",
79443         "2223",
79444         "2232",
79445         "2233",
79446         "2322",
79447         "2323",
79448         "2332",
79449         "2333",
79450         "3222",
79451         "3223",
79452         "3232",
79453         "3233",
79454         "3322",
79455         "3323",
79456         "3332",
79457         "3333"
79458       ];
79459     } else if (dim === 8) {
79460       quadKeys = [
79461         "000",
79462         "001",
79463         "010",
79464         "011",
79465         "100",
79466         "101",
79467         "110",
79468         "111",
79469         "002",
79470         "003",
79471         "012",
79472         "013",
79473         "102",
79474         "103",
79475         "112",
79476         "113",
79477         "020",
79478         "021",
79479         "030",
79480         "031",
79481         "120",
79482         "121",
79483         "130",
79484         "131",
79485         "022",
79486         "023",
79487         "032",
79488         "033",
79489         "122",
79490         "123",
79491         "132",
79492         "133",
79493         "200",
79494         "201",
79495         "210",
79496         "211",
79497         "300",
79498         "301",
79499         "310",
79500         "311",
79501         "202",
79502         "203",
79503         "212",
79504         "213",
79505         "302",
79506         "303",
79507         "312",
79508         "313",
79509         "220",
79510         "221",
79511         "230",
79512         "231",
79513         "320",
79514         "321",
79515         "330",
79516         "331",
79517         "222",
79518         "223",
79519         "232",
79520         "233",
79521         "322",
79522         "323",
79523         "332",
79524         "333"
79525       ];
79526     } else if (dim === 4) {
79527       quadKeys = [
79528         "00",
79529         "01",
79530         "10",
79531         "11",
79532         "02",
79533         "03",
79534         "12",
79535         "13",
79536         "20",
79537         "21",
79538         "30",
79539         "31",
79540         "22",
79541         "23",
79542         "32",
79543         "33"
79544       ];
79545     } else {
79546       quadKeys = [
79547         "0",
79548         "1",
79549         "2",
79550         "3"
79551       ];
79552     }
79553     return quadKeys;
79554   }
79555   var streetside_default = {
79556     /**
79557      * init() initialize streetside.
79558      */
79559     init: function() {
79560       if (!_ssCache) {
79561         this.reset();
79562       }
79563       this.event = utilRebind(this, dispatch10, "on");
79564     },
79565     /**
79566      * reset() reset the cache.
79567      */
79568     reset: function() {
79569       if (_ssCache) {
79570         Object.values(_ssCache.bubbles.inflight).forEach(abortRequest5);
79571       }
79572       _ssCache = {
79573         bubbles: { inflight: {}, loaded: {}, nextPage: {}, rtree: new RBush(), points: {} },
79574         sequences: {}
79575       };
79576     },
79577     /**
79578      * bubbles()
79579      */
79580     bubbles: function(projection2) {
79581       const limit = 5;
79582       return searchLimited4(limit, projection2, _ssCache.bubbles.rtree);
79583     },
79584     cachedImage: function(imageKey) {
79585       return _ssCache.bubbles.points[imageKey];
79586     },
79587     sequences: function(projection2) {
79588       const viewport = projection2.clipExtent();
79589       const min3 = [viewport[0][0], viewport[1][1]];
79590       const max3 = [viewport[1][0], viewport[0][1]];
79591       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
79592       let seen = {};
79593       let results = [];
79594       _ssCache.bubbles.rtree.search(bbox2).forEach((d2) => {
79595         const key = d2.data.sequenceKey;
79596         if (key && !seen[key]) {
79597           seen[key] = true;
79598           results.push(_ssCache.sequences[key].geojson);
79599         }
79600       });
79601       return results;
79602     },
79603     /**
79604      * loadBubbles()
79605      */
79606     loadBubbles: function(projection2, margin) {
79607       if (margin === void 0) margin = 2;
79608       loadTiles3("bubbles", streetsideApi, projection2, margin);
79609     },
79610     viewer: function() {
79611       return _pannellumViewer2;
79612     },
79613     initViewer: function() {
79614       if (!window.pannellum) return;
79615       if (_pannellumViewer2) return;
79616       _currScene += 1;
79617       const sceneID = _currScene.toString();
79618       const options2 = {
79619         "default": { firstScene: sceneID },
79620         scenes: {}
79621       };
79622       options2.scenes[sceneID] = _sceneOptions;
79623       _pannellumViewer2 = window.pannellum.viewer("ideditor-viewer-streetside", options2);
79624     },
79625     ensureViewerLoaded: function(context) {
79626       if (_loadViewerPromise4) return _loadViewerPromise4;
79627       let wrap2 = context.container().select(".photoviewer").selectAll(".ms-wrapper").data([0]);
79628       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper ms-wrapper").classed("hide", true);
79629       let that = this;
79630       let pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
79631       wrapEnter.append("div").attr("id", "ideditor-viewer-streetside").on(pointerPrefix + "down.streetside", () => {
79632         select_default2(window).on(pointerPrefix + "move.streetside", () => {
79633           dispatch10.call("viewerChanged");
79634         }, true);
79635       }).on(pointerPrefix + "up.streetside pointercancel.streetside", () => {
79636         select_default2(window).on(pointerPrefix + "move.streetside", null);
79637         let t2 = timer((elapsed) => {
79638           dispatch10.call("viewerChanged");
79639           if (elapsed > 2e3) {
79640             t2.stop();
79641           }
79642         });
79643       }).append("div").attr("class", "photo-attribution fillD");
79644       let controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
79645       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
79646       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
79647       wrap2 = wrap2.merge(wrapEnter).call(setupCanvas, true);
79648       context.ui().photoviewer.on("resize.streetside", () => {
79649         if (_pannellumViewer2) {
79650           _pannellumViewer2.resize();
79651         }
79652       });
79653       _loadViewerPromise4 = new Promise((resolve, reject) => {
79654         let loadedCount = 0;
79655         function loaded() {
79656           loadedCount += 1;
79657           if (loadedCount === 2) resolve();
79658         }
79659         const head = select_default2("head");
79660         head.selectAll("#ideditor-streetside-viewercss").data([0]).enter().append("link").attr("id", "ideditor-streetside-viewercss").attr("rel", "stylesheet").attr("crossorigin", "anonymous").attr("href", context.asset(pannellumViewerCSS2)).on("load.serviceStreetside", loaded).on("error.serviceStreetside", function() {
79661           reject();
79662         });
79663         head.selectAll("#ideditor-streetside-viewerjs").data([0]).enter().append("script").attr("id", "ideditor-streetside-viewerjs").attr("crossorigin", "anonymous").attr("src", context.asset(pannellumViewerJS2)).on("load.serviceStreetside", loaded).on("error.serviceStreetside", function() {
79664           reject();
79665         });
79666       }).catch(function() {
79667         _loadViewerPromise4 = null;
79668       });
79669       return _loadViewerPromise4;
79670       function step(stepBy) {
79671         return () => {
79672           let viewer = context.container().select(".photoviewer");
79673           let selected = viewer.empty() ? void 0 : viewer.datum();
79674           if (!selected) return;
79675           let nextID = stepBy === 1 ? selected.ne : selected.pr;
79676           let yaw = _pannellumViewer2.getYaw();
79677           let ca = selected.ca + yaw;
79678           let origin = selected.loc;
79679           const meters = 35;
79680           let p1 = [
79681             origin[0] + geoMetersToLon(meters / 5, origin[1]),
79682             origin[1]
79683           ];
79684           let p2 = [
79685             origin[0] + geoMetersToLon(meters / 2, origin[1]),
79686             origin[1] + geoMetersToLat(meters)
79687           ];
79688           let p3 = [
79689             origin[0] - geoMetersToLon(meters / 2, origin[1]),
79690             origin[1] + geoMetersToLat(meters)
79691           ];
79692           let p4 = [
79693             origin[0] - geoMetersToLon(meters / 5, origin[1]),
79694             origin[1]
79695           ];
79696           let poly = [p1, p2, p3, p4, p1];
79697           let angle2 = (stepBy === 1 ? ca : ca + 180) * (Math.PI / 180);
79698           poly = geoRotate(poly, -angle2, origin);
79699           let extent = poly.reduce((extent2, point) => {
79700             return extent2.extend(geoExtent(point));
79701           }, geoExtent());
79702           let minDist = Infinity;
79703           _ssCache.bubbles.rtree.search(extent.bbox()).forEach((d2) => {
79704             if (d2.data.key === selected.key) return;
79705             if (!geoPointInPolygon(d2.data.loc, poly)) return;
79706             let dist = geoVecLength(d2.data.loc, selected.loc);
79707             let theta = selected.ca - d2.data.ca;
79708             let minTheta = Math.min(Math.abs(theta), 360 - Math.abs(theta));
79709             if (minTheta > 20) {
79710               dist += 5;
79711             }
79712             if (dist < minDist) {
79713               nextID = d2.data.key;
79714               minDist = dist;
79715             }
79716           });
79717           let nextBubble = nextID && that.cachedImage(nextID);
79718           if (!nextBubble) return;
79719           context.map().centerEase(nextBubble.loc);
79720           that.selectImage(context, nextBubble.key).yaw(yaw).showViewer(context);
79721         };
79722       }
79723     },
79724     yaw: function(yaw) {
79725       if (typeof yaw !== "number") return yaw;
79726       _sceneOptions.yaw = yaw;
79727       return this;
79728     },
79729     /**
79730      * showViewer()
79731      */
79732     showViewer: function(context) {
79733       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
79734       let isHidden = wrap2.selectAll(".photo-wrapper.ms-wrapper.hide").size();
79735       if (isHidden) {
79736         wrap2.selectAll(".photo-wrapper:not(.ms-wrapper)").classed("hide", true);
79737         wrap2.selectAll(".photo-wrapper.ms-wrapper").classed("hide", false);
79738       }
79739       return this;
79740     },
79741     /**
79742      * hideViewer()
79743      */
79744     hideViewer: function(context) {
79745       let viewer = context.container().select(".photoviewer");
79746       if (!viewer.empty()) viewer.datum(null);
79747       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
79748       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
79749       this.updateUrlImage(null);
79750       return this.setStyles(context, null, true);
79751     },
79752     /**
79753      * selectImage().
79754      */
79755     selectImage: function(context, key) {
79756       let that = this;
79757       let d2 = this.cachedImage(key);
79758       let viewer = context.container().select(".photoviewer");
79759       if (!viewer.empty()) viewer.datum(d2);
79760       this.setStyles(context, null, true);
79761       let wrap2 = context.container().select(".photoviewer .ms-wrapper");
79762       let attribution = wrap2.selectAll(".photo-attribution").html("");
79763       wrap2.selectAll(".pnlm-load-box").style("display", "block");
79764       if (!d2) return this;
79765       this.updateUrlImage(key);
79766       _sceneOptions.northOffset = d2.ca;
79767       let line1 = attribution.append("div").attr("class", "attribution-row");
79768       const hiresDomId = utilUniqueDomId("streetside-hires");
79769       let label = line1.append("label").attr("for", hiresDomId).attr("class", "streetside-hires");
79770       label.append("input").attr("type", "checkbox").attr("id", hiresDomId).property("checked", _hires).on("click", (d3_event) => {
79771         d3_event.stopPropagation();
79772         _hires = !_hires;
79773         _resolution = _hires ? 1024 : 512;
79774         wrap2.call(setupCanvas, true);
79775         let viewstate = {
79776           yaw: _pannellumViewer2.getYaw(),
79777           pitch: _pannellumViewer2.getPitch(),
79778           hfov: _pannellumViewer2.getHfov()
79779         };
79780         _sceneOptions = Object.assign(_sceneOptions, viewstate);
79781         that.selectImage(context, d2.key).showViewer(context);
79782       });
79783       label.append("span").call(_t.append("streetside.hires"));
79784       let captureInfo = line1.append("div").attr("class", "attribution-capture-info");
79785       if (d2.captured_by) {
79786         const yyyy = (/* @__PURE__ */ new Date()).getFullYear();
79787         captureInfo.append("a").attr("class", "captured_by").attr("target", "_blank").attr("href", "https://www.microsoft.com/en-us/maps/streetside").text("\xA9" + yyyy + " Microsoft");
79788         captureInfo.append("span").text("|");
79789       }
79790       if (d2.captured_at) {
79791         captureInfo.append("span").attr("class", "captured_at").text(localeTimestamp2(d2.captured_at));
79792       }
79793       let line2 = attribution.append("div").attr("class", "attribution-row");
79794       line2.append("a").attr("class", "image-view-link").attr("target", "_blank").attr("href", "https://www.bing.com/maps?cp=" + d2.loc[1] + "~" + d2.loc[0] + "&lvl=17&dir=" + d2.ca + "&style=x&v=2&sV=1").call(_t.append("streetside.view_on_bing"));
79795       line2.append("a").attr("class", "image-report-link").attr("target", "_blank").attr("href", "https://www.bing.com/maps/privacyreport/streetsideprivacyreport?bubbleid=" + encodeURIComponent(d2.key) + "&focus=photo&lat=" + d2.loc[1] + "&lng=" + d2.loc[0] + "&z=17").call(_t.append("streetside.report"));
79796       const faceKeys = ["01", "02", "03", "10", "11", "12"];
79797       let quadKeys = getQuadKeys();
79798       let faces = faceKeys.map((faceKey) => {
79799         return quadKeys.map((quadKey) => {
79800           const xy = qkToXY(quadKey);
79801           return {
79802             face: faceKey,
79803             url: d2.imageUrl.replace("{faceId}", faceKey).replace("{tileId}", quadKey),
79804             x: xy[0],
79805             y: xy[1]
79806           };
79807         });
79808       });
79809       loadFaces(faces).then(function() {
79810         if (!_pannellumViewer2) {
79811           that.initViewer();
79812         } else {
79813           _currScene += 1;
79814           let sceneID = _currScene.toString();
79815           _pannellumViewer2.addScene(sceneID, _sceneOptions).loadScene(sceneID);
79816           if (_currScene > 2) {
79817             sceneID = (_currScene - 1).toString();
79818             _pannellumViewer2.removeScene(sceneID);
79819           }
79820         }
79821       });
79822       return this;
79823     },
79824     getSequenceKeyForBubble: function(d2) {
79825       return d2 && d2.sequenceKey;
79826     },
79827     // Updates the currently highlighted sequence and selected bubble.
79828     // Reset is only necessary when interacting with the viewport because
79829     // this implicitly changes the currently selected bubble/sequence
79830     setStyles: function(context, hovered, reset) {
79831       if (reset) {
79832         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
79833         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
79834       }
79835       let hoveredBubbleKey = hovered && hovered.key;
79836       let hoveredSequenceKey = this.getSequenceKeyForBubble(hovered);
79837       let hoveredSequence = hoveredSequenceKey && _ssCache.sequences[hoveredSequenceKey];
79838       let hoveredBubbleKeys = hoveredSequence && hoveredSequence.bubbles.map((d2) => d2.key) || [];
79839       let viewer = context.container().select(".photoviewer");
79840       let selected = viewer.empty() ? void 0 : viewer.datum();
79841       let selectedBubbleKey = selected && selected.key;
79842       let selectedSequenceKey = this.getSequenceKeyForBubble(selected);
79843       let selectedSequence = selectedSequenceKey && _ssCache.sequences[selectedSequenceKey];
79844       let selectedBubbleKeys = selectedSequence && selectedSequence.bubbles.map((d2) => d2.key) || [];
79845       let highlightedBubbleKeys = utilArrayUnion(hoveredBubbleKeys, selectedBubbleKeys);
79846       context.container().selectAll(".layer-streetside-images .viewfield-group").classed("highlighted", (d2) => highlightedBubbleKeys.indexOf(d2.key) !== -1).classed("hovered", (d2) => d2.key === hoveredBubbleKey).classed("currentView", (d2) => d2.key === selectedBubbleKey);
79847       context.container().selectAll(".layer-streetside-images .sequence").classed("highlighted", (d2) => d2.properties.key === hoveredSequenceKey).classed("currentView", (d2) => d2.properties.key === selectedSequenceKey);
79848       context.container().selectAll(".layer-streetside-images .viewfield-group .viewfield").attr("d", viewfieldPath);
79849       function viewfieldPath() {
79850         let d2 = this.parentNode.__data__;
79851         if (d2.pano && d2.key !== selectedBubbleKey) {
79852           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
79853         } else {
79854           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
79855         }
79856       }
79857       return this;
79858     },
79859     updateUrlImage: function(imageKey) {
79860       if (!window.mocha) {
79861         var hash2 = utilStringQs(window.location.hash);
79862         if (imageKey) {
79863           hash2.photo = "streetside/" + imageKey;
79864         } else {
79865           delete hash2.photo;
79866         }
79867         window.location.replace("#" + utilQsString(hash2, true));
79868       }
79869     },
79870     /**
79871      * cache().
79872      */
79873     cache: function() {
79874       return _ssCache;
79875     }
79876   };
79877
79878   // modules/services/taginfo.js
79879   var apibase4 = taginfoApiUrl;
79880   var _inflight3 = {};
79881   var _popularKeys = {};
79882   var _taginfoCache = {};
79883   var tag_sorts = {
79884     point: "count_nodes",
79885     vertex: "count_nodes",
79886     area: "count_ways",
79887     line: "count_ways"
79888   };
79889   var tag_sort_members = {
79890     point: "count_node_members",
79891     vertex: "count_node_members",
79892     area: "count_way_members",
79893     line: "count_way_members",
79894     relation: "count_relation_members"
79895   };
79896   var tag_filters = {
79897     point: "nodes",
79898     vertex: "nodes",
79899     area: "ways",
79900     line: "ways"
79901   };
79902   var tag_members_fractions = {
79903     point: "count_node_members_fraction",
79904     vertex: "count_node_members_fraction",
79905     area: "count_way_members_fraction",
79906     line: "count_way_members_fraction",
79907     relation: "count_relation_members_fraction"
79908   };
79909   function sets(params, n3, o2) {
79910     if (params.geometry && o2[params.geometry]) {
79911       params[n3] = o2[params.geometry];
79912     }
79913     return params;
79914   }
79915   function setFilter(params) {
79916     return sets(params, "filter", tag_filters);
79917   }
79918   function setSort(params) {
79919     return sets(params, "sortname", tag_sorts);
79920   }
79921   function setSortMembers(params) {
79922     return sets(params, "sortname", tag_sort_members);
79923   }
79924   function clean(params) {
79925     return utilObjectOmit(params, ["geometry", "debounce"]);
79926   }
79927   function filterKeys(type2) {
79928     var count_type = type2 ? "count_" + type2 : "count_all";
79929     return function(d2) {
79930       return Number(d2[count_type]) > 2500 || d2.in_wiki;
79931     };
79932   }
79933   function filterMultikeys(prefix) {
79934     return function(d2) {
79935       var re3 = new RegExp("^" + prefix + "(.*)$", "i");
79936       var matches = d2.key.match(re3) || [];
79937       return matches.length === 2 && matches[1].indexOf(":") === -1;
79938     };
79939   }
79940   function filterValues(allowUpperCase) {
79941     return function(d2) {
79942       if (d2.value.match(/[;,]/) !== null) return false;
79943       if (!allowUpperCase && d2.value.match(/[A-Z*]/) !== null) return false;
79944       return d2.count > 100 || d2.in_wiki;
79945     };
79946   }
79947   function filterRoles(geometry) {
79948     return function(d2) {
79949       if (d2.role === "") return false;
79950       if (d2.role.match(/[A-Z*;,]/) !== null) return false;
79951       return Number(d2[tag_members_fractions[geometry]]) > 0;
79952     };
79953   }
79954   function valKey(d2) {
79955     return {
79956       value: d2.key,
79957       title: d2.key
79958     };
79959   }
79960   function valKeyDescription(d2) {
79961     var obj = {
79962       value: d2.value,
79963       title: d2.description || d2.value
79964     };
79965     return obj;
79966   }
79967   function roleKey(d2) {
79968     return {
79969       value: d2.role,
79970       title: d2.role
79971     };
79972   }
79973   function sortKeys(a2, b2) {
79974     return a2.key.indexOf(":") === -1 && b2.key.indexOf(":") !== -1 ? -1 : a2.key.indexOf(":") !== -1 && b2.key.indexOf(":") === -1 ? 1 : 0;
79975   }
79976   var debouncedRequest2 = debounce_default(request2, 300, { leading: false });
79977   function request2(url, params, exactMatch, callback, loaded) {
79978     if (_inflight3[url]) return;
79979     if (checkCache(url, params, exactMatch, callback)) return;
79980     var controller = new AbortController();
79981     _inflight3[url] = controller;
79982     json_default(url, { signal: controller.signal }).then(function(result) {
79983       delete _inflight3[url];
79984       if (loaded) loaded(null, result);
79985     }).catch(function(err) {
79986       delete _inflight3[url];
79987       if (err.name === "AbortError") return;
79988       if (loaded) loaded(err.message);
79989     });
79990   }
79991   function checkCache(url, params, exactMatch, callback) {
79992     var rp = params.rp || 25;
79993     var testQuery = params.query || "";
79994     var testUrl = url;
79995     do {
79996       var hit = _taginfoCache[testUrl];
79997       if (hit && (url === testUrl || hit.length < rp)) {
79998         callback(null, hit);
79999         return true;
80000       }
80001       if (exactMatch || !testQuery.length) return false;
80002       testQuery = testQuery.slice(0, -1);
80003       testUrl = url.replace(/&query=(.*?)&/, "&query=" + testQuery + "&");
80004     } while (testQuery.length >= 0);
80005     return false;
80006   }
80007   var taginfo_default = {
80008     init: function() {
80009       _inflight3 = {};
80010       _taginfoCache = {};
80011       _popularKeys = {
80012         // manually exclude some keys – #5377, #7485
80013         postal_code: true,
80014         full_name: true,
80015         loc_name: true,
80016         reg_name: true,
80017         short_name: true,
80018         sorting_name: true,
80019         artist_name: true,
80020         nat_name: true,
80021         long_name: true,
80022         via: true,
80023         "bridge:name": true
80024       };
80025       var params = {
80026         rp: 100,
80027         sortname: "values_all",
80028         sortorder: "desc",
80029         page: 1,
80030         debounce: false,
80031         lang: _mainLocalizer.languageCode()
80032       };
80033       this.keys(params, function(err, data) {
80034         if (err) return;
80035         data.forEach(function(d2) {
80036           if (d2.value === "opening_hours") return;
80037           _popularKeys[d2.value] = true;
80038         });
80039       });
80040     },
80041     reset: function() {
80042       Object.values(_inflight3).forEach(function(controller) {
80043         controller.abort();
80044       });
80045       _inflight3 = {};
80046     },
80047     keys: function(params, callback) {
80048       var doRequest = params.debounce ? debouncedRequest2 : request2;
80049       params = clean(setSort(params));
80050       params = Object.assign({
80051         rp: 10,
80052         sortname: "count_all",
80053         sortorder: "desc",
80054         page: 1,
80055         lang: _mainLocalizer.languageCode()
80056       }, params);
80057       var url = apibase4 + "keys/all?" + utilQsString(params);
80058       doRequest(url, params, false, callback, function(err, d2) {
80059         if (err) {
80060           callback(err);
80061         } else {
80062           var f2 = filterKeys(params.filter);
80063           var result = d2.data.filter(f2).sort(sortKeys).map(valKey);
80064           _taginfoCache[url] = result;
80065           callback(null, result);
80066         }
80067       });
80068     },
80069     multikeys: function(params, callback) {
80070       var doRequest = params.debounce ? debouncedRequest2 : request2;
80071       params = clean(setSort(params));
80072       params = Object.assign({
80073         rp: 25,
80074         sortname: "count_all",
80075         sortorder: "desc",
80076         page: 1,
80077         lang: _mainLocalizer.languageCode()
80078       }, params);
80079       var prefix = params.query;
80080       var url = apibase4 + "keys/all?" + utilQsString(params);
80081       doRequest(url, params, true, callback, function(err, d2) {
80082         if (err) {
80083           callback(err);
80084         } else {
80085           var f2 = filterMultikeys(prefix);
80086           var result = d2.data.filter(f2).map(valKey);
80087           _taginfoCache[url] = result;
80088           callback(null, result);
80089         }
80090       });
80091     },
80092     values: function(params, callback) {
80093       var key = params.key;
80094       if (key && _popularKeys[key]) {
80095         callback(null, []);
80096         return;
80097       }
80098       var doRequest = params.debounce ? debouncedRequest2 : request2;
80099       params = clean(setSort(setFilter(params)));
80100       params = Object.assign({
80101         rp: 25,
80102         sortname: "count_all",
80103         sortorder: "desc",
80104         page: 1,
80105         lang: _mainLocalizer.languageCode()
80106       }, params);
80107       var url = apibase4 + "key/values?" + utilQsString(params);
80108       doRequest(url, params, false, callback, function(err, d2) {
80109         if (err) {
80110           callback(err);
80111         } else {
80112           var allowUpperCase = allowUpperCaseTagValues.test(params.key);
80113           var f2 = filterValues(allowUpperCase);
80114           var result = d2.data.filter(f2).map(valKeyDescription);
80115           _taginfoCache[url] = result;
80116           callback(null, result);
80117         }
80118       });
80119     },
80120     roles: function(params, callback) {
80121       var doRequest = params.debounce ? debouncedRequest2 : request2;
80122       var geometry = params.geometry;
80123       params = clean(setSortMembers(params));
80124       params = Object.assign({
80125         rp: 25,
80126         sortname: "count_all_members",
80127         sortorder: "desc",
80128         page: 1,
80129         lang: _mainLocalizer.languageCode()
80130       }, params);
80131       var url = apibase4 + "relation/roles?" + utilQsString(params);
80132       doRequest(url, params, true, callback, function(err, d2) {
80133         if (err) {
80134           callback(err);
80135         } else {
80136           var f2 = filterRoles(geometry);
80137           var result = d2.data.filter(f2).map(roleKey);
80138           _taginfoCache[url] = result;
80139           callback(null, result);
80140         }
80141       });
80142     },
80143     docs: function(params, callback) {
80144       var doRequest = params.debounce ? debouncedRequest2 : request2;
80145       params = clean(setSort(params));
80146       var path = "key/wiki_pages?";
80147       if (params.value) {
80148         path = "tag/wiki_pages?";
80149       } else if (params.rtype) {
80150         path = "relation/wiki_pages?";
80151       }
80152       var url = apibase4 + path + utilQsString(params);
80153       doRequest(url, params, true, callback, function(err, d2) {
80154         if (err) {
80155           callback(err);
80156         } else {
80157           _taginfoCache[url] = d2.data;
80158           callback(null, d2.data);
80159         }
80160       });
80161     },
80162     apibase: function(_2) {
80163       if (!arguments.length) return apibase4;
80164       apibase4 = _2;
80165       return this;
80166     }
80167   };
80168
80169   // modules/services/vector_tile.js
80170   var import_fast_deep_equal11 = __toESM(require_fast_deep_equal());
80171   var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify());
80172   var import_polygon_clipping = __toESM(require_polygon_clipping_umd());
80173   var tiler7 = utilTiler().tileSize(512).margin(1);
80174   var dispatch11 = dispatch_default("loadedData");
80175   var _vtCache;
80176   function abortRequest6(controller) {
80177     controller.abort();
80178   }
80179   function vtToGeoJSON(data, tile, mergeCache) {
80180     var vectorTile = new VectorTile(new Pbf(data));
80181     var layers = Object.keys(vectorTile.layers);
80182     if (!Array.isArray(layers)) {
80183       layers = [layers];
80184     }
80185     var features = [];
80186     layers.forEach(function(layerID) {
80187       var layer = vectorTile.layers[layerID];
80188       if (layer) {
80189         for (var i3 = 0; i3 < layer.length; i3++) {
80190           var feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
80191           var geometry = feature3.geometry;
80192           if (geometry.type === "Polygon") {
80193             geometry.type = "MultiPolygon";
80194             geometry.coordinates = [geometry.coordinates];
80195           }
80196           var isClipped = false;
80197           if (geometry.type === "MultiPolygon") {
80198             var featureClip = turf_bbox_clip_default(feature3, tile.extent.rectangle());
80199             if (!(0, import_fast_deep_equal11.default)(feature3.geometry, featureClip.geometry)) {
80200               isClipped = true;
80201             }
80202             if (!feature3.geometry.coordinates.length) continue;
80203             if (!feature3.geometry.coordinates[0].length) continue;
80204           }
80205           var featurehash = utilHashcode((0, import_fast_json_stable_stringify2.default)(feature3));
80206           var propertyhash = utilHashcode((0, import_fast_json_stable_stringify2.default)(feature3.properties || {}));
80207           feature3.__layerID__ = layerID.replace(/[^_a-zA-Z0-9\-]/g, "_");
80208           feature3.__featurehash__ = featurehash;
80209           feature3.__propertyhash__ = propertyhash;
80210           features.push(feature3);
80211           if (isClipped && geometry.type === "MultiPolygon") {
80212             var merged = mergeCache[propertyhash];
80213             if (merged && merged.length) {
80214               var other2 = merged[0];
80215               var coords = import_polygon_clipping.default.union(
80216                 feature3.geometry.coordinates,
80217                 other2.geometry.coordinates
80218               );
80219               if (!coords || !coords.length) {
80220                 continue;
80221               }
80222               merged.push(feature3);
80223               for (var j2 = 0; j2 < merged.length; j2++) {
80224                 merged[j2].geometry.coordinates = coords;
80225                 merged[j2].__featurehash__ = featurehash;
80226               }
80227             } else {
80228               mergeCache[propertyhash] = [feature3];
80229             }
80230           }
80231         }
80232       }
80233     });
80234     return features;
80235   }
80236   function loadTile3(source, tile) {
80237     if (source.loaded[tile.id] || source.inflight[tile.id]) return;
80238     var url = source.template.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace(/\{[t-]y\}/, Math.pow(2, tile.xyz[2]) - tile.xyz[1] - 1).replace(/\{z(oom)?\}/, tile.xyz[2]).replace(/\{switch:([^}]+)\}/, function(s2, r2) {
80239       var subdomains = r2.split(",");
80240       return subdomains[(tile.xyz[0] + tile.xyz[1]) % subdomains.length];
80241     });
80242     var controller = new AbortController();
80243     source.inflight[tile.id] = controller;
80244     fetch(url, { signal: controller.signal }).then(function(response) {
80245       if (!response.ok) {
80246         throw new Error(response.status + " " + response.statusText);
80247       }
80248       source.loaded[tile.id] = [];
80249       delete source.inflight[tile.id];
80250       return response.arrayBuffer();
80251     }).then(function(data) {
80252       if (!data) {
80253         throw new Error("No Data");
80254       }
80255       var z2 = tile.xyz[2];
80256       if (!source.canMerge[z2]) {
80257         source.canMerge[z2] = {};
80258       }
80259       source.loaded[tile.id] = vtToGeoJSON(data, tile, source.canMerge[z2]);
80260       dispatch11.call("loadedData");
80261     }).catch(function() {
80262       source.loaded[tile.id] = [];
80263       delete source.inflight[tile.id];
80264     });
80265   }
80266   var vector_tile_default = {
80267     init: function() {
80268       if (!_vtCache) {
80269         this.reset();
80270       }
80271       this.event = utilRebind(this, dispatch11, "on");
80272     },
80273     reset: function() {
80274       for (var sourceID in _vtCache) {
80275         var source = _vtCache[sourceID];
80276         if (source && source.inflight) {
80277           Object.values(source.inflight).forEach(abortRequest6);
80278         }
80279       }
80280       _vtCache = {};
80281     },
80282     addSource: function(sourceID, template) {
80283       _vtCache[sourceID] = { template, inflight: {}, loaded: {}, canMerge: {} };
80284       return _vtCache[sourceID];
80285     },
80286     data: function(sourceID, projection2) {
80287       var source = _vtCache[sourceID];
80288       if (!source) return [];
80289       var tiles = tiler7.getTiles(projection2);
80290       var seen = {};
80291       var results = [];
80292       for (var i3 = 0; i3 < tiles.length; i3++) {
80293         var features = source.loaded[tiles[i3].id];
80294         if (!features || !features.length) continue;
80295         for (var j2 = 0; j2 < features.length; j2++) {
80296           var feature3 = features[j2];
80297           var hash2 = feature3.__featurehash__;
80298           if (seen[hash2]) continue;
80299           seen[hash2] = true;
80300           results.push(Object.assign({}, feature3));
80301         }
80302       }
80303       return results;
80304     },
80305     loadTiles: function(sourceID, template, projection2) {
80306       var source = _vtCache[sourceID];
80307       if (!source) {
80308         source = this.addSource(sourceID, template);
80309       }
80310       var tiles = tiler7.getTiles(projection2);
80311       Object.keys(source.inflight).forEach(function(k2) {
80312         var wanted = tiles.find(function(tile) {
80313           return k2 === tile.id;
80314         });
80315         if (!wanted) {
80316           abortRequest6(source.inflight[k2]);
80317           delete source.inflight[k2];
80318         }
80319       });
80320       tiles.forEach(function(tile) {
80321         loadTile3(source, tile);
80322       });
80323     },
80324     cache: function() {
80325       return _vtCache;
80326     }
80327   };
80328
80329   // modules/services/wikidata.js
80330   var apibase5 = "https://www.wikidata.org/w/api.php?";
80331   var _wikidataCache = {};
80332   var wikidata_default = {
80333     init: function() {
80334     },
80335     reset: function() {
80336       _wikidataCache = {};
80337     },
80338     // Search for Wikidata items matching the query
80339     itemsForSearchQuery: function(query, callback, language) {
80340       if (!query) {
80341         if (callback) callback("No query", {});
80342         return;
80343       }
80344       var lang = this.languagesToQuery()[0];
80345       var url = apibase5 + utilQsString({
80346         action: "wbsearchentities",
80347         format: "json",
80348         formatversion: 2,
80349         search: query,
80350         type: "item",
80351         // the language to search
80352         language: language || lang,
80353         // the language for the label and description in the result
80354         uselang: lang,
80355         limit: 10,
80356         origin: "*"
80357       });
80358       json_default(url).then((result) => {
80359         if (result && result.error) {
80360           if (result.error.code === "badvalue" && result.error.info.includes(lang) && !language && lang.includes("-")) {
80361             this.itemsForSearchQuery(query, callback, lang.split("-")[0]);
80362             return;
80363           } else {
80364             throw new Error(result.error);
80365           }
80366         }
80367         if (callback) callback(null, result.search || {});
80368       }).catch(function(err) {
80369         if (callback) callback(err.message, {});
80370       });
80371     },
80372     // Given a Wikipedia language and article title,
80373     // return an array of corresponding Wikidata entities.
80374     itemsByTitle: function(lang, title, callback) {
80375       if (!title) {
80376         if (callback) callback("No title", {});
80377         return;
80378       }
80379       lang = lang || "en";
80380       var url = apibase5 + utilQsString({
80381         action: "wbgetentities",
80382         format: "json",
80383         formatversion: 2,
80384         sites: lang.replace(/-/g, "_") + "wiki",
80385         titles: title,
80386         languages: "en",
80387         // shrink response by filtering to one language
80388         origin: "*"
80389       });
80390       json_default(url).then(function(result) {
80391         if (result && result.error) {
80392           throw new Error(result.error);
80393         }
80394         if (callback) callback(null, result.entities || {});
80395       }).catch(function(err) {
80396         if (callback) callback(err.message, {});
80397       });
80398     },
80399     languagesToQuery: function() {
80400       return _mainLocalizer.localeCodes().map(function(code) {
80401         return code.toLowerCase();
80402       }).filter(function(code) {
80403         return code !== "en-us";
80404       });
80405     },
80406     entityByQID: function(qid, callback) {
80407       if (!qid) {
80408         callback("No qid", {});
80409         return;
80410       }
80411       if (_wikidataCache[qid]) {
80412         if (callback) callback(null, _wikidataCache[qid]);
80413         return;
80414       }
80415       var langs = this.languagesToQuery();
80416       var url = apibase5 + utilQsString({
80417         action: "wbgetentities",
80418         format: "json",
80419         formatversion: 2,
80420         ids: qid,
80421         props: "labels|descriptions|claims|sitelinks",
80422         sitefilter: langs.map(function(d2) {
80423           return d2 + "wiki";
80424         }).join("|"),
80425         languages: langs.join("|"),
80426         languagefallback: 1,
80427         origin: "*"
80428       });
80429       json_default(url).then(function(result) {
80430         if (result && result.error) {
80431           throw new Error(result.error);
80432         }
80433         if (callback) callback(null, result.entities[qid] || {});
80434       }).catch(function(err) {
80435         if (callback) callback(err.message, {});
80436       });
80437     },
80438     // Pass `params` object of the form:
80439     // {
80440     //   qid: 'string'      // brand wikidata  (e.g. 'Q37158')
80441     // }
80442     //
80443     // Get an result object used to display tag documentation
80444     // {
80445     //   title:        'string',
80446     //   description:  'string',
80447     //   editURL:      'string',
80448     //   imageURL:     'string',
80449     //   wiki:         { title: 'string', text: 'string', url: 'string' }
80450     // }
80451     //
80452     getDocs: function(params, callback) {
80453       var langs = this.languagesToQuery();
80454       this.entityByQID(params.qid, function(err, entity) {
80455         if (err || !entity) {
80456           callback(err || "No entity");
80457           return;
80458         }
80459         var i3;
80460         var description;
80461         for (i3 in langs) {
80462           let code = langs[i3];
80463           if (entity.descriptions[code] && entity.descriptions[code].language === code) {
80464             description = entity.descriptions[code];
80465             break;
80466           }
80467         }
80468         if (!description && Object.values(entity.descriptions).length) description = Object.values(entity.descriptions)[0];
80469         var result = {
80470           title: entity.id,
80471           description: description ? description.value : "",
80472           descriptionLocaleCode: description ? description.language : "",
80473           editURL: "https://www.wikidata.org/wiki/" + entity.id
80474         };
80475         if (entity.claims) {
80476           var imageroot = "https://commons.wikimedia.org/w/index.php";
80477           var props = ["P154", "P18"];
80478           var prop, image;
80479           for (i3 = 0; i3 < props.length; i3++) {
80480             prop = entity.claims[props[i3]];
80481             if (prop && Object.keys(prop).length > 0) {
80482               image = prop[Object.keys(prop)[0]].mainsnak.datavalue.value;
80483               if (image) {
80484                 result.imageURL = imageroot + "?" + utilQsString({
80485                   title: "Special:Redirect/file/" + image,
80486                   width: 400
80487                 });
80488                 break;
80489               }
80490             }
80491           }
80492         }
80493         if (entity.sitelinks) {
80494           var englishLocale = _mainLocalizer.languageCode().toLowerCase() === "en";
80495           for (i3 = 0; i3 < langs.length; i3++) {
80496             var w2 = langs[i3] + "wiki";
80497             if (entity.sitelinks[w2]) {
80498               var title = entity.sitelinks[w2].title;
80499               var tKey = "inspector.wiki_reference";
80500               if (!englishLocale && langs[i3] === "en") {
80501                 tKey = "inspector.wiki_en_reference";
80502               }
80503               result.wiki = {
80504                 title,
80505                 text: tKey,
80506                 url: "https://" + langs[i3] + ".wikipedia.org/wiki/" + title.replace(/ /g, "_")
80507               };
80508               break;
80509             }
80510           }
80511         }
80512         callback(null, result);
80513       });
80514     }
80515   };
80516
80517   // modules/services/wikipedia.js
80518   var endpoint = "https://en.wikipedia.org/w/api.php?";
80519   var wikipedia_default = {
80520     init: function() {
80521     },
80522     reset: function() {
80523     },
80524     search: function(lang, query, callback) {
80525       if (!query) {
80526         if (callback) callback("No Query", []);
80527         return;
80528       }
80529       lang = lang || "en";
80530       var url = endpoint.replace("en", lang) + utilQsString({
80531         action: "query",
80532         list: "search",
80533         srlimit: "10",
80534         srinfo: "suggestion",
80535         format: "json",
80536         origin: "*",
80537         srsearch: query
80538       });
80539       json_default(url).then(function(result) {
80540         if (result && result.error) {
80541           throw new Error(result.error);
80542         } else if (!result || !result.query || !result.query.search) {
80543           throw new Error("No Results");
80544         }
80545         if (callback) {
80546           var titles = result.query.search.map(function(d2) {
80547             return d2.title;
80548           });
80549           callback(null, titles);
80550         }
80551       }).catch(function(err) {
80552         if (callback) callback(err, []);
80553       });
80554     },
80555     suggestions: function(lang, query, callback) {
80556       if (!query) {
80557         if (callback) callback("", []);
80558         return;
80559       }
80560       lang = lang || "en";
80561       var url = endpoint.replace("en", lang) + utilQsString({
80562         action: "opensearch",
80563         namespace: 0,
80564         suggest: "",
80565         format: "json",
80566         origin: "*",
80567         search: query
80568       });
80569       json_default(url).then(function(result) {
80570         if (result && result.error) {
80571           throw new Error(result.error);
80572         } else if (!result || result.length < 2) {
80573           throw new Error("No Results");
80574         }
80575         if (callback) callback(null, result[1] || []);
80576       }).catch(function(err) {
80577         if (callback) callback(err.message, []);
80578       });
80579     },
80580     translations: function(lang, title, callback) {
80581       if (!title) {
80582         if (callback) callback("No Title");
80583         return;
80584       }
80585       var url = endpoint.replace("en", lang) + utilQsString({
80586         action: "query",
80587         prop: "langlinks",
80588         format: "json",
80589         origin: "*",
80590         lllimit: 500,
80591         titles: title
80592       });
80593       json_default(url).then(function(result) {
80594         if (result && result.error) {
80595           throw new Error(result.error);
80596         } else if (!result || !result.query || !result.query.pages) {
80597           throw new Error("No Results");
80598         }
80599         if (callback) {
80600           var list2 = result.query.pages[Object.keys(result.query.pages)[0]];
80601           var translations = {};
80602           if (list2 && list2.langlinks) {
80603             list2.langlinks.forEach(function(d2) {
80604               translations[d2.lang] = d2["*"];
80605             });
80606           }
80607           callback(null, translations);
80608         }
80609       }).catch(function(err) {
80610         if (callback) callback(err.message);
80611       });
80612     }
80613   };
80614
80615   // modules/services/mapilio.js
80616   var apiUrl2 = "https://end.mapilio.com";
80617   var imageBaseUrl = "https://cdn.mapilio.com/im";
80618   var baseTileUrl2 = "https://geo.mapilio.com/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=mapilio:";
80619   var pointLayer = "map_points";
80620   var lineLayer = "map_roads_line";
80621   var tileStyle = "&STYLE=&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}";
80622   var minZoom3 = 14;
80623   var dispatch12 = dispatch_default("loadedImages", "loadedLines");
80624   var imgZoom3 = zoom_default2().extent([[0, 0], [320, 240]]).translateExtent([[0, 0], [320, 240]]).scaleExtent([1, 15]);
80625   var pannellumViewerCSS3 = "pannellum/pannellum.css";
80626   var pannellumViewerJS3 = "pannellum/pannellum.js";
80627   var resolution = 1080;
80628   var _activeImage;
80629   var _cache3;
80630   var _loadViewerPromise5;
80631   var _pannellumViewer3;
80632   var _sceneOptions2 = {
80633     showFullscreenCtrl: false,
80634     autoLoad: true,
80635     yaw: 0,
80636     minHfov: 10,
80637     maxHfov: 90,
80638     hfov: 60
80639   };
80640   var _currScene2 = 0;
80641   function partitionViewport5(projection2) {
80642     const z2 = geoScaleToZoom(projection2.scale());
80643     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
80644     const tiler8 = utilTiler().zoomExtent([z22, z22]);
80645     return tiler8.getTiles(projection2).map(function(tile) {
80646       return tile.extent;
80647     });
80648   }
80649   function searchLimited5(limit, projection2, rtree) {
80650     limit = limit || 5;
80651     return partitionViewport5(projection2).reduce(function(result, extent) {
80652       const found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
80653         return d2.data;
80654       });
80655       return found.length ? result.concat(found) : result;
80656     }, []);
80657   }
80658   function loadTiles4(which, url, maxZoom2, projection2) {
80659     const tiler8 = utilTiler().zoomExtent([minZoom3, maxZoom2]).skipNullIsland(true);
80660     const tiles = tiler8.getTiles(projection2);
80661     tiles.forEach(function(tile) {
80662       loadTile4(which, url, tile);
80663     });
80664   }
80665   function loadTile4(which, url, tile) {
80666     const cache = _cache3.requests;
80667     const tileId = "".concat(tile.id, "-").concat(which);
80668     if (cache.loaded[tileId] || cache.inflight[tileId]) return;
80669     const controller = new AbortController();
80670     cache.inflight[tileId] = controller;
80671     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
80672     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
80673       if (!response.ok) {
80674         throw new Error(response.status + " " + response.statusText);
80675       }
80676       cache.loaded[tileId] = true;
80677       delete cache.inflight[tileId];
80678       return response.arrayBuffer();
80679     }).then(function(data) {
80680       if (data.byteLength === 0) {
80681         throw new Error("No Data");
80682       }
80683       loadTileDataToCache2(data, tile, which);
80684       if (which === "images") {
80685         dispatch12.call("loadedImages");
80686       } else {
80687         dispatch12.call("loadedLines");
80688       }
80689     }).catch(function(e3) {
80690       if (e3.message === "No Data") {
80691         cache.loaded[tileId] = true;
80692       } else {
80693         console.error(e3);
80694       }
80695     });
80696   }
80697   function loadTileDataToCache2(data, tile) {
80698     const vectorTile = new VectorTile(new Pbf(data));
80699     let features, cache, layer, i3, feature3, loc, d2;
80700     if (vectorTile.layers.hasOwnProperty(pointLayer)) {
80701       features = [];
80702       cache = _cache3.images;
80703       layer = vectorTile.layers[pointLayer];
80704       for (i3 = 0; i3 < layer.length; i3++) {
80705         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
80706         loc = feature3.geometry.coordinates;
80707         let resolutionArr = feature3.properties.resolution.split("x");
80708         let sourceWidth = Math.max(resolutionArr[0], resolutionArr[1]);
80709         let sourceHeight = Math.min(resolutionArr[0], resolutionArr[1]);
80710         let isPano = sourceWidth % sourceHeight === 0;
80711         d2 = {
80712           loc,
80713           capture_time: feature3.properties.capture_time,
80714           id: feature3.properties.id,
80715           sequence_id: feature3.properties.sequence_uuid,
80716           heading: feature3.properties.heading,
80717           resolution: feature3.properties.resolution,
80718           isPano
80719         };
80720         cache.forImageId[d2.id] = d2;
80721         features.push({
80722           minX: loc[0],
80723           minY: loc[1],
80724           maxX: loc[0],
80725           maxY: loc[1],
80726           data: d2
80727         });
80728       }
80729       if (cache.rtree) {
80730         cache.rtree.load(features);
80731       }
80732     }
80733     if (vectorTile.layers.hasOwnProperty(lineLayer)) {
80734       cache = _cache3.sequences;
80735       layer = vectorTile.layers[lineLayer];
80736       for (i3 = 0; i3 < layer.length; i3++) {
80737         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
80738         if (cache.lineString[feature3.properties.sequence_uuid]) {
80739           cache.lineString[feature3.properties.sequence_uuid].push(feature3);
80740         } else {
80741           cache.lineString[feature3.properties.sequence_uuid] = [feature3];
80742         }
80743       }
80744     }
80745   }
80746   function getImageData(imageId, sequenceId) {
80747     return fetch(apiUrl2 + "/api/sequence-detail?sequence_uuid=".concat(sequenceId), { method: "GET" }).then(function(response) {
80748       if (!response.ok) {
80749         throw new Error(response.status + " " + response.statusText);
80750       }
80751       return response.json();
80752     }).then(function(data) {
80753       let index = data.data.findIndex((feature3) => feature3.id === imageId);
80754       const { filename, uploaded_hash } = data.data[index];
80755       _sceneOptions2.panorama = imageBaseUrl + "/" + uploaded_hash + "/" + filename + "/" + resolution;
80756     });
80757   }
80758   var mapilio_default = {
80759     // Initialize Mapilio
80760     init: function() {
80761       if (!_cache3) {
80762         this.reset();
80763       }
80764       this.event = utilRebind(this, dispatch12, "on");
80765     },
80766     // Reset cache and state
80767     reset: function() {
80768       if (_cache3) {
80769         Object.values(_cache3.requests.inflight).forEach(function(request3) {
80770           request3.abort();
80771         });
80772       }
80773       _cache3 = {
80774         images: { rtree: new RBush(), forImageId: {} },
80775         sequences: { rtree: new RBush(), lineString: {} },
80776         requests: { loaded: {}, inflight: {} }
80777       };
80778       _activeImage = null;
80779     },
80780     // Get visible images
80781     images: function(projection2) {
80782       const limit = 5;
80783       return searchLimited5(limit, projection2, _cache3.images.rtree);
80784     },
80785     cachedImage: function(imageKey) {
80786       return _cache3.images.forImageId[imageKey];
80787     },
80788     // Load images in the visible area
80789     loadImages: function(projection2) {
80790       let url = baseTileUrl2 + pointLayer + tileStyle;
80791       loadTiles4("images", url, 14, projection2);
80792     },
80793     // Load line in the visible area
80794     loadLines: function(projection2) {
80795       let url = baseTileUrl2 + lineLayer + tileStyle;
80796       loadTiles4("line", url, 14, projection2);
80797     },
80798     // Get visible sequences
80799     sequences: function(projection2) {
80800       const viewport = projection2.clipExtent();
80801       const min3 = [viewport[0][0], viewport[1][1]];
80802       const max3 = [viewport[1][0], viewport[0][1]];
80803       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
80804       const sequenceIds = {};
80805       let lineStrings = [];
80806       _cache3.images.rtree.search(bbox2).forEach(function(d2) {
80807         if (d2.data.sequence_id) {
80808           sequenceIds[d2.data.sequence_id] = true;
80809         }
80810       });
80811       Object.keys(sequenceIds).forEach(function(sequenceId) {
80812         if (_cache3.sequences.lineString[sequenceId]) {
80813           lineStrings = lineStrings.concat(_cache3.sequences.lineString[sequenceId]);
80814         }
80815       });
80816       return lineStrings;
80817     },
80818     // Set the currently visible image
80819     setActiveImage: function(image) {
80820       if (image) {
80821         _activeImage = {
80822           id: image.id,
80823           sequence_id: image.sequence_id
80824         };
80825       } else {
80826         _activeImage = null;
80827       }
80828     },
80829     // Update the currently highlighted sequence and selected bubble.
80830     setStyles: function(context, hovered) {
80831       const hoveredImageId = hovered && hovered.id;
80832       const hoveredSequenceId = hovered && hovered.sequence_id;
80833       const selectedSequenceId = _activeImage && _activeImage.sequence_id;
80834       const selectedImageId = _activeImage && _activeImage.id;
80835       const markers = context.container().selectAll(".layer-mapilio .viewfield-group");
80836       const sequences = context.container().selectAll(".layer-mapilio .sequence");
80837       markers.classed("highlighted", function(d2) {
80838         return d2.id === hoveredImageId;
80839       }).classed("hovered", function(d2) {
80840         return d2.id === hoveredImageId;
80841       }).classed("currentView", function(d2) {
80842         return d2.id === selectedImageId;
80843       });
80844       sequences.classed("highlighted", function(d2) {
80845         return d2.properties.sequence_uuid === hoveredSequenceId;
80846       }).classed("currentView", function(d2) {
80847         return d2.properties.sequence_uuid === selectedSequenceId;
80848       });
80849       return this;
80850     },
80851     updateUrlImage: function(imageKey) {
80852       if (!window.mocha) {
80853         var hash2 = utilStringQs(window.location.hash);
80854         if (imageKey) {
80855           hash2.photo = "mapilio/" + imageKey;
80856         } else {
80857           delete hash2.photo;
80858         }
80859         window.location.replace("#" + utilQsString(hash2, true));
80860       }
80861     },
80862     initViewer: function() {
80863       if (!window.pannellum) return;
80864       if (_pannellumViewer3) return;
80865       _currScene2 += 1;
80866       const sceneID = _currScene2.toString();
80867       const options2 = {
80868         "default": { firstScene: sceneID },
80869         scenes: {}
80870       };
80871       options2.scenes[sceneID] = _sceneOptions2;
80872       _pannellumViewer3 = window.pannellum.viewer("ideditor-viewer-mapilio-pnlm", options2);
80873     },
80874     selectImage: function(context, id2) {
80875       let that = this;
80876       let d2 = this.cachedImage(id2);
80877       this.setActiveImage(d2);
80878       this.updateUrlImage(d2.id);
80879       let viewer = context.container().select(".photoviewer");
80880       if (!viewer.empty()) viewer.datum(d2);
80881       this.setStyles(context, null);
80882       if (!d2) return this;
80883       let wrap2 = context.container().select(".photoviewer .mapilio-wrapper");
80884       let attribution = wrap2.selectAll(".photo-attribution").text("");
80885       if (d2.capture_time) {
80886         attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.capture_time));
80887         attribution.append("span").text("|");
80888       }
80889       attribution.append("a").attr("class", "image-link").attr("target", "_blank").attr("href", "https://mapilio.com/app?lat=".concat(d2.loc[1], "&lng=").concat(d2.loc[0], "&zoom=17&pId=").concat(d2.id)).text("mapilio.com");
80890       wrap2.transition().duration(100).call(imgZoom3.transform, identity2);
80891       wrap2.selectAll("img").remove();
80892       wrap2.selectAll("button.back").classed("hide", !_cache3.images.forImageId.hasOwnProperty(+id2 - 1));
80893       wrap2.selectAll("button.forward").classed("hide", !_cache3.images.forImageId.hasOwnProperty(+id2 + 1));
80894       getImageData(d2.id, d2.sequence_id).then(function() {
80895         if (d2.isPano) {
80896           if (!_pannellumViewer3) {
80897             that.initViewer();
80898           } else {
80899             _currScene2 += 1;
80900             let sceneID = _currScene2.toString();
80901             _pannellumViewer3.addScene(sceneID, _sceneOptions2).loadScene(sceneID);
80902             if (_currScene2 > 2) {
80903               sceneID = (_currScene2 - 1).toString();
80904               _pannellumViewer3.removeScene(sceneID);
80905             }
80906           }
80907         } else {
80908           that.initOnlyPhoto(context);
80909         }
80910       });
80911       function localeDateString2(s2) {
80912         if (!s2) return null;
80913         var options2 = { day: "numeric", month: "short", year: "numeric" };
80914         var d4 = new Date(s2);
80915         if (isNaN(d4.getTime())) return null;
80916         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
80917       }
80918       return this;
80919     },
80920     initOnlyPhoto: function(context) {
80921       if (_pannellumViewer3) {
80922         _pannellumViewer3.destroy();
80923         _pannellumViewer3 = null;
80924       }
80925       let wrap2 = context.container().select("#ideditor-viewer-mapilio-simple");
80926       let imgWrap = wrap2.select("img");
80927       if (!imgWrap.empty()) {
80928         imgWrap.attr("src", _sceneOptions2.panorama);
80929       } else {
80930         wrap2.append("img").attr("src", _sceneOptions2.panorama);
80931       }
80932     },
80933     ensureViewerLoaded: function(context) {
80934       let that = this;
80935       let imgWrap = context.container().select("#ideditor-viewer-mapilio-simple > img");
80936       if (!imgWrap.empty()) {
80937         imgWrap.remove();
80938       }
80939       if (_loadViewerPromise5) return _loadViewerPromise5;
80940       let wrap2 = context.container().select(".photoviewer").selectAll(".mapilio-wrapper").data([0]);
80941       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper mapilio-wrapper").classed("hide", true).on("dblclick.zoom", null);
80942       wrapEnter.append("div").attr("class", "photo-attribution fillD");
80943       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls-mapilio");
80944       controlsEnter.append("button").classed("back", true).on("click.back", step(-1)).text("\u25C4");
80945       controlsEnter.append("button").classed("forward", true).on("click.forward", step(1)).text("\u25BA");
80946       wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-pnlm");
80947       wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-simple-wrap").call(imgZoom3.on("zoom", zoomPan2)).append("div").attr("id", "ideditor-viewer-mapilio-simple");
80948       context.ui().photoviewer.on("resize.mapilio", () => {
80949         if (_pannellumViewer3) {
80950           _pannellumViewer3.resize();
80951         }
80952       });
80953       _loadViewerPromise5 = new Promise((resolve, reject) => {
80954         let loadedCount = 0;
80955         function loaded() {
80956           loadedCount += 1;
80957           if (loadedCount === 2) resolve();
80958         }
80959         const head = select_default2("head");
80960         head.selectAll("#ideditor-mapilio-viewercss").data([0]).enter().append("link").attr("id", "ideditor-mapilio-viewercss").attr("rel", "stylesheet").attr("crossorigin", "anonymous").attr("href", context.asset(pannellumViewerCSS3)).on("load.serviceMapilio", loaded).on("error.serviceMapilio", function() {
80961           reject();
80962         });
80963         head.selectAll("#ideditor-mapilio-viewerjs").data([0]).enter().append("script").attr("id", "ideditor-mapilio-viewerjs").attr("crossorigin", "anonymous").attr("src", context.asset(pannellumViewerJS3)).on("load.serviceMapilio", loaded).on("error.serviceMapilio", function() {
80964           reject();
80965         });
80966       }).catch(function() {
80967         _loadViewerPromise5 = null;
80968       });
80969       function step(stepBy) {
80970         return function() {
80971           if (!_activeImage) return;
80972           const imageId = _activeImage.id;
80973           const nextIndex = imageId + stepBy;
80974           if (!nextIndex) return;
80975           const nextImage = _cache3.images.forImageId[nextIndex];
80976           context.map().centerEase(nextImage.loc);
80977           that.selectImage(context, nextImage.id);
80978         };
80979       }
80980       function zoomPan2(d3_event) {
80981         var t2 = d3_event.transform;
80982         context.container().select(".photoviewer #ideditor-viewer-mapilio-simple").call(utilSetTransform, t2.x, t2.y, t2.k);
80983       }
80984       return _loadViewerPromise5;
80985     },
80986     showViewer: function(context) {
80987       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
80988       let isHidden = wrap2.selectAll(".photo-wrapper.mapilio-wrapper.hide").size();
80989       if (isHidden) {
80990         wrap2.selectAll(".photo-wrapper:not(.mapilio-wrapper)").classed("hide", true);
80991         wrap2.selectAll(".photo-wrapper.mapilio-wrapper").classed("hide", false);
80992       }
80993       return this;
80994     },
80995     /**
80996      * hideViewer()
80997      */
80998     hideViewer: function(context) {
80999       let viewer = context.container().select(".photoviewer");
81000       if (!viewer.empty()) viewer.datum(null);
81001       this.updateUrlImage(null);
81002       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
81003       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
81004       this.setActiveImage();
81005       return this.setStyles(context, null);
81006     },
81007     // Return the current cache
81008     cache: function() {
81009       return _cache3;
81010     }
81011   };
81012
81013   // modules/services/panoramax.js
81014   var apiUrl3 = "https://api.panoramax.xyz/";
81015   var tileUrl2 = apiUrl3 + "api/map/{z}/{x}/{y}.mvt";
81016   var imageDataUrl = apiUrl3 + "api/collections/{collectionId}/items/{itemId}";
81017   var userIdUrl = apiUrl3 + "api/users/search?q={username}";
81018   var usernameURL = apiUrl3 + "api/users/{userId}";
81019   var viewerUrl = apiUrl3;
81020   var highDefinition = "hd";
81021   var standardDefinition = "sd";
81022   var pictureLayer = "pictures";
81023   var sequenceLayer = "sequences";
81024   var minZoom4 = 10;
81025   var imageMinZoom = 15;
81026   var lineMinZoom = 10;
81027   var dispatch13 = dispatch_default("loadedImages", "loadedLines", "viewerChanged");
81028   var _cache4;
81029   var _loadViewerPromise6;
81030   var _definition = standardDefinition;
81031   var _isHD = false;
81032   var _planeFrame2;
81033   var _pannellumFrame2;
81034   var _currentFrame2;
81035   var _oldestDate;
81036   var _currentScene = {
81037     currentImage: null,
81038     nextImage: null,
81039     prevImage: null
81040   };
81041   var _activeImage2;
81042   function partitionViewport6(projection2) {
81043     const z2 = geoScaleToZoom(projection2.scale());
81044     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
81045     const tiler8 = utilTiler().zoomExtent([z22, z22]);
81046     return tiler8.getTiles(projection2).map(function(tile) {
81047       return tile.extent;
81048     });
81049   }
81050   function searchLimited6(limit, projection2, rtree) {
81051     limit = limit || 5;
81052     return partitionViewport6(projection2).reduce(function(result, extent) {
81053       let found = rtree.search(extent.bbox());
81054       const spacing = Math.max(1, Math.floor(found.length / limit));
81055       found = found.filter((d2, idx) => idx % spacing === 0 || d2.data.id === (_activeImage2 == null ? void 0 : _activeImage2.id)).sort((a2, b2) => {
81056         if (a2.data.id === (_activeImage2 == null ? void 0 : _activeImage2.id)) return -1;
81057         if (b2.data.id === (_activeImage2 == null ? void 0 : _activeImage2.id)) return 1;
81058         return 0;
81059       }).slice(0, limit).map((d2) => d2.data);
81060       return found.length ? result.concat(found) : result;
81061     }, []);
81062   }
81063   function loadTiles5(which, url, maxZoom2, projection2, zoom) {
81064     const tiler8 = utilTiler().zoomExtent([minZoom4, maxZoom2]).skipNullIsland(true);
81065     const tiles = tiler8.getTiles(projection2);
81066     tiles.forEach(function(tile) {
81067       loadTile5(which, url, tile, zoom);
81068     });
81069   }
81070   function loadTile5(which, url, tile, zoom) {
81071     const cache = _cache4.requests;
81072     const tileId = "".concat(tile.id, "-").concat(which);
81073     if (cache.loaded[tileId] || cache.inflight[tileId]) return;
81074     const controller = new AbortController();
81075     cache.inflight[tileId] = controller;
81076     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
81077     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
81078       if (!response.ok) {
81079         throw new Error(response.status + " " + response.statusText);
81080       }
81081       cache.loaded[tileId] = true;
81082       delete cache.inflight[tileId];
81083       return response.arrayBuffer();
81084     }).then(function(data) {
81085       if (data.byteLength === 0) {
81086         throw new Error("No Data");
81087       }
81088       loadTileDataToCache3(data, tile, zoom);
81089       if (which === "images") {
81090         dispatch13.call("loadedImages");
81091       } else {
81092         dispatch13.call("loadedLines");
81093       }
81094     }).catch(function(e3) {
81095       if (e3.message === "No Data") {
81096         cache.loaded[tileId] = true;
81097       } else {
81098         console.error(e3);
81099       }
81100     });
81101   }
81102   function loadTileDataToCache3(data, tile, zoom) {
81103     const vectorTile = new VectorTile(new Pbf(data));
81104     let features, cache, layer, i3, feature3, loc, d2;
81105     if (vectorTile.layers.hasOwnProperty(pictureLayer)) {
81106       features = [];
81107       cache = _cache4.images;
81108       layer = vectorTile.layers[pictureLayer];
81109       for (i3 = 0; i3 < layer.length; i3++) {
81110         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
81111         loc = feature3.geometry.coordinates;
81112         d2 = {
81113           loc,
81114           capture_time: feature3.properties.ts,
81115           capture_time_parsed: new Date(feature3.properties.ts),
81116           id: feature3.properties.id,
81117           account_id: feature3.properties.account_id,
81118           sequence_id: feature3.properties.sequences.split('"')[1],
81119           heading: parseInt(feature3.properties.heading, 10),
81120           image_path: "",
81121           resolution: feature3.properties.resolution,
81122           isPano: feature3.properties.type === "equirectangular",
81123           model: feature3.properties.model
81124         };
81125         cache.forImageId[d2.id] = d2;
81126         features.push({
81127           minX: loc[0],
81128           minY: loc[1],
81129           maxX: loc[0],
81130           maxY: loc[1],
81131           data: d2
81132         });
81133         if (_oldestDate) {
81134           if (d2.capture_time < _oldestDate) {
81135             _oldestDate = d2.capture_time;
81136           }
81137         } else {
81138           _oldestDate = d2.capture_time;
81139         }
81140       }
81141       if (cache.rtree) {
81142         cache.rtree.load(features);
81143       }
81144     }
81145     if (vectorTile.layers.hasOwnProperty(sequenceLayer)) {
81146       cache = _cache4.sequences;
81147       if (zoom >= lineMinZoom && zoom < imageMinZoom) cache = _cache4.mockSequences;
81148       layer = vectorTile.layers[sequenceLayer];
81149       for (i3 = 0; i3 < layer.length; i3++) {
81150         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
81151         if (cache.lineString[feature3.properties.id]) {
81152           cache.lineString[feature3.properties.id].push(feature3);
81153         } else {
81154           cache.lineString[feature3.properties.id] = [feature3];
81155         }
81156         if (_oldestDate) {
81157           if (feature3.properties.date < _oldestDate) {
81158             _oldestDate = feature3.properties.date;
81159           }
81160         } else {
81161           _oldestDate = feature3.properties.date;
81162         }
81163       }
81164     }
81165   }
81166   async function getImageData2(collection_id, image_id) {
81167     const requestUrl = imageDataUrl.replace("{collectionId}", collection_id).replace("{itemId}", image_id);
81168     const response = await fetch(requestUrl, { method: "GET" });
81169     if (!response.ok) {
81170       throw new Error(response.status + " " + response.statusText);
81171     }
81172     const data = await response.json();
81173     return data;
81174   }
81175   async function getUsername(user_id) {
81176     const requestUrl = usernameURL.replace("{userId}", user_id);
81177     const response = await fetch(requestUrl, { method: "GET" });
81178     if (!response.ok) {
81179       throw new Error(response.status + " " + response.statusText);
81180     }
81181     const data = await response.json();
81182     return data.name;
81183   }
81184   var panoramax_default = {
81185     init: function() {
81186       if (!_cache4) {
81187         this.reset();
81188       }
81189       this.event = utilRebind(this, dispatch13, "on");
81190     },
81191     reset: function() {
81192       if (_cache4) {
81193         Object.values(_cache4.requests.inflight).forEach(function(request3) {
81194           request3.abort();
81195         });
81196       }
81197       _cache4 = {
81198         images: { rtree: new RBush(), forImageId: {} },
81199         sequences: { rtree: new RBush(), lineString: {} },
81200         mockSequences: { rtree: new RBush(), lineString: {} },
81201         requests: { loaded: {}, inflight: {} }
81202       };
81203       _currentScene.currentImage = null;
81204       _activeImage2 = null;
81205     },
81206     // Get visible images
81207     images: function(projection2) {
81208       const limit = 5;
81209       return searchLimited6(limit, projection2, _cache4.images.rtree);
81210     },
81211     cachedImage: function(imageKey) {
81212       return _cache4.images.forImageId[imageKey];
81213     },
81214     // Load images in the visible area
81215     loadImages: function(projection2) {
81216       loadTiles5("images", tileUrl2, imageMinZoom, projection2);
81217     },
81218     // Load line in the visible area
81219     loadLines: function(projection2, zoom) {
81220       loadTiles5("line", tileUrl2, lineMinZoom, projection2, zoom);
81221     },
81222     getUserIds: async function(usernames) {
81223       const requestUrls = usernames.map((username) => userIdUrl.replace("{username}", username));
81224       const responses = await Promise.all(requestUrls.map((requestUrl) => fetch(requestUrl, { method: "GET" })));
81225       if (responses.some((response) => !response.ok)) {
81226         const response = responses.find((response2) => !response2.ok);
81227         throw new Error(response.status + " " + response.statusText);
81228       }
81229       const data = await Promise.all(responses.map((response) => response.json()));
81230       return data.flatMap((d2, i3) => d2.features.filter((f2) => f2.name === usernames[i3]).map((f2) => f2.id));
81231     },
81232     getOldestDate: function() {
81233       return _oldestDate;
81234     },
81235     // Get visible sequences
81236     sequences: function(projection2, zoom) {
81237       const viewport = projection2.clipExtent();
81238       const min3 = [viewport[0][0], viewport[1][1]];
81239       const max3 = [viewport[1][0], viewport[0][1]];
81240       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
81241       const sequenceIds = {};
81242       let lineStrings = [];
81243       if (zoom >= imageMinZoom) {
81244         _cache4.images.rtree.search(bbox2).forEach(function(d2) {
81245           if (d2.data.sequence_id) {
81246             sequenceIds[d2.data.sequence_id] = true;
81247           }
81248         });
81249         Object.keys(sequenceIds).forEach(function(sequenceId) {
81250           if (_cache4.sequences.lineString[sequenceId]) {
81251             lineStrings = lineStrings.concat(_cache4.sequences.lineString[sequenceId]);
81252           }
81253         });
81254         return lineStrings;
81255       }
81256       if (zoom >= lineMinZoom) {
81257         Object.keys(_cache4.mockSequences.lineString).forEach(function(sequenceId) {
81258           lineStrings = lineStrings.concat(_cache4.mockSequences.lineString[sequenceId]);
81259         });
81260       }
81261       return lineStrings;
81262     },
81263     // Set the currently visible image
81264     setActiveImage: function(image) {
81265       if (image) {
81266         _activeImage2 = {
81267           id: image.id,
81268           sequence_id: image.sequence_id
81269         };
81270       } else {
81271         _activeImage2 = null;
81272       }
81273     },
81274     getActiveImage: function() {
81275       return _activeImage2;
81276     },
81277     // Update the currently highlighted sequence and selected bubble.
81278     setStyles: function(context, hovered) {
81279       const hoveredImageId = hovered && hovered.id;
81280       const hoveredSequenceId = hovered && hovered.sequence_id;
81281       const selectedSequenceId = _activeImage2 && _activeImage2.sequence_id;
81282       const selectedImageId = _activeImage2 && _activeImage2.id;
81283       const markers = context.container().selectAll(".layer-panoramax .viewfield-group");
81284       const sequences = context.container().selectAll(".layer-panoramax .sequence");
81285       markers.classed("highlighted", function(d2) {
81286         return d2.sequence_id === selectedSequenceId || d2.id === hoveredImageId;
81287       }).classed("hovered", function(d2) {
81288         return d2.id === hoveredImageId;
81289       }).classed("currentView", function(d2) {
81290         return d2.id === selectedImageId;
81291       });
81292       sequences.classed("highlighted", function(d2) {
81293         return d2.properties.id === hoveredSequenceId;
81294       }).classed("currentView", function(d2) {
81295         return d2.properties.id === selectedSequenceId;
81296       });
81297       context.container().selectAll(".layer-panoramax .viewfield-group .viewfield").attr("d", viewfieldPath);
81298       function viewfieldPath() {
81299         let d2 = this.parentNode.__data__;
81300         if (d2.isPano && d2.id !== selectedImageId) {
81301           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
81302         } else {
81303           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
81304         }
81305       }
81306       return this;
81307     },
81308     updateUrlImage: function(imageKey) {
81309       if (!window.mocha) {
81310         var hash2 = utilStringQs(window.location.hash);
81311         if (imageKey) {
81312           hash2.photo = "panoramax/" + imageKey;
81313         } else {
81314           delete hash2.photo;
81315         }
81316         window.location.replace("#" + utilQsString(hash2, true));
81317       }
81318     },
81319     selectImage: function(context, id2) {
81320       let that = this;
81321       let d2 = that.cachedImage(id2);
81322       that.setActiveImage(d2);
81323       that.updateUrlImage(d2.id);
81324       const viewerLink = "".concat(viewerUrl, "#pic=").concat(d2.id, "&focus=pic");
81325       let viewer = context.container().select(".photoviewer");
81326       if (!viewer.empty()) viewer.datum(d2);
81327       this.setStyles(context, null);
81328       if (!d2) return this;
81329       let wrap2 = context.container().select(".photoviewer .panoramax-wrapper");
81330       let attribution = wrap2.selectAll(".photo-attribution").text("");
81331       let line1 = attribution.append("div").attr("class", "attribution-row");
81332       const hdDomId = utilUniqueDomId("panoramax-hd");
81333       let label = line1.append("label").attr("for", hdDomId).attr("class", "panoramax-hd");
81334       label.append("input").attr("type", "checkbox").attr("id", hdDomId).property("checked", _isHD).on("click", (d3_event) => {
81335         d3_event.stopPropagation();
81336         _isHD = !_isHD;
81337         _definition = _isHD ? highDefinition : standardDefinition;
81338         that.selectImage(context, d2.id).showViewer(context);
81339       });
81340       label.append("span").call(_t.append("panoramax.hd"));
81341       if (d2.capture_time) {
81342         attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.capture_time));
81343         attribution.append("span").text("|");
81344       }
81345       attribution.append("a").attr("class", "report-photo").attr("href", "mailto:signalement.ign@panoramax.fr").call(_t.append("panoramax.report"));
81346       attribution.append("span").text("|");
81347       attribution.append("a").attr("class", "image-link").attr("target", "_blank").attr("href", viewerLink).text("panoramax.xyz");
81348       getImageData2(d2.sequence_id, d2.id).then(function(data) {
81349         _currentScene = {
81350           currentImage: null,
81351           nextImage: null,
81352           prevImage: null
81353         };
81354         _currentScene.currentImage = data.assets[_definition];
81355         const nextIndex = data.links.findIndex((x2) => x2.rel === "next");
81356         const prevIndex = data.links.findIndex((x2) => x2.rel === "prev");
81357         if (nextIndex !== -1) {
81358           _currentScene.nextImage = data.links[nextIndex];
81359         }
81360         if (prevIndex !== -1) {
81361           _currentScene.prevImage = data.links[prevIndex];
81362         }
81363         d2.image_path = _currentScene.currentImage.href;
81364         wrap2.selectAll("button.back").classed("hide", _currentScene.prevImage === null);
81365         wrap2.selectAll("button.forward").classed("hide", _currentScene.nextImage === null);
81366         _currentFrame2 = d2.isPano ? _pannellumFrame2 : _planeFrame2;
81367         _currentFrame2.showPhotoFrame(wrap2).selectPhoto(d2, true);
81368       });
81369       function localeDateString2(s2) {
81370         if (!s2) return null;
81371         var options2 = { day: "numeric", month: "short", year: "numeric" };
81372         var d4 = new Date(s2);
81373         if (isNaN(d4.getTime())) return null;
81374         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
81375       }
81376       if (d2.account_id) {
81377         attribution.append("span").text("|");
81378         let line2 = attribution.append("span").attr("class", "attribution-row");
81379         getUsername(d2.account_id).then(function(username) {
81380           line2.append("span").attr("class", "captured_by").text(_t("panoramax.captured_by", { username }));
81381         });
81382       }
81383       return this;
81384     },
81385     photoFrame: function() {
81386       return _currentFrame2;
81387     },
81388     ensureViewerLoaded: function(context) {
81389       let that = this;
81390       let imgWrap = context.container().select("#ideditor-viewer-panoramax-simple > img");
81391       if (!imgWrap.empty()) {
81392         imgWrap.remove();
81393       }
81394       if (_loadViewerPromise6) return _loadViewerPromise6;
81395       let wrap2 = context.container().select(".photoviewer").selectAll(".panoramax-wrapper").data([0]);
81396       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper panoramax-wrapper").classed("hide", true).on("dblclick.zoom", null);
81397       wrapEnter.append("div").attr("class", "photo-attribution fillD");
81398       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls-panoramax");
81399       controlsEnter.append("button").classed("back", true).on("click.back", step(-1)).text("\u25C4");
81400       controlsEnter.append("button").classed("forward", true).on("click.forward", step(1)).text("\u25BA");
81401       _loadViewerPromise6 = Promise.all([
81402         pannellum_photo_default.init(context, wrapEnter),
81403         plane_photo_default.init(context, wrapEnter)
81404       ]).then(([pannellumPhotoFrame, planePhotoFrame]) => {
81405         _pannellumFrame2 = pannellumPhotoFrame;
81406         _pannellumFrame2.event.on("viewerChanged", () => dispatch13.call("viewerChanged"));
81407         _planeFrame2 = planePhotoFrame;
81408         _planeFrame2.event.on("viewerChanged", () => dispatch13.call("viewerChanged"));
81409       });
81410       function step(stepBy) {
81411         return function() {
81412           if (!_currentScene.currentImage) return;
81413           let nextId;
81414           if (stepBy === 1) nextId = _currentScene.nextImage.id;
81415           else nextId = _currentScene.prevImage.id;
81416           if (!nextId) return;
81417           const nextImage = _cache4.images.forImageId[nextId];
81418           if (nextImage) {
81419             context.map().centerEase(nextImage.loc);
81420             that.selectImage(context, nextImage.id);
81421           }
81422         };
81423       }
81424       return _loadViewerPromise6;
81425     },
81426     showViewer: function(context) {
81427       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
81428       let isHidden = wrap2.selectAll(".photo-wrapper.panoramax-wrapper.hide").size();
81429       if (isHidden) {
81430         wrap2.selectAll(".photo-wrapper:not(.panoramax-wrapper)").classed("hide", true);
81431         wrap2.selectAll(".photo-wrapper.panoramax-wrapper").classed("hide", false);
81432       }
81433       return this;
81434     },
81435     hideViewer: function(context) {
81436       let viewer = context.container().select(".photoviewer");
81437       if (!viewer.empty()) viewer.datum(null);
81438       this.updateUrlImage(null);
81439       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
81440       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
81441       this.setActiveImage();
81442       return this.setStyles(context, null);
81443     },
81444     cache: function() {
81445       return _cache4;
81446     }
81447   };
81448
81449   // modules/services/index.js
81450   var services = {
81451     geocoder: nominatim_default,
81452     keepRight: keepRight_default,
81453     osmose: osmose_default,
81454     mapillary: mapillary_default,
81455     nsi: nsi_default,
81456     kartaview: kartaview_default,
81457     vegbilder: vegbilder_default,
81458     osm: osm_default,
81459     osmWikibase: osm_wikibase_default,
81460     maprules: maprules_default,
81461     streetside: streetside_default,
81462     taginfo: taginfo_default,
81463     vectorTile: vector_tile_default,
81464     wikidata: wikidata_default,
81465     wikipedia: wikipedia_default,
81466     mapilio: mapilio_default,
81467     panoramax: panoramax_default
81468   };
81469
81470   // modules/modes/drag_note.js
81471   function modeDragNote(context) {
81472     var mode = {
81473       id: "drag-note",
81474       button: "browse"
81475     };
81476     var edit2 = behaviorEdit(context);
81477     var _nudgeInterval;
81478     var _lastLoc;
81479     var _note;
81480     function startNudge(d3_event, nudge) {
81481       if (_nudgeInterval) window.clearInterval(_nudgeInterval);
81482       _nudgeInterval = window.setInterval(function() {
81483         context.map().pan(nudge);
81484         doMove(d3_event, nudge);
81485       }, 50);
81486     }
81487     function stopNudge() {
81488       if (_nudgeInterval) {
81489         window.clearInterval(_nudgeInterval);
81490         _nudgeInterval = null;
81491       }
81492     }
81493     function origin(note) {
81494       return context.projection(note.loc);
81495     }
81496     function start2(d3_event, note) {
81497       _note = note;
81498       var osm = services.osm;
81499       if (osm) {
81500         _note = osm.getNote(_note.id);
81501       }
81502       context.surface().selectAll(".note-" + _note.id).classed("active", true);
81503       context.perform(actionNoop());
81504       context.enter(mode);
81505       context.selectedNoteID(_note.id);
81506     }
81507     function move(d3_event, entity, point) {
81508       d3_event.stopPropagation();
81509       _lastLoc = context.projection.invert(point);
81510       doMove(d3_event);
81511       var nudge = geoViewportEdge(point, context.map().dimensions());
81512       if (nudge) {
81513         startNudge(d3_event, nudge);
81514       } else {
81515         stopNudge();
81516       }
81517     }
81518     function doMove(d3_event, nudge) {
81519       nudge = nudge || [0, 0];
81520       var currPoint = d3_event && d3_event.point || context.projection(_lastLoc);
81521       var currMouse = geoVecSubtract(currPoint, nudge);
81522       var loc = context.projection.invert(currMouse);
81523       _note = _note.move(loc);
81524       var osm = services.osm;
81525       if (osm) {
81526         osm.replaceNote(_note);
81527       }
81528       context.replace(actionNoop());
81529     }
81530     function end() {
81531       context.replace(actionNoop());
81532       context.selectedNoteID(_note.id).enter(modeSelectNote(context, _note.id));
81533     }
81534     var drag = behaviorDrag().selector(".layer-touch.markers .target.note.new").surface(context.container().select(".main-map").node()).origin(origin).on("start", start2).on("move", move).on("end", end);
81535     mode.enter = function() {
81536       context.install(edit2);
81537     };
81538     mode.exit = function() {
81539       context.ui().sidebar.hover.cancel();
81540       context.uninstall(edit2);
81541       context.surface().selectAll(".active").classed("active", false);
81542       stopNudge();
81543     };
81544     mode.behavior = drag;
81545     return mode;
81546   }
81547
81548   // modules/modes/select_data.js
81549   function modeSelectData(context, selectedDatum) {
81550     var mode = {
81551       id: "select-data",
81552       button: "browse"
81553     };
81554     var keybinding = utilKeybinding("select-data");
81555     var dataEditor = uiDataEditor(context);
81556     var behaviors = [
81557       behaviorBreathe(context),
81558       behaviorHover(context),
81559       behaviorSelect(context),
81560       behaviorLasso(context),
81561       modeDragNode(context).behavior,
81562       modeDragNote(context).behavior
81563     ];
81564     function selectData(d3_event, drawn) {
81565       var selection2 = context.surface().selectAll(".layer-mapdata .data" + selectedDatum.__featurehash__);
81566       if (selection2.empty()) {
81567         var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
81568         if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
81569           context.enter(modeBrowse(context));
81570         }
81571       } else {
81572         selection2.classed("selected", true);
81573       }
81574     }
81575     function esc() {
81576       if (context.container().select(".combobox").size()) return;
81577       context.enter(modeBrowse(context));
81578     }
81579     mode.zoomToSelected = function() {
81580       var extent = geoExtent(bounds_default(selectedDatum));
81581       context.map().centerZoomEase(extent.center(), context.map().trimmedExtentZoom(extent));
81582     };
81583     mode.enter = function() {
81584       behaviors.forEach(context.install);
81585       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
81586       select_default2(document).call(keybinding);
81587       selectData();
81588       var sidebar = context.ui().sidebar;
81589       sidebar.show(dataEditor.datum(selectedDatum));
81590       var extent = geoExtent(bounds_default(selectedDatum));
81591       sidebar.expand(sidebar.intersects(extent));
81592       context.map().on("drawn.select-data", selectData);
81593     };
81594     mode.exit = function() {
81595       behaviors.forEach(context.uninstall);
81596       select_default2(document).call(keybinding.unbind);
81597       context.surface().selectAll(".layer-mapdata .selected").classed("selected hover", false);
81598       context.map().on("drawn.select-data", null);
81599       context.ui().sidebar.hide();
81600     };
81601     return mode;
81602   }
81603
81604   // modules/behavior/select.js
81605   function behaviorSelect(context) {
81606     var _tolerancePx = 4;
81607     var _lastMouseEvent = null;
81608     var _showMenu = false;
81609     var _downPointers = {};
81610     var _longPressTimeout = null;
81611     var _lastInteractionType = null;
81612     var _multiselectionPointerId = null;
81613     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
81614     function keydown(d3_event) {
81615       if (d3_event.keyCode === 32) {
81616         var activeNode = document.activeElement;
81617         if (activeNode && (/* @__PURE__ */ new Set(["INPUT", "TEXTAREA"])).has(activeNode.nodeName)) return;
81618       }
81619       if (d3_event.keyCode === 93 || // context menu key
81620       d3_event.keyCode === 32) {
81621         d3_event.preventDefault();
81622       }
81623       if (d3_event.repeat) return;
81624       cancelLongPress();
81625       if (d3_event.shiftKey) {
81626         context.surface().classed("behavior-multiselect", true);
81627       }
81628       if (d3_event.keyCode === 32) {
81629         if (!_downPointers.spacebar && _lastMouseEvent) {
81630           cancelLongPress();
81631           _longPressTimeout = window.setTimeout(didLongPress, 500, "spacebar", "spacebar");
81632           _downPointers.spacebar = {
81633             firstEvent: _lastMouseEvent,
81634             lastEvent: _lastMouseEvent
81635           };
81636         }
81637       }
81638     }
81639     function keyup(d3_event) {
81640       cancelLongPress();
81641       if (!d3_event.shiftKey) {
81642         context.surface().classed("behavior-multiselect", false);
81643       }
81644       if (d3_event.keyCode === 93) {
81645         d3_event.preventDefault();
81646         _lastInteractionType = "menukey";
81647         contextmenu(d3_event);
81648       } else if (d3_event.keyCode === 32) {
81649         var pointer = _downPointers.spacebar;
81650         if (pointer) {
81651           delete _downPointers.spacebar;
81652           if (pointer.done) return;
81653           d3_event.preventDefault();
81654           _lastInteractionType = "spacebar";
81655           click(pointer.firstEvent, pointer.lastEvent, "spacebar");
81656         }
81657       }
81658     }
81659     function pointerdown(d3_event) {
81660       var id2 = (d3_event.pointerId || "mouse").toString();
81661       cancelLongPress();
81662       if (d3_event.buttons && d3_event.buttons !== 1) return;
81663       context.ui().closeEditMenu();
81664       if (d3_event.pointerType !== "mouse") {
81665         _longPressTimeout = window.setTimeout(didLongPress, 500, id2, "longdown-" + (d3_event.pointerType || "mouse"));
81666       }
81667       _downPointers[id2] = {
81668         firstEvent: d3_event,
81669         lastEvent: d3_event
81670       };
81671     }
81672     function didLongPress(id2, interactionType) {
81673       var pointer = _downPointers[id2];
81674       if (!pointer) return;
81675       for (var i3 in _downPointers) {
81676         _downPointers[i3].done = true;
81677       }
81678       _longPressTimeout = null;
81679       _lastInteractionType = interactionType;
81680       _showMenu = true;
81681       click(pointer.firstEvent, pointer.lastEvent, id2);
81682     }
81683     function pointermove(d3_event) {
81684       var id2 = (d3_event.pointerId || "mouse").toString();
81685       if (_downPointers[id2]) {
81686         _downPointers[id2].lastEvent = d3_event;
81687       }
81688       if (!d3_event.pointerType || d3_event.pointerType === "mouse") {
81689         _lastMouseEvent = d3_event;
81690         if (_downPointers.spacebar) {
81691           _downPointers.spacebar.lastEvent = d3_event;
81692         }
81693       }
81694     }
81695     function pointerup(d3_event) {
81696       var id2 = (d3_event.pointerId || "mouse").toString();
81697       var pointer = _downPointers[id2];
81698       if (!pointer) return;
81699       delete _downPointers[id2];
81700       if (_multiselectionPointerId === id2) {
81701         _multiselectionPointerId = null;
81702       }
81703       if (pointer.done) return;
81704       click(pointer.firstEvent, d3_event, id2);
81705     }
81706     function pointercancel(d3_event) {
81707       var id2 = (d3_event.pointerId || "mouse").toString();
81708       if (!_downPointers[id2]) return;
81709       delete _downPointers[id2];
81710       if (_multiselectionPointerId === id2) {
81711         _multiselectionPointerId = null;
81712       }
81713     }
81714     function contextmenu(d3_event) {
81715       d3_event.preventDefault();
81716       if (!+d3_event.clientX && !+d3_event.clientY) {
81717         if (_lastMouseEvent) {
81718           d3_event = _lastMouseEvent;
81719         } else {
81720           return;
81721         }
81722       } else {
81723         _lastMouseEvent = d3_event;
81724         if (d3_event.pointerType === "touch" || d3_event.pointerType === "pen" || d3_event.mozInputSource && // firefox doesn't give a pointerType on contextmenu events
81725         (d3_event.mozInputSource === MouseEvent.MOZ_SOURCE_TOUCH || d3_event.mozInputSource === MouseEvent.MOZ_SOURCE_PEN)) {
81726           _lastInteractionType = "touch";
81727         } else {
81728           _lastInteractionType = "rightclick";
81729         }
81730       }
81731       _showMenu = true;
81732       click(d3_event, d3_event);
81733     }
81734     function click(firstEvent, lastEvent, pointerId) {
81735       cancelLongPress();
81736       var mapNode = context.container().select(".main-map").node();
81737       var pointGetter = utilFastMouse(mapNode);
81738       var p1 = pointGetter(firstEvent);
81739       var p2 = pointGetter(lastEvent);
81740       var dist = geoVecLength(p1, p2);
81741       if (dist > _tolerancePx || !mapContains(lastEvent)) {
81742         resetProperties();
81743         return;
81744       }
81745       var targetDatum = lastEvent.target.__data__;
81746       var multiselectEntityId;
81747       if (!_multiselectionPointerId) {
81748         var selectPointerInfo = pointerDownOnSelection(pointerId);
81749         if (selectPointerInfo) {
81750           _multiselectionPointerId = selectPointerInfo.pointerId;
81751           multiselectEntityId = !selectPointerInfo.selected && selectPointerInfo.entityId;
81752           _downPointers[selectPointerInfo.pointerId].done = true;
81753         }
81754       }
81755       var isMultiselect = context.mode().id === "select" && // and shift key is down
81756       (lastEvent && lastEvent.shiftKey || // or we're lasso-selecting
81757       context.surface().select(".lasso").node() || // or a pointer is down over a selected feature
81758       _multiselectionPointerId && !multiselectEntityId);
81759       processClick(targetDatum, isMultiselect, p2, multiselectEntityId);
81760       function mapContains(event) {
81761         var rect = mapNode.getBoundingClientRect();
81762         return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
81763       }
81764       function pointerDownOnSelection(skipPointerId) {
81765         var mode = context.mode();
81766         var selectedIDs = mode.id === "select" ? mode.selectedIDs() : [];
81767         for (var pointerId2 in _downPointers) {
81768           if (pointerId2 === "spacebar" || pointerId2 === skipPointerId) continue;
81769           var pointerInfo = _downPointers[pointerId2];
81770           var p12 = pointGetter(pointerInfo.firstEvent);
81771           var p22 = pointGetter(pointerInfo.lastEvent);
81772           if (geoVecLength(p12, p22) > _tolerancePx) continue;
81773           var datum2 = pointerInfo.firstEvent.target.__data__;
81774           var entity = datum2 && datum2.properties && datum2.properties.entity || datum2;
81775           if (context.graph().hasEntity(entity.id)) {
81776             return {
81777               pointerId: pointerId2,
81778               entityId: entity.id,
81779               selected: selectedIDs.indexOf(entity.id) !== -1
81780             };
81781           }
81782         }
81783         return null;
81784       }
81785     }
81786     function processClick(datum2, isMultiselect, point, alsoSelectId) {
81787       var mode = context.mode();
81788       var showMenu = _showMenu;
81789       var interactionType = _lastInteractionType;
81790       var entity = datum2 && datum2.properties && datum2.properties.entity;
81791       if (entity) datum2 = entity;
81792       if (datum2 && datum2.type === "midpoint") {
81793         datum2 = datum2.parents[0];
81794       }
81795       var newMode;
81796       if (datum2 instanceof osmEntity) {
81797         var selectedIDs = context.selectedIDs();
81798         context.selectedNoteID(null);
81799         context.selectedErrorID(null);
81800         if (!isMultiselect) {
81801           if (!showMenu || selectedIDs.length <= 1 || selectedIDs.indexOf(datum2.id) === -1) {
81802             if (alsoSelectId === datum2.id) alsoSelectId = null;
81803             selectedIDs = (alsoSelectId ? [alsoSelectId] : []).concat([datum2.id]);
81804             newMode = mode.id === "select" ? mode.selectedIDs(selectedIDs) : modeSelect(context, selectedIDs).selectBehavior(behavior);
81805             context.enter(newMode);
81806           }
81807         } else {
81808           if (selectedIDs.indexOf(datum2.id) !== -1) {
81809             if (!showMenu) {
81810               selectedIDs = selectedIDs.filter(function(id2) {
81811                 return id2 !== datum2.id;
81812               });
81813               newMode = selectedIDs.length ? mode.selectedIDs(selectedIDs) : modeBrowse(context).selectBehavior(behavior);
81814               context.enter(newMode);
81815             }
81816           } else {
81817             selectedIDs = selectedIDs.concat([datum2.id]);
81818             newMode = mode.selectedIDs(selectedIDs);
81819             context.enter(newMode);
81820           }
81821         }
81822       } else if (datum2 && datum2.__featurehash__ && !isMultiselect) {
81823         context.selectedNoteID(null).enter(modeSelectData(context, datum2));
81824       } else if (datum2 instanceof osmNote && !isMultiselect) {
81825         context.selectedNoteID(datum2.id).enter(modeSelectNote(context, datum2.id));
81826       } else if (datum2 instanceof QAItem && !isMultiselect) {
81827         context.selectedErrorID(datum2.id).enter(modeSelectError(context, datum2.id, datum2.service));
81828       } else {
81829         context.selectedNoteID(null);
81830         context.selectedErrorID(null);
81831         if (!isMultiselect && mode.id !== "browse") {
81832           context.enter(modeBrowse(context));
81833         }
81834       }
81835       context.ui().closeEditMenu();
81836       if (showMenu) context.ui().showEditMenu(point, interactionType);
81837       resetProperties();
81838     }
81839     function cancelLongPress() {
81840       if (_longPressTimeout) window.clearTimeout(_longPressTimeout);
81841       _longPressTimeout = null;
81842     }
81843     function resetProperties() {
81844       cancelLongPress();
81845       _showMenu = false;
81846       _lastInteractionType = null;
81847     }
81848     function behavior(selection2) {
81849       resetProperties();
81850       _lastMouseEvent = context.map().lastPointerEvent();
81851       select_default2(window).on("keydown.select", keydown).on("keyup.select", keyup).on(_pointerPrefix + "move.select", pointermove, true).on(_pointerPrefix + "up.select", pointerup, true).on("pointercancel.select", pointercancel, true).on("contextmenu.select-window", function(d3_event) {
81852         var e3 = d3_event;
81853         if (+e3.clientX === 0 && +e3.clientY === 0) {
81854           d3_event.preventDefault();
81855         }
81856       });
81857       selection2.on(_pointerPrefix + "down.select", pointerdown).on("contextmenu.select", contextmenu);
81858     }
81859     behavior.off = function(selection2) {
81860       cancelLongPress();
81861       select_default2(window).on("keydown.select", null).on("keyup.select", null).on("contextmenu.select-window", null).on(_pointerPrefix + "move.select", null, true).on(_pointerPrefix + "up.select", null, true).on("pointercancel.select", null, true);
81862       selection2.on(_pointerPrefix + "down.select", null).on("contextmenu.select", null);
81863       context.surface().classed("behavior-multiselect", false);
81864     };
81865     return behavior;
81866   }
81867
81868   // modules/operations/index.js
81869   var operations_exports = {};
81870   __export(operations_exports, {
81871     operationCircularize: () => operationCircularize,
81872     operationContinue: () => operationContinue,
81873     operationCopy: () => operationCopy,
81874     operationDelete: () => operationDelete,
81875     operationDisconnect: () => operationDisconnect,
81876     operationDowngrade: () => operationDowngrade,
81877     operationExtract: () => operationExtract,
81878     operationMerge: () => operationMerge,
81879     operationMove: () => operationMove,
81880     operationOrthogonalize: () => operationOrthogonalize,
81881     operationPaste: () => operationPaste,
81882     operationReflectLong: () => operationReflectLong,
81883     operationReflectShort: () => operationReflectShort,
81884     operationReverse: () => operationReverse,
81885     operationRotate: () => operationRotate,
81886     operationSplit: () => operationSplit,
81887     operationStraighten: () => operationStraighten
81888   });
81889
81890   // modules/operations/continue.js
81891   function operationContinue(context, selectedIDs) {
81892     var _entities = selectedIDs.map(function(id2) {
81893       return context.graph().entity(id2);
81894     });
81895     var _geometries = Object.assign(
81896       { line: [], vertex: [] },
81897       utilArrayGroupBy(_entities, function(entity) {
81898         return entity.geometry(context.graph());
81899       })
81900     );
81901     var _vertex = _geometries.vertex.length && _geometries.vertex[0];
81902     function candidateWays() {
81903       return _vertex ? context.graph().parentWays(_vertex).filter(function(parent) {
81904         return parent.geometry(context.graph()) === "line" && !parent.isClosed() && parent.affix(_vertex.id) && (_geometries.line.length === 0 || _geometries.line[0] === parent);
81905       }) : [];
81906     }
81907     var _candidates = candidateWays();
81908     var operation2 = function() {
81909       var candidate = _candidates[0];
81910       context.enter(
81911         modeDrawLine(context, candidate.id, context.graph(), "line", candidate.affix(_vertex.id), true)
81912       );
81913     };
81914     operation2.relatedEntityIds = function() {
81915       return _candidates.length ? [_candidates[0].id] : [];
81916     };
81917     operation2.available = function() {
81918       return _geometries.vertex.length === 1 && _geometries.line.length <= 1 && !context.features().hasHiddenConnections(_vertex, context.graph());
81919     };
81920     operation2.disabled = function() {
81921       if (_candidates.length === 0) {
81922         return "not_eligible";
81923       } else if (_candidates.length > 1) {
81924         return "multiple";
81925       }
81926       return false;
81927     };
81928     operation2.tooltip = function() {
81929       var disable = operation2.disabled();
81930       return disable ? _t.append("operations.continue." + disable) : _t.append("operations.continue.description");
81931     };
81932     operation2.annotation = function() {
81933       return _t("operations.continue.annotation.line");
81934     };
81935     operation2.id = "continue";
81936     operation2.keys = [_t("operations.continue.key")];
81937     operation2.title = _t.append("operations.continue.title");
81938     operation2.behavior = behaviorOperation(context).which(operation2);
81939     return operation2;
81940   }
81941
81942   // modules/operations/copy.js
81943   function operationCopy(context, selectedIDs) {
81944     function getFilteredIdsToCopy() {
81945       return selectedIDs.filter(function(selectedID) {
81946         var entity = context.graph().hasEntity(selectedID);
81947         return entity.hasInterestingTags() || entity.geometry(context.graph()) !== "vertex";
81948       });
81949     }
81950     var operation2 = function() {
81951       var graph = context.graph();
81952       var selected = groupEntities(getFilteredIdsToCopy(), graph);
81953       var canCopy = [];
81954       var skip = {};
81955       var entity;
81956       var i3;
81957       for (i3 = 0; i3 < selected.relation.length; i3++) {
81958         entity = selected.relation[i3];
81959         if (!skip[entity.id] && entity.isComplete(graph)) {
81960           canCopy.push(entity.id);
81961           skip = getDescendants(entity.id, graph, skip);
81962         }
81963       }
81964       for (i3 = 0; i3 < selected.way.length; i3++) {
81965         entity = selected.way[i3];
81966         if (!skip[entity.id]) {
81967           canCopy.push(entity.id);
81968           skip = getDescendants(entity.id, graph, skip);
81969         }
81970       }
81971       for (i3 = 0; i3 < selected.node.length; i3++) {
81972         entity = selected.node[i3];
81973         if (!skip[entity.id]) {
81974           canCopy.push(entity.id);
81975         }
81976       }
81977       context.copyIDs(canCopy);
81978       if (_point && (canCopy.length !== 1 || graph.entity(canCopy[0]).type !== "node")) {
81979         context.copyLonLat(context.projection.invert(_point));
81980       } else {
81981         context.copyLonLat(null);
81982       }
81983     };
81984     function groupEntities(ids, graph) {
81985       var entities = ids.map(function(id2) {
81986         return graph.entity(id2);
81987       });
81988       return Object.assign(
81989         { relation: [], way: [], node: [] },
81990         utilArrayGroupBy(entities, "type")
81991       );
81992     }
81993     function getDescendants(id2, graph, descendants) {
81994       var entity = graph.entity(id2);
81995       var children2;
81996       descendants = descendants || {};
81997       if (entity.type === "relation") {
81998         children2 = entity.members.map(function(m2) {
81999           return m2.id;
82000         });
82001       } else if (entity.type === "way") {
82002         children2 = entity.nodes;
82003       } else {
82004         children2 = [];
82005       }
82006       for (var i3 = 0; i3 < children2.length; i3++) {
82007         if (!descendants[children2[i3]]) {
82008           descendants[children2[i3]] = true;
82009           descendants = getDescendants(children2[i3], graph, descendants);
82010         }
82011       }
82012       return descendants;
82013     }
82014     operation2.available = function() {
82015       return getFilteredIdsToCopy().length > 0;
82016     };
82017     operation2.disabled = function() {
82018       var extent = utilTotalExtent(getFilteredIdsToCopy(), context.graph());
82019       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
82020         return "too_large";
82021       }
82022       return false;
82023     };
82024     operation2.availableForKeypress = function() {
82025       var selection2 = window.getSelection && window.getSelection();
82026       return !selection2 || !selection2.toString();
82027     };
82028     operation2.tooltip = function() {
82029       var disable = operation2.disabled();
82030       return disable ? _t.append("operations.copy." + disable, { n: selectedIDs.length }) : _t.append("operations.copy.description", { n: selectedIDs.length });
82031     };
82032     operation2.annotation = function() {
82033       return _t("operations.copy.annotation", { n: selectedIDs.length });
82034     };
82035     var _point;
82036     operation2.point = function(val) {
82037       _point = val;
82038       return operation2;
82039     };
82040     operation2.id = "copy";
82041     operation2.keys = [uiCmd("\u2318C")];
82042     operation2.title = _t.append("operations.copy.title");
82043     operation2.behavior = behaviorOperation(context).which(operation2);
82044     return operation2;
82045   }
82046
82047   // modules/operations/disconnect.js
82048   function operationDisconnect(context, selectedIDs) {
82049     var _vertexIDs = [];
82050     var _wayIDs = [];
82051     var _otherIDs = [];
82052     var _actions = [];
82053     selectedIDs.forEach(function(id2) {
82054       var entity = context.entity(id2);
82055       if (entity.type === "way") {
82056         _wayIDs.push(id2);
82057       } else if (entity.geometry(context.graph()) === "vertex") {
82058         _vertexIDs.push(id2);
82059       } else {
82060         _otherIDs.push(id2);
82061       }
82062     });
82063     var _coords, _descriptionID = "", _annotationID = "features";
82064     var _disconnectingVertexIds = [];
82065     var _disconnectingWayIds = [];
82066     if (_vertexIDs.length > 0) {
82067       _disconnectingVertexIds = _vertexIDs;
82068       _vertexIDs.forEach(function(vertexID) {
82069         var action = actionDisconnect(vertexID);
82070         if (_wayIDs.length > 0) {
82071           var waysIDsForVertex = _wayIDs.filter(function(wayID) {
82072             var way = context.entity(wayID);
82073             return way.nodes.indexOf(vertexID) !== -1;
82074           });
82075           action.limitWays(waysIDsForVertex);
82076         }
82077         _actions.push(action);
82078         _disconnectingWayIds = _disconnectingWayIds.concat(context.graph().parentWays(context.graph().entity(vertexID)).map((d2) => d2.id));
82079       });
82080       _disconnectingWayIds = utilArrayUniq(_disconnectingWayIds).filter(function(id2) {
82081         return _wayIDs.indexOf(id2) === -1;
82082       });
82083       _descriptionID += _actions.length === 1 ? "single_point." : "multiple_points.";
82084       if (_wayIDs.length === 1) {
82085         _descriptionID += "single_way." + context.graph().geometry(_wayIDs[0]);
82086       } else {
82087         _descriptionID += _wayIDs.length === 0 ? "no_ways" : "multiple_ways";
82088       }
82089     } else if (_wayIDs.length > 0) {
82090       var ways = _wayIDs.map(function(id2) {
82091         return context.entity(id2);
82092       });
82093       var nodes = utilGetAllNodes(_wayIDs, context.graph());
82094       _coords = nodes.map(function(n3) {
82095         return n3.loc;
82096       });
82097       var sharedActions = [];
82098       var sharedNodes = [];
82099       var unsharedActions = [];
82100       var unsharedNodes = [];
82101       nodes.forEach(function(node) {
82102         var action = actionDisconnect(node.id).limitWays(_wayIDs);
82103         if (action.disabled(context.graph()) !== "not_connected") {
82104           var count = 0;
82105           for (var i3 in ways) {
82106             var way = ways[i3];
82107             if (way.nodes.indexOf(node.id) !== -1) {
82108               count += 1;
82109             }
82110             if (count > 1) break;
82111           }
82112           if (count > 1) {
82113             sharedActions.push(action);
82114             sharedNodes.push(node);
82115           } else {
82116             unsharedActions.push(action);
82117             unsharedNodes.push(node);
82118           }
82119         }
82120       });
82121       _descriptionID += "no_points.";
82122       _descriptionID += _wayIDs.length === 1 ? "single_way." : "multiple_ways.";
82123       if (sharedActions.length) {
82124         _actions = sharedActions;
82125         _disconnectingVertexIds = sharedNodes.map((node) => node.id);
82126         _descriptionID += "conjoined";
82127         _annotationID = "from_each_other";
82128       } else {
82129         _actions = unsharedActions;
82130         _disconnectingVertexIds = unsharedNodes.map((node) => node.id);
82131         if (_wayIDs.length === 1) {
82132           _descriptionID += context.graph().geometry(_wayIDs[0]);
82133         } else {
82134           _descriptionID += "separate";
82135         }
82136       }
82137     }
82138     var _extent = utilTotalExtent(_disconnectingVertexIds, context.graph());
82139     var operation2 = function() {
82140       context.perform(function(graph) {
82141         return _actions.reduce(function(graph2, action) {
82142           return action(graph2);
82143         }, graph);
82144       }, operation2.annotation());
82145       context.validator().validate();
82146     };
82147     operation2.relatedEntityIds = function() {
82148       if (_vertexIDs.length) {
82149         return _disconnectingWayIds;
82150       }
82151       return _disconnectingVertexIds;
82152     };
82153     operation2.available = function() {
82154       if (_actions.length === 0) return false;
82155       if (_otherIDs.length !== 0) return false;
82156       if (_vertexIDs.length !== 0 && _wayIDs.length !== 0 && !_wayIDs.every(function(wayID) {
82157         return _vertexIDs.some(function(vertexID) {
82158           var way = context.entity(wayID);
82159           return way.nodes.indexOf(vertexID) !== -1;
82160         });
82161       })) return false;
82162       return true;
82163     };
82164     operation2.disabled = function() {
82165       var reason;
82166       for (var actionIndex in _actions) {
82167         reason = _actions[actionIndex].disabled(context.graph());
82168         if (reason) return reason;
82169       }
82170       if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
82171         return "too_large." + ((_vertexIDs.length ? _vertexIDs : _wayIDs).length === 1 ? "single" : "multiple");
82172       } else if (_coords && someMissing()) {
82173         return "not_downloaded";
82174       } else if (selectedIDs.some(context.hasHiddenConnections)) {
82175         return "connected_to_hidden";
82176       }
82177       return false;
82178       function someMissing() {
82179         if (context.inIntro()) return false;
82180         var osm = context.connection();
82181         if (osm) {
82182           var missing = _coords.filter(function(loc) {
82183             return !osm.isDataLoaded(loc);
82184           });
82185           if (missing.length) {
82186             missing.forEach(function(loc) {
82187               context.loadTileAtLoc(loc);
82188             });
82189             return true;
82190           }
82191         }
82192         return false;
82193       }
82194     };
82195     operation2.tooltip = function() {
82196       var disable = operation2.disabled();
82197       return disable ? _t.append("operations.disconnect." + disable) : _t.append("operations.disconnect.description." + _descriptionID);
82198     };
82199     operation2.annotation = function() {
82200       return _t("operations.disconnect.annotation." + _annotationID);
82201     };
82202     operation2.id = "disconnect";
82203     operation2.keys = [_t("operations.disconnect.key")];
82204     operation2.title = _t.append("operations.disconnect.title");
82205     operation2.behavior = behaviorOperation(context).which(operation2);
82206     return operation2;
82207   }
82208
82209   // modules/operations/downgrade.js
82210   function operationDowngrade(context, selectedIDs) {
82211     var _affectedFeatureCount = 0;
82212     var _downgradeType = downgradeTypeForEntityIDs(selectedIDs);
82213     var _multi = _affectedFeatureCount === 1 ? "single" : "multiple";
82214     function downgradeTypeForEntityIDs(entityIds) {
82215       var downgradeType;
82216       _affectedFeatureCount = 0;
82217       for (var i3 in entityIds) {
82218         var entityID = entityIds[i3];
82219         var type2 = downgradeTypeForEntityID(entityID);
82220         if (type2) {
82221           _affectedFeatureCount += 1;
82222           if (downgradeType && type2 !== downgradeType) {
82223             if (downgradeType !== "generic" && type2 !== "generic") {
82224               downgradeType = "building_address";
82225             } else {
82226               downgradeType = "generic";
82227             }
82228           } else {
82229             downgradeType = type2;
82230           }
82231         }
82232       }
82233       return downgradeType;
82234     }
82235     function downgradeTypeForEntityID(entityID) {
82236       var graph = context.graph();
82237       var entity = graph.entity(entityID);
82238       var preset = _mainPresetIndex.match(entity, graph);
82239       if (!preset || preset.isFallback()) return null;
82240       if (entity.type === "node" && preset.id !== "address" && Object.keys(entity.tags).some(function(key) {
82241         return key.match(/^addr:.{1,}/);
82242       })) {
82243         return "address";
82244       }
82245       var geometry = entity.geometry(graph);
82246       if (geometry === "area" && entity.tags.building && !preset.tags.building) {
82247         return "building";
82248       }
82249       if (geometry === "vertex" && Object.keys(entity.tags).length) {
82250         return "generic";
82251       }
82252       return null;
82253     }
82254     var buildingKeysToKeep = ["architect", "building", "height", "layer", "nycdoitt:bin", "source", "type", "wheelchair"];
82255     var addressKeysToKeep = ["source"];
82256     var operation2 = function() {
82257       context.perform(function(graph) {
82258         for (var i3 in selectedIDs) {
82259           var entityID = selectedIDs[i3];
82260           var type2 = downgradeTypeForEntityID(entityID);
82261           if (!type2) continue;
82262           var tags = Object.assign({}, graph.entity(entityID).tags);
82263           for (var key in tags) {
82264             if (type2 === "address" && addressKeysToKeep.indexOf(key) !== -1) continue;
82265             if (type2 === "building") {
82266               if (buildingKeysToKeep.indexOf(key) !== -1 || key.match(/^building:.{1,}/) || key.match(/^roof:.{1,}/)) continue;
82267             }
82268             if (type2 !== "generic") {
82269               if (key.match(/^addr:.{1,}/) || key.match(/^source:.{1,}/)) continue;
82270             }
82271             delete tags[key];
82272           }
82273           graph = actionChangeTags(entityID, tags)(graph);
82274         }
82275         return graph;
82276       }, operation2.annotation());
82277       context.validator().validate();
82278       context.enter(modeSelect(context, selectedIDs));
82279     };
82280     operation2.available = function() {
82281       return _downgradeType;
82282     };
82283     operation2.disabled = function() {
82284       if (selectedIDs.some(hasWikidataTag)) {
82285         return "has_wikidata_tag";
82286       }
82287       return false;
82288       function hasWikidataTag(id2) {
82289         var entity = context.entity(id2);
82290         return entity.tags.wikidata && entity.tags.wikidata.trim().length > 0;
82291       }
82292     };
82293     operation2.tooltip = function() {
82294       var disable = operation2.disabled();
82295       return disable ? _t.append("operations.downgrade." + disable + "." + _multi) : _t.append("operations.downgrade.description." + _downgradeType);
82296     };
82297     operation2.annotation = function() {
82298       var suffix;
82299       if (_downgradeType === "building_address") {
82300         suffix = "generic";
82301       } else {
82302         suffix = _downgradeType;
82303       }
82304       return _t("operations.downgrade.annotation." + suffix, { n: _affectedFeatureCount });
82305     };
82306     operation2.id = "downgrade";
82307     operation2.keys = [uiCmd("\u232B")];
82308     operation2.title = _t.append("operations.downgrade.title");
82309     operation2.behavior = behaviorOperation(context).which(operation2);
82310     return operation2;
82311   }
82312
82313   // modules/operations/extract.js
82314   function operationExtract(context, selectedIDs) {
82315     var _amount = selectedIDs.length === 1 ? "single" : "multiple";
82316     var _geometries = utilArrayUniq(selectedIDs.map(function(entityID) {
82317       return context.graph().hasEntity(entityID) && context.graph().geometry(entityID);
82318     }).filter(Boolean));
82319     var _geometryID = _geometries.length === 1 ? _geometries[0] : "feature";
82320     var _extent;
82321     var _actions = selectedIDs.map(function(entityID) {
82322       var graph = context.graph();
82323       var entity = graph.hasEntity(entityID);
82324       if (!entity || !entity.hasInterestingTags()) return null;
82325       if (entity.type === "node" && graph.parentWays(entity).length === 0) return null;
82326       if (entity.type !== "node") {
82327         var preset = _mainPresetIndex.match(entity, graph);
82328         if (preset.geometry.indexOf("point") === -1) return null;
82329       }
82330       _extent = _extent ? _extent.extend(entity.extent(graph)) : entity.extent(graph);
82331       return actionExtract(entityID, context.projection);
82332     }).filter(Boolean);
82333     var operation2 = function(d3_event) {
82334       const shiftKeyPressed = (d3_event == null ? void 0 : d3_event.shiftKey) || false;
82335       var combinedAction = function(graph) {
82336         _actions.forEach(function(action) {
82337           graph = action(graph, shiftKeyPressed);
82338         });
82339         return graph;
82340       };
82341       context.perform(combinedAction, operation2.annotation());
82342       var extractedNodeIDs = _actions.map(function(action) {
82343         return action.getExtractedNodeID();
82344       });
82345       context.enter(modeSelect(context, extractedNodeIDs));
82346     };
82347     operation2.available = function() {
82348       return _actions.length && selectedIDs.length === _actions.length;
82349     };
82350     operation2.disabled = function() {
82351       if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
82352         return "too_large";
82353       } else if (selectedIDs.some(function(entityID) {
82354         return context.graph().geometry(entityID) === "vertex" && context.hasHiddenConnections(entityID);
82355       })) {
82356         return "connected_to_hidden";
82357       }
82358       return false;
82359     };
82360     operation2.tooltip = function() {
82361       var disableReason = operation2.disabled();
82362       if (disableReason) {
82363         return _t.append("operations.extract." + disableReason + "." + _amount);
82364       } else {
82365         return _t.append("operations.extract.description." + _geometryID + "." + _amount);
82366       }
82367     };
82368     operation2.annotation = function() {
82369       return _t("operations.extract.annotation", { n: selectedIDs.length });
82370     };
82371     operation2.id = "extract";
82372     operation2.keys = [_t("operations.extract.key")];
82373     operation2.title = _t.append("operations.extract.title");
82374     operation2.behavior = behaviorOperation(context).which(operation2);
82375     return operation2;
82376   }
82377
82378   // modules/operations/merge.js
82379   function operationMerge(context, selectedIDs) {
82380     var _action = getAction();
82381     function getAction() {
82382       var join = actionJoin(selectedIDs);
82383       if (!join.disabled(context.graph())) return join;
82384       var merge2 = actionMerge(selectedIDs);
82385       if (!merge2.disabled(context.graph())) return merge2;
82386       var mergePolygon = actionMergePolygon(selectedIDs);
82387       if (!mergePolygon.disabled(context.graph())) return mergePolygon;
82388       var mergeNodes = actionMergeNodes(selectedIDs);
82389       if (!mergeNodes.disabled(context.graph())) return mergeNodes;
82390       if (join.disabled(context.graph()) !== "not_eligible") return join;
82391       if (merge2.disabled(context.graph()) !== "not_eligible") return merge2;
82392       if (mergePolygon.disabled(context.graph()) !== "not_eligible") return mergePolygon;
82393       return mergeNodes;
82394     }
82395     var operation2 = function() {
82396       if (operation2.disabled()) return;
82397       context.perform(_action, operation2.annotation());
82398       context.validator().validate();
82399       var resultIDs = selectedIDs.filter(context.hasEntity);
82400       if (resultIDs.length > 1) {
82401         var interestingIDs = resultIDs.filter(function(id2) {
82402           return context.entity(id2).hasInterestingTags();
82403         });
82404         if (interestingIDs.length) resultIDs = interestingIDs;
82405       }
82406       context.enter(modeSelect(context, resultIDs));
82407     };
82408     operation2.available = function() {
82409       return selectedIDs.length >= 2;
82410     };
82411     operation2.disabled = function() {
82412       var actionDisabled = _action.disabled(context.graph());
82413       if (actionDisabled) return actionDisabled;
82414       var osm = context.connection();
82415       if (osm && _action.resultingWayNodesLength && _action.resultingWayNodesLength(context.graph()) > osm.maxWayNodes()) {
82416         return "too_many_vertices";
82417       }
82418       return false;
82419     };
82420     operation2.tooltip = function() {
82421       var disabled = operation2.disabled();
82422       if (disabled) {
82423         if (disabled === "conflicting_relations") {
82424           return _t.append("operations.merge.conflicting_relations");
82425         }
82426         if (disabled === "restriction" || disabled === "connectivity") {
82427           return _t.append(
82428             "operations.merge.damage_relation",
82429             { relation: _mainPresetIndex.item("type/" + disabled).name() }
82430           );
82431         }
82432         return _t.append("operations.merge." + disabled);
82433       }
82434       return _t.append("operations.merge.description");
82435     };
82436     operation2.annotation = function() {
82437       return _t("operations.merge.annotation", { n: selectedIDs.length });
82438     };
82439     operation2.id = "merge";
82440     operation2.keys = [_t("operations.merge.key")];
82441     operation2.title = _t.append("operations.merge.title");
82442     operation2.behavior = behaviorOperation(context).which(operation2);
82443     return operation2;
82444   }
82445
82446   // modules/operations/paste.js
82447   function operationPaste(context) {
82448     var _pastePoint;
82449     var operation2 = function() {
82450       if (!_pastePoint) return;
82451       var oldIDs = context.copyIDs();
82452       if (!oldIDs.length) return;
82453       var projection2 = context.projection;
82454       var extent = geoExtent();
82455       var oldGraph = context.copyGraph();
82456       var newIDs = [];
82457       var action = actionCopyEntities(oldIDs, oldGraph);
82458       context.perform(action);
82459       var copies = action.copies();
82460       var originals = /* @__PURE__ */ new Set();
82461       Object.values(copies).forEach(function(entity) {
82462         originals.add(entity.id);
82463       });
82464       for (var id2 in copies) {
82465         var oldEntity = oldGraph.entity(id2);
82466         var newEntity = copies[id2];
82467         extent._extend(oldEntity.extent(oldGraph));
82468         var parents = context.graph().parentWays(newEntity);
82469         var parentCopied = parents.some(function(parent) {
82470           return originals.has(parent.id);
82471         });
82472         if (!parentCopied) {
82473           newIDs.push(newEntity.id);
82474         }
82475       }
82476       var copyPoint = context.copyLonLat() && projection2(context.copyLonLat()) || projection2(extent.center());
82477       var delta = geoVecSubtract(_pastePoint, copyPoint);
82478       context.replace(actionMove(newIDs, delta, projection2), operation2.annotation());
82479       context.enter(modeSelect(context, newIDs));
82480     };
82481     operation2.point = function(val) {
82482       _pastePoint = val;
82483       return operation2;
82484     };
82485     operation2.available = function() {
82486       return context.mode().id === "browse";
82487     };
82488     operation2.disabled = function() {
82489       return !context.copyIDs().length;
82490     };
82491     operation2.tooltip = function() {
82492       var oldGraph = context.copyGraph();
82493       var ids = context.copyIDs();
82494       if (!ids.length) {
82495         return _t.append("operations.paste.nothing_copied");
82496       }
82497       return _t.append("operations.paste.description", { feature: utilDisplayLabel(oldGraph.entity(ids[0]), oldGraph), n: ids.length });
82498     };
82499     operation2.annotation = function() {
82500       var ids = context.copyIDs();
82501       return _t("operations.paste.annotation", { n: ids.length });
82502     };
82503     operation2.id = "paste";
82504     operation2.keys = [uiCmd("\u2318V")];
82505     operation2.title = _t.append("operations.paste.title");
82506     return operation2;
82507   }
82508
82509   // modules/operations/reverse.js
82510   function operationReverse(context, selectedIDs) {
82511     var operation2 = function() {
82512       context.perform(function combinedReverseAction(graph) {
82513         actions().forEach(function(action) {
82514           graph = action(graph);
82515         });
82516         return graph;
82517       }, operation2.annotation());
82518       context.validator().validate();
82519     };
82520     function actions(situation) {
82521       return selectedIDs.map(function(entityID) {
82522         var entity = context.hasEntity(entityID);
82523         if (!entity) return null;
82524         if (situation === "toolbar") {
82525           if (entity.type === "way" && (!entity.isOneWay() && !entity.isSided())) return null;
82526         }
82527         var geometry = entity.geometry(context.graph());
82528         if (entity.type !== "node" && geometry !== "line") return null;
82529         var action = actionReverse(entityID);
82530         if (action.disabled(context.graph())) return null;
82531         return action;
82532       }).filter(Boolean);
82533     }
82534     function reverseTypeID() {
82535       var acts = actions();
82536       var nodeActionCount = acts.filter(function(act) {
82537         var entity = context.hasEntity(act.entityID());
82538         return entity && entity.type === "node";
82539       }).length;
82540       if (nodeActionCount === 0) return "line";
82541       if (nodeActionCount === acts.length) return "point";
82542       return "feature";
82543     }
82544     operation2.available = function(situation) {
82545       return actions(situation).length > 0;
82546     };
82547     operation2.disabled = function() {
82548       return false;
82549     };
82550     operation2.tooltip = function() {
82551       return _t.append("operations.reverse.description." + reverseTypeID());
82552     };
82553     operation2.annotation = function() {
82554       var acts = actions();
82555       return _t("operations.reverse.annotation." + reverseTypeID(), { n: acts.length });
82556     };
82557     operation2.id = "reverse";
82558     operation2.keys = [_t("operations.reverse.key")];
82559     operation2.title = _t.append("operations.reverse.title");
82560     operation2.behavior = behaviorOperation(context).which(operation2);
82561     return operation2;
82562   }
82563
82564   // modules/operations/split.js
82565   function operationSplit(context, selectedIDs) {
82566     var _vertexIds = selectedIDs.filter(function(id2) {
82567       return context.graph().geometry(id2) === "vertex";
82568     });
82569     var _selectedWayIds = selectedIDs.filter(function(id2) {
82570       var entity = context.graph().hasEntity(id2);
82571       return entity && entity.type === "way";
82572     });
82573     var _isAvailable = _vertexIds.length > 0 && _vertexIds.length + _selectedWayIds.length === selectedIDs.length;
82574     var _action = actionSplit(_vertexIds);
82575     var _ways = [];
82576     var _geometry = "feature";
82577     var _waysAmount = "single";
82578     var _nodesAmount = _vertexIds.length === 1 ? "single" : "multiple";
82579     if (_isAvailable) {
82580       if (_selectedWayIds.length) _action.limitWays(_selectedWayIds);
82581       _ways = _action.ways(context.graph());
82582       var geometries = {};
82583       _ways.forEach(function(way) {
82584         geometries[way.geometry(context.graph())] = true;
82585       });
82586       if (Object.keys(geometries).length === 1) {
82587         _geometry = Object.keys(geometries)[0];
82588       }
82589       _waysAmount = _ways.length === 1 ? "single" : "multiple";
82590     }
82591     var operation2 = function() {
82592       var difference2 = context.perform(_action, operation2.annotation());
82593       var idsToSelect = _vertexIds.concat(difference2.extantIDs().filter(function(id2) {
82594         return context.entity(id2).type === "way";
82595       }));
82596       context.enter(modeSelect(context, idsToSelect));
82597     };
82598     operation2.relatedEntityIds = function() {
82599       return _selectedWayIds.length ? [] : _ways.map((way) => way.id);
82600     };
82601     operation2.available = function() {
82602       return _isAvailable;
82603     };
82604     operation2.disabled = function() {
82605       var reason = _action.disabled(context.graph());
82606       if (reason) {
82607         return reason;
82608       } else if (selectedIDs.some(context.hasHiddenConnections)) {
82609         return "connected_to_hidden";
82610       }
82611       return false;
82612     };
82613     operation2.tooltip = function() {
82614       var disable = operation2.disabled();
82615       return disable ? _t.append("operations.split." + disable) : _t.append("operations.split.description." + _geometry + "." + _waysAmount + "." + _nodesAmount + "_node");
82616     };
82617     operation2.annotation = function() {
82618       return _t("operations.split.annotation." + _geometry, { n: _ways.length });
82619     };
82620     operation2.icon = function() {
82621       if (_waysAmount === "multiple") {
82622         return "#iD-operation-split-multiple";
82623       } else {
82624         return "#iD-operation-split";
82625       }
82626     };
82627     operation2.id = "split";
82628     operation2.keys = [_t("operations.split.key")];
82629     operation2.title = _t.append("operations.split.title");
82630     operation2.behavior = behaviorOperation(context).which(operation2);
82631     return operation2;
82632   }
82633
82634   // modules/operations/straighten.js
82635   function operationStraighten(context, selectedIDs) {
82636     var _wayIDs = selectedIDs.filter(function(id2) {
82637       return id2.charAt(0) === "w";
82638     });
82639     var _nodeIDs = selectedIDs.filter(function(id2) {
82640       return id2.charAt(0) === "n";
82641     });
82642     var _amount = (_wayIDs.length ? _wayIDs : _nodeIDs).length === 1 ? "single" : "multiple";
82643     var _nodes = utilGetAllNodes(selectedIDs, context.graph());
82644     var _coords = _nodes.map(function(n3) {
82645       return n3.loc;
82646     });
82647     var _extent = utilTotalExtent(selectedIDs, context.graph());
82648     var _action = chooseAction();
82649     var _geometry;
82650     function chooseAction() {
82651       if (_wayIDs.length === 0 && _nodeIDs.length > 2) {
82652         _geometry = "point";
82653         return actionStraightenNodes(_nodeIDs, context.projection);
82654       } else if (_wayIDs.length > 0 && (_nodeIDs.length === 0 || _nodeIDs.length === 2)) {
82655         var startNodeIDs = [];
82656         var endNodeIDs = [];
82657         for (var i3 = 0; i3 < selectedIDs.length; i3++) {
82658           var entity = context.entity(selectedIDs[i3]);
82659           if (entity.type === "node") {
82660             continue;
82661           } else if (entity.type !== "way" || entity.isClosed()) {
82662             return null;
82663           }
82664           startNodeIDs.push(entity.first());
82665           endNodeIDs.push(entity.last());
82666         }
82667         startNodeIDs = startNodeIDs.filter(function(n3) {
82668           return startNodeIDs.indexOf(n3) === startNodeIDs.lastIndexOf(n3);
82669         });
82670         endNodeIDs = endNodeIDs.filter(function(n3) {
82671           return endNodeIDs.indexOf(n3) === endNodeIDs.lastIndexOf(n3);
82672         });
82673         if (utilArrayDifference(startNodeIDs, endNodeIDs).length + utilArrayDifference(endNodeIDs, startNodeIDs).length !== 2) return null;
82674         var wayNodeIDs = utilGetAllNodes(_wayIDs, context.graph()).map(function(node) {
82675           return node.id;
82676         });
82677         if (wayNodeIDs.length <= 2) return null;
82678         if (_nodeIDs.length === 2 && (wayNodeIDs.indexOf(_nodeIDs[0]) === -1 || wayNodeIDs.indexOf(_nodeIDs[1]) === -1)) return null;
82679         if (_nodeIDs.length) {
82680           _extent = utilTotalExtent(_nodeIDs, context.graph());
82681         }
82682         _geometry = "line";
82683         return actionStraightenWay(selectedIDs, context.projection);
82684       }
82685       return null;
82686     }
82687     function operation2() {
82688       if (!_action) return;
82689       context.perform(_action, operation2.annotation());
82690       window.setTimeout(function() {
82691         context.validator().validate();
82692       }, 300);
82693     }
82694     operation2.available = function() {
82695       return Boolean(_action);
82696     };
82697     operation2.disabled = function() {
82698       var reason = _action.disabled(context.graph());
82699       if (reason) {
82700         return reason;
82701       } else if (_extent.percentContainedIn(context.map().extent()) < 0.8) {
82702         return "too_large";
82703       } else if (someMissing()) {
82704         return "not_downloaded";
82705       } else if (selectedIDs.some(context.hasHiddenConnections)) {
82706         return "connected_to_hidden";
82707       }
82708       return false;
82709       function someMissing() {
82710         if (context.inIntro()) return false;
82711         var osm = context.connection();
82712         if (osm) {
82713           var missing = _coords.filter(function(loc) {
82714             return !osm.isDataLoaded(loc);
82715           });
82716           if (missing.length) {
82717             missing.forEach(function(loc) {
82718               context.loadTileAtLoc(loc);
82719             });
82720             return true;
82721           }
82722         }
82723         return false;
82724       }
82725     };
82726     operation2.tooltip = function() {
82727       var disable = operation2.disabled();
82728       return disable ? _t.append("operations.straighten." + disable + "." + _amount) : _t.append("operations.straighten.description." + _geometry + (_wayIDs.length === 1 ? "" : "s"));
82729     };
82730     operation2.annotation = function() {
82731       return _t("operations.straighten.annotation." + _geometry, { n: _wayIDs.length ? _wayIDs.length : _nodeIDs.length });
82732     };
82733     operation2.id = "straighten";
82734     operation2.keys = [_t("operations.straighten.key")];
82735     operation2.title = _t.append("operations.straighten.title");
82736     operation2.behavior = behaviorOperation(context).which(operation2);
82737     return operation2;
82738   }
82739
82740   // modules/modes/select.js
82741   function modeSelect(context, selectedIDs) {
82742     var mode = {
82743       id: "select",
82744       button: "browse"
82745     };
82746     var keybinding = utilKeybinding("select");
82747     var _breatheBehavior = behaviorBreathe(context);
82748     var _modeDragNode = modeDragNode(context);
82749     var _selectBehavior;
82750     var _behaviors = [];
82751     var _operations = [];
82752     var _newFeature = false;
82753     var _follow = false;
82754     var _focusedParentWayId;
82755     var _focusedVertexIds;
82756     function singular() {
82757       if (selectedIDs && selectedIDs.length === 1) {
82758         return context.hasEntity(selectedIDs[0]);
82759       }
82760     }
82761     function selectedEntities() {
82762       return selectedIDs.map(function(id2) {
82763         return context.hasEntity(id2);
82764       }).filter(Boolean);
82765     }
82766     function checkSelectedIDs() {
82767       var ids = [];
82768       if (Array.isArray(selectedIDs)) {
82769         ids = selectedIDs.filter(function(id2) {
82770           return context.hasEntity(id2);
82771         });
82772       }
82773       if (!ids.length) {
82774         context.enter(modeBrowse(context));
82775         return false;
82776       } else if (selectedIDs.length > 1 && ids.length === 1 || selectedIDs.length === 1 && ids.length > 1) {
82777         context.enter(modeSelect(context, ids));
82778         return false;
82779       }
82780       selectedIDs = ids;
82781       return true;
82782     }
82783     function parentWaysIdsOfSelection(onlyCommonParents) {
82784       var graph = context.graph();
82785       var parents = [];
82786       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
82787         var entity = context.hasEntity(selectedIDs[i3]);
82788         if (!entity || entity.geometry(graph) !== "vertex") {
82789           return [];
82790         }
82791         var currParents = graph.parentWays(entity).map(function(w2) {
82792           return w2.id;
82793         });
82794         if (!parents.length) {
82795           parents = currParents;
82796           continue;
82797         }
82798         parents = (onlyCommonParents ? utilArrayIntersection : utilArrayUnion)(parents, currParents);
82799         if (!parents.length) {
82800           return [];
82801         }
82802       }
82803       return parents;
82804     }
82805     function childNodeIdsOfSelection(onlyCommon) {
82806       var graph = context.graph();
82807       var childs = [];
82808       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
82809         var entity = context.hasEntity(selectedIDs[i3]);
82810         if (!entity || !["area", "line"].includes(entity.geometry(graph))) {
82811           return [];
82812         }
82813         var currChilds = graph.childNodes(entity).map(function(node) {
82814           return node.id;
82815         });
82816         if (!childs.length) {
82817           childs = currChilds;
82818           continue;
82819         }
82820         childs = (onlyCommon ? utilArrayIntersection : utilArrayUnion)(childs, currChilds);
82821         if (!childs.length) {
82822           return [];
82823         }
82824       }
82825       return childs;
82826     }
82827     function checkFocusedParent() {
82828       if (_focusedParentWayId) {
82829         var parents = parentWaysIdsOfSelection(true);
82830         if (parents.indexOf(_focusedParentWayId) === -1) _focusedParentWayId = null;
82831       }
82832     }
82833     function parentWayIdForVertexNavigation() {
82834       var parentIds = parentWaysIdsOfSelection(true);
82835       if (_focusedParentWayId && parentIds.indexOf(_focusedParentWayId) !== -1) {
82836         return _focusedParentWayId;
82837       }
82838       return parentIds.length ? parentIds[0] : null;
82839     }
82840     mode.selectedIDs = function(val) {
82841       if (!arguments.length) return selectedIDs;
82842       selectedIDs = val;
82843       return mode;
82844     };
82845     mode.zoomToSelected = function() {
82846       context.map().zoomToEase(selectedEntities());
82847     };
82848     mode.newFeature = function(val) {
82849       if (!arguments.length) return _newFeature;
82850       _newFeature = val;
82851       return mode;
82852     };
82853     mode.selectBehavior = function(val) {
82854       if (!arguments.length) return _selectBehavior;
82855       _selectBehavior = val;
82856       return mode;
82857     };
82858     mode.follow = function(val) {
82859       if (!arguments.length) return _follow;
82860       _follow = val;
82861       return mode;
82862     };
82863     function loadOperations() {
82864       _operations.forEach(function(operation2) {
82865         if (operation2.behavior) {
82866           context.uninstall(operation2.behavior);
82867         }
82868       });
82869       _operations = Object.values(operations_exports).map(function(o2) {
82870         return o2(context, selectedIDs);
82871       }).filter(function(o2) {
82872         return o2.id !== "delete" && o2.id !== "downgrade" && o2.id !== "copy";
82873       }).concat([
82874         // group copy/downgrade/delete operation together at the end of the list
82875         operationCopy(context, selectedIDs),
82876         operationDowngrade(context, selectedIDs),
82877         operationDelete(context, selectedIDs)
82878       ]).filter(function(operation2) {
82879         return operation2.available();
82880       });
82881       _operations.forEach(function(operation2) {
82882         if (operation2.behavior) {
82883           context.install(operation2.behavior);
82884         }
82885       });
82886       context.ui().closeEditMenu();
82887     }
82888     mode.operations = function() {
82889       return _operations;
82890     };
82891     mode.enter = function() {
82892       if (!checkSelectedIDs()) return;
82893       context.features().forceVisible(selectedIDs);
82894       _modeDragNode.restoreSelectedIDs(selectedIDs);
82895       loadOperations();
82896       if (!_behaviors.length) {
82897         if (!_selectBehavior) _selectBehavior = behaviorSelect(context);
82898         _behaviors = [
82899           behaviorPaste(context),
82900           _breatheBehavior,
82901           behaviorHover(context).on("hover", context.ui().sidebar.hoverModeSelect),
82902           _selectBehavior,
82903           behaviorLasso(context),
82904           _modeDragNode.behavior,
82905           modeDragNote(context).behavior
82906         ];
82907       }
82908       _behaviors.forEach(context.install);
82909       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on(["[", "pgup"], previousVertex).on(["]", "pgdown"], nextVertex).on(["{", uiCmd("\u2318["), "home"], firstVertex).on(["}", uiCmd("\u2318]"), "end"], lastVertex).on(uiCmd("\u21E7\u2190"), nudgeSelection([-10, 0])).on(uiCmd("\u21E7\u2191"), nudgeSelection([0, -10])).on(uiCmd("\u21E7\u2192"), nudgeSelection([10, 0])).on(uiCmd("\u21E7\u2193"), nudgeSelection([0, 10])).on(uiCmd("\u21E7\u2325\u2190"), nudgeSelection([-100, 0])).on(uiCmd("\u21E7\u2325\u2191"), nudgeSelection([0, -100])).on(uiCmd("\u21E7\u2325\u2192"), nudgeSelection([100, 0])).on(uiCmd("\u21E7\u2325\u2193"), nudgeSelection([0, 100])).on(utilKeybinding.plusKeys.map((key) => uiCmd("\u21E7" + key)), scaleSelection(1.05)).on(utilKeybinding.plusKeys.map((key) => uiCmd("\u21E7\u2325" + key)), scaleSelection(Math.pow(1.05, 5))).on(utilKeybinding.minusKeys.map((key) => uiCmd("\u21E7" + key)), scaleSelection(1 / 1.05)).on(utilKeybinding.minusKeys.map((key) => uiCmd("\u21E7\u2325" + key)), scaleSelection(1 / Math.pow(1.05, 5))).on(["\\", "pause"], focusNextParent).on(uiCmd("\u2318\u2191"), selectParent).on(uiCmd("\u2318\u2193"), selectChild).on("\u238B", esc, true);
82910       select_default2(document).call(keybinding);
82911       context.ui().sidebar.select(selectedIDs, _newFeature);
82912       context.history().on("change.select", function() {
82913         loadOperations();
82914         selectElements();
82915       }).on("undone.select", checkSelectedIDs).on("redone.select", checkSelectedIDs);
82916       context.map().on("drawn.select", selectElements).on("crossEditableZoom.select", function() {
82917         selectElements();
82918         _breatheBehavior.restartIfNeeded(context.surface());
82919       });
82920       context.map().doubleUpHandler().on("doubleUp.modeSelect", didDoubleUp);
82921       selectElements();
82922       if (_follow) {
82923         var extent = geoExtent();
82924         var graph = context.graph();
82925         selectedIDs.forEach(function(id2) {
82926           var entity = context.entity(id2);
82927           extent._extend(entity.extent(graph));
82928         });
82929         var loc = extent.center();
82930         context.map().centerEase(loc);
82931         _follow = false;
82932       }
82933       function nudgeSelection(delta) {
82934         return function() {
82935           if (!context.map().withinEditableZoom()) return;
82936           var moveOp = operationMove(context, selectedIDs);
82937           if (moveOp.disabled()) {
82938             context.ui().flash.duration(4e3).iconName("#iD-operation-" + moveOp.id).iconClass("operation disabled").label(moveOp.tooltip())();
82939           } else {
82940             context.perform(actionMove(selectedIDs, delta, context.projection), moveOp.annotation());
82941             context.validator().validate();
82942           }
82943         };
82944       }
82945       function scaleSelection(factor) {
82946         return function() {
82947           if (!context.map().withinEditableZoom()) return;
82948           let nodes = utilGetAllNodes(selectedIDs, context.graph());
82949           let isUp = factor > 1;
82950           if (nodes.length <= 1) return;
82951           let extent2 = utilTotalExtent(selectedIDs, context.graph());
82952           function scalingDisabled() {
82953             if (tooSmall()) {
82954               return "too_small";
82955             } else if (extent2.percentContainedIn(context.map().extent()) < 0.8) {
82956               return "too_large";
82957             } else if (someMissing() || selectedIDs.some(incompleteRelation)) {
82958               return "not_downloaded";
82959             } else if (selectedIDs.some(context.hasHiddenConnections)) {
82960               return "connected_to_hidden";
82961             }
82962             return false;
82963             function tooSmall() {
82964               if (isUp) return false;
82965               let dLon = Math.abs(extent2[1][0] - extent2[0][0]);
82966               let dLat = Math.abs(extent2[1][1] - extent2[0][1]);
82967               return dLon < geoMetersToLon(1, extent2[1][1]) && dLat < geoMetersToLat(1);
82968             }
82969             function someMissing() {
82970               if (context.inIntro()) return false;
82971               let osm = context.connection();
82972               if (osm) {
82973                 let missing = nodes.filter(function(n3) {
82974                   return !osm.isDataLoaded(n3.loc);
82975                 });
82976                 if (missing.length) {
82977                   missing.forEach(function(loc2) {
82978                     context.loadTileAtLoc(loc2);
82979                   });
82980                   return true;
82981                 }
82982               }
82983               return false;
82984             }
82985             function incompleteRelation(id2) {
82986               let entity = context.entity(id2);
82987               return entity.type === "relation" && !entity.isComplete(context.graph());
82988             }
82989           }
82990           const disabled = scalingDisabled();
82991           if (disabled) {
82992             let multi = selectedIDs.length === 1 ? "single" : "multiple";
82993             context.ui().flash.duration(4e3).iconName("#iD-icon-no").iconClass("operation disabled").label(_t.append("operations.scale." + disabled + "." + multi))();
82994           } else {
82995             const pivot = context.projection(extent2.center());
82996             const annotation = _t("operations.scale.annotation." + (isUp ? "up" : "down") + ".feature", { n: selectedIDs.length });
82997             context.perform(actionScale(selectedIDs, pivot, factor, context.projection), annotation);
82998             context.validator().validate();
82999           }
83000         };
83001       }
83002       function didDoubleUp(d3_event, loc2) {
83003         if (!context.map().withinEditableZoom()) return;
83004         var target = select_default2(d3_event.target);
83005         var datum2 = target.datum();
83006         var entity = datum2 && datum2.properties && datum2.properties.entity;
83007         if (!entity) return;
83008         if (entity instanceof osmWay && target.classed("target")) {
83009           var choice = geoChooseEdge(context.graph().childNodes(entity), loc2, context.projection);
83010           var prev = entity.nodes[choice.index - 1];
83011           var next = entity.nodes[choice.index];
83012           context.perform(
83013             actionAddMidpoint({ loc: choice.loc, edge: [prev, next] }, osmNode()),
83014             _t("operations.add.annotation.vertex")
83015           );
83016           context.validator().validate();
83017         } else if (entity.type === "midpoint") {
83018           context.perform(
83019             actionAddMidpoint({ loc: entity.loc, edge: entity.edge }, osmNode()),
83020             _t("operations.add.annotation.vertex")
83021           );
83022           context.validator().validate();
83023         }
83024       }
83025       function selectElements() {
83026         if (!checkSelectedIDs()) return;
83027         var surface = context.surface();
83028         surface.selectAll(".selected-member").classed("selected-member", false);
83029         surface.selectAll(".selected").classed("selected", false);
83030         surface.selectAll(".related").classed("related", false);
83031         checkFocusedParent();
83032         if (_focusedParentWayId) {
83033           surface.selectAll(utilEntitySelector([_focusedParentWayId])).classed("related", true);
83034         }
83035         if (context.map().withinEditableZoom()) {
83036           surface.selectAll(utilDeepMemberSelector(
83037             selectedIDs,
83038             context.graph(),
83039             true
83040             /* skipMultipolgonMembers */
83041           )).classed("selected-member", true);
83042           surface.selectAll(utilEntityOrDeepMemberSelector(selectedIDs, context.graph())).classed("selected", true);
83043         }
83044       }
83045       function esc() {
83046         if (context.container().select(".combobox").size()) return;
83047         context.enter(modeBrowse(context));
83048       }
83049       function firstVertex(d3_event) {
83050         d3_event.preventDefault();
83051         var entity = singular();
83052         var parentId = parentWayIdForVertexNavigation();
83053         var way;
83054         if (entity && entity.type === "way") {
83055           way = entity;
83056         } else if (parentId) {
83057           way = context.entity(parentId);
83058         }
83059         _focusedParentWayId = way && way.id;
83060         if (way) {
83061           context.enter(
83062             mode.selectedIDs([way.first()]).follow(true)
83063           );
83064         }
83065       }
83066       function lastVertex(d3_event) {
83067         d3_event.preventDefault();
83068         var entity = singular();
83069         var parentId = parentWayIdForVertexNavigation();
83070         var way;
83071         if (entity && entity.type === "way") {
83072           way = entity;
83073         } else if (parentId) {
83074           way = context.entity(parentId);
83075         }
83076         _focusedParentWayId = way && way.id;
83077         if (way) {
83078           context.enter(
83079             mode.selectedIDs([way.last()]).follow(true)
83080           );
83081         }
83082       }
83083       function previousVertex(d3_event) {
83084         d3_event.preventDefault();
83085         var parentId = parentWayIdForVertexNavigation();
83086         _focusedParentWayId = parentId;
83087         if (!parentId) return;
83088         var way = context.entity(parentId);
83089         var length2 = way.nodes.length;
83090         var curr = way.nodes.indexOf(selectedIDs[0]);
83091         var index = -1;
83092         if (curr > 0) {
83093           index = curr - 1;
83094         } else if (way.isClosed()) {
83095           index = length2 - 2;
83096         }
83097         if (index !== -1) {
83098           context.enter(
83099             mode.selectedIDs([way.nodes[index]]).follow(true)
83100           );
83101         }
83102       }
83103       function nextVertex(d3_event) {
83104         d3_event.preventDefault();
83105         var parentId = parentWayIdForVertexNavigation();
83106         _focusedParentWayId = parentId;
83107         if (!parentId) return;
83108         var way = context.entity(parentId);
83109         var length2 = way.nodes.length;
83110         var curr = way.nodes.indexOf(selectedIDs[0]);
83111         var index = -1;
83112         if (curr < length2 - 1) {
83113           index = curr + 1;
83114         } else if (way.isClosed()) {
83115           index = 0;
83116         }
83117         if (index !== -1) {
83118           context.enter(
83119             mode.selectedIDs([way.nodes[index]]).follow(true)
83120           );
83121         }
83122       }
83123       function focusNextParent(d3_event) {
83124         d3_event.preventDefault();
83125         var parents = parentWaysIdsOfSelection(true);
83126         if (!parents || parents.length < 2) return;
83127         var index = parents.indexOf(_focusedParentWayId);
83128         if (index < 0 || index > parents.length - 2) {
83129           _focusedParentWayId = parents[0];
83130         } else {
83131           _focusedParentWayId = parents[index + 1];
83132         }
83133         var surface = context.surface();
83134         surface.selectAll(".related").classed("related", false);
83135         if (_focusedParentWayId) {
83136           surface.selectAll(utilEntitySelector([_focusedParentWayId])).classed("related", true);
83137         }
83138       }
83139       function selectParent(d3_event) {
83140         d3_event.preventDefault();
83141         var currentSelectedIds = mode.selectedIDs();
83142         var parentIds = _focusedParentWayId ? [_focusedParentWayId] : parentWaysIdsOfSelection(false);
83143         if (!parentIds.length) return;
83144         context.enter(
83145           mode.selectedIDs(parentIds)
83146         );
83147         _focusedVertexIds = currentSelectedIds;
83148       }
83149       function selectChild(d3_event) {
83150         d3_event.preventDefault();
83151         var currentSelectedIds = mode.selectedIDs();
83152         var childIds = _focusedVertexIds ? _focusedVertexIds.filter((id2) => context.hasEntity(id2)) : childNodeIdsOfSelection(true);
83153         if (!childIds || !childIds.length) return;
83154         if (currentSelectedIds.length === 1) _focusedParentWayId = currentSelectedIds[0];
83155         context.enter(
83156           mode.selectedIDs(childIds)
83157         );
83158       }
83159     };
83160     mode.exit = function() {
83161       _newFeature = false;
83162       _focusedVertexIds = null;
83163       _operations.forEach(function(operation2) {
83164         if (operation2.behavior) {
83165           context.uninstall(operation2.behavior);
83166         }
83167       });
83168       _operations = [];
83169       _behaviors.forEach(context.uninstall);
83170       select_default2(document).call(keybinding.unbind);
83171       context.ui().closeEditMenu();
83172       context.history().on("change.select", null).on("undone.select", null).on("redone.select", null);
83173       var surface = context.surface();
83174       surface.selectAll(".selected-member").classed("selected-member", false);
83175       surface.selectAll(".selected").classed("selected", false);
83176       surface.selectAll(".highlighted").classed("highlighted", false);
83177       surface.selectAll(".related").classed("related", false);
83178       context.map().on("drawn.select", null);
83179       context.ui().sidebar.hide();
83180       context.features().forceVisible([]);
83181       var entity = singular();
83182       if (_newFeature && entity && entity.type === "relation" && // no tags
83183       Object.keys(entity.tags).length === 0 && // no parent relations
83184       context.graph().parentRelations(entity).length === 0 && // no members or one member with no role
83185       (entity.members.length === 0 || entity.members.length === 1 && !entity.members[0].role)) {
83186         var deleteAction = actionDeleteRelation(
83187           entity.id,
83188           true
83189           /* don't delete untagged members */
83190         );
83191         context.perform(deleteAction, _t("operations.delete.annotation.relation"));
83192         context.validator().validate();
83193       }
83194     };
83195     return mode;
83196   }
83197
83198   // modules/behavior/lasso.js
83199   function behaviorLasso(context) {
83200     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
83201     var behavior = function(selection2) {
83202       var lasso;
83203       function pointerdown(d3_event) {
83204         var button = 0;
83205         if (d3_event.button === button && d3_event.shiftKey === true) {
83206           lasso = null;
83207           select_default2(window).on(_pointerPrefix + "move.lasso", pointermove).on(_pointerPrefix + "up.lasso", pointerup);
83208           d3_event.stopPropagation();
83209         }
83210       }
83211       function pointermove() {
83212         if (!lasso) {
83213           lasso = uiLasso(context);
83214           context.surface().call(lasso);
83215         }
83216         lasso.p(context.map().mouse());
83217       }
83218       function normalize2(a2, b2) {
83219         return [
83220           [Math.min(a2[0], b2[0]), Math.min(a2[1], b2[1])],
83221           [Math.max(a2[0], b2[0]), Math.max(a2[1], b2[1])]
83222         ];
83223       }
83224       function lassoed() {
83225         if (!lasso) return [];
83226         var graph = context.graph();
83227         var limitToNodes;
83228         if (context.map().editableDataEnabled(
83229           true
83230           /* skipZoomCheck */
83231         ) && context.map().isInWideSelection()) {
83232           limitToNodes = new Set(utilGetAllNodes(context.selectedIDs(), graph));
83233         } else if (!context.map().editableDataEnabled()) {
83234           return [];
83235         }
83236         var bounds = lasso.extent().map(context.projection.invert);
83237         var extent = geoExtent(normalize2(bounds[0], bounds[1]));
83238         var intersects2 = context.history().intersects(extent).filter(function(entity) {
83239           return entity.type === "node" && (!limitToNodes || limitToNodes.has(entity)) && geoPointInPolygon(context.projection(entity.loc), lasso.coordinates) && !context.features().isHidden(entity, graph, entity.geometry(graph));
83240         });
83241         intersects2.sort(function(node1, node2) {
83242           var parents1 = graph.parentWays(node1);
83243           var parents2 = graph.parentWays(node2);
83244           if (parents1.length && parents2.length) {
83245             var sharedParents = utilArrayIntersection(parents1, parents2);
83246             if (sharedParents.length) {
83247               var sharedParentNodes = sharedParents[0].nodes;
83248               return sharedParentNodes.indexOf(node1.id) - sharedParentNodes.indexOf(node2.id);
83249             } else {
83250               return Number(parents1[0].id.slice(1)) - Number(parents2[0].id.slice(1));
83251             }
83252           } else if (parents1.length || parents2.length) {
83253             return parents1.length - parents2.length;
83254           }
83255           return node1.loc[0] - node2.loc[0];
83256         });
83257         return intersects2.map(function(entity) {
83258           return entity.id;
83259         });
83260       }
83261       function pointerup() {
83262         select_default2(window).on(_pointerPrefix + "move.lasso", null).on(_pointerPrefix + "up.lasso", null);
83263         if (!lasso) return;
83264         var ids = lassoed();
83265         lasso.close();
83266         if (ids.length) {
83267           context.enter(modeSelect(context, ids));
83268         }
83269       }
83270       selection2.on(_pointerPrefix + "down.lasso", pointerdown);
83271     };
83272     behavior.off = function(selection2) {
83273       selection2.on(_pointerPrefix + "down.lasso", null);
83274     };
83275     return behavior;
83276   }
83277
83278   // modules/modes/browse.js
83279   function modeBrowse(context) {
83280     var mode = {
83281       button: "browse",
83282       id: "browse",
83283       title: _t.append("modes.browse.title"),
83284       description: _t.append("modes.browse.description")
83285     };
83286     var sidebar;
83287     var _selectBehavior;
83288     var _behaviors = [];
83289     mode.selectBehavior = function(val) {
83290       if (!arguments.length) return _selectBehavior;
83291       _selectBehavior = val;
83292       return mode;
83293     };
83294     mode.enter = function() {
83295       if (!_behaviors.length) {
83296         if (!_selectBehavior) _selectBehavior = behaviorSelect(context);
83297         _behaviors = [
83298           behaviorPaste(context),
83299           behaviorHover(context).on("hover", context.ui().sidebar.hover),
83300           _selectBehavior,
83301           behaviorLasso(context),
83302           modeDragNode(context).behavior,
83303           modeDragNote(context).behavior
83304         ];
83305       }
83306       _behaviors.forEach(context.install);
83307       if (document.activeElement && document.activeElement.blur) {
83308         document.activeElement.blur();
83309       }
83310       if (sidebar) {
83311         context.ui().sidebar.show(sidebar);
83312       } else {
83313         context.ui().sidebar.select(null);
83314       }
83315     };
83316     mode.exit = function() {
83317       context.ui().sidebar.hover.cancel();
83318       _behaviors.forEach(context.uninstall);
83319       if (sidebar) {
83320         context.ui().sidebar.hide();
83321       }
83322     };
83323     mode.sidebar = function(_2) {
83324       if (!arguments.length) return sidebar;
83325       sidebar = _2;
83326       return mode;
83327     };
83328     mode.operations = function() {
83329       return [operationPaste(context)];
83330     };
83331     return mode;
83332   }
83333
83334   // modules/behavior/add_way.js
83335   function behaviorAddWay(context) {
83336     var dispatch14 = dispatch_default("start", "startFromWay", "startFromNode");
83337     var draw = behaviorDraw(context);
83338     function behavior(surface) {
83339       draw.on("click", function() {
83340         dispatch14.apply("start", this, arguments);
83341       }).on("clickWay", function() {
83342         dispatch14.apply("startFromWay", this, arguments);
83343       }).on("clickNode", function() {
83344         dispatch14.apply("startFromNode", this, arguments);
83345       }).on("cancel", behavior.cancel).on("finish", behavior.cancel);
83346       context.map().dblclickZoomEnable(false);
83347       surface.call(draw);
83348     }
83349     behavior.off = function(surface) {
83350       surface.call(draw.off);
83351     };
83352     behavior.cancel = function() {
83353       window.setTimeout(function() {
83354         context.map().dblclickZoomEnable(true);
83355       }, 1e3);
83356       context.enter(modeBrowse(context));
83357     };
83358     return utilRebind(behavior, dispatch14, "on");
83359   }
83360
83361   // modules/behavior/hash.js
83362   function behaviorHash(context) {
83363     var _cachedHash = null;
83364     var _latitudeLimit = 90 - 1e-8;
83365     function computedHashParameters() {
83366       var map2 = context.map();
83367       var center = map2.center();
83368       var zoom = map2.zoom();
83369       var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
83370       var oldParams = utilObjectOmit(
83371         utilStringQs(window.location.hash),
83372         ["comment", "source", "hashtags", "walkthrough"]
83373       );
83374       var newParams = {};
83375       delete oldParams.id;
83376       var selected = context.selectedIDs().filter(function(id2) {
83377         return context.hasEntity(id2);
83378       });
83379       if (selected.length) {
83380         newParams.id = selected.join(",");
83381       } else if (context.selectedNoteID()) {
83382         newParams.id = "note/".concat(context.selectedNoteID());
83383       }
83384       newParams.map = zoom.toFixed(2) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3);
83385       return Object.assign(oldParams, newParams);
83386     }
83387     function computedHash() {
83388       return "#" + utilQsString(computedHashParameters(), true);
83389     }
83390     function computedTitle(includeChangeCount) {
83391       var baseTitle = context.documentTitleBase() || "iD";
83392       var contextual;
83393       var changeCount;
83394       var titleID;
83395       var selected = context.selectedIDs().filter(function(id2) {
83396         return context.hasEntity(id2);
83397       });
83398       if (selected.length) {
83399         var firstLabel = utilDisplayLabel(context.entity(selected[0]), context.graph());
83400         if (selected.length > 1) {
83401           contextual = _t("title.labeled_and_more", {
83402             labeled: firstLabel,
83403             count: selected.length - 1
83404           });
83405         } else {
83406           contextual = firstLabel;
83407         }
83408         titleID = "context";
83409       }
83410       if (includeChangeCount) {
83411         changeCount = context.history().difference().summary().length;
83412         if (changeCount > 0) {
83413           titleID = contextual ? "changes_context" : "changes";
83414         }
83415       }
83416       if (titleID) {
83417         return _t("title.format." + titleID, {
83418           changes: changeCount,
83419           base: baseTitle,
83420           context: contextual
83421         });
83422       }
83423       return baseTitle;
83424     }
83425     function updateTitle(includeChangeCount) {
83426       if (!context.setsDocumentTitle()) return;
83427       var newTitle = computedTitle(includeChangeCount);
83428       if (document.title !== newTitle) {
83429         document.title = newTitle;
83430       }
83431     }
83432     function updateHashIfNeeded() {
83433       if (context.inIntro()) return;
83434       var latestHash = computedHash();
83435       if (_cachedHash !== latestHash) {
83436         _cachedHash = latestHash;
83437         window.history.replaceState(null, computedTitle(
83438           false
83439           /* includeChangeCount */
83440         ), latestHash);
83441         updateTitle(
83442           true
83443           /* includeChangeCount */
83444         );
83445         const q2 = utilStringQs(latestHash);
83446         if (q2.map) {
83447           corePreferences("map-location", q2.map);
83448         }
83449       }
83450     }
83451     var _throttledUpdate = throttle_default(updateHashIfNeeded, 500);
83452     var _throttledUpdateTitle = throttle_default(function() {
83453       updateTitle(
83454         true
83455         /* includeChangeCount */
83456       );
83457     }, 500);
83458     function hashchange() {
83459       if (window.location.hash === _cachedHash) return;
83460       _cachedHash = window.location.hash;
83461       var q2 = utilStringQs(_cachedHash);
83462       var mapArgs = (q2.map || "").split("/").map(Number);
83463       if (mapArgs.length < 3 || mapArgs.some(isNaN)) {
83464         updateHashIfNeeded();
83465       } else {
83466         if (_cachedHash === computedHash()) return;
83467         var mode = context.mode();
83468         context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]);
83469         if (q2.id && mode) {
83470           var ids = q2.id.split(",").filter(function(id2) {
83471             return context.hasEntity(id2) || id2.startsWith("note/");
83472           });
83473           if (ids.length && ["browse", "select-note", "select"].includes(mode.id)) {
83474             if (ids.length === 1 && ids[0].startsWith("note/")) {
83475               context.enter(modeSelectNote(context, ids[0]));
83476             } else if (!utilArrayIdentical(mode.selectedIDs(), ids)) {
83477               context.enter(modeSelect(context, ids));
83478             }
83479             return;
83480           }
83481         }
83482         var center = context.map().center();
83483         var dist = geoSphericalDistance(center, [mapArgs[2], mapArgs[1]]);
83484         var maxdist = 500;
83485         if (mode && mode.id.match(/^draw/) !== null && dist > maxdist) {
83486           context.enter(modeBrowse(context));
83487           return;
83488         }
83489       }
83490     }
83491     function behavior() {
83492       context.map().on("move.behaviorHash", _throttledUpdate);
83493       context.history().on("change.behaviorHash", _throttledUpdateTitle);
83494       context.on("enter.behaviorHash", _throttledUpdate);
83495       select_default2(window).on("hashchange.behaviorHash", hashchange);
83496       var q2 = utilStringQs(window.location.hash);
83497       if (q2.id) {
83498         const selectIds = q2.id.split(",");
83499         if (selectIds.length === 1 && selectIds[0].startsWith("note/")) {
83500           const noteId = selectIds[0].split("/")[1];
83501           context.zoomToNote(noteId, !q2.map);
83502         } else {
83503           context.zoomToEntities(
83504             // convert ids to short form id: node/123 -> n123
83505             selectIds.map((id2) => id2.replace(/([nwr])[^/]*\//, "$1")),
83506             !q2.map
83507           );
83508         }
83509       }
83510       if (q2.walkthrough === "true") {
83511         behavior.startWalkthrough = true;
83512       }
83513       if (q2.map) {
83514         behavior.hadLocation = true;
83515       } else if (!q2.id && corePreferences("map-location")) {
83516         const mapArgs = corePreferences("map-location").split("/").map(Number);
83517         context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]);
83518         updateHashIfNeeded();
83519         behavior.hadLocation = true;
83520       }
83521       hashchange();
83522       updateTitle(false);
83523     }
83524     behavior.off = function() {
83525       _throttledUpdate.cancel();
83526       _throttledUpdateTitle.cancel();
83527       context.map().on("move.behaviorHash", null);
83528       context.on("enter.behaviorHash", null);
83529       select_default2(window).on("hashchange.behaviorHash", null);
83530       window.location.hash = "";
83531     };
83532     return behavior;
83533   }
83534
83535   // node_modules/d3-brush/src/brush.js
83536   var { abs: abs2, max: max2, min: min2 } = Math;
83537   function number1(e3) {
83538     return [+e3[0], +e3[1]];
83539   }
83540   function number22(e3) {
83541     return [number1(e3[0]), number1(e3[1])];
83542   }
83543   var X3 = {
83544     name: "x",
83545     handles: ["w", "e"].map(type),
83546     input: function(x2, e3) {
83547       return x2 == null ? null : [[+x2[0], e3[0][1]], [+x2[1], e3[1][1]]];
83548     },
83549     output: function(xy) {
83550       return xy && [xy[0][0], xy[1][0]];
83551     }
83552   };
83553   var Y3 = {
83554     name: "y",
83555     handles: ["n", "s"].map(type),
83556     input: function(y2, e3) {
83557       return y2 == null ? null : [[e3[0][0], +y2[0]], [e3[1][0], +y2[1]]];
83558     },
83559     output: function(xy) {
83560       return xy && [xy[0][1], xy[1][1]];
83561     }
83562   };
83563   var XY = {
83564     name: "xy",
83565     handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(type),
83566     input: function(xy) {
83567       return xy == null ? null : number22(xy);
83568     },
83569     output: function(xy) {
83570       return xy;
83571     }
83572   };
83573   function type(t2) {
83574     return { type: t2 };
83575   }
83576
83577   // modules/index.js
83578   var debug = false;
83579   var setDebug = (newValue) => {
83580     debug = newValue;
83581   };
83582   var d3 = {
83583     dispatch: dispatch_default,
83584     geoMercator: mercator_default,
83585     geoProjection: projection,
83586     polygonArea: area_default3,
83587     polygonCentroid: centroid_default2,
83588     select: select_default2,
83589     selectAll: selectAll_default2,
83590     timerFlush
83591   };
83592
83593   // modules/id.js
83594   window.requestIdleCallback = window.requestIdleCallback || function(cb) {
83595     var start2 = Date.now();
83596     return window.requestAnimationFrame(function() {
83597       cb({
83598         didTimeout: false,
83599         timeRemaining: function() {
83600           return Math.max(0, 50 - (Date.now() - start2));
83601         }
83602       });
83603     });
83604   };
83605   window.cancelIdleCallback = window.cancelIdleCallback || function(id2) {
83606     window.cancelAnimationFrame(id2);
83607   };
83608   window.iD = index_exports;
83609 })();
83610 //# sourceMappingURL=iD.js.map